/* ============================================================================
   IMS — Modern Admin Panel
   IBM Plex Sans (body) · IBM Plex Mono (numbers/IDs)
   Warm off-white canvas (#FAF8F4) · near-black text · ochre accent
   Dense grid · hairline dividers · small-caps labels · tabular numerals
   No rounded-corner left-accent cards · No gradients · No emoji
   ============================================================================ */

:root {
  /* surfaces */
  --bg:        #F1EDE6;
  --bg-2:      #E9E4DB;
  --bg-3:      #DDD7CC;
  --paper:     #FAF8F4;
  --paper-2:   #F4F0E9;
  --paper-3:   #EDE8DF;

  /* ink */
  --ink:       #1A1816;
  --ink-2:     #3D3832;
  --ink-3:     #6E665B;
  --ink-4:     #958C7F;

  /* lines */
  --line:      #E2DDD4;
  --line-2:    #D4CEC3;

  /* accent — muted amber/ochre */
  --accent:    #C06A2C;
  --accent-2:  #9A5220;
  --accent-ink:#FAF8F4;
  --accent-bg: #F6EBE0;
  --accent-dim:#EDCFB5;

  /* status — low chroma */
  --ok:        #4D7C3A;
  --ok-bg:     #E4EFD9;
  --ok-dark:   #2F4D23;

  --warn:      #B08518;
  --warn-bg:   #F5EACC;
  --warn-dark: #6B5010;

  --alert:     #B33D2A;
  --alert-2:   #8A2E1F;
  --alert-bg:  #F5DDD7;
  --alert-dark:#5C1F15;

  --info:      #2C6E8C;
  --info-bg:   #D9ECF4;
  --info-dark: #1A4255;

  /* shadows */
  --shadow-sm: 0 1px 2px rgba(26,24,22,0.06);
  --shadow-md: 0 2px 8px rgba(26,24,22,0.08);
  --shadow-lg: 0 8px 24px rgba(26,24,22,0.12);
  --shadow-xl: 0 16px 48px rgba(26,24,22,0.16);

  /* radii — tight */
  --r-xs: 2px;
  --r-sm: 3px;
  --r: 4px;
  --r-md: 6px;
  --r-lg: 8px;

  /* type */
  --font: 'IBM Plex Sans', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  --mono: 'IBM Plex Mono', 'SF Mono', Menlo, Consolas, monospace;

  /* legacy aliases used in JSX inline styles */
  --font-sans: var(--font);
  --font-mono: var(--mono);
  --font-display: var(--font);
  --radius: var(--r);
  --radius-sm: var(--r-xs);
  --radius-md: var(--r-md);
  --radius-lg: var(--r-lg);
  --radius-xl: var(--r-lg);
}

/* ============================================================================
   Reset & Base
   ============================================================================ */

*, *::before, *::after { box-sizing: border-box; }
html, body, #root { height: 100%; margin: 0; }

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 13.5px;
  line-height: 1.5;
  font-feature-settings: "tnum";
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow: hidden;
}

button { font: inherit; color: inherit; cursor: pointer; border: none; background: none; padding: 0; }
input, textarea, select { font: inherit; color: inherit; }
a { color: inherit; text-decoration: none; }

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(110,102,91,0.22); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: rgba(110,102,91,0.38); }

::selection { background: var(--accent-dim); color: var(--accent-2); }

/* ============================================================================
   Shell
   ============================================================================ */

.app {
  display: grid;
  grid-template-columns: 252px 1fr;
  height: 100vh;
  background: var(--bg);
}

/* ============================================================================
   Sidebar
   ============================================================================ */

.sidebar {
  background: var(--paper);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  min-height: 0;
  z-index: 2;
}

.brand {
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 10px;
}
.brand .mark {
  width: 30px; height: 30px;
  background: var(--accent);
  color: var(--accent-ink);
  border-radius: var(--r);
  display: grid; place-items: center;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: -0.03em;
}
.brand .wordmark {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--ink);
}
.brand .wordmark .ital { font-style: normal; color: var(--accent); }
.brand .env {
  margin-left: auto;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.04em;
  color: var(--ink-3);
  background: var(--bg);
  border: 1px solid var(--line);
  padding: 2px 6px;
  border-radius: 99px;
  font-weight: 500;
}

.nav {
  flex: 1;
  overflow-y: auto;
  padding: 10px 0 16px;
}
.nav-section { padding: 10px 10px 2px; }
.nav-section + .nav-section { padding-top: 14px; }
.nav-section .label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-4);
  padding: 0 8px 6px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  white-space: nowrap;
  overflow: hidden;
}
.nav-section .label > span:first-child { overflow: hidden; text-overflow: ellipsis; }
.nav-section .label .hint { font-size: 9px; color: var(--ink-4); font-weight: 500; }
.nav-section .label .hint.tag {
  background: var(--bg);
  border: 1px solid var(--line);
  padding: 1px 5px;
  border-radius: 99px;
  color: var(--ink-3);
}

