/* Corestone V2 — distilled from Corestone_Design_System_v1.html.
   Every token here is from the design system. No new tokens. */

/* Typography — uses the local system sans stack (system-ui / Segoe UI / Roboto),
   declared on `body` below. No @font-face / web-font requests are made, so there
   are no font 404/503s on the offline demo (zero external assets). To bundle a
   web font later, drop the .woff2 files in static/fonts/ and re-add @font-face
   blocks pointing at them — only do so once the files are actually present. */

:root {
  --navy: #1B3A6B;
  --navy-hover: #152d54;
  --gold: #C9A84C;
  --gold-light: #F5E6B8;
  --white: #FFFFFF;
  --grey-100: #F8F9FA;
  --grey-200: #E9ECEF;
  --grey-400: #CED4DA;
  --grey-600: #6C757D;
  --grey-800: #343A40;
  --green: #1E7E34;
  --green-light: #D4EDDA;
  --amber: #B45309;
  --amber-light: #FFF3CD;
  --red: #C00000;
  --red-light: #F8D7DA;
  --blue: #0056A6;
  --blue-light: #CCE5FF;
  --sidebar: 240px;
  --header: 56px;
  --radius: 6px;
  --radius-lg: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,0.08);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.12);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: 'DM Sans', system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  font-size: 14px;
  background: var(--grey-100);
  color: var(--grey-800);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}
