/* =========================================================
   RenewalHub - self-contained admin theme
   No framework, no CDN. Works offline.
   ========================================================= */

:root {
  --brand: #4f46e5;
  --brand-dark: #4338ca;
  --brand-soft: rgba(79, 70, 229, .1);
  --ink: #0f172a;
  --ink-2: #334155;
  --muted: #64748b;
  --line: #e2e8f0;
  --bg: #f1f5f9;
  --card: #ffffff;
  --sidebar: #0f172a;
  --sidebar-2: #1e293b;
  --ok: #059669;
  --ok-soft: #d1fae5;
  --warn: #d97706;
  --warn-soft: #fef3c7;
  --bad: #dc2626;
  --bad-soft: #fee2e2;
  --info: #0284c7;
  --info-soft: #e0f2fe;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 8px 24px -12px rgba(15, 23, 42, .18);
  --shadow-lg: 0 24px 60px -18px rgba(15, 23, 42, .32);
  --sidebar-w: 256px;
  --topbar-h: 62px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.55;
  color: var(--ink-2);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3, h4, h5 { margin: 0; color: var(--ink); font-weight: 650; line-height: 1.3; }
h1 { font-size: 22px; }
h2 { font-size: 18px; }
h3 { font-size: 15px; }
p { margin: 0 0 10px; }

hr { border: 0; border-top: 1px solid var(--line); margin: 18px 0; }

::selection { background: var(--brand-soft); }

/* ---------- Accessibility ---------- */

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

.skip-link {
  position: absolute; left: -999px; top: 8px; z-index: 999;
  background: #fff; color: var(--ink); padding: 10px 16px; border-radius: 8px;
}
.skip-link:focus { left: 8px; }

:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

/* =========================================================
   Shell
   ========================================================= */

/* The sidebar is position: fixed, so it is out of flow. The content area is
   simply offset by its width - no flex sizing involved, which keeps the
   content width independent of how wide its contents want to be. */
.shell { min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar);
  color: #cbd5e1;
  display: flex;
  flex-direction: column;
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 60;
  transition: transform .22s ease;
}

.sidebar__brand {
  display: flex; align-items: center; gap: 11px;
  height: var(--topbar-h);
  padding: 0 18px;
  border-bottom: 1px solid rgba(148, 163, 184, .14);
  flex: 0 0 auto;
}

