/* dd99 Portal — Design Tokens & Shared Styles */

:root {
  /* Primary — deep teal */
  --primary:        oklch(48% 0.09 200);
  --primary-600:    oklch(42% 0.10 200);
  --primary-700:    oklch(36% 0.10 200);
  --primary-50:     oklch(96% 0.02 200);
  --primary-100:    oklch(92% 0.03 200);

  /* Ink (neutrals) */
  --ink-900:        oklch(22% 0.01 230);
  --ink-800:        oklch(30% 0.01 230);
  --ink-700:        oklch(40% 0.01 230);
  --ink-600:        oklch(50% 0.008 230);
  --ink-500:        oklch(60% 0.006 230);
  --ink-400:        oklch(72% 0.005 230);
  --ink-300:        oklch(86% 0.004 230);
  --ink-200:        oklch(93% 0.004 230);
  --ink-100:        oklch(97% 0.003 230);
  --ink-50:         oklch(99% 0.002 230);

  --paper:          oklch(98.5% 0.003 230);
  --surface:        #ffffff;

  /* Semantic */
  --success:        oklch(55% 0.13 155);
  --success-50:     oklch(96% 0.04 155);
  --warn:           oklch(72% 0.16 75);
  --warn-50:        oklch(97% 0.05 80);
  --danger:         oklch(58% 0.20 25);
  --danger-50:      oklch(96% 0.04 25);
  --info:           oklch(55% 0.14 250);
  --info-50:        oklch(96% 0.03 250);
  --purple:         oklch(55% 0.16 300);
  --purple-50:      oklch(96% 0.04 300);

  --radius-sm: 6px;
  --radius:    8px;
  --radius-lg: 12px;
  --radius-xl: 16px;

  --shadow-xs: 0 1px 2px rgba(15, 30, 40, 0.05);
  --shadow-sm: 0 1px 3px rgba(15, 30, 40, 0.06), 0 1px 2px rgba(15, 30, 40, 0.04);
  --shadow:    0 4px 12px rgba(15, 30, 40, 0.08), 0 1px 3px rgba(15, 30, 40, 0.05);
  --shadow-lg: 0 12px 32px rgba(15, 30, 40, 0.12), 0 4px 8px rgba(15, 30, 40, 0.06);

  --sidebar-w: 244px;
  --sidebar-w-collapsed: 64px;
  --topbar-h: 56px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  font-family: 'Inter', system-ui, -apple-system, "Segoe UI", Helvetica, Arial, sans-serif;
  font-size: 14px;
  color: var(--ink-900);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

code, .mono { font-family: 'JetBrains Mono', ui-monospace, "SF Mono", Consolas, monospace; }

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-700); text-decoration: underline; }

/* ====== Bootstrap overrides ====== */
.btn { font-weight: 500; border-radius: var(--radius); padding: .45rem .85rem; }
.btn-sm { padding: .3rem .65rem; font-size: 12.5px; }
.btn-xs { padding: .25rem .55rem; font-size: 11.5px; border-radius: calc(var(--radius) - 2px); }
.btn .ic { display: inline-flex; align-items: center; }
.btn .ic svg { width: 14px; height: 14px; }
.btn-xs .ic svg { width: 13px; height: 13px; }
.btn-primary {
  background: var(--primary); border-color: var(--primary); color: #fff;
}
.btn-primary:hover, .btn-primary:focus {
  background: var(--primary-700); border-color: var(--primary-700);
}
.btn-outline-primary { color: var(--primary); border-color: var(--ink-300); }
.btn-outline-primary:hover { background: var(--primary-50); border-color: var(--primary); color: var(--primary-700); }
.btn-light { background: var(--surface); border-color: var(--ink-300); color: var(--ink-800); }
.btn-light:hover { background: var(--ink-100); border-color: var(--ink-400); }
.btn-ghost { background: transparent; border: 1px solid transparent; color: var(--ink-700); }
.btn-ghost:hover { background: var(--ink-100); color: var(--ink-900); }
.btn-danger { background: var(--danger); border-color: var(--danger); }
.btn-danger:hover { background: oklch(50% 0.20 25); border-color: oklch(50% 0.20 25); }

