:root {
    --bg: #f3efe7;
    --ink: #1c1915;
    --muted: #6f675e;
    --line: #e4ddd2;
    --card: #fffdf9;
    --teal: #0f766e;
    --teal-d: #115e59;
    --gold: #b5812b;
    --shadow: 0 12px 40px rgba(28, 25, 21, 0.06);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: "Nirmala UI", "Segoe UI", sans-serif;
    background:
        radial-gradient(900px 280px at 100% -10%, rgba(15, 118, 110, 0.08), transparent 50%),
        var(--bg);
    color: var(--ink);
    font-size: 17px;
}

button, input, select, textarea { font-family: inherit; }

a { color: var(--teal); }
a:hover { color: var(--teal-d); }

.btn-primary {
    --bs-btn-bg: #0f766e;
    --bs-btn-border-color: #0f766e;
    --bs-btn-hover-bg: #115e59;
    --bs-btn-hover-border-color: #115e59;
    --bs-btn-active-bg: #134e4a;
    --bs-btn-active-border-color: #134e4a;
    --bs-btn-color: #fff;
    --bs-btn-hover-color: #fff;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    border-radius: 12px;
    font-weight: 700;
    padding: 9px 14px;
}

.btn-primary .ico { width: 16px; height: 16px; }

.btn-soft {
    background: #fff;
    border: 1px solid var(--line);
    color: var(--ink);
    border-radius: 12px;
    font-weight: 700;
    padding: 8px 12px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.btn-soft:hover { background: #faf7f2; color: var(--ink); }

.btn-danger-soft {
    background: #fff1f2;
    color: #9f1239;
    border: 0;
    border-radius: 12px;
    font-weight: 700;
    padding: 8px 12px;
    display: inline-flex;
    align-items: center;
    gap: 5px;
}
.btn-sm .ico { width: 14px; height: 14px; }

.form-control, .form-select {
    border-radius: 12px;
    border-color: #ddd4c6;
    min-height: 46px;
    background: #fff;
    font-size: 16.5px;
}

.form-control:focus, .form-select:focus {
    border-color: #0f766e;
    box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.15);
}

textarea.form-control { min-height: 90px; }

.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: 268px;
    background: #13221f;
    color: #e7f0ec;
    display: flex;
    flex-direction: column;
    z-index: 1040;
    overflow: auto;
}

.brand {
    display: flex;
    gap: 10px;
    align-items: center;
    padding: 18px 16px 8px;
    text-decoration: none;
    color: #fff;
}

