:root {
    --br-green: #009c3b;
    --br-yellow: #ffdf00;
    --us-blue: #0a3161;
    --us-red: #b31942;
    --primary: #009c3b;
    --secondary: #002776;
    --ink: #14181f;
    --muted: #667085;
    --line: #e6e9ef;
    --bg: #f5f7fb;
    --card: #ffffff;
    --radius: 14px;
    --shadow: 0 6px 24px rgba(16, 24, 40, 0.08);
    --shadow-sm: 0 2px 8px rgba(16, 24, 40, 0.06);
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    color: var(--ink);
    background: var(--bg);
    line-height: 1.55;
}

a { color: var(--secondary); text-decoration: none; }
a:hover { text-decoration: underline; }

img { max-width: 100%; }

h1, h2, h3, h4 { line-height: 1.2; margin: 0 0 .5em; }

.container { max-width: 1180px; margin: 0 auto; padding: 0 20px; }
.container-sm { max-width: 720px; margin: 0 auto; padding: 0 20px; }

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 11px 20px; border-radius: 10px; border: 1px solid transparent;
    font-weight: 600; font-size: 15px; cursor: pointer; transition: .15s;
    background: var(--primary); color: #fff; text-decoration: none;
}
.btn:hover { filter: brightness(.95); text-decoration: none; }
.btn-secondary { background: var(--secondary); }
.btn-outline { background: transparent; color: var(--ink); border-color: var(--line); }
.btn-outline:hover { background: #f0f2f7; }
.btn-danger { background: var(--us-red); }
.btn-ghost { background: transparent; color: var(--muted); }
.btn-sm { padding: 7px 13px; font-size: 13px; }
.btn-block { width: 100%; justify-content: center; }

/* ---------- Badges ---------- */
.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.badge-green { background: #e6f7ee; color: #067647; }
.badge-yellow { background: #fef7e0; color: #a15c07; }
.badge-red { background: #fde8ec; color: #b31942; }
.badge-blue { background: #e7edf9; color: #0a3161; }
.badge-gray { background: #eef1f6; color: #475467; }

/* ---------- Cards ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.card-pad { padding: 22px; }
.card + .card { margin-top: 18px; }

.grid { display: grid; gap: 18px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 900px) { .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; } }

.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow-sm); }
.stat .label { color: var(--muted); font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
.stat .value { font-size: 30px; font-weight: 800; margin-top: 6px; }
.stat .sub { color: var(--muted); font-size: 13px; }

/* ---------- Forms ---------- */
.form-group { margin-bottom: 16px; }
label { display: block; font-weight: 600; font-size: 14px; margin-bottom: 6px; }
input[type=text], input[type=email], input[type=password], input[type=tel], input[type=number],
input[type=date], input[type=url], select, textarea {
    width: 100%; padding: 11px 13px; border: 1px solid var(--line); border-radius: 10px;
    font-size: 15px; font-family: inherit; background: #fff; color: var(--ink);
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(0,156,59,.12); }
textarea { min-height: 92px; resize: vertical; }
.hint { color: var(--muted); font-size: 13px; margin-top: 4px; }
.form-row { display: flex; gap: 14px; flex-wrap: wrap; }
.form-row > * { flex: 1; min-width: 160px; }

/* ---------- Tables ---------- */
.table { width: 100%; border-collapse: collapse; background: #fff; }
.table th, .table td { text-align: left; padding: 12px 14px; border-bottom: 1px solid var(--line); font-size: 14px; }
.table th { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .03em; background: #fafbfd; }
.table tbody tr:hover { background: #fafbfd; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); }

/* ---------- Flash ---------- */
.flash { padding: 13px 16px; border-radius: 10px; margin-bottom: 16px; font-weight: 500; }
.flash-success { background: #e6f7ee; color: #067647; border: 1px solid #a6e5c4; }
.flash-error { background: #fde8ec; color: #b31942; border: 1px solid #f5b5c3; }
.flash-info { background: #e7edf9; color: #0a3161; border: 1px solid #b9caea; }

/* ---------- App shell ---------- */
.shell { display: flex; min-height: 100vh; }
.sidebar {
    width: 250px; background: var(--secondary); color: #fff; flex-shrink: 0;
    display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
}
.sidebar .brand { padding: 20px 22px; font-weight: 800; font-size: 20px; display: flex; align-items: center; gap: 10px; border-bottom: 1px solid rgba(255,255,255,.12); }
.sidebar nav { padding: 14px 12px; flex: 1; overflow-y: auto; }
.sidebar nav a {
    display: flex; align-items: center; gap: 11px; color: #d5ddec; padding: 11px 14px;
    border-radius: 9px; font-weight: 500; font-size: 15px; margin-bottom: 3px;
}
.sidebar nav a:hover { background: rgba(255,255,255,.10); color: #fff; text-decoration: none; }
.sidebar nav a.active { background: var(--primary); color: #fff; }
.sidebar .foot { padding: 14px; border-top: 1px solid rgba(255,255,255,.12); font-size: 13px; color: #b9c4d8; }
.flag-strip { height: 4px; background: linear-gradient(90deg, var(--br-green) 0 33%, var(--br-yellow) 33% 50%, var(--us-blue) 50% 75%, var(--us-red) 75% 100%); }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { background: #fff; border-bottom: 1px solid var(--line); padding: 14px 26px; display: flex; align-items: center; justify-content: space-between; }
.topbar h1 { font-size: 20px; margin: 0; }
.content { padding: 26px; flex: 1; }

.page-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; gap: 12px; flex-wrap: wrap; }
.page-head h2 { margin: 0; font-size: 22px; }

@media (max-width: 820px) {
    .sidebar { position: fixed; left: -260px; z-index: 50; transition: .2s; }
    .sidebar.open { left: 0; }
    .menu-toggle { display: inline-flex !important; }
}
.menu-toggle { display: none; }

/* ---------- Public / landing ---------- */
.public-nav { background: #fff; border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
.public-nav .inner { display: flex; align-items: center; justify-content: space-between; padding: 16px 0; }
.logo { font-weight: 800; font-size: 22px; display: flex; align-items: center; gap: 10px; color: var(--ink); }
.logo .dot { width: 12px; height: 12px; border-radius: 50%; background: linear-gradient(135deg, var(--br-green), var(--us-blue)); }
.public-nav .links a { margin-left: 22px; color: var(--ink); font-weight: 500; }

.hero { background: linear-gradient(135deg, #041e42 0%, #063f2a 100%); color: #fff; padding: 80px 0; position: relative; overflow: hidden; }
.hero:after { content:''; position:absolute; inset:0; background: radial-gradient(circle at 80% 20%, rgba(255,223,0,.15), transparent 40%); }
.hero .inner { position: relative; z-index: 2; max-width: 720px; }
.hero h1 { font-size: 46px; font-weight: 800; }
.hero p { font-size: 19px; color: #cdd7e6; margin: 18px 0 28px; }
.hero .cta { display: flex; gap: 14px; flex-wrap: wrap; }
.eyebrow { display: inline-block; background: rgba(255,255,255,.12); padding: 6px 14px; border-radius: 999px; font-size: 13px; font-weight: 600; margin-bottom: 18px; }

.section { padding: 70px 0; }
.section h2 { font-size: 32px; text-align: center; }
.section .lead { text-align: center; color: var(--muted); max-width: 640px; margin: 0 auto 44px; font-size: 17px; }

.feature { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 26px; box-shadow: var(--shadow-sm); }
.feature .ic { width: 46px; height: 46px; border-radius: 12px; background: #e6f7ee; color: var(--br-green); display: flex; align-items: center; justify-content: center; font-size: 22px; margin-bottom: 14px; }
.feature h3 { font-size: 18px; }
.feature p { color: var(--muted); font-size: 15px; margin: 0; }

.pricing-card { text-align: center; border: 2px solid var(--line); border-radius: 18px; padding: 34px; background: #fff; }
.pricing-card.highlight { border-color: var(--primary); box-shadow: var(--shadow); }
.pricing-card .price { font-size: 44px; font-weight: 800; margin: 10px 0; }
.pricing-card .price small { font-size: 16px; color: var(--muted); font-weight: 500; }
.pricing-card ul { list-style: none; padding: 0; margin: 20px 0; text-align: left; }
.pricing-card li { padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 15px; }
.pricing-card li:before { content: '✓'; color: var(--br-green); font-weight: 800; margin-right: 8px; }

.footer { background: #041e42; color: #b9c4d8; padding: 40px 0; text-align: center; }

/* auth box */
.auth-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; background: linear-gradient(135deg, #041e42, #063f2a); }
.auth-box { background: #fff; border-radius: 18px; padding: 38px; width: 100%; max-width: 420px; box-shadow: var(--shadow); }
.auth-box .logo { justify-content: center; margin-bottom: 8px; }
.auth-box h1 { text-align: center; font-size: 22px; }
.auth-box .sub { text-align: center; color: var(--muted); margin-bottom: 24px; }

.text-muted { color: var(--muted); }
.text-right { text-align: right; }
.mt-0 { margin-top: 0; } .mt-1 { margin-top: 8px; } .mt-2 { margin-top: 16px; } .mt-3 { margin-top: 24px; }
.mb-0 { margin-bottom: 0; } .mb-2 { margin-bottom: 16px; } .mb-3 { margin-bottom: 24px; }
.flex { display: flex; } .items-center { align-items: center; } .justify-between { justify-content: space-between; } .gap { gap: 12px; }
.flex-wrap { flex-wrap: wrap; }
.empty { text-align: center; padding: 48px 20px; color: var(--muted); }
.empty .ic { font-size: 40px; margin-bottom: 10px; }

/* invoice item rows */
.item-row td { vertical-align: top; }
.item-thumb { width: 44px; height: 44px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); }
.item-thumb-empty { display: inline-flex; align-items: center; justify-content: center; font-size: 20px; background: var(--bg, #f5f5f5); color: var(--muted, #999); }
.totals { max-width: 340px; margin-left: auto; }
.totals .line { display: flex; justify-content: space-between; padding: 8px 0; }
.totals .line.total { border-top: 2px solid var(--ink); font-size: 20px; font-weight: 800; margin-top: 6px; padding-top: 12px; }

/* barcode scanner modal */
.modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.55); display: none; align-items: center; justify-content: center; z-index: 100; padding: 16px; }
.modal-backdrop.open { display: flex; }
.modal { background: #fff; border-radius: 16px; width: 100%; max-width: 480px; overflow: hidden; }
.modal .head { padding: 16px 20px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; }
.modal .body { padding: 20px; }
#reader { width: 100%; border-radius: 10px; overflow: hidden; }

/* conversation thread (chat) */
.conv-thread {
    overflow-y: auto;
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 10px;
    margin-bottom: 12px;
    background: #fafbfc;
}
.conv-day-sep {
    text-align: center;
    margin: 8px 0 10px;
}
.conv-day-sep span {
    display: inline-block;
    font-size: 11px;
    font-weight: 600;
    color: var(--muted);
    background: #eef0f3;
    padding: 3px 10px;
    border-radius: 999px;
}
.conv-row {
    display: flex;
    flex-direction: column;
    margin-bottom: 10px;
}
.conv-row--start { align-items: flex-start; }
.conv-row--end { align-items: flex-end; }
.conv-bubble {
    max-width: 92%;
    padding: 8px 12px;
    border-radius: 10px;
    font-size: 13px;
    line-height: 1.45;
    word-break: break-word;
}
.conv-bubble--staff { background: #e7edf9; color: #0a3161; }
.conv-bubble--client { background: #e6f7ee; color: #067647; }
.conv-meta {
    font-size: 11px;
    color: var(--muted);
    margin-top: 3px;
}
.conv-panel {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--line);
}
.conv-panel__title {
    font-size: 12px;
    font-weight: 600;
    color: var(--muted);
    margin-bottom: 8px;
}
.conv-reply {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid var(--line);
}
.conv-panel .conv-reply {
    border-top: none;
    padding-top: 0;
}
.conv-panel:not(:has(.conv-thread)) .conv-reply {
    margin-top: 0;
    padding-top: 0;
    border-top: none;
}
.modal-conversation {
    max-width: 560px;
}
.card[id^="item-"] { scroll-margin-top: 16px; }