a { color: var(--navy); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Layout ── */
.sidebar {
  width: var(--sidebar);
  background: var(--navy);
  position: fixed; top: 0; left: 0;
  height: 100vh;
  overflow-y: auto;
  z-index: 100;
  padding-bottom: 24px;
}
.main { margin-left: var(--sidebar); min-height: 100vh; display: flex; flex-direction: column; }
.topbar {
  background: var(--white);
  border-bottom: 1px solid var(--grey-400);
  height: var(--header);
  display: flex; align-items: center;
  padding: 0 24px; gap: 12px;
  position: sticky; top: 0; z-index: 50;
}
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.breadcrumb { font-size: 12px; color: var(--grey-600); display: flex; gap: 6px; }
.breadcrumb .crumb-active { color: var(--navy); font-weight: 600; }
.content { padding: 24px 28px; flex: 1; }

/* ── Sidebar ── */
.brand { padding: 18px 16px 14px; border-bottom: 1px solid rgba(255,255,255,0.1); }
.brand-name { font-size: 18px; font-weight: 700; color: var(--white); letter-spacing: -0.5px; }
.brand-sub { font-size: 10px; color: var(--gold); text-transform: uppercase; letter-spacing: 1px; margin-top: 2px; }
.brand-demo { font-size: 11px; color: rgba(255,255,255,0.55); margin-top: 6px; }

.nav-mod { border-bottom: 1px solid rgba(255,255,255,0.06); }
.nav-mod-hdr {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 14px;
  color: rgba(255,255,255,0.7);
  font-size: 12px; font-weight: 600;
  cursor: pointer;
  user-select: none;
  background: none;
  border: none;
  width: 100%;
  text-align: left;
  font-family: inherit;
}
.nav-mod-num {
  font-size: 10px; background: rgba(255,255,255,0.12);
  color: var(--gold);
  border-radius: 3px; padding: 1px 5px; font-weight: 700;
  min-width: 22px; text-align: center;
}

/* Clickable variant — e.g. 00 Dashboard at the sidebar top */
a.nav-mod-hdr,
.nav-mod-hdr.nav-mod-link {
  cursor: pointer;
  text-decoration: none;
}
a.nav-mod-hdr:hover,
.nav-mod-hdr.nav-mod-link:hover {
  background: rgba(255,255,255,0.07);
  color: var(--white);
  text-decoration: none;
}
a.nav-mod-hdr.active,
.nav-mod-hdr.nav-mod-link.active {
  background: rgba(201,168,76,0.15);
  color: var(--gold);
  border-left: 2px solid var(--gold);
  padding-left: 12px;
}
a.nav-mod-hdr.active .nav-mod-num,
.nav-mod-hdr.nav-mod-link.active .nav-mod-num {
  background: rgba(201,168,76,0.25);
  color: var(--gold);
}

.nav-sa-section { border-top: 2px solid var(--gold); margin-top: 12px; }
.nav-sa-hdr {
  display: flex; align-items: center; gap: 8px;
  padding: 12px 14px 8px;
  font-size: 10px; font-weight: 700;
  color: var(--gold);
  text-transform: uppercase; letter-spacing: 1px;
  cursor: pointer;
  user-select: none;
  background: transparent;
  border: none;
  width: 100%;
  text-align: left;
  font-family: inherit;
}
.nav-sa-hdr:hover { background: rgba(255,255,255,0.04); }
.nav-sa-chevron {
  margin-left: auto;
  font-size: 12px;
  color: var(--gold);
  transition: transform 200ms ease;
  display: inline-block;
}
.nav-sa-section.open .nav-sa-chevron,
.nav-mod.open .nav-sa-chevron { transform: rotate(90deg); }
.nav-sa-body { max-height: 0; overflow: hidden; transition: max-height 300ms ease; }
.nav-sa-section.open .nav-sa-body,
.nav-mod.open .nav-sa-body { max-height: 1200px; }
.nav-mod .nav-mod-hdr:hover { background: rgba(255,255,255,0.06); color: var(--white); }
.nav-sa {
  display: flex; align-items: center; gap: 6px;
  padding: 8px 14px; font-size: 13px;
  color: rgba(255,255,255,0.7);
  border-left: 3px solid transparent;
  text-decoration: none;
}
.nav-sa:hover { background: rgba(255,255,255,0.07); color: var(--white); text-decoration: none; }
.nav-sa.active {
  background: rgba(201,168,76,0.15);
  color: var(--gold);
  border-left-color: var(--gold);
  font-weight: 600;
}

/* ── Page header ── */
.page-hdr { margin-bottom: 24px; }
.page-title { font-size: 22px; font-weight: 700; color: var(--navy); }
.page-sub { font-size: 13px; color: var(--grey-600); margin-top: 4px; max-width: 900px; }

/* ── Cards ── */
.card { background: var(--white); border: 1px solid var(--grey-200); border-radius: var(--radius-lg); box-shadow: var(--shadow); padding: 20px; margin-bottom: 16px; }
.card-hdr { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.card-title { font-size: 16px; font-weight: 600; color: var(--grey-800); }

/* ── KPIs ── */
.kpi-row { display: grid; gap: 16px; margin-bottom: 24px; }
.kpi-3 { grid-template-columns: repeat(3, 1fr); }
.kpi-4 { grid-template-columns: repeat(4, 1fr); }
.kpi-5 { grid-template-columns: repeat(5, 1fr); }
.kpi-7 { grid-template-columns: repeat(7, 1fr); }
.kpi { background: var(--white); border: 1px solid var(--grey-200); border-radius: var(--radius-lg); padding: 16px 20px; box-shadow: var(--shadow); }
.kpi-label { font-size: 11px; font-weight: 600; color: var(--grey-600); text-transform: uppercase; letter-spacing: 0.5px; }
.kpi-value { font-size: 26px; font-weight: 700; color: var(--navy); margin: 4px 0; }
.kpi-value.green { color: var(--green); }
.kpi-value.amber { color: var(--amber); }
.kpi-value.red { color: var(--red); }
.kpi-sub { font-size: 11px; color: var(--grey-600); }

/* ── Buttons ── */
.btn { display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 16px; border-radius: var(--radius); border: none; cursor: pointer; font-family: inherit; font-size: 13px; font-weight: 600; transition: all 150ms; text-decoration: none; }
.btn-sm { height: 30px; padding: 0 12px; font-size: 12px; }
.btn-primary { background: var(--navy); color: var(--white); }
.btn-primary:hover { background: var(--navy-hover); text-decoration: none; }
.btn-secondary, .btn-outline { background: var(--white); color: var(--navy); border: 1px solid var(--navy); }
.btn-secondary:hover, .btn-outline:hover { background: var(--grey-100); text-decoration: none; }
.btn-danger { background: var(--red); color: var(--white); }
.btn-danger:hover { background: #a00000; text-decoration: none; }
.btn-gold { background: var(--gold); color: var(--navy); }
.btn-ghost { background: transparent; color: var(--navy); }
.btn-ghost:hover { text-decoration: underline; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ── Forms ── */
.form-grid { display: grid; gap: 16px; margin-bottom: 20px; }
.form-2 { grid-template-columns: 1fr 1fr; }
.form-3 { grid-template-columns: 1fr 1fr 1fr; }
.form-group { display: flex; flex-direction: column; gap: 5px; }
.form-group label { font-size: 13px; font-weight: 500; color: var(--grey-800); }
.req { color: var(--red); margin-left: 2px; }
.form-input, .form-select, .form-textarea {
  padding: 8px 12px;
  border: 1px solid var(--grey-400);
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 14px;
  color: var(--grey-800);
  background: var(--white);
  outline: none;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--navy);
  box-shadow: 0 0 0 3px rgba(27,58,107,0.1);
}
.form-input.readonly, .form-input:disabled { background: var(--grey-100); color: var(--grey-600); }
.form-textarea { min-height: 90px; resize: vertical; }
.form-hint { font-size: 12px; color: var(--grey-600); }
.form-error { font-size: 12px; color: var(--red); font-weight: 500; }

/* ── Step indicator (wizard) ── */
.step-row { display: flex; gap: 0; margin-bottom: 32px; }
.step { flex: 1; text-align: center; position: relative; }
.step:not(:last-child)::after {
  content: ''; position: absolute; top: 16px; left: 60%;
  width: 80%; height: 2px; background: var(--grey-200); z-index: 0;
}
.step.done:not(:last-child)::after { background: var(--green); }
.step-circle {
  width: 32px; height: 32px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700;
  margin: 0 auto 8px;
  position: relative; z-index: 1;
  border: 2px solid var(--grey-400);
  background: var(--white); color: var(--grey-600);
}
.step.done .step-circle { background: var(--green); border-color: var(--green); color: var(--white); }
.step.active .step-circle { background: var(--navy); border-color: var(--navy); color: var(--white); }
.step-label { font-size: 11px; font-weight: 600; color: var(--grey-600); }
.step.active .step-label { color: var(--navy); }
.step.done .step-label { color: var(--green); }

/* ── Tables ── */
.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th { text-align: left; padding: 10px 14px; background: var(--grey-100); color: var(--grey-600); font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; border-bottom: 2px solid var(--grey-200); }
.tbl td { padding: 11px 14px; border-bottom: 1px solid var(--grey-200); color: var(--grey-800); }
.tbl tr:last-child td { border-bottom: none; }
.tbl tr:hover td { background: var(--grey-100); }
.tbl-link { color: var(--navy); font-weight: 600; cursor: pointer; }
.tbl-empty { padding: 48px 20px; text-align: center; color: var(--grey-600); }
.tbl-empty-title { font-size: 15px; font-weight: 600; color: var(--grey-800); margin: 12px 0 6px; }

.table-toolbar { display: flex; align-items: center; gap: 12px; padding: 12px 0 16px; }
.table-toolbar input[type=text],
.table-toolbar select {
  height: 34px; padding: 0 12px;
  border: 1px solid var(--grey-400); border-radius: var(--radius);
  font-family: inherit; font-size: 13px; outline: none;
  background: var(--white);
}
.table-toolbar input[type=text] { flex: 1; max-width: 320px; }

/* ── Badges ── */
.badge { display: inline-flex; align-items: center; padding: 3px 9px; border-radius: 20px; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; }
.badge-success, .badge-green { background: var(--green-light); color: var(--green); }
.badge-warning, .badge-amber { background: var(--amber-light); color: var(--amber); }
.badge-danger, .badge-red { background: var(--red-light); color: var(--red); }
.badge-neutral, .badge-grey { background: var(--grey-200); color: var(--grey-600); }
.badge-info, .badge-blue { background: var(--blue-light); color: var(--blue); }
.badge-navy { background: #E8EDF5; color: var(--navy); }

/* ── Alerts / banners ── */
.alert { padding: 12px 16px; border-radius: var(--radius); border-left: 4px solid; font-size: 13px; margin-bottom: 16px; }
.alert-success { background: var(--green-light); border-color: var(--green); color: var(--green); }
.alert-warning { background: var(--amber-light); border-color: var(--gold); color: var(--amber); }
.alert-danger, .alert-error { background: var(--red-light); border-color: var(--red); color: var(--red); }
.alert-info { background: var(--blue-light); border-color: var(--navy); color: var(--navy); }

.status-banner { padding: 12px 16px; border-radius: var(--radius); border-left: 4px solid; margin-bottom: 20px; font-size: 13px; font-weight: 600; }
.status-banner.green { background: var(--green-light); border-color: var(--green); color: var(--green); }
.status-banner.amber { background: var(--amber-light); border-color: var(--amber); color: var(--amber); }
.status-banner.red { background: var(--red-light); border-color: var(--red); color: var(--red); }
.status-banner.navy { background: #E8EDF5; border-color: var(--navy); color: var(--navy); }

/* ── Filter bar (register search + select row) ── */
.filter-bar { display: flex; gap: 10px; margin-bottom: 18px; flex-wrap: wrap; align-items: center; }
.filter-bar input[type=text], .filter-bar input[type=search] { height: 34px; padding: 0 12px; border: 1px solid var(--grey-400); border-radius: var(--radius); font-family: inherit; font-size: 13px; outline: none; background: var(--white); min-width: 200px; flex: 1; max-width: 320px; }
.filter-bar select { height: 34px; padding: 0 10px; border: 1px solid var(--grey-400); border-radius: var(--radius); font-family: inherit; font-size: 13px; outline: none; background: var(--white); color: var(--grey-800); cursor: pointer; }
.filter-bar select:focus, .filter-bar input:focus { border-color: var(--navy); box-shadow: 0 0 0 2px rgba(30,52,93,0.08); }
.filter-bar-count { font-size: 12px; color: var(--grey-600); margin-left: auto; white-space: nowrap; }

.flash-stack { position: fixed; top: 12px; right: 16px; z-index: 200; max-width: 420px; }
.flash-stack .alert { box-shadow: var(--shadow-md); }

/* ── Login page ── */
.login-shell { display: flex; min-height: 100vh; align-items: center; justify-content: center; background: var(--navy); padding: 24px; }
.login-card { background: var(--white); padding: 32px 36px; width: 100%; max-width: 420px; border-radius: var(--radius-lg); box-shadow: var(--shadow-md); }
.login-brand { text-align: center; margin-bottom: 24px; }
.login-brand-name { font-size: 26px; font-weight: 700; color: var(--navy); letter-spacing: -0.5px; }
.login-brand-sub { font-size: 11px; color: var(--gold); text-transform: uppercase; letter-spacing: 1.5px; margin-top: 2px; }
.login-card .form-group { margin-bottom: 16px; }
.login-footer { text-align: center; margin-top: 16px; font-size: 12px; color: var(--grey-600); }

/* ── Role / option cards ── */
.role-card { background: var(--white); border: 1px solid var(--grey-200); border-radius: var(--radius); padding: 14px 16px; }
.role-name { font-size: 13px; font-weight: 700; color: var(--navy); margin-bottom: 6px; }
.role-can { font-size: 11px; color: var(--green); margin-bottom: 4px; }
.role-cannot { font-size: 11px; color: var(--red); }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }

.sect-tag { display: inline-flex; gap: 6px; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.8px; color: var(--navy); background: #E8EDF5; padding: 4px 10px; border-radius: 3px; margin-bottom: 20px; }

.actions-row { display: flex; gap: 10px; justify-content: flex-end; margin-top: 16px; }
.actions-row.between { justify-content: space-between; }

.text-mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.text-right { text-align: right; }
.text-muted { color: var(--grey-600); }
.text-bold { font-weight: 700; }

.locked-badge { display: inline-flex; gap: 4px; align-items: center; font-size: 11px; color: var(--amber); font-weight: 600; }

@media (max-width: 900px) {
  .kpi-4, .kpi-5, .kpi-7 { grid-template-columns: repeat(2, 1fr); }
  .form-2, .form-3, .grid-3, .grid-4 { grid-template-columns: 1fr; }
}

/* Locked-module nav (Tier 2) — module not active for the company: greyed,
   lock icon, hover tooltip with description + request-access mailto. */
.nav-mod-locked { border-bottom: 1px solid rgba(255,255,255,0.06); position: relative; }
.nav-mod-locked-hdr {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 14px;
  color: rgba(255,255,255,0.32);
  font-size: 12px; font-weight: 600;
  cursor: default; user-select: none;
}
.nav-mod-locked .nav-mod-num { background: rgba(255,255,255,0.05); color: rgba(255,255,255,0.4); }
.nav-mod-lock { margin-left: auto; font-size: 11px; opacity: 0.6; }
.nav-mod-locked-tip { display: none; padding: 2px 14px 12px 14px; }
.nav-mod-locked:hover .nav-mod-locked-tip { display: block; }
.locked-tip-desc { font-size: 11px; color: rgba(255,255,255,0.5); line-height: 1.5; margin-bottom: 6px; }
.locked-tip-req { font-size: 11px; color: var(--gold); text-decoration: none; font-weight: 600; }
.locked-tip-req:hover { text-decoration: underline; }

/* File-upload inputs (Tier 2/3) — style the native picker button to match the
   UI instead of the browser default. */
input[type="file"] { font-size: 12px; color: var(--grey-600); }
input[type="file"]::file-selector-button {
  font-family: inherit; font-size: 12px; font-weight: 600;
  padding: 7px 12px; margin-right: 10px;
  background: var(--navy); color: var(--white);
  border: none; border-radius: var(--radius); cursor: pointer;
  transition: background 0.15s;
}
input[type="file"]::file-selector-button:hover { background: var(--gold); }