.nav-list { display: flex; flex-direction: column; gap: 1px; }
.nav-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 10px;
  border-radius: var(--r);
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-2);
  cursor: pointer;
  transition: background 0.1s, color 0.1s;
  white-space: nowrap;
  overflow: hidden;
  gap: 6px;
}
.nav-item:hover { background: var(--bg); color: var(--ink); }
.nav-item.active {
  background: var(--accent-bg);
  color: var(--accent-2);
  font-weight: 600;
}
.nav-item.top-level { padding-left: 10px; }

.nav-count {
  font-size: 11px;
  font-weight: 600;
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  color: var(--ink-3);
  background: var(--bg);
  border: 1px solid var(--line);
  padding: 0 6px;
  border-radius: 99px;
  min-width: 20px;
  text-align: center;
  line-height: 1.6;
}
.nav-item.active .nav-count { background: var(--paper); color: var(--accent-2); border-color: var(--accent-dim); }
.nav-count.hot { background: var(--alert-bg); color: var(--alert-2); border-color: transparent; }

.sidebar-foot {
  border-top: 1px solid var(--line);
  padding: 12px 18px;
  font-size: 11.5px;
  color: var(--ink-3);
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.sidebar-foot .row { display: flex; justify-content: space-between; gap: 8px; white-space: nowrap; }
.sidebar-foot .status { color: var(--ok); font-weight: 600; }

/* ============================================================================
   Masthead
   ============================================================================ */

.masthead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  height: 52px;
  background: var(--paper);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 20;
  flex-shrink: 0;
}
.masthead-left { display: flex; align-items: center; gap: 14px; }
.masthead .crumbs {
  font-size: 12.5px;
  color: var(--ink-3);
  display: flex;
  align-items: center;
  font-weight: 500;
}
.masthead .crumbs .sep { margin: 0 6px; color: var(--ink-4); }
.masthead .crumbs .cur { color: var(--ink); font-weight: 600; }
.masthead-right { display: flex; align-items: center; gap: 10px; }

.live-pulse {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border: 1px solid var(--line);
  border-radius: 99px;
  background: var(--paper);
  font-size: 11px;
  font-weight: 500;
  color: var(--ink-3);
  white-space: nowrap;
  flex-shrink: 0;
}
.live-pulse .dot {
  width: 6px; height: 6px; border-radius: 99px;
  background: var(--ok);
  animation: pulse 2s infinite;
}
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(77,124,58,0.35); }
  70% { box-shadow: 0 0 0 5px rgba(77,124,58,0); }
  100% { box-shadow: 0 0 0 0 rgba(77,124,58,0); }
}

.user-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 3px 10px 3px 3px;
  border-radius: 99px;
  background: var(--bg);
  border: 1px solid var(--line);
  color: var(--ink);
  cursor: pointer;
  transition: background 0.1s;
}
.user-chip:hover { background: var(--bg-2); }
.user-chip .initials {
  width: 26px; height: 26px;
  background: var(--accent);
  color: var(--accent-ink);
  border-radius: 99px;
  display: grid; place-items: center;
  font-size: 10px;
  font-weight: 600;
}
.user-chip .who-block { display: flex; flex-direction: column; min-width: 0; }
.user-chip .who { font-size: 12px; font-weight: 600; line-height: 1.15; white-space: nowrap; }
.user-chip .role { font-size: 10px; color: var(--ink-3); line-height: 1.1; font-weight: 500; white-space: nowrap; }

/* ============================================================================
   Main / Page
   ============================================================================ */

.main { display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.main-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 24px 28px 72px;
}

.page-head {
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
}
.page-head h1 {
  margin: 0 0 4px;
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.2;
  color: var(--ink);
}
.page-head h1 .ital { color: var(--accent); font-style: italic; font-weight: 600; }

.page-head .sub,
.page-head .subtitle,
.subtitle {
  font-size: 13px;
  color: var(--ink-3);
  max-width: 520px;
  line-height: 1.5;
}
.page-head .meta {
  font-size: 11px;
  color: var(--ink-3);
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
  font-family: var(--mono);
}
.page-head .meta .sep { color: var(--ink-4); }
.page-head .actions { display: flex; gap: 6px; align-items: center; }

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 6px;
}
.eyebrow::before {
  content: "";
  display: inline-block;
  width: 14px;
  height: 1px;
  background: currentColor;
  opacity: 0.5;
}

