/* Tumirai Platform — Design System */
:root {
  /* Brand — sampled from Tumirai paper-airplane logo */
  --brand-blue: #1E6BFF;
  --brand-blue-700: #1751CC;
  --brand-blue-600: #1E6BFF;
  --brand-blue-500: #4D8AFF;
  --brand-blue-100: #DCE8FF;
  --brand-blue-50: #EEF4FF;
  --brand-green: #22C55E;
  --brand-green-700: #16A34A;
  --brand-green-100: #D7F5E1;
  --brand-green-50: #EFFCF3;

  /* Neutrals (cool-tinted) */
  --ink-900: #0d1530;
  --ink-800: #18223f;
  --ink-700: #2a3454;
  --ink-600: #475070;
  --ink-500: #6a7390;
  --ink-400: #9098b1;
  --ink-300: #c2c8d8;
  --ink-200: #e3e6ef;
  --ink-100: #eef0f6;
  --ink-50: #f6f7fb;
  --paper: #ffffff;
  --canvas: #f6f7fb;

  /* Status */
  --ok: #16A34A;
  --ok-bg: #D7F5E1;
  --warn: #b16b00;
  --warn-bg: #fcf2dc;
  --err: #b42318;
  --err-bg: #fde7e4;
  --info: #1E6BFF;
  --info-bg: #DCE8FF;
  --pending: #6a7390;
  --pending-bg: #eef0f6;

  /* Layout */
  --sidebar-w: 248px;
  --sidebar-w-collapsed: 64px;
  --topbar-h: 56px;
  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 14px;
  --shadow-xs: 0 1px 2px rgba(13,21,48,0.05);
  --shadow-sm: 0 1px 2px rgba(13,21,48,0.06), 0 1px 3px rgba(13,21,48,0.04);
  --shadow-md: 0 4px 12px rgba(13,21,48,0.08), 0 1px 2px rgba(13,21,48,0.04);
  --shadow-lg: 0 12px 32px rgba(13,21,48,0.12), 0 2px 6px rgba(13,21,48,0.06);

  --row-h: 44px;
  --pad: 16px;

  font-feature-settings: "ss01","cv11";
}

[data-theme="dark"] {
  --paper: #0f1730;
  --canvas: #0a1126;
  --ink-900: #f6f7fb;
  --ink-800: #eef0f6;
  --ink-700: #c2c8d8;
  --ink-600: #9098b1;
  --ink-500: #6a7390;
  --ink-400: #475070;
  --ink-300: #2a3454;
  --ink-200: #1c2645;
  --ink-100: #16203c;
  --ink-50: #121a35;
  --brand-blue-50: #16203c;
  --brand-blue-100: #1c2c5e;
  --brand-green-50: #11321e;
  --brand-green-100: #163d27;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.5);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.5);
}
[data-theme="dim"] {
  --paper: #f6f7fb;
  --canvas: #ebeef6;
  --ink-100: #e3e6ef;
  --ink-200: #d6dae8;
}

* { box-sizing: border-box; }
html, body, #root { height: 100%; margin: 0; }
body {
  font-family: 'Inter', 'Segoe UI', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.45;
  color: var(--ink-800);
  background: var(--canvas);
  -webkit-font-smoothing: antialiased;
}
.mono { font-family: 'JetBrains Mono', 'SF Mono', Menlo, Consolas, monospace; }

/* Density */
[data-density="compact"] { --row-h: 36px; --pad: 12px; font-size: 13px; }

/* Typography */
h1,h2,h3,h4 { margin: 0; color: var(--ink-900); font-weight: 600; letter-spacing: -0.01em; }
h1 { font-size: 24px; letter-spacing: -0.02em; }
h2 { font-size: 18px; }
h3 { font-size: 15px; }
h4 { font-size: 13px; color: var(--ink-600); text-transform: uppercase; letter-spacing: 0.06em; font-weight: 600; }
a { color: var(--brand-blue); text-decoration: none; }
a:hover { text-decoration: underline; }
p { margin: 0; }

/* Layout primitives */
.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  grid-template-rows: var(--topbar-h) 1fr;
  height: 100vh;
  background: var(--canvas);
}
.app[data-sidebar="collapsed"] { grid-template-columns: var(--sidebar-w-collapsed) 1fr; }
.app[data-sidebar="hidden"] { grid-template-columns: 0 1fr; }
.sidebar { grid-row: 1 / 3; background: var(--paper); border-right: 1px solid var(--ink-200); display: flex; flex-direction: column; min-width: 0; overflow: hidden; }
.topbar { background: var(--paper); border-bottom: 1px solid var(--ink-200); display: flex; align-items: center; padding: 0 20px; gap: 16px; }
.main { overflow: auto; padding: 24px 28px 80px; }
.main-narrow { max-width: 1240px; margin: 0 auto; }

