/* ==========================================================================
   Oakframe Media OS — design system
   Flat and architectural, not a soft-shadow rounded-card template: sharp
   corners, hairline borders instead of glow, one typeface (DM Sans) with
   hierarchy built from weight/tracking/case rather than a serif pairing.
   Light: cool gallery-white ground, near-black ink. Dark: true-black
   ground, off-white ink — the auth screen's brand panel stays black in
   both modes, matching the real logo. Gold is the single accent, used
   deliberately (primary actions, one rule line) rather than tinted
   everywhere. Every color is a custom property; :root[data-theme="dark"]
   below overrides them with dark values — no component rule needs to know
   which mode is active.
   ========================================================================== */

:root {
  --bg: #f2f2f0;            /* cool gallery white, not warm paper */
  --bg-raise: #ffffff;
  --surface: #ffffff;
  --surface-2: #ffffff;
  --panel: #f5f5f3;

  --ink: #101012;          /* true near-black */
  --ink-2: #4d4d52;        /* secondary */
  --muted: #86868c;        /* muted gray */
  --faint: #b9b9bd;

  --gold: #b8860b;         /* accent fills */
  --gold-deep: #916a08;    /* gold text on white (contrast-safe) */
  --gold-bright: #caa63a;
  --gold-tint: #f6efda;    /* soft gold wash */
  --gold-tint-2: #f0e6cc;

  --good: #1a7f4b;
  --good-tint: #e7f3ec;
  --warn: #b6791a;
  --warn-tint: #f7efdd;
  --bad: #c1362f;
  --bad-tint: #fbe9e7;
  --info: #2a6fdb;
  --info-tint: #e8f0fc;

  --hairline: #e2e1de;
  --hairline-strong: #c9c8c4;
  --ring: rgba(184, 134, 11, 0.28);
  --scrim: rgba(10, 10, 10, 0.4);
  --skeleton-base: #ececea;
  --skeleton-shine: rgba(255, 255, 255, 0.7);
  --track: #e2e1de;
  --code-bg: #ececea;
  --auth-grad-1: #fbf7ec;
  --auth-grad-2: #f3efe6;
  --hover: #ececea;
  --scroll-thumb: #d2d1cd;
  --scroll-thumb-hover: #bfbebb;
  --topbar-bg: rgba(255, 255, 255, 0.88);
  --color-scheme: light;

  /* Sharp, architectural — not the rounded-2xl-everything default every
     generated dashboard ships with. */
  --r-lg: 4px;
  --r-md: 3px;
  --r-sm: 3px;
  /* Flat design: borders do the separating, shadows are reserved for things
     that actually float above the page (modals, dropdown menus). */
  --shadow-sm: none;
  --shadow: 0 1px 3px rgba(16, 16, 18, 0.1);
  --shadow-lg: 0 20px 48px -18px rgba(16, 16, 18, 0.32), 0 2px 8px rgba(16, 16, 18, 0.08);

  --font-display: "DM Sans", -apple-system, "Segoe UI", sans-serif;
  --font-body: "DM Sans", -apple-system, "Segoe UI", sans-serif;
}

/* ---- Dark theme — same token names, dark values. Everything else in this
   file and refine.css reads these variables, so no component rule needs to
   know which mode is active. Toggled by setting data-theme on <html> (see
   js/theme.js); defaults to the visitor's OS preference on first visit. ---- */