.form-control, .form-select {
  border-radius: var(--radius);
  border: 1px solid var(--ink-300);
  font-size: 13.5px;
  padding: .5rem .7rem;
  background: var(--surface);
  color: var(--ink-900);
}
.form-control:focus, .form-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px color-mix(in oklch, var(--primary) 18%, transparent);
}
.form-control::placeholder { color: var(--ink-500); }
.form-label { font-size: 12.5px; font-weight: 500; color: var(--ink-700); margin-bottom: 4px; }
.form-text { font-size: 12px; color: var(--ink-500); }
.required::after { content: " *"; color: var(--danger); }

.card {
  border: 1px solid var(--ink-200);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-xs);
}
.card-header {
  background: var(--surface);
  border-bottom: 1px solid var(--ink-200);
  padding: 14px 18px;
}
.card-header h6 { margin: 0; font-weight: 600; color: var(--ink-900); }
.card-body { padding: 18px; }

.nav-tabs {
  border-bottom: 1px solid var(--ink-200);
  gap: 0;
}
.nav-tabs .nav-link {
  border: none;
  color: var(--ink-600);
  font-weight: 500;
  padding: 12px 16px;
  margin-bottom: -1px;
  border-bottom: 2px solid transparent;
  border-radius: 0;
}
.nav-tabs .nav-link:hover { color: var(--ink-900); border-bottom-color: var(--ink-300); }
.nav-tabs .nav-link.active {
  color: var(--primary-700);
  background: transparent;
  border-bottom-color: var(--primary);
}

/* ====== Shell ====== */
.dd-shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  grid-template-rows: var(--topbar-h) 1fr;
  min-height: 100vh;
}
.dd-shell.collapsed { grid-template-columns: var(--sidebar-w-collapsed) 1fr; }

/* Sidebar */
.dd-sidebar {
  grid-row: 1 / span 2;
  background: var(--ink-900);
  color: var(--ink-200);
  padding: 0;
  border-right: 1px solid var(--ink-800);
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
  overflow-y: auto;
}
.dd-sidebar::-webkit-scrollbar { width: 6px; }
.dd-sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,.08); border-radius: 3px; }

.dd-brand {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 18px;
  border-bottom: 1px solid rgba(255,255,255,.06);
  min-height: var(--topbar-h);
}
.dd-brand-mark {
  width: 28px; height: 28px;
  display: grid; place-items: center;
  background: linear-gradient(135deg, var(--primary) 0%, oklch(58% 0.10 180) 100%);
  border-radius: 7px;
  color: #fff;
  font-weight: 700;
  font-size: 13px;
  letter-spacing: -.5px;
}
.dd-brand-text {
  font-weight: 700; font-size: 15px; color: #fff; letter-spacing: -.2px;
}
.collapsed .dd-brand-text { display: none; }
/* Collapsed: align the brand "D" with the centred nav-icon tile below it.
   Match .dd-nav's 8px side padding and centre the mark so its visual
   centre lines up with the icon centre at x = sidebar-w/2. */
.collapsed .dd-brand { padding: 14px 8px; justify-content: center; gap: 0; }
.collapsed .dd-brand-mark { width: 36px; height: 36px; font-size: 14px; border-radius: 8px; }

.dd-nav-section {
  padding: 14px 12px 6px;
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: rgba(255,255,255,.4);
  font-weight: 600;
}
.collapsed .dd-nav-section { font-size: 0; padding: 10px 0; }
.collapsed .dd-nav-section::before { content: ""; display: block; height: 1px; background: rgba(255,255,255,.08); margin: 0 12px; }