/* Sidebar */
.brand-row {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 12px 16px 11px;
  min-height: 106px;
  border-bottom: 1px solid var(--ink-200);
}
.brand-logo-full {
  display: block;
  width: min(178px, 100%);
  height: auto;
  object-fit: contain;
}
.brand-logo-mark { display: none; }
.brand-byline {
  color: var(--ink-500);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.02em;
  line-height: 1;
  white-space: nowrap;
}
.app[data-sidebar="collapsed"] .brand-row {
  align-items: center;
  padding: 12px 16px;
  min-height: var(--topbar-h);
}
.app[data-sidebar="collapsed"] .brand-logo-full,
.app[data-sidebar="collapsed"] .brand-byline { display: none; }
.app[data-sidebar="collapsed"] .brand-logo-mark {
  display: block;
  width: 32px;
  height: 32px;
  object-fit: contain;
}

.nav { padding: 12px 8px; flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 2px; }
.nav-section { font-size: 10px; font-weight: 600; color: var(--ink-500); text-transform: uppercase; letter-spacing: 0.08em; padding: 14px 12px 6px; }
.app[data-sidebar="collapsed"] .nav-section { display: none; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px; border-radius: var(--radius-sm);
  color: var(--ink-700); cursor: pointer; font-weight: 500;
  white-space: nowrap; user-select: none;
}
.nav-item:hover { background: var(--ink-50); color: var(--ink-900); text-decoration: none; }
.nav-item.active { background: var(--brand-blue-50); color: var(--brand-blue); }
.nav-item .ico { width: 18px; height: 18px; flex: 0 0 18px; }
.nav-item .badge { margin-left: auto; background: var(--ink-100); color: var(--ink-700); font-size: 11px; padding: 1px 7px; border-radius: 999px; }
.nav-item.active .badge { background: var(--brand-blue); color: white; }
.app[data-sidebar="collapsed"] .nav-item .label,
.app[data-sidebar="collapsed"] .nav-item .badge { display: none; }
.app[data-sidebar="collapsed"] .nav-item { justify-content: center; }

