:root {
  --navy-950: #0b1f33;
  --navy-900: #12314c;
  --blue-700: #17669a;
  --blue-100: #e8f3fa;
  --ink: #172330;
  --muted: #667584;
  --line: #dce4eb;
  --surface: #ffffff;
  --canvas: #f3f6f8;
  --danger: #b8323f;
  --danger-bg: #fff0f1;
  --warning: #9a5b08;
  --warning-bg: #fff7e8;
  --success: #14734b;
  --success-bg: #eaf7f1;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--canvas);
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; font-size: 16px; line-height: 1.45; background: var(--canvas); }
a { color: var(--blue-700); }
button, input, select { font: inherit; }

.topbar {
  min-height: 64px;
  padding: 0 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  background: var(--navy-950);
  color: white;
}
.brand { display: inline-flex; align-items: center; gap: 12px; color: white; text-decoration: none; font-weight: 750; letter-spacing: -.01em; }
.brand-mark { width: 36px; height: 36px; display: grid; place-items: center; border-radius: 9px; color: white; background: #ea4b71; font-size: 14px; font-weight: 800; letter-spacing: .04em; }
.user-menu { display: flex; align-items: center; gap: 18px; font-size: 14px; }
.user-menu a, .link-button { color: #d7e6f2; text-decoration: none; }
.user-menu form { margin: 0; }
.link-button { border: 0; padding: 0; background: none; cursor: pointer; }

.page-shell { width: min(1500px, 100%); margin: 0 auto; padding: 28px; }
.page-heading { display: flex; justify-content: space-between; align-items: flex-end; gap: 24px; margin-bottom: 22px; }
.page-heading h1 { margin: 2px 0 4px; font-size: clamp(28px, 3vw, 38px); letter-spacing: -.035em; line-height: 1.15; }
.page-heading p { margin: 0; color: var(--muted); }
.back-link { display: inline-block; margin-bottom: 10px; text-decoration: none; font-size: 14px; }

.summary-grid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
.summary-card { min-height: 92px; padding: 16px 18px; display: flex; flex-direction: column; justify-content: space-between; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); box-shadow: 0 1px 2px rgb(12 36 56 / 4%); }
.summary-card span { color: var(--muted); font-size: 14px; }
.summary-card strong { font-size: 27px; line-height: 1; }
.summary-card .summary-date { font-size: 19px; }
.summary-alert { border-left: 4px solid #e0a13a; }
.summary-primary { border-left: 4px solid var(--blue-700); background: #f7fbfe; }

.filters { display: grid; grid-template-columns: 160px minmax(180px, 1fr) 210px minmax(220px, 1.25fr) auto; gap: 12px; align-items: end; padding: 16px; margin-bottom: 16px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.filters-range { grid-template-columns: 150px 150px minmax(180px, 1fr) 190px minmax(210px, 1.2fr) auto; }
.filters label, .login-form label { display: grid; gap: 6px; color: #435260; font-size: 14px; font-weight: 650; }
.filters .checkbox-label { grid-column: 1 / span 3; display: flex; align-items: center; align-self: center; gap: 9px; min-height: 42px; }
.checkbox-label input[type="checkbox"] { width: 18px; min-height: 18px; height: 18px; margin: 0; accent-color: var(--blue-700); }
.checkbox-label input[type="hidden"] { display: none; }
input, select { width: 100%; min-height: 42px; padding: 9px 11px; border: 1px solid #cbd7e0; border-radius: 8px; background: white; color: var(--ink); }
input:focus, select:focus { outline: 3px solid rgb(23 102 154 / 16%); border-color: var(--blue-700); }
.button { min-height: 42px; display: inline-flex; align-items: center; justify-content: center; padding: 9px 16px; border: 1px solid transparent; border-radius: 8px; font-weight: 700; text-decoration: none; cursor: pointer; white-space: nowrap; }
.button-primary { background: var(--blue-700); color: white; }
.button-primary:hover { background: #105a89; }
.button-secondary { color: var(--navy-900); background: white; border-color: #bdccd8; }

.table-card { overflow: hidden; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); box-shadow: 0 2px 8px rgb(12 36 56 / 4%); }
.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { padding: 12px 14px; text-align: left; color: #50616f; background: #edf3f7; border-bottom: 1px solid #ccd8e1; font-weight: 750; white-space: nowrap; }
td { padding: 13px 14px; border-bottom: 1px solid #e6ecf0; vertical-align: top; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #f8fbfd; }
.number { text-align: right; white-space: nowrap; }
.sort-link { display: inline-flex; align-items: center; gap: 5px; color: inherit; text-decoration: none; }
.sort-link:hover { color: var(--blue-700); }
.toggle-column { width: 48px; min-width: 48px; padding-left: 12px; padding-right: 6px; text-align: center; }
.expand-button { width: 30px; height: 30px; display: inline-grid; place-items: center; padding: 0; border: 1px solid #afc2d0; border-radius: 7px; color: var(--navy-900); background: white; font-size: 21px; line-height: 1; cursor: pointer; }
.expand-button:hover, .expand-button:focus-visible { color: white; background: var(--blue-700); border-color: var(--blue-700); }
.expand-button:focus-visible { outline: 3px solid rgb(23 102 154 / 20%); outline-offset: 2px; }
.product-summary > td { vertical-align: middle; }
.product-name-cell { min-width: 260px; }
.product-name-cell > a { display: block; max-width: 400px; color: var(--ink); font-weight: 750; text-decoration: none; }
.product-name-cell > a:hover { color: var(--blue-700); }
.orders-panel > td { padding: 0; background: #f6f9fb; }
.orders-panel-inner { padding: 12px 18px 18px 58px; border-bottom: 1px solid #d9e3ea; }
.orders-table { min-width: 760px; border: 1px solid #d5e0e8; border-radius: 8px; background: white; overflow: hidden; }
.orders-table th { padding: 9px 11px; background: #e5eef4; font-size: 13px; }
.orders-table td { padding: 9px 11px; font-size: 13px; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.product-cell { min-width: 260px; }
.product-cell > a:first-child { display: block; color: var(--ink); font-weight: 800; text-decoration: none; }
.product-cell > span { display: block; max-width: 380px; margin: 2px 0 4px; color: #475866; }
.external-link { font-size: 12px; text-decoration: none; }
td small { display: block; margin-top: 3px; color: var(--muted); }
.muted { color: #8996a0; }
.positive { color: var(--success) !important; }
.negative { color: var(--danger) !important; }
.delta { font-weight: 750; white-space: nowrap; }
.spp-pill { display: inline-flex; min-width: 48px; justify-content: center; padding: 4px 8px; border-radius: 999px; color: var(--navy-900); background: var(--blue-100); font-weight: 800; }
.spp-zero { color: var(--danger); background: var(--danger-bg); }
.spp-decrease { color: var(--warning); background: var(--warning-bg); }
.row-zero { box-shadow: inset 4px 0 var(--danger); }
.row-decrease { box-shadow: inset 4px 0 #e0a13a; }
.cancelled { opacity: .58; }
.empty-state { padding: 30px; text-align: center; color: var(--muted); }
.footnote { margin: 12px 2px 0; color: var(--muted); font-size: 13px; }
.history-section { margin-top: 26px; }
.history-section h2 { margin: 0 0 10px; font-size: 20px; }

.login-shell { min-height: calc(100vh - 120px); display: grid; place-items: center; padding: 30px 0; }
.login-card { width: min(420px, 100%); padding: 34px; border: 1px solid var(--line); border-radius: 16px; background: white; box-shadow: 0 18px 50px rgb(12 36 56 / 12%); }
.login-mark { width: 48px; height: 48px; border-radius: 12px; }
.login-card h1 { margin: 20px 0 5px; font-size: 28px; letter-spacing: -.03em; }
.login-card > p { margin: 0 0 24px; color: var(--muted); }
.login-form { display: grid; gap: 15px; }
.notice { margin: 0 0 18px; padding: 11px 13px; border-radius: 8px; font-size: 14px; }
.notice-error { color: var(--danger); background: var(--danger-bg); }

@media (max-width: 950px) {
  .summary-grid { grid-template-columns: repeat(3, 1fr); }
  .filters { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .filters .checkbox-label { grid-column: span 2; }
  .filters .button { grid-column: span 2; }
}

@media (max-width: 620px) {
  .topbar { padding: 0 16px; }
  .user-menu > span { display: none; }
  .page-shell { padding: 20px 14px; }
  .page-heading { align-items: stretch; flex-direction: column; }
  .summary-grid { grid-template-columns: 1fr 1fr; }
  .summary-card { min-height: 84px; padding: 13px; }
  .summary-card strong { font-size: 23px; }
  .filters { grid-template-columns: 1fr; }
  .filters .checkbox-label { grid-column: auto; }
  .filters .button { grid-column: auto; }
  .orders-panel-inner { padding-left: 12px; }
  .login-card { padding: 26px 22px; }
}