.dd-nav { list-style: none; padding: 0 8px; margin: 0; }
.dd-nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px;
  border-radius: 6px;
  color: rgba(255,255,255,.78);
  font-size: 13.5px;
  font-weight: 500;
  margin-bottom: 1px;
  white-space: nowrap;
  text-decoration: none;
}
.dd-nav a:hover { background: rgba(255,255,255,.06); color: #fff; }
.dd-nav a.active { background: var(--primary); color: #fff; }
.dd-nav a svg { width: 16px; height: 16px; flex-shrink: 0; opacity: .9; }
.dd-nav .badge { margin-left: auto; font-size: 10.5px; padding: 2px 6px; }

/* Square count badge for sidebar nav items — fixed square footprint that
   grows only enough to fit a 2-digit number (or "99+"). */
.dd-nav .dd-count-group { margin-left: auto; display: inline-flex; gap: 4px; }
.dd-nav .dd-count {
  margin-left: auto;
  min-width: 18px; height: 18px;
  padding: 0 4px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 10px; font-weight: 600; line-height: 1;
  border-radius: 4px;
  color: #fff;
}
.dd-nav .dd-count-group .dd-count { margin-left: 0; }
.dd-count--muted   { background: rgba(255,255,255,.16); }
.dd-count--success { background: var(--success, #16a34a); }
.dd-count--warn    { background: var(--warn); }
.dd-count--danger  { background: var(--danger); }

/* Collapsed sidebar: hide label spans + badges but KEEP the icon span (.ic). */
.collapsed .dd-nav a > span:not(.ic),
.collapsed .dd-nav .badge,
.collapsed .dd-nav .dd-count,
.collapsed .dd-nav .dd-count-group { display: none; }
.collapsed .dd-nav a { justify-content: center; padding: 10px; }

.dd-sidebar-foot {
  margin-top: auto;
  padding: 12px;
  border-top: 1px solid rgba(255,255,255,.06);
  font-size: 12px;
  color: rgba(255,255,255,.5);
}
.collapsed .dd-sidebar-foot .label { display: none; }

/* Topbar */
.dd-topbar {
  grid-column: 2;
  background: var(--surface);
  border-bottom: 1px solid var(--ink-200);
  padding: 0 24px;
  display: flex; align-items: center; gap: 16px;
  position: sticky; top: 0; z-index: 50;
}
.dd-topbar .search {
  flex: 1; max-width: 480px;
  position: relative;
}
.dd-topbar .search input {
  width: 100%;
  border: 1px solid var(--ink-200);
  background: var(--ink-100);
  border-radius: var(--radius);
  padding: 8px 12px 8px 36px;
  font-size: 13px;
}
.dd-topbar .search input:focus {
  background: #fff; border-color: var(--primary);
  box-shadow: 0 0 0 3px color-mix(in oklch, var(--primary) 15%, transparent);
  outline: none;
}
.dd-topbar .search svg {
  position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  width: 14px; height: 14px; color: var(--ink-500);
}
.dd-topbar .kbd {
  position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
  background: #fff; border: 1px solid var(--ink-300);
  border-radius: 4px; padding: 1px 5px; font-size: 11px; color: var(--ink-500);
  font-family: 'JetBrains Mono', monospace;
}

.dd-topbar-actions { display: flex; align-items: center; gap: 6px; margin-left: auto; }
.dd-icon-btn {
  width: 34px; height: 34px;
  display: grid; place-items: center;
  border: 1px solid transparent;
  background: transparent;
  border-radius: var(--radius);
  color: var(--ink-700);
  cursor: pointer;
  position: relative;
}
.dd-icon-btn:hover { background: var(--ink-100); color: var(--ink-900); }
.dd-icon-btn svg { width: 16px; height: 16px; }
.dd-icon-btn .dot {
  position: absolute; top: 6px; right: 7px;
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--danger);
  border: 1.5px solid #fff;
}

.dd-avatar {
  width: 30px; height: 30px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  display: grid; place-items: center;
  font-weight: 600; font-size: 11.5px;
  letter-spacing: 0;
}
.dd-avatar.lg { width: 40px; height: 40px; font-size: 14px; }
.dd-avatar.sm { width: 24px; height: 24px; font-size: 10px; }
.dd-avatar.gray { background: var(--ink-400); }
.dd-avatar.purple { background: var(--purple); }
.dd-avatar.warn { background: var(--warn); }
.dd-avatar.info { background: var(--info); }

/* Main */
.dd-main {
  grid-column: 2;
  padding: 24px 28px 48px;
  min-width: 0;
}

/* Page header */
.dd-page-head {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 16px; margin-bottom: 22px;
}
.dd-breadcrumb {
  font-size: 12px; color: var(--ink-500);
  margin-bottom: 6px;
  display: flex; gap: 6px; align-items: center;
}
.dd-breadcrumb a { color: var(--ink-500); }
.dd-breadcrumb a:hover { color: var(--primary); text-decoration: none; }
.dd-breadcrumb .sep { color: var(--ink-400); }
.dd-page-title { font-size: 22px; font-weight: 700; color: var(--ink-900); margin: 0; letter-spacing: -.3px; }
.dd-page-sub { font-size: 13.5px; color: var(--ink-600); margin-top: 4px; }
.dd-page-actions { display: flex; gap: 8px; align-items: center; }
.dd-page-actions a { text-decoration: none; }

/* KPI Cards */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; }
.kpi {
  background: var(--surface);
  border: 1px solid var(--ink-200);
  border-radius: var(--radius-lg);
  padding: 16px 18px;
  box-shadow: var(--shadow-xs);
  position: relative;
}
.kpi-label {
  font-size: 12px; color: var(--ink-600);
  font-weight: 500; text-transform: uppercase; letter-spacing: .04em;
  margin-bottom: 8px;
  display: flex; align-items: center; gap: 6px;
}
.kpi-label .ic { color: var(--ink-500); }
.kpi-value { font-size: 24px; font-weight: 700; color: var(--ink-900); letter-spacing: -.4px; line-height: 1.1; }
.kpi-value .sub { font-size: 13px; color: var(--ink-500); font-weight: 500; margin-left: 6px; }
.kpi-meta { font-size: 12px; color: var(--ink-600); margin-top: 6px; }
.kpi-meta.up { color: var(--success); }
.kpi-meta.down { color: var(--danger); }

/* Badges & status */
.badge {
  font-weight: 500; font-size: 11.5px;
  padding: 3px 8px;
  border-radius: 999px;
  display: inline-flex; align-items: center; gap: 4px;
  letter-spacing: 0;
}
.badge.status::before {
  content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor;
}
.badge-active   { background: var(--success-50); color: var(--success); }
.badge-trial    { background: var(--info-50); color: var(--info); }
.badge-paused   { background: var(--ink-100); color: var(--ink-600); }
.badge-cancelled{ background: var(--ink-100); color: var(--ink-600); text-decoration: line-through; }
.badge-expired  { background: var(--danger-50); color: var(--danger); }
.badge-pending  { background: var(--warn-50); color: oklch(45% 0.13 75); }
.badge-free     { background: var(--success-50); color: var(--success); font-weight: 600; }
.badge-soft     { background: var(--ink-100); color: var(--ink-700); }
.badge-warn     { background: var(--warn-50); color: oklch(45% 0.13 75); }
.badge-danger   { background: var(--danger-50); color: var(--danger); }
.badge-info     { background: var(--info-50); color: var(--info); }
.badge-success  { background: var(--success-50); color: var(--success); }
.badge-purple   { background: var(--purple-50); color: var(--purple); }
.badge-outline  { background: transparent; border: 1px solid var(--ink-300); color: var(--ink-700); }

/* Tag chips with color */
.tag-chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 8px 2px 6px;
  border-radius: 999px;
  font-size: 11.5px; font-weight: 500;
  background: var(--ink-100); color: var(--ink-800);
}
.tag-chip .dot { width: 7px; height: 7px; border-radius: 50%; }

/* Tables */
.dd-table-wrap {
  background: var(--surface);
  border: 1px solid var(--ink-200);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-xs);
}
.dd-table { width: 100%; border-collapse: separate; border-spacing: 0; }
.dd-table thead th {
  background: var(--ink-50);
  color: var(--ink-600);
  font-size: 11.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
  padding: 10px 14px;
  text-align: left;
  border-bottom: 1px solid var(--ink-200);
  white-space: nowrap;
  position: sticky; top: 0; z-index: 5;
}
.dd-table thead th .sort {
  margin-left: 4px; opacity: .5; cursor: pointer;
}
.dd-table tbody td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--ink-100);
  font-size: 13.5px;
  vertical-align: middle;
  color: var(--ink-800);
}
.dd-table tbody tr:hover { background: var(--ink-50); cursor: pointer; }
.dd-table tbody tr:last-child td { border-bottom: 0; }
.dd-table.compact tbody td { padding: 8px 12px; font-size: 13px; }
.dd-table .actions-cell { text-align: right; white-space: nowrap; }