.sidebar-footer { border-top: 1px solid var(--ink-200); padding: 12px; }
.tenant-pill { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: var(--radius-sm); background: var(--ink-50); cursor: pointer; }
.tenant-pill:hover { background: var(--ink-100); }
.tenant-pill .avatar { width: 28px; height: 28px; border-radius: 6px; background: var(--brand-blue); color: white; display: grid; place-items: center; font-weight: 600; font-size: 12px; flex: 0 0 28px; }
.tenant-pill .meta { min-width: 0; flex: 1; }
.tenant-pill .meta .name { font-weight: 600; color: var(--ink-900); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tenant-pill .meta .sub { font-size: 11px; color: var(--ink-500); }
.app[data-sidebar="collapsed"] .tenant-pill .meta { display: none; }

/* Topbar */
.topbar .breadcrumb { display: flex; align-items: center; gap: 6px; color: var(--ink-500); font-size: 13px; }
.topbar .breadcrumb .sep { color: var(--ink-300); }
.topbar .breadcrumb .here { color: var(--ink-900); font-weight: 600; }
.topbar .spacer { flex: 1; }
.topbar .search { display: flex; align-items: center; gap: 8px; background: var(--ink-50); border: 1px solid transparent; border-radius: var(--radius-sm); padding: 6px 10px; min-width: 280px; position: relative; }
.topbar .search:focus-within { background: var(--paper); border-color: var(--brand-blue-500); }
.topbar .search input { border: 0; background: transparent; outline: none; flex: 1; font-size: 13px; color: var(--ink-800); }
.topbar .search kbd { font-size: 10px; color: var(--ink-500); background: var(--paper); border: 1px solid var(--ink-200); padding: 1px 5px; border-radius: 4px; font-family: inherit; }
.search-popover { position: absolute; top: calc(100% + 8px); right: 0; width: min(420px, calc(100vw - 32px)); max-height: 420px; overflow-y: auto; padding: 6px; background: var(--paper); border: 1px solid var(--ink-200); border-radius: 8px; box-shadow: var(--shadow-lg); z-index: 30; }
.search-state { padding: 14px 12px; font-size: 13px; color: var(--ink-500); text-align: center; }
.search-state.err { color: var(--err); }
.search-result { width: 100%; display: flex; align-items: center; gap: 10px; border: 0; background: transparent; border-radius: 6px; padding: 9px 10px; text-align: left; cursor: pointer; }
.search-result:hover, .search-result.active { background: var(--ink-50); }
.search-result .result-icon { width: 28px; height: 28px; border-radius: 6px; display: grid; place-items: center; background: var(--brand-blue-50); color: var(--brand-blue); flex: 0 0 28px; }
.search-result .result-copy { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.search-result .result-label { font-size: 13px; font-weight: 600; color: var(--ink-900); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.search-result .result-meta { font-size: 11px; color: var(--ink-500); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar .icon-btn { width: 34px; height: 34px; border-radius: var(--radius-sm); display: grid; place-items: center; cursor: pointer; color: var(--ink-600); position: relative; }
.topbar .icon-btn:hover { background: var(--ink-50); color: var(--ink-900); }
.topbar .icon-btn .dot { position: absolute; top: 8px; right: 9px; width: 7px; height: 7px; border-radius: 50%; background: var(--err); border: 2px solid var(--paper); }
.topbar .user { display: flex; align-items: center; gap: 8px; cursor: pointer; padding: 4px 8px 4px 4px; border-radius: var(--radius-sm); }
.topbar .user:hover { background: var(--ink-50); }
.topbar .user .av { width: 28px; height: 28px; border-radius: 50%; background: linear-gradient(135deg, var(--brand-blue), var(--brand-green)); color: white; display: grid; place-items: center; font-weight: 600; font-size: 12px; }
.topbar .user .nm { font-size: 13px; font-weight: 600; color: var(--ink-900); }
.topbar .user .rl { font-size: 11px; color: var(--ink-500); }

/* Cards */
.card { background: var(--paper); border: 1px solid var(--ink-200); border-radius: var(--radius); box-shadow: var(--shadow-xs); }
.card-pad { padding: 20px; }
.card-head { padding: 14px 20px; border-bottom: 1px solid var(--ink-200); display: flex; align-items: center; gap: 12px; }
.card-head h2, .card-head h3 { margin: 0; }
.card-head .actions { margin-left: auto; display: flex; gap: 8px; }
.card-body { padding: 20px; }

/* Buttons */
.btn { display: inline-flex; align-items: center; gap: 8px; padding: 8px 14px; border-radius: var(--radius-sm); font-weight: 500; font-size: 13px; cursor: pointer; border: 1px solid transparent; background: transparent; color: var(--ink-800); transition: all .15s; white-space: nowrap; font-family: inherit; }
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--brand-blue); color: white; border-color: var(--brand-blue); }
.btn-primary:hover { background: var(--brand-blue-700); border-color: var(--brand-blue-700); }
.btn-ghost { background: transparent; color: var(--ink-700); border-color: transparent; }
.btn-ghost:hover { background: var(--ink-50); color: var(--ink-900); }
.btn-secondary { background: var(--paper); color: var(--ink-800); border-color: var(--ink-200); }
.btn-secondary:hover { background: var(--ink-50); border-color: var(--ink-300); }
.btn-success { background: var(--brand-green); color: white; border-color: var(--brand-green); }
.btn-success:hover { background: var(--brand-green-700); }
.btn-danger { background: white; color: var(--err); border-color: var(--ink-200); }
.btn-danger:hover { background: var(--err-bg); border-color: var(--err); }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-lg { padding: 11px 18px; font-size: 14px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* Forms */
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 12px; font-weight: 500; color: var(--ink-700); }
.field .hint { font-size: 11px; color: var(--ink-500); }
.field .err { font-size: 12px; color: var(--err); }
input:not([type]), input[type="text"], input[type="email"], input[type="password"], input[type="number"], input[type="search"], input[type="tel"], input[type="url"], input[type="datetime-local"], input[type="date"], input[type="time"], select, textarea {
  border: 1px solid var(--ink-200);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  font-size: 13px;
  background: var(--paper);
  color: var(--ink-900);
  font-family: inherit;
  outline: none;
  width: 100%;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--brand-blue-500);
  box-shadow: 0 0 0 3px var(--brand-blue-100);
}
textarea { resize: vertical; font-family: inherit; }
.input-group { display: flex; align-items: stretch; border: 1px solid var(--ink-200); border-radius: var(--radius-sm); background: var(--paper); }
.input-group:focus-within { border-color: var(--brand-blue-500); box-shadow: 0 0 0 3px var(--brand-blue-100); }
.input-group .prefix, .input-group .suffix { display: flex; align-items: center; padding: 0 10px; color: var(--ink-500); font-size: 13px; background: var(--ink-50); }
.input-group .prefix { border-right: 1px solid var(--ink-200); border-radius: 5px 0 0 5px; }
.input-group .suffix { border-left: 1px solid var(--ink-200); border-radius: 0 5px 5px 0; }
.input-group input { border: 0; box-shadow: none !important; }

.checkbox { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; user-select: none; }
.checkbox input { width: 16px; height: 16px; accent-color: var(--brand-blue); }

.toggle { width: 36px; height: 20px; background: var(--ink-200); border-radius: 999px; position: relative; cursor: pointer; transition: background .15s; flex: 0 0 36px; }
.toggle::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; background: white; border-radius: 50%; box-shadow: var(--shadow-sm); transition: transform .15s; }
.toggle.on { background: var(--brand-blue); }
.toggle.on::after { transform: translateX(16px); }

/* Badges */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 600; line-height: 1.5; white-space: nowrap; }
.badge .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-ok { background: var(--ok-bg); color: var(--ok); }
.badge-warn { background: var(--warn-bg); color: var(--warn); }
.badge-err { background: var(--err-bg); color: var(--err); }
.badge-info { background: var(--info-bg); color: var(--info); }
.badge-pending { background: var(--pending-bg); color: var(--pending); }
.badge-neutral { background: var(--ink-100); color: var(--ink-700); }

/* Tables */
.table-wrap { background: var(--paper); border: 1px solid var(--ink-200); border-radius: var(--radius); overflow: hidden; }
.table-toolbar { display: flex; align-items: center; gap: 8px; padding: 10px 16px; border-bottom: 1px solid var(--ink-200); flex-wrap: wrap; }
.table-toolbar .left { display: flex; gap: 8px; align-items: center; flex: 1 1 auto; min-width: 0; flex-wrap: wrap; }
.table-toolbar .right { display: flex; gap: 8px; flex: 0 0 auto; }
/* Override the global `select { width: 100% }` rule so toolbar selects size to
   their option text instead of stretching the flex container. The input-group
   keeps its inline maxWidth:320 but its inner <input> still needs width:auto
   so it can shrink/grow inside the group cleanly. */
