:root {
  --navy: #10283f;
  --navy-soft: #1a3853;
  --green: #16966b;
  --green-dark: #0d7653;
  --text: #1b2934;
  --muted: #70808d;
  --line: #e4eaed;
  --surface: #f5f7f8;
  --white: #fff;
  --amber-bg: #fff4da;
  --amber: #9b6811;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; color: var(--text); background: var(--surface); }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
.app-shell { min-height: 100vh; display: grid; grid-template-columns: 232px 1fr; }
.sidebar { background: var(--navy); color: white; display: flex; flex-direction: column; padding: 22px 14px; }
.sidebar-brand { display: flex; align-items: center; gap: 11px; margin: 2px 8px 46px; }
.sidebar-brand span { display: block; color: #a9bdcc; font-size: 12px; margin-top: 2px; }
.brand-mark { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 13px; background: var(--green); color: white; font-weight: 800; }
.nav-item { width: 100%; border: 0; background: transparent; color: #c7d5df; padding: 12px 13px; border-radius: 9px; display: flex; align-items: center; gap: 12px; text-align: left; font-size: 14px; text-decoration: none; }
.nav-item.active, .nav-item:hover { color: white; background: var(--navy-soft); }
.nav-item span { width: 15px; text-align: center; font-size: 18px; }
.sidebar-foot { margin-top: auto; }
.workspace { padding: 34px 38px 42px; min-width: 0; }
.topbar, .panel-heading, .drawer-header, .drawer-actions { display: flex; justify-content: space-between; align-items: center; gap: 16px; }
h1, h2, p { margin: 0; }
h1 { font-size: 27px; letter-spacing: -.7px; }
h2 { font-size: 19px; letter-spacing: -.25px; }
.eyebrow { margin-bottom: 5px; color: var(--green-dark); font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: 1.1px; }
.button { border: 1px solid transparent; border-radius: 9px; padding: 11px 15px; font-weight: 750; font-size: 14px; transition: .16s ease; }
.button-primary { color: white; background: var(--green); box-shadow: 0 4px 11px #16966b2e; }
.button-primary:hover { background: var(--green-dark); }
.button-secondary { background: white; border-color: var(--line); color: var(--text); }
.button-full { width: 100%; }
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin: 29px 0 20px; }
.stat-card { padding: 18px; background: white; border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 5px 18px #1c354407; }
.stat-card span, .stat-card small { display: block; color: var(--muted); font-size: 12px; }
.stat-card strong { display: block; margin: 10px 0 8px; font-size: 28px; letter-spacing: -1px; }
.stat-2 strong { color: var(--amber); }
.stat-3 strong { color: var(--green-dark); }
.panel { background: white; border: 1px solid var(--line); border-radius: 13px; overflow: hidden; box-shadow: 0 6px 24px #1c354407; }
.panel-heading { padding: 20px 22px 15px; }
.panel-heading p { color: var(--muted); margin-top: 5px; font-size: 13px; }
.filters { display: flex; gap: 10px; padding: 0 22px 16px; }
.search-field { min-width: 260px; max-width: 390px; flex: 1; display: flex; align-items: center; gap: 8px; padding: 0 11px; border: 1px solid var(--line); border-radius: 8px; color: var(--muted); }
.search-field input, .filters select { height: 39px; border: 0; outline: 0; background: white; color: var(--text); font-size: 13px; }
.search-field input { width: 100%; }
.filters select { min-width: 145px; border: 1px solid var(--line); border-radius: 8px; padding: 0 10px; }
.table-wrap { overflow-x: auto; border-top: 1px solid var(--line); }
table { width: 100%; min-width: 970px; border-collapse: collapse; text-align: left; }
th { padding: 12px 16px; background: #f9fbfb; color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .6px; }
td { padding: 14px 16px; border-top: 1px solid var(--line); font-size: 13px; vertical-align: middle; }
td small { display: block; color: var(--muted); margin-top: 4px; font-size: 12px; }
.arrival-cell { display: flex; align-items: center; gap: 10px; min-width: 155px; }
.thumb { width: 43px; height: 43px; object-fit: cover; border-radius: 8px; background: var(--surface); }
.thumb-placeholder { display: grid; place-items: center; font-size: 19px; }
.status { display: inline-block; padding: 6px 9px; border-radius: 999px; font-size: 11px; font-weight: 800; white-space: nowrap; }
.status.initial { background: #e5f1ff; color: #286a9e; }
.status.pending { background: var(--amber-bg); color: var(--amber); }
.status.completed { background: #e5f7ef; color: var(--green-dark); }
.row-action { border: 0; background: transparent; color: var(--green-dark); font-weight: 800; }
.row-actions { display: grid; justify-items: start; gap: 7px; min-width: 104px; }
.inventory-action { color: #286a9e; text-align: left; }
.inventory-added { color: var(--green-dark); font-size: 11px; font-weight: 800; white-space: nowrap; }
.date-group-row td { padding: 0; border-top: 1px solid var(--line); background: #f2f7f6; }
.date-group-toggle { width: 100%; display: flex; align-items: center; gap: 9px; padding: 13px 16px; border: 0; background: transparent; color: var(--text); text-align: left; }
.date-group-toggle small { margin: 0; color: var(--muted); }
.date-group-chevron { color: var(--green-dark); font-size: 18px; transition: transform .16s ease; }
.date-group-toggle[aria-expanded="false"] .date-group-chevron { transform: rotate(-90deg); }
.arrival-record-row td:first-child { padding-left: 27px; }
.final-check-control { display: inline-flex; align-items: center; gap: 7px; color: var(--muted); font-size: 12px; font-weight: 800; white-space: nowrap; }
.final-check-control input { width: 17px; height: 17px; accent-color: var(--green); }
.final-check-control:has(input:checked) { color: var(--green-dark); }
.empty-state { padding: 44px; text-align: center; color: var(--muted); }
.empty-state span { display: block; margin-top: 6px; font-size: 13px; }
.drawer-backdrop { position: fixed; inset: 0; background: #0e253c73; z-index: 4; }
.drawer { position: fixed; top: 0; right: 0; z-index: 5; width: min(560px, 100vw); height: 100vh; overflow-y: auto; padding: 24px; background: white; box-shadow: -10px 0 40px #0e253c26; transform: translateX(105%); transition: transform .22s ease; }
.drawer.open { transform: translateX(0); }
.icon-button { border: 0; background: transparent; color: var(--muted); font-size: 30px; line-height: 1; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 15px 13px; margin-top: 25px; }
.field span, .field small { display: block; }
.field span { margin-bottom: 7px; color: #41515d; font-size: 12px; font-weight: 750; }
.field input, .field select, .field textarea { width: 100%; border: 1px solid var(--line); border-radius: 8px; padding: 10px; outline: 0; color: var(--text); background: white; font-size: 14px; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--green); box-shadow: 0 0 0 3px #16966b1c; }
.field-wide { grid-column: 1 / -1; }
.upload-field { border: 1px dashed #bccbd3; border-radius: 9px; padding: 12px; background: #fbfcfc; }
.upload-field input { border: 0; padding: 0; }
.upload-field small { margin-top: 8px; color: var(--muted); font-size: 11px; }
.conditional-field { display: none !important; }
.conditional-field.is-visible { display: block !important; }
.section-label { display: block; margin-bottom: 8px; color: #41515d; font-size: 12px; font-weight: 750; }
.size-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 9px; }
.size-section { padding: 13px; border: 1px solid var(--line); border-radius: 9px; background: #fbfcfc; }
.size-section-heading, .size-row-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.size-section-heading small { color: var(--muted); font-size: 11px; }
.button-small { padding: 8px 10px; font-size: 12px; white-space: nowrap; }
.size-rows { display: grid; gap: 10px; margin-top: 12px; }
.size-row { padding: 11px; border: 1px solid var(--line); border-radius: 8px; background: white; }
.size-row-header { margin-bottom: 9px; color: var(--muted); font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .45px; }
.remove-size { border: 0; background: transparent; color: #a83f38; font-size: 12px; font-weight: 800; }
.size-row-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 9px; }
.size-row-grid.other-mode { grid-template-columns: 1fr 110px; }
.drawer-actions { margin-top: 20px; justify-content: flex-end; }
.toast { position: fixed; bottom: 20px; left: 50%; z-index: 8; padding: 12px 16px; border-radius: 9px; background: var(--navy); color: white; font-size: 13px; box-shadow: 0 6px 22px #10283f35; opacity: 0; transform: translate(-50%, 12px); pointer-events: none; transition: .2s; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error, .alert { background: #a83f38; color: white; }
.mobile-only { display: none; }
.login-page { min-height: 100vh; display: grid; place-items: center; background: var(--surface); }
.login-card { width: min(390px, calc(100vw - 32px)); padding: 30px; border: 1px solid var(--line); border-radius: 14px; background: white; box-shadow: 0 14px 40px #1c354412; }
.login-card h1 { margin-bottom: 8px; }
.login-copy { color: var(--muted); margin-bottom: 18px; font-size: 14px; }
.login-card .brand-mark { margin-bottom: 22px; }
.login-card .field { display: block; margin-bottom: 14px; }
.alert { padding: 10px; margin-bottom: 14px; border-radius: 7px; font-size: 13px; }
.auth-link { margin-top: 18px; color: var(--muted); font-size: 13px; text-align: center; }
.auth-link a { color: var(--green-dark); font-weight: 750; }
.signed-in { margin-top: 5px; color: var(--muted); font-size: 12px; }

@media (max-width: 850px) {
  .app-shell { display: block; }
  .sidebar { display: none; }
  .workspace { padding: 22px 16px 30px; }
  .topbar .button { display: none; }
  h1 { font-size: 23px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 9px; margin: 20px 0 14px; }
  .stat-card { padding: 14px; }
  .stat-card strong { font-size: 23px; }
  .mobile-only { display: inline-block; }
  .panel-heading { padding: 15px; }
  .panel-heading p { display: none; }
  .filters { display: grid; grid-template-columns: 1fr 1fr; padding: 0 15px 14px; gap: 8px; }
  .search-field { grid-column: 1 / -1; max-width: none; min-width: 0; }
  .filters select { min-width: 0; width: 100%; }
  .table-wrap { overflow: visible; border-top: 1px solid var(--line); }
  table, tbody { display: block; min-width: 0; }
  thead { display: none; }
  tr { display: grid; grid-template-columns: 1fr auto; gap: 8px 14px; padding: 14px 15px; border-top: 1px solid var(--line); }
  .date-group-row { display: block; padding: 0; }
  .date-group-row td { display: block; }
  .date-group-toggle { padding: 12px 15px; flex-wrap: wrap; }
  .date-group-toggle small { width: 100%; padding-left: 27px; }
  .arrival-record-row td:first-child { padding-left: 0; }
  tbody tr:first-child { border-top: 0; }
  td { display: block; padding: 0; border: 0; }
  td:nth-child(2), td:nth-child(6) { color: var(--muted); font-size: 12px; }
  td:nth-child(3) { grid-column: 1 / 2; }
  td:nth-child(4) { grid-row: 1; grid-column: 2; text-align: right; font-size: 17px; }
  td:nth-child(4)::before { content: "Qty "; color: var(--muted); font-size: 11px; font-weight: 400; }
  td:nth-child(5) { grid-column: 1 / 2; }
  td:nth-child(7) { grid-column: 2; grid-row: 4; text-align: right; }
  .arrival-cell { min-width: 0; }
  .drawer { padding: 20px 16px; }
  .form-grid { grid-template-columns: 1fr; }
  .field-wide { grid-column: auto; }
  .size-grid { grid-template-columns: repeat(2, 1fr); }
  .size-row-grid { grid-template-columns: repeat(2, 1fr); }
  .size-row-grid.other-mode { grid-template-columns: 1fr; }
}
