/* NAC LMIS — institutional theme aligned with NAC reporting palette */
:root {
  --green-dark: #0b8f63;
  --green: #0e9e6e;
  --green-mid: #10b981;
  --green-pale: #e6f9f1;
  --orange: #d4a843;
  --ink: #1a1a2e;
  --muted: #6b7280;
  --line: #d1d5db;
  --paper: #e8f0ec;
  --card: #ffffff;
  --red: #c8102e;
  --navy: #1a3a6b;
  --surface: #f3f4f6;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(26, 26, 46, .05), 0 8px 24px rgba(26, 58, 107, .07);
  --font-ui: Candara, Calibri, "Segoe UI", sans-serif;
  --font-display: Constantia, "Palatino Linotype", Georgia, serif;
  --sidebar-w: 260px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font-ui);
  background:
    radial-gradient(1100px 480px at 88% -8%, rgba(16, 185, 129, .16), transparent 55%),
    radial-gradient(900px 420px at -8% 18%, rgba(26, 58, 107, .10), transparent 52%),
    linear-gradient(180deg, #e6f9f1 0%, var(--paper) 40%, var(--surface) 100%);
  background-attachment: fixed;
  color: var(--ink);
  font-size: 16px;
  line-height: 1.55;
}
a { color: var(--navy); }
.shell { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  background: linear-gradient(180deg, #0d5c45 0%, #0b4a38 100%);
  color: #e8f7f1;
  padding: 18px 14px 28px;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.brand { display: flex; gap: 12px; align-items: center; padding: 6px 8px 18px; border-bottom: 1px solid rgba(255,255,255,.12); margin-bottom: 14px; }
.brand-logo { border-radius: 50%; background: #fff; padding: 2px; }
.brand-text strong { display: block; font-size: 17px; letter-spacing: .02em; }
.brand-text span { font-size: 12.5px; opacity: .8; }
.nav-header { font-size: 11.5px; letter-spacing: .08em; text-transform: uppercase; opacity: .55; margin: 14px 8px 6px; }
.nav-link { display: block; padding: 9px 12px; border-radius: 8px; color: #e8f7f1; text-decoration: none; font-weight: 600; font-size: 15px; }
.nav-link:hover { background: rgba(255,255,255,.08); }
.nav-link.active { background: rgba(16,185,129,.28); }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: 14px 24px; background: rgba(255,255,255,.72); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10;
}
.topbar-left { display: flex; align-items: center; gap: 10px; }
.topbar-title { font-family: var(--font-display); font-size: 21px; font-weight: 700; }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.whoami { text-align: right; line-height: 1.2; }
.whoami-name { display: block; font-weight: 700; font-size: 14.5px; }
.whoami-role { font-size: 12.5px; color: var(--muted); }
.content { padding: 22px 24px 40px; flex: 1; }
.content-wide { max-width: 1280px; }
.footer { padding: 12px 24px 20px; color: var(--muted); font-size: 13.5px; }
.page-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.page-head h1 { margin: 0; font-family: var(--font-display); font-size: 27px; }
.page-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px 20px; box-shadow: var(--shadow); margin-bottom: 16px;
}
.card h2 { margin: 0 0 12px; font-size: 18px; font-family: var(--font-display); }
.kpi-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 16px; box-shadow: var(--shadow); border-top: 3px solid var(--green-mid);
}
.kpi-label { display: block; font-size: 12.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 700; }
.kpi strong { display: block; font-size: 27px; margin: 4px 0 2px; color: var(--green-dark); font-family: var(--font-display); }
.kpi-sub { font-size: 13px; color: var(--muted); }
.grid-2 { display: grid; grid-template-columns: 1.2fr 1fr; gap: 16px; }
@media (max-width: 980px) { .grid-2 { grid-template-columns: 1fr; } }
.table { width: 100%; border-collapse: collapse; font-size: 15px; }
.table th, .table td { padding: 9px 10px; border-bottom: 1px solid #eef2f0; text-align: left; vertical-align: top; }
.table th { font-size: 12.5px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); background: #f7fbf9; }
.table.compact th, .table.compact td { padding: 7px 8px; font-size: 14px; }
.num { text-align: right !important; font-variant-numeric: tabular-nums; white-space: nowrap; }
.row-warn { background: #fff8e8; }
.muted { color: var(--muted); }
.hint { font-size: 14px; color: var(--muted); margin: 0 0 12px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 14px; border-radius: 8px; border: 1px solid var(--line); background: #fff;
  color: var(--ink); font: inherit; font-weight: 700; font-size: 14.5px; text-decoration: none; cursor: pointer;
}
.btn:hover { border-color: var(--green); color: var(--green-dark); }
.btn-primary { background: var(--green); border-color: var(--green); color: #fff; }
.btn-primary:hover { background: var(--green-dark); color: #fff; }
.btn-secondary { background: var(--green-pale); border-color: #bfead7; color: var(--green-dark); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn-block { width: 100%; }
.inline { display: inline; }
.inline-form { display: flex; gap: 8px; align-items: center; }
.form label { display: flex; flex-direction: column; gap: 5px; font-weight: 700; font-size: 14px; color: var(--ink); }
.form input, .form select, .form textarea {
  font: inherit; font-weight: 400; padding: 10px 12px; border: 1px solid var(--line);
  border-radius: 8px; background: #fff; color: var(--ink);
}
.form input:focus, .form select:focus, .form textarea:focus {
  outline: none; border-color: var(--green); box-shadow: 0 0 0 3px rgba(16,185,129,.16);
}
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 16px; }
.form-grid .full { grid-column: 1 / -1; }
@media (max-width: 700px) { .form-grid { grid-template-columns: 1fr; } }
.adj-lot-box {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 14px 14px;
  margin: 0;
  background: var(--surface);
}
.adj-lot-box legend {
  font-weight: 700;
  padding: 0 6px;
  color: var(--navy);
}
.adj-lot-mode-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 20px;
  margin-bottom: 12px;
}
.radio-inline {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  cursor: pointer;
}
.radio-inline input { margin: 0; }
.adj-lot-panel { margin: 0; }
.form-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 8px; }
.dest-box {
  border: 1px solid #cfe0d8; border-radius: 10px; padding: 14px 16px 16px;
  background: linear-gradient(180deg, #f4fbf8, #fff); margin: 4px 0;
}
.dest-box legend { font-weight: 800; padding: 0 6px; color: var(--green-dark); }
.input-num { width: 110px; text-align: right; padding: 6px 8px; border: 1px solid var(--line); border-radius: 6px; font: inherit; }
.tag {
  display: inline-block; font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 999px;
  background: #eef2f0; color: var(--ink); text-transform: capitalize;
}
.tag-receipt { background: #e6f9f1; color: #0b7a55; }
.tag-issue { background: #e6edf6; color: #1a3a6b; }
.tag-adjustment { background: #fdf6e6; color: #9a6800; }
.tag-physical_count { background: #f3e8fd; color: #5b21b6; }
.tag-draft { background: #f3f4f6; color: #4b5563; }
.tag-submitted, .tag-locked { background: #e6f9f1; color: #0b7a55; }
.tag-pending_receipt { background: #fff4e5; color: #9a5b00; }
.tag-confirmed { background: #e6f9f1; color: #0b7a55; }
.tag-discrepancy { background: #fde8e8; color: #9b1c1c; }
.tag-cancelled { background: #f3f4f6; color: #4b5563; }

/* AMC / Min / Max order levels */
.row-below-min { background: #fde8e8; }
.row-above-max { background: #fff4e5; }
.row-no-amc { background: #f3f4f6; }
.tag-below-min { background: #fde8e8; color: #9b1c1c; text-transform: none; }
.tag-level-ok { background: #e6f9f1; color: #0b7a55; text-transform: none; }
.tag-above-max { background: #fff4e5; color: #9a5b00; text-transform: none; }
.tag-no-amc { background: #f3f4f6; color: #4b5563; text-transform: none; }
.tag-override { background: #e6edf6; color: #1a3a6b; text-transform: none; font-size: 11px; }
.kpi-alert { border-top-color: var(--red); }
.kpi-alert strong { color: var(--red); }
.table-scroll { overflow-x: auto; }
.override-panel { font-size: 13px; }
.override-panel summary { cursor: pointer; color: var(--navy); font-weight: 700; }
.override-panel .stack-form {
  display: flex; flex-direction: column; gap: 6px; margin-top: 8px;
  min-width: 160px; padding: 8px; border: 1px solid var(--line); border-radius: 8px; background: #fff;
}
.override-panel .stack-form label { font-size: 12px; font-weight: 700; display: flex; flex-direction: column; gap: 2px; }
.override-panel .stack-form input { font-weight: 400; padding: 6px 8px; border: 1px solid var(--line); border-radius: 6px; }
.btn-sm { padding: 5px 10px; font-size: 12.5px; }
.actions-cell { min-width: 120px; }

/* Reports infographics */
.info-section { margin-bottom: 16px; }
.info-lead { margin: -4px 0 14px; }
.info-kpis { margin-bottom: 18px; }
.info-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.info-panel {
  background: linear-gradient(180deg, #f8fbf9 0%, #fff 48%);
  border: 1px solid #d7e5de;
  border-radius: 12px;
  padding: 14px 14px 10px;
  min-height: 200px;
}
.info-panel-wide { grid-column: 1 / -1; }
.chart-title {
  margin: 0 0 10px;
  font-size: 15px;
  font-family: var(--font-display);
  color: var(--navy);
  font-weight: 700;
}
.chart-block { width: 100%; }
.chart-svg { width: 100%; height: auto; max-height: 280px; display: block; }
.chart-svg-tall { max-height: 260px; }
.chart-label { font-size: 12px; fill: var(--ink); font-family: var(--font-ui); }
.chart-value { font-size: 12px; fill: var(--muted); font-family: var(--font-ui); font-weight: 700; }
.chart-tick { font-size: 11px; fill: var(--muted); font-family: var(--font-ui); }
.chart-grid { stroke: #e5ebe7; stroke-width: 1; }
.chart-empty { padding: 28px 8px; text-align: center; font-size: 14px; }
.chart-legend {
  display: flex; flex-wrap: wrap; gap: 12px 16px;
  margin: 0 0 8px; font-size: 13px; color: var(--muted); font-weight: 600;
}
.chart-legend .swatch, .donut-legend .swatch, .funnel-hint + .swatch {
  display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; vertical-align: middle;
}
.swatch { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; vertical-align: middle; }
.donut-layout { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; }
.donut-svg { width: 160px; height: 160px; flex: 0 0 auto; }
.donut-total { font-size: 16px; font-weight: 800; fill: var(--green-dark); font-family: var(--font-display); }
.donut-total-sub { font-size: 11px; fill: var(--muted); font-family: var(--font-ui); }
.donut-legend { list-style: none; margin: 0; padding: 0; flex: 1 1 160px; }
.donut-legend li {
  display: grid; grid-template-columns: 14px 1fr auto auto; gap: 6px 8px;
  align-items: center; font-size: 13px; padding: 5px 0; border-bottom: 1px solid #eef2f0;
}
.donut-legend li:last-child { border-bottom: 0; }
.donut-legend strong { font-variant-numeric: tabular-nums; color: var(--ink); }
.donut-legend em { font-style: normal; color: var(--muted); font-weight: 700; min-width: 2.5em; text-align: right; }
.funnel { display: flex; flex-direction: column; gap: 10px; }
.funnel-step { display: flex; flex-direction: column; gap: 4px; }
.funnel-meta { display: flex; justify-content: space-between; gap: 8px; font-size: 13px; }
.funnel-label { font-weight: 700; color: var(--ink); }
.funnel-hint { color: var(--muted); }
.funnel-track {
  position: relative; height: 28px; background: #eef4f0; border-radius: 8px; overflow: hidden;
}
.funnel-fill { height: 100%; border-radius: 8px; min-width: 4px; transition: width .35s ease; }
.funnel-val {
  position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
  font-size: 13px; color: var(--ink); font-variant-numeric: tabular-nums;
}
@media (max-width: 980px) {
  .info-grid { grid-template-columns: 1fr; }
  .info-panel-wide { grid-column: auto; }
}

.notify-btn { position: relative; }
.notify-badge {
  display: inline-block; min-width: 1.25em; padding: 1px 6px; margin-left: 4px;
  border-radius: 999px; background: #c8102e; color: #fff; font-size: 11px; font-weight: 800;
  line-height: 1.4; vertical-align: middle;
}
.row-unread { background: #f3fbf7; }
.tag-inbound { background: #fff4e5; color: #9a5b00; }
.tag-discrepancy { background: #fde8e8; color: #9b1c1c; }
.tag-info { background: #e6edf6; color: #1a3a6b; }
.gap-list { margin: 0; padding-left: 1.2rem; columns: 2; }
.table-scroll { overflow-x: auto; }
.total-row { background: #f0f7f3; }
.muted-row { opacity: .72; }
.nowrap { white-space: nowrap; }
#issue-lines-table select { width: 100%; max-width: 280px; }

.flash { margin: 12px 24px 0; padding: 12px 14px; border-radius: 8px; font-weight: 600; }
.flash-ok { background: #e6f9f1; border: 1px solid #bfead7; color: #0b7a55; }
.flash-error { background: #fde8eb; border: 1px solid #f4c2cb; color: #9f1239; }
.flash-warn { background: #fdf6e6; border: 1px solid #edd9a8; color: #9a6800; }
.kv { display: grid; grid-template-columns: 140px 1fr; gap: 8px 16px; }
.kv dt { color: var(--muted); font-weight: 700; }
.kv dd { margin: 0; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); border: 0; }
.nav-toggle { display: none; background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 8px; cursor: pointer; }
.nav-toggle svg { width: 20px; height: 20px; display: block; }
.sidebar-backdrop { display: none; }

/* Auth */
body.bare { min-height: 100vh; }
.auth-shell { display: grid; grid-template-columns: 1.1fr 1fr; min-height: 100vh; }
.auth-hero {
  background: linear-gradient(160deg, #0d5c45 0%, #0b8f63 55%, #1a3a6b 120%);
  color: #fff; padding: 48px; display: flex; flex-direction: column; justify-content: space-between;
}
.auth-hero-brand { display: flex; gap: 14px; align-items: center; }
.auth-hero-brand img { border-radius: 50%; background: #fff; padding: 3px; }
.auth-hero-org { font-size: 14px; opacity: .9; max-width: 280px; }
.auth-hero-copy h1 { font-family: var(--font-display); font-size: 42px; margin: 24px 0 10px; }
.auth-hero-copy p { font-size: 16px; opacity: .92; max-width: 420px; line-height: 1.5; }
.auth-hero-foot { font-size: 13px; opacity: .7; }
.auth-panel { display: flex; align-items: center; justify-content: center; padding: 32px; }
.auth-card {
  width: 100%; max-width: 400px; background: #fff; border-radius: 14px; padding: 28px;
  box-shadow: var(--shadow); border: 1px solid var(--line);
}
.auth-card h2 { margin: 0 0 6px; font-family: var(--font-display); }
.auth-lead { color: var(--muted); margin: 0 0 18px; }
.auth-card .form label { margin-bottom: 12px; }
.error-block { text-align: center; }

@media (max-width: 860px) {
  .sidebar { position: fixed; left: 0; top: 0; transform: translateX(-105%); transition: transform .2s; z-index: 40; }
  body.nav-open .sidebar { transform: none; }
  .nav-toggle { display: inline-flex; }
  body.nav-open .sidebar-backdrop {
    display: block; position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 30;
  }
  .auth-shell { grid-template-columns: 1fr; }
  .auth-hero { min-height: auto; padding: 28px; }
}
