/* ============================================================================
   AGC Quarry ERP — application chrome & component system
   Brand baseline: AGC Brand Portal v2.1 (portal.html). Primitives in
   design-tokens.css (loaded first). Local Inter variable font only — no CDN.
   This file is the full interaction system: shell, nav, page header,
   KPI/cockpit, unified table system (toolbar/sort/quick-actions/expand),
   stepper, cash gate, forms, toasts, skeletons, empty states.
   ============================================================================ */
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("../fonts/inter-latin-wght-normal.woff2") format("woff2-variations");
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: var(--font-sans);
  color: var(--agc-dark);
  background: var(--agc-canvas);
  background-image: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23d5d4ce' fill-opacity='0.25'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
  min-height: 100vh;
}

.accent-bar { height: 5px; background: var(--gradient-accent); }
.shell { display: grid; grid-template-columns: 236px 1fr; min-height: calc(100vh - 5px); }
/* No sidebar pre-auth (login etc.) — let main fill the viewport. */
.shell--auth { grid-template-columns: 1fr; }

/* ── SIDEBAR ────────────────────────────────────────────────────────────── */
.sidebar {
  background: var(--gradient-chrome); color: #fff;
  padding: 20px 0 18px; position: relative; display: flex; flex-direction: column;
}
.sidebar::after { content: ''; position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(ellipse at 80% 0%, rgba(35,170,8,0.06), transparent 55%); }
.sidebar > * { position: relative; z-index: 1; }

