:root {
    --navy: #0b1c33;
    --navy-2: #132844;
    --ink: #122033;
    --muted: #7d8b9e;
    --line: #e7edf4;
    --bg: #f4f7fb;
    --white: #ffffff;
    --teal: #12b981;
    --green: #16a34a;
    --green-bg: #e9f9ef;
    --orange: #f58220;
    --orange-hover: #d96c0c;
    --orange-bg: #fff4e8;
    --red: #ef4444;
    --red-bg: #fdecec;
    --blue: #1c7ed6;
    --blue-bg: #eaf1ff;
    --sidebar: 248px;
    --radius: 16px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
    font-family: "Segoe UI", Inter, Arial, sans-serif;
    background: var(--bg);
    color: var(--ink);
    font-size: 14px;
    line-height: 1.45;
}
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font-family: inherit; }

.app-shell { min-height: 100vh; }
.sidebar {
    width: var(--sidebar);
    background: var(--navy);
    color: #fff;
    position: fixed;
    inset: 0 auto 0 0;
    display: flex;
    flex-direction: column;
    z-index: 40;
}
.sidebar-brand {
    padding: 14px 14px 6px;
}
.brand-logo {
    display: block;
    width: 100%;
    background: #fff;
    border-radius: 12px;
    padding: 8px 10px 6px;
}
.brand-logo img { width: 100%; height: auto; display: block; }
.logo-mark {
    width: 36px; height: 36px; border-radius: 10px;
    background: var(--teal); color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-weight: 800; font-size: 18px; flex-shrink: 0;
}
.site-chip {
    margin: 10px 14px 8px;
    background: #132844;
    border: 1px solid #23466e;
    border-radius: 12px;
    padding: 10px 12px;
    display: flex; gap: 10px; align-items: center;
}
.site-chip .pin {
    width: 28px; height: 28px; border-radius: 8px;
    background: rgba(245,130,32,.18); color: var(--orange);
    display: flex; align-items: center; justify-content: center; font-size: 14px;
}
.site-chip b { display: block; font-size: 12.5px; font-weight: 600; }
.site-chip small { color: #93a4bb; font-size: 11px; }
.sidebar-nav { padding: 6px 10px 16px; overflow-y: auto; flex: 1; }
.nav-link {
    display: flex; align-items: center; gap: 10px;
    color: #c5d0de; padding: 9px 12px; border-radius: 10px;
    margin-bottom: 2px; font-size: 13.5px; font-weight: 500;
}
.nav-link svg { width: 18px; height: 18px; flex-shrink: 0; opacity: .85; }
.nav-link:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav-link.active { background: #fff; color: var(--navy); font-weight: 700; }
.nav-link.active svg { opacity: 1; }
.nav-badge {
    margin-left: auto; background: #ef4444; color: #fff;
    min-width: 18px; height: 18px; border-radius: 999px;
    font-size: 10px; display: inline-flex; align-items: center; justify-content: center;
    padding: 0 5px; font-weight: 700;
}
.nav-dot { margin-left: auto; width: 8px; height: 8px; border-radius: 50%; background: var(--orange); }
.sidebar-user {
    margin: 8px 12px 14px; background: #102743; border-radius: 14px;
    padding: 10px; display: flex; align-items: center; gap: 10px;
}
.avatar {
    width: 34px; height: 34px; border-radius: 50%;
    background: var(--teal); color: #fff; font-weight: 800; font-size: 12px;
    display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.sidebar-user b { display: block; font-size: 12.5px; }
.sidebar-user small { color: #93a4bb; font-size: 11px; }
.sidebar-user form { margin-left: auto; }
.sidebar-user button {
    background: transparent; border: 0; color: #93a4bb; cursor: pointer;
    display: inline-flex; align-items: center; justify-content: center; padding: 0;
}

.main-wrap { margin-left: var(--sidebar); min-height: 100vh; }
.topbar {
    position: sticky; top: 0; z-index: 20;
    background: var(--bg);
    display: flex; align-items: center; gap: 16px;
    padding: 14px 22px 8px;
}
.back-btn {
    display: inline-flex; align-items: center; gap: 4px; flex-shrink: 0;
    height: 36px; padding: 0 12px 0 8px; border-radius: 10px;
    border: 1px solid var(--line); background: #fff; color: var(--navy);
    font-weight: 700; font-size: 13px;
}
.back-btn:hover { border-color: #c5d0de; }
.topbar-title { min-width: 180px; }
.topbar-title h1 { margin: 0; font-size: 18px; color: var(--navy); }
.topbar-title p { margin: 2px 0 0; color: var(--muted); font-size: 12px; }
.search {
    flex: 1; max-width: 460px; background: #fff; border: 1px solid var(--line);
    border-radius: 999px; display: flex; align-items: center; gap: 8px; padding: 0 14px;
    height: 40px; color: var(--muted);
}
.search input { border: 0; outline: 0; width: 100%; font-size: 13px; background: transparent; color: var(--ink); }
.top-filters { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.chip {
    background: #fff; border: 1px solid var(--line); border-radius: 999px;
    height: 36px; padding: 0 12px; display: inline-flex; align-items: center; gap: 6px;
    font-size: 12.5px; color: var(--ink); font-weight: 600;
}
.chip.dark { background: var(--navy); color: #fff; border-color: var(--navy); }
.chip-select {
    background: var(--navy); color: #fff; border: 1px solid var(--navy); border-radius: 999px;
    height: 36px; padding: 0 12px; font-size: 12.5px; font-weight: 600; max-width: 260px;
}
.scope-form { margin: 0; }
.page-header h2 { font-size: 18px; }
table.data { background: #fff; }
.card > table.data, .card .table-wrap table.data { border-radius: 0; }
.content { padding: 8px 22px 28px; }

.page-tools { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.page-tools .spacer { margin-left: auto; display: flex; gap: 8px; }

.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 12px; }
.kpi, .card {
    background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
}
.kpi { padding: 14px 16px; }
.kpi .label { color: var(--muted); font-size: 12px; display: flex; justify-content: space-between; align-items: center; }
.kpi .value { font-size: 22px; font-weight: 800; color: var(--navy); margin-top: 6px; letter-spacing: -.3px; }
.kpi .hint { margin-top: 6px; font-size: 12px; color: var(--muted); }
.trend { font-size: 11px; font-weight: 700; border-radius: 999px; padding: 2px 7px; }
.trend.up { color: var(--green); background: var(--green-bg); }
.trend.down { color: var(--red); background: var(--red-bg); }
.kpi.navy { background: var(--navy); color: #fff; border-color: var(--navy); }
.kpi.navy .label, .kpi.navy .hint { color: #b7c4d6; }
.kpi.navy .value { color: #fff; }

.grid-3 { display: grid; grid-template-columns: 1.3fr 1fr 1fr; gap: 12px; margin-bottom: 12px; }
.grid-2 { display: grid; grid-template-columns: 1.2fr .8fr; gap: 12px; }
.card-header {
    padding: 14px 16px 0; display: flex; align-items: center; justify-content: space-between;
    font-weight: 700; color: var(--navy);
}
.card-header a, .link { color: var(--blue); font-size: 12px; font-weight: 600; }
.card a:not(.btn):not(.icon-btn):not(.prod) { color: var(--blue); }
.card-body { padding: 14px 16px 16px; }

.bars { display: flex; align-items: flex-end; gap: 8px; height: 160px; padding-top: 8px; }
.bars .col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; justify-content: flex-end; }
.bars .bar { width: 100%; max-width: 22px; border-radius: 6px 6px 2px 2px; background: #dbe4f0; min-height: 6px; }
.bars .bar.on { background: var(--orange); }
.bars span { font-size: 10px; color: var(--muted); }

.hlist { display: flex; flex-direction: column; gap: 10px; }
.hrow { display: grid; grid-template-columns: 140px 1fr auto; gap: 8px; align-items: center; font-size: 12.5px; }
.htrack { height: 8px; background: #eef2f7; border-radius: 99px; overflow: hidden; }
.htrack i { display: block; height: 100%; background: var(--navy); border-radius: 99px; }

.donut-wrap { display: flex; align-items: center; gap: 16px; }
.donut {
    width: 120px; height: 120px; border-radius: 50%;
    background: conic-gradient(var(--teal) 0 62%, var(--orange) 62% 84%, #94a3b8 84% 100%);
    display: grid; place-items: center; position: relative;
}
.donut::after {
    content: ""; width: 78px; height: 78px; background: #fff; border-radius: 50%; position: absolute;
}
.donut b { position: relative; z-index: 1; font-size: 18px; color: var(--navy); }
.legend { font-size: 12px; color: var(--muted); display: flex; flex-direction: column; gap: 6px; }
.legend i { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; }

.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data th {
    text-align: left; font-size: 11px; letter-spacing: .4px; text-transform: uppercase;
    color: var(--muted); font-weight: 700; padding: 10px 12px; border-bottom: 1px solid var(--line);
}
table.data td { padding: 12px; border-bottom: 1px solid #f0f3f8; vertical-align: middle; }
table.data tr:hover td { background: #fafcff; }
.prod { display: flex; align-items: center; gap: 10px; }
.thumb {
    width: 42px; height: 42px; border-radius: 10px; background: #e8eef6;
    display: grid; place-items: center; font-size: 18px; flex-shrink: 0; overflow: hidden;
}
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb-ref { font-size: 11px; font-weight: 800; letter-spacing: .2px; color: var(--navy); background: #e7f2fb; }
a.alert-row { color: inherit; text-decoration: none; }
.num, table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
a.settings-card { display: block; color: inherit; }
a.settings-card:hover { border-color: var(--orange); }
a.settings-card .go { color: var(--blue); font-size: 12px; font-weight: 700; }
a.kpi { display: block; color: inherit; }
a.kpi:hover { border-color: var(--orange); }
.prod b { display: block; color: var(--navy); }
.prod small { color: var(--muted); }

.badge, .pill {
    display: inline-flex; align-items: center; gap: 4px;
    border-radius: 999px; padding: 3px 8px; font-size: 11px; font-weight: 700;
}
.badge-success, .pill.ok { background: var(--green-bg); color: var(--green); }
.badge-warning, .pill.warn { background: var(--orange-bg); color: #b45309; }
.badge-danger, .pill.bad { background: var(--red-bg); color: var(--red); }
.badge-info, .pill.info { background: var(--blue-bg); color: var(--blue); }
.badge-gray, .pill.gray { background: #f1f4f8; color: #64748b; }
.badge-navy { background: #e8eef7; color: var(--navy); }
.badge-orange { background: var(--orange-bg); color: #b45309; }

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    height: 36px; padding: 0 14px; border-radius: 10px; border: 1px solid transparent;
    font-weight: 700; font-size: 13px; cursor: pointer; background: #fff; color: var(--ink);
}
.btn-navy { background: var(--navy); color: #fff; }
.btn-navy:hover { background: #163154; color: #fff; }
.btn-primary { background: var(--orange); color: #fff; }
.btn-primary:hover { background: var(--orange-hover); color: #fff; }
.btn-teal { background: var(--teal); color: #fff; }
.btn-outline { background: #fff; border-color: var(--line); color: var(--ink); }
.btn-outline:hover { border-color: #c5d0de; }
.btn-danger { background: var(--red); color: #fff; }
.btn-sm { height: 30px; padding: 0 10px; font-size: 12px; border-radius: 8px; }
.icon-btn {
    width: 32px; height: 32px; border-radius: 8px; border: 1px solid var(--line);
    background: #fff; display: inline-flex; align-items: center; justify-content: center; cursor: pointer; color: var(--muted);
}
.ico { display: inline-flex; width: 16px; height: 16px; flex-shrink: 0; color: currentColor; }
.ico svg { width: 16px; height: 16px; display: block; }
.row-menu { position: relative; display: inline-block; }
.row-menu > summary { list-style: none; }
.row-menu > summary::-webkit-details-marker { display: none; }
.row-menu:not([open]) .row-menu-list { display: none; }
.row-menu[open] .row-menu-list {
    position: absolute; right: 0; top: calc(100% + 4px); z-index: 50;
    min-width: 168px; background: #fff; border: 1px solid var(--line);
    border-radius: 10px; padding: 4px; display: flex; flex-direction: column;
}
.row-menu-list a, .row-menu-list button {
    display: block; width: 100%; text-align: left; background: transparent; border: 0;
    border-radius: 8px; padding: 8px 10px; font: inherit; font-size: 13px; font-weight: 600;
    color: var(--ink); cursor: pointer;
}
.row-menu-list a:hover, .row-menu-list button:hover { background: #f4f7fb; }
.row-menu-list .danger { color: var(--red); }
.row-menu-list form { margin: 0; }

.tabs { display: flex; gap: 6px; background: #eef2f7; padding: 4px; border-radius: 12px; width: fit-content; }
.tabs a { padding: 7px 12px; border-radius: 9px; font-size: 13px; font-weight: 600; color: var(--muted); }
.tabs a.on { background: #fff; color: var(--navy); }

.alert { padding: 12px 14px; border-radius: 12px; margin-bottom: 12px; font-size: 13px; }
.alert-success { background: var(--green-bg); color: var(--green); }
.alert-danger { background: var(--red-bg); color: var(--red); }
.alert-info { background: var(--blue-bg); color: var(--blue); }
.empty { text-align: center; padding: 28px 12px; color: var(--muted); }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 14px; }
.form-grid .full { grid-column: 1 / -1; }
.form-group label { display: block; font-size: 12px; font-weight: 700; color: #5d6b7e; margin-bottom: 6px; }
.form-control {
    width: 100%; height: 40px; border: 1px solid var(--line); border-radius: 10px;
    padding: 0 12px; background: #fff; color: var(--ink); font-size: 13px;
}
textarea.form-control { height: auto; min-height: 88px; padding: 10px 12px; }
.form-control:focus { outline: none; border-color: var(--blue); }
.form-actions { display: flex; gap: 8px; margin-top: 14px; flex-wrap: wrap; }
.page-header { display: flex; justify-content: flex-end; align-items: center; gap: 8px; margin-bottom: 14px; }
.export-btns { display: inline-flex; gap: 6px; align-items: center; }
.facts { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 18px 16px; }
.fact span { display: block; font-size: 11px; font-weight: 700; letter-spacing: .3px; text-transform: uppercase; color: var(--muted); margin-bottom: 4px; }
.fact b { display: block; color: var(--navy); font-size: 14.5px; font-weight: 700; word-break: break-word; }
.fact.wide { grid-column: 1 / -1; }
input[type="file"].form-control { height: auto; min-height: 40px; padding: 8px 12px; }
.page-header h1, .page-header h2 { margin: 0; color: var(--navy); font-size: 20px; }
.page-header h2 { display: none; }
.sale-layout { display: grid; grid-template-columns: minmax(0, 1.45fr) minmax(260px, .7fr); gap: 16px; align-items: start; }
.sale-recap { position: sticky; top: 78px; }
details.more summary { cursor: pointer; font-weight: 700; color: var(--navy); margin: 8px 0 12px; }
.page-header p { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.filters .form-control { width: auto; min-width: 160px; }

.alert-row { display: flex; gap: 10px; padding: 10px 0; border-bottom: 1px solid #f1f4f8; font-size: 13px; }
.alert-row:last-child { border-bottom: 0; }
.dot { width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center; flex-shrink: 0; }
.dot.bad { background: var(--red-bg); color: var(--red); }
.dot.warn { background: var(--orange-bg); color: #b45309; }
.dot.ok { background: var(--green-bg); color: var(--green); }

.pay-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.pay-opt { border: 1px solid var(--line); border-radius: 12px; padding: 10px; text-align: center; font-size: 12px; font-weight: 700; cursor: pointer; background: #fff; }
.pay-opt input { display: none; }
.pay-opt:has(input:checked) { border-color: var(--navy); background: #f4f7fb; }

.recap { background: var(--navy); color: #fff; border-radius: 18px; padding: 18px; }
.recap .row { display: flex; justify-content: space-between; margin: 6px 0; color: #c5d2e2; font-size: 13px; }
.recap .total { display: flex; justify-content: space-between; margin-top: 12px; font-size: 20px; font-weight: 800; color: #fff; }
.stepper { display: flex; justify-content: space-between; gap: 8px; }
.step { flex: 1; text-align: center; font-size: 12px; color: var(--muted); }
.step .bubble { width: 28px; height: 28px; border-radius: 50%; margin: 0 auto 6px; display: grid; place-items: center; background: #e8eef6; color: var(--navy); font-weight: 800; }
.step.done .bubble { background: var(--teal); color: #fff; }
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; text-align: center; font-size: 12px; }
.cal b { color: var(--muted); font-weight: 600; }
.cal span { padding: 6px 0; border-radius: 8px; }
.cal .mark { background: var(--orange); color: #fff; font-weight: 700; }

.mobile-toggle { display: none; background: var(--navy); color: #fff; border: 0; border-radius: 8px; height: 36px; padding: 0 10px; }
@media (max-width: 1100px) {
    .kpis, .grid-3, .facts { grid-template-columns: 1fr 1fr; }
    .grid-2 { grid-template-columns: 1fr; }
    .search { display: none; }
}
@media (max-width: 860px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: none; }
    .main-wrap { margin-left: 0; }
    .mobile-toggle { display: inline-flex; }
    .kpis, .form-grid, .pay-grid, .sale-layout, .facts { grid-template-columns: 1fr; }
    .sale-recap { position: static; }
    .top-filters .avatar { display: none; }
    table.data.cards thead { display: none; }
    table.data.cards, table.data.cards tbody, table.data.cards tr, table.data.cards td { display: block; width: 100%; }
    table.data.cards tr { border: 1px solid var(--line); border-radius: 12px; margin: 0 12px 10px; padding: 6px 0; background: #fff; }
    table.data.cards td { border: 0; display: flex; justify-content: space-between; align-items: center; gap: 12px; }
    table.data.cards td.num { text-align: right; }
    table.data.cards td::before { content: attr(data-label); color: var(--muted); font-size: 11px; font-weight: 700; text-transform: uppercase; }
    table.data.cards td[data-label=""]::before { content: none; }
}

/* Auth */
.auth-split { min-height: 100vh; display: grid; grid-template-columns: 1.05fr .95fr; }
.auth-hero {
    background: radial-gradient(1200px 500px at -10% -10%, #16345c, transparent 50%), var(--navy);
    color: #fff; padding: 36px 48px; display: flex; flex-direction: column;
}
.auth-hero .brand { display: flex; gap: 12px; align-items: center; }
.auth-hero h2 { font-size: 40px; line-height: 1.15; max-width: 520px; margin: 48px 0 24px; font-weight: 750; }
.hero-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; max-width: 520px; }
.hero-stats div { background: #132844; border: 1px solid #23466e; border-radius: 14px; padding: 14px; }
.hero-stats b { display: block; font-size: 20px; }
.hero-stats span { color: #9aadc4; font-size: 12px; }
.auth-hero footer { margin-top: auto; display: flex; justify-content: space-between; color: #8ea0b8; font-size: 12px; }
.auth-panel { display: flex; align-items: center; justify-content: center; padding: 32px; background: #f7f9fc; }
.auth-box { width: 100%; max-width: 420px; }
.auth-box h1 { margin: 0 0 4px; font-size: 28px; color: var(--navy); }
.auth-box .sub { color: var(--muted); margin: 0 0 18px; }
.otp-input {
    height: 52px; font-size: 24px; font-weight: 750; letter-spacing: .42em;
    text-align: center; padding-left: .42em;
}
.auth-cancel { margin: 16px 0 0; text-align: center; font-size: 13px; }
.auth-cancel a { color: var(--blue); }
.seg { display: grid; grid-template-columns: 1fr 1fr; background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 4px; margin-bottom: 16px; }
.seg span, .seg button { border: 0; background: transparent; border-radius: 9px; height: 36px; font-weight: 700; color: var(--muted); }
.seg .on { background: #fff; color: var(--navy); border: 1px solid var(--line); }
.auth-logo-mobile { display: none; max-width: 240px; margin: 0 auto 18px; }
@media print {
    .sidebar, .topbar, .page-tools, .no-print { display: none !important; }
    .main-wrap { margin-left: 0 !important; }
    .content { padding: 0 !important; }
    .print-sheet { display: block !important; }
    body { background: #fff; }
}
.print-sheet { display: none; background: #fff; color: #122033; padding: 8px 12px 24px; }
.print-head { display: flex; justify-content: space-between; gap: 24px; align-items: flex-start; border-bottom: 2px solid #0b1c33; padding-bottom: 14px; margin-bottom: 16px; }
.print-head img { width: 180px; height: auto; }
.print-head h2 { margin: 0; font-size: 22px; color: #0b1c33; text-align: right; }
.print-meta { display: flex; justify-content: space-between; gap: 24px; margin-bottom: 16px; font-size: 13px; }
.print-meta b { display: block; margin-bottom: 4px; }
.print-sheet table { width: 100%; border-collapse: collapse; font-size: 13px; }
.print-sheet th, .print-sheet td { border-bottom: 1px solid #e7edf4; padding: 8px 6px; text-align: left; }
.print-sheet th { font-size: 11px; text-transform: uppercase; color: #7d8b9e; }
.print-sheet td.num, .print-sheet th.num { text-align: right; }
.print-totals { margin-left: auto; width: 260px; margin-top: 12px; }
.print-totals div { display: flex; justify-content: space-between; padding: 4px 0; }
.print-totals .due { font-size: 16px; font-weight: 800; border-top: 2px solid #0b1c33; margin-top: 6px; padding-top: 8px; }
.print-foot { margin-top: 28px; font-size: 11px; color: #7d8b9e; }
@media (max-width: 900px) {
    .auth-split { grid-template-columns: 1fr; }
    .auth-hero { display: none; }
    .auth-logo-mobile { display: block; }
}