/* Service / row entity */
.entity-row { display: flex; align-items: center; gap: 10px; }
.service-logo {
  width: 28px; height: 28px;
  border-radius: 6px;
  background: var(--ink-100);
  display: grid; place-items: center;
  font-weight: 700; font-size: 11px;
  color: var(--ink-800);
  flex-shrink: 0;
  border: 1px solid var(--ink-200);
}
.service-logo.lg { width: 44px; height: 44px; font-size: 15px; border-radius: 9px; }
.service-logo.xl { width: 56px; height: 56px; font-size: 18px; border-radius: 12px; }
.service-logo.sky    { background: oklch(92% 0.06 230); color: oklch(40% 0.13 230); }
.service-logo.green  { background: oklch(94% 0.06 155); color: oklch(38% 0.14 155); }
.service-logo.purple { background: oklch(93% 0.07 300); color: oklch(40% 0.16 300); }
.service-logo.amber  { background: oklch(94% 0.07 75); color: oklch(40% 0.15 75); }
.service-logo.rose   { background: oklch(94% 0.06 20); color: oklch(45% 0.18 20); }
.service-logo.teal   { background: oklch(94% 0.05 195); color: oklch(38% 0.10 195); }
.service-logo.slate  { background: var(--ink-200); color: var(--ink-800); }

