/* Shared design system — extracted from Design/Compliance Platform Design
   System.dc.html. One source of tokens + components for every screen so the
   app reads as one product, not seven independently-styled pages. */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

:root {
  --bg-page: #F7F8FA;
  --bg-surface: #FFFFFF;
  --bg-inset: #F1F3F6;
  --border: #E4E7EC;
  --border-strong: #D0D5DD;
  --text-primary: #101828;
  --text-secondary: #475467;
  --text-tertiary: #98A2B3;
  --shadow: 0 1px 2px rgba(16,24,40,0.05), 0 1px 3px rgba(16,24,40,0.08);
  --primary: #006389;
  --primary-dark: #004864;
  --primary-focus: rgba(0,99,137,0.18);
  --success: #16A34A;
  --success-alt: #5C9A2E;
  --success-bg: #EEF7E4;
  --warn: #B54708;
  --warn-bg: rgba(247,144,9,0.14);
  --danger: #B42318;
  --danger-bg: #FEE4E2;
  --flag-bg: #FEF4F3;
  --flag-border: #FBDDD9;
  --ai-bg: #EFF8FC;
  --ai-border: #D3ECF6;
}

html[data-theme="dark"] {
  --bg-page: #0B0F14;
  --bg-surface: #11161C;
  --bg-inset: #161C24;
  --border: #232A33;
  --border-strong: #2E3742;
  --text-primary: #F2F4F7;
  --text-secondary: #98A2B3;
  --text-tertiary: #667085;
  --shadow: none;
  --success-bg: rgba(111,175,46,0.15);
  --danger-bg: rgba(240,68,56,0.15);
  --flag-bg: rgba(240,68,56,0.08);
  --flag-border: rgba(240,68,56,0.2);
  --ai-bg: rgba(0,99,137,0.10);
  --ai-border: rgba(0,99,137,0.25);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
  background: var(--bg-page);
  color: var(--text-primary);
  transition: background 0.2s ease, color 0.2s ease;
}
input, select, button, textarea { font-family: inherit; }
a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-dark); }
::selection { background: rgba(0,99,137,0.25); }

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 8px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* ---- Top chrome ---- */
.chrome {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 20px; border-bottom: 1px solid var(--border);
  background: var(--bg-surface); position: sticky; top: 0; z-index: 20;
  flex-wrap: wrap; gap: 10px;
}
.chrome-left { display: flex; align-items: center; gap: 10px; }
.logo-chip {
  background: #FFFFFF; border-radius: 8px; padding: 5px 10px;
  display: flex; align-items: center; border: 1px solid var(--border);
}
.logo-chip img { height: 22px; display: block; }
.chrome-divider { width: 1px; height: 20px; background: var(--border); }
.chrome-label { font-size: 13px; font-weight: 600; color: var(--text-secondary); }
.toggle-btn {
  background: var(--bg-inset); border: 1px solid var(--border); color: var(--text-primary);
  border-radius: 8px; padding: 7px 12px; font-size: 13px; font-weight: 600; cursor: pointer;
}

/* ---- Layout wrappers ---- */
.center-wrap {
  min-height: calc(100vh - 53px); display: flex; align-items: center;
  justify-content: center; padding: 24px;
}
.center-wrap.top-align { align-items: flex-start; padding-top: 48px; }
.wrap-inner { width: 100%; max-width: 420px; }
.wrap-inner.wide { max-width: 440px; }
.page-inner { max-width: 1080px; margin: 0 auto; padding: 32px 24px 64px; }

/* ---- Typography ---- */
h1.ds-h1 { font-size: 26px; font-weight: 800; margin: 0; letter-spacing: -0.02em; color: var(--text-primary); }
.text-secondary { font-size: 14px; color: var(--text-secondary); }
.text-tertiary { font-size: 12px; color: var(--text-tertiary); }