:root[data-theme="dark"] {
  --bg: #050505;
  --bg-raise: #0d0d0e;
  --surface: #111113;
  --surface-2: #17171a;
  --panel: #0d0d0e;

  --ink: #f2f2f0;
  --ink-2: #b4b4b8;
  --muted: #87878d;
  --faint: #56565b;

  --gold: #c9a227;
  --gold-deep: #e3c565;    /* readable gold text on dark surfaces */
  --gold-bright: #f0d989;
  --gold-tint: rgba(201, 162, 39, 0.14);
  --gold-tint-2: rgba(201, 162, 39, 0.24);

  --good: #34d399;
  --good-tint: rgba(52, 211, 153, 0.14);
  --warn: #fab219;
  --warn-tint: rgba(250, 178, 25, 0.14);
  --bad: #f87171;
  --bad-tint: rgba(248, 113, 113, 0.14);
  --info: #7ea6e0;
  --info-tint: rgba(126, 166, 224, 0.14);

  --hairline: rgba(255, 255, 255, 0.08);
  --hairline-strong: rgba(255, 255, 255, 0.14);
  --ring: rgba(201, 162, 39, 0.38);
  --scrim: rgba(0, 0, 0, 0.5);
  --skeleton-base: rgba(255, 255, 255, 0.06);
  --skeleton-shine: rgba(255, 255, 255, 0.12);
  --track: rgba(255, 255, 255, 0.08);
  --code-bg: rgba(255, 255, 255, 0.08);
  --auth-grad-1: #17140d;
  --auth-grad-2: #0c0c0c;
  --hover: rgba(255, 255, 255, 0.055);
  --scroll-thumb: rgba(255, 255, 255, 0.12);
  --scroll-thumb-hover: rgba(255, 255, 255, 0.2);
  --topbar-bg: rgba(10, 10, 13, 0.75);
  --color-scheme: dark;

  --shadow-sm: none;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 24px 56px -18px rgba(0, 0, 0, 0.7), 0 2px 10px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
html { color-scheme: var(--color-scheme); }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
::selection { background: var(--gold-tint-2); }
a { color: var(--gold-deep); text-decoration: none; }
.link { color: var(--gold-deep); cursor: pointer; font-size: 12.5px; font-weight: 500; }
.link:hover { text-decoration: underline; }
.muted { color: var(--muted); }
.mono { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 0.9em; }
h1, h2, h3, h4 { font-family: var(--font-display); font-weight: 700; letter-spacing: -0.5px; margin: 0; color: var(--ink); }
.flex-spacer { flex: 1; }

::-webkit-scrollbar { width: 11px; height: 11px; }
::-webkit-scrollbar-thumb { background: var(--scroll-thumb); border-radius: 7px; border: 3px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: var(--scroll-thumb-hover); }
::-webkit-scrollbar-track { background: transparent; }

/* ============ SHELL ============ */
.shell { display: flex; height: 100vh; overflow: hidden; }
.sidebar {
  width: 256px; flex-shrink: 0; display: flex; flex-direction: column;
  background: var(--bg-raise);
  border-right: 1px solid var(--hairline);
}
.brand { display: flex; align-items: center; gap: 11px; padding: 20px 18px 14px; }
.brand-mark {
  width: 34px; height: 34px; border-radius: var(--r-sm); flex-shrink: 0; cursor: pointer;
  background: var(--ink); color: var(--bg);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display); font-size: 20px; font-weight: 700;
}
.brand-mark.xl { width: 56px; height: 56px; font-size: 29px; border-radius: var(--r-md); }
.brand-mark .icon { width: 18px; height: 18px; }
.brand-mark.xl .icon { width: 30px; height: 30px; }
.brand-text { cursor: pointer; }
.brand-text b { font-family: var(--font-display); font-size: 15px; font-weight: 800; display: block; line-height: 1.1; text-transform: uppercase; letter-spacing: 1.2px; }
.brand-text span { color: var(--muted); font-size: 10px; letter-spacing: 2.2px; text-transform: uppercase; }

