/* ==========================================================================
   UX FLOW — Design System CSS
   SaaS CRM de pós-venda para corretores de seguros
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@400;500&family=Roboto:wght@400;500;600&display=swap');

:root {
  /* Neutros */
  --bg: #f4f7fa;
  --surface: #ffffff;
  --fg: #1d3c54;
  --muted: #5c6b78;
  --border: #e0e6eb;

  /* Acento */
  --accent: #24bce4;
  --accent-strong: #0089ad;

  /* Marca */
  --navy: #061f36;
  --navy-deep: #1d3c54;

  /* Semântica */
  --success: #1a8f4c;
  --warn: #c47a12;
  --danger: #c0392b;

  /* Tipografia */
  --font-display: "Roboto", "Segoe UI", system-ui, sans-serif;
  --font-body: "Roboto", "Segoe UI", system-ui, sans-serif;
  --font-mono: "IBM Plex Mono", Consolas, ui-monospace, monospace;

  /* Layout */
  --sidebar-w: 248px;
  --top-h: 56px;
  --radius: 10px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(29,60,84,.06), 0 8px 24px rgba(29,60,84,.06);
  --focus: 0 0 0 3px rgba(36,188,228,.28);
}

@media (min-width: 1440px) {
  :root { --sidebar-w: 260px; }
}

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font-body);
  font-size: 14px;
  color: var(--fg);
  background: var(--bg);
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3, h4, p { margin: 0; }
ul { list-style: none; margin: 0; padding: 0; }
svg { display: block; }
.mono { font-family: var(--font-mono); }

button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, a:focus-visible {
  outline: 2px solid var(--accent-strong);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}

/* ---------- App shell ---------- */
.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
}

.main { display: flex; flex-direction: column; min-width: 0; }

.content {
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 20px;
}

/* ---------- Sidebar ---------- */
.sidebar {
  background: var(--navy);
  color: #e8f1f7;
  display: flex;
  flex-direction: column;
  padding: 16px 12px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
.nav-scrim { display: none; position: fixed; inset: 0; background: rgba(6,31,54,.4); z-index: 25; }
.side-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 8px 18px;
  border-bottom: 1px solid rgba(255,255,255,.1);
  margin-bottom: 10px;
}
.side-brand .logo-badge,
.logo-badge {
  width: 40px; height: 40px;
  border-radius: 10px;
  object-fit: cover;
  flex-shrink: 0;
}
.side-brand .bt { display: flex; flex-direction: column; line-height: 1.25; }
.side-brand .bt strong { font-size: 16px; font-weight: 800; letter-spacing: 0.01em; }

