/* ============================================================
   Bache CSP — reverse-engineered prototype
   Design tokens captured from the live application.
   ============================================================ */

:root {
  /* ---- Bache Papur luxury palette (dark gold · charcoal · ivory) ---- */
  --gold-light: #AD974F;       /* light gold accent */
  --gold-dark: #8E793E;        /* dark gold */
  --primary: #8E793E;          /* dark gold — primary accent (legible) */
  --primary-hover: #74622F;    /* deeper gold on hover */
  --primary-soft: #F1EBDA;     /* soft gold tint for active states */
  --bg: #F5F3EE;               /* warm ivory page background */
  --sidebar-bg: #FBF9F4;       /* lighter ivory sidebar */
  --card: #FFFFFF;
  --text: #231F20;             /* intellectual grey (near-black) */
  --text-muted: #6E6A61;       /* warm muted grey */
  --text-faint: #A29D91;       /* faint warm grey */
  --border: #E6E3DA;           /* warm light border */
  --border-strong: #D3CFC3;
  --hover: #F0EEE6;            /* warm hover wash */
  --radius: 8px;
  --radius-lg: 12px;
  --shadow-sm: 0 1px 2px rgba(35, 31, 32, 0.05);
  --shadow: 0 1px 3px rgba(35, 31, 32, 0.07), 0 1px 2px rgba(35, 31, 32, 0.05);
  --shadow-lg: 0 14px 40px rgba(35, 31, 32, 0.12);

  /* status colors — muted & editorial to keep the palette classy */
  --green: #5C7A52;   --green-bg: #ECF0E6;
  --red: #A2453B;     --red-bg: #F6E9E6;
  --amber: #B0843C;   --amber-bg: #F6EEDC;
  --blue: #445A6E;    --blue-bg: #E8ECF0;   /* slate-ink stands in for the old blue */
  --violet: #6E5F7A;  --violet-bg: #EEEAF1;
  --slate: #6E6A61;   --slate-bg: #EFECE3;
  --teal: #4F6E68;    --teal-bg: #E5EDEB;

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

[data-theme="dark"] {
  --gold-light: #C9B26E;
  --gold-dark: #AD974F;
  --primary: #C4AF6A;          /* brighter gold reads well on charcoal */
  --primary-hover: #D8C57E;
  --primary-soft: #2C2820;
  --bg: #1A1717;               /* deep charcoal */
  --sidebar-bg: #211D1C;
  --card: #262220;
  --text: #F3EFE5;             /* warm ivory text */
  --text-muted: #B4AE9F;
  --text-faint: #837D6F;
  --border: #38332E;
  --border-strong: #4B443C;
  --hover: #2E2925;
  --green-bg: #21281B;  --red-bg: #331E1A;  --amber-bg: #33291A;
  --blue-bg: #1E2833;   --violet-bg: #29222F; --slate-bg: #2A2620; --teal-bg: #1C2826;
  --shadow: 0 1px 3px rgba(0,0,0,0.5);
  --shadow-lg: 0 14px 40px rgba(0,0,0,0.6);
}

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

html, body {
  height: 100%;
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; border: none; background: none; }
input, select { font-family: inherit; font-size: 14px; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 6px; }
::-webkit-scrollbar-track { background: transparent; }

/* ---------- utility ---------- */
.hidden { display: none !important; }
.muted { color: var(--text-muted); }
.faint { color: var(--text-faint); }
.mono { font-variant-numeric: tabular-nums; }
.row { display: flex; align-items: center; }
.gap-2 { gap: 8px; } .gap-3 { gap: 12px; } .gap-4 { gap: 16px; }
.spacer { flex: 1; }

/* ============================================================
   Gate + Persona picker (centered screens)
   ============================================================ */
.center-screen {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  background: var(--bg) url("../../public/gate-bg.svg") center / cover no-repeat;
}
.gate-card {
  width: 100%;
  max-width: 430px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 44px 44px 36px;
  text-align: center;
}
.gate-card h1 { font-family: Georgia, "Times New Roman", serif; font-size: 26px; letter-spacing: 0.01em; margin-bottom: 10px; color: var(--text); }
.gate-tagline { font-size: 13.5px; color: var(--text-muted); letter-spacing: 0.01em; margin-bottom: 6px; line-height: 1.5; }
.gate-sub { font-size: 13.5px; color: var(--gold-dark); opacity: 0.65; letter-spacing: 0.04em; margin-bottom: 24px; }
.gate-card p { color: var(--text-muted); }
.gate-card input {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--card);
  color: var(--text);
  margin-bottom: 14px;
}
.gate-card input:focus { outline: 2px solid var(--primary); outline-offset: -1px; border-color: var(--primary); }
.gate-btn {
  width: 100%;
  padding: 12px;
  background: #231F20;
  color: #F5F3EE;
  font-weight: 600;
  letter-spacing: 0.02em;
  border-radius: var(--radius);
  font-size: 15px;
  transition: background .15s;
}
.gate-btn:hover { background: var(--gold-dark); }
.gate-error { color: var(--red); font-size: 13px; margin-bottom: 12px; min-height: 16px; }