.brand-name {
    display: block;
    font-weight: 800;
    font-size: 18px;
    line-height: 1.2;
    max-width: 180px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.brand-sub { display: block; color: #b7c7c2; font-size: 13px; }

.star-mark { width: 34px; height: 34px; display: inline-flex; color: #e7c98a; flex: 0 0 auto; }
.star-mark svg { width: 100%; height: 100%; }

.side-nav { padding: 8px 12px 18px; }
.nav-label {
    font-size: 12px;
    letter-spacing: 0.08em;
    color: #8aa39b;
    margin: 14px 12px 6px;
}
.nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    color: #d5e4df;
    text-decoration: none;
    padding: 10px 12px;
    border-radius: 12px;
    font-weight: 600;
    margin-bottom: 2px;
    font-size: 16px;
}
.nav-link:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav-link.active { background: rgba(212, 168, 83, .16); color: #f6e2b8; }
.nav-badge {
    margin-left: auto;
    background: #be123c;
    color: #fff;
    border-radius: 999px;
    padding: 1px 7px;
    font-size: 11px;
    font-style: normal;
}
.ico { width: 18px; height: 18px; flex: 0 0 auto; }

.side-user {
    margin-top: auto;
    padding: 14px 16px 18px;
    border-top: 1px solid rgba(255,255,255,.08);
    display: flex;
    gap: 10px;
    align-items: center;
}
.side-user strong { display: block; font-size: 14px; }
.side-user a { color: #e7c98a; font-size: 13px; text-decoration: none; }

.avatar {
    width: 36px;
    height: 36px;
    border-radius: 12px;
    display: grid;
    place-items: center;
    background: #24574f;
    color: #f6e2b8;
    font-weight: 800;
    flex: 0 0 auto;
}

.main { margin-left: 268px; min-width: 0; min-height: 100vh; display: flex; flex-direction: column; }
.topbar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 22px;
    position: sticky;
    top: 0;
    z-index: 1020;
    background: rgba(243, 239, 231, .9);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid rgba(228, 221, 210, .9);
}
.top-date { color: var(--muted); font-weight: 600; }
.top-actions { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.lang-switch { display: inline-flex; background: #fff; border: 1px solid var(--line); border-radius: 999px; padding: 3px; gap: 2px; }
.lang-switch button { border: 0; background: transparent; border-radius: 999px; padding: 6px 10px; font-size: .78rem; font-weight: 700; color: var(--muted); line-height: 1; }
.lang-switch button.is-on { background: #0f766e; color: #fff; }
.user-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    border: 1px solid var(--line);
    background: #fff;
    border-radius: 999px;
    padding: 4px 10px 4px 4px;
    font-weight: 700;
}
.icon-btn {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    border: 1px solid var(--line);
    background: #fff;
    display: grid;
    place-items: center;
}
.content { padding: 22px; flex: 1; }
.app-foot { padding: 8px 22px 18px; color: var(--muted); font-size: 13px; }

.page-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 12px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}
.page-head h1 { font-size: 1.7rem; font-weight: 800; margin: 0; }
.page-head p { margin: 4px 0 0; color: var(--muted); }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.panel {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 18px;
    box-shadow: var(--shadow);
}
.panel-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 16px 18px;
    border-bottom: 1px solid var(--line);
}
.panel-head h2 { font-size: 1.05rem; margin: 0; font-weight: 800; }
.panel-body { padding: 16px 18px; }
.panel-body.flush { padding: 0; }

.stat {
    display: flex;
    gap: 14px;
    padding: 18px;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 18px;
    text-decoration: none;
    color: inherit;
    height: 100%;
    box-shadow: var(--shadow);
}
.stat:hover { border-color: #c9b89a; color: inherit; transform: translateY(-2px); }
.stat .ic {
    width: 46px;
    height: 46px;
    border-radius: 14px;
    display: grid;
    place-items: center;
    background: #e7f4f2;
    color: var(--teal);
    flex: 0 0 auto;
}
.stat.gold .ic { background: #f8efdc; color: var(--gold); }
.stat.rose .ic { background: #ffe4e6; color: #be123c; }
.stat > span { display: flex; flex-direction: column; min-width: 0; }
.stat .label { display: block; color: var(--muted); font-size: 13px; }
.stat .value { display: block; font-size: 1.35rem; font-weight: 800; line-height: 1.25; white-space: nowrap; }
.stat .ic .ico { width: 22px; height: 22px; }

.table-wrap { overflow: auto; }
.table-app { margin: 0; min-width: 680px; font-size: 16px; }
.table-app thead th {
    font-size: 14px;
    color: var(--muted);
    font-weight: 700;
    background: #faf7f2;
    border-bottom: 1px solid var(--line);
    white-space: nowrap;
    padding: 12px;
}
.table-app td { vertical-align: middle; border-color: #f0ebe3; padding: 12px; }
.table-app tbody tr:hover { background: #fbfaf7; }
tr.low td { background: #fff7f8; }
.num { font-variant-numeric: tabular-nums; font-family: "Segoe UI", sans-serif; }
.muted { color: var(--muted); }
.right { text-align: right; }

.pill {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    border-radius: 999px;
    padding: 4px 10px;
    font-size: 13.5px;
    font-weight: 700;
    line-height: 1.4;
    white-space: nowrap;
}
.pill-ok { background: #d1fae5; color: #065f46; }
.pill-warn { background: #fef3c7; color: #92400e; }
.pill-bad { background: #ffe4e6; color: #9f1239; }
.pill-mute { background: #f1efe9; color: #6b645c; }
.pill .ico { width: 14px; height: 14px; }
.row-actions { display: inline-flex; align-items: center; justify-content: flex-end; gap: 10px; flex-wrap: wrap; }
.act {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-weight: 700;
    text-decoration: none;
    white-space: nowrap;
}
.act .ico { width: 16px; height: 16px; }

.alert-app { border-radius: 14px; padding: 12px 14px; margin-bottom: 14px; border: 1px solid; }
.alert-success { background: #ecfdf5; border-color: #a7f3d0; color: #065f46; }
.alert-error { background: #fff1f2; border-color: #fecdd3; color: #9f1239; }
.alert-warn { background: #fffbeb; border-color: #fde68a; color: #92400e; }

.empty { padding: 28px 16px; text-align: center; color: var(--muted); }
.pager { display: flex; gap: 6px; padding: 14px 16px 16px; flex-wrap: wrap; }
.page-link {
    min-width: 36px;
    height: 36px;
    display: inline-grid;
    place-items: center;
    border-radius: 10px;
    border: 1px solid var(--line);
    background: #fff;
    color: var(--ink);
    text-decoration: none;
    padding: 0 10px;
    font-weight: 700;
}
.page-link.is-current { background: var(--teal); color: #fff; border-color: var(--teal); }
.page-link.is-disabled { opacity: .45; }

.guide {
    background: #13221f;
    color: #f6f3ec;
    border-radius: 18px;
    padding: 16px 18px;
    margin-bottom: 16px;
}
.guide-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.guide ol { display: flex; gap: 10px; list-style: none; padding: 10px 0 0; margin: 0; flex-wrap: wrap; }
.guide li {
    background: rgba(255,255,255,.06);
    border-radius: 12px;
    padding: 8px 10px;
    font-size: 13px;
}
.guide .btn-link { color: #e7c98a; text-decoration: none; }

.bars { display: flex; align-items: flex-end; gap: 10px; height: 170px; }
.bar { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; gap: 6px; min-width: 0; }
.bar i {
    display: block;
    width: 100%;
    max-width: 42px;
    border-radius: 8px 8px 4px 4px;
    background: linear-gradient(180deg, #2dd4bf, #0f766e);
    min-height: 4px;
}
.bar em { font-style: normal; font-size: 11px; color: var(--muted); text-align: center; }
.bar b { font-size: 11px; font-weight: 700; }

.picker { position: relative; }
.picker-list {
    display: none;
    position: absolute;
    z-index: 30;
    left: 0;
    right: 0;
    top: calc(100% + 6px);
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 14px;
    box-shadow: var(--shadow);
    max-height: 280px;
    overflow: auto;
}
.picker-list.open { display: block; }
.picker-item, .picker-empty {
    width: 100%;
    text-align: left;
    border: 0;
    background: transparent;
    padding: 10px 12px;
    display: flex;
    justify-content: space-between;
    gap: 10px;
    border-bottom: 1px solid #f3efe7;
}
.picker-item:hover { background: #f6fbfa; }
.picker-item strong, .picker-item small { display: block; }
.picker-item small, .picker-empty { color: var(--muted); }
.picker-item em { font-style: normal; color: #be123c; font-weight: 700; white-space: nowrap; }
.shop-card {
    margin-top: 10px;
    padding: 12px 14px;
    border-radius: 14px;
    background: #f4faf8;
    border: 1px solid #d5ebe6;
}
.summary-card { position: sticky; top: 84px; }
.sum-row, .grand-line { display: flex; justify-content: space-between; gap: 10px; padding: 6px 0; }
.grand-line { border-top: 1px solid var(--line); margin-top: 6px; padding-top: 10px; font-size: 1.25rem; font-weight: 800; }
.btn-remove {
    border: 0;
    background: #ffe4e6;
    color: #9f1239;
    width: 34px;
    height: 34px;
    border-radius: 10px;
    font-size: 20px;
    line-height: 1;
}
.line-sku { color: var(--muted); font-size: 14px; }

.backdrop { display: none; }

.auth-shell { min-height: 100vh; display: grid; grid-template-columns: 1.05fr .95fr; }
.auth-brand {
    background:
        radial-gradient(520px 260px at 15% 8%, rgba(231, 201, 138, .35), transparent 60%),
        radial-gradient(420px 240px at 90% 90%, rgba(45, 212, 191, .16), transparent 55%),
        #13221f;
    color: #f8f4ec;
    padding: 48px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 24px;
}
.auth-brand h1 { font-size: 2.4rem; font-weight: 800; margin: 12px 0 8px; }
.auth-brand p { color: #d5e4df; max-width: 460px; }
.dev-credit {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding-top: 18px;
    border-top: 1px solid rgba(255,255,255,.12);
    max-width: 280px;
}
.dev-credit span {
    color: #b7c7c2;
    font-size: 13px;
    letter-spacing: .16em;
    text-transform: uppercase;
}
.dev-credit strong {
    color: #f6e2b8;
    font-size: 1.35rem;
    font-weight: 800;
    letter-spacing: .02em;
}
.brand-points { list-style: none; padding: 0; margin: 22px 0 0; }
.brand-points li {
    padding: 10px 0 10px 28px;
    position: relative;
    border-bottom: 1px solid rgba(255,255,255,.08);
}
.brand-points li:before {
    content: "";
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #e7c98a;
    position: absolute;
    left: 0;
    top: 16px;
}
.auth-panel { display: grid; place-items: center; padding: 28px 18px; }
.auth-card { width: min(460px, 100%); }
.auth-card h2 { font-weight: 800; margin-bottom: 6px; }

.sheet {
    position: relative;
    overflow: hidden;
    background: #fff;
    color: #1c1915;
    border: 1px solid var(--line);
    border-radius: 18px;
    padding: 28px 32px 24px;
    box-shadow: var(--shadow);
}
.sheet .star-mark { color: #b5812b; }
.inv-top, .parties { display: flex; justify-content: space-between; gap: 18px; }
.parties { display: grid; grid-template-columns: 1.4fr .8fr; margin: 8px 0 16px; }
.brand-block h1 { font-size: 28px; margin: 8px 0 4px; }
.brand-block p, .party p { margin: 0 0 3px; color: #444; }
.tagline { color: var(--teal) !important; font-weight: 700; }
.inv-logo { max-height: 64px; max-width: 180px; object-fit: contain; }
.inv-meta { text-align: right; min-width: 220px; }
.inv-kicker { font-size: 28px; font-weight: 800; letter-spacing: .12em; margin: 0; font-family: "Segoe UI", sans-serif; }
.inv-sub { margin: 0 0 8px; color: var(--muted); }
.inv-barcode { width: 220px; height: auto; }
.meta-table { margin-left: auto; border-collapse: collapse; }
.meta-table th, .meta-table td { padding: 3px 0 3px 12px; text-align: left; font-weight: 600; }
.meta-table th { color: var(--muted); font-weight: 600; }
.gold-line { height: 4px; border-radius: 4px; margin: 12px 0; background: linear-gradient(90deg, #0f766e, #d4a853); }
.party { background: #faf7f2; border-radius: 12px; padding: 12px 14px; }
.party h3 { margin: 0 0 6px; font-size: 12px; color: var(--teal); }
.inv-table { width: 100%; border-collapse: collapse; }
.inv-table th { background: #13221f; color: #fff; font-weight: 600; font-size: 13px; padding: 8px 10px; text-align: left; }
.inv-table td { padding: 8px 10px; border-bottom: 1px solid #eee4d6; vertical-align: top; }
.inv-table th:first-child { border-radius: 8px 0 0 0; }
.inv-table th:last-child { border-radius: 0 8px 0 0; }
.sku-line { color: var(--muted); font-size: 12px; }
.totals { width: min(320px, 100%); margin-left: auto; margin-top: 12px; }
.totals div { display: flex; justify-content: space-between; gap: 12px; padding: 4px 0; }
.totals .grand-row { border-top: 2px solid #13221f; margin-top: 4px; padding-top: 8px; font-size: 1.15rem; font-weight: 800; }
.totals .due-row { color: #be123c; font-weight: 800; }
.totals .paid-row { color: #047857; font-weight: 700; }
.in-words { margin-top: 12px; font-weight: 700; }
.inv-note, .terms { margin-top: 10px; font-size: 13px; color: #444; }
.terms strong { display: block; margin-bottom: 4px; }
.sign-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; margin-top: 28px; text-align: center; }
.sign-line { display: block; height: 46px; border-bottom: 1px solid #1c1915; margin-bottom: 6px; }
.sign-row small { display: block; color: var(--muted); }
.inv-footer { text-align: center; margin: 18px 0 0; color: var(--muted); font-size: 13px; }
.inv-auto {
    margin: 14px 0 0;
    text-align: center;
    font-size: 11px;
    line-height: 1.4;
    color: #8a8278;
}
.watermark {
    position: absolute;
    left: 0; right: 0; top: 42%;
    text-align: center;
    font-size: 72px;
    font-weight: 800;
    color: rgba(190, 18, 60, .13);
    transform: rotate(-14deg);
    pointer-events: none;
}
.print-bar {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    align-items: center;
    margin-bottom: 14px;
}
.print-page { background: #efeae2; min-height: 100vh; padding: 18px; }
.print-page .sheet { max-width: 920px; margin: 0 auto; }

.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
    border-radius: 999px;
    background: #f6f1e7;
    padding: 4px 10px;
    font-size: 13px;
    font-weight: 700;
}

@media (max-width: 991.98px) {
    .sidebar { transform: translateX(-105%); transition: transform .2s ease; }
    .sidebar.open { transform: none; }
    .main { margin-left: 0; }
    .backdrop.show { display: block; position: fixed; inset: 0; background: rgba(16, 20, 18, .45); z-index: 1030; }
    .summary-card { position: static; }
}

@media (max-width: 900px) {
    .auth-shell { grid-template-columns: 1fr; }
    .auth-brand { padding: 28px 22px; }
    .auth-brand h1 { font-size: 2rem; }
    .parties, .inv-top, .sign-row { display: block; }
    .inv-meta { text-align: left; margin-top: 12px; }
    .meta-table { margin-left: 0; }
    .sheet { padding: 16px; }
}

@media (max-width: 575.98px) {
    .top-date, .user-chip .name { display: none; }
    .content { padding: 14px; }
    .stat .value { font-size: 1.25rem; }
}

@media print {
    body { background: #fff !important; }
    .sidebar, .topbar, .app-foot, .no-print, .backdrop, .print-bar { display: none !important; }
    .main { margin: 0 !important; }
    .content, .print-page { padding: 0 !important; }
    .sheet { border: 0; box-shadow: none; border-radius: 0; max-width: none; }
    .sheet, .sheet * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
    @page { size: A4; margin: 10mm; }
}
