:root {
  --ink: #17232d;
  --muted: #6c7882;
  --line: #dfe5e8;
  --paper: #ffffff;
  --canvas: #f3f5f5;
  --navy: #173f5f;
  --teal: #0a7b75;
  --teal-soft: #dff2ef;
  --amber: #a45c00;
  --amber-soft: #fff0d2;
  --red: #a83232;
  --red-soft: #fde8e8;
  --blue-soft: #e7f0f8;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--canvas);
}
* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; }
a { color: var(--teal); text-decoration: none; }
button, input, select { font: inherit; }
button, .button { cursor: pointer; }
.topbar { height: 76px; padding: 0 4vw; background: var(--paper); border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; position: sticky; top: 0; z-index: 10; }
.brand { display: flex; align-items: center; gap: 12px; color: var(--ink); }
.brand-mark { display: grid; place-items: center; width: 38px; height: 38px; color: white; background: var(--navy); border-radius: 10px 2px 10px 2px; font-weight: 800; }
.brand strong, .brand small { display: block; }
.brand strong { font-size: 17px; letter-spacing: -.02em; }
.brand small { margin-top: 2px; color: var(--muted); font-size: 11px; }
nav { display: flex; gap: 8px; }
nav a { color: var(--muted); padding: 11px 14px; border-radius: 8px; font-weight: 650; font-size: 14px; }
nav a:hover, nav a.active { color: var(--navy); background: #eef3f5; }
.logout-form { margin-left: 3px; padding-left: 10px; border-left: 1px solid var(--line); }
.nav-logout { height: 40px; padding: 0 12px; color: var(--muted); background: transparent; border: 0; border-radius: 8px; font-weight: 650; }
.nav-logout:hover { color: var(--red); background: var(--red-soft); }
.page { width: min(1460px, 92vw); margin: 34px auto 60px; }
.hero { background: var(--navy); color: white; padding: 34px 40px; border-radius: 18px 4px 18px 4px; display: flex; align-items: center; justify-content: space-between; gap: 34px; box-shadow: 0 16px 44px rgba(23,63,95,.13); }
.hero.compact { padding-top: 28px; padding-bottom: 28px; }
.hero h1 { margin: 6px 0 10px; font-size: clamp(28px, 4vw, 45px); letter-spacing: -.04em; line-height: 1.05; }
.hero p:not(.eyebrow) { margin: 0; max-width: 760px; color: #d7e3eb; font-size: 16px; line-height: 1.55; }
.eyebrow { margin: 0; color: #79d7cd; text-transform: uppercase; letter-spacing: .13em; font-size: 11px; font-weight: 800; }
.supplier-switcher { display: grid; grid-template-columns: minmax(290px, 1.15fr) minmax(260px, 1fr) auto; align-items: end; gap: 18px; margin-top: 20px; padding: 18px 22px; background: white; border: 1px solid var(--line); border-left: 4px solid var(--teal); border-radius: 11px 3px 11px 3px; }
.supplier-switcher form { min-width: 0; }
.supplier-context { min-width: 0; padding-bottom: 2px; }
.supplier-context strong, .supplier-context small { display: block; }
.supplier-context strong { margin: 2px 0 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.supplier-context small { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.context-label { color: var(--teal); font-size: 10px; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; }
.button { display: inline-flex; align-items: center; justify-content: center; min-height: 42px; padding: 0 17px; border: 1px solid transparent; border-radius: 8px 2px 8px 2px; font-weight: 750; font-size: 14px; white-space: nowrap; }
.button.primary { background: #55c9bc; color: #0d3435; box-shadow: 0 8px 22px rgba(0,0,0,.12); }
.button.primary:hover { background: #74d7cc; }
.button.secondary { color: var(--navy); border-color: #afc1ce; background: white; }
.button.ghost { color: var(--navy); border-color: var(--line); background: #f7f9fa; }
.dark-button { color: white; background: var(--navy); }
.summary-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin: 20px 0; }
.summary-card { min-height: 135px; padding: 22px; background: var(--paper); border: 1px solid var(--line); border-radius: 12px 3px 12px 3px; display: flex; flex-direction: column; }
.summary-card span { color: var(--muted); font-size: 13px; }
.summary-card strong { margin: 8px 0 5px; font: 750 34px/1 Georgia, serif; }
.summary-card small { color: var(--muted); margin-top: auto; }
.summary-card.dark { background: #202f3a; border-color: #202f3a; color: white; }
.summary-card.dark span, .summary-card.dark small { color: #b9c7cf; }
.summary-card.warning { border-top: 4px solid #e8aa42; }
.panel { margin-top: 20px; background: var(--paper); border: 1px solid var(--line); border-radius: 13px 3px 13px 3px; overflow: hidden; }
.panel-head { padding: 21px 24px; display: flex; align-items: center; justify-content: space-between; gap: 18px; border-bottom: 1px solid var(--line); }
.panel-head h2 { margin: 0 0 4px; font-size: 21px; letter-spacing: -.02em; }
.panel-head p { margin: 0; color: var(--muted); font-size: 13px; }
.actions, .dialog-actions { display: flex; align-items: center; gap: 9px; }
.filters { display: grid; grid-template-columns: minmax(220px, 1.8fr) 1fr 1fr auto auto; gap: 12px; align-items: end; padding: 18px 24px; background: #fafbfb; border-bottom: 1px solid var(--line); }
label span { display: block; margin-bottom: 6px; color: #53616b; font-size: 12px; font-weight: 700; }
label em { color: var(--muted); font-style: normal; font-weight: 400; }
input, select { width: 100%; height: 42px; padding: 0 12px; color: var(--ink); background: white; border: 1px solid #cbd4d8; border-radius: 7px; outline: none; }
input:focus, select:focus { border-color: var(--teal); box-shadow: 0 0 0 3px rgba(10,123,117,.11); }
.clear-filter { align-self: center; padding-bottom: 10px; font-size: 13px; }
.table-wrap { width: 100%; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { padding: 12px 16px; color: #687681; background: #f6f8f8; text-align: left; text-transform: uppercase; letter-spacing: .05em; font-size: 10px; white-space: nowrap; }
td { padding: 14px 16px; border-top: 1px solid #edf0f1; vertical-align: top; }
tbody tr:hover { background: #fbfcfc; }
.item-cell { min-width: 300px; }
.item-cell strong, .item-cell small { display: block; }
.item-cell strong { line-height: 1.35; }
.item-cell small, .import-list small { margin-top: 5px; color: var(--muted); }
code { display: block; color: var(--ink); font: 650 13px ui-monospace, SFMono-Regular, Menlo, monospace; white-space: nowrap; }
.mini { display: inline-block; margin-top: 5px; font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }
.mini.yes { color: var(--teal); }
.mini.no { color: var(--red); }
.badge { display: inline-block; max-width: 240px; padding: 6px 9px; border-radius: 999px; font-size: 11px; font-weight: 750; line-height: 1.25; }
.badge.success { color: #08635d; background: var(--teal-soft); }
.badge.warning { color: var(--amber); background: var(--amber-soft); }
.badge.info { color: #285e87; background: var(--blue-soft); }
.badge.danger { color: var(--red); background: var(--red-soft); }
.badge.muted { color: #68747c; background: #eceff0; }
.empty-state { padding: 58px 20px 65px; text-align: center; }
.empty-icon { margin: 0 auto 12px; display: grid; place-items: center; width: 54px; height: 54px; color: var(--navy); background: #eaf0f3; border-radius: 50%; font-size: 28px; }
.empty-state h3 { margin: 0 0 7px; }
.empty-state p { margin: 0 0 20px; color: var(--muted); }
.imports-panel { padding: 0; }
.imports-panel summary { padding: 18px 24px; cursor: pointer; font-weight: 750; }
.import-list > div { display: flex; justify-content: space-between; gap: 20px; padding: 13px 24px; border-top: 1px solid var(--line); }
.import-list strong, .import-list small { display: block; }
.link { color: var(--teal); background: none; border: 0; padding: 4px; font-weight: 700; font-size: 12px; }
.danger-link { color: var(--red); }
dialog { width: min(540px, 92vw); padding: 0; border: 0; border-radius: 14px 3px 14px 3px; box-shadow: 0 24px 80px rgba(14,35,49,.3); }
dialog::backdrop { background: rgba(13,28,38,.64); backdrop-filter: blur(2px); }
dialog form { padding: 28px; }
.dialog-head { display: flex; align-items: start; justify-content: space-between; margin-bottom: 22px; }
.dialog-head h2 { margin: 4px 0 0; font-size: 26px; }
.close { border: 0; background: #edf1f2; color: #58666f; width: 34px; height: 34px; border-radius: 50%; font-size: 22px; line-height: 1; }
dialog label { display: block; margin-top: 15px; }
.hint { margin-top: 16px; padding: 12px 14px; color: #52636d; background: #eef4f5; border-left: 3px solid var(--teal); font-size: 12px; line-height: 1.5; }
.danger-hint { background: var(--red-soft); border-color: var(--red); }
.or-divider { display: flex; align-items: center; gap: 10px; margin: 13px 0 -2px; color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .1em; }
.or-divider::before, .or-divider::after { content: ""; height: 1px; flex: 1; background: var(--line); }
.dialog-actions { justify-content: flex-end; margin-top: 23px; }
.flash-stack { position: fixed; top: 88px; right: 4vw; z-index: 20; width: min(440px, 90vw); }
.flash { margin-bottom: 8px; padding: 13px 16px; border-radius: 9px; border: 1px solid; box-shadow: 0 10px 28px rgba(0,0,0,.12); background: white; font-size: 13px; }
.flash.success { color: #075f59; border-color: #8fd2ca; }
.flash.error { color: var(--red); border-color: #e8aaaa; }
.reference-add .inline-form { padding: 19px 24px; }
.inline-form { display: grid; grid-template-columns: 1fr 1fr 2fr auto; gap: 12px; align-items: end; }
.reference-search { display: flex; align-items: center; gap: 8px; min-width: min(500px, 50vw); }
.reference-table input { min-width: 140px; height: 36px; padding: 0 9px; background: #fcfdfd; }
.reference-table td:nth-child(4) input { min-width: 320px; }
.row-actions { display: flex; min-width: 130px; }
.client-add-form { display: grid; grid-template-columns: minmax(280px, 1fr) auto; gap: 12px; align-items: end; padding: 19px 24px; }
.client-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; padding: 20px; background: #f8fafa; }
.client-card { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 14px; align-items: center; padding: 20px; background: white; border: 1px solid var(--line); border-radius: 11px 3px 11px 3px; }
.client-avatar { display: grid; place-items: center; width: 46px; height: 46px; color: white; background: var(--navy); border-radius: 12px 3px 12px 3px; font: 750 21px Georgia, serif; }
.client-main { min-width: 0; }
.client-main h3 { margin: 0 0 5px; font-size: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.client-main p, .client-main small { display: block; margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.client-main p { color: #4d5c66; font-size: 13px; }
.client-main small { margin-top: 4px; color: var(--muted); font-size: 11px; }
.client-stats { min-width: 62px; padding-left: 14px; border-left: 1px solid var(--line); text-align: center; }
.client-stats span, .client-stats small { display: block; }
.client-stats span { font: 750 25px Georgia, serif; }
.client-stats small { color: var(--muted); font-size: 10px; }
.client-actions { grid-column: 2 / -1; display: flex; gap: 8px; padding-top: 11px; border-top: 1px solid #edf0f1; }
footer { padding: 24px; color: #7a858c; text-align: center; font-size: 11px; }
.login-page { min-height: 100vh; background: #102f48; }
.login-shell { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(380px, .85fr); }
.login-intro { display: flex; flex-direction: column; justify-content: center; padding: clamp(42px, 8vw, 120px); color: white; background: radial-gradient(circle at 20% 20%, #23607f 0, #173f5f 35%, #102f48 75%); }
.login-brand { position: absolute; top: 38px; display: flex; align-items: center; gap: 12px; }
.login-brand strong, .login-brand small { display: block; }
.login-brand small { margin-top: 2px; color: #b9d0dd; font-size: 11px; }
.login-intro h1 { max-width: 680px; margin: 12px 0 18px; font-size: clamp(40px, 6vw, 72px); line-height: 1; letter-spacing: -.05em; }
.login-intro > p:last-child { max-width: 620px; margin: 0; color: #d4e2e9; font-size: 17px; line-height: 1.6; }
.login-card { align-self: center; width: min(460px, 86%); margin: 40px auto; padding: 40px; background: white; border-radius: 18px 4px 18px 4px; box-shadow: 0 30px 80px rgba(4, 24, 38, .28); }
.login-card h2 { margin: 7px 0 6px; font-size: 30px; letter-spacing: -.03em; }
.login-card > div > p:not(.eyebrow) { margin: 0 0 25px; color: var(--muted); }
.login-card form { display: grid; gap: 17px; }
.login-card .button { width: 100%; margin-top: 4px; }
.login-card .flash { margin: 0 0 18px; box-shadow: none; }
.login-note { display: block; margin-top: 22px; color: var(--muted); line-height: 1.45; text-align: center; }
.error-panel { max-width: 720px; margin: 12vh auto; }
@media (max-width: 980px) {
  .summary-grid { grid-template-columns: repeat(2, 1fr); }
  .supplier-switcher { grid-template-columns: 1fr 1fr; }
  .supplier-switcher > .button { grid-column: span 2; }
  .filters { grid-template-columns: 1fr 1fr; }
  .inline-form { grid-template-columns: 1fr 1fr; }
  .inline-form .wide { grid-column: span 2; }
  .panel-head { align-items: flex-start; flex-direction: column; }
  .reference-search { min-width: 100%; }
  .client-grid { grid-template-columns: 1fr; }
}
@media (max-width: 680px) {
  .topbar { height: auto; padding: 12px 4vw; align-items: flex-start; flex-direction: column; gap: 10px; position: static; }
  .brand small { display: none; }
  nav { width: 100%; }
  nav a { flex: 1; text-align: center; }
  .page { width: 94vw; margin-top: 16px; }
  .hero { padding: 26px 22px; align-items: flex-start; flex-direction: column; }
  .hero .button { width: 100%; }
  .summary-grid { grid-template-columns: 1fr 1fr; }
  .summary-card { min-height: 120px; padding: 17px; }
  .summary-card strong { font-size: 28px; }
  .supplier-switcher, .filters, .inline-form, .client-add-form { grid-template-columns: 1fr; }
  .supplier-switcher > .button { grid-column: auto; width: 100%; }
  .inline-form .wide { grid-column: auto; }
  .actions { width: 100%; flex-wrap: wrap; }
  .actions > * { flex: 1; }
  .actions .button { width: 100%; }
  .reference-search { flex-wrap: wrap; }
  .reference-search input { flex: 1 0 100%; }
  .client-grid { padding: 12px; }
  .client-card { grid-template-columns: auto minmax(0, 1fr); }
  .client-stats { display: none; }
  .client-actions { grid-column: 1 / -1; flex-direction: column; }
  .client-actions .button { width: 100%; }
  .login-shell { display: block; padding: 20px 0; }
  .login-intro { min-height: auto; padding: 32px 7vw 60px; background: transparent; }
  .login-brand { position: static; margin-bottom: 54px; }
  .login-intro h1 { font-size: 39px; }
  .login-intro > p:last-child { font-size: 15px; }
  .login-card { width: 90%; margin: -28px auto 20px; padding: 28px 24px; }
}
