/* ==========================================================================
   Double Check — Trust Locally
   AML/CFT/PF screening & case management — core stylesheet

   Palette is taken from the brand mark: the badge navy (#1f355b) and the
   gold of the seal (#f8d548). Gold is a signal colour, not a surface colour —
   it earns attention on the active nav item, the primary button and focus
   rings, and is kept off large fills where it would fight the data.
   ========================================================================== */

:root {
  /* Brand navy, sampled from the badge outline */
  --navy-950: #0c1729;
  --navy-900: #12233d;
  --navy-850: #172b49;
  --navy-800: #1f355b;
  --navy-700: #294470;
  --navy-600: #35578c;
  --border: #2c4670;
  --border-light: #e4e8ef;

  /* Brand gold, sampled from the seal */
  --gold-500: #f8d548;
  --gold-600: #e0bb2c;
  --gold-700: #a67f10;
  --gold-soft: #fdf6da;

  --bg-app: #f5f7fa;
  --bg-card: #ffffff;
  --bg-subtle: #f8fafc;

  --text-primary: #14213a;
  --text-secondary: #4d5d78;
  --text-muted: #8290a8;
  --text-inverse: #eef2f9;
  --text-inverse-muted: #a3b5d0;

  /* Accent === brand navy, so interactive chrome reads as the brand */
  --accent: #1f355b;
  --accent-600: #12233d;
  --accent-soft: #eaeff7;

  --risk-critical: #b91c1c;
  --risk-critical-bg: #fdecec;
  --risk-high: #c2410c;
  --risk-high-bg: #fdf1e7;
  --risk-medium: #a16207;
  --risk-medium-bg: #fef7e0;
  --risk-low: #15803d;
  --risk-low-bg: #e9f8ef;
  --risk-clear: #0f766e;
  --risk-clear-bg: #e6f7f5;

  --status-open: #1f355b;
  --status-open-bg: #eaeff7;
  --status-review: #a16207;
  --status-review-bg: #fef7e0;
  --status-escalated: #b91c1c;
  --status-escalated-bg: #fdecec;
  --status-closed: #4d5d78;
  --status-closed-bg: #eef1f6;
  --status-approved: #15803d;
  --status-approved-bg: #e9f8ef;

  /* Softer, larger radii and layered shadows — the main visual modernisation */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --shadow-sm: 0 1px 2px rgba(20, 33, 58, 0.05), 0 1px 3px rgba(20, 33, 58, 0.04);
  --shadow-md: 0 2px 4px rgba(20, 33, 58, 0.04), 0 8px 24px rgba(20, 33, 58, 0.07);
  --shadow-lg: 0 4px 8px rgba(20, 33, 58, 0.05), 0 20px 48px rgba(20, 33, 58, 0.14);
  --ring: 0 0 0 3px rgba(248, 213, 72, 0.42);

  --sidebar-w: 256px;
  --topbar-h: 66px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg-app);
  color: var(--text-primary);
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }

/* Every icon in this app is an inline SVG dropped straight into markup, and an
   SVG with no intrinsic size renders enormous. Give them all a sane default —
   the component rules below (.nav-item svg, .btn svg, .empty-state svg …) are
   more specific and still win where a different size is wanted. */
svg { width: 16px; height: 16px; flex-shrink: 0; }
.topbar-search svg { color: var(--text-muted); }
.data-table svg { vertical-align: -3px; color: var(--text-muted); }
table { border-collapse: collapse; width: 100%; }
input, select, textarea { font-family: inherit; font-size: 13px; }

/* ---------- App shell ---------- */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: linear-gradient(180deg, var(--navy-950) 0%, var(--navy-900) 100%);
  color: var(--text-inverse);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; bottom: 0; left: 0;
  z-index: 40;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 20px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

/* The brand mark is a round badge — give it a light disc to sit on so the
   navy in the artwork doesn't disappear into the navy sidebar. */
.sidebar-brand .mark {
  width: 40px; height: 40px;
  border-radius: 50%;
  background: #fff;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 0 0 1px rgba(255,255,255,0.14), 0 2px 8px rgba(0,0,0,0.25);
  overflow: hidden;
}
.sidebar-brand .mark img { width: 100%; height: 100%; object-fit: contain; display: block; }

