/* ========================================================================
 * NexusFFL — brand system
 * Modern-minimal: near-black navy + white, one navy-blue accent, restrained
 * color use elsewhere (status only). Generous whitespace, quiet borders,
 * soft shadows instead of heavy outlines.
 * ==================================================================== */
:root{
  --ink:#0b1220;         /* near-black navy — primary text, top bar */
  --ink-2:#1f2937;
  --bg:#f6f7f9;          /* app background */
  --surface:#ffffff;
  --surface-2:#f1f2f5;
  --border:#e5e7eb;
  --border-strong:#d7dae0;
  --text:#111827;
  --text-2:#5b6472;
  --text-muted:#8b93a1;

  --accent:#1b3a5c;      /* navy — primary action color */
  --accent-ink:#12283f;
  --accent-bg:#e7edf3;

  --success:#0f7a4d;
  --success-bg:#e7f6ee;
  --danger:#c0293c;
  --danger-bg:#fdecef;
  --warn:#a15c00;
  --warn-bg:#fdf2e0;
  --purple:#7c3aed;
  --purple-bg:#f2ebfe;

  --radius:10px;
  --radius-lg:14px;
  --shadow-sm: 0 1px 2px rgba(11,18,32,0.05);
  --shadow-md: 0 4px 16px rgba(11,18,32,0.08);
  --shadow-lg: 0 12px 40px rgba(11,18,32,0.14);

  --font: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-font-smoothing: antialiased; }
body {
  font-family: var(--font);
  background: var(--bg); color: var(--text); margin: 0; padding: 0;
  font-size: 14px; line-height: 1.55; letter-spacing: -0.001em;
}
.hidden { display: none !important; }

/* ---------------------------------------------------------------------- */
/* brand mark                                                              */
/* ---------------------------------------------------------------------- */
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark { width: 28px; height: 28px; flex: none; }
.brand-word { font-size: 16px; font-weight: 700; letter-spacing: -0.01em; color: inherit; }
.brand-word b { font-weight: 800; }

/* ---------------------------------------------------------------------- */
/* layout shell                                                            */
/* ---------------------------------------------------------------------- */
.topbar {
  background: var(--ink); color: #fff;
  padding: 12px 28px; display: flex; align-items: center; justify-content: space-between;
  gap: 14px; flex-wrap: wrap;
}
.topbar .brand-word { color: #fff; }
.topbar .badge { background: rgba(255,255,255,0.1); color: #c7d6e6; border: 1px solid rgba(255,255,255,0.14); }
.topbar .env-note { font-size: 12px; color: #aeb4c8; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.topbar button.small { background: rgba(255,255,255,0.06); color: #e7e9f5; border-color: rgba(255,255,255,0.16); }
.topbar button.small:hover { background: rgba(255,255,255,0.14); }

.wrap { max-width: 1240px; margin: 0 auto; padding: 24px 28px 60px; }

h1 { font-size: 20px; font-weight: 700; margin: 0; letter-spacing: -0.01em; }
h2 { font-size: 15px; font-weight: 700; margin: 0 0 14px; letter-spacing: -0.005em; }
h3 { font-size: 16px; font-weight: 700; margin: 0 0 4px; }
h4 { font-size: 12.5px; font-weight: 700; margin: 14px 0 8px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-2); }
.sub { color: var(--text-2); font-size: 13px; }

/* ---------------------------------------------------------------------- */
/* stat cards / badges                                                     */
/* ---------------------------------------------------------------------- */
.badge { font-size: 11.5px; font-weight: 600; padding: 4px 10px; border-radius: 999px; background: var(--success-bg); color: var(--success); white-space: nowrap; border: 1px solid transparent; }
.badge.warn { background: var(--danger-bg); color: var(--danger); }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 12px; margin-bottom: 20px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 16px 18px; box-shadow: var(--shadow-sm); }
.stat .n { font-size: 24px; font-weight: 700; letter-spacing: -0.01em; font-variant-numeric: tabular-nums; }
.stat .l { font-size: 12px; color: var(--text-2); margin-top: 2px; }
.stat.flag .n { color: var(--warn); }

/* ---------------------------------------------------------------------- */
/* cards / sections                                                        */
/* ---------------------------------------------------------------------- */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 20px 22px; margin-bottom: 18px; box-shadow: var(--shadow-sm);
}