.sidebar__mark {
  width: 34px; height: 34px; border-radius: 10px;
  background: linear-gradient(135deg, var(--brand), #8b5cf6);
  display: grid; place-items: center;
  color: #fff; font-weight: 700; font-size: 15px;
  flex: 0 0 auto;
}

.sidebar__name { color: #fff; font-weight: 650; font-size: 15px; letter-spacing: .1px; }
.sidebar__sub { font-size: 11px; color: #94a3b8; margin-top: -2px; }

.sidebar__nav { flex: 1 1 auto; overflow-y: auto; padding: 14px 10px 20px; }
.sidebar__nav::-webkit-scrollbar { width: 6px; }
.sidebar__nav::-webkit-scrollbar-thumb { background: rgba(148, 163, 184, .3); border-radius: 3px; }

.nav__label {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: .09em;
  color: #64748b; font-weight: 700; padding: 16px 12px 7px;
}

.nav__item {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 12px; margin-bottom: 2px;
  border-radius: var(--radius-sm);
  color: #cbd5e1; font-weight: 500; font-size: 13.5px;
  transition: background .15s, color .15s;
}
.nav__item:hover { background: rgba(148, 163, 184, .12); color: #fff; text-decoration: none; }
.nav__item.active { background: var(--brand); color: #fff; box-shadow: 0 6px 16px -6px rgba(79, 70, 229, .8); }
.nav__item.active .nav__ico { opacity: 1; }
.nav__ico { width: 18px; height: 18px; flex: 0 0 18px; opacity: .8; }
.nav__count {
  margin-left: auto; background: rgba(255, 255, 255, .16);
  border-radius: 999px; padding: 1px 7px; font-size: 11px; font-weight: 700;
}
.nav__item.active .nav__count { background: rgba(255, 255, 255, .25); }
.nav__count--bad { background: var(--bad); color: #fff; }

.sidebar__foot {
  flex: 0 0 auto; padding: 12px 14px;
  border-top: 1px solid rgba(148, 163, 184, .14);
  font-size: 11.5px; color: #64748b;
}

.main {
  margin-left: var(--sidebar-w);
  min-width: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ---------- Topbar ---------- */

.topbar {
  height: var(--topbar-h);
  background: rgba(255, 255, 255, .88);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 12px;
  padding: 0 20px;
  position: sticky; top: 0; z-index: 40;
}

.topbar__title { font-weight: 650; color: var(--ink); font-size: 15px; }
.topbar__spacer { flex: 1 1 auto; }

.icon-btn {
  width: 38px; height: 38px; border-radius: 10px;
  border: 1px solid var(--line); background: #fff;
  display: grid; place-items: center; cursor: pointer;
  color: var(--ink-2); position: relative;
  transition: background .15s, border-color .15s;
}
.icon-btn:hover { background: var(--bg); border-color: #cbd5e1; }
.icon-btn svg { width: 18px; height: 18px; }

.icon-btn__dot {
  position: absolute; top: 6px; right: 6px;
  min-width: 16px; height: 16px; padding: 0 4px;
  background: var(--bad); color: #fff;
  border-radius: 999px; font-size: 10px; font-weight: 700;
  display: grid; place-items: center; line-height: 1;
}

.burger { display: none; }

.who {
  display: flex; align-items: center; gap: 10px;
  padding: 5px 10px 5px 5px; border-radius: 999px;
  border: 1px solid var(--line); background: #fff; cursor: pointer;
}
.who:hover { background: var(--bg); }
.who__name { font-size: 13px; font-weight: 600; color: var(--ink); }
.who__role { font-size: 11px; color: var(--muted); margin-top: -3px; }

.avatar {
  width: 30px; height: 30px; border-radius: 50%;
  background: linear-gradient(135deg, var(--brand), #8b5cf6);
  color: #fff; font-size: 12px; font-weight: 700;
  display: grid; place-items: center; flex: 0 0 auto;
}
.avatar--lg { width: 60px; height: 60px; font-size: 21px; }
.avatar--sm { width: 26px; height: 26px; font-size: 10.5px; }

/* ---------- Dropdown ---------- */

.pop { position: relative; }
.pop__panel {
  position: absolute; right: 0; top: calc(100% + 8px);
  min-width: 230px; background: #fff;
  border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow-lg); padding: 6px;
  display: none; z-index: 70;
}
.pop__panel--wide { min-width: 340px; }
.pop.open .pop__panel { display: block; }

.pop__item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 11px; border-radius: var(--radius-sm);
  color: var(--ink-2); font-size: 13.5px; width: 100%;
  background: none; border: 0; text-align: left; cursor: pointer;
  font-family: inherit;
}
.pop__item:hover { background: var(--bg); text-decoration: none; color: var(--ink); }
.pop__item svg { width: 16px; height: 16px; opacity: .7; }
.pop__sep { height: 1px; background: var(--line); margin: 5px 3px; }
.pop__head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 9px 11px 7px; font-size: 12px; font-weight: 700;
  color: var(--muted); text-transform: uppercase; letter-spacing: .05em;
}

.notif-list { max-height: 340px; overflow-y: auto; }
.notif {
  display: flex; gap: 10px; padding: 10px 11px;
  border-radius: var(--radius-sm); color: var(--ink-2);
}
.notif:hover { background: var(--bg); text-decoration: none; }
.notif--unread { background: var(--brand-soft); }
.notif__dot { width: 8px; height: 8px; border-radius: 50%; background: var(--brand); margin-top: 6px; flex: 0 0 8px; }
.notif__dot--warn { background: var(--warn); }
.notif__dot--bad { background: var(--bad); }
.notif__title { font-size: 13px; font-weight: 600; color: var(--ink); }
.notif__meta { font-size: 11.5px; color: var(--muted); }

/* =========================================================
   Page
   ========================================================= */

.page {
  padding: 22px;
  flex: 1 1 auto;
  max-width: 1560px;
  width: 100%;
  /* Hard stop: nothing inside a page may push the whole panel sideways.
     clip (not hidden) leaves the vertical axis visible so the sticky
     topbar and the dropdown panels keep working. */
  min-width: 0;
  overflow-x: clip;
}

/* Fallback for browsers without overflow: clip. */
@supports not (overflow-x: clip) {
  .page { overflow-x: hidden; }
}

.page__head {
  display: flex; align-items: flex-start; gap: 16px;
  flex-wrap: wrap; margin-bottom: 18px;
}
.page__head h1 { margin-bottom: 3px; }
.page__lede { color: var(--muted); font-size: 13.5px; }
.page__actions { margin-left: auto; display: flex; gap: 9px; flex-wrap: wrap; }

.crumbs { font-size: 12.5px; color: var(--muted); margin-bottom: 6px; }
.crumbs a { color: var(--muted); }

/* ---------- Grid ---------- */

.grid { display: grid; gap: 16px; }
.grid--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid--4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid--5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.grid--sidebar { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.grid--form { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.span-2 { grid-column: span 2; }
.span-full { grid-column: 1 / -1; }

/* ---------- Card ---------- */

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  /* Lets the card shrink inside a grid or flex parent instead of being
     widened by a wide table. */
  min-width: 0;
  max-width: 100%;
}
.card__head {
  display: flex; align-items: center; gap: 12px;
  padding: 15px 18px; border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}
.card__head h2, .card__head h3 { margin: 0; }
.card__head .card__actions { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.card__body { padding: 18px; }
.card__body--tight { padding: 0; }
.card__foot {
  padding: 13px 18px; border-top: 1px solid var(--line);
  background: #fbfcfe; border-radius: 0 0 var(--radius) var(--radius);
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
}
.card__note { font-size: 12.5px; color: var(--muted); margin: 4px 0 0; }

/* ---------- Stat tiles ---------- */

.tile {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 16px 17px;
  box-shadow: var(--shadow); position: relative; overflow: hidden;
  display: block; color: inherit;
}
.tile:hover { text-decoration: none; border-color: #cbd5e1; }
.tile__top { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.tile__ico {
  width: 36px; height: 36px; border-radius: 10px;
  display: grid; place-items: center; flex: 0 0 auto;
  background: var(--brand-soft); color: var(--brand);
}
.tile__ico svg { width: 18px; height: 18px; }
.tile__ico--ok { background: var(--ok-soft); color: var(--ok); }
.tile__ico--warn { background: var(--warn-soft); color: var(--warn); }
.tile__ico--bad { background: var(--bad-soft); color: var(--bad); }
.tile__ico--info { background: var(--info-soft); color: var(--info); }
.tile__label { font-size: 12.5px; color: var(--muted); font-weight: 550; }
.tile__value { font-size: 27px; font-weight: 700; color: var(--ink); line-height: 1.15; letter-spacing: -.5px; }
.tile__foot { font-size: 12px; color: var(--muted); margin-top: 5px; }
.tile__foot strong { color: var(--ink-2); }

/* =========================================================
   Buttons
   ========================================================= */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 38px; padding: 0 15px;
  border-radius: var(--radius-sm); border: 1px solid transparent;
  background: var(--brand); color: #fff;
  font-family: inherit; font-size: 13.5px; font-weight: 600;
  cursor: pointer; white-space: nowrap;
  transition: background .15s, box-shadow .15s, border-color .15s, transform .06s;
}
.btn:hover { background: var(--brand-dark); text-decoration: none; color: #fff; }
.btn:active { transform: translateY(1px); }
.btn svg { width: 16px; height: 16px; }
.btn[disabled], .btn.is-busy { opacity: .6; cursor: not-allowed; pointer-events: none; }

.btn--ghost { background: #fff; color: var(--ink-2); border-color: var(--line); }
.btn--ghost:hover { background: var(--bg); color: var(--ink); border-color: #cbd5e1; }
.btn--soft { background: var(--brand-soft); color: var(--brand); }
.btn--soft:hover { background: rgba(79, 70, 229, .18); color: var(--brand-dark); }
.btn--danger { background: var(--bad); }
.btn--danger:hover { background: #b91c1c; }
.btn--ok { background: var(--ok); }
.btn--ok:hover { background: #047857; }
.btn--sm { height: 31px; padding: 0 11px; font-size: 12.5px; border-radius: 8px; }
.btn--sm svg { width: 14px; height: 14px; }
.btn--icon { width: 31px; padding: 0; }
.btn--block { width: 100%; }
.btn--lg { height: 44px; padding: 0 20px; font-size: 14.5px; }

.btn-row { display: flex; gap: 9px; flex-wrap: wrap; align-items: center; }

/* =========================================================
   Forms
   ========================================================= */

.field { margin-bottom: 15px; }
.field--flush { margin-bottom: 0; }

.label {
  display: block; font-size: 12.5px; font-weight: 600;
  color: var(--ink); margin-bottom: 6px;
}
.label .req { color: var(--bad); }
.label__hint { font-weight: 400; color: var(--muted); }

.input, .select, .textarea {
  width: 100%; height: 39px; padding: 0 12px;
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: #fff; color: var(--ink); font-family: inherit; font-size: 13.5px;
  transition: border-color .15s, box-shadow .15s;
}
.textarea { height: auto; min-height: 84px; padding: 10px 12px; line-height: 1.55; resize: vertical; }
.input:focus, .select:focus, .textarea:focus {
  outline: none; border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-soft);
}
.input[readonly] { background: #f8fafc; color: var(--muted); }
.input.is-bad, .select.is-bad, .textarea.is-bad { border-color: var(--bad); }
.input::placeholder, .textarea::placeholder { color: #94a3b8; }

.select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2.2' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center; background-size: 16px;
  padding-right: 32px;
}

.help { font-size: 12px; color: var(--muted); margin-top: 5px; }
.error-text { font-size: 12px; color: var(--bad); margin-top: 5px; display: none; }
.error-text.show { display: block; }

.input-group { display: flex; }
.input-group .input { border-radius: var(--radius-sm) 0 0 var(--radius-sm); }
.input-group .btn { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; height: 39px; }

.check {
  display: flex; align-items: flex-start; gap: 9px;
  font-size: 13.5px; cursor: pointer; margin-bottom: 9px;
}
.check input { width: 17px; height: 17px; margin: 2px 0 0; accent-color: var(--brand); flex: 0 0 17px; cursor: pointer; }
.check__text strong { display: block; color: var(--ink); font-weight: 600; }
.check__text span { color: var(--muted); font-size: 12.5px; }

/* Segmented radio group */
.seg { display: flex; gap: 6px; flex-wrap: wrap; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg label {
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 8px 13px; font-size: 13px; font-weight: 550;
  cursor: pointer; background: #fff; color: var(--ink-2);
  display: flex; align-items: center; gap: 7px;
}
.seg label:hover { border-color: #cbd5e1; background: var(--bg); }
.seg input:checked + label {
  border-color: var(--brand); background: var(--brand-soft);
  color: var(--brand-dark); font-weight: 650;
}
.seg input:focus-visible + label { outline: 2px solid var(--brand); outline-offset: 2px; }

/* Toggle */
.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; }
.switch input { position: absolute; opacity: 0; }
.switch__track {
  width: 40px; height: 22px; border-radius: 999px;
  background: #cbd5e1; position: relative; transition: background .18s; flex: 0 0 40px;
}
.switch__track::after {
  content: ""; position: absolute; top: 3px; left: 3px;
  width: 16px; height: 16px; border-radius: 50%;
  background: #fff; transition: transform .18s;
  box-shadow: 0 1px 3px rgba(15, 23, 42, .3);
}
.switch input:checked + .switch__track { background: var(--brand); }
.switch input:checked + .switch__track::after { transform: translateX(18px); }
.switch input:focus-visible + .switch__track { outline: 2px solid var(--brand); outline-offset: 2px; }

/* =========================================================
   Toolbar / filters
   ========================================================= */

.toolbar {
  display: flex; gap: 9px; align-items: center; flex-wrap: wrap;
  padding: 13px 18px; border-bottom: 1px solid var(--line);
}
.toolbar .input, .toolbar .select { height: 36px; }
.toolbar__grow { flex: 1 1 220px; min-width: 180px; }
.toolbar__right { margin-left: auto; display: flex; gap: 9px; align-items: center; flex-wrap: wrap; }

/* A label glued to its field. Keeps the pair on one line so a wrapping
   toolbar can never leave the caption stranded above or below its input. */
.field-inline {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  flex: 0 0 auto;
  white-space: nowrap;
}
.field-inline > label {
  margin: 0;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--muted);
}
.field-inline .input,
.field-inline .select { width: auto; min-width: 145px; }

/* Date inputs render at different intrinsic heights across browsers, which
   is what makes a row of them look uneven. Pin them to the field height. */
input[type="date"].input,
input[type="month"].input,
input[type="time"].input {
  height: 39px;
  min-height: 39px;
  line-height: normal;
  padding-right: 10px;
  font-family: inherit;
}
.toolbar input[type="date"].input { height: 36px; min-height: 36px; }
input[type="date"].input::-webkit-calendar-picker-indicator { opacity: .55; cursor: pointer; }
input[type="date"].input::-webkit-calendar-picker-indicator:hover { opacity: 1; }
input[type="date"].input::-webkit-datetime-edit { padding: 0; }

.search { position: relative; flex: 1 1 240px; min-width: 190px; }
.search .input { padding-left: 35px; }
.search svg {
  position: absolute; left: 11px; top: 50%; transform: translateY(-50%);
  width: 16px; height: 16px; color: var(--muted); pointer-events: none;
}

.chips { display: flex; gap: 7px; flex-wrap: wrap; }
.chip {
  border: 1px solid var(--line); background: #fff;
  border-radius: 999px; padding: 5px 13px;
  font-size: 12.5px; font-weight: 550; color: var(--ink-2);
  cursor: pointer; font-family: inherit;
  display: inline-flex; align-items: center; gap: 6px;
}
.chip:hover { background: var(--bg); border-color: #cbd5e1; }
.chip.active { background: var(--ink); border-color: var(--ink); color: #fff; }
.chip__n {
  background: var(--bg); color: var(--ink-2);
  border-radius: 999px; padding: 0 6px; font-size: 11px; font-weight: 700;
}
.chip.active .chip__n { background: rgba(255, 255, 255, .22); color: #fff; }

/* =========================================================
   Table
   ========================================================= */

/* The only element allowed to scroll sideways. Everything wide lives here. */
.table-wrap {
  overflow-x: auto;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  -webkit-overflow-scrolling: touch;
}

/* A visible slim scrollbar, so it is obvious there is more to the right. */
.table-wrap::-webkit-scrollbar { height: 9px; }
.table-wrap::-webkit-scrollbar-track { background: #f1f5f9; border-radius: 0 0 var(--radius) var(--radius); }
.table-wrap::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 999px; }
.table-wrap::-webkit-scrollbar-thumb:hover { background: #94a3b8; }
.table-wrap { scrollbar-width: thin; scrollbar-color: #cbd5e1 #f1f5f9; }

.table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13.5px;
  /* Columns size from content, but long values are broken by the rules
     below rather than stretching the table. */
  table-layout: auto;
}
.table th, .table td {
  padding: 12px 14px;
  text-align: left;
  vertical-align: middle;
  /* Long domains, URLs and email addresses must break instead of forcing
     a column hundreds of pixels wide. */
  overflow-wrap: anywhere;
  word-break: break-word;
}
/* Keep the widest free-text column in check. */
.table td.col-main { max-width: 330px; min-width: 190px; }
.table td.col-text { max-width: 220px; }
.table .cell-sub { overflow-wrap: anywhere; }
.table thead th {
  background: #f8fafc; color: var(--muted);
  font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em;
  border-bottom: 1px solid var(--line); white-space: nowrap;
}
.table tbody tr { border-bottom: 1px solid #f1f5f9; }
.table tbody tr:last-child { border-bottom: 0; }
.table tbody tr:hover { background: #fbfcfe; }
.table tbody tr.is-picked { background: var(--brand-soft); }
.table td.num, .table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.table td.mid, .table th.mid { text-align: center; }
.table .nowrap { white-space: nowrap; }
.table__sort { cursor: pointer; user-select: none; }
.table__sort:hover { color: var(--ink); }
.table__sort::after { content: ""; display: inline-block; width: 0; }
.table__sort.asc::after { content: " \2191"; }
.table__sort.desc::after { content: " \2193"; }
.table__pick { width: 38px; }
.table__pick input { width: 16px; height: 16px; accent-color: var(--brand); cursor: pointer; }

.cell-main { font-weight: 600; color: var(--ink); display: block; }
.cell-sub { font-size: 12px; color: var(--muted); display: block; }

.row-actions { display: flex; gap: 5px; justify-content: flex-end; }

.pager {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 12px 18px; border-top: 1px solid var(--line); font-size: 13px; color: var(--muted);
}
.pager__right { margin-left: auto; display: flex; gap: 6px; align-items: center; }

.empty { padding: 52px 20px; text-align: center; color: var(--muted); }
.empty svg { width: 42px; height: 42px; opacity: .35; margin-bottom: 12px; }
.empty h3 { margin-bottom: 5px; }

.loading { padding: 40px; text-align: center; color: var(--muted); }
.spin {
  display: inline-block; width: 22px; height: 22px;
  border: 2.5px solid var(--line); border-top-color: var(--brand);
  border-radius: 50%; animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* =========================================================
   Badges / pills
   ========================================================= */

.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px; border-radius: 999px;
  font-size: 11.5px; font-weight: 650; white-space: nowrap;
  background: var(--bg); color: var(--ink-2);
}
.badge--success { background: var(--ok-soft); color: #065f46; }
.badge--warning { background: var(--warn-soft); color: #92400e; }
.badge--danger { background: var(--bad-soft); color: #991b1b; }
.badge--info { background: var(--info-soft); color: #075985; }
.badge--muted { background: #e2e8f0; color: #475569; }
.badge--brand { background: var(--brand-soft); color: var(--brand-dark); }
.badge__dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

.pill-side {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 11px; font-weight: 650; padding: 2px 7px;
  border-radius: 6px; background: #eef2ff; color: #3730a3;
}
.pill-side--our { background: #fdf2f8; color: #9d174d; }
.pill-side--both { background: #ecfeff; color: #155e75; }

.meter { height: 6px; border-radius: 999px; background: var(--line); overflow: hidden; }
.meter__bar { height: 100%; border-radius: 999px; background: var(--brand); }
.meter__bar--warn { background: var(--warn); }
.meter__bar--bad { background: var(--bad); }
.meter__bar--ok { background: var(--ok); }

/* =========================================================
   Modal / drawer
   ========================================================= */

.scrim {
  position: fixed; inset: 0; background: rgba(15, 23, 42, .55);
  backdrop-filter: blur(2px); z-index: 90;
  display: none; align-items: flex-start; justify-content: center;
  padding: 28px 16px; overflow-y: auto;
}
.scrim.open { display: flex; }

.modal {
  background: #fff; border-radius: 16px; box-shadow: var(--shadow-lg);
  width: 100%; max-width: 560px; animation: pop .18s ease;
  margin: auto;
}
.modal--wide { max-width: 880px; }
.modal--xl { max-width: 1120px; }
@keyframes pop { from { opacity: 0; transform: translateY(-8px) scale(.98); } }

.modal__head {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 18px 20px; border-bottom: 1px solid var(--line);
}
.modal__head h2 { font-size: 17px; }
.modal__head p { margin: 3px 0 0; font-size: 13px; color: var(--muted); }
.modal__x {
  margin-left: auto; background: none; border: 0; cursor: pointer;
  color: var(--muted); width: 32px; height: 32px; border-radius: 8px;
  display: grid; place-items: center; flex: 0 0 32px;
}
.modal__x:hover { background: var(--bg); color: var(--ink); }
.modal__x svg { width: 18px; height: 18px; }
.modal__body { padding: 20px; max-height: 68vh; overflow-y: auto; }
.modal__foot {
  padding: 15px 20px; border-top: 1px solid var(--line);
  display: flex; gap: 9px; justify-content: flex-end; flex-wrap: wrap;
  background: #fbfcfe; border-radius: 0 0 16px 16px;
}
.modal__foot .left { margin-right: auto; }

/* =========================================================
   Toast
   ========================================================= */

.toasts {
  position: fixed; bottom: 20px; right: 20px; z-index: 120;
  display: flex; flex-direction: column; gap: 9px; max-width: 380px;
}
.toast {
  background: #fff; border: 1px solid var(--line);
  border-left: 4px solid var(--brand);
  border-radius: var(--radius-sm); box-shadow: var(--shadow-lg);
  padding: 12px 14px; display: flex; gap: 10px; align-items: flex-start;
  animation: slide .2s ease;
}
@keyframes slide { from { opacity: 0; transform: translateX(20px); } }
.toast--ok { border-left-color: var(--ok); }
.toast--bad { border-left-color: var(--bad); }
.toast--warn { border-left-color: var(--warn); }
.toast__ico { flex: 0 0 18px; margin-top: 1px; }
.toast__ico svg { width: 18px; height: 18px; }
.toast--ok .toast__ico { color: var(--ok); }
.toast--bad .toast__ico { color: var(--bad); }
.toast--warn .toast__ico { color: var(--warn); }
.toast__body { flex: 1 1 auto; font-size: 13.5px; color: var(--ink-2); }
.toast__body strong { display: block; color: var(--ink); }
.toast__x { background: none; border: 0; cursor: pointer; color: var(--muted); padding: 0; }

/* =========================================================
   Misc components
   ========================================================= */

.tabs {
  display: flex; gap: 3px; border-bottom: 1px solid var(--line);
  margin-bottom: 18px; overflow-x: auto;
}
.tabs a {
  padding: 10px 15px; font-size: 13.5px; font-weight: 600;
  color: var(--muted); border-bottom: 2px solid transparent; white-space: nowrap;
}
.tabs a:hover { color: var(--ink); text-decoration: none; }
.tabs a.active { color: var(--brand); border-bottom-color: var(--brand); }

.kv { display: grid; grid-template-columns: minmax(120px, 34%) 1fr; gap: 9px 14px; font-size: 13.5px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; color: var(--ink); font-weight: 550; }

.timeline { position: relative; padding-left: 26px; }
.timeline::before {
  content: ""; position: absolute; left: 7px; top: 6px; bottom: 6px;
  width: 2px; background: var(--line);
}
.tl { position: relative; padding-bottom: 18px; }
.tl:last-child { padding-bottom: 0; }
.tl::before {
  content: ""; position: absolute; left: -23px; top: 5px;
  width: 12px; height: 12px; border-radius: 50%;
  background: #fff; border: 2.5px solid var(--brand);
}
.tl--our::before { border-color: #db2777; }
.tl--pending::before { border-color: var(--warn); background: var(--warn-soft); }
.tl__head { display: flex; gap: 9px; align-items: center; flex-wrap: wrap; }
.tl__title { font-weight: 650; color: var(--ink); font-size: 13.5px; }
.tl__meta { font-size: 12px; color: var(--muted); margin-top: 2px; }

.note {
  border-radius: var(--radius-sm); padding: 12px 14px;
  font-size: 13px; display: flex; gap: 10px; align-items: flex-start;
  background: var(--info-soft); color: #075985; border: 1px solid #bae6fd;
}
.note svg { width: 17px; height: 17px; flex: 0 0 17px; margin-top: 1px; }
.note--warn { background: var(--warn-soft); color: #92400e; border-color: #fde68a; }
.note--bad { background: var(--bad-soft); color: #991b1b; border-color: #fecaca; }
.note--ok { background: var(--ok-soft); color: #065f46; border-color: #a7f3d0; }
.note--plain { background: var(--bg); color: var(--ink-2); border-color: var(--line); }
.note p:last-child { margin-bottom: 0; }

.code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12.5px; background: #0f172a; color: #e2e8f0;
  padding: 12px 14px; border-radius: var(--radius-sm);
  overflow-x: auto; white-space: pre; line-height: 1.6;
}
code.inline {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  background: var(--bg); padding: 1px 6px; border-radius: 5px; font-size: 12.5px; color: var(--ink);
}

.copy-row { display: flex; gap: 8px; align-items: center; }
.copy-row .input { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12.5px; }

/* Charts (inline SVG, no library) */
.chart { width: 100%; height: 220px; display: block; }
.chart-legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 12.5px; color: var(--muted); margin-top: 10px; }
.chart-legend span { display: inline-flex; align-items: center; gap: 6px; }
.chart-legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }

.bars { display: flex; flex-direction: column; gap: 11px; }
.bar-row { display: grid; grid-template-columns: minmax(90px, 30%) 1fr auto; gap: 11px; align-items: center; font-size: 13px; }
.bar-row__name { color: var(--ink); font-weight: 550; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-row__n { color: var(--muted); font-variant-numeric: tabular-nums; font-size: 12.5px; }

/* Login */
.auth {
  min-height: 100vh; display: grid; grid-template-columns: 1fr 1fr;
  background: var(--bg);
}
.auth__brand {
  background: linear-gradient(150deg, #1e1b4b 0%, #312e81 45%, #4f46e5 100%);
  color: #fff; padding: 46px; display: flex; flex-direction: column;
  position: relative; overflow: hidden;
}
.auth__brand::after {
  content: ""; position: absolute; right: -120px; bottom: -140px;
  width: 380px; height: 380px; border-radius: 50%;
  background: rgba(255, 255, 255, .07);
}
.auth__brand h1 { color: #fff; font-size: 30px; line-height: 1.25; margin-bottom: 12px; letter-spacing: -.4px; }
.auth__brand p { color: rgba(255, 255, 255, .78); font-size: 14.5px; max-width: 420px; }
.auth__points { margin-top: auto; display: flex; flex-direction: column; gap: 13px; position: relative; }
.auth__point { display: flex; gap: 11px; align-items: flex-start; font-size: 13.5px; color: rgba(255, 255, 255, .88); }
.auth__point svg { width: 19px; height: 19px; flex: 0 0 19px; margin-top: 1px; color: #a5b4fc; }
.auth__form { display: grid; place-items: center; padding: 40px 24px; }
.auth__card { width: 100%; max-width: 388px; }
.auth__logo { display: flex; align-items: center; gap: 11px; margin-bottom: 26px; }

/* Utilities */
.mt-0 { margin-top: 0; } .mt-1 { margin-top: 8px; } .mt-2 { margin-top: 16px; } .mt-3 { margin-top: 24px; }
.mb-0 { margin-bottom: 0; } .mb-1 { margin-bottom: 8px; } .mb-2 { margin-bottom: 16px; } .mb-3 { margin-bottom: 24px; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.tiny { font-size: 11.5px; }
.strong { font-weight: 650; color: var(--ink); }
.right { text-align: right; }
.center { text-align: center; }
.nowrap { white-space: nowrap; }
.flex { display: flex; gap: 10px; align-items: center; }
.flex-between { display: flex; gap: 10px; align-items: center; justify-content: space-between; }
.flex-wrap { flex-wrap: wrap; }
.gap-sm { gap: 6px; }
.hidden { display: none !important; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.mono { font-family: ui-monospace, Menlo, Consolas, monospace; font-variant-numeric: tabular-nums; }
.text-bad { color: var(--bad); } .text-ok { color: var(--ok); } .text-warn { color: var(--warn); }

/* =========================================================
   Responsive
   ========================================================= */

@media (max-width: 1200px) {
  .grid--5 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .grid--4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid--sidebar { grid-template-columns: 1fr; }
}

@media (max-width: 980px) {
  .sidebar { transform: translateX(-100%); box-shadow: var(--shadow-lg); }
  .sidebar.open { transform: translateX(0); }
  .main { margin-left: 0; }
  .burger { display: grid; }
  .grid--3, .grid--form { grid-template-columns: 1fr; }
  .span-2 { grid-column: span 1; }
  .sidebar-scrim {
    position: fixed; inset: 0; background: rgba(15, 23, 42, .5); z-index: 55; display: none;
  }
  .sidebar-scrim.open { display: block; }
}

@media (max-width: 720px) {
  .page { padding: 15px; }
  .grid--2, .grid--4, .grid--5 { grid-template-columns: 1fr; }
  .who__name, .who__role { display: none; }
  .who { padding: 4px; border: 0; background: none; }
  .page__actions { width: 100%; }
  .page__actions .btn { flex: 1 1 auto; }
  .card__head { padding: 13px 14px; }
  .card__body { padding: 14px; }
  .toolbar { padding: 12px 14px; }
  .table th, .table td { padding: 10px 11px; }
  .kv { grid-template-columns: 1fr; gap: 3px 0; }
  .kv dd { margin-bottom: 9px; }
  .auth { grid-template-columns: 1fr; }
  .auth__brand { display: none; }
  .modal__body { max-height: 62vh; }
  .toasts { left: 12px; right: 12px; bottom: 12px; max-width: none; }
}

@media print {
  .sidebar, .topbar, .page__actions, .toolbar, .pager, .row-actions { display: none !important; }
  .main { margin-left: 0; }
  .card { box-shadow: none; border-color: #cbd5e1; }
  body { background: #fff; }
}