.sidebar-brand .name { font-weight: 800; font-size: 15.5px; color: #fff; letter-spacing: -0.1px; }
.sidebar-brand .sub {
  font-size: 10px; color: var(--gold-500); letter-spacing: 1.1px;
  text-transform: uppercase; font-weight: 700; margin-top: 1px;
}

.sidebar-nav { flex: 1; overflow-y: auto; padding: 14px 12px; }
.sidebar-section { margin-bottom: 18px; }
.sidebar-section-label {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.8px;
  color: var(--text-inverse-muted); padding: 0 10px; margin-bottom: 6px; font-weight: 600;
}

.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px; border-radius: 8px;
  color: var(--text-inverse-muted); font-size: 13.5px; font-weight: 500;
  margin-bottom: 2px;
  transition: background 0.12s ease, color 0.12s ease;
}
.nav-item svg { width: 17px; height: 17px; flex-shrink: 0; opacity: 0.8; }
.nav-item:hover { background: rgba(255,255,255,0.07); color: #fff; }
/* Gold marks the current page — the one place it reads as "you are here" */
.nav-item.active {
  background: rgba(248, 213, 72, 0.14);
  color: #fff;
  box-shadow: inset 3px 0 0 var(--gold-500);
}
.nav-item.active svg { opacity: 1; color: var(--gold-500); }
.nav-item .badge {
  margin-left: auto; background: var(--risk-critical); color: #fff;
  font-size: 10.5px; font-weight: 700; padding: 1px 6px; border-radius: 20px;
}

.sidebar-footer {
  padding: 14px 20px; border-top: 1px solid rgba(255,255,255,0.08);
  display: flex; align-items: center; gap: 10px;
}
.avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: linear-gradient(135deg, var(--gold-500), var(--gold-600));
  color: var(--navy-900); font-weight: 800; font-size: 12px;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.sidebar-footer .who { font-size: 12.5px; font-weight: 600; color: #fff; }
.sidebar-footer .role { font-size: 11px; color: var(--text-inverse-muted); }

/* ---------- Main column ---------- */
.main {
  margin-left: var(--sidebar-w);
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  height: var(--topbar-h);
  background: var(--bg-card);
  border-bottom: 1px solid var(--border-light);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 24px;
  position: sticky; top: 0; z-index: 30;
}

.topbar .crumbs { font-size: 13px; color: var(--text-muted); }
.topbar .crumbs strong { color: var(--text-primary); font-weight: 600; }

.topbar-search {
  display: flex; align-items: center; gap: 8px;
  background: var(--bg-subtle); border: 1px solid var(--border-light);
  border-radius: 8px; padding: 7px 12px; width: 320px;
  color: var(--text-muted); font-size: 13px;
}
.topbar-search input { border: none; background: transparent; outline: none; width: 100%; color: var(--text-primary); }

.topbar-actions { display: flex; align-items: center; gap: 14px; }
.icon-btn {
  width: 34px; height: 34px; border-radius: 8px; border: 1px solid var(--border-light);
  background: var(--bg-card); display: flex; align-items: center; justify-content: center;
  color: var(--text-secondary); position: relative;
}
.icon-btn svg { width: 16px; height: 16px; }
.icon-btn .dot { position: absolute; top: 6px; right: 6px; width: 7px; height: 7px; border-radius: 50%; background: var(--risk-critical); border: 1.5px solid #fff; }

.content { padding: 26px 28px 60px; }

/* ---------- Page header ---------- */
.page-header { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 22px; gap: 16px; flex-wrap: wrap; }
.page-header h1 { font-size: 21px; font-weight: 700; margin: 0 0 4px; letter-spacing: -0.2px; }
.page-header p { margin: 0; color: var(--text-secondary); font-size: 13.5px; max-width: 640px; }
.page-header-actions { display: flex; gap: 10px; flex-shrink: 0; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 9px 17px; border-radius: var(--radius-sm); font-size: 13px; font-weight: 600;
  border: 1px solid transparent; white-space: nowrap;
  transition: background 0.15s ease, box-shadow 0.15s ease, transform 0.06s ease, border-color 0.15s ease;
}
.btn svg { width: 15px; height: 15px; }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: none; box-shadow: var(--ring); }
.btn-primary { background: var(--accent); color: #fff; box-shadow: var(--shadow-sm); }
.btn-primary:hover { background: var(--navy-700); box-shadow: var(--shadow-md); }
/* Gold call-to-action for the one primary act on a page (e.g. Run Screening) */
.btn-gold { background: var(--gold-500); color: var(--navy-900); box-shadow: var(--shadow-sm); font-weight: 700; }
.btn-gold:hover { background: var(--gold-600); box-shadow: var(--shadow-md); }
.btn-secondary { background: var(--bg-card); color: var(--text-primary); border-color: var(--border-light); }
.btn-secondary:hover { background: var(--bg-subtle); border-color: #cfd7e4; }
.btn-danger { background: var(--risk-critical-bg); color: var(--risk-critical); border-color: #f6cbcb; }
.btn-success { background: var(--risk-low-bg); color: var(--risk-low); border-color: #bfe8cd; }
.btn-ghost { background: transparent; color: var(--text-secondary); }
.btn-ghost:hover { background: var(--bg-subtle); }
.btn-sm { padding: 6px 11px; font-size: 12px; }
.btn-block { width: 100%; justify-content: center; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ---------- Cards / KPIs ---------- */
.grid { display: grid; gap: 18px; }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
@media (max-width: 1100px) { .grid-4 { grid-template-columns: repeat(2, 1fr); } .grid-3 { grid-template-columns: repeat(2,1fr);} }

.card {
  background: var(--bg-card); border: 1px solid var(--border-light);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-sm);
  transition: box-shadow 0.18s ease, border-color 0.18s ease;
}
.card:hover { box-shadow: var(--shadow-md); }

/* Brand banner used as a slim page hero.
   The supplied artwork already carries the logo and the "Trust Locally"
   wordmark, so nothing is overlaid on top of it — an overlay here duplicated
   the brand and covered the mark. The artwork's own left edge is the anchor,
   hence object-position: left. A caption strip below carries the sentence the
   overlay used to, where it stays legible at any width. */
.brand-hero {
  border-radius: var(--radius-lg); overflow: hidden;
  margin-bottom: 22px; box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-light);
  background: var(--bg-card);
}
/* Shown at its natural aspect: cropping to a fixed height sliced the badge
   in the artwork in half. */
.brand-hero img { width: 100%; display: block; height: auto; }
.brand-hero .hero-caption {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 12px 18px; border-top: 1px solid var(--border-light);
  background: var(--bg-card);
}
.brand-hero .hero-caption p {
  margin: 0; color: var(--text-secondary); font-size: 12.5px;
}
.brand-hero .hero-tag {
  display: inline-flex; align-items: center; flex-shrink: 0;
  padding: 4px 11px; border-radius: 20px;
  background: var(--gold-soft); border: 1px solid var(--gold-500);
  color: var(--gold-700); font-size: 10.5px; font-weight: 800;
  letter-spacing: 1.1px; text-transform: uppercase;
}
.card-pad { padding: 20px 22px; }
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid var(--border-light);
}
.card-header h3 { font-size: 14.5px; font-weight: 700; margin: 0; }
.card-header .muted { font-size: 12px; color: var(--text-muted); }

.kpi-card { padding: 18px 20px; display: flex; flex-direction: column; gap: 10px; }
.kpi-top { display: flex; align-items: center; justify-content: space-between; }
.kpi-label { font-size: 12px; color: var(--text-muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.4px; }
.kpi-icon { width: 34px; height: 34px; border-radius: 9px; display: flex; align-items: center; justify-content: center; }
.kpi-icon svg { width: 17px; height: 17px; }
.kpi-value { font-size: 27px; font-weight: 800; letter-spacing: -0.5px; }
.kpi-delta { font-size: 12px; font-weight: 600; display: flex; align-items: center; gap: 4px; }
.kpi-delta.up { color: var(--risk-low); }
.kpi-delta.down { color: var(--risk-critical); }

/* ---------- Tags / badges ---------- */
.tag {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px; border-radius: 20px; font-size: 11.5px; font-weight: 700;
  letter-spacing: 0.2px; white-space: nowrap;
}
.tag::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.tag-critical { background: var(--risk-critical-bg); color: var(--risk-critical); }
.tag-high { background: var(--risk-high-bg); color: var(--risk-high); }
.tag-medium { background: var(--risk-medium-bg); color: var(--risk-medium); }
.tag-low { background: var(--risk-low-bg); color: var(--risk-low); }
.tag-clear { background: var(--risk-clear-bg); color: var(--risk-clear); }

.status-pill {
  display: inline-flex; align-items: center; padding: 4px 10px; border-radius: 20px;
  font-size: 11.5px; font-weight: 700;
}
.status-open { background: var(--status-open-bg); color: var(--status-open); }
.status-review { background: var(--status-review-bg); color: var(--status-review); }
.status-escalated { background: var(--status-escalated-bg); color: var(--status-escalated); }
.status-closed { background: var(--status-closed-bg); color: var(--status-closed); }
.status-approved { background: var(--status-approved-bg); color: var(--status-approved); }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
table.data-table { min-width: 720px; }
.data-table thead th {
  text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px;
  color: var(--text-muted); font-weight: 700; padding: 12px 16px; background: var(--bg-subtle);
  border-bottom: 1px solid var(--border-light); white-space: nowrap;
}
.data-table tbody td { padding: 13px 16px; border-bottom: 1px solid var(--border-light); font-size: 13px; vertical-align: middle; }
.data-table tbody tr:hover { background: var(--bg-subtle); cursor: pointer; }
.data-table tbody tr:last-child td { border-bottom: none; }
.cell-primary { font-weight: 600; color: var(--text-primary); }
.cell-muted { color: var(--text-muted); font-size: 12.5px; }
.mono { font-family: "SF Mono", ui-monospace, Menlo, monospace; font-size: 12px; }

.score-bar-wrap { display: flex; align-items: center; gap: 8px; min-width: 90px; }
.score-bar { flex: 1; height: 6px; border-radius: 4px; background: #e7ebf1; overflow: hidden; }
.score-bar > span { display: block; height: 100%; border-radius: 4px; }
.score-num { font-weight: 700; font-size: 12px; width: 28px; text-align: right; }

/* ---------- Forms ---------- */
.form-group { margin-bottom: 16px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
label.field-label { display: block; font-size: 12.5px; font-weight: 600; color: var(--text-secondary); margin-bottom: 6px; }
.field-hint { font-size: 11.5px; color: var(--text-muted); margin-top: 5px; }
input[type=text], input[type=date], input[type=email], input[type=password], input[type=number], select, textarea {
  width: 100%; padding: 10px 12px; border-radius: 8px; border: 1px solid var(--border-light);
  background: var(--bg-card); color: var(--text-primary); outline: none;
}
input[type=text], input[type=date], input[type=email], input[type=password], input[type=number], select, textarea {
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
input:focus, select:focus, textarea:focus { border-color: var(--gold-600); box-shadow: var(--ring); }
textarea { resize: vertical; min-height: 80px; }

/* Must sit AFTER the generic input[type=text] rule above, which would
   otherwise re-apply a border and padding and draw a second box inside the
   search pill. */
.topbar-search input[type=text] {
  border: none; background: transparent; outline: none;
  width: 100%; padding: 0; color: var(--text-primary); box-shadow: none;
}
.topbar-search input[type=text]:focus { border: none; box-shadow: none; }
.topbar-search:focus-within { border-color: var(--gold-600); box-shadow: var(--ring); }

.toggle-group { display: inline-flex; background: var(--bg-subtle); border: 1px solid var(--border-light); border-radius: 8px; padding: 3px; }
.toggle-group button {
  border: none; background: transparent; padding: 7px 16px; border-radius: 6px; font-size: 12.5px; font-weight: 600; color: var(--text-secondary);
}
.toggle-group button { transition: background 0.15s ease, color 0.15s ease; }
.toggle-group button.active { background: var(--bg-card); color: var(--accent); box-shadow: var(--shadow-sm); font-weight: 700; }

.checkbox-row { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-secondary); }

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border-light); margin-bottom: 20px; }
.tab-item {
  padding: 11px 16px; font-size: 13px; font-weight: 600; color: var(--text-muted);
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tab-item { transition: color 0.15s ease, border-color 0.15s ease; }
.tab-item:hover { color: var(--text-secondary); }
.tab-item.active { color: var(--accent); border-color: var(--gold-500); border-bottom-width: 2.5px; }

/* ---------- Misc ---------- */
.divider { height: 1px; background: var(--border-light); margin: 18px 0; }
.empty-state { text-align: center; padding: 50px 20px; color: var(--text-muted); }
.empty-state svg { width: 46px; height: 46px; margin-bottom: 12px; opacity: 0.5; }
.pagination { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; font-size: 12.5px; color: var(--text-muted); }
.pagination .pages { display: flex; gap: 4px; }
.pagination button { width: 28px; height: 28px; border-radius: 6px; border: 1px solid var(--border-light); background: var(--bg-card); font-size: 12px; }
.pagination button.active { background: var(--accent); color: #fff; border-color: var(--accent); }

.timeline { position: relative; padding-left: 26px; }
.timeline::before { content: ""; position: absolute; left: 7px; top: 4px; bottom: 4px; width: 2px; background: var(--border-light); }
.timeline-item { position: relative; padding-bottom: 22px; }
.timeline-item::before { content: ""; position: absolute; left: -26px; top: 3px; width: 12px; height: 12px; border-radius: 50%; background: var(--accent); border: 2px solid #fff; box-shadow: 0 0 0 2px var(--accent-soft); }
.timeline-item .t-title { font-size: 13px; font-weight: 600; }
.timeline-item .t-meta { font-size: 11.5px; color: var(--text-muted); margin-top: 2px; }
.timeline-item .t-body { font-size: 12.5px; color: var(--text-secondary); margin-top: 6px; background: var(--bg-subtle); padding: 10px 12px; border-radius: 8px; }

.modal-backdrop {
  position: fixed; inset: 0; background: rgba(15,23,42,0.5); display: none;
  align-items: center; justify-content: center; z-index: 100;
}
.modal-backdrop.open { display: flex; }
.modal { width: 480px; max-width: 92vw; background: #fff; border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); overflow: hidden; }
.modal-header { padding: 18px 22px; border-bottom: 1px solid var(--border-light); display:flex; align-items:center; justify-content:space-between; }
.modal-header h3 { margin:0; font-size: 15px; }
.modal-body { padding: 20px 22px; max-height: 60vh; overflow-y: auto; }
.modal-footer { padding: 14px 22px; border-top: 1px solid var(--border-light); display:flex; justify-content:flex-end; gap: 10px; }

.banner {
  display: flex; align-items: flex-start; gap: 10px; padding: 12px 16px; border-radius: 10px;
  font-size: 12.5px; margin-bottom: 18px; border: 1px solid;
}
.banner-info { background: var(--accent-soft); border-color: #c7d9fb; color: var(--accent-600); }
.banner-warn { background: var(--risk-medium-bg); border-color: #f3e0ad; color: var(--risk-medium); }

.toast-stack { position: fixed; bottom: 22px; right: 22px; display: flex; flex-direction: column; gap: 10px; z-index: 200; }
.toast { background: var(--navy-900); color: #fff; padding: 12px 16px; border-radius: 10px; font-size: 12.5px; box-shadow: var(--shadow-lg); display: flex; align-items: center; gap: 10px; min-width: 240px; }

.skeleton { background: linear-gradient(90deg, #eef1f6 25%, #f7f9fb 37%, #eef1f6 63%); background-size: 400% 100%; animation: sk 1.4s ease infinite; border-radius: 6px; }
@keyframes sk { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }

::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 20px; }
::-webkit-scrollbar-track { background: transparent; }