/* ---------------------------------------------------------------------- */
/* form controls                                                           */
/* ---------------------------------------------------------------------- */
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.row > * { flex: 1; min-width: 140px; }
label { font-size: 12px; font-weight: 600; color: var(--text-2); display: block; margin-bottom: 4px; }
input, select, textarea {
  width: 100%; padding: 8px 11px; border: 1px solid var(--border-strong); border-radius: 8px;
  background: var(--surface); color: var(--text); font-size: 13.5px; font-family: inherit;
  transition: border-color .12s ease, box-shadow .12s ease;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-bg);
}
.field { min-width: 140px; }
.checkfield { display: flex; align-items: center; gap: 7px; min-width: 140px; }
.checkfield input[type=checkbox] { width: auto; accent-color: var(--accent); }

/* ---------------------------------------------------------------------- */
/* buttons                                                                 */
/* ---------------------------------------------------------------------- */
button {
  padding: 8px 15px; border: 1px solid var(--border-strong); border-radius: 8px;
  background: var(--surface); color: var(--text); font-size: 13.5px; font-weight: 600;
  cursor: pointer; font-family: inherit; transition: background .12s ease, border-color .12s ease, transform .04s ease;
}
button:hover { background: var(--surface-2); border-color: var(--border-strong); }
button:active { transform: translateY(1px); }
button.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
button.primary:hover { background: var(--accent-ink); border-color: var(--accent-ink); }
button.small { padding: 5px 10px; font-size: 12px; }
button.danger { color: var(--danger); }
button.danger.primary { background: var(--danger); border-color: var(--danger); color: #fff; }

/* ---------------------------------------------------------------------- */
/* toolbar / table                                                         */
/* ---------------------------------------------------------------------- */
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 4px; }
.toolbar > input, .toolbar > select { flex: 1; min-width: 160px; }