/* ---- Fields ---- */
label.field-label { display: block; font-size: 13px; font-weight: 600; color: var(--text-secondary); margin-bottom: 6px; }
.ds-input, select.ds-input {
  width: 100%; padding: 11px 13px; border-radius: 9px; border: 1px solid var(--border);
  background: var(--bg-surface); color: var(--text-primary); font-size: 14px; outline: none;
}
.ds-input.lg { padding: 14px; border-radius: 10px; font-size: 16px; }
.ds-input:focus, select.ds-input:focus {
  border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-focus);
}
.ds-input.invalid { border-color: var(--danger); }
.ds-input.invalid:focus { box-shadow: 0 0 0 3px var(--danger-bg); }
.field-error { display: block; color: var(--danger); font-size: 12px; font-weight: 600; margin-top: 5px; }

/* ---- Buttons ---- */
.btn-primary {
  width: 100%; padding: 13px; border-radius: 10px; border: none; background: var(--primary);
  color: #fff; font-size: 15px; font-weight: 700; cursor: pointer; transition: all 0.15s ease;
}
.btn-primary:hover { background: var(--primary-dark); box-shadow: 0 4px 12px rgba(0,99,137,0.3); }
.btn-primary:active { transform: scale(0.98); }
.btn-primary:disabled { opacity: 0.6; cursor: default; }
.btn-primary.lg { padding: 15px; font-size: 16px; }
.btn-primary.auto { width: auto; padding: 12px 24px; }

.btn-secondary-sm {
  padding: 8px 14px; border-radius: 8px; border: 1px solid var(--border-strong);
  background: var(--bg-surface); color: var(--text-primary); font-size: 13px; font-weight: 600; cursor: pointer;
}
.btn-ghost {
  padding: 8px 12px; border-radius: 8px; border: none; background: transparent;
  color: var(--text-secondary); font-size: 13px; font-weight: 600; cursor: pointer;
}
.btn-back {
  background: none; border: none; padding: 0; color: var(--text-secondary);
  font-size: 13px; font-weight: 600; cursor: pointer;
}
.link-forgot { text-align: center; font-size: 13px; font-weight: 600; display: block; margin-top: 2px; }
.btn-icon {
  width: 30px; height: 30px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--bg-surface); color: var(--text-secondary); cursor: pointer; font-size: 13px;
}

/* ---- Path cards (landing intent picker) ---- */
.path-card {
  display: flex; align-items: center; gap: 14px; width: 100%; padding: 18px;
  border-radius: 12px; border: 1px solid var(--border); background: var(--bg-surface);
  cursor: pointer; box-shadow: var(--shadow); transition: all 0.15s ease; text-align: left;
}
.path-card:hover { transform: translateY(-1px); box-shadow: 0 4px 14px rgba(16,24,40,0.10); }
.path-card:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.path-icon {
  width: 40px; height: 40px; border-radius: 10px; display: flex; align-items: center;
  justify-content: center; font-size: 18px; font-weight: 700; flex-shrink: 0;
}
.path-title { display: block; font-weight: 700; font-size: 16px; }
.path-sub { display: block; font-size: 13px; color: var(--text-secondary); }
.chevron { color: var(--text-tertiary); font-size: 18px; }

/* ---- Segmented control ---- */
.segmented {
  display: inline-flex; background: var(--bg-inset); border-radius: 9px; padding: 3px;
  border: 1px solid var(--border); flex-wrap: wrap;
}
.seg-btn {
  padding: 8px 14px; border-radius: 7px; border: none; background: transparent;
  color: var(--text-secondary); font-weight: 600; font-size: 13px; cursor: pointer;
}
.seg-btn.sm { padding: 6px 12px; font-size: 12.5px; }
.seg-btn.active { background: var(--primary); color: #fff; }

/* ---- Cards ---- */
.ds-card { background: var(--bg-surface); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow); }
.card-title { font-size: 14px; font-weight: 700; color: var(--text-primary); }
.card-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 16px; }