/* Persona picker */
.persona-wrap { max-width: 980px; width: 100%; margin: 0 auto; }
.persona-head { text-align: center; margin-bottom: 36px; }
.persona-eyebrow { font-size: 12px; letter-spacing: 0.14em; color: var(--text-faint); font-weight: 600; text-transform: uppercase; }
.persona-head h1 { font-size: 30px; margin: 8px 0 12px; }
.persona-head p { color: var(--text-muted); max-width: 560px; margin: 0 auto; }
.persona-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 20px; }
.persona-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  display: flex;
  gap: 16px;
  cursor: pointer;
  transition: border-color .15s, box-shadow .15s, transform .1s;
  text-align: left;
}
.persona-card:hover { border-color: var(--primary); box-shadow: var(--shadow-lg); transform: translateY(-1px); }
.persona-icon {
  width: 44px; height: 44px; flex: none;
  border-radius: 10px;
  background: var(--primary-soft);
  color: var(--primary);
  display: flex; align-items: center; justify-content: center;
}
.persona-card h3 { font-size: 16px; margin-bottom: 4px; }
.persona-tag { font-size: 11px; letter-spacing: 0.08em; font-weight: 600; color: var(--text-faint); text-transform: uppercase; margin-bottom: 10px; }
.persona-card .desc { font-size: 13px; color: var(--text-muted); }

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

.sidebar {
  width: var(--sidebar-w);
  flex: none;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
.brand { display: flex; align-items: center; gap: 12px; padding: 20px 20px 16px; }
.brand-logo {
  width: 36px; height: 36px; border-radius: 9px;
  background: #231F20; color: var(--gold-light);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 18px; font-family: Georgia, "Times New Roman", serif;
}
.brand-name { font-weight: 700; font-size: 17px; letter-spacing: 0.01em; }
.nav-label { font-size: 11px; letter-spacing: 0.1em; color: var(--text-faint); font-weight: 600; padding: 8px 20px 6px; }
.nav { display: flex; flex-direction: column; padding: 0 12px 20px; gap: 2px; }
.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 9px 12px;
  border-radius: var(--radius);
  color: var(--text-muted);
  font-weight: 500;
  transition: background .12s, color .12s;
}
.nav-item:hover { background: var(--hover); color: var(--text); }
.nav-item.active { background: var(--primary-soft); color: var(--primary); font-weight: 600; }
.nav-item.active svg { color: var(--primary); }
.nav-item svg { width: 18px; height: 18px; flex: none; }
.sidebar-collapse {
  margin-top: auto; padding: 12px 20px; border-top: 1px solid var(--border);
  display: flex; align-items: center; gap: 8px; color: var(--text-muted); font-size: 13px;
}

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  height: var(--topbar-h);
  border-bottom: 1px solid var(--border);
  background: var(--card);
  display: flex; align-items: center; gap: 16px;
  padding: 0 24px;
  position: sticky; top: 0; z-index: 20;
}
.search {
  display: flex; align-items: center; gap: 8px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 12px;
  width: 280px; color: var(--text-faint);
}
.search input { border: none; background: none; color: var(--text); flex: 1; outline: none; }
.kbd { font-size: 11px; border: 1px solid var(--border-strong); border-radius: 4px; padding: 1px 5px; color: var(--text-faint); }
.tenant-name { color: var(--text-muted); font-weight: 500; }
.icon-btn {
  width: 36px; height: 36px; border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
  color: var(--text-muted); position: relative;
}
.icon-btn:hover { background: var(--hover); color: var(--text); }
.badge-dot {
  position: absolute; top: 5px; right: 5px;
  background: var(--red); color: #fff; font-size: 10px; font-weight: 700;
  min-width: 16px; height: 16px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center; padding: 0 4px;
}
.avatar { width: 36px; height: 36px; border-radius: 8px; background: var(--slate-bg); color: var(--slate); display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 13px; }
.user-block { display: flex; align-items: center; gap: 10px; }
.user-block .u-name { font-weight: 600; font-size: 13px; }
.user-block .u-mail { font-size: 12px; color: var(--text-muted); }