table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th {
  text-align: left; padding: 10px 10px; color: var(--text-2); font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.03em; border-bottom: 1px solid var(--border); font-size: 11px; background: var(--surface-2);
}
th:first-child { border-top-left-radius: 8px; }
th:last-child { border-top-right-radius: 8px; }
td { padding: 10px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
tbody tr:hover td { background: var(--surface-2); }
tr.corrected-orig td { color: var(--text-muted); }
tr.corrected-orig td:first-child::before { content: "orig · "; font-size: 11px; }
tr.corrected-new td:first-child::before { content: "corrected · "; font-size: 11px; color: var(--accent); font-weight: 600; }

.tag { font-size: 11px; font-weight: 600; padding: 3px 9px; border-radius: 999px; white-space: nowrap; display: inline-block; margin: 1px 3px 1px 0; }
.tag.stock { background: var(--accent-bg); color: var(--accent-ink); }
.tag.disposed { background: var(--success-bg); color: var(--success); }
.tag.layaway { background: var(--warn-bg); color: var(--warn); }
.tag.consignment { background: var(--purple-bg); color: var(--purple); }
.tag.nfa { background: var(--danger-bg); color: var(--danger); }
.tag.verified { background: var(--success-bg); color: var(--success); }
.tag.lost { background: var(--danger-bg); color: var(--danger); }
.tag.denied { background: var(--danger-bg); color: var(--danger); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; }

/* ---------------------------------------------------------------------- */
/* modals                                                                  */
/* ---------------------------------------------------------------------- */
.modal-bg { position: fixed; inset: 0; background: rgba(11,18,32,0.45); backdrop-filter: blur(2px); display: flex; align-items: center; justify-content: center; z-index: 50; padding: 20px; overflow-y: auto; }
.modal { background: var(--surface); border-radius: var(--radius-lg); padding: 24px; max-width: 560px; width: 100%; max-height: 90vh; overflow-y: auto; box-shadow: var(--shadow-lg); }
.modal.wide { max-width: 780px; }
.modal h3 { margin: 0 0 14px; font-size: 16px; }
.modal .row { margin-bottom: 12px; }
.actions-right { text-align: right; margin-top: 16px; display: flex; gap: 8px; justify-content: flex-end; }

.audit { max-height: 200px; overflow-y: auto; font-size: 12.5px; color: var(--text-2); }
.audit .entry { padding: 7px 0; border-bottom: 1px solid var(--border); }
.audit .entry:last-child { border-bottom: none; }

.banner { background: var(--danger-bg); color: var(--danger); border-radius: var(--radius); padding: 12px 16px; font-size: 12.5px; margin-bottom: 18px; border: 1px solid rgba(192,41,60,0.15); }
.banner.warn2 { background: var(--warn-bg); color: var(--warn); border-color: rgba(161,92,0,0.15); }

.flag-item { border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; margin-bottom: 8px; font-size: 13.5px; background: var(--surface); }
.flag-item .hd { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 4px; }
.flag-item .actions { display: flex; gap: 6px; }

.csv-map-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; align-items: center; margin-bottom: 6px; }
.cc-list { max-height: 260px; overflow-y: auto; border: 1px solid var(--border); border-radius: 8px; padding: 10px; }
.cc-row { display: flex; justify-content: space-between; padding: 5px 0; border-bottom: 1px solid var(--border); font-size: 13.5px; }
.cc-row:last-child { border-bottom: none; }
.bar-row { display: grid; grid-template-columns: 110px 1fr 40px; gap: 8px; align-items: center; margin-bottom: 7px; font-size: 12.5px; }
.bar-track { background: var(--surface-2); border-radius: 4px; height: 14px; overflow: hidden; }
.bar-fill { background: var(--accent); height: 100%; border-radius: 4px; }
.checklist-item { display: flex; align-items: center; gap: 8px; padding: 5px 0; font-size: 13.5px; }
.error { color: var(--danger); font-size: 12.5px; min-height: 16px; margin-top: 4px; }
.success { color: var(--success); background: var(--success-bg); border-radius: var(--radius); padding: 8px 12px; font-size: 12.5px; margin-top: 8px; }
footer { text-align: center; color: var(--text-muted); font-size: 12px; margin-top: 34px; }

/* ---------------------------------------------------------------------- */
/* login / setup screen                                                    */
/* ---------------------------------------------------------------------- */
.auth-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background:
    radial-gradient(1200px 600px at 10% -10%, #161d33 0%, transparent 60%),
    radial-gradient(1000px 500px at 110% 10%, #14263d 0%, transparent 55%),
    var(--ink);
  padding: 24px;
}
.auth-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 34px 32px; max-width: 400px; width: 100%; box-shadow: var(--shadow-lg);
}
.auth-card .brand { margin-bottom: 18px; }
.auth-card .brand-mark { width: 32px; height: 32px; }
.auth-card .brand-word { font-size: 18px; color: var(--ink); }
.auth-card h1 { display: none; }
.auth-card > p.sub { margin: -12px 0 20px; }
.auth-card label { margin-top: 12px; }
.auth-card label:first-of-type { margin-top: 0; }
.auth-tabs {
  display: flex; gap: 4px; margin-bottom: 18px; background: var(--ink);
  border-radius: var(--radius); padding: 4px;
}
.auth-tab {
  flex: 1; border: none; background: transparent; color: var(--text-muted);
  font-size: 13px; font-weight: 600; padding: 8px 10px; border-radius: calc(var(--radius) - 2px);
  cursor: pointer; transition: background .15s, color .15s;
}
.auth-tab.active { background: var(--surface); color: var(--accent); }

@media print {
  body { background: #fff; padding: 0; }
  .no-print { display: none !important; }
  .card { border: none; box-shadow: none; padding: 0; }
  .topbar { display: none; }
}