/* ============================================================================
   Buttons
   ============================================================================ */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 12px;
  border-radius: var(--r);
  border: 1px solid var(--line-2);
  background: var(--paper);
  color: var(--ink);
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.1s;
  white-space: nowrap;
}
.btn:hover { background: var(--bg); border-color: var(--ink-4); }
.btn.primary, .btn.accent {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: var(--accent);
}
.btn.primary:hover, .btn.accent:hover { background: var(--accent-2); border-color: var(--accent-2); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--bg); border-color: transparent; }
.btn.sm { padding: 4px 8px; font-size: 11.5px; }
.btn.lg { padding: 8px 14px; font-size: 13.5px; }
.btn.danger { color: var(--alert); }
.btn.danger:hover { background: var(--alert-bg); border-color: var(--alert); color: var(--alert-2); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; pointer-events: none; }

/* ============================================================================
   Search & Toolbar
   ============================================================================ */

.search {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--paper);
  border: 1px solid var(--line);
  padding: 6px 10px;
  border-radius: var(--r);
  min-width: 200px;
  transition: border-color 0.1s;
}
.search:focus-within { border-color: var(--accent); }
.search input { width: 100%; border: 0; background: transparent; outline: 0; font-size: 12.5px; color: var(--ink); }
.search input::placeholder { color: var(--ink-4); }
.search-clear {
  display: flex; align-items: center; justify-content: center;
  background: none; border: none; cursor: pointer;
  color: var(--ink-3); padding: 0 2px; flex-shrink: 0;
  border-radius: 2px; line-height: 1;
}
.search-clear:hover { color: var(--ink); }

.searchbar { /* alias */
  display: flex; align-items: center; gap: 6px;
  background: var(--paper); border: 1px solid var(--line);
  padding: 6px 10px; border-radius: var(--r); min-width: 200px;
}
.searchbar:focus-within { border-color: var(--accent); }
.searchbar input { width: 100%; border: 0; background: transparent; outline: 0; font-size: 12.5px; }
.searchbar input::placeholder { color: var(--ink-4); }
.searchbar .icon { color: var(--ink-4); display: grid; place-items: center; }

.toolbar {
  display: flex; align-items: center; gap: 8px;
  padding: 12px 0;
  flex-wrap: wrap;
}
.toolbar .spacer { flex: 1; }

/* ============================================================================
   Tables
   ============================================================================ */

.table-wrap {
  border: 1px solid var(--line);
  background: var(--paper);
  border-radius: var(--r-lg);
  overflow: auto;
  max-height: min(calc(100vh - 360px), 640px);
  min-height: 200px;
}
table.ims {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
table.ims th {
  text-align: left;
  padding: 8px 12px;
  border-bottom: 1px solid var(--line);
  font-weight: 600;
  font-family: var(--mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-4);
  background: var(--paper-2);
  white-space: nowrap;
  position: sticky;
  top: 0;
  z-index: 2;
}
table.ims th.sortable { cursor: pointer; user-select: none; }
table.ims th.sortable:hover { color: var(--ink-2); }
table.ims th .arrow { font-size: 9px; opacity: 0.4; margin-left: 3px; }
table.ims th.sorted .arrow { opacity: 1; color: var(--accent); }
table.ims th.filtered { color: var(--accent); background: var(--accent-bg); }

table.ims td {
  padding: 10px 12px;
  height: 48px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
  color: var(--ink);
  font-size: 13px;
}
table.ims tr:last-child td { border-bottom: 0; }
table.ims tbody tr { transition: background 0.08s; }
table.ims tbody tr:hover { background: var(--paper-2); }
table.ims tbody tr.clickable { cursor: pointer; }
table.ims tbody tr.selected { background: var(--accent-bg); }
table.ims tbody tr.selected:hover { background: var(--accent-dim); }

table.ims .num, td.mono {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-size: 12px;
}

.checkbox-cell { width: 32px; padding-left: 12px; padding-right: 0; }

/* ============================================================================
   Chips & Badges
   ============================================================================ */

.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 1px 7px;
  font-size: 11px;
  font-weight: 600;
  border-radius: 99px;
  background: var(--bg);
  color: var(--ink-2);
  border: 1px solid var(--line);
  white-space: nowrap;
}
.chip.outline { background: transparent; }
.chip.xs { padding: 0 5px; font-size: 10px; }
.chip.dark { background: var(--ink); color: var(--paper); border-color: transparent; }
.chip.ok    { background: var(--ok-bg);    color: var(--ok-dark);    border-color: transparent; }
.chip.warn  { background: var(--warn-bg);  color: var(--warn-dark);  border-color: transparent; }
.chip.alert { background: var(--alert-bg); color: var(--alert-2);    border-color: transparent; }
.chip.info  { background: var(--info-bg);  color: var(--info-dark);  border-color: transparent; }
.chip.accent{ background: var(--accent-bg);color: var(--accent-2);   border-color: transparent; }