.table-toolbar .input-group { flex: 1 1 240px; min-width: 200px; }
.table-toolbar .input-group input { width: auto; min-width: 0; flex: 1 1 auto; }
.table-toolbar select { width: auto; min-width: 140px; max-width: 240px; }
table.t { width: 100%; border-collapse: collapse; }
table.t th { font-size: 11px; text-align: left; font-weight: 600; color: var(--ink-500); text-transform: uppercase; letter-spacing: 0.06em; padding: 10px 16px; background: var(--ink-50); border-bottom: 1px solid var(--ink-200); white-space: nowrap; }
table.t td { padding: 12px 16px; border-bottom: 1px solid var(--ink-100); font-size: 13px; vertical-align: middle; height: var(--row-h); }
table.t tr:last-child td { border-bottom: 0; }
table.t tbody tr:hover { background: var(--ink-50); }
table.t tbody tr.selected { background: var(--brand-blue-50); }
table.t .num { font-variant-numeric: tabular-nums; text-align: right; }
.table-wrap.audit-table-wrap { overflow-x: auto; }
.audit-table { min-width: 980px; table-layout: fixed; }
.audit-table .audit-col-event { width: 17%; }
.audit-table .audit-col-actor { width: 15%; }
.audit-table .audit-col-target { width: 22%; }
.audit-table .audit-col-tenant { width: 12%; }
.audit-table .audit-col-severity { width: 9%; }
.audit-table .audit-col-ip { width: 11%; }
.audit-table .audit-col-when { width: 14%; }
.audit-table td { overflow: hidden; vertical-align: top; }
.audit-table .audit-id,
.audit-table .audit-action,
.audit-table .audit-text,
.audit-table .audit-ip {
  display: block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.audit-table .audit-action {
  margin-top: 2px;
  font-weight: 600;
  color: var(--ink-900);
  line-height: 1.35;
}
.audit-table .audit-severity { white-space: nowrap; }
.pagination { display: flex; align-items: center; justify-content: space-between; padding: 10px 16px; border-top: 1px solid var(--ink-200); font-size: 12px; color: var(--ink-600); gap: 12px; flex-wrap: wrap; }
.pagination .pages { display: flex; gap: 4px; }
.pagination .pg { width: 28px; height: 28px; display: grid; place-items: center; border-radius: 6px; cursor: pointer; user-select: none; }
.pagination .pg:hover { background: var(--ink-100); }
.pagination .pg.active { background: var(--brand-blue); color: white; }
.pagination .pg.active:hover { background: var(--brand-blue); }
.pagination .pg.disabled { color: var(--ink-300); cursor: not-allowed; }
.pagination .pg.disabled:hover { background: transparent; }
.pagination .pg.ellipsis { cursor: default; color: var(--ink-400); }
.pagination .pg.ellipsis:hover { background: transparent; }
.pagination select { border: 1px solid var(--ink-200); border-radius: var(--radius-sm); background: var(--paper); font-size: 12px; padding: 2px 6px; height: 26px; }

/* Stats */
.stat-grid { display: grid; gap: 16px; grid-template-columns: repeat(4, 1fr); }
.stat { background: var(--paper); border: 1px solid var(--ink-200); border-radius: var(--radius); padding: 18px 20px; }
.stat .lbl { font-size: 12px; color: var(--ink-500); font-weight: 500; }
.stat .val { font-size: 28px; font-weight: 600; color: var(--ink-900); margin-top: 4px; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.stat .val .unit { font-size: 14px; color: var(--ink-500); font-weight: 500; margin-left: 4px; }
.stat .delta { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; margin-top: 6px; font-weight: 600; }
.stat .delta.up { color: var(--ok); }
.stat .delta.down { color: var(--err); }
.stat .spark { margin-top: 10px; height: 32px; }

/* Tabs */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--ink-200); }
.tab { padding: 10px 14px; cursor: pointer; color: var(--ink-600); font-weight: 500; font-size: 13px; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tab:hover { color: var(--ink-900); }
.tab.active { color: var(--brand-blue); border-bottom-color: var(--brand-blue); }

/* Empty + spinners */
.empty { text-align: center; padding: 48px 24px; color: var(--ink-500); }
.empty .ico { width: 48px; height: 48px; margin: 0 auto 12px; color: var(--ink-300); }
.empty h3 { color: var(--ink-800); margin-bottom: 4px; }

/* Modal */
.modal-back { position: fixed; inset: 0; background: rgba(13,21,48,0.45); z-index: 1000; display: grid; place-items: center; backdrop-filter: blur(2px); }
.modal { background: var(--paper); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); width: 540px; max-width: calc(100vw - 32px); max-height: calc(100vh - 64px); display: flex; flex-direction: column; }
.modal.lg { width: 760px; }
.modal-head { padding: 18px 22px; border-bottom: 1px solid var(--ink-200); display: flex; align-items: center; gap: 12px; }
.modal-head .x { margin-left: auto; cursor: pointer; color: var(--ink-500); }
.modal-body { padding: 22px; overflow-y: auto; }
.modal-foot { padding: 14px 22px; border-top: 1px solid var(--ink-200); display: flex; justify-content: flex-end; gap: 8px; }