.entity-row .name { font-weight: 500; color: var(--ink-900); }
.entity-row .meta { font-size: 12px; color: var(--ink-500); margin-top: 1px; }

/* Budget bar */
.budget-cell { min-width: 140px; }
.budget-bar {
  height: 5px; background: var(--ink-200); border-radius: 999px; overflow: hidden;
  margin-top: 4px;
}
.budget-bar > i {
  display: block; height: 100%; border-radius: 999px;
  background: var(--success);
}
.budget-bar > i.warn { background: var(--warn); }
.budget-bar > i.danger { background: var(--danger); }
.budget-line { display: flex; justify-content: space-between; font-size: 12px; color: var(--ink-700); }
.budget-line .pct { font-weight: 600; }
.budget-line .pct.warn { color: oklch(45% 0.15 75); }
.budget-line .pct.danger { color: var(--danger); }

/* Currency display */
.currency-orig { color: var(--ink-900); font-weight: 500; }
.currency-inr { color: var(--ink-500); font-size: 12.5px; }
.currency-stack .orig { font-weight: 500; color: var(--ink-900); }
.currency-stack .inr { font-size: 12px; color: var(--ink-500); }

/* Filter bar */
.dd-filterbar {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  background: var(--surface);
  border: 1px solid var(--ink-200);
  border-radius: var(--radius-lg);
  padding: 10px 12px;
  margin-bottom: 14px;
  box-shadow: var(--shadow-xs);
}
.dd-filterbar .form-control, .dd-filterbar .form-select {
  padding: .35rem .6rem; font-size: 12.5px;
  width: auto; flex: 0 0 auto;
  min-width: 140px; max-width: 220px;
}
.dd-filterbar .search-mini {
  position: relative; flex: 1 1 200px; max-width: 280px;
}
.dd-filterbar .search-mini input { padding-left: 30px; width: 100%; max-width: none; }
.dd-filterbar .search-mini svg {
  position: absolute; left: 10px; top: 50%; transform: translateY(-50%);
  width: 12px; height: 12px; color: var(--ink-500);
}
/* Select2 inside the filterbar — match the other controls' inline sizing. */
.dd-filterbar .select2-container {
  width: auto !important; min-width: 160px;
}
.dd-filterbar .select2-container .select2-selection--single {
  height: calc(1.5em + .7rem + 2px);
  border: 1px solid var(--ink-300);
  border-radius: var(--radius-md);
  font-size: 12.5px;
}
.dd-filterbar .select2-container .select2-selection--single .select2-selection__rendered {
  line-height: calc(1.5em + .7rem); padding: 0 .6rem;
}
.dd-filterbar .select2-container .select2-selection--single .select2-selection__arrow {
  height: calc(1.5em + .7rem);
}
.filter-chip {
  background: var(--ink-100);
  border: 1px solid var(--ink-200);
  border-radius: 999px;
  padding: 4px 10px 4px 8px;
  font-size: 12px; color: var(--ink-700);
  display: inline-flex; gap: 6px; align-items: center;
  cursor: pointer;
}
.filter-chip.active { background: var(--primary-50); border-color: var(--primary); color: var(--primary-700); font-weight: 500; }
.filter-chip .x { color: var(--ink-500); cursor: pointer; }