.filter-chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 8px;
  border-radius: var(--r);
  border: 1px solid var(--line);
  background: var(--paper);
  font-size: 12px;
  font-weight: 500;
  color: var(--ink-2);
  cursor: pointer;
  transition: all 0.08s;
}
.filter-chip:hover { border-color: var(--ink-4); }
.filter-chip.active { background: var(--accent-bg); color: var(--accent-2); border-color: var(--accent-dim); }
.filter-chip .x {
  display: inline-grid; place-items: center;
  width: 13px; height: 13px; border-radius: 99px;
  background: var(--accent); color: var(--paper); font-size: 8px;
}

.pill {
  display: inline-flex; align-items: center; gap: 3px;
  padding: 1px 6px;
  border-radius: 99px;
  background: var(--bg);
  border: 1px solid var(--line);
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--ink-2);
  font-weight: 500;
  white-space: nowrap;
}

.section-label {
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-4);
  margin-bottom: 6px;
}

/* ============================================================================
   KPI
   ============================================================================ */

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}
.kpi-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-bottom: 16px;
}
.kpi, .kpi-row > .kpi {
  padding: 14px 16px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
}
.kpi.featured, .kpi-row > .kpi.featured {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: var(--accent);
}
.kpi .label, .kpi-row > .kpi .label,
.kpi-label {
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-4);
  margin-bottom: 6px;
}
.kpi.featured .label, .kpi-row > .kpi.featured .label,
.kpi.featured .kpi-label { color: rgba(255,255,255,0.75); }

.kpi .value, .kpi-row > .kpi .value,
.kpi-value {
  font-family: var(--font);
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}
.kpi .delta, .kpi-row > .kpi .delta,
.kpi-trend {
  margin-top: 4px;
  font-size: 11px;
  color: var(--ink-3);
  font-weight: 500;
}
.kpi.featured .delta, .kpi-row > .kpi.featured .delta { color: rgba(255,255,255,0.7); }
.kpi-trend.up { color: var(--ok); }
.kpi-trend.down { color: var(--alert); }

/* ============================================================================
   Influencer Cell
   ============================================================================ */

.inf-cell { display: flex; align-items: center; gap: 10px; min-width: 0; }
.inf-cell .avatar {
  width: 30px; height: 30px;
  border-radius: 99px;
  background: var(--accent-bg);
  color: var(--accent-2);
  display: grid; place-items: center;
  font-size: 11px;
  font-weight: 600;
  flex-shrink: 0;
}
.inf-cell .name-block { min-width: 0; }
.inf-cell .name { font-weight: 600; color: var(--ink); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.inf-cell .handle { font-family: var(--mono); font-size: 11px; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.inf-cell .meta { font-size: 11px; color: var(--ink-3); margin-top: 1px; }

/* ============================================================================
   Modal — FIXED OVERLAY
   ============================================================================ */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(26,24,22,0.45);
  backdrop-filter: blur(3px);
  z-index: 50;
  display: grid;
  place-items: center;
  animation: fade-in 0.12s ease-out;
}
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

.scrim { /* legacy alias */
  position: fixed; inset: 0;
  background: rgba(26,24,22,0.45);
  backdrop-filter: blur(3px);
  z-index: 50;
  display: grid; place-items: center;
  animation: fade-in 0.12s ease-out;
}

.modal {
  background: var(--paper);
  color: var(--ink);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-xl);
  border-radius: var(--r-lg);
  width: min(580px, calc(100vw - 40px));
  max-height: calc(100vh - 60px);
  display: flex;
  flex-direction: column;
  animation: modal-up 0.15s ease-out;
}
@keyframes modal-up { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.modal.wide, .modal.lg { width: min(780px, calc(100vw - 40px)); }
.modal.xwide, .modal.xl { width: min(1020px, calc(100vw - 40px)); }

.modal-head {
  padding: 16px 20px 12px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}
.modal-head h2, .modal-head h3 { margin: 0; font-size: 16px; font-weight: 600; letter-spacing: -0.01em; line-height: 1.3; }
.modal-head .sub { font-size: 12px; color: var(--ink-3); margin-top: 2px; }
.modal-body { padding: 16px 20px; overflow-y: auto; flex: 1; }
.modal-foot {
  padding: 12px 20px;
  border-top: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  background: var(--paper-2);
  border-radius: 0 0 var(--r-lg) var(--r-lg);
}
.modal .close-x { color: var(--ink-3); font-size: 16px; padding: 2px; cursor: pointer; line-height: 1; }
.modal .close-x:hover { color: var(--ink); }

.step-dots {
  display: flex; align-items: center; gap: 6px;
  font-size: 11px; color: var(--ink-3);
  font-weight: 500;
}
.step-dots .dot { width: 5px; height: 5px; border-radius: 99px; background: var(--line-2); }
.step-dots .dot.active, .step-dots .dot.done { background: var(--accent); }

/* ============================================================================
   Forms
   ============================================================================ */

.form-row { display: flex; flex-direction: column; gap: 4px; margin-bottom: 14px; }
.form-row label { font-size: 12px; font-weight: 600; color: var(--ink); }
.form-row .hint { font-size: 11px; color: var(--ink-3); }

.input, textarea.input, select.input,
.textarea, textarea.textarea {
  width: 100%;
  padding: 7px 10px;
  border: 1px solid var(--line-2);
  background: var(--paper);
  color: var(--ink);
  border-radius: var(--r);
  font-size: 13px;
  font-family: var(--font);
  transition: border-color 0.1s;
}
.input:focus, textarea.input:focus, select.input:focus,
.textarea:focus, textarea.textarea:focus {
  outline: 0;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(192,106,44,0.12);
}
textarea.input, .textarea, textarea.textarea { min-height: 72px; resize: vertical; line-height: 1.5; }

.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; }
.field label { font-size: 12px; font-weight: 600; color: var(--ink); }
.field input, .field select, .field textarea {
  width: 100%; padding: 7px 10px; border: 1px solid var(--line-2);
  background: var(--paper); color: var(--ink); border-radius: var(--r);
  font-size: 13px;
}
.field select {
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%236E665B'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 28px;
  cursor: pointer;
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: 0; border-color: var(--accent); box-shadow: 0 0 0 2px rgba(192,106,44,0.12);
}