.nav { flex: 1; overflow-y: auto; padding: 6px 12px 12px; }
.nav-section { margin-top: 16px; }
.nav-label { font-size: 10.5px; text-transform: uppercase; letter-spacing: 1.4px; color: var(--faint); padding: 0 8px 6px; font-weight: 600; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px 8px 9px; border-radius: var(--r-sm);
  border-left: 2px solid transparent;
  color: var(--ink-2); font-size: 13.5px; font-weight: 500;
  transition: border-color 0.14s ease, color 0.14s ease, background 0.14s ease;
}
.nav-item:hover { color: var(--ink); background: var(--hover); }
.nav-item.active {
  border-left-color: var(--gold);
  color: var(--ink); font-weight: 700;
}
.nav-icon { width: 18px; height: 18px; display: inline-flex; align-items: center; justify-content: center; opacity: 0.8; flex-shrink: 0; }
.icon { width: 1em; height: 1em; display: inline-block; vertical-align: -0.15em; flex-shrink: 0; }
.nav-icon .icon { width: 17px; height: 17px; }
.nav-item.active .nav-icon { opacity: 1; }
.nav-count { margin-left: auto; background: var(--gold); color: #fff; font-size: 10.5px; font-weight: 700; border-radius: 999px; padding: 1px 7px; }
.nav-lock { color: var(--gold); }
.sidebar-foot { border-top: 1px solid var(--hairline); padding: 12px; }
.me-chip { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: var(--r-sm); cursor: pointer; }
.me-chip:hover { background: var(--hover); }
.me-info b { display: block; font-size: 13px; }
.me-info span { color: var(--muted); font-size: 11px; }

.main-col { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar {
  display: flex; align-items: center; gap: 14px;
  padding: 12px 26px; border-bottom: 1px solid var(--hairline);
  background: var(--topbar-bg); backdrop-filter: blur(12px); z-index: 30;
}
.burger { display: none; }
.global-search { position: relative; flex: 1; max-width: 540px; }
.gs-icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.gs-icon .icon { width: 15px; height: 15px; }
.global-search input {
  width: 100%; background: var(--bg); border: 1px solid var(--hairline-strong);
  border-radius: var(--r-sm); padding: 9px 14px 9px 34px; color: var(--ink); font-size: 13px; outline: none;
  font-family: var(--font-body); transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.global-search input::placeholder { color: var(--muted); }
.global-search input:focus { border-color: var(--gold); box-shadow: 0 0 0 3px var(--ring); background: var(--surface); }

.icon-btn {
  background: transparent; border: 1px solid transparent; color: var(--ink-2);
  border-radius: var(--r-sm); padding: 7px 10px; cursor: pointer; font-size: 15px;
  transition: background 0.14s ease; display: inline-flex; align-items: center; justify-content: center;
}
.icon-btn:hover { background: var(--hover); color: var(--ink); }
.icon-btn .icon { width: 17px; height: 17px; }
.bell { position: relative; }
.bell-count { position: absolute; top: 2px; right: 2px; background: var(--gold); color: #fff; font-size: 9.5px; font-weight: 700; border-radius: 999px; padding: 0 5px; line-height: 15px; }
.user-menu-wrap { position: relative; }
.user-menu {
  display: none; position: absolute; right: 0; top: calc(100% + 8px); width: 230px;
  background: var(--surface); border: 1px solid var(--hairline-strong); border-radius: var(--r-md);
  box-shadow: var(--shadow-lg); overflow: hidden; z-index: 70;
}
.user-menu.open { display: block; }
.um-head { padding: 12px 14px; border-bottom: 1px solid var(--hairline); }
.um-head b { display: block; }
.um-head span { font-size: 12px; }
.user-menu a, .user-menu button {
  display: block; width: 100%; text-align: left; padding: 10px 14px;
  background: none; border: none; color: var(--ink-2); font-size: 13px; cursor: pointer; font-family: var(--font-body);
}
.user-menu a:hover, .user-menu button:hover { background: #f6f4ef; color: var(--ink); }

.content { flex: 1; overflow-y: auto; padding: 30px 36px 64px; }

/* ============ PAGE SCAFFOLD ============ */
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 24px; flex-wrap: wrap; }
.page-title { font-size: 30px; line-height: 1.1; letter-spacing: -0.8px; font-weight: 800; }
.page-sub { color: var(--muted); margin: 7px 0 0; font-size: 13.5px; }
.page-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.grid-2 { display: grid; grid-template-columns: 1.25fr 1fr; gap: 20px; align-items: start; margin-top: 20px; }
.tab-body { margin-top: 18px; }
.row-gap { margin-top: 14px; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.row-gap.center { justify-content: center; }
.footnote { font-size: 12px; margin-top: 10px; color: var(--muted); }
.body-text { color: var(--ink-2); font-size: 13.5px; line-height: 1.65; margin: 10px 0 0; }

/* ============ CARDS ============ */
.card {
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--r-lg);
  padding: 20px;
  margin-bottom: 18px;
  box-shadow: var(--shadow-sm);
}
.card-flush { padding: 4px 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; gap: 10px; }
.card-head h3 { font-size: 16px; }
.card.clickable, .clickable { cursor: pointer; }

/* KPI tiles */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(172px, 1fr)); gap: 14px; }
.kpi { padding: 16px 18px; margin-bottom: 0; transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease; }
.kpi.clickable:hover { transform: translateY(-2px); box-shadow: var(--shadow); border-color: var(--hairline-strong); }
.kpi-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 6px; }
.kpi-label { font-size: 11px; text-transform: uppercase; letter-spacing: 1.2px; color: var(--muted); font-weight: 600; }
.kpi-icon {
  width: 30px; height: 30px; border-radius: var(--r-sm); flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  background: var(--panel); color: var(--gold-deep); border: 1px solid var(--hairline);
}
.kpi-icon .icon { width: 15px; height: 15px; }
.kpi-value { font-family: var(--font-display); font-weight: 800; font-size: 28px; margin-top: 8px; line-height: 1; letter-spacing: -0.8px; font-variant-numeric: tabular-nums; }
.kpi-sub { color: var(--muted); font-size: 12px; margin-top: 6px; }
.tone-text-good { color: var(--good); } .tone-text-warn { color: var(--warn); } .tone-text-bad { color: var(--bad); }
.mini-stats { display: flex; gap: 22px; flex-wrap: wrap; }
.mini-stat b { font-family: var(--font-display); font-size: 21px; display: block; }
.mini-stat span { color: var(--muted); font-size: 11.5px; }

/* ============ BUTTONS ============ */
.btn {
  border: 1px solid var(--hairline-strong); background: var(--surface);
  color: var(--ink); border-radius: var(--r-sm); padding: 9px 16px;
  font-size: 13px; font-weight: 600; cursor: pointer; font-family: var(--font-body);
  transition: all 0.12s ease; white-space: nowrap;
}
.btn:hover { background: var(--hover); border-color: var(--faint); }
.btn:active { transform: translateY(1px); }
.btn-gold {
  background: var(--gold); border-color: var(--gold); color: #fff; font-weight: 700;
}
.btn-gold:hover { background: var(--gold-deep); border-color: var(--gold-deep); }
.btn-ghost { background: transparent; }
.btn-ghost:hover { background: var(--hover); }
.btn-danger { background: var(--bad-tint); border-color: #eebcb8; color: var(--bad); }
.btn-danger-ghost { background: transparent; border-color: #eec8c5; color: var(--bad); }
.btn-danger-ghost:hover { background: var(--bad-tint); }
.btn-sm { padding: 6px 12px; font-size: 12px; border-radius: var(--r-sm); }
.btn-lg { padding: 13px 22px; font-size: 14.5px; border-radius: var(--r-md); }
.btn-block { width: 100%; display: block; }
.btn:disabled { opacity: 0.5; cursor: default; }
.link-btn { background: none; border: none; color: var(--gold-deep); font: inherit; font-weight: 600; cursor: pointer; padding: 0; }
.link-btn:hover { text-decoration: underline; }

/* ============ BADGES / CHIPS ============ */
.badge {
  display: inline-block; font-size: 10.5px; font-weight: 650; letter-spacing: 0.3px;
  padding: 3px 9px; border-radius: 999px; text-transform: uppercase; white-space: nowrap;
}
.tone-good { background: var(--good-tint); color: var(--good); }
.tone-warn { background: var(--warn-tint); color: var(--warn); }
.tone-bad { background: var(--bad-tint); color: var(--bad); }
.tone-info { background: var(--info-tint); color: var(--info); }
.tone-neutral { background: var(--code-bg); color: var(--ink-2); }
.tag { display: inline-block; background: var(--code-bg); color: var(--ink-2); font-size: 10.5px; padding: 2px 8px; border-radius: 3px; margin: 2px 3px 0 0; }
.tag-lock { color: var(--warn); background: var(--warn-tint); }
.tier { display: inline-flex; width: 24px; height: 24px; align-items: center; justify-content: center; border-radius: var(--r-sm); font-weight: 700; font-size: 12px; }
.tier-A { background: var(--gold-tint); color: var(--gold-deep); border: 1px solid var(--gold-tint-2); }
.tier-B { background: var(--info-tint); color: var(--info); }
.tier-C { background: var(--code-bg); color: var(--ink-2); }
.prio { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex-shrink: 0; }
.prio-urgent { background: var(--bad); box-shadow: 0 0 0 3px var(--bad-tint); }
.prio-high { background: var(--warn); }
.prio-medium { background: var(--info); }
.prio-low { background: var(--faint); }

/* Avatars */
.avatar {
  position: relative; width: 30px; height: 30px; border-radius: 50%; flex-shrink: 0;
  background: var(--av, #efece6); color: #fff; overflow: hidden;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 650; letter-spacing: 0.4px;
}
.avatar-img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }
.avatar.lg { width: 46px; height: 46px; font-size: 15px; }
.avatar.xl { width: 84px; height: 84px; font-size: 26px; }

.avatar-upload { position: relative; width: 84px; height: 84px; flex-shrink: 0; cursor: pointer; border-radius: 50%; }
.avatar-upload-overlay {
  position: absolute; inset: 0; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  background: rgba(0, 0, 0, 0.45); color: #fff; font-size: 20px; opacity: 0; transition: opacity 0.15s ease;
}
.avatar-upload:hover .avatar-upload-overlay { opacity: 1; }
.avatar-upload.uploading .avatar-upload-overlay { opacity: 1; animation: pulse-op 1s infinite; }
@keyframes pulse-op { 0%, 100% { opacity: 0.6; } 50% { opacity: 1; } }
.dot-online { position: absolute; bottom: -1px; right: -1px; width: 9px; height: 9px; background: var(--good); border-radius: 50%; border: 2px solid #fff; }
.user-cell { display: inline-flex; align-items: center; gap: 9px; }
.user-cell .user-name { display: block; font-weight: 550; font-size: 13px; }
.user-cell .user-sub { display: block; color: var(--muted); font-size: 11px; }

/* ============ LISTS ============ */
.list-row { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-bottom: 1px solid var(--hairline); }
.card .list-row:last-child, .card-flush .list-row:last-child { border-bottom: none; }
.list-row.clickable:hover { background: var(--hover); }
.list-icon { width: 28px; height: 28px; flex-shrink: 0; display: flex; align-items: center; justify-content: center; background: var(--hover); border-radius: var(--r-sm); font-size: 12px; color: var(--ink-2); }
.list-icon .icon { width: 15px; height: 15px; }
.list-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.list-main b { font-weight: 560; font-size: 13.5px; }
.list-main .muted { font-size: 12px; }
.lead-value { font-family: var(--font-display); font-size: 15px; color: var(--gold-deep); white-space: nowrap; }
.unread-dot { width: 8px; height: 8px; background: var(--gold); border-radius: 50%; flex-shrink: 0; }
.notif.unread { background: var(--gold-tint); }

/* ============ TABLES ============ */
.table-toolbar { display: flex; align-items: center; gap: 12px; padding: 10px 14px; flex-wrap: wrap; }
.search-box { display: flex; align-items: center; gap: 8px; background: var(--bg); border: 1px solid var(--hairline-strong); border-radius: var(--r-sm); padding: 7px 12px; color: var(--muted); flex: 0 1 300px; }
.search-box:focus-within { border-color: var(--gold); box-shadow: 0 0 0 3px var(--ring); background: var(--surface); }
.search-box input { background: none; border: none; outline: none; color: var(--ink); font-size: 13px; width: 100%; font-family: var(--font-body); }
.table-count { color: var(--muted); font-size: 12px; }
.table-scroll { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table th {
  text-align: left; padding: 11px 14px; font-size: 10.5px; text-transform: uppercase;
  letter-spacing: 1px; color: var(--muted); font-weight: 600;
  border-bottom: 1px solid var(--hairline-strong); cursor: pointer; user-select: none; white-space: nowrap;
  position: sticky; top: 0; background: var(--panel); z-index: 2;
}
.data-table th:hover { color: var(--ink-2); }
.data-table th.sorted { color: var(--gold-deep); }
.filter-row th { padding: 6px 10px; cursor: default; position: sticky; top: 37px; background: var(--panel); z-index: 2; border-bottom: 1px solid var(--hairline-strong); }
.filter-row th:hover { color: inherit; }
.col-filter {
  width: 100%; background: var(--surface); border: 1px solid var(--hairline); border-radius: 7px;
  padding: 5px 9px; font-size: 12px; color: var(--ink); outline: none; font-family: var(--font-body);
  font-weight: 400; text-transform: none; letter-spacing: normal;
}
.col-filter:focus { border-color: var(--gold); box-shadow: 0 0 0 2px var(--ring); }
.col-filter::placeholder { color: var(--faint); }
.data-table td { padding: 12px 14px; border-bottom: 1px solid var(--hairline); vertical-align: middle; }
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tr.row-click { cursor: pointer; }
.data-table tr.row-click:hover { background: var(--hover); }
.table-empty { text-align: center; color: var(--muted); padding: 34px !important; }
.table-pager { display: flex; align-items: center; justify-content: center; gap: 14px; padding: 12px; color: var(--muted); font-size: 12.5px; }

/* ============ FORMS ============ */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-field { display: flex; flex-direction: column; gap: 6px; }
.form-field.span2 { grid-column: span 2; }
.form-label { font-size: 11px; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); font-weight: 600; }
.om-form input, .om-form textarea, textarea, input[type="text"], input[type="email"], input[type="number"], input[type="password"], input[type="date"] {
  background: var(--surface); border: 1px solid var(--hairline-strong); border-radius: var(--r-sm);
  color: var(--ink); padding: 10px 13px; font-size: 13.5px; outline: none; font-family: var(--font-body);
  transition: border-color 0.15s ease, box-shadow 0.15s ease; width: 100%;
}
.om-form input:focus, .om-form textarea:focus, textarea:focus, input:focus { border-color: var(--gold); box-shadow: 0 0 0 3px var(--ring); }
.file-input { padding: 8px 10px; font-size: 12.5px; color: var(--ink-2); }
.file-input::file-selector-button {
  border: 1px solid var(--hairline-strong); background: var(--panel); color: var(--ink);
  border-radius: var(--r-sm); padding: 6px 12px; font-size: 12px; font-family: var(--font-body); font-weight: 550;
  cursor: pointer; margin-right: 10px; transition: background 0.14s ease;
}
.file-input::file-selector-button:hover { background: var(--hover); }
.upload-progress { font-size: 12px; color: var(--muted); margin-top: 6px; }
.form-readonly { color: var(--ink-2); padding: 10px 0; }
.form-hint { font-size: 11.5px; color: var(--muted); }
.form-actions { margin-top: 18px; display: flex; justify-content: flex-end; gap: 8px; }
.inline-add { display: flex; gap: 8px; margin-top: 10px; }
.inline-add input { flex: 1; }
.check-row { display: flex; align-items: center; gap: 9px; padding: 6px 0; font-size: 13.5px; cursor: pointer; }
.check-row input { accent-color: var(--gold); width: 15px; height: 15px; }
.struck { text-decoration: line-through; color: var(--muted); }

/* ============ CUSTOM DROPDOWN ============ */
.dropdown { position: relative; width: 100%; }
.dropdown-trigger {
  width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 10px;
  background: var(--surface); border: 1px solid var(--hairline-strong); border-radius: var(--r-sm);
  color: var(--ink); padding: 10px 13px; font-size: 13.5px; cursor: pointer; font-family: var(--font-body);
  text-align: left; transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.dropdown-trigger:hover { border-color: var(--faint); }
.dropdown.open .dropdown-trigger { border-color: var(--gold); box-shadow: 0 0 0 3px var(--ring); }
.dropdown-trigger .dd-value { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dropdown-trigger .dd-value.placeholder { color: var(--muted); }
.dropdown-caret { color: var(--muted); font-size: 10px; transition: transform 0.16s ease; flex-shrink: 0; }
.dropdown.open .dropdown-caret { transform: rotate(180deg); }
.dropdown-menu {
  position: absolute; z-index: 120; top: calc(100% + 6px); left: 0; right: 0;
  background: var(--surface); border: 1px solid var(--hairline-strong); border-radius: var(--r-md);
  box-shadow: var(--shadow-lg); overflow: hidden; display: none;
  animation: ddIn 0.13s cubic-bezier(.2,.7,.3,1);
}
.dropdown.open .dropdown-menu { display: block; }
.dropdown.up .dropdown-menu { top: auto; bottom: calc(100% + 6px); }
@keyframes ddIn { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
.dropdown-search { padding: 9px 11px; border-bottom: 1px solid var(--hairline); }
.dropdown-search input { width: 100%; border: none; outline: none; font-size: 13px; font-family: var(--font-body); background: none; padding: 2px; }
.dropdown-options { max-height: 264px; overflow-y: auto; padding: 5px; }
.dropdown-opt {
  display: flex; align-items: center; gap: 9px; padding: 9px 11px; border-radius: var(--r-sm);
  font-size: 13.5px; cursor: pointer; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.dropdown-opt:hover, .dropdown-opt.active { background: var(--hover); }
.dropdown-opt.selected { color: var(--gold-deep); font-weight: 600; }
.dropdown-opt .dd-check { margin-left: auto; color: var(--gold); font-size: 13px; opacity: 0; }
.dropdown-opt.selected .dd-check { opacity: 1; }
.dropdown-empty { padding: 14px; text-align: center; color: var(--muted); font-size: 12.5px; }

/* ============ MODALS ============ */
.modal-overlay {
  position: fixed; inset: 0; background: var(--scrim); backdrop-filter: blur(3px);
  display: flex; align-items: flex-start; justify-content: center; padding: 8vh 18px 18px;
  z-index: 100; opacity: 0; transition: opacity 0.16s ease; overflow-y: auto;
}
.modal-overlay.open { opacity: 1; }
.modal {
  width: 100%; max-width: 480px; background: var(--surface);
  border: 1px solid var(--hairline); border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg); transform: translateY(10px); transition: transform 0.16s ease;
}
.modal-overlay.open .modal { transform: translateY(0); }
.modal-wide { max-width: 640px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 22px 0; }
.modal-head h3 { font-size: 19px; }
.modal-body { padding: 18px 22px 22px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 0 22px 20px; }
.modal-sub { font-size: 13px; margin: 16px 0 6px; color: var(--gold-deep); }
.confirm-text { color: var(--ink-2); margin: 4px 0 12px; }

/* ============ TOASTS ============ */
.toast-host { position: fixed; bottom: 22px; right: 22px; display: flex; flex-direction: column; gap: 8px; z-index: 200; }
.toast {
  background: var(--surface); border: 1px solid var(--hairline-strong); border-left: 3px solid var(--info);
  color: var(--ink); padding: 12px 16px; border-radius: var(--r-md); font-size: 13px;
  box-shadow: var(--shadow-lg); max-width: 380px;
  opacity: 0; transform: translateX(12px); transition: all 0.22s ease;
}
.toast.show { opacity: 1; transform: translateX(0); }
.toast.tone-good { border-left-color: var(--good); }
.toast.tone-warn { border-left-color: var(--warn); }
.toast.tone-bad { border-left-color: var(--bad); }

/* ============ TABS ============ */
.tab-row { display: flex; gap: 4px; border-bottom: 1px solid var(--hairline); flex-wrap: wrap; align-items: center; }
.tab {
  background: none; border: none; color: var(--muted); font-size: 13.5px; font-family: var(--font-body); font-weight: 500;
  padding: 9px 14px; cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; transition: color 0.14s ease;
}
.tab:hover { color: var(--ink); }
.tab.active { color: var(--gold-deep); border-bottom-color: var(--gold); font-weight: 600; }
.tab-count { background: var(--code-bg); border-radius: 999px; font-size: 10.5px; padding: 1px 7px; margin-left: 4px; }
.sub-tabs { border-bottom: none; margin: 4px 0 12px; }
.sub-tabs .tab { padding: 6px 12px; border: 1px solid var(--hairline-strong); border-radius: 999px; font-size: 12.5px; margin: 0 2px 4px 0; }
.sub-tabs .tab.active { border-color: var(--gold); background: var(--gold-tint); }

/* ============ KANBAN ============ */
.kanban { display: flex; gap: 14px; overflow-x: auto; padding-bottom: 12px; align-items: flex-start; }
.kanban-col { min-width: 244px; width: 244px; flex-shrink: 0; background: var(--panel); border: 1px solid var(--hairline); border-radius: var(--r-md); }
.kanban-head { display: flex; align-items: center; gap: 8px; padding: 12px 13px; font-size: 12px; text-transform: uppercase; letter-spacing: 1px; color: var(--ink-2); font-weight: 600; }
.kanban-count { background: var(--hover); border-radius: 999px; padding: 1px 8px; font-size: 10.5px; }
.kanban-sum { margin-left: auto; color: var(--gold-deep); font-size: 11px; letter-spacing: 0; text-transform: none; font-family: var(--font-display); }
.kanban-body { padding: 4px 8px 10px; min-height: 60px; display: flex; flex-direction: column; gap: 8px; }
.kanban-body.dragover { background: var(--gold-tint); outline: 1px dashed var(--gold); }
.kanban-card { background: var(--surface); border: 1px solid var(--hairline-strong); border-radius: var(--r-sm); padding: 11px 13px; cursor: grab; box-shadow: var(--shadow-sm); transition: box-shadow 0.14s ease, transform 0.14s ease, border-color 0.14s ease; }
.kanban-card:hover { box-shadow: var(--shadow); transform: translateY(-1px); border-color: var(--faint); }
.kanban-card.dragging { opacity: 0.5; }
.kanban-empty { color: var(--faint); font-size: 12px; text-align: center; padding: 14px 0; }
.kc-title { font-size: 13px; font-weight: 560; line-height: 1.3; }
.kc-sub { color: var(--muted); font-size: 11.5px; margin-top: 3px; }
.kc-meta { display: flex; align-items: center; gap: 8px; margin-top: 8px; font-size: 11.5px; }
.kc-meta .avatar { width: 22px; height: 22px; font-size: 9px; margin-left: auto; }

/* ============ CHARTS ============ */
.ax { fill: var(--muted); font-size: 10.5px; font-family: var(--font-body); }
.bar { transition: opacity 0.12s ease; cursor: pointer; }
.bar:hover { opacity: 0.82; }
.seg { cursor: pointer; transition: opacity 0.12s ease; }
.seg:hover { opacity: 0.85; }
.donut-big { fill: var(--ink); font-family: var(--font-display); font-size: 21px; }
.donut-wrap { display: flex; align-items: center; gap: 20px; flex-wrap: wrap; }
.chart-legend { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 10px; font-size: 12px; color: var(--ink-2); }
.chart-legend-col { flex-direction: column; gap: 7px; margin-top: 0; }
.legend-item { display: inline-flex; align-items: center; gap: 7px; }
.legend-swatch { width: 10px; height: 10px; border-radius: 3px; display: inline-block; flex-shrink: 0; }
.legend-val { margin-left: 4px; color: var(--ink); font-weight: 600; }
.chart-tip {
  display: none; position: fixed; z-index: 300; pointer-events: none;
  background: var(--surface); border: 1px solid var(--hairline-strong); border-radius: 9px;
  padding: 9px 12px; font-size: 12px; box-shadow: var(--shadow-lg); color: var(--ink-2);
}
.tip-title { font-weight: 650; color: var(--ink); margin-bottom: 4px; }
.tip-row { display: flex; align-items: center; gap: 7px; margin-top: 2px; }
.tip-row b { margin-left: auto; padding-left: 14px; color: var(--ink); }
.hbars { display: flex; flex-direction: column; gap: 9px; }
.hbar-row { display: grid; grid-template-columns: minmax(90px, 160px) 1fr auto; align-items: center; gap: 10px; }
.hbar-label { font-size: 12.5px; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hbar-track { background: var(--hover); border-radius: 5px; height: 14px; overflow: hidden; }
.hbar-fill { height: 100%; border-radius: 4px; min-width: 2px; transition: width 0.4s ease; }
.hbar-value { font-size: 12px; color: var(--ink); font-weight: 600; white-space: nowrap; }
.meter { background: var(--hover); border-radius: 4px; height: 6px; width: 90px; overflow: hidden; display: inline-block; vertical-align: middle; margin-right: 7px; }
.meter-fill { height: 100%; border-radius: 4px; }

/* ============ DETAIL / PROFILE ============ */
.detail-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 14px; margin-bottom: 6px; }
.detail-label { display: block; font-size: 10.5px; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); margin-bottom: 3px; font-weight: 600; }
.status-row { flex-wrap: wrap; }
.dep-list { margin-top: 12px; }
.dep-chip { display: inline-block; background: var(--hover); border: 1px solid var(--hairline); color: var(--ink-2); border-radius: 999px; padding: 4px 12px; font-size: 12px; margin: 4px 4px 0 0; }
.dep-chip.done { color: var(--good); border-color: #cfe6d8; background: var(--good-tint); }
.comment-list { display: flex; flex-direction: column; gap: 12px; margin-bottom: 6px; }
.comment { display: flex; gap: 10px; }
.comment-head { display: flex; gap: 8px; align-items: baseline; font-size: 13px; }
.comment-body { color: var(--ink-2); font-size: 13px; margin-top: 2px; }
.mention { color: var(--gold-deep); font-weight: 600; }
.profile-row { display: flex; gap: 14px; align-items: center; margin-bottom: 14px; }
.perm-row { display: flex; gap: 10px; align-items: center; padding: 5px 0; color: var(--muted); font-size: 13px; }
.perm-row.ok { color: var(--ink-2); }
.perm-row span { width: 18px; color: var(--bad); font-weight: 700; }
.perm-row.ok span { color: var(--good); }

/* Timeline */
.timeline { display: flex; flex-direction: column; }
.tl-item { display: flex; gap: 12px; position: relative; padding-bottom: 16px; }
.tl-item:not(:last-child)::before { content: ""; position: absolute; left: 12px; top: 26px; bottom: 0; width: 1px; background: var(--hairline-strong); }
.tl-marker { width: 25px; height: 25px; flex-shrink: 0; background: var(--hover); border: 1px solid var(--hairline-strong); border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 10px; color: var(--gold-deep); }
.tl-title { font-size: 13px; }
.tl-body { color: var(--ink-2); font-size: 12.5px; margin-top: 2px; }
.tl-meta { color: var(--muted); font-size: 11.5px; margin-top: 3px; }

/* ============ SALES ============ */
.stage-track { display: flex; gap: 4px; margin-bottom: 18px; flex-wrap: wrap; }
.stage-step { flex: 1; min-width: 100px; text-align: center; font-size: 11px; text-transform: uppercase; letter-spacing: 0.6px; padding: 8px 6px; background: var(--panel); color: var(--muted); border: 1px solid var(--hairline); }
.stage-step:first-child { border-radius: 8px 0 0 8px; }
.stage-step:last-child { border-radius: 0 8px 8px 0; }
.stage-step.hit { background: var(--gold-tint); color: var(--gold-deep); border-color: var(--gold-tint-2); font-weight: 600; }
.stage-step.won-all { background: var(--good-tint); color: var(--good); }
.stage-step.lost-all { background: var(--bad-tint); color: var(--bad); }
.call-queue-row { display: flex; align-items: center; gap: 13px; padding: 13px 14px; border-bottom: 1px solid var(--hairline); }
.call-queue-row:hover { background: var(--hover); }
.cq-actions { display: flex; gap: 6px; }
.call-header { display: flex; justify-content: space-between; align-items: center; background: var(--panel); border: 1px solid var(--hairline); border-radius: var(--r-md); padding: 14px 16px; margin-bottom: 16px; }
.call-number { font-family: var(--font-display); font-size: 21px; color: var(--gold-deep); }
.call-timer { text-align: right; }
.call-timer span { font-family: ui-monospace, monospace; font-size: 21px; display: block; margin-bottom: 4px; }
.outcome-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }
.outcome-opt { position: relative; }
.outcome-opt input { position: absolute; opacity: 0; }
.outcome-opt span { display: block; padding: 9px 12px; background: var(--surface); border: 1px solid var(--hairline-strong); border-radius: var(--r-sm); font-size: 12.5px; cursor: pointer; color: var(--ink-2); transition: all 0.13s ease; }
.outcome-opt input:checked + span { border-color: var(--gold); background: var(--gold-tint); color: var(--gold-deep); font-weight: 600; }
.rep-monitor { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.rep-calls { max-height: 320px; overflow-y: auto; }

/* ============ EQUIPMENT / LIBRARY ============ */
.eq-grid, .lib-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(252px, 1fr)); gap: 14px; margin-top: 14px; }
.eq-card, .lib-card { display: flex; flex-direction: column; gap: 5px; margin-bottom: 0; }
.eq-top, .lib-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 3px; }
.eq-name { font-size: 14.5px; }
.eq-note { font-size: 12px; color: var(--warn); background: var(--warn-tint); border-radius: 7px; padding: 6px 9px; margin-top: 4px; }
.eq-actions { display: flex; gap: 6px; margin-top: 10px; flex-wrap: wrap; }
.file-icon { display: inline-flex; align-items: center; justify-content: center; background: var(--gold-tint); color: var(--gold-deep); border-radius: 3px; font-size: 9px; font-weight: 800; letter-spacing: 0.5px; padding: 4px 6px; min-width: 34px; }
.file-icon.xl { font-size: 15px; padding: 14px 18px; }
.lib-toolbar { display: flex; flex-direction: column; gap: 10px; margin-bottom: 6px; }
.lib-toolbar .search-box { max-width: 380px; }
.lib-tags { margin-top: 2px; }
.preview-box { text-align: center; padding: 8px 0; }
.preview-box .detail-grid { text-align: left; margin-top: 14px; }
.export-grid { display: flex; gap: 8px; flex-wrap: wrap; }

/* ============ MISC MODULES ============ */
.approval-row { display: flex; align-items: center; gap: 13px; padding: 14px; border-bottom: 1px solid var(--hairline); flex-wrap: wrap; }
.approval-row:last-child { border-bottom: none; }
.cal-day { display: flex; gap: 16px; margin-bottom: 14px; }
.cal-day.today .cal-date b { color: var(--gold-deep); }
.cal-date { width: 84px; flex-shrink: 0; text-align: right; padding-top: 10px; }
.cal-date b { display: block; font-family: var(--font-display); font-size: 16px; }
.cal-date span { color: var(--muted); font-size: 12px; display: block; }
.cal-events { flex: 1; border-left: 1px solid var(--hairline-strong); padding-left: 16px; display: flex; flex-direction: column; gap: 6px; }
.cal-event { display: flex; gap: 11px; align-items: center; background: var(--surface); border: 1px solid var(--hairline); border-radius: var(--r-sm); padding: 9px 12px; box-shadow: var(--shadow-sm); }
.cal-event:hover { border-color: var(--faint); }
.dir-dept { font-size: 15px; color: var(--gold-deep); margin: 22px 0 10px; }
.dir-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.dir-card { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; margin-bottom: 0; }
.dir-info b { display: block; }
.dir-info .muted { display: block; font-size: 12px; margin: 1px 0 5px; }
.dir-contact { font-size: 11.5px; line-height: 1.5; }
.online-grid { display: flex; flex-wrap: wrap; gap: 7px; }
.online-chip { display: inline-flex; align-items: center; gap: 7px; background: var(--surface); border: 1px solid var(--hairline); border-radius: 999px; padding: 4px 12px 4px 5px; font-size: 12px; }
.live-dot { display: inline-block; width: 9px; height: 9px; background: var(--good); border-radius: 50%; margin-right: 5px; animation: pulse 1.8s infinite; }
@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(26, 127, 75, 0.4); } 50% { box-shadow: 0 0 0 6px rgba(26, 127, 75, 0); } }
.review-score { font-family: var(--font-display); font-size: 19px; }
.proj-burn { font-size: 12px; white-space: nowrap; }
.diff { font-size: 10.5px; margin-top: 3px; opacity: 0.85; word-break: break-all; }
.empty-block { text-align: center; padding: 44px 18px; color: var(--muted); }
.empty-icon { font-size: 26px; margin-bottom: 8px; opacity: 0.5; }

/* ============ RESPONSIVE ============ */
@media (max-width: 1080px) { .grid-2 { grid-template-columns: 1fr; } }
@media (max-width: 820px) {
  .sidebar { position: fixed; inset: 0 auto 0 0; z-index: 90; transform: translateX(-100%); transition: transform 0.2s ease; width: 260px; box-shadow: var(--shadow-lg); }
  .sidebar.open { transform: translateX(0); }
  .burger { display: block; }
  .content { padding: 18px 16px 50px; }
  .topbar { padding: 10px 14px; }
  .kpi-grid { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
  .form-grid { grid-template-columns: 1fr; }
  .form-field.span2 { grid-column: span 1; }
  .cal-date { width: 60px; }
}
