:root {
    --ink: #142033;
    --muted: #4b5b6d;
    --paper: #e9eef3;
    --card: #ffffff;
    --line: #aebac7;
    --line-dark: #748394;
    --nav: #132b38;
    --nav-hover: #21495b;
    --accent: #006b5b;
    --accent-dark: #004c41;
    --blue: #1769aa;
    --blue-soft: #dcecff;
    --red: #a21d2f;
    --red-soft: #fde4e7;
    --amber: #78520a;
    --amber-soft: #fff0c2;
    --green-soft: #d8f1e7;
    --shadow: 0 8px 24px rgba(20, 32, 51, .12);
    color: var(--ink);
    background: var(--paper);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
    font-size: 16px;
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; background: var(--paper); line-height: 1.45; }
a { color: #005d8f; text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select { font: inherit; }
button:focus-visible, input:focus-visible, select:focus-visible, a:focus-visible, summary:focus-visible { outline: 3px solid #62a9dd; outline-offset: 2px; }

.topbar {
    position: sticky;
    z-index: 100;
    top: 0;
    min-height: 66px;
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 0 max(20px, calc((100vw - 1500px) / 2));
    color: #fff;
    background: var(--nav);
    border-bottom: 4px solid #00a58b;
    box-shadow: 0 3px 12px rgba(11, 25, 35, .24);
}
.brand { color: #fff; font-size: 1.2rem; font-weight: 850; letter-spacing: .01em; white-space: nowrap; }
.topbar nav { display: flex; align-items: center; gap: 5px; margin-left: auto; }
.topbar nav > a, .link-button { display: inline-flex; min-height: 40px; align-items: center; padding: 7px 10px; border-radius: 7px; color: #f4fbff; font: inherit; font-weight: 620; }
.topbar nav > a:hover, .link-button:hover { background: var(--nav-hover); text-decoration: none; }
.topbar nav > a[aria-current] { color: #fff; background: var(--nav-hover); box-shadow: inset 0 -3px #00c5a5; }
.logout-form { margin: 0; padding-left: 12px; border-left: 1px solid #53707f; }
.link-button { border: 0; background: transparent; cursor: pointer; }
.nav-toggle { display: none; margin-left: auto; min-height: 40px; padding: 7px 10px; border: 1px solid #53707f; border-radius: 7px; color: #fff; background: transparent; font-weight: 650; }
.section-nav { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; padding: 10px max(22px, calc((100vw - 1240px) / 2 + 22px)); border-bottom: 1px solid var(--line); background: #fff; }
.section-nav-label { margin-right: 10px; color: var(--muted); font-size: .8rem; font-weight: 750; }
.section-nav a { display: inline-flex; align-items: center; min-height: 40px; padding: 7px 11px; border-radius: 6px; color: var(--ink); font-size: .92rem; font-weight: 650; }
.section-nav a:hover { background: #edf3f6; text-decoration: none; }
.section-nav a[aria-current] { color: var(--accent-dark); background: var(--green-soft); box-shadow: inset 0 -3px var(--accent); }
details.card, #submissions { scroll-margin-top: 85px; }
details.card > summary { min-height: 42px; padding: 7px 0; color: #172a3c; font-size: 1.16rem; font-weight: 750; cursor: pointer; }
details.card[open] > summary { margin-bottom: 14px; }
.inventory-management-body > section + section { margin-top: 26px; padding-top: 22px; border-top: 1px solid var(--line); }
.inventory-management [data-share-url] { display: block; width: 100%; margin: 6px 0 12px; }

.container { width: min(1240px, 100%); margin: 0 auto; padding: 30px 22px 72px; }
.container-wide { width: min(1780px, 100%); }
.heading { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; margin-bottom: 22px; }
h1 { margin: 0 0 7px; color: #102436; font-size: clamp(1.75rem, 4vw, 2.55rem); line-height: 1.12; letter-spacing: -.025em; }
h2 { margin: 0 0 18px; color: #172a3c; font-size: 1.16rem; }
.muted { color: var(--muted); }
.eyebrow { margin: 0 0 4px; color: #31576b; font-size: .76rem; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

.card {
    margin-bottom: 20px;
    padding: 21px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--card);
    box-shadow: var(--shadow);
}
.narrow { max-width: 620px; }
.login-card { max-width: 420px; margin: 8vh auto; }
.stat-grid, .card-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 24px; }
.card-grid { grid-template-columns: repeat(2, 1fr); }
.stat { padding: 20px; border: 1px solid var(--line); border-left: 5px solid var(--blue); border-radius: 10px; background: #fff; box-shadow: 0 3px 12px rgba(20, 32, 51, .07); }
.stat span, .stock span, .stock-inline span { display: block; color: var(--muted); font-size: .85rem; font-weight: 650; }
.stat strong { color: #102436; font-size: 2rem; }
a.stat:hover { border-color: var(--accent); background: #f0f8f6; text-decoration: none; }
.dashboard-stats-employee { grid-template-columns: repeat(2, 1fr); }
.stat.danger { border-color: #d98791; border-left-color: var(--red); background: #fff7f8; }
.two-column { display: grid; grid-template-columns: 2fr 1fr; gap: 20px; }
.stock { min-width: 160px; padding: 16px 22px; border: 1px solid #91bdae; border-radius: 12px; background: var(--green-soft); text-align: right; }
.stock strong { display: block; font-size: 2.5rem; }
.stock small, .stock-inline small { color: var(--muted); }
.stock.danger { border-color: #da929a; color: var(--red); background: var(--red-soft); }
.stock-inline { display: grid; grid-template-columns: 1fr auto; align-items: end; margin-bottom: 20px; padding: 16px; border: 1px solid #aac3b9; border-radius: 9px; background: #e8f4ef; }
.stock-inline strong { font-size: 2rem; }
.stock-inline small { grid-column: 1 / -1; }

.button {
    display: inline-flex;
    min-height: 42px;
    align-items: center;
    justify-content: center;
    padding: 8px 15px;
    border: 1px solid var(--line-dark);
    border-radius: 7px;
    color: var(--ink);
    background: #fff;
    font-weight: 720;
    cursor: pointer;
}
.button:hover { border-color: var(--accent); background: #f0f8f6; text-decoration: none; }
.button:disabled { cursor: not-allowed; opacity: .5; }
.button-primary { border-color: var(--accent); color: #fff; background: var(--accent); }
.button-primary:hover { color: #fff; background: var(--accent-dark); }
.button-danger { border-color: #c36e78; color: var(--red); }
.button-small { min-height: 34px; padding: 5px 10px; font-size: .9rem; }
.actions, .search, .inline-form { display: flex; align-items: center; gap: 10px; }
.actions { flex-wrap: wrap; }
.inline-form { flex-wrap: wrap; }
.inline-form > * { flex: 1 1 180px; }

.form-stack { display: grid; gap: 16px; }
.form-stack label { display: grid; gap: 6px; font-weight: 680; }
input, select {
    min-height: 42px;
    padding: 8px 10px;
    border: 1px solid #7f8e9e;
    border-radius: 6px;
    color: var(--ink);
    background: #fff;
}
input:hover, select:hover { border-color: #4e6478; }
.form-stack input, .form-stack select, .search input, .search select, .inline-form input { width: 100%; }
.checkbox { display: flex !important; align-items: center; gap: 9px !important; font-weight: 500 !important; }
.checkbox input { width: auto !important; min-height: auto !important; }
[hidden] { display: none !important; }

.filter-panel {
    margin: 0 0 20px;
    padding: 16px;
    border: 1px solid #8798a9;
    border-radius: 11px;
    background: #f8fafc;
    box-shadow: 0 4px 14px rgba(20, 32, 51, .08);
}
.filter-grid { display: grid; grid-template-columns: minmax(260px, 2fr) repeat(7, minmax(125px, 1fr)); gap: 10px; }
.filter-grid label { display: grid; gap: 5px; color: #34485b; font-size: .78rem; font-weight: 760; }
.filter-grid input, .filter-grid select { width: 100%; min-height: 40px; font-size: .9rem; }
.filter-search { min-width: 230px; }
.filter-footer { display: flex; justify-content: space-between; align-items: center; gap: 14px; margin-top: 12px; padding-top: 12px; border-top: 1px solid #c4cdd6; color: var(--muted); font-size: .87rem; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: .92rem; }
th, td { padding: 10px; border-right: 1px solid #d2d9e0; border-bottom: 1px solid #c6d0d9; vertical-align: middle; text-align: left; }
th:last-child, td:last-child { border-right: 0; }
th { color: #fff; background: #34495b; font-size: .75rem; font-weight: 800; letter-spacing: .045em; text-transform: uppercase; }
thead th:first-child { border-radius: 6px 0 0; }
thead th:last-child { border-radius: 0 6px 0 0; }
tbody tr:nth-child(even) td { background: #f1f5f8; }
tbody tr:hover td { background: #e4edf4; }
tbody tr:last-child td { border-bottom: 0; }
tbody input { width: 100%; min-width: 140px; }
.number { text-align: right; font-variant-numeric: tabular-nums; }
.negative { color: var(--red); font-weight: 800; }
.positive { color: #006044; font-weight: 800; }
.row-danger td { background: #fff0f2 !important; }
.empty { padding: 34px; color: var(--muted); text-align: center; }
.pagination { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 16px; margin: 18px 0; }
.pagination > :last-child { justify-self: end; }
.status-pill { display: inline-flex; padding: 3px 8px; border: 1px solid; border-radius: 999px; font-size: .74rem; font-weight: 800; }
.status-pill.is-active { border-color: #6fad94; color: #00593d; background: #dff3e9; }
.status-pill.is-inactive { border-color: #9ba7b3; color: #46515c; background: #e8ecef; }

.bulk-toolbar {
    position: sticky;
    z-index: 40;
    top: 78px;
    display: grid;
    grid-template-columns: auto minmax(470px, 1fr) minmax(360px, 1.1fr);
    align-items: end;
    gap: 14px;
    margin-bottom: 12px;
    padding: 14px;
    border: 1px solid #5b7185;
    border-radius: 10px;
    color: #fff;
    background: #21394b;
    box-shadow: 0 7px 22px rgba(13, 28, 40, .24);
}
.bulk-toolbar input, .bulk-toolbar select { min-height: 39px; }
.bulk-summary { display: grid; min-width: 170px; gap: 4px; }
.unsaved-badge { width: max-content; padding: 2px 8px; border-radius: 999px; color: #352500; background: #ffd86e; font-size: .78rem; font-weight: 800; }
.draft-state { color: #d4e4ed; font-size: .76rem; }
.bulk-apply { display: grid; grid-template-columns: minmax(160px, 1fr) 110px auto auto; gap: 8px; }
.bulk-save { display: grid; grid-template-columns: minmax(210px, 1fr) auto; gap: 8px 12px; align-items: end; }
.reason-field { display: grid; gap: 4px; color: #e9f4fa; font-size: .76rem; font-weight: 750; }
.reason-field input { width: 100%; }
.negative-approval { grid-column: 1 / -1; color: #ffe6a1; font-size: .8rem; }
.bulk-help { margin: 0 0 12px; padding: 10px 13px; border-left: 5px solid var(--blue); color: #263c50; background: #dceaf5; font-size: .88rem; }
.bulk-table-wrap { max-height: 65vh; padding: 0; border-radius: 8px; }
.bulk-table { min-width: 1180px; }
.bulk-table thead th { position: sticky; z-index: 5; top: 0; background: #293f52; }
.bulk-table .select-cell { width: 44px; text-align: center; }
.bulk-table .select-cell input { width: 18px; min-width: 18px; min-height: 18px; accent-color: var(--blue); }
.bulk-table .product-name { min-width: 250px; }
.bulk-table tr.is-selected td { background: var(--blue-soft); }
.bulk-table tr.is-selected:hover td { background: #cbe2fb; }
.bulk-table tr.is-changed td { box-shadow: inset 0 2px 0 #e1a900, inset 0 -2px 0 #e1a900; }
.bulk-table tr.is-invalid td { background: var(--red-soft) !important; }
.target-heading { background: #116393 !important; }
.target-cell { position: relative; min-width: 145px; padding: 5px 13px 5px 8px; }
.target-cell input[type="number"] { width: 120px; min-width: 120px; min-height: 36px; text-align: right; font-weight: 760; }
.is-changed .target-cell input[type="number"] { border: 2px solid #b88600; color: #5b3f00; background: #fff8dc; }
.fill-handle { position: absolute; right: 4px; bottom: 4px; width: 10px; min-width: 10px; height: 10px; min-height: 10px; padding: 0; border: 1px solid #fff; border-radius: 1px; background: var(--blue); box-shadow: 0 0 0 1px var(--blue); cursor: crosshair; }
.delta-cell { min-width: 90px; font-weight: 750; }
body.is-filling, body.is-filling * { cursor: crosshair !important; user-select: none; }

.flash { margin: 0 0 18px; padding: 13px 16px; border: 1px solid; border-left-width: 5px; border-radius: 8px; font-weight: 620; }
.flash-success { border-color: #4d9a77; color: #064b34; background: #dff3e8; }
.flash-error { border-color: #c05e69; color: #7b1421; background: #fde5e8; }
.flash-warning { border-color: #c09028; color: #604000; background: #fff0c9; }
.badge { display: inline-block; padding: 3px 9px; border-radius: 99px; font-size: .72rem; font-weight: 800; letter-spacing: .05em; text-transform: uppercase; }
.badge.ok { color: #075438; background: #d7f0e2; }
.badge.blocked { color: #674300; background: #ffe8b4; }
.readiness { padding: 15px 0; border-top: 1px solid var(--line); }
.readiness:first-of-type { border: 0; }
.readiness strong { margin-left: 7px; }
.readiness p { margin: 5px 0 0; color: var(--muted); font-size: .88rem; }
.back { display: inline-block; margin-bottom: 15px; }
.scanner-video { width: 100%; margin-top: 16px; border-radius: 10px; background: #000; }
.camera-button { margin-top: 16px; }
code { padding: 2px 5px; border: 1px solid #c5ced7; border-radius: 4px; color: #173c55; background: #eef2f5; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; }
.status-line { display: grid; grid-template-columns: 1fr auto 1fr auto; align-items: center; gap: 12px 20px; margin-bottom: 16px; }
.status-line span { color: var(--muted); }

@media (max-width: 1450px) {
    .filter-grid { grid-template-columns: repeat(4, minmax(150px, 1fr)); }
    .filter-search { grid-column: span 2; }
    .bulk-toolbar { grid-template-columns: 1fr 2fr; }
    .bulk-save { grid-column: 1 / -1; grid-template-columns: 1fr auto; }
}

@media (max-width: 1000px) {
    .topbar { position: static; flex-wrap: wrap; gap: 6px; padding: 10px 16px; }
    .topbar .brand { margin-right: auto; }
    .topbar nav { order: 3; width: 100%; flex-wrap: wrap; margin-left: 0; }
    .topbar.nav-ready { position: sticky; flex-wrap: nowrap; }
    .nav-ready .nav-toggle { display: block; }
    .nav-ready nav { position: absolute; z-index: 110; top: 100%; right: 0; left: 0; display: none; flex-direction: column; flex-wrap: nowrap; align-items: stretch; padding: 14px 18px; background: var(--nav); border-bottom: 3px solid #00a58b; max-height: calc(100dvh - 70px); overflow-y: auto; }
    .nav-ready nav.open { display: flex; }
    .nav-ready nav > a { width: 100%; }
    .logout-form { padding-left: 6px; }
    .section-nav { padding: 8px 16px; }
    .section-nav-label { width: 100%; }
    .stat-grid { grid-template-columns: repeat(2, 1fr); }
    .two-column, .card-grid { grid-template-columns: 1fr; }
    .filter-grid { grid-template-columns: repeat(2, minmax(150px, 1fr)); }
    .bulk-toolbar { position: static; grid-template-columns: 1fr; }
    .bulk-save { grid-column: auto; }
}

@media (max-width: 620px) {
    .topbar { padding-right: 10px; padding-left: 10px; }
    .brand { font-size: 1rem; }
    .logout-form .link-button { padding-right: 6px; padding-left: 6px; font-size: .85rem; }
    .section-nav { padding-right: 12px; padding-left: 12px; }
    .container { padding: 22px 12px 60px; }
    .heading { display: block; }
    .heading > .actions, .heading > .button { margin-top: 13px; }
    .actions { flex-wrap: wrap; }
    .card { padding: 15px; }
    .stat-grid { grid-template-columns: 1fr 1fr; gap: 9px; }
    .stat { padding: 14px; }
    .stat strong { font-size: 1.6rem; }
    .stock { margin-top: 18px; text-align: left; }
    .filter-grid { grid-template-columns: 1fr; }
    .filter-search { grid-column: auto; }
    .filter-footer { align-items: flex-start; flex-direction: column; }
    .bulk-apply, .bulk-save { grid-template-columns: 1fr; }
    .negative-approval { grid-column: auto; }
    .pagination { grid-template-columns: auto 1fr auto; font-size: .85rem; }
    .status-line { grid-template-columns: 1fr auto; }
}