.brand-lockup { display: flex; align-items: center; gap: 10px; padding: 0 18px 2px; }
.brand-lockup svg { display: block; flex-shrink: 0; }
.brand-name { font-size: 17px; font-weight: 800; letter-spacing: -0.02em; line-height: 1.1; color: #fff; }
.brand-name span { color: var(--agc-green); }
.brand-division { font-size: 9px; letter-spacing: 0.3em; text-transform: uppercase; color: var(--agc-slate); font-weight: 500; margin-top: 3px; }

.new-btn {
  margin: 14px 16px 6px; display: flex; align-items: center; justify-content: center; gap: 7px;
  padding: 10px; border-radius: 8px; background: rgba(35,170,8,0.14); color: var(--agc-green-2);
  border: 1px solid rgba(35,170,8,0.3); font: inherit; font-size: 11px; font-weight: 700;
  letter-spacing: 0.1em; text-transform: uppercase; cursor: pointer; transition: 0.15s; text-decoration: none;
}
.new-btn svg { width: 15px; height: 15px; }
.new-btn:hover { background: rgba(35,170,8,0.22); color: #fff; }

.nav { display: flex; flex-direction: column; margin-top: 4px; }
.nav a {
  display: flex; align-items: center; gap: 11px; color: var(--agc-slate); text-decoration: none;
  padding: 9px 18px 9px 21px; font-size: 11.5px; font-weight: 600; letter-spacing: 0.08em;
  text-transform: uppercase; border-left: 3px solid transparent; transition: 0.2s;
}
.nav a svg { width: 16px; height: 16px; flex-shrink: 0; opacity: 0.8; }
.nav a:hover { color: var(--agc-grey); background: rgba(255,255,255,0.03); }
.nav a.active, .nav a[aria-current="page"] { color: #fff; border-left-color: var(--agc-green); background: rgba(35,170,8,0.07); }
.nav a.active svg, .nav a[aria-current="page"] svg { opacity: 1; color: var(--agc-green-2); }
.nav a .count { margin-left: auto; background: #2a3244; color: var(--agc-grey); font-size: 9px; padding: 1px 7px; border-radius: 10px; letter-spacing: 0; }
.nav a .count.alert { background: rgba(206,39,45,0.25); color: #ff9a9d; }
.nav .nav-section { margin: 12px 0 2px; padding: 0 18px; font-size: 9px; color: #3a4353; letter-spacing: 0.25em; text-transform: uppercase; font-weight: 600; }

.sidebar-foot { margin: 14px 12px 0; padding: 14px 6px 0; border-top: 1px solid #232a38; display: flex; align-items: center; gap: 9px; }
.avatar { width: 30px; height: 30px; border-radius: 8px; background: var(--agc-green); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 12px; text-transform: uppercase; }
.sidebar-foot .who { font-size: 11px; font-weight: 600; color: #fff; }
.sidebar-foot .who small { display: block; color: var(--agc-slate); font-size: 9px; letter-spacing: 0.1em; text-transform: uppercase; font-weight: 500; }
.sidebar-foot form { margin-left: auto; }
.sidebar-foot .label { color: var(--agc-slate); }

/* ── MAIN + PAGE HEADER ─────────────────────────────────────────────────── */
.main { padding: 0; min-width: 0; }
/* Let tables scroll inside their wrapper instead of stretching the layout */
.card, .kpi { min-width: 0; }
.g-main > *, .grid-2 > *, .flow > *, .kpis > * { min-width: 0; }
.tbl-wrap { max-width: 100%; }
.pagehead { background: #fff; border-bottom: 1px solid var(--color-border); padding: 15px clamp(16px, 3vw, 44px) 17px; position: sticky; top: 0; z-index: 20; box-shadow: var(--shadow-sm); }
.crumbs { font-size: 10px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--agc-slate); margin-bottom: 8px; display: flex; gap: 7px; align-items: center; flex-wrap: wrap; }
.crumbs a { color: var(--agc-slate); text-decoration: none; }
.crumbs a:hover { color: var(--agc-green); }
.crumbs .sep { color: #c9cbc7; }
.crumbs .cur { color: var(--agc-green); font-weight: 600; }
.ph-row { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.ph-row h1 { font-size: 24px; font-weight: 800; letter-spacing: -0.02em; margin: 0; }
.ph-row .spacer { flex: 1; }
/* Fluid: fill the device viewport (no fixed cap) — the sidebar takes a fixed
   column, the content flexes to whatever width the device gives it. */
.body { padding: 28px clamp(16px, 3vw, 44px) 60px; max-width: none; }

/* ── HEADINGS ───────────────────────────────────────────────────────────── */
h1 { font-size: 24px; font-weight: 800; color: var(--agc-dark); letter-spacing: -0.02em; margin-bottom: 20px; }
h1 .muted { font-size: 13px; font-weight: 400; letter-spacing: 0; }
h2 { font-size: 12px; font-weight: 700; color: var(--agc-dark); letter-spacing: 0.1em; text-transform: uppercase; margin-bottom: 14px; padding-bottom: 12px; border-bottom: 1px solid var(--color-border-row); display: flex; align-items: center; gap: 8px; }
h2 .r { margin-left: auto; }

/* ── CARDS ──────────────────────────────────────────────────────────────── */
.card { background: #fff; border: 1px solid rgba(0,0,0,0.04); border-radius: var(--radius-lg); padding: 22px 26px; box-shadow: var(--shadow); }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; margin-bottom: 20px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; align-items: start; }
.g-main { display: grid; grid-template-columns: 1.5fr 1fr; gap: 20px; align-items: start; }

/* ── KPI COCKPIT ────────────────────────────────────────────────────────── */
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 20px; }
.kpi { background: #fff; border: 1px solid rgba(0,0,0,0.04); border-radius: var(--radius-lg); padding: 18px 20px; box-shadow: var(--shadow-sm); position: relative; overflow: hidden; text-decoration: none; display: block; }
a.kpi:hover { box-shadow: var(--shadow); transform: translateY(-2px); transition: 0.2s; }
.kpi .lab { font-size: 9px; letter-spacing: 0.2em; text-transform: uppercase; color: var(--agc-slate); font-weight: 600; display: flex; align-items: center; gap: 6px; }
.kpi .lab svg { width: 13px; height: 13px; color: var(--agc-green); }
.kpi .val { font-size: 28px; font-weight: 800; letter-spacing: -0.02em; margin-top: 8px; color: var(--agc-dark); }
.kpi .val small { font-size: 15px; color: var(--agc-slate); font-weight: 700; }
.kpi .dl { font-size: 11px; color: var(--agc-slate); margin-top: 2px; }
.kpi .dl b { color: var(--agc-green-deep); }
.kpi.alert { border-color: rgba(217,138,0,0.3); background: linear-gradient(180deg, #fffdf8, #fff); }
.kpi.alert .val, .kpi.alert .lab svg { color: var(--agc-amber); }
.kpi.good { border-color: rgba(35,170,8,0.25); }

.stat { min-height: 118px; }
.stat .label { font-size: 10px; letter-spacing: 0.25em; text-transform: uppercase; color: var(--agc-green); font-weight: 600; margin-bottom: 6px; display: block; }
.stat-num { font-size: 30px; font-weight: 800; letter-spacing: -0.02em; color: var(--agc-dark); }
.stat-sub { color: var(--agc-slate); font-size: 12px; margin-top: 4px; }

/* ── BAR CHART (inline, no lib) ─────────────────────────────────────────── */
.bars { display: flex; flex-direction: column; gap: 12px; }
.bar-row { display: grid; grid-template-columns: 96px 1fr 74px; align-items: center; gap: 12px; font-size: 12.5px; }
.bar-track { height: 22px; background: var(--color-surface-alt); border-radius: 5px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 5px; background: linear-gradient(90deg, var(--agc-green), var(--agc-green-2)); min-width: 3px; transition: width 0.4s ease; }
.bar-fill.byproduct { background: linear-gradient(90deg, #536877, #6b7f8e); }
.bar-row .v { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; color: var(--agc-body); }

/* ── ALERTS + ACTIVITY FEED ─────────────────────────────────────────────── */
.alert-item { display: flex; align-items: center; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--color-border-row); font-size: 12.5px; }
.alert-item:last-child { border-bottom: 0; }
.alert-item .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--agc-amber); flex-shrink: 0; }
.alert-item .grow { flex: 1; }
.alert-item a { color: var(--agc-green); font-weight: 600; text-decoration: none; white-space: nowrap; }

.feed { list-style: none; display: flex; flex-direction: column; }
.feed li { padding: 10px 0 10px 16px; border-bottom: 1px solid var(--color-border-row); font-size: 12.5px; color: var(--agc-body); position: relative; }
.feed li:last-child { border-bottom: 0; }
.feed li::before { content: ''; position: absolute; left: 0; top: 15px; width: 6px; height: 6px; border-radius: 50%; background: var(--agc-grey); }
.feed li time { display: block; font-size: 10px; letter-spacing: 0.06em; color: var(--agc-slate); text-transform: uppercase; margin-bottom: 2px; font-weight: 500; }
/* BRD 6.1.2 — by-product/audit rows in red */
.feed li.red, .feed li.audit-red { color: var(--color-audit-flag); font-weight: 600; }
.feed li.red::before, .feed li.audit-red::before { background: var(--color-audit-flag); }

.activity { list-style: none; display: flex; flex-direction: column; }
.activity li { padding: 9px 0; border-bottom: 1px solid var(--color-border-row); font-size: 12.5px; color: var(--agc-body); }
.activity li:last-child { border-bottom: 0; }
.activity .label { display: block; text-transform: none; letter-spacing: 0.02em; font-size: 10px; color: var(--agc-slate); font-weight: 500; margin-bottom: 2px; }
.audit-red, .audit-red td { color: var(--color-audit-flag) !important; font-weight: 600; }

/* ── TABLE SYSTEM ───────────────────────────────────────────────────────── */
.toolbar { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.search { display: flex; align-items: center; gap: 8px; background: #fff; border: 1px solid #e0dfdb; border-radius: 8px; padding: 8px 12px; min-width: 240px; }
.search svg { width: 15px; height: 15px; color: var(--agc-slate); flex-shrink: 0; }
.search input { border: none; outline: none; font: inherit; font-size: 13px; width: 100%; background: transparent; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { padding: 6px 12px; border-radius: 20px; border: 1px solid #e0dfdb; background: #fff; font: inherit; font-size: 11px; color: var(--agc-slate); cursor: pointer; letter-spacing: 0.03em; transition: 0.15s; text-decoration: none; }
.chip:hover { border-color: var(--agc-grey); }
.chip.on { background: var(--agc-dark); color: #fff; border-color: var(--agc-dark); font-weight: 600; }
.count { margin-left: auto; font-size: 11px; color: var(--agc-slate); letter-spacing: 0.03em; }
.count b { color: var(--agc-dark); }

.tbl-wrap { background: #fff; border: 1px solid var(--color-border); border-radius: 8px; overflow-x: auto; box-shadow: var(--shadow-sm); }

table.data { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 12.5px; background: #fff; }
.tbl-wrap table.data { border: 0; }
table.data thead th, table.data > tr:first-child th { background: var(--agc-dark); color: #fff; text-align: left; padding: 11px 14px; font-size: 9px; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; }
table.data th.sortable { cursor: pointer; user-select: none; }
table.data th.sortable a { color: inherit; text-decoration: none; display: inline-flex; align-items: center; gap: 5px; }
table.data th.sortable:hover { background: #232b3a; }
table.data th .caret { opacity: 0.4; font-size: 8px; }
table.data th.sorted .caret { opacity: 1; color: var(--agc-green-2); }
table.data td { padding: 11px 14px; border-bottom: 1px solid var(--color-border-row); color: var(--agc-body); vertical-align: middle; transition: background 0.15s; }
table.data tbody tr:nth-child(even) td, table.data tr:nth-child(even) td { background: #fafaf8; }
table.data tbody tr:hover td, table.data tr:hover td { background: #f0f7ee; color: var(--agc-dark); }
table.data tr:last-child td { border-bottom: 0; }
/* Uniform left alignment across every table — headers and cells, numbers
   included — so all columns line up on the same edge. tabular-nums keeps digit
   widths even; nowrap stops amounts breaking across lines. */
th.num, td.num { text-align: left; font-variant-numeric: tabular-nums; letter-spacing: normal; white-space: nowrap; }
table.data thead th.num, table.data > tr:first-child th.num { text-align: left; }
table.data th.num.sortable a { justify-content: flex-start; }
table.data a.lead, table.data td .lead { font-weight: 600; color: var(--agc-dark); text-decoration: none; }
table.data a.lead:hover { color: var(--agc-green); }
table.data code { font-size: 11px; }

.qa { display: flex; gap: 4px; justify-content: flex-end; }
.qa a, .qa button { width: 28px; height: 28px; border-radius: 6px; border: 1px solid var(--color-border); background: #fff; color: var(--agc-slate); cursor: pointer; display: inline-flex; align-items: center; justify-content: center; transition: 0.15s; text-decoration: none; }
.qa a svg, .qa button svg { width: 14px; height: 14px; }
.qa a:hover, .qa button:hover { border-color: var(--agc-green); color: var(--agc-green); background: var(--agc-green-tint); }
tr.grp-row .qa { opacity: 0; }
tr.grp-row:hover .qa { opacity: 1; }
@media (hover: none) { tr.grp-row .qa { opacity: 1; } }
tr.grp-row { cursor: pointer; }
.expander { display: inline-block; color: var(--agc-slate); transition: transform 0.2s; }
.expander.open { transform: rotate(90deg); color: var(--agc-green); }
.hidden { display: none !important; }
tr.detail td { border-bottom: 1px solid var(--color-border-row); }

.empty { text-align: center; padding: 46px 20px; color: var(--agc-slate); }
.empty svg { width: 42px; height: 42px; opacity: 0.35; margin-bottom: 12px; }
.empty p { font-size: 13px; margin-bottom: 16px; }

/* ── STEPPER ────────────────────────────────────────────────────────────── */
.stepper { display: flex; align-items: center; margin: 4px 0 24px; overflow-x: auto; padding-bottom: 4px; }
.step { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.step .ball { width: 30px; height: 30px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 800; background: #fff; border: 2px solid var(--agc-grey); color: var(--agc-slate); }
.step .stx { font-size: 10px; letter-spacing: 0.1em; text-transform: uppercase; font-weight: 700; color: var(--agc-slate); }
.step.done .ball { background: var(--agc-green); border-color: var(--agc-green); color: #fff; }
.step.done .stx { color: var(--agc-green-deep); }
.step.cur .ball { background: var(--agc-dark); border-color: var(--agc-dark); color: #fff; box-shadow: 0 0 0 4px rgba(25,30,43,0.12); }
.step.cur .stx { color: var(--agc-dark); }
.step .line { width: 40px; height: 2px; background: var(--agc-grey); margin: 0 8px; }
.step.done .line { background: var(--agc-green); }

.flow { display: grid; grid-template-columns: 1.5fr 1fr; gap: 20px; align-items: start; }
.receipts { display: flex; flex-direction: column; gap: 8px; }
.receipt { display: flex; align-items: center; gap: 10px; padding: 11px 14px; background: var(--color-surface-alt); border: 1px solid var(--color-border); border-radius: 8px; font-size: 12px; color: var(--agc-body); }
.receipt .ck { width: 18px; height: 18px; border-radius: 50%; background: var(--agc-green); color: #fff; display: flex; align-items: center; justify-content: center; flex-shrink: 0; font-size: 11px; }
.receipt b { color: var(--agc-dark); }
.receipt .r { margin-left: auto; font-variant-numeric: tabular-nums; font-weight: 600; color: var(--agc-slate); }

.gate { background: linear-gradient(180deg, #0f1622, #191e2b); color: #fff; border-radius: 12px; padding: 24px; text-align: center; box-shadow: var(--shadow-lg); }
.gate .lab { font-size: 10px; letter-spacing: 0.22em; text-transform: uppercase; color: var(--agc-slate); font-weight: 600; }
.gate .amt { font-size: 40px; font-weight: 800; letter-spacing: -0.02em; margin: 8px 0; }
.gate .amt small { font-size: 18px; color: var(--agc-green-2); }
.gate .sub { font-size: 11px; color: var(--agc-grey); margin-bottom: 16px; }
.gate input { width: 100%; padding: 12px; border-radius: 8px; border: 1px solid #2a3244; background: #0d1018; color: #fff; font: inherit; font-size: 16px; text-align: center; font-variant-numeric: tabular-nums; margin-bottom: 12px; }
.gate .btn { width: 100%; justify-content: center; padding: 12px; font-size: 12px; }
.gate .hint { margin-top: 12px; font-size: 10px; color: var(--agc-slate); letter-spacing: 0.05em; }

.totals-box { min-width: 280px; font-size: 13px; }
.totals-box .tr { display: flex; justify-content: space-between; padding: 6px 0; color: var(--agc-body); }
.totals-box .tr b, .totals-box .tr span { font-variant-numeric: tabular-nums; }
.totals-box .tr.mut { color: var(--agc-slate); }
.totals-box .tr.grand { padding-top: 12px; margin-top: 6px; border-top: 2px solid var(--agc-green); font-size: 15px; font-weight: 800; }
.totals-box .tr.grand span:last-child { color: var(--agc-green); }

/* ── BUTTONS ────────────────────────────────────────────────────────────── */
.btn { display: inline-flex; align-items: center; gap: 7px; padding: 9px 17px; border-radius: 6px; border: none; cursor: pointer; font-family: var(--font-sans); font-size: 11px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; background: var(--agc-green); color: #fff; box-shadow: 0 1px 3px rgba(0,0,0,0.1); transition: 0.2s; text-decoration: none; }
.btn svg { width: 14px; height: 14px; }
.btn:hover { filter: brightness(1.1); transform: translateY(-2px); box-shadow: 0 4px 12px rgba(35,170,8,0.3); }
.btn:active { transform: translateY(0); box-shadow: 0 1px 3px rgba(35,170,8,0.2); }
.btn--secondary { background: var(--agc-dark); filter: none; }
.btn--secondary:hover { background: #2a3244; filter: none; box-shadow: 0 4px 12px rgba(25,30,43,0.3); }
.btn--danger { background: var(--agc-red); }
.btn--danger:hover { filter: brightness(1.08); box-shadow: 0 4px 12px rgba(206,39,45,0.3); }
.btn--ghost { background: transparent; color: var(--agc-slate); box-shadow: inset 0 0 0 1px #d6d5d0; }
.btn--ghost:hover { background: var(--color-surface-alt); transform: none; color: var(--agc-dark); box-shadow: inset 0 0 0 1px var(--agc-grey); }
.btn.sm, .btn--sm { padding: 6px 11px; font-size: 10px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none !important; box-shadow: none !important; }

/* ── BADGES ─────────────────────────────────────────────────────────────── */
.badge { display: inline-flex; align-items: center; gap: 5px; font-size: 9px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; padding: 3px 10px; border-radius: 20px; }
.badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge--success { background: var(--agc-green-tint); color: var(--agc-green-deep); }
.badge--warning { background: var(--agc-amber-tint); color: #8a5800; }
.badge--danger { background: var(--agc-red-tint); color: var(--agc-red); }
.badge--muted { background: #eceef0; color: var(--agc-slate); }

/* ── FORMS ──────────────────────────────────────────────────────────────── */
form.stack { display: flex; flex-direction: column; gap: 4px; max-width: 680px; }
.fsec { margin-bottom: 22px; }
.fsec .st { font-size: 10px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--agc-green); font-weight: 700; padding-bottom: 8px; border-bottom: 1px solid var(--color-border-row); margin-bottom: 14px; }
.errsum { background: var(--agc-red-tint); border: 1px solid rgba(206,39,45,0.3); border-left: 3px solid var(--agc-red); border-radius: 8px; padding: 12px 16px; margin-bottom: 20px; font-size: 12.5px; color: var(--agc-red); }
.errsum b { display: block; margin-bottom: 4px; letter-spacing: 0.04em; }
label, .label { font-size: 11px; font-weight: 600; letter-spacing: 0.04em; color: var(--agc-dark); text-transform: none; }
.label--wide { font-size: 9px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--agc-slate); }
.req { color: var(--agc-red); margin-left: 2px; }
input, select, textarea { font-family: var(--font-sans); font-size: 13px; color: var(--agc-dark); padding: 9px 12px; border: 1px solid #e0dfdb; border-radius: 6px; background: #fff; transition: box-shadow 0.12s, border-color 0.12s; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--agc-green); box-shadow: 0 0 0 2px rgba(35,170,8,0.18); }
input.bad, select.bad { border-color: var(--agc-red); box-shadow: 0 0 0 2px rgba(206,39,45,0.15); }
.formline { display: grid; grid-template-columns: 190px 1fr; gap: 14px; align-items: start; padding: 7px 0; }
.formline > label { padding-top: 9px; }
.formline .help, .fe { font-size: 11px; color: var(--agc-slate); margin-top: 5px; }
.fe { color: var(--agc-red); }
.actions { display: flex; gap: 10px; margin: 18px 0; flex-wrap: wrap; align-items: center; }

/* ── MESSAGES / TOASTS ──────────────────────────────────────────────────── */
.messages { margin-bottom: 20px; }
.msg { padding: 12px 16px; border-radius: 8px; margin-bottom: 8px; font-size: 13px; background: #fff; border: 1px solid var(--color-border); border-left: 3px solid var(--agc-slate); box-shadow: var(--shadow-sm); }
.msg--success { border-left-color: var(--agc-green); color: var(--agc-green-deep); background: #f4fbf2; }
.msg--warning { border-left-color: var(--agc-amber); color: #8a5800; background: #fdf8ee; }
.msg--error, .msg--danger { border-left-color: var(--agc-red); color: var(--agc-red); background: #fdf3f3; }
.msg--info { border-left-color: var(--agc-slate); color: var(--agc-dark); }

.toast-wrap { position: fixed; bottom: 24px; right: 24px; display: flex; flex-direction: column; gap: 10px; z-index: 80; }
.toast { background: #fff; border: 1px solid var(--color-border); border-left: 3px solid var(--agc-green); border-radius: 8px; box-shadow: var(--shadow-lg); padding: 12px 16px 12px 14px; display: flex; align-items: center; gap: 10px; font-size: 12.5px; min-width: 280px; animation: slidein 0.25s ease; }
.toast.warn { border-left-color: var(--agc-amber); }
.toast.err { border-left-color: var(--agc-red); }
.toast .tk { width: 22px; height: 22px; border-radius: 50%; background: var(--agc-green-tint); color: var(--agc-green); display: flex; align-items: center; justify-content: center; flex-shrink: 0; font-size: 12px; }
@keyframes slidein { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: none; } }

/* ── MODAL (B6 — reusable HTMX quick-create/quick-edit dialog) ──────────── */
dialog#modal-root { border: none; border-radius: var(--radius-lg); padding: 0; width: min(480px, 92vw); box-shadow: var(--shadow-lg); }
dialog#modal-root::backdrop { background: rgba(25, 30, 43, 0.45); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--color-border-row); }
.modal-head h3 { margin: 0; font-size: 15px; }
.modal-x { background: none; border: none; font-size: 20px; line-height: 1; cursor: pointer; color: var(--color-text-muted); padding: 2px 6px; }
.modal-x:hover { color: var(--agc-dark); }
.modal-body { padding: 18px 20px 20px; }

/* ── SKELETON (HTMX swaps) ──────────────────────────────────────────────── */
.skel { background: linear-gradient(90deg, #eee 25%, #f5f5f2 50%, #eee 75%); background-size: 200% 100%; animation: sk 1.2s infinite; border-radius: 4px; height: 12px; }
@keyframes sk { to { background-position: -200% 0; } }
.htmx-indicator { opacity: 0; transition: opacity 0.2s; }
.htmx-request .htmx-indicator, .htmx-request.htmx-indicator { opacity: 1; }

/* ── LOGIN ──────────────────────────────────────────────────────────────── */
.login-wrap {
  display: flex; align-items: center; justify-content: center;
  min-height: calc(100vh - 5px); padding: 6vh 20px; position: relative; overflow: hidden;
  background:
    radial-gradient(ellipse at 15% 8%, rgba(35,170,8,0.16), transparent 45%),
    radial-gradient(ellipse at 85% 92%, rgba(70,184,46,0.10), transparent 50%),
    linear-gradient(160deg, #1c2233, var(--agc-dark) 55%, #12151e);
}
/* Subtle repeating hexagon motif, echoes the brand mark. Inline SVG data-uri, no asset. */
.login-wrap::before {
  content: ''; position: absolute; inset: 0; pointer-events: none; opacity: 0.5;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='84' height='96' viewBox='0 0 84 96'%3E%3Cpolygon points='42,2 80,24 80,72 42,94 4,72 4,24' fill='none' stroke='%23ffffff' stroke-opacity='0.035' stroke-width='1.5'/%3E%3C/svg%3E");
  background-position: 0 0, 42px 48px;
}
.login-card {
  width: 380px; display: flex; flex-direction: column; gap: 14px; position: relative; overflow: hidden;
  z-index: 1; box-shadow: var(--shadow-lg); border: 1px solid rgba(255,255,255,0.06);
}
.login-card::before { content: ''; position: absolute; top: 0; left: 0; right: 0; height: 4px; background: var(--gradient-accent); }
.login-card form { display: flex; flex-direction: column; gap: 10px; }
.login-card h1 { margin-bottom: 0; font-size: 20px; }
.wordmark { font-weight: 900; letter-spacing: -0.02em; font-size: 22px; color: var(--agc-green); }
.wordmark span { color: var(--agc-dark); font-weight: 300; letter-spacing: 0.12em; font-size: 13px; }
.wordmark--dark { color: var(--agc-green); }
.wordmark--dark span { color: var(--agc-dark); }

/* ── MISC ───────────────────────────────────────────────────────────────── */
.pill-row { display: flex; gap: 8px; flex-wrap: wrap; }
.notepill { display: inline-block; background: var(--agc-green-tint); color: var(--agc-green-deep); font-size: 10px; letter-spacing: 0.06em; padding: 3px 10px; border-radius: 20px; font-weight: 600; }
code { background: var(--color-surface-alt); border: 1px solid var(--color-border); padding: 1px 7px; border-radius: 4px; font-size: 0.85em; }
.muted { color: var(--agc-slate); }
p { line-height: 1.6; }
p.muted { font-size: 13px; margin-bottom: 14px; }

/* ── FOCUS / SCROLLBAR / MOTION ─────────────────────────────────────────── */
:focus-visible { outline: 2px solid var(--agc-green); outline-offset: 2px; border-radius: 3px; }
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-track { background: var(--agc-canvas); }
::-webkit-scrollbar-thumb { background: var(--agc-grey); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--agc-slate); }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; } }
@supports not (font-variation-settings: normal) { body { font-family: Arial, Helvetica, sans-serif; } }

/* ── RESPONSIVE ─────────────────────────────────────────────────────────── */
@media (max-width: 1000px) {
  .kpis { grid-template-columns: 1fr 1fr; }
  .g-main, .grid-2, .flow { grid-template-columns: 1fr; }
}
@media (max-width: 820px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { flex-direction: row; flex-wrap: wrap; align-items: center; gap: 4px 6px; padding: 10px 12px; }
  .sidebar::after { display: none; }
  .brand-lockup { padding: 0 8px 0 4px; }
  .new-btn { margin: 0; order: 3; padding: 8px 12px; }
  .nav { flex-direction: row; flex-wrap: wrap; width: 100%; order: 5; margin-top: 4px; }
  .nav a { border-left: none; border-bottom: 3px solid transparent; padding: 7px 10px; font-size: 10px; letter-spacing: 0.05em; }
  .nav a.active { border-bottom-color: var(--agc-green); }
  .nav a .count, .nav .nav-section { display: none; }
  .sidebar-foot { order: 4; margin: 0 0 0 auto; border-top: 0; padding: 0; }
  .pagehead { padding: 14px 16px; position: static; }
  .body { padding: 18px 14px 40px; }
  .formline { grid-template-columns: 1fr; gap: 4px; }
  h1, .ph-row h1 { font-size: 20px; }
}
@media (max-width: 480px) {
  .kpis { grid-template-columns: 1fr; }
  .card { padding: 16px; }
  /* ── B9 field flows — dispatch/weighbridge, used one-handed away from a
     desk: bigger tap targets, 16px inputs (stops iOS zoom-on-focus), full-
     width stacked action buttons, single-column grids. ── */
  input, select, textarea { font-size: 16px; padding: 12px 14px; }
  .btn { padding: 13px 18px; }
  .actions { flex-direction: column; align-items: stretch; }
  .actions > .btn, .actions > a.btn, .actions > button { width: 100%; justify-content: center; }
}