.content { padding: 28px 32px 60px; flex: 1; }

/* ---------- page header ---------- */
.page-head { display: flex; align-items: flex-start; gap: 16px; margin-bottom: 24px; }
.page-title { display: flex; align-items: center; gap: 12px; }
.page-title svg { width: 26px; height: 26px; color: var(--text); }
.page-title h1 { font-size: 24px; }
.page-sub { color: var(--text-muted); margin-top: 4px; }
.page-actions { margin-left: auto; display: flex; gap: 10px; align-items: center; }
.pill-live { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--green); font-weight: 600; }
.pill-live::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--green); }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 9px 16px; border-radius: var(--radius);
  font-weight: 600; font-size: 13px;
  border: 1px solid var(--border-strong);
  background: var(--card); color: var(--text);
  transition: background .12s, border-color .12s;
}
.btn:hover { background: var(--hover); }
.btn svg { width: 16px; height: 16px; }
.btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-hover); }

/* ---------- KPI cards ---------- */
.kpi-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 28px; }
.kpi {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 20px;
  display: flex; align-items: flex-start; justify-content: space-between;
}
.kpi .k-label { font-size: 11px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-muted); font-weight: 600; }
.kpi .k-value { font-size: 30px; font-weight: 700; margin: 8px 0 4px; letter-spacing: -0.02em; }
.kpi .k-hint { font-size: 12px; color: var(--text-muted); }
.kpi .k-icon {
  width: 42px; height: 42px; border-radius: 10px;
  background: var(--primary-soft); color: var(--primary);
  display: flex; align-items: center; justify-content: center; flex: none;
}

.section-label { font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-muted); font-weight: 600; margin: 8px 0 14px; }

.kpi-click { cursor: pointer; transition: border-color .12s, box-shadow .12s, transform .1s; position: relative; }
.kpi-click:hover { border-color: var(--primary); box-shadow: var(--shadow); transform: translateY(-1px); }
.kpi-arrow { position: absolute; bottom: 14px; right: 14px; color: var(--text-faint); }
.kpi-arrow svg { width: 16px; height: 16px; }
.kpi-click:hover .kpi-arrow { color: var(--primary); }
.banner-click { cursor: pointer; transition: border-color .12s, box-shadow .12s; }
.banner-click:hover { border-color: var(--primary); box-shadow: var(--shadow); }
.tc-case { padding: 12px 0; border-bottom: 1px solid var(--border); }
.tc-case:last-child { border-bottom: none; }
.val-bar { height: 8px; border-radius: 5px; background: var(--hover); overflow: hidden; margin-bottom: 18px; }
.val-fill { height: 100%; border-radius: 5px; transition: width .5s; }
.val-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.val-suite { border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; }
.val-case { display: flex; align-items: center; gap: 7px; padding: 3px 0; }
.val-dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.val-dot.ok { background: var(--green); }
.val-dot.bad { background: var(--red); }
.val-ct { font-size: 11.5px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 1100px) { .val-grid { grid-template-columns: 1fr; } }

/* ---------- banners ---------- */
.banner {
  display: flex; align-items: center; gap: 16px;
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 18px 20px; margin-bottom: 28px;
}
.banner-icon { width: 46px; height: 46px; border-radius: 10px; background: var(--primary-soft); color: var(--primary); display: flex; align-items: center; justify-content: center; flex: none; }
.banner h4 { font-size: 14px; } .banner .banner-sub { color: var(--text-muted); font-size: 13px; }
.chip-count { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; padding: 4px 10px; border-radius: 20px; }
.chip-green { background: var(--green-bg); color: var(--green); }
.chip-amber { background: var(--amber-bg); color: var(--amber); }
.chip-slate { background: var(--slate-bg); color: var(--slate); }