/* Toasts */
.toasts { position: fixed; top: 20px; right: 20px; z-index: 2000; display: flex; flex-direction: column; gap: 8px; }
.toast { background: var(--paper); border: 1px solid var(--ink-200); border-left: 3px solid var(--brand-blue); border-radius: var(--radius); box-shadow: var(--shadow-md); padding: 12px 14px; min-width: 280px; max-width: 360px; display: flex; gap: 10px; align-items: flex-start; animation: slideIn .2s; }
.toast.ok { border-left-color: var(--ok); }
.toast.err { border-left-color: var(--err); }
.toast.warn { border-left-color: var(--warn); }
@keyframes slideIn { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: none; } }

/* Misc */
.row { display: flex; align-items: center; gap: 8px; }
.col { display: flex; flex-direction: column; gap: 8px; }
.gap-4 { gap: 4px; } .gap-8 { gap: 8px; } .gap-12 { gap: 12px; } .gap-16 { gap: 16px; } .gap-20 { gap: 20px; } .gap-24 { gap: 24px; }
.mt-4 { margin-top: 4px; } .mt-8 { margin-top: 8px; } .mt-12 { margin-top: 12px; } .mt-16 { margin-top: 16px; } .mt-20 { margin-top: 20px; } .mt-24 { margin-top: 24px; }
.mb-4 { margin-bottom: 4px; } .mb-8 { margin-bottom: 8px; } .mb-12 { margin-bottom: 12px; } .mb-16 { margin-bottom: 16px; } .mb-20 { margin-bottom: 20px; } .mb-24 { margin-bottom: 24px; }
.flex-1 { flex: 1; }
.muted { color: var(--ink-500); }
.small { font-size: 12px; }
.tiny { font-size: 11px; }
.right { text-align: right; }
.center { text-align: center; }
.divider { height: 1px; background: var(--ink-200); margin: 16px 0; }
.divider-v { width: 1px; background: var(--ink-200); align-self: stretch; }
.tag { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: var(--radius-sm); background: var(--ink-100); color: var(--ink-700); font-size: 11px; font-weight: 500; }
.kpi-pill { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; background: var(--ink-50); border: 1px solid var(--ink-200); border-radius: 999px; font-size: 12px; }
.kpi-pill .dot { width: 6px; height: 6px; border-radius: 50%; }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; margin-bottom: 20px; gap: 16px; flex-wrap: wrap; }
.page-head .titles h1 { margin-bottom: 4px; }
.page-head .titles p { color: var(--ink-500); font-size: 13px; }
.page-head .actions { display: flex; gap: 8px; }

.split-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.split-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }
.grid-2-1 { display: grid; grid-template-columns: 2fr 1fr; gap: 16px; }
.grid-1-2 { display: grid; grid-template-columns: 1fr 2fr; gap: 16px; }