.brand-ux, .brand-flow {
  font-family: var(--font-display);
  text-transform: uppercase;
}
.brand-ux {
  background: linear-gradient(135deg, #6fe3ff 0%, #2f7dff 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.brand-flow { color: #fff; }

.nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  font-size: 12.5px;
  font-weight: 500;
  color: rgba(232,241,247,.78);
  min-height: 36px;
}
.nav a:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav a.active { background: rgba(36,188,228,.2); color: #fff; font-weight: 600; }
.nav a svg { width: 17px; height: 17px; flex-shrink: 0; stroke: currentColor; }
.nav-label {
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(232,241,247,.4);
  padding: 14px 10px 4px;
}
.nav a.nav-cta { background: var(--accent); color: var(--navy-deep); font-weight: 700; margin-bottom: 4px; }
.nav a.nav-cta svg { stroke: var(--navy-deep); }
.nav a.nav-cta:hover { background: var(--accent); filter: brightness(1.08); color: var(--navy-deep); }
.nav a.nav-cta.active { background: var(--accent); color: var(--navy-deep); }
.nav a.nav-chat { background: rgba(36,188,228,.12); border: 1px solid rgba(36,188,228,.35); margin-top: 6px; }
.nav a.nav-dir { background: rgba(255,255,255,.05); border: 1px solid rgba(255,255,255,.08); font-weight: 600; }
.nav a.nav-config { margin-top: auto; border-top: 1px solid rgba(255,255,255,.1); border-radius: 0; padding-top: 14px; }
.nav .badge-count {
  margin-left: auto;
  background: var(--accent);
  color: var(--navy);
  font-size: 10px;
  font-weight: 700;
  min-width: 18px;
  height: 18px;
  border-radius: 99px;
  display: grid;
  place-items: center;
  padding: 0 5px;
}

/* ---------- Topbar ---------- */
.topbar {
  height: var(--top-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 20px;
  position: sticky;
  top: 0;
  z-index: 15;
}
.menu-btn {
  display: none;
  width: 34px; height: 34px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  align-items: center;
  justify-content: center;
  font-size: 18px;
}
.search {
  flex: 1;
  max-width: 480px;
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0 12px;
  height: 36px;
}
.search svg { width: 15px; height: 15px; stroke: var(--muted); flex-shrink: 0; }
.search input {
  border: none;
  background: transparent;
  outline: none;
  width: 100%;
  font-size: 13px;
}
.topbar-spacer { flex: 1; }
.pill {
  font-size: 12px;
  font-weight: 600;
  font-family: var(--font-mono);
  color: var(--muted);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 5px 12px;
  white-space: nowrap;
}
.avatar {
  width: 32px; height: 32px;
  border-radius: 99px;
  background: var(--navy);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 11.5px;
  font-weight: 700;
  flex-shrink: 0;
}

/* ---------- Page head ---------- */
.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.page-head h1 {
  font-size: clamp(22px, 2.5vw, 28px);
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.15;
}
.page-head p { color: var(--muted); font-size: 13.5px; margin-top: 4px; max-width: 62ch; }
.filters { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.crumb { font-size: 12.5px; color: var(--muted); margin-bottom: -4px; }
.crumb a:hover { color: var(--accent-strong); }
.crumb strong { color: var(--fg); }

/* ---------- Buttons ---------- */
.btn {
  height: 36px;
  padding: 0 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 13px;
  font-weight: 550;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}
.btn:hover { background: var(--bg); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--navy-deep); font-weight: 600; }
.btn-primary:hover { background: var(--accent-strong); border-color: var(--accent-strong); color: #fff; }
.btn-navy { background: var(--navy); border-color: var(--navy); color: #fff; font-weight: 600; }
.btn-navy:hover { background: var(--navy-deep); }
.btn-sm { height: 30px; padding: 0 10px; font-size: 12.5px; border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--surface); }
.btn-sm.on { background: rgba(36,188,228,.16); border-color: var(--accent); color: var(--accent-strong); font-weight: 600; }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-danger { color: var(--danger); border-color: rgba(192,57,43,.3); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn svg { width: 15px; height: 15px; stroke: currentColor; }

/* ---------- KPI ---------- */
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.kpi {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  box-shadow: var(--shadow);
}
.kpi .label { font-size: 11.5px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted); }
.kpi .value { font-family: var(--font-mono); font-size: 24px; font-weight: 500; letter-spacing: -0.02em; line-height: 1.1; }
.kpi .delta { font-size: 12px; font-weight: 550; }
.kpi .delta.up { color: var(--success); }
.kpi .delta.down { color: var(--danger); }
.kpi.hero, .kpi.accent-card { background: var(--navy); color: #fff; border-color: var(--navy); }
.kpi.hero .label, .kpi.accent-card .label { color: rgba(232,241,247,.6); }
.kpi.hero .delta, .kpi.accent-card .delta { color: var(--accent); }

/* ---------- Panel ---------- */
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.panel-h { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; gap: 10px; flex-wrap: wrap; }
.panel-h h2 { font-size: 15px; font-weight: 600; letter-spacing: -0.01em; }
.panel-h span { font-size: 12px; color: var(--muted); }
.panel-b { padding-top: 2px; }

.row-2 { display: grid; grid-template-columns: 1.4fr 1fr; gap: 14px; }
.body-grid { display: grid; grid-template-columns: 1.4fr 1fr; gap: 14px; }
.subnav-grid { display: grid; grid-template-columns: 200px 1fr; gap: 14px; }
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }

/* ---------- Table ---------- */
.table-wrap { overflow: auto; border-radius: var(--radius-sm); border: 1px solid var(--border); }
table { width: 100%; border-collapse: collapse; }
thead { position: sticky; top: 0; background: var(--bg); z-index: 1; }
th {
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.065em;
  text-transform: uppercase;
  color: var(--muted);
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
td { font-size: 13px; padding: 11px 12px; border-bottom: 1px solid var(--border); }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: color-mix(in srgb, var(--accent) 4%, #fff); }
tbody tr.clickable { cursor: pointer; }

/* ---------- Tags / badges ---------- */
.tag {
  display: inline-flex; align-items: center;
  height: 22px; padding: 0 9px;
  border-radius: 999px;
  font-size: 11.5px; font-weight: 600;
  background: rgba(0,0,0,.05);
}
.tag.ok { background: rgba(26,143,76,.12); color: var(--success); }
.tag.warn { background: rgba(196,122,18,.12); color: var(--warn); }
.tag.off { background: rgba(92,107,120,.12); color: var(--muted); }
.tag.pf { background: rgba(0,137,173,.12); color: var(--accent-strong); }
.tag.pj { background: rgba(6,31,54,.1); color: var(--navy); }
.tag.prop { background: rgba(6,31,54,.1); color: var(--navy); }
.tag.neg { background: rgba(192,57,43,.12); color: var(--danger); }
.tag.pos { background: rgba(26,143,76,.12); color: var(--success); }
.tag.seg { background: rgba(6,31,54,.1); color: var(--navy); }
.tag.faq { background: rgba(0,137,173,.12); color: var(--accent-strong); }
.tag.fn { background: rgba(26,143,76,.12); color: var(--success); }
.tag.sm { height: 20px; font-size: 11px; padding: 0 7px; }

.badge { display: inline-flex; align-items: center; height: 22px; padding: 0 9px; border-radius: 999px; font-size: 11.5px; font-weight: 600; }

.ramo-badge {
  display: inline-flex; align-items: center; justify-content: center;
  width: 19px; height: 19px;
  border-radius: 6px;
  color: #fff;
  flex-shrink: 0;
}
.ramo-badge svg { width: 12px; height: 12px; }
.ramo-badge.ramo-car { background: linear-gradient(135deg, var(--success), var(--accent)); }
.badge.pago { background: rgba(26,143,76,.12); color: var(--success); }
.badge.aberto { background: rgba(0,137,173,.12); color: var(--accent-strong); }
.badge.atrasado { background: rgba(192,57,43,.12); color: var(--danger); }
.badge.in { background: rgba(26,143,76,.12); color: var(--success); }
.badge.out { background: rgba(192,57,43,.12); color: var(--danger); }

/* ---------- Tabs ---------- */
.tabs-main { display: inline-flex; border-radius: 10px; background: var(--bg); padding: 3px; gap: 2px; }
.tabs-main button {
  border: none; background: transparent; padding: 7px 14px;
  border-radius: 8px; font-size: 12.5px; font-weight: 550; color: var(--muted);
}
.tabs-main button[aria-selected="true"] { background: var(--surface); color: var(--fg); box-shadow: var(--shadow); font-weight: 600; }
.view { display: none; }
.view.active { display: flex; flex-direction: column; gap: 18px; }

/* ---------- Segmented ---------- */
.seg { display: inline-flex; padding: 3px; border-radius: 9px; background: var(--bg); gap: 2px; }
.seg button { border: none; background: transparent; padding: 6px 12px; border-radius: 7px; font-size: 12.5px; font-weight: 550; color: var(--muted); }
.seg button.on { background: var(--surface); color: var(--fg); box-shadow: var(--shadow); font-weight: 600; }

/* ---------- Form ---------- */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px 14px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field.full { grid-column: 1 / -1; }
.field.span2 { grid-column: span 2; }
.field.span3 { grid-column: span 3; }
.field label { font-size: 12px; font-weight: 600; color: var(--muted); }
.field input, .field select, .field textarea {
  height: 40px; border-radius: var(--radius-sm); border: 1px solid var(--border);
  background: var(--surface); padding: 0 12px; font-size: 13.5px; outline: none;
}
.field textarea { height: auto; min-height: 80px; padding: 10px 12px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--accent-strong); box-shadow: var(--focus); }

.field-locked label { display: flex; align-items: center; gap: 5px; }
.field-locked label .lock-ic { width: 11px; height: 11px; opacity: .65; flex-shrink: 0; }
.field-locked input {
  background: var(--surface-2, #eef2f5);
  color: var(--muted);
  cursor: not-allowed;
}

.doc-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 0; border-bottom: 1px solid var(--border);
}
.doc-row:last-child { border-bottom: none; }

.cob-table { display: flex; flex-direction: column; gap: 6px; }
.cob-row {
  display: grid;
  grid-template-columns: 100px 1fr 100px 130px 110px 26px;
  gap: 8px;
  align-items: center;
}
.cob-row input {
  height: 34px; border-radius: var(--radius-sm); border: 1px solid var(--border);
  background: var(--surface); padding: 0 10px; font-size: 12.5px; outline: none;
}
.cob-row input:focus { border-color: var(--accent-strong); box-shadow: var(--focus); }
.cob-row.cob-head span { font-size: 11px; font-weight: 600; color: var(--muted); text-transform: uppercase; }
.cob-row .btn-sm { height: 26px; width: 26px; padding: 0; display: grid; place-items: center; }
@media (max-width: 700px) {
  .cob-row { grid-template-columns: 1fr 1fr; }
  .cob-row.cob-head { display: none; }
}

@media (max-width: 900px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .field.span3 { grid-column: span 2; }
}
@media (max-width: 600px) {
  .grid-4 { grid-template-columns: 1fr; }
  .field.span2, .field.span3 { grid-column: span 1; }
}
.field .hint { font-size: 11.5px; color: var(--muted); }
select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%235c6b78' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 30px; }

.filters select, .filters input[type="search"] {
  height: 34px; border-radius: var(--radius-sm); border: 1px solid var(--border);
  background: var(--surface); padding: 0 10px; font-size: 12.5px;
}

/* ---------- Switch ---------- */
.sw { position: relative; display: inline-block; width: 44px; height: 26px; flex-shrink: 0; }
.sw input { opacity: 0; width: 0; height: 0; }
.sw span { position: absolute; inset: 0; background: #c5ced6; border-radius: 99px; transition: background .15s ease; }
.sw span::before { content: ""; position: absolute; width: 20px; height: 20px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: transform .15s ease; box-shadow: 0 1px 2px rgba(0,0,0,.2); }
.sw input:checked + span { background: var(--accent); }
.sw input:checked + span::before { transform: translateX(18px); }

/* ---------- Timeline ---------- */
.timeline { display: flex; flex-direction: column; }
.tl { display: grid; grid-template-columns: 88px 1fr; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.tl:last-child { border-bottom: none; }
.tl time { font-family: var(--font-mono); font-size: 11.5px; color: var(--muted); padding-top: 2px; }
.tl .tit { font-size: 13.5px; font-weight: 600; }
.tl .desc { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.tl .prem { font-family: var(--font-mono); font-size: 12.5px; font-weight: 600; margin-top: 4px; }
.tl .prem.pos { color: var(--success); }
.tl .prem.neg { color: var(--danger); }

/* ---------- Apólice card ---------- */
.apol-grid-wrap { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.apol-card { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 14px; background: var(--surface); display: flex; flex-direction: column; gap: 10px; }
.apol-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.apol-top h3 { font-size: 13.5px; font-weight: 600; }
.apol-top .num { font-family: var(--font-mono); font-size: 11px; color: var(--muted); white-space: nowrap; }
.apol-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; font-size: 12px; color: var(--muted); }
.apol-grid b { display: block; font-family: var(--font-mono); color: var(--fg); font-size: 13px; font-weight: 500; margin-top: 2px; }
.apol-actions { display: flex; gap: 8px; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; bottom: 20px; right: 20px;
  background: var(--navy); color: #fff;
  padding: 12px 18px; border-radius: var(--radius-sm);
  font-size: 13px; font-weight: 550;
  box-shadow: var(--shadow);
  transform: translateY(120%);
  transition: transform .25s ease;
  z-index: 100;
}
.toast.show { transform: none; }

/* ---------- Modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(6,31,54,.45);
  z-index: 40; display: none;
}
.modal-backdrop.show { display: block; }
.modal {
  position: fixed; top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: min(560px, 92vw);
  max-height: 86vh;
  overflow: auto;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  z-index: 41;
  display: none;
}
.modal.show { display: block; }
.modal-h { display: flex; align-items: center; justify-content: space-between; padding: 16px 18px; border-bottom: 1px solid var(--border); }
.modal-h h3 { font-size: 15.5px; font-weight: 600; }
.modal-close { width: 28px; height: 28px; border-radius: 8px; border: none; background: var(--bg); font-size: 14px; }
.modal-b { padding: 18px; display: flex; flex-direction: column; gap: 14px; }
.modal-footer { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 18px; border-top: 1px solid var(--border); }

/* ---------- Empty state ---------- */
.empty { text-align: center; padding: 28px; color: var(--muted); font-size: 13px; }

/* ---------- Callout ---------- */
.callout {
  background: color-mix(in srgb, var(--accent) 10%, #fff);
  border: 1px solid color-mix(in srgb, var(--accent) 28%, var(--border));
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-size: 13px;
}
.callout strong { font-weight: 600; }

/* ---------- Chart: bar-stack ---------- */
.chart { display: grid; grid-template-columns: repeat(6, 1fr); gap: 10px; align-items: end; max-height: 180px; height: 180px; padding-top: 10px; }
.bar-col { display: flex; flex-direction: column; align-items: center; gap: 8px; height: 100%; justify-content: flex-end; }
.bar-stack { width: 100%; max-width: 36px; height: 100%; display: flex; flex-direction: column-reverse; border-radius: 4px 4px 0 0; overflow: hidden; background: var(--bg); }
.bar-stack .bar { width: 100%; }
.bar-stack .bar.confirmada { background: var(--accent); }
.bar-stack .bar.prevista { background: var(--navy); }
.bar-col label { font-size: 11px; color: var(--muted); font-weight: 550; }
.chart-legend { display: flex; gap: 16px; font-size: 12px; color: var(--muted); margin-top: 10px; }
.chart-legend span { display: inline-flex; align-items: center; gap: 6px; }
.chart-legend i { width: 9px; height: 9px; border-radius: 2px; display: inline-block; }
.chart-legend i.confirmada { background: var(--accent); }
.chart-legend i.prevista { background: var(--navy); }

/* ---------- Financial horizontal bars ---------- */
.mrow { display: grid; grid-template-columns: 44px 1fr auto auto auto; align-items: center; gap: 10px; padding: 8px 0; }
.mrow .m { font-size: 12px; color: var(--muted); font-weight: 550; }
.track { position: relative; height: 8px; background: var(--bg); border-radius: 99px; overflow: hidden; }
.track .in, .track .out { position: absolute; top: 0; bottom: 0; border-radius: 99px; }
.track .in { background: var(--success); left: 0; }
.track .out { background: var(--danger); opacity: .55; left: 0; }
.mrow .n { font-family: var(--font-mono); font-size: 12px; font-weight: 600; text-align: right; min-width: 68px; }
.mrow .n.pos { color: var(--success); }
.mrow .n.neg { color: var(--danger); }

/* ---------- Ranking ---------- */
.rank-row { display: grid; grid-template-columns: 26px 1fr auto; align-items: center; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--border); }
.rank-row:last-child { border-bottom: none; }
.rank-pos { width: 26px; height: 26px; border-radius: 8px; background: var(--bg); display: grid; place-items: center; font-size: 12px; font-weight: 700; color: var(--muted); }
.rank-row:nth-child(1) .rank-pos { background: rgba(36,188,228,.18); color: var(--accent-strong); }
.rank-name { font-size: 13px; font-weight: 600; }
.rank-meta { font-size: 11.5px; color: var(--muted); margin: 2px 0 5px; }
.rank-row .track { height: 5px; position: relative; }
.rank-row .track span { position: absolute; inset: 0; background: var(--accent); border-radius: 99px; }
.rank-val { font-family: var(--font-mono); font-size: 13px; font-weight: 600; white-space: nowrap; }

/* ---------- Chips ---------- */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { border: 1px solid var(--border); background: var(--bg); border-radius: var(--radius-sm); padding: 8px 12px; display: flex; flex-direction: column; gap: 3px; min-width: 120px; }
.chip span { font-size: 11px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted); }
.chip b { font-family: var(--font-mono); font-size: 16px; font-weight: 500; }

/* ---------- Kanban ---------- */
.kanban-wrap { overflow-x: auto; padding-bottom: 8px; }
.kanban { display: flex; gap: 12px; align-items: flex-start; min-height: 200px; }
.kanban-col { flex: 0 0 260px; background: var(--bg); border-radius: var(--radius); padding: 10px; display: flex; flex-direction: column; gap: 8px; }
.kanban-col-h { display: flex; align-items: center; justify-content: space-between; padding: 4px 4px 8px; }
.kanban-col-h h3 { font-size: 12px; font-weight: 700; letter-spacing: 0.03em; text-transform: uppercase; color: var(--muted); }
.kanban-col-h .cnt { font-family: var(--font-mono); font-size: 11px; background: var(--surface); border: 1px solid var(--border); border-radius: 99px; padding: 1px 7px; }
.kanban-col.dragover { background: rgba(36,188,228,.12); outline: 2px dashed var(--accent); }
.kcard {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 12px; display: flex; flex-direction: column; gap: 6px; cursor: grab;
  box-shadow: var(--shadow);
}
.kcard:active { cursor: grabbing; }
.kcard.dragging { opacity: .4; }
.kcard .kc-title { font-size: 13px; font-weight: 600; }
.kcard .kc-meta { font-size: 11.5px; color: var(--muted); }
.kcard .kc-foot { display: flex; align-items: center; justify-content: space-between; margin-top: 4px; }
.kcard .kc-prem { font-family: var(--font-mono); font-size: 12.5px; font-weight: 600; }

/* ---------- Wizard ---------- */
.wizard-progress { display: flex; flex-direction: column; gap: 10px; }
.wizard-steps { display: flex; gap: 6px; }
.wizard-step {
  flex: 1; text-align: left; background: var(--bg); border: none; border-radius: 8px 8px 0 0;
  padding: 10px 12px; font-size: 12px; font-weight: 600; color: var(--muted); position: relative;
}
.wizard-step .num { display: inline-flex; width: 18px; height: 18px; border-radius: 50%; background: var(--border); color: var(--fg); font-size: 10.5px; align-items: center; justify-content: center; margin-right: 6px; }
.wizard-step.active { background: var(--surface); color: var(--fg); box-shadow: var(--shadow); }
.wizard-step.active .num { background: var(--accent); color: var(--navy-deep); }
.wizard-step.done .num { background: var(--success); color: #fff; }
.wizard-bar { height: 4px; background: var(--border); border-radius: 99px; overflow: hidden; }
.wizard-bar-fill { height: 100%; background: var(--accent); transition: width .2s ease; }
.wizard-actions { display: flex; justify-content: space-between; align-items: center; padding-top: 6px; }
.wizard-actions .right { display: flex; gap: 8px; }

/* ---------- Goal progress ---------- */
.goal-row { display: flex; flex-direction: column; gap: 6px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.goal-row:last-child { border-bottom: none; }
.goal-h { display: flex; justify-content: space-between; align-items: baseline; }
.goal-h .name { font-size: 13px; font-weight: 600; }
.goal-h .pct { font-family: var(--font-mono); font-size: 12.5px; font-weight: 600; color: var(--accent-strong); }
.goal-track { height: 8px; border-radius: 99px; background: var(--bg); overflow: hidden; }
.goal-track > div { height: 100%; background: var(--accent); border-radius: 99px; }
.goal-track > div.over { background: var(--success); }
.goal-meta { font-size: 11.5px; color: var(--muted); font-family: var(--font-mono); }

/* ---------- Chat ---------- */
.chat-wrap { display: grid; grid-template-columns: 220px 1fr; gap: 0; height: 560px; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; background: var(--surface); }
.chat-channels { background: var(--bg); border-right: 1px solid var(--border); overflow-y: auto; padding: 8px; }
.chat-channel { display: flex; align-items: center; gap: 8px; padding: 9px 10px; border-radius: var(--radius-sm); font-size: 12.5px; font-weight: 550; }
.chat-channel.active { background: var(--surface); box-shadow: var(--shadow); font-weight: 600; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex-shrink: 0; }
.flag-select {
  height: 30px; border-radius: 999px; border: 1px solid var(--border);
  background: var(--surface); padding: 0 28px 0 12px; font-size: 11.5px; min-width: 150px;
}
.flag-select:focus { border-color: var(--accent-strong); box-shadow: var(--focus); }
.chat-channel .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--success); flex-shrink: 0; }
.chat-main { display: flex; flex-direction: column; }
.chat-msgs { flex: 1; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.chat-msg { max-width: 72%; padding: 9px 12px; border-radius: 12px; background: var(--bg); font-size: 13px; }
.chat-msg.me { align-self: flex-end; background: var(--accent); color: var(--navy-deep); }
.chat-msg .author { font-size: 10.5px; font-weight: 700; color: var(--muted); margin-bottom: 3px; }
.chat-msg.me .author { color: rgba(6,31,54,.6); }
.chat-input-row { display: flex; gap: 8px; padding: 10px; border-top: 1px solid var(--border); }
.chat-input-row input { flex: 1; height: 38px; border-radius: 999px; border: 1px solid var(--border); padding: 0 14px; outline: none; }

/* ---------- Utility ---------- */
.flex { display: flex; align-items: center; gap: 8px; }
.flex-col { display: flex; flex-direction: column; gap: 4px; }
.grow { flex: 1; }
.text-muted { color: var(--muted); }
.mt-0 { margin-top: 0; }
.hidden { display: none !important; }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .row-2, .body-grid { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
  .subnav-grid { grid-template-columns: 1fr; }
  .grid-2 { grid-template-columns: 1fr; }
  .body-grid { grid-template-columns: 1fr; }
  .chat-wrap { grid-template-columns: 1fr; height: auto; }
  .chat-channels { display: flex; overflow-x: auto; border-right: none; border-bottom: 1px solid var(--border); }
}
@media (max-width: 820px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; left: 0; top: 0; z-index: 30;
    width: min(280px, 86vw);
    transform: translateX(-105%);
    transition: transform .2s ease;
  }
  body.nav-open .sidebar { transform: translateX(0); }
  body.nav-open .nav-scrim { display: block; }
  .menu-btn { display: grid; }
  .content { padding: 14px; }
}
@media (max-width: 600px) {
  .filters { width: 100%; }
  .filters > * { flex: 1; }
  .table-wrap { overflow-x: auto; }
  .kpis { grid-template-columns: 1fr 1fr; }
  .apol-grid-wrap { grid-template-columns: 1fr; }
}