.checkbox { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; font-size: 13px; user-select: none; position: relative; }
.checkbox input { position: absolute; opacity: 0; pointer-events: none; }
.checkbox .box {
  width: 15px; height: 15px;
  border: 1.5px solid var(--line-2);
  border-radius: var(--r-xs);
  display: grid; place-items: center;
  background: var(--paper);
  transition: all 0.1s;
}
.checkbox input:checked ~ .box { background: var(--accent); border-color: var(--accent); }
.checkbox input:checked ~ .box::after {
  content: ""; width: 7px; height: 3.5px;
  border-left: 1.5px solid var(--paper);
  border-bottom: 1.5px solid var(--paper);
  transform: rotate(-45deg) translate(1px, -1px);
}

.radio {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border: 1px solid var(--line);
  border-radius: var(--r);
  cursor: pointer; background: var(--paper); transition: all 0.1s;
}
.radio:hover { border-color: var(--ink-4); }
.radio.checked { border-color: var(--accent); background: var(--accent-bg); }
.radio .dot {
  width: 14px; height: 14px; border-radius: 99px;
  border: 1.5px solid var(--line-2);
  display: grid; place-items: center; flex-shrink: 0;
}
.radio.checked .dot { border-color: var(--accent); }
.radio.checked .dot::after { content: ""; width: 7px; height: 7px; border-radius: 99px; background: var(--accent); }

/* ============================================================================
   Cards
   ============================================================================ */

.card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 16px;
}
.card h3 { margin: 0 0 6px; font-size: 14px; font-weight: 600; }
.card .sub { color: var(--ink-3); font-size: 12px; margin-bottom: 10px; }

.banner {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 12px 14px;
  background: var(--accent-bg);
  color: var(--ink);
  border: 1px solid var(--accent-dim);
  border-radius: var(--r-md);
  margin-bottom: 14px;
  font-size: 13px;
}
.banner .icon { flex-shrink: 0; }
.banner h4 { margin: 0 0 2px; font-size: 13px; font-weight: 600; }
.banner p { margin: 0; font-size: 12px; color: var(--ink-2); }
.banner.warn { background: var(--warn-bg); border-color: var(--warn); }
.banner.alert { background: var(--alert-bg); border-color: var(--alert); }
.banner.info { background: var(--info-bg); border-color: var(--info); }

/* ============================================================================
   Bulk Action Bar / Sticky Widget (Manual Selection)
   ============================================================================ */