/* Toggle (M/A) */
.dd-toggle {
  display: inline-flex; background: var(--ink-100); padding: 3px; border-radius: var(--radius); border: 1px solid var(--ink-200);
}
.dd-toggle button {
  border: 0; background: transparent;
  padding: 5px 12px; font-size: 12.5px; font-weight: 500;
  border-radius: 5px; color: var(--ink-600); cursor: pointer;
}
.dd-toggle button.active { background: #fff; color: var(--ink-900); box-shadow: var(--shadow-xs); }

/* Drawer */
.dd-drawer {
  position: fixed; right: 0; top: 0; height: 100vh;
  width: 480px; max-width: 90vw;
  background: #fff;
  box-shadow: -8px 0 30px rgba(15,30,40,.10);
  z-index: 1050;
  transform: translateX(100%);
  transition: transform .25s ease;
  display: flex; flex-direction: column;
}
.dd-drawer.open { transform: translateX(0); }
.dd-drawer-head {
  padding: 16px 20px;
  border-bottom: 1px solid var(--ink-200);
  display: flex; align-items: center; gap: 12px;
}
.dd-drawer-head h6 { margin: 0; font-weight: 600; }
.dd-drawer-body { flex: 1; overflow-y: auto; padding: 20px; }
.dd-drawer-foot { padding: 14px 20px; border-top: 1px solid var(--ink-200); display: flex; gap: 8px; justify-content: flex-end; }
.dd-backdrop {
  position: fixed; inset: 0; background: rgba(15,30,40,.35);
  opacity: 0; pointer-events: none; transition: opacity .2s;
  z-index: 1040;
}
.dd-backdrop.open { opacity: 1; pointer-events: auto; }

/* Notification dropdown */
.notif-dropdown {
  width: 380px;
  max-height: 480px;
  overflow-y: auto;
  padding: 0;
}
.notif-item { display: flex; gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--ink-100); }
.notif-item:hover { background: var(--ink-50); }
.notif-item .ic {
  flex-shrink: 0;
  width: 32px; height: 32px; border-radius: 8px;
  display: grid; place-items: center;
}
.notif-item .body { flex: 1; }
.notif-item .title { font-size: 13px; font-weight: 500; color: var(--ink-900); }
.notif-item .meta { font-size: 11.5px; color: var(--ink-500); margin-top: 2px; }
.notif-item.unread { background: var(--primary-50); }

/* Charts (light styling) */
.chart-card { padding: 16px 18px; }
.chart-svg { width: 100%; height: auto; display: block; }
.chart-bar { fill: var(--primary); transition: fill .15s; }
.chart-bar:hover { fill: var(--primary-700); }

