:root {
  --navy: #15324b;
  --navy-2: #204b6b;
  --blue: #1678b8;
  --blue-soft: #e8f3fa;
  --ink: #172632;
  --muted: #647482;
  --line: #dbe4ea;
  --surface: #ffffff;
  --canvas: #f3f6f8;
  --success: #18794e;
  --danger: #b4232c;
  --warning: #9a6700;
  --radius: 14px;
  --shadow: 0 10px 30px rgba(20, 50, 75, .08);
  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-height: 100vh; background: var(--canvas); font-size: 16px; line-height: 1.45; }
a { color: var(--blue); text-decoration: none; }
button, input, select { font: inherit; }
button, .button { min-height: 44px; }

.sidebar {
  position: fixed; inset: 0 auto 0 0; width: 248px; padding: 22px 16px;
  display: flex; flex-direction: column; z-index: 20;
  color: #fff; background: linear-gradient(175deg, #112b42 0%, #183e5a 72%, #215a78 100%);
}
.brand { display: flex; align-items: center; gap: 12px; margin: 0 6px 32px; color: #fff; font-weight: 750; }
.brand-mark { width: 64px; height: 64px; display: grid; place-items: center; border-radius: 18px; color: #fff; background: linear-gradient(135deg, #19a0db, #2756a1); box-shadow: 0 10px 30px rgba(17, 94, 150, .25); font-weight: 850; letter-spacing: -.04em; }
.brand-mark.small { width: 42px; height: 42px; border-radius: 12px; flex: 0 0 auto; }
.sidebar nav { display: grid; gap: 6px; }
.nav-link { display: flex; align-items: center; gap: 12px; min-height: 48px; padding: 10px 13px; border-radius: 10px; color: #cfe0eb; font-weight: 650; }
.nav-link span { width: 24px; text-align: center; font-size: 1.25rem; }
.nav-link:hover, .nav-link.active { color: #fff; background: rgba(255,255,255,.12); }
.logout-form { margin-top: auto; }
.button-link { width: 100%; border: 0; background: transparent; cursor: pointer; }

.app-shell { margin-left: 248px; min-height: 100vh; }
.topbar { min-height: 96px; display: flex; align-items: center; justify-content: space-between; padding: 20px clamp(20px, 4vw, 56px); border-bottom: 1px solid var(--line); background: rgba(255,255,255,.88); backdrop-filter: blur(10px); }
.topbar h1 { margin: 2px 0 0; font-size: clamp(1.45rem, 3vw, 2rem); letter-spacing: -.035em; }
.topbar-actions { display: flex; align-items: center; gap: .65rem; }
.mobile-logout { display: none; }
.eyebrow { margin: 0; color: var(--blue); font-size: .75rem; font-weight: 850; letter-spacing: .14em; }
.user-chip { padding: 8px 14px; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); background: #fff; font-size: .875rem; }
.content { width: min(1500px, 100%); margin: 0 auto; padding: clamp(18px, 3vw, 42px); }

.card { padding: clamp(18px, 2.5vw, 30px); border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
.card + .card { margin-top: 22px; }
.card h2 { margin: 2px 0; font-size: 1.2rem; letter-spacing: -.015em; }
.card-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 22px; }
.required-note, .muted { color: var(--muted); }
.required-note { font-size: .82rem; }
.stack-md > * + * { margin-top: 14px; }
.stack-lg > * + * { margin-top: 22px; }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px 22px; }
.form-grid.one-column { grid-template-columns: 1fr; }
.field-wide { grid-column: 1 / -1; }
label { display: grid; gap: 7px; color: #334753; font-size: .9rem; font-weight: 700; }
label span em { color: var(--muted); font-size: .78rem; font-style: normal; font-weight: 500; }
input, select { width: 100%; min-height: 46px; padding: 10px 12px; border: 1px solid #bfcdd6; border-radius: 9px; color: var(--ink); background: #fff; outline: none; }
input:focus, select:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(22,120,184,.14); }
input[readonly] { color: #536674; background: #f2f5f7; }
.input-action { display: grid; grid-template-columns: 1fr auto; gap: 8px; }
.split-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.check-field { display: flex; align-items: center; gap: 9px; align-self: end; min-height: 46px; }
.check-field input { width: 20px; min-height: 20px; accent-color: var(--blue); }

.button { display: inline-flex; align-items: center; justify-content: center; gap: 7px; padding: 10px 16px; border: 1px solid transparent; border-radius: 9px; cursor: pointer; font-weight: 750; white-space: nowrap; }
.button.primary { color: #fff; background: var(--blue); }
.button.primary:hover { background: #11689f; }
.button.secondary { color: #105f90; border-color: #9dc7df; background: var(--blue-soft); }
.button.ghost { color: #405766; border-color: var(--line); background: #fff; }
.button.danger { color: var(--danger); border-color: #f0b9bd; background: #fff4f4; }
.button.compact { min-height: 36px; padding: 7px 10px; font-size: .82rem; }
.button.full { width: 100%; }
.form-actions { display: flex; justify-content: flex-end; align-items: center; gap: 10px; }

.table-wrap { max-width: 100%; overflow-x: auto; border: 1px solid var(--line); border-radius: 10px; }
table { width: 100%; border-collapse: collapse; min-width: 760px; }
th { padding: 11px 12px; color: #47606f; background: #f2f6f8; font-size: .76rem; letter-spacing: .04em; text-align: left; text-transform: uppercase; }
td { padding: 12px; border-top: 1px solid var(--line); vertical-align: middle; }
tbody tr:hover { background: #f9fbfc; }
td.description-cell { min-width: 300px; }
.actions { display: flex; align-items: center; gap: 6px; }
.inline-form { display: inline-flex; margin: 0; }
.no-results { padding: 34px; color: var(--muted); text-align: center; }
.empty-state { padding: 36px 16px; color: var(--muted); text-align: center; }
.empty-state strong, .empty-state span { display: block; }
.empty-state[hidden] { display: none; }
.total-bar { display: flex; justify-content: flex-end; align-items: baseline; gap: 18px; padding: 18px 4px 0; }
.total-bar strong { font-size: 1.35rem; color: var(--navy); }

.toolbar, .date-toolbar { display: flex; flex-wrap: wrap; align-items: end; gap: 10px; margin-bottom: 18px; }
.toolbar input { flex: 1 1 280px; }
.date-toolbar label { min-width: 180px; }
.metric-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.metric-row > div { padding: 18px; border-radius: 10px; background: #f3f7fa; }
.metric-row span, .metric-row strong { display: block; }
.metric-row span { color: var(--muted); font-size: .82rem; font-weight: 700; }
.metric-row strong { margin-top: 4px; color: var(--navy); font-size: 1.55rem; }
.badge { display: inline-flex; padding: 5px 9px; border-radius: 999px; font-size: .75rem; font-weight: 800; }
.badge.success { color: var(--success); background: #eaf7f0; }
.badge.neutral { color: #526470; background: #edf1f3; }

.alert { margin-bottom: 18px; padding: 13px 16px; border: 1px solid; border-radius: 10px; }
.alert-success { color: var(--success); border-color: #a7dcc3; background: #eefaf4; }
.alert-error { color: var(--danger); border-color: #efb5ba; background: #fff3f3; }
.alert-warning { color: var(--warning); border-color: #ead19b; background: #fff9e8; }

.autocomplete { position: relative; }
.autocomplete-menu { position: absolute; z-index: 50; top: calc(100% + 5px); left: 0; right: 0; max-height: 290px; overflow-y: auto; padding: 6px; border: 1px solid #b9cbd6; border-radius: 10px; background: #fff; box-shadow: 0 14px 34px rgba(20,50,75,.18); }
.autocomplete-menu[hidden] { display: none; }
.autocomplete-menu button { width: 100%; min-height: 40px; padding: 9px 10px; border: 0; border-radius: 7px; background: transparent; color: var(--ink); text-align: left; cursor: pointer; }
.autocomplete-menu button:hover { background: var(--blue-soft); }
.selection-preview { display: grid; gap: 3px; padding: 13px 15px; border: 1px solid var(--line); border-radius: 9px; color: var(--muted); background: #f6f9fa; }
.selection-preview strong { color: var(--navy); font-size: 1.15rem; }

.modal { width: min(720px, calc(100% - 24px)); padding: 0; border: 0; border-radius: 16px; color: var(--ink); box-shadow: 0 24px 70px rgba(12,30,44,.35); }
.modal::backdrop { background: rgba(7,22,34,.62); backdrop-filter: blur(2px); }
.modal form { padding: 24px; }
.modal-heading { display: flex; justify-content: space-between; align-items: start; margin-bottom: 20px; }
.modal-heading h2 { margin: 2px 0; }
.icon-button { width: 42px; height: 42px; border: 0; border-radius: 50%; color: #536774; background: #eef3f5; font-size: 1.5rem; cursor: pointer; }

.tabs { display: flex; gap: 6px; margin-bottom: 18px; padding: 5px; overflow-x: auto; border: 1px solid var(--line); border-radius: 11px; background: #fff; }
.tabs a { padding: 10px 14px; border-radius: 8px; color: #526774; font-weight: 750; white-space: nowrap; }
.tabs a.active { color: #fff; background: var(--navy-2); }
.catalog-layout { display: grid; grid-template-columns: minmax(260px, 360px) 1fr; gap: 20px; }
.catalog-layout .card + .card, .two-columns .card + .card { margin-top: 0; }
.form-card { align-self: start; }
.two-columns { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.inline-editor { display: flex; flex-wrap: wrap; align-items: center; gap: 9px; margin: 16px 0; }
.inline-editor > input { flex: 1 1 190px; }
.catalog-editor summary { cursor: pointer; font-size: 1.12rem; font-weight: 800; }
.catalog-editor form { margin-top: 20px; }

.login-page { display: grid; place-items: center; padding: 20px; background: radial-gradient(circle at 20% 10%, #d7eff9, transparent 34%), linear-gradient(150deg, #f5f8fa, #eaf1f5); }
.login-card { width: min(430px, 100%); padding: 34px; border: 1px solid rgba(255,255,255,.8); border-radius: 20px; background: rgba(255,255,255,.94); box-shadow: 0 24px 80px rgba(22,65,92,.18); }
.login-card .brand-mark { margin-bottom: 24px; }
.login-card h1 { margin: 0; font-size: 1.8rem; }
.login-card form { display: grid; gap: 17px; margin-top: 24px; }
.mobile-nav { display: none; }

@media (max-width: 1050px) {
  .sidebar { width: 208px; }
  .app-shell { margin-left: 208px; }
  .catalog-layout, .two-columns { grid-template-columns: 1fr; }
}

@media (max-width: 760px) {
  body { padding-bottom: 72px; }
  .sidebar { display: none; }
  .app-shell { margin-left: 0; }
  .topbar { min-height: 82px; padding: 14px 18px; }
  .topbar .eyebrow, .user-chip { display: none; }
  .mobile-logout { display: block; }
  .content { padding: 14px; }
  .card { padding: 17px; border-radius: 12px; }
  .form-grid, .split-fields { grid-template-columns: 1fr; }
  .field-wide { grid-column: auto; }
  .card-heading { align-items: flex-start; flex-wrap: wrap; }
  .card-heading .button { width: 100%; }
  .form-actions { position: sticky; bottom: 70px; z-index: 8; padding: 10px; border: 1px solid var(--line); border-radius: 11px; background: rgba(255,255,255,.94); box-shadow: 0 -8px 24px rgba(20,50,75,.08); }
  .form-actions .button { flex: 1; }
  .metric-row { grid-template-columns: 1fr; }
  .mobile-nav { position: fixed; z-index: 30; inset: auto 0 0; height: 64px; display: grid; grid-template-columns: repeat(4, 1fr); border-top: 1px solid var(--line); background: rgba(255,255,255,.96); backdrop-filter: blur(10px); }
  .mobile-nav .nav-link { min-height: 64px; padding: 6px 3px; display: flex; flex-direction: column; justify-content: center; gap: 0; border-radius: 0; color: #657783; font-size: .69rem; }
  .mobile-nav .nav-link span { height: 24px; font-size: 1.15rem; }
  .mobile-nav .nav-link.active { color: var(--blue); background: var(--blue-soft); }
  .modal form { padding: 18px; }
  .input-action { grid-template-columns: 1fr; }
}