.bulk-bar, .sticky-widget {
  position: sticky; top: 0; z-index: 15;
  background: var(--paper);
  color: var(--ink);
  padding: 10px 16px;
  border-radius: var(--r-md);
  border: 1px solid var(--accent);
  display: flex; align-items: center; gap: 14px;
  margin-bottom: 12px;
  box-shadow: var(--shadow-md);
  animation: slideDown 0.18s ease-out;
}
@keyframes slideDown { from { transform: translateY(-6px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

.bulk-bar .count, .sticky-widget .count { font-weight: 700; font-size: 14px; color: var(--accent); }
.bulk-bar .meta, .sticky-widget .hint { font-size: 12px; color: var(--ink-3); }
.bulk-bar .spacer, .sticky-widget .spacer { flex: 1; }
.bulk-bar .btn, .sticky-widget .btn { box-shadow: none; }
.bulk-bar .btn.primary, .sticky-widget .btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.bulk-bar .btn.primary:hover, .sticky-widget .btn.primary:hover { background: var(--accent-2); border-color: var(--accent-2); }

.sticky-widget .x {
  width: 28px; height: 28px; border-radius: var(--r);
  display: grid; place-items: center;
  background: var(--bg);
  border: 1px solid var(--line);
  color: var(--ink-3);
  transition: all 0.1s;
  cursor: pointer;
}
.sticky-widget .x:hover { background: var(--alert-bg); border-color: var(--alert); color: var(--alert); }

/* ============================================================================
   Profile
   ============================================================================ */

.profile-head {
  display: flex; align-items: flex-start; gap: 18px;
  padding: 0 0 18px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 0;
}
.profile-head .avatar-lg {
  width: 64px; height: 64px; border-radius: 99px;
  background: var(--accent-bg);
  color: var(--accent-2);
  display: grid; place-items: center;
  font-size: 22px; font-weight: 700; flex-shrink: 0;
}
.profile-head .info { flex: 1; min-width: 0; }
.profile-head h1, .profile-head h2 {
  margin: 0;
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.profile-head .handle-line {
  margin-top: 4px;
  font-size: 12px;
  color: var(--ink-3);
  display: flex; flex-wrap: wrap; gap: 8px; align-items: center;
}
.profile-head .handle-line .sep { color: var(--ink-4); }
.profile-head .handle {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--ink);
  background: var(--bg);
  border: 1px solid var(--line);
  padding: 1px 6px;
  border-radius: var(--r-xs);
}

/* Tabs */
.tabs {
  display: flex; align-items: center; gap: 0;
  border-bottom: 1px solid var(--line);
  margin: 0;
  position: sticky; top: 0; z-index: 10;
  background: var(--bg);
}
.tab {
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-3);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: all 0.1s;
}
.tab:hover { color: var(--ink); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }
.tab .count {
  font-size: 10.5px; color: var(--ink-3);
  background: var(--bg);
  border-radius: 99px; padding: 1px 6px;
  margin-left: 4px; font-weight: 600;
}
.tab.active .count { background: var(--accent-bg); color: var(--accent-2); }

/* Facts */
.facts {
  display: grid;
  grid-template-columns: 130px 1fr;
  padding: 9px 0;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
}
.facts:last-child { border-bottom: 0; }
.facts dt { color: var(--ink-3); font-weight: 500; }
.facts dd { margin: 0; color: var(--ink); font-weight: 500; }

/* KV list */
.kv-list { display: flex; flex-direction: column; }
.kv {
  display: flex; align-items: flex-start; justify-content: space-between;
  padding: 8px 0; border-bottom: 1px solid var(--line);
  font-size: 13px; gap: 10px;
}
.kv:last-child { border-bottom: 0; }
.kv .k { color: var(--ink-3); font-weight: 500; min-width: 110px; flex-shrink: 0; }
.kv .v { color: var(--ink); font-weight: 500; text-align: right; }

/* Shot placeholder */
.shot-placeholder {
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
  background: var(--paper-2);
  border: 1.5px dashed var(--line-2);
  border-radius: var(--r-md);
  color: var(--ink-3);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  min-height: 72px;
  transition: all 0.1s;
}
.shot-placeholder:hover { background: var(--bg); border-color: var(--accent); color: var(--accent); }

/* Stage rail & card */
.stage-rail {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-bottom: 14px;
}
.stage-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }

.stage-card {
  border: 1px solid var(--line);
  padding: 14px;
  background: var(--paper);
  border-radius: var(--r-md);
}
.stage-card .head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 8px;
  font-family: var(--mono);
  font-size: 10px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--ink-4);
}
.stage-card .num {
  font-family: var(--mono); font-size: 10px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--ink-4); margin-bottom: 3px;
}
.stage-card .name { font-size: 13px; font-weight: 600; color: var(--ink); margin-bottom: 3px; }
.stage-card .amt { font-family: var(--mono); font-size: 16px; font-weight: 600; margin-bottom: 8px; }
.stage-card .foot { margin-top: 8px; display: flex; justify-content: space-between; align-items: center; gap: 6px; }
.stage-card .body { font-size: 12px; color: var(--ink-2); }
.stage-card h4 { margin: 0 0 4px; font-size: 13px; font-weight: 600; }