/* Tree view */
.tree { font-size: 13.5px; }
.tree ul { list-style: none; padding-left: 22px; margin: 0; border-left: 1px dashed var(--ink-300); }
.tree > ul { padding-left: 0; border: 0; }
.tree li { padding: 3px 0; position: relative; }
.tree-node {
  display: flex; align-items: center; gap: 8px;
  padding: 5px 8px;
  border-radius: 6px;
  cursor: pointer;
}
.tree-node:hover { background: var(--ink-100); }
.tree-toggle {
  width: 16px; height: 16px;
  display: grid; place-items: center;
  color: var(--ink-500);
  cursor: pointer;
  transition: transform .15s;
}
.tree-toggle.open { transform: rotate(90deg); }
.tree-toggle.leaf { visibility: hidden; }
.tree-check {
  width: 16px; height: 16px;
  border: 1.5px solid var(--ink-300);
  border-radius: 4px;
  display: grid; place-items: center;
  flex-shrink: 0;
  background: #fff;
  cursor: pointer;
}
.tree-check.checked { background: var(--primary); border-color: var(--primary); }
.tree-check.checked::after { content: "✓"; color: #fff; font-size: 11px; font-weight: 700; line-height: 1; }
.tree-check.indeterminate { background: var(--primary); border-color: var(--primary); }
.tree-check.indeterminate::after { content: ""; width: 8px; height: 2px; background: #fff; border-radius: 2px; }
.tree-label { color: var(--ink-800); flex: 1; }
.tree-label .code { font-family: 'JetBrains Mono', monospace; font-size: 11.5px; color: var(--ink-500); margin-left: 6px; }
.tree li.hidden { display: none; }

/* Approval stepper */
.stepper { display: flex; flex-direction: column; gap: 0; }
.stepper-item {
  display: flex; gap: 14px; position: relative;
  padding-bottom: 18px;
}
.stepper-item::before {
  content: ""; position: absolute; left: 11px; top: 26px; bottom: 0;
  width: 2px; background: var(--ink-200);
}
.stepper-item:last-child::before { display: none; }
.stepper-icon {
  width: 24px; height: 24px; border-radius: 50%;
  display: grid; place-items: center;
  flex-shrink: 0;
  background: var(--ink-100); color: var(--ink-500);
  border: 2px solid #fff;
  font-size: 13px;
  z-index: 1;
}
.stepper-item.done .stepper-icon { background: var(--success); color: #fff; }
.stepper-item.current .stepper-icon { background: var(--warn); color: #fff; }
.stepper-item.rejected .stepper-icon { background: var(--danger); color: #fff; }
.stepper-body { flex: 1; padding-top: 1px; }
.stepper-body .title { font-weight: 500; color: var(--ink-900); font-size: 13.5px; }
.stepper-body .meta { font-size: 12px; color: var(--ink-500); margin-top: 2px; }
.stepper-body .comment {
  margin-top: 6px; padding: 8px 10px;
  background: var(--ink-50); border-radius: 6px; font-size: 12.5px; color: var(--ink-700);
  border-left: 2px solid var(--ink-300);
}

/* Toasts */
.toast-container { position: fixed; bottom: 24px; right: 24px; z-index: 2000; }
.dd-toast {
  background: #fff; border: 1px solid var(--ink-200);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 12px 16px; min-width: 280px; max-width: 380px;
  display: flex; gap: 10px; align-items: flex-start;
  margin-top: 10px;
  border-left: 3px solid var(--success);
  animation: slideIn .25s ease;
}
.dd-toast.error { border-left-color: var(--danger); }
.dd-toast.warn  { border-left-color: var(--warn); }
.dd-toast.info  { border-left-color: var(--info); }
@keyframes slideIn { from { transform: translateX(20px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* Empty state */
.empty-state {
  text-align: center; padding: 56px 24px;
  color: var(--ink-600);
}
.empty-state .illus {
  width: 80px; height: 80px; margin: 0 auto 18px;
  background: var(--ink-100); border-radius: 20px;
  display: grid; place-items: center; color: var(--ink-400);
}
.empty-state h6 { font-weight: 600; color: var(--ink-900); margin-bottom: 6px; font-size: 15px; }
.empty-state p { font-size: 13px; max-width: 320px; margin: 0 auto 16px; }

/* Skeleton */
.sk { background: linear-gradient(90deg, var(--ink-100) 0%, var(--ink-200) 50%, var(--ink-100) 100%);
  background-size: 200% 100%;
  animation: sk 1.5s linear infinite;
  border-radius: 4px;
}
@keyframes sk { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* Section header */
.section-head {
  display: flex; align-items: center; justify-content: space-between;
  margin: 22px 0 12px;
}
.section-head h6 { margin: 0; font-weight: 600; font-size: 14px; color: var(--ink-800); }

/* Sub-info grid */
.kv-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px 24px;
}
.kv label { font-size: 11.5px; color: var(--ink-500); text-transform: uppercase; letter-spacing: .04em; font-weight: 600; display: block; }
.kv value, .kv .val { display: block; margin-top: 3px; font-size: 13.5px; color: var(--ink-900); font-weight: 500; }

/* Misc */
.divider { height: 1px; background: var(--ink-200); margin: 18px 0; }
.dot-sep { color: var(--ink-400); margin: 0 6px; }

/* Auth screens */
.auth-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: var(--paper);
}
.auth-left {
  background: var(--ink-900);
  color: #fff;
  padding: 48px;
  display: flex; flex-direction: column; justify-content: space-between;
  position: relative; overflow: hidden;
}
.auth-left::before {
  content: ""; position: absolute; inset: 0;
  background: radial-gradient(circle at 30% 20%, color-mix(in oklch, var(--primary) 35%, transparent) 0%, transparent 50%);
}
.auth-left > * { position: relative; z-index: 1; }
.auth-right { padding: 48px; display: flex; align-items: center; justify-content: center; }
.auth-card { width: 100%; max-width: 380px; }
.auth-card h2 { font-weight: 700; letter-spacing: -.5px; margin-bottom: 8px; }
.auth-card .sub { color: var(--ink-600); margin-bottom: 28px; }

@media (max-width: 900px) {
  .auth-shell { grid-template-columns: 1fr; }
  .auth-left { display: none; }
}

/* Pagination */
.dd-pagination {
  display: flex; align-items: center; gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid var(--ink-200);
  background: var(--ink-50);
  font-size: 13px; color: var(--ink-700);
}
.dd-pagination .page-info { margin-right: auto; }
.dd-pagination .pg-btn {
  background: #fff; border: 1px solid var(--ink-300);
  border-radius: 6px; width: 30px; height: 30px;
  display: grid; place-items: center;
  cursor: pointer;
}
.dd-pagination .pg-btn:hover { background: var(--ink-100); }
.dd-pagination .pg-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* Files / dropzones */
.dropzone {
  border: 2px dashed var(--ink-300);
  border-radius: var(--radius-lg);
  padding: 28px;
  text-align: center;
  background: var(--ink-50);
  color: var(--ink-600);
}
.dropzone .ic { font-size: 24px; color: var(--ink-400); }

/* Calendar */
.dd-cal {
  background: #fff;
  border: 1px solid var(--ink-200);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.dd-cal-head { display: grid; grid-template-columns: repeat(7, 1fr); background: var(--ink-50); }
.dd-cal-head div { padding: 10px; font-size: 11.5px; font-weight: 600; color: var(--ink-600); text-transform: uppercase; letter-spacing: .03em; text-align: center; }
.dd-cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); }
.dd-cal-cell {
  min-height: 100px; padding: 8px;
  border-right: 1px solid var(--ink-100);
  border-bottom: 1px solid var(--ink-100);
  font-size: 12px;
}
.dd-cal-cell.oom { background: var(--ink-50); color: var(--ink-400); }
.dd-cal-cell .date { font-weight: 500; color: var(--ink-700); margin-bottom: 4px; }
.dd-cal-evt {
  background: var(--primary-50); color: var(--primary-700);
  font-size: 11px; padding: 2px 6px; border-radius: 4px;
  margin-bottom: 2px;
  display: flex; align-items: center; gap: 4px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.dd-cal-evt.warn { background: var(--warn-50); color: oklch(45% 0.15 75); }
.dd-cal-evt.danger { background: var(--danger-50); color: var(--danger); }

/* Misc utilities */
.text-ink-900 { color: var(--ink-900) !important; }
.text-ink-700 { color: var(--ink-700) !important; }
.text-ink-600 { color: var(--ink-600) !important; }
.text-ink-500 { color: var(--ink-500) !important; }
.text-success { color: var(--success) !important; }
.text-danger  { color: var(--danger) !important; }
.text-warn    { color: oklch(45% 0.15 75) !important; }
.bg-paper { background: var(--paper) !important; }
.bg-surface { background: var(--surface) !important; }
.fw-500 { font-weight: 500; }
.fw-600 { font-weight: 600; }
.fs-12 { font-size: 12px; } .fs-13 { font-size: 13px; } .fs-14 { font-size: 14px; }
.fs-16 { font-size: 16px; } .fs-18 { font-size: 18px; } .fs-20 { font-size: 20px; }
.gap-2 { gap: 8px; } .gap-3 { gap: 12px; } .gap-4 { gap: 16px; }
.cursor-pointer { cursor: pointer; }