.warn-strip {
  display: flex; align-items: center; gap: 10px;
  background: var(--amber-bg); color: #92400e;
  border: 1px solid #fcd9a5; border-radius: var(--radius);
  padding: 12px 16px; margin-bottom: 24px; font-size: 13px; font-weight: 500;
}
[data-theme="dark"] .warn-strip { color: #fbbf24; border-color: #4a3206; }

/* ---------- attention two-column lists ---------- */
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 28px; }
.list-card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; }
.list-card-head { display: flex; align-items: center; gap: 8px; padding: 16px 18px; border-bottom: 1px solid var(--border); font-weight: 600; }
.list-card-head .count { margin-left: auto; font-size: 12px; font-weight: 700; color: var(--text-muted); }
.list-row { display: flex; align-items: center; padding: 12px 18px; border-bottom: 1px solid var(--border); }
.list-row:last-child { border-bottom: none; }
.list-row:hover { background: var(--hover); }
.list-row .lr-main { min-width: 0; }
.list-row .lr-title { font-weight: 600; font-size: 13px; }
.list-row .lr-sub { font-size: 12px; color: var(--text-muted); }
.list-row .lr-right { margin-left: auto; text-align: right; display: flex; align-items: center; gap: 12px; }
.list-row .lr-meta { font-size: 12px; }
.lr-overdue { color: var(--red); font-weight: 600; }
.lr-upcoming { color: var(--amber); font-weight: 600; }

/* ---------- filter chips ---------- */
.chips { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 16px; }
.chip {
  padding: 6px 14px; border-radius: 20px; font-size: 13px; font-weight: 500;
  background: var(--card); border: 1px solid var(--border); color: var(--text-muted);
  transition: all .12s;
}
.chip:hover { border-color: var(--border-strong); color: var(--text); }
.chip.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.chip-divider { width: 1px; height: 22px; background: var(--border); margin: 0 4px; }

/* ---------- filter bar (selects) ---------- */
.filter-bar { display: flex; gap: 18px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 16px; }
.field { display: flex; flex-direction: column; gap: 5px; }
.field label { font-size: 12px; color: var(--text-muted); font-weight: 500; }
.field select, .field input {
  padding: 8px 12px; border: 1px solid var(--border-strong); border-radius: var(--radius);
  background: var(--card); color: var(--text); min-width: 150px;
}
.search-box {
  display: flex; align-items: center; gap: 8px; width: 100%; max-width: 400px;
  border: 1px solid var(--border-strong); border-radius: var(--radius);
  padding: 9px 12px; margin-bottom: 16px; color: var(--text-faint); background: var(--card);
}
.search-box input { border: none; background: none; outline: none; color: var(--text); flex: 1; }
.view-toggle { margin-left: auto; display: inline-flex; border: 1px solid var(--border-strong); border-radius: var(--radius); overflow: hidden; }
.view-toggle button { padding: 7px 14px; font-size: 13px; font-weight: 600; color: var(--text-muted); display: flex; align-items: center; gap: 6px; }
.view-toggle button.active { background: var(--primary); color: #fff; }

/* ---------- tables ---------- */
.table-card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; }
table { width: 100%; border-collapse: collapse; }
thead th {
  text-align: left; font-size: 11px; letter-spacing: 0.05em; text-transform: uppercase;
  color: var(--text-muted); font-weight: 600; padding: 14px 18px;
  border-bottom: 1px solid var(--border); white-space: nowrap;
}
thead th .sortable { display: inline-flex; align-items: center; gap: 4px; cursor: pointer; }
tbody td { padding: 13px 18px; border-bottom: 1px solid var(--border); font-size: 13px; vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--hover); cursor: pointer; }
td .primary-text { font-weight: 600; }
td .dim { color: var(--text-faint); }

.status-pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px; border-radius: 20px; font-size: 12px; font-weight: 600; white-space: nowrap;
}
.status-pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.s-green { background: var(--green-bg); color: var(--green); }
.s-red { background: var(--red-bg); color: var(--red); }
.s-amber { background: var(--amber-bg); color: var(--amber); }
.s-blue { background: var(--blue-bg); color: var(--blue); }
.s-violet { background: var(--violet-bg); color: var(--violet); }
.s-slate { background: var(--slate-bg); color: var(--slate); }
.s-teal { background: var(--teal-bg); color: var(--teal); }

.badge-mini { font-size: 10px; font-weight: 700; padding: 2px 6px; border-radius: 4px; background: var(--red-bg); color: var(--red); letter-spacing: 0.03em; }

.table-foot { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; border-top: 1px solid var(--border); font-size: 13px; color: var(--text-muted); }
.pager { display: flex; gap: 6px; align-items: center; }
.pager button { padding: 6px 12px; border: 1px solid var(--border-strong); border-radius: 6px; font-weight: 600; color: var(--text); }
.pager button:disabled { opacity: .4; cursor: default; }
.pager button:not(:disabled):hover { background: var(--hover); }