.stage-card.complete { background: var(--ok-bg); color: var(--ok-dark); border-color: transparent; }
.stage-card.complete .head, .stage-card.complete .body, .stage-card.complete .num { color: var(--ok-dark); }
.stage-card.current, .stage-card.active { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-dim); }
.stage-card.locked { opacity: 0.5; }

.tick {
  width: 16px; height: 16px;
  border-radius: 99px;
  background: var(--ok);
  display: grid; place-items: center;
  flex-shrink: 0;
}
.tick::after {
  content: ""; width: 7px; height: 3.5px;
  border-left: 1.5px solid var(--paper);
  border-bottom: 1.5px solid var(--paper);
  transform: rotate(-45deg) translate(0, -1px);
}
.tick.warn { background: var(--warn); }
.tick.pending { background: var(--bg-3); }
.tick.pending::after { display: none; }

/* Activity */
.activity .row {
  display: grid; grid-template-columns: 100px 1fr;
  gap: 14px; padding: 10px 0; border-bottom: 1px solid var(--line);
  font-size: 13px;
}
.activity .row:last-child { border-bottom: 0; }
.activity .at { font-family: var(--mono); font-size: 11px; color: var(--ink-4); padding-top: 1px; }
.activity .what { color: var(--ink); font-weight: 500; }
.activity .by { color: var(--ink-3); font-size: 12px; margin-top: 1px; }

/* Activity row (legacy) */
.activity-row {
  display: grid; grid-template-columns: 100px 1fr; gap: 14px;
  padding: 10px 0; border-bottom: 1px solid var(--line);
}
.activity-row .when { font-family: var(--mono); font-size: 11px; color: var(--ink-4); }
.activity-row .what { font-size: 13px; color: var(--ink); }
.activity-row .what .by { color: var(--ink-3); }

/* Threads */
.thread { display: flex; flex-direction: column; gap: 8px; }
.thread-msg {
  padding: 10px 14px;
  border: 1px solid var(--line);
  background: var(--paper);
  border-radius: var(--r-md);
  margin-bottom: 6px;
  font-size: 13px; line-height: 1.5; color: var(--ink-2);
}
.thread-msg.admin { background: var(--accent-bg); border-color: var(--accent-dim); }
.thread-msg .who-row, .thread-msg .head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 4px; font-size: 12px;
}
.thread-msg .who { font-weight: 600; color: var(--ink); }
.thread-msg.admin .who, .thread-msg.admin .head .who { color: var(--accent-2); }
.thread-msg .when, .thread-msg .head .when { color: var(--ink-4); font-family: var(--mono); font-size: 10.5px; }
.thread-msg .body { font-size: 13px; line-height: 1.5; color: var(--ink-2); }

/* ============================================================================
   Announce chip
   ============================================================================ */

.announce {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px; margin-bottom: 12px;
  background: var(--warn-bg); border: 1px solid var(--warn);
  border-radius: var(--r-md); font-size: 12.5px; color: var(--ink);
}
.announce .dot {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 1px 6px; border-radius: 99px;
  background: var(--warn); color: var(--paper);
  font-size: 9.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em;
}

/* ============================================================================
   Stage bar (inline)
   ============================================================================ */

.stage-bar { display: flex; gap: 3px; align-items: center; }
.stage-bar-dot {
  width: 18px; height: 4px; border-radius: 2px;
  background: var(--bg-3);
}
.stage-bar-dot.done { background: var(--accent); }
.stage-bar-dot.active { background: var(--accent); box-shadow: 0 0 0 1.5px var(--accent-dim); }

/* ============================================================================
   Tweaks
   ============================================================================ */

.tweaks-panel {
  position: fixed;
  top: 56px; right: 12px;
  bottom: 12px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 14px;
  width: 264px;
  z-index: 100;
  box-shadow: var(--shadow-lg);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}
.tweaks-panel h3 {
  margin: 0 0 10px;
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-3);
}

.role-opts { display: flex; flex-direction: column; gap: 5px; }
.role-opt {
  display: flex; align-items: center;
  padding: 8px 10px;
  border-radius: var(--r);
  border: 1px solid var(--line);
  cursor: pointer;
  font-size: 12.5px;
  font-weight: 500;
  transition: all 0.1s;
}
.role-opt:hover { border-color: var(--ink-4); }
.role-opt.active {
  background: var(--accent-bg);
  border-color: var(--accent);
  color: var(--accent-2);
  font-weight: 600;
}
.role-opt .short { font-size: 10.5px; color: var(--ink-3); margin-top: 1px; font-weight: 500; }