.hub-card {
  text-align: left; padding: 22px; border-radius: 14px; border: 1px solid var(--border);
  background: var(--bg-surface); cursor: pointer; box-shadow: var(--shadow); transition: all 0.15s ease;
  display: block; width: 100%;
}
.hub-card:hover { transform: translateY(-2px); box-shadow: 0 8px 20px rgba(16,24,40,0.10); }
.hub-icon {
  width: 38px; height: 38px; border-radius: 10px; display: flex; align-items: center;
  justify-content: center; font-size: 17px; font-weight: 700;
}
.hub-title { display: block; font-weight: 700; font-size: 16px; margin-top: 14px; }
.hub-sub { display: block; font-size: 13px; margin-top: 4px; color: var(--text-secondary); }

/* ---- AI summary card ---- */
.ai-card { background: var(--ai-bg); border: 1px solid var(--ai-border); border-radius: 14px; padding: 20px; margin-bottom: 20px; }
.ai-badge {
  flex-shrink: 0; width: 30px; height: 30px; border-radius: 50%; background: var(--primary);
  color: #fff; font-size: 11px; font-weight: 800; display: flex; align-items: center; justify-content: center;
}
.ai-label { font-size: 12px; font-weight: 700; letter-spacing: 0.03em; text-transform: uppercase; color: var(--primary); }
.ai-text { margin: 6px 0 0; font-size: 15px; line-height: 1.55; color: var(--text-primary); }

/* ---- Stat cards ---- */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; margin-bottom: 20px; }
.stat-card {
  background: var(--bg-surface); border: 1px solid var(--border); border-radius: 14px; padding: 18px;
  display: flex; flex-direction: column; gap: 6px; box-shadow: var(--shadow);
}
.stat-label { font-size: 13px; font-weight: 600; color: var(--text-secondary); }
.stat-value { font-size: 30px; font-weight: 800; letter-spacing: -0.02em; }
.stat-delta { font-size: 12px; font-weight: 600; }
.stat-delta.up { color: var(--success); }
.stat-delta.down { color: var(--danger); }

.two-col { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; }

/* ---- Star bars ---- */
.bar-row { display: flex; align-items: center; gap: 10px; }
.bar-label { width: 38px; font-size: 13px; font-weight: 600; color: var(--text-secondary); }
.bar-track { flex: 1; height: 10px; border-radius: 999px; background: var(--bg-inset); overflow: hidden; }
.bar-fill { height: 100%; border-radius: 999px; }
.bar-count { width: 24px; text-align: right; font-size: 13px; font-weight: 600; color: var(--text-primary); }

/* ---- Flagged reviews ---- */
.flag-row { padding: 12px 14px; border-radius: 10px; background: var(--flag-bg); border: 1px solid var(--flag-border); }
.rating-chip { font-size: 12px; font-weight: 700; color: var(--danger); background: var(--danger-bg); border-radius: 999px; padding: 2px 9px; flex-shrink: 0; }

/* ---- Table ---- */
.ds-table { width: 100%; border-collapse: collapse; min-width: 520px; }
.ds-table th {
  text-align: left; font-size: 12px; font-weight: 700; color: var(--text-secondary);
  text-transform: uppercase; letter-spacing: 0.03em; padding: 0 10px 10px; border-bottom: 1px solid var(--border);
}
.ds-table td { font-size: 14px; padding: 12px 10px; border-bottom: 1px solid var(--border); }
.ds-table tbody tr:hover { background: rgba(127,127,127,0.06); }