/* Code blocks */
pre.code { background: #0d1530; color: #d8def0; padding: 16px; border-radius: var(--radius-sm); font-family: 'JetBrains Mono', 'SF Mono', Menlo, monospace; font-size: 12px; line-height: 1.6; overflow-x: auto; margin: 0; }
pre.code .k { color: #7aa6ff; }
pre.code .s { color: #8be9a4; }
pre.code .n { color: #ffd479; }
pre.code .c { color: #6a7390; font-style: italic; }
pre.code .p { color: #c2c8d8; }

/* Public site */
.public-nav { display: flex; align-items: center; padding: 20px 64px; background: var(--paper); border-bottom: 1px solid var(--ink-200); position: sticky; top: 0; z-index: 50; }
.public-nav .logo { height: 64px; width: auto; display: block; }
.public-nav nav { display: flex; gap: 24px; flex: 1; align-items: center; justify-content: center; }
.public-nav nav a { color: var(--ink-700); font-weight: 500; font-size: 14px; }
.public-nav nav a:hover { color: var(--ink-900); text-decoration: none; }
.public-nav .auth { display: flex; gap: 8px; align-items: center; }
.hero { padding: 80px 40px 60px; max-width: 1200px; margin: 0 auto; display: grid; grid-template-columns: 1.1fr 1fr; gap: 60px; align-items: center; }
.hero h1 { font-size: 52px; line-height: 1.05; letter-spacing: -0.03em; margin-bottom: 20px; }
.hero h1 em { color: var(--brand-blue); font-style: normal; }
.hero p.lede { font-size: 17px; color: var(--ink-600); line-height: 1.6; margin-bottom: 28px; max-width: 520px; }
.hero .cta-row { display: flex; gap: 12px; }
.hero .trust { margin-top: 36px; display: flex; gap: 24px; flex-wrap: wrap; }
.hero .trust .pill { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--ink-600); }
.preview-card { background: var(--paper); border: 1px solid var(--ink-200); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); overflow: hidden; }

/* Hero "live" pulse on the SMS-sent-today counter. */
.hero-live-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--brand-green); display: inline-block; box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.6); animation: heroLivePulse 1.8s ease-out infinite; }
@keyframes heroLivePulse {
  0%   { box-shadow: 0 0 0 0   rgba(34, 197, 94, 0.55); }
  70%  { box-shadow: 0 0 0 10px rgba(34, 197, 94, 0); }
  100% { box-shadow: 0 0 0 0   rgba(34, 197, 94, 0); }
}

/* Hero motion graphic: two phones with messages flying between them. Pure
   CSS, no JS. Lives inside the .preview-card so it stays neatly bounded.
   Height tuned for ~3 lines of wrapped bubble text. */
.hero-flow {
  position: relative;
  margin-top: 16px;
  height: 180px;
  display: grid;
  grid-template-columns: 56px 1fr 56px;
  align-items: center;
  gap: 12px;
  padding: 8px 4px;
  background: linear-gradient(180deg, var(--brand-blue-50) 0%, transparent 100%);
  border-radius: var(--radius);
  overflow: hidden;
}
.hero-flow__phone {
  width: 56px;
  height: 140px;
  border-radius: 12px;
  background: linear-gradient(160deg, var(--ink-900), var(--ink-800));
  position: relative;
  box-shadow: 0 6px 14px -6px rgba(13, 21, 48, 0.45);
  border: 2px solid var(--ink-700);
}
.hero-flow__phone::after {
  content: ""; position: absolute; left: 50%; transform: translateX(-50%); bottom: 4px; width: 18px; height: 3px; background: var(--ink-600); border-radius: 2px;
}
.hero-flow__phone-screen {
  position: absolute; inset: 6px 4px 12px; background: var(--paper); border-radius: 6px; padding: 8px 6px; display: flex; flex-direction: column; gap: 4px;
}
.hero-flow__phone-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--brand-green); }
.hero-flow__phone-bar { height: 3px; background: var(--ink-200); border-radius: 2px; }
.hero-flow__phone-bar--short { width: 60%; }
.hero-flow__phone-bubble { height: 10px; background: var(--brand-blue-100); border-radius: 4px; align-self: flex-start; width: 80%; opacity: 0; animation: phoneBubbleArrive 48s ease-in-out infinite; animation-delay: 5.8s; }
.hero-flow__phone-bubble--mid { animation-delay: 11.8s; width: 70%; background: var(--brand-green-100); }
.hero-flow__phone-bubble--end { animation-delay: 17.8s; width: 90%; background: var(--ink-100); }
@keyframes phoneBubbleArrive {
  0%   { opacity: 0; transform: translateX(-6px) scale(0.9); }
  1%   { opacity: 1; transform: translateX(0) scale(1); }
  100% { opacity: 1; transform: translateX(0) scale(1); }
}

/* Right phone vibrates + lights up each time a bubble arrives (every 6 s, first at 5.8 s). */
.hero-flow__phone--right {
  animation: phoneVibrate 6s ease-in-out infinite;
  animation-delay: 5.8s;
}
.hero-flow__phone--right .hero-flow__phone-screen {
  animation: phoneScreenGlow 6s ease-in-out infinite;
  animation-delay: 5.8s;
}
@keyframes phoneVibrate {
  0%, 7%, 100% { transform: translateX(0); box-shadow: 0 6px 14px -6px rgba(13, 21, 48, 0.45); }
  1%  { transform: translateX(-3px); box-shadow: 0 0 0 4px rgba(30, 107, 255, 0.5), 0 6px 14px -6px rgba(13, 21, 48, 0.45); }
  2%  { transform: translateX( 3px); box-shadow: 0 0 0 5px rgba(30, 107, 255, 0.3), 0 6px 14px -6px rgba(13, 21, 48, 0.45); }
  3%  { transform: translateX(-2px); box-shadow: 0 0 0 3px rgba(30, 107, 255, 0.15), 0 6px 14px -6px rgba(13, 21, 48, 0.45); }
  4%  { transform: translateX( 2px); box-shadow: 0 6px 14px -6px rgba(13, 21, 48, 0.45); }
  5%  { transform: translateX(-1px); }
  6%  { transform: translateX( 0); }
}
@keyframes phoneScreenGlow {
  0%, 15%, 100% { background: var(--paper); }
  2%  { background: rgba(30, 107, 255, 0.22); }
  8%  { background: rgba(30, 107, 255, 0.07); }
}