/* ---------- tabs (billing) ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 20px; }
.tab { padding: 12px 16px; font-weight: 600; font-size: 14px; color: var(--text-muted); border-bottom: 2px solid transparent; display: flex; align-items: center; gap: 8px; }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }
.tab:hover { color: var(--text); }

/* ---------- legend ---------- */
.legend { display: flex; flex-wrap: wrap; gap: 18px; margin-bottom: 18px; font-size: 13px; color: var(--text-muted); }
.legend span { display: inline-flex; align-items: center; gap: 7px; }
.legend .dot { width: 9px; height: 9px; border-radius: 50%; }

/* ---------- charts ---------- */
.chart-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; margin-bottom: 28px; }
.chart-card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 20px; }
.chart-card h4 { font-size: 14px; margin-bottom: 2px; }
.chart-card .c-sub { font-size: 12px; color: var(--text-muted); margin-bottom: 18px; }
.bars { display: flex; align-items: flex-end; gap: 12px; height: 150px; }
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 8px; height: 100%; justify-content: flex-end; }
.bar { width: 100%; background: var(--primary); border-radius: 5px 5px 0 0; min-height: 3px; transition: height .4s; }
.bar.bar-amber { background: var(--amber); } .bar.bar-red { background: var(--red); }
.bar.bar-green { background: var(--green); } .bar.bar-blue { background: var(--blue); }
.bar-label { font-size: 11px; color: var(--text-muted); }
.hbar-row { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.hbar-label { width: 84px; font-size: 12px; color: var(--text-muted); }
.hbar-track { flex: 1; height: 22px; background: var(--hover); border-radius: 5px; overflow: hidden; }
.hbar-fill { height: 100%; background: var(--primary); border-radius: 5px; display: flex; align-items: center; padding-left: 8px; color: #fff; font-size: 11px; font-weight: 700; }
.donut-wrap { display: flex; align-items: center; gap: 20px; }
.bar.bar-dark { background: #231F20; }
[data-theme="dark"] .bar.bar-dark { background: #C4AF6A; }
.dash-lower { display: grid; grid-template-columns: 1fr 2fr; gap: 20px; margin-bottom: 28px; }
.fin-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-top: 18px; }
.fin-card { border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; }
.fin-label { font-size: 11px; letter-spacing: 0.05em; text-transform: uppercase; color: var(--text-muted); font-weight: 600; }
.fin-value { font-size: 22px; font-weight: 700; margin: 6px 0 3px; letter-spacing: -0.01em; }
.fin-hint { font-size: 11px; color: var(--text-muted); }

/* ---------- documents ---------- */
.docs-layout { display: grid; grid-template-columns: 320px 1fr; gap: 20px; }
.tree { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 8px; max-height: 640px; overflow-y: auto; }
.tree-item { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 6px; font-size: 13px; color: var(--text); cursor: pointer; }
.tree-item:hover { background: var(--hover); }
.tree-item.active { background: var(--primary-soft); color: var(--primary); font-weight: 600; }
.tree-item .t-count { margin-left: auto; font-size: 12px; color: var(--text-faint); }
.tree-child { padding-left: 22px; }
.tree-grand { padding-left: 40px; }
.doc-viewer { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 20px; }
.breadcrumb { color: var(--text-muted); font-size: 13px; margin-bottom: 18px; }
.breadcrumb b { color: var(--text); }
.empty-drop { border: 2px dashed var(--border-strong); border-radius: var(--radius-lg); padding: 60px 20px; text-align: center; color: var(--text-muted); }
.empty-drop .drop-icon { width: 48px; height: 48px; border-radius: 12px; background: var(--hover); color: var(--text-muted); display: inline-flex; align-items: center; justify-content: center; margin-bottom: 16px; }
.empty-drop h4 { color: var(--text); margin-bottom: 6px; }

/* ---------- calendar ---------- */
.cal-grid { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; }
.cal-head, .cal-week { display: grid; grid-template-columns: repeat(7, 1fr); }
.cal-head div { padding: 12px; text-align: center; font-size: 12px; font-weight: 600; color: var(--text-muted); border-bottom: 1px solid var(--border); }
.cal-cell { min-height: 108px; border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); padding: 8px; font-size: 12px; }
.cal-cell:nth-child(7n) { border-right: none; }
.cal-cell.dim { background: var(--bg); color: var(--text-faint); }
.cal-daynum { font-weight: 600; margin-bottom: 6px; display: inline-block; }
.cal-daynum.today { background: var(--primary); color: #fff; width: 22px; height: 22px; border-radius: 50%; text-align: center; line-height: 22px; }
.cal-ev { font-size: 11px; padding: 2px 6px; border-radius: 4px; margin-bottom: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ev-deadline { background: var(--red-bg); color: var(--red); }
.ev-event { background: var(--amber-bg); color: var(--amber); }
.ev-meeting { background: var(--blue-bg); color: var(--blue); }
.ev-leave { background: var(--violet-bg); color: var(--violet); }
.ev-spike { background: var(--amber-bg); color: var(--amber); }
.cal-more { font-size: 11px; color: var(--primary); font-weight: 600; cursor: pointer; }

/* ---------- generic panel / detail ---------- */
.panel { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 22px; margin-bottom: 20px; }
.panel h3 { font-size: 15px; margin-bottom: 14px; }
.kv { display: grid; grid-template-columns: 180px 1fr; gap: 10px 20px; font-size: 13px; }
.kv dt { color: var(--text-muted); } .kv dd { font-weight: 500; }
.detail-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 20px; }

.placeholder-note { color: var(--text-muted); font-size: 13px; }
.feature-list { display: grid; grid-template-columns: repeat(2,1fr); gap: 14px; margin-top: 16px; }
.feature-item { display: flex; gap: 12px; padding: 16px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--card); }
.feature-item svg { width: 20px; height: 20px; color: var(--primary); flex: none; }
.feature-item h5 { font-size: 13px; margin-bottom: 3px; }
.feature-item p { font-size: 12px; color: var(--text-muted); }

/* 404 */
.notfound { text-align: center; }
.notfound .nf-icon { width: 56px; height: 56px; border-radius: 14px; background: var(--primary-soft); color: var(--primary); display: inline-flex; align-items: center; justify-content: center; margin-bottom: 18px; }
.notfound h1 { font-size: 40px; } .notfound h2 { font-size: 20px; margin: 4px 0 10px; }

/* ============================================================
   Modals / forms
   ============================================================ */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(15, 23, 41, 0.45);
  display: flex; align-items: center; justify-content: center;
  z-index: 100; padding: 24px; animation: fade .12s ease;
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.modal {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
  width: 100%; max-width: 520px; max-height: 90vh; overflow-y: auto;
  animation: pop .14s ease;
}
@keyframes pop { from { transform: translateY(8px) scale(.98); opacity: .6; } to { transform: none; opacity: 1; } }
.modal-head { display: flex; align-items: center; padding: 20px 22px; border-bottom: 1px solid var(--border); }
.modal-head h3 { font-size: 16px; }
.modal-head .close { margin-left: auto; width: 30px; height: 30px; border-radius: 7px; display: flex; align-items: center; justify-content: center; color: var(--text-muted); }
.modal-head .close:hover { background: var(--hover); color: var(--text); }
.modal-body { padding: 22px; display: flex; flex-direction: column; gap: 16px; }
.modal-foot { display: flex; gap: 10px; justify-content: flex-end; padding: 16px 22px; border-top: 1px solid var(--border); }
.form-field { display: flex; flex-direction: column; gap: 6px; }
.form-field label { font-size: 12px; font-weight: 600; color: var(--text-muted); }
.form-field input, .form-field select, .form-field textarea {
  padding: 10px 12px; border: 1px solid var(--border-strong); border-radius: var(--radius);
  background: var(--card); color: var(--text); width: 100%;
}
.form-field input:focus, .form-field select:focus, .form-field textarea:focus { outline: 2px solid var(--primary); outline-offset: -1px; border-color: var(--primary); }
.form-field textarea { resize: vertical; min-height: 84px; font-family: inherit; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-hint { font-size: 12px; color: var(--text-faint); }
.checkbox-row { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.checkbox-row input { width: auto; }
.chip-select { display: flex; flex-wrap: wrap; gap: 8px; }
.chip-select .chip.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* toast */
.toast-wrap { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast {
  background: var(--text); color: var(--card); padding: 11px 18px; border-radius: var(--radius);
  font-size: 13px; font-weight: 500; box-shadow: var(--shadow-lg); display: flex; align-items: center; gap: 8px;
  animation: toastIn .2s ease;
}
.toast svg { width: 16px; height: 16px; color: var(--green); }
@keyframes toastIn { from { transform: translateY(10px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ============================================================
   Kanban (BD Agent)
   ============================================================ */
.kanban { display: grid; grid-template-columns: repeat(7, minmax(150px, 1fr)); gap: 12px; overflow-x: auto; padding-bottom: 8px; }
.kb-col { background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 10px; min-height: 160px; }
.kb-head { display: flex; align-items: center; justify-content: space-between; font-size: 11px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-muted); font-weight: 700; margin-bottom: 10px; padding: 0 2px; }
.kb-head .n { background: var(--card); border: 1px solid var(--border); border-radius: 10px; padding: 1px 7px; }
.kb-card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px; margin-bottom: 8px; box-shadow: var(--shadow-sm); }
.kb-card h5 { font-size: 13px; margin-bottom: 2px; }
.kb-card .kb-sub { font-size: 12px; color: var(--text-muted); margin-bottom: 8px; }
.kb-tags { display: flex; gap: 6px; flex-wrap: wrap; }
.kb-tag { font-size: 10px; font-weight: 700; padding: 2px 6px; border-radius: 4px; background: var(--slate-bg); color: var(--slate); }
.kb-tag.score { background: var(--blue-bg); color: var(--blue); }
.kb-tag.ok { background: var(--green-bg); color: var(--green); }
.kb-empty { color: var(--text-faint); font-size: 12px; text-align: center; padding: 12px 0; }

/* ============================================================
   Master-detail (KYC, Customer Service)
   ============================================================ */
.md-layout { display: grid; grid-template-columns: 340px 1fr; gap: 20px; }
.md-layout.three { grid-template-columns: 320px 1fr 300px; }
.md-list { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; }
.md-item { padding: 14px 16px; border-bottom: 1px solid var(--border); cursor: pointer; }
.md-item:last-child { border-bottom: none; }
.md-item:hover { background: var(--hover); }
.md-item.active { background: var(--primary-soft); }
.md-item .md-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; }
.md-item .md-name { font-weight: 600; font-size: 13px; }
.md-item .md-meta { font-size: 12px; color: var(--text-muted); display: flex; gap: 8px; align-items: center; }
.md-detail, .md-side { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 22px; min-height: 380px; }
.md-empty { display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; height: 100%; color: var(--text-muted); }
.md-empty .md-ic { width: 46px; height: 46px; border-radius: 12px; background: var(--hover); display: flex; align-items: center; justify-content: center; margin-bottom: 14px; }
.md-empty h4 { color: var(--text); margin-bottom: 4px; }

/* chat bubbles */
.chat-scroll { display: flex; flex-direction: column; gap: 10px; margin: 8px 0 16px; }
.bubble { max-width: 78%; padding: 9px 13px; border-radius: 12px; font-size: 13px; line-height: 1.45; }
.bubble.them { background: var(--hover); align-self: flex-start; border-bottom-left-radius: 3px; }
.bubble.me { background: var(--primary); color: #fff; align-self: flex-end; border-bottom-right-radius: 3px; }
.chat-input { display: flex; gap: 8px; }
.chat-input input { flex: 1; padding: 11px 14px; border: 1px solid var(--border-strong); border-radius: var(--radius); background: var(--card); color: var(--text); }
.chat-input button { width: 42px; border-radius: var(--radius); background: var(--primary); color: #fff; display: flex; align-items: center; justify-content: center; }
.prompt-chip { padding: 9px 14px; border: 1px solid var(--border-strong); border-radius: 20px; font-size: 13px; color: var(--text); background: var(--card); text-align: left; }
.prompt-chip:hover { border-color: var(--primary); color: var(--primary); }

/* provider / platform grid */
.provider-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 20px; }
.provider-card { border: 1px solid var(--border-strong); border-radius: var(--radius); padding: 14px 16px; cursor: pointer; background: var(--card); }
.provider-card:hover { border-color: var(--primary); background: var(--primary-soft); }
.provider-card h5 { font-size: 14px; } .provider-card p { font-size: 12px; color: var(--text-muted); }

/* post cards */
.post-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 20px; }
.post-card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 20px; }
.post-card .p-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.post-card h4 { font-size: 16px; margin-bottom: 6px; }
.post-card p { font-size: 13px; color: var(--text-muted); margin-bottom: 12px; }
.post-actions { display: flex; gap: 8px; align-items: center; margin-top: 14px; }

/* team load rows */
.team-row { display: flex; align-items: center; gap: 16px; padding: 16px 0; border-bottom: 1px solid var(--border); }
.team-row:last-child { border-bottom: none; }
.team-av { width: 40px; height: 40px; border-radius: 10px; background: var(--primary-soft); color: var(--primary); display: flex; align-items: center; justify-content: center; font-weight: 700; }
.team-meta { flex: 1; }
.team-meta .t-name { font-weight: 600; }
.team-meta .t-sub { font-size: 12px; color: var(--text-muted); }
.load-track { width: 160px; }
.load-bar { height: 8px; border-radius: 5px; background: var(--hover); overflow: hidden; margin-top: 6px; }
.load-fill { height: 100%; border-radius: 5px; background: var(--primary); }
.load-fill.over { background: var(--red); }

.info-strip { display: flex; gap: 12px; background: var(--primary-soft); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 16px 18px; margin-bottom: 24px; font-size: 13px; }
.info-strip svg { width: 20px; height: 20px; color: var(--primary); flex: none; }
.info-strip b { color: var(--text); }

/* ============================================================
   Dropdown menu (New Company)
   ============================================================ */
.dropdown { position: relative; }
.dropdown-menu {
  position: absolute; right: 0; top: calc(100% + 6px); min-width: 200px; z-index: 40;
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-lg); padding: 6px; animation: pop .12s ease;
}
.dropdown-item { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; padding: 9px 12px; border-radius: 6px; font-size: 13px; font-weight: 500; color: var(--text); }
.dropdown-item:hover { background: var(--hover); }
.dropdown-item svg { width: 16px; height: 16px; color: var(--text-muted); }

/* ============================================================
   Incorporation wizard
   ============================================================ */
.wiz-steps { display: flex; align-items: center; gap: 8px; margin-bottom: 24px; flex-wrap: wrap; }
.wiz-step { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 14px; color: var(--text-faint); }
.wiz-step.cur { color: var(--text); }
.wiz-step.done { color: var(--text); }
.wiz-num { width: 26px; height: 26px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 13px; background: var(--hover); color: var(--text-muted); border: 1px solid var(--border); }
.wiz-step.cur .wiz-num { background: var(--primary-soft); color: var(--primary); border-color: var(--primary); }
.wiz-step.done .wiz-num { background: var(--primary); color: #fff; border-color: var(--primary); }
.wiz-line { width: 40px; height: 1px; background: var(--border); }
.wiz-line.on { background: var(--primary); }
.wiz-foot { display: flex; justify-content: space-between; margin-top: 20px; }
.wiz-row { display: flex; gap: 10px; align-items: center; margin-bottom: 10px; }
.wiz-row input, .wiz-row select { padding: 9px 12px; border: 1px solid var(--border-strong); border-radius: var(--radius); background: var(--card); color: var(--text); flex: 1; min-width: 0; }
.wiz-row input:focus, .wiz-row select:focus { outline: 2px solid var(--primary); outline-offset: -1px; border-color: var(--primary); }
.icon-del { width: 36px; height: 36px; flex: none; border: 1px solid var(--border-strong); border-radius: var(--radius); display: flex; align-items: center; justify-content: center; color: var(--text-muted); transform: rotate(45deg); }
.icon-del:hover { color: var(--red); border-color: var(--red); }
.icon-del svg { width: 16px; height: 16px; }
.review-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 24px; }
.review-grid > div { display: flex; justify-content: space-between; border-bottom: 1px dashed var(--border); padding: 8px 0; }

/* ============================================================
   KYC onboarding wizard (case detail)
   ============================================================ */
.kyc-step { display: flex; gap: 14px; padding: 16px 0; border-bottom: 1px solid var(--border); }
.kyc-step:last-child { border-bottom: none; }
.kyc-check { width: 24px; height: 24px; flex: none; border-radius: 50%; background: var(--hover); color: var(--text-faint); display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; }
.kyc-check svg { width: 14px; height: 14px; }
.kyc-check.on { background: var(--green); color: #fff; }
.kyc-check.warn { background: var(--amber); color: #fff; }
.kyc-body { flex: 1; min-width: 0; }
.kyc-body h4 { font-size: 14px; margin-bottom: 4px; }
.kyc-ok { color: var(--green); font-size: 13px; }
.kyc-list-row { display: flex; align-items: center; justify-content: space-between; padding: 6px 0; font-size: 13px; }

/* responsive */
@media (max-width: 1100px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .chart-grid { grid-template-columns: 1fr; }
  .two-col, .detail-grid, .docs-layout, .feature-list, .post-grid, .dash-lower { grid-template-columns: 1fr; }
  .fin-grid { grid-template-columns: repeat(2, 1fr); }
  .persona-grid { grid-template-columns: 1fr; }
  .provider-grid { grid-template-columns: repeat(2, 1fr) !important; }
  .md-layout, .md-layout.three { grid-template-columns: 1fr; }
}
@media (max-width: 720px) {
  .sidebar { display: none; }
  .kpi-grid { grid-template-columns: 1fr; }
  .search { width: 160px; }
  .user-block .u-mail, .tenant-name { display: none; }
}