/* ---- List rows (branches / staff) ---- */
.list-row {
  display: flex; align-items: center; justify-content: space-between; padding: 13px 4px;
  border-bottom: 1px solid var(--border); flex-wrap: wrap; gap: 10px;
}
.list-row:last-child { border-bottom: none; }
.pill { font-size: 12px; font-weight: 600; color: var(--text-secondary); background: var(--bg-inset); border-radius: 999px; padding: 3px 10px; }
.avatar {
  width: 34px; height: 34px; border-radius: 50%; background: var(--bg-inset); color: var(--text-primary);
  font-size: 12px; font-weight: 700; display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.enc-badge {
  font-size: 10px; font-weight: 700; color: var(--success-alt); background: var(--success-bg);
  border-radius: 999px; padding: 2px 7px; margin-left: 6px; text-transform: uppercase;
}
.role-chip { font-size: 11px; font-weight: 700; padding: 3px 9px; border-radius: 999px; }
.role-chip.staff { background: var(--bg-inset); color: var(--text-secondary); }
.role-chip.branch_manager { background: rgba(0,99,137,0.14); color: var(--primary); }
.role-chip.zone_manager { background: rgba(111,175,46,0.16); color: var(--success-alt); }
.role-chip.owner { background: var(--warn-bg); color: var(--warn); }

.pin-chip { font-size: 13px; font-weight: 700; color: var(--primary-dark); background: rgba(0,99,137,0.10); border-radius: 8px; padding: 6px 10px; }

/* ---- Consent box (intake) ---- */
.consent-box { background: var(--bg-inset); border-radius: 10px; padding: 14px; }
.consent-box p { margin: 0 0 10px; font-size: 13px; font-style: italic; color: var(--text-secondary); }
.consent-box label { display: flex; align-items: flex-start; gap: 10px; cursor: pointer; }
.consent-box input[type="checkbox"] { width: 20px; height: 20px; margin-top: 1px; accent-color: var(--primary); flex-shrink: 0; }
.consent-box span.consent-text { font-size: 14px; font-weight: 500; }

/* ---- Empty states ---- */
.empty-state {
  display: flex; flex-direction: column; align-items: center; text-align: center;
  gap: 6px; padding: 32px 20px; border: 1.5px dashed var(--border-strong);
  border-radius: 12px; background: var(--bg-inset);
}
.empty-state-icon {
  width: 44px; height: 44px; border-radius: 50%; background: var(--ai-bg); color: var(--primary);
  display: flex; align-items: center; justify-content: center; font-size: 20px; margin-bottom: 6px;
}
.empty-state-title { font-weight: 700; font-size: 14px; color: var(--text-primary); }
.empty-state-sub { font-size: 13px; color: var(--text-secondary); max-width: 340px; }

/* ---- Loading skeleton ---- */
.skeleton {
  background: linear-gradient(90deg, var(--bg-inset) 25%, var(--border) 37%, var(--bg-inset) 63%);
  background-size: 400% 100%; animation: skeletonWave 1.4s ease infinite; border-radius: 8px;
}
@keyframes skeletonWave { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }

/* ---- Error / status banner ---- */
.status-banner {
  display: flex; align-items: flex-start; gap: 10px; padding: 13px 15px; border-radius: 10px;
  font-size: 13px; font-weight: 500; border: 1px solid var(--flag-border); background: var(--flag-bg); color: var(--danger);
}
.status-banner.info { border-color: var(--ai-border); background: var(--ai-bg); color: var(--text-primary); }
.status-banner.success { border-color: var(--success-bg); background: var(--success-bg); color: var(--success-alt); }

/* ---- Toast ---- */
.toast {
  position: fixed; bottom: 28px; left: 50%; transform: translateX(-50%);
  background: var(--text-primary); color: var(--bg-page); padding: 11px 18px; border-radius: 10px;
  font-size: 13px; font-weight: 600; box-shadow: 0 8px 24px rgba(0,0,0,0.25); z-index: 50;
  animation: toastIn 0.2s ease;
}
.toast.error { background: var(--danger); color: #fff; }

/* ---- Utility ---- */
.hidden { display: none !important; }
.spinner {
  display: inline-block; width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.4); border-top-color: #fff;
  animation: spin 0.7s linear infinite; vertical-align: middle; margin-right: 8px;
}