.hero-flow__bubbles { position: relative; height: 100%; }
.hero-flow__bubble {
  position: absolute;
  top: 50%;
  left: 0;
  transform: translate(-12px, -50%);
  background: var(--paper);
  border: 1px solid var(--ink-200);
  border-radius: 14px;
  padding: 8px 12px;
  font-size: 11px;
  line-height: 1.4;
  color: var(--ink-700);
  box-shadow: 0 4px 14px -6px rgba(13, 21, 48, 0.15);
  max-width: 70%;
  min-width: 200px;
  opacity: 0;
  animation: bubbleFly 48s ease-in-out infinite;
}
.hero-flow__bubble strong { color: var(--ink-900); font-weight: 600; }
.hero-flow__bubble-tag {
  display: inline-block;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 1px 6px;
  border-radius: 999px;
  margin-right: 6px;
  vertical-align: middle;
}
.hero-flow__bubble--otp      .hero-flow__bubble-tag { background: var(--brand-blue-100);  color: var(--brand-blue-700); }
.hero-flow__bubble--verify   .hero-flow__bubble-tag { background: var(--brand-blue-100);  color: var(--brand-blue-700); }
.hero-flow__bubble--reminder .hero-flow__bubble-tag { background: var(--ink-100);         color: var(--ink-700); }
.hero-flow__bubble--promo    .hero-flow__bubble-tag { background: var(--brand-green-100); color: var(--brand-green-700); }
.hero-flow__bubble--payment  .hero-flow__bubble-tag { background: var(--brand-green-100); color: var(--brand-green-700); }
.hero-flow__bubble--delivery .hero-flow__bubble-tag { background: var(--warn-bg);         color: var(--warn); }
.hero-flow__bubble--bill     .hero-flow__bubble-tag { background: var(--err-bg);          color: var(--err); }
.hero-flow__bubble--alert    .hero-flow__bubble-tag { background: var(--err-bg);          color: var(--err); }
@keyframes bubbleFly {
  /* Active window: 0 s → ~7 s out of 48 s total cycle. Next bubble begins at 6 s,
     giving a clean relay with a brief overlap as the current bubble fades on arrival. */
  0%   { opacity: 0; transform: translate(-12px, -50%) scale(0.9); }
  1%   { opacity: 1; transform: translate(-12px, -50%) scale(1); }
  12%  { opacity: 1; transform: translate(calc(100% + 12px), -50%) scale(1); }
  15%  { opacity: 0; transform: translate(calc(100% + 12px), -50%) scale(0.95); }
  100% { opacity: 0; transform: translate(calc(100% + 12px), -50%) scale(0.95); }
}

@media (prefers-reduced-motion: reduce) {
  .hero-live-dot,
  .hero-flow__phone-bubble,
  .hero-flow__bubble,
  .hero-flow__phone--right,
  .hero-flow__phone--right .hero-flow__phone-screen { animation: none !important; }
  .hero-flow__bubble { opacity: 0; }
  .hero-flow__bubble--otp { opacity: 1; transform: translate(40%, -50%); }
  .hero-flow__phone-bubble { opacity: 1; }
}

/* charts */
.chart-axis { stroke: var(--ink-200); }
.chart-grid { stroke: var(--ink-100); stroke-dasharray: 2 4; }
.chart-label { font-size: 10px; fill: var(--ink-500); }

/* segmented */
.segmented { display: inline-flex; background: var(--ink-100); padding: 3px; border-radius: var(--radius-sm); gap: 2px; }
.segmented .seg { padding: 5px 10px; border-radius: 5px; cursor: pointer; font-size: 12px; font-weight: 500; color: var(--ink-600); }
.segmented .seg.active { background: var(--paper); color: var(--ink-900); box-shadow: var(--shadow-xs); }

/* progress */
.progress { height: 6px; background: var(--ink-100); border-radius: 999px; overflow: hidden; }
.progress > .bar { height: 100%; background: var(--brand-blue); border-radius: 999px; }
.progress.green > .bar { background: var(--brand-green); }
.progress.warn > .bar { background: var(--warn); }

/* avatar group */
.av-group { display: inline-flex; }
.av-group > * { margin-left: -6px; border: 2px solid var(--paper); }
.av-group > *:first-child { margin-left: 0; }
.av-mini { width: 24px; height: 24px; border-radius: 50%; background: var(--ink-200); color: var(--ink-700); display: inline-grid; place-items: center; font-weight: 600; font-size: 10px; }

/* timeline */
.timeline { position: relative; padding-left: 24px; }
.timeline::before { content: ""; position: absolute; left: 7px; top: 6px; bottom: 6px; width: 2px; background: var(--ink-200); }
.timeline-item { position: relative; padding-bottom: 18px; }
.timeline-item::before { content: ""; position: absolute; left: -21px; top: 4px; width: 12px; height: 12px; border-radius: 50%; background: var(--paper); border: 2px solid var(--brand-blue); }
.timeline-item.done::before { background: var(--brand-green); border-color: var(--brand-green); }
.timeline-item.err::before { background: var(--err); border-color: var(--err); }
.timeline-item .ts { font-size: 11px; color: var(--ink-500); }
.timeline-item .msg { font-weight: 500; color: var(--ink-800); }

/* drop zone */
.dropzone { border: 1.5px dashed var(--ink-300); border-radius: var(--radius); padding: 28px; text-align: center; background: var(--ink-50); cursor: pointer; transition: all .15s; }
.dropzone:hover { border-color: var(--brand-blue); background: var(--brand-blue-50); }