/* ============================================================================
   Layouts
   ============================================================================ */

.two-col { display: grid; grid-template-columns: 1fr 340px; gap: 20px; align-items: start; }
.three-col { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }

.section-head {
  display: flex; align-items: baseline; justify-content: space-between;
  margin: 18px 0 10px;
}
.section-head h2 { margin: 0; font-size: 16px; font-weight: 600; letter-spacing: -0.01em; }
.section-head .sub { font-size: 12px; color: var(--ink-3); }

/* ============================================================================
   Tooltip
   ============================================================================ */

.tip { position: relative; }
.tip[data-tip]:hover::after {
  content: attr(data-tip);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--ink);
  color: var(--paper);
  font-size: 11px;
  padding: 4px 8px;
  border-radius: var(--r);
  white-space: nowrap;
  z-index: 100;
  font-weight: 500;
}

/* ============================================================================
   Misc utilities
   ============================================================================ */

.text-mute { color: var(--ink-3); }
.text-xs { font-size: 10.5px; }
.text-small { font-size: 12px; }
.text-mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.nowrap { white-space: nowrap; }
.hr { height: 1px; background: var(--line); border: none; margin: 14px 0; }

/* Missing utilities */
.card.tinted { background: var(--paper-2); }

.input.big {
  font-size: 36px;
  font-weight: 700;
  padding: 14px 16px;
  font-family: var(--mono);
  letter-spacing: -0.02em;
}

.stack-sm > * + * { margin-top: 6px; }
.stack-md > * + * { margin-top: 12px; }
.stack-lg > * + * { margin-top: 18px; }

.notes-cell {
  max-width: 240px;
  color: var(--ink-2);
  font-size: 12px;
  position: relative;
}
.notes-cell .note-preview {
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
  font-style: italic;
  color: var(--ink-3);
}
.notes-cell:hover .note-tooltip, .note-has-content:hover .note-tooltip { display: block; }
.note-tooltip {
  display: none;
  position: absolute;
  top: 100%;
  left: 8px;
  z-index: 30;
  background: var(--ink);
  color: var(--paper);
  padding: 10px 12px;
  border-radius: var(--r-md);
  max-width: 300px;
  font-size: 12px;
  box-shadow: var(--shadow-lg);
  white-space: normal;
  margin-top: 4px;
  font-style: normal;
  line-height: 1.5;
}

.warn-tri { color: var(--warn); font-size: 11px; display: inline-flex; align-items: center; }

/* Notes-cell add note button */
.notes-cell .btn { font-size: 11px; }

/* Table row selected highlight */
table.ims tbody tr.selected td { background: var(--accent-bg); }

/* Page wrapper — needed by JSX */
.page { max-width: 1280px; }

.empty {
  padding: 48px 20px;
  text-align: center;
  color: var(--ink-3);
}
.empty .icon { font-size: 28px; margin-bottom: 10px; opacity: 0.4; }
.empty h4 { margin: 0 0 4px; font-size: 15px; color: var(--ink); font-weight: 600; }
.empty p { margin: 0; font-size: 12px; }

.toast-wrap, .toast-stack {
  position: fixed;
  bottom: 20px; left: 50%;
  transform: translateX(-50%);
  z-index: 200;
}
.toast {
  background: var(--ink);
  color: var(--paper);
  padding: 10px 16px;
  border-radius: var(--r-md);
  font-size: 13px;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  display: flex; align-items: center; gap: 8px;
  animation: modal-up 0.15s ease-out;
}
.toast.ok::before { content: "✓"; color: var(--ok); font-weight: 700; }
.toast.err::before { content: "✕"; color: var(--alert); font-weight: 700; }

/* Link/external button */
.link-btn {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 8px;
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--ink-2);
  font-size: 11px;
  font-weight: 500;
  border-radius: var(--r);
  cursor: pointer;
  transition: all 0.08s;
}
.link-btn:hover { color: var(--accent); border-color: var(--accent-dim); background: var(--accent-bg); }

/* Avatar group */
.avatar-group { display: inline-flex; }
.avatar-group .avatar {
  width: 24px; height: 24px;
  border-radius: 99px;
  background: var(--accent-bg);
  color: var(--accent-2);
  display: grid; place-items: center;
  font-size: 9px; font-weight: 700;
  border: 2px solid var(--paper);
  margin-left: -6px;
}
.avatar-group .avatar:first-child { margin-left: 0; }
.avatar-group .more { background: var(--bg); color: var(--ink-3); }

.kbd {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--ink-3);
  border: 1px solid var(--line);
  padding: 1px 4px;
  border-radius: var(--r-xs);
  background: var(--bg);
}