/* phone preview */
.phone-prev { background: linear-gradient(180deg, #1a2238 0%, #0d1530 100%); border-radius: 22px; padding: 18px 16px; color: white; max-width: 280px; }
.phone-prev .from { font-size: 11px; opacity: 0.6; margin-bottom: 4px; text-transform: uppercase; letter-spacing: 0.06em; }
.phone-prev .sender { font-weight: 600; margin-bottom: 8px; }
.phone-prev .bubble { background: rgba(255,255,255,0.08); border-radius: 16px 16px 16px 4px; padding: 10px 14px; font-size: 13px; line-height: 1.5; white-space: pre-wrap; }
.phone-prev .meta { font-size: 10px; opacity: 0.5; margin-top: 6px; text-align: right; }

/* utility */
.hide-scroll::-webkit-scrollbar { display: none; }
.scroll-x { overflow-x: auto; }

/* ================================================================
   Responsive design — tablet (≤1024px), phone (≤768px), small (≤480px)
   ================================================================ */

/* Tablet — tighten the 4-up stat grid and big public margins */
@media (max-width: 1024px) {
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .split-3 { grid-template-columns: 1fr 1fr; }
  .public-nav { padding: 16px 28px; }
  .hero { padding: 60px 28px 48px; gap: 40px; }
  .hero h1 { font-size: 42px; }
  .main { padding: 20px 20px 80px; }
}

/* Phone — drawer sidebar, single-column grids, compact chrome */
@media (max-width: 768px) {
  /* Shell: hide sidebar by default, drawer slides over content. */
  .app,
  .app[data-sidebar="expanded"],
  .app[data-sidebar="collapsed"],
  .app[data-sidebar="hidden"],
  .app[data-sidebar="drawer"] {
    grid-template-columns: 0 1fr;
  }
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-w);
    height: 100vh;
    z-index: 1100;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    box-shadow: var(--shadow-lg);
  }
  .app[data-sidebar="drawer"] .sidebar { transform: translateX(0); }
  /* Force expanded-style labels visible inside drawer regardless of collapsed flag */
  .app[data-sidebar="drawer"] .nav-item .label,
  .app[data-sidebar="drawer"] .nav-item .badge,
  .app[data-sidebar="drawer"] .brand-stack,
  .app[data-sidebar="drawer"] .nav-section,
  .app[data-sidebar="drawer"] .tenant-pill .meta { display: revert; }
  .app[data-sidebar="drawer"] .nav-item { justify-content: flex-start; }
  /* Backdrop is rendered as a sibling .sidebar-backdrop element from JSX */
  .sidebar-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(13, 21, 48, 0.45);
    z-index: 1099;
    backdrop-filter: blur(2px);
  }

  /* Topbar */
  .topbar { padding: 0 12px; gap: 8px; }
  .topbar .search { min-width: 0; flex: 1; }
  .topbar .search kbd { display: none; }
  .topbar .breadcrumb .sep,
  .topbar .breadcrumb > *:not(.here):not(:last-child) { display: none; }
  .topbar .user .nm,
  .topbar .user .rl { display: none; }

  /* Main content */
  .main { padding: 16px 16px 80px; }
  .card-pad, .card-body { padding: 16px; }
  .card-head { padding: 12px 16px; }
  h1 { font-size: 22px; }
  .page-head { align-items: flex-start; }

  /* Grids — single column on phones */
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .split-2,
  .split-3,
  .grid-2-1,
  .grid-1-2 { grid-template-columns: 1fr; }

  /* Hero / public site */
  .public-nav { padding: 12px 16px; flex-wrap: wrap; gap: 8px; }
  .public-nav .logo { height: 44px; }
  .public-nav nav { gap: 12px; flex: 1 1 100%; order: 3; overflow-x: auto; justify-content: flex-start; padding-bottom: 4px; }
  .public-nav nav::-webkit-scrollbar { display: none; }
  .public-nav .auth { margin-left: auto; }
  .hero {
    grid-template-columns: 1fr;
    padding: 40px 20px 32px;
    gap: 32px;
  }
  .hero h1 { font-size: 32px; }
  .hero p.lede { font-size: 15px; }

  /* Tables — compact padding; horizontal scroll already in .scroll-x */
  table.t th { padding: 8px 12px; }
  table.t td { padding: 10px 12px; font-size: 12px; }

  /* Modal — full-screen with small gutter */
  .modal,
  .modal.lg {
    width: calc(100vw - 16px);
    max-width: calc(100vw - 16px);
    max-height: calc(100vh - 16px);
  }
  .modal-head { padding: 14px 16px; }
  .modal-body { padding: 16px; }
  .modal-foot { padding: 12px 16px; }

  /* Toasts — full-width on phones */
  .toasts { left: 12px; right: 12px; top: 12px; }
  .toast { min-width: 0; max-width: none; }

  .pagination { flex-wrap: wrap; gap: 8px; }
}

/* Small phones — drop stat grid to single column, tighten further */
@media (max-width: 480px) {
  .stat-grid { grid-template-columns: 1fr; }
  .hero h1 { font-size: 26px; }
  .hero { padding: 28px 16px 24px; }
  .main { padding: 12px 12px 80px; }
  h1 { font-size: 20px; }
  .stat .val { font-size: 24px; }
  .public-nav .logo { height: 36px; }
  .topbar .icon-btn { width: 32px; height: 32px; }
}
