/* KiroDash — same visual system as Kiro Finance (navy · blue · cyan→green→gold). */
:root {
  --font: "Urbanist", system-ui, -apple-system, "Segoe UI", sans-serif;
  --bg: #f4f6fb;
  --surface: #ffffff;
  --surface-2: #eef2f8;
  --ink: #0f1d33;
  --ink-2: #24324a;
  --muted: #56647d;
  --line: #0f23401a;
  --line-2: #0f23402e;
  --accent: #1f5c9e;
  --accent-from: #3387c8;
  --accent-to: #1a4172;
  --accent-soft: #1f5c9e1a;
  --accent-ink: #1a4172;
  --on-accent: #f4f8fd;
  --good: #12764a;
  --bad: #b13b22;
  --warn: #8a5a08;
  --brand-grad: linear-gradient(90deg, #12c1dc 0%, #94d08f 52%, #fadc54 100%);
  --shadow: 0 1px 2px #14284a0f, 0 18px 40px -28px #14284a59;
  --radius: 18px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --st-lead: #6b7690; --st-lead-bg: #6b76901f;
  --st-trial: #0e7490; --st-trial-bg: #06b6d41f;
  --st-paying: #12764a; --st-paying-bg: #22c55e1f;
  --st-expired: #a0530a; --st-expired-bg: #f59e0b24;
  --st-churned: #b13b22; --st-churned-bg: #ef44441c;
  --st-comp: #5b3fa6; --st-comp-bg: #8b5cf61f;
  color-scheme: light;
}
html[data-theme="dark"] {
  --bg: #0a1020;
  --surface: #0f1628;
  --surface-2: #17203a;
  --ink: #eef2fa;
  --ink-2: #d7deec;
  --muted: #a6b3cc;
  --line: #dce8ff17;
  --line-2: #dce8ff2b;
  --accent: #7db8f0;
  --accent-from: #9fcbf5;
  --accent-to: #4f97dc;
  --accent-soft: #7db8f024;
  --accent-ink: #b9d8f7;
  --on-accent: #071a33;
  --good: #8ee9b7;
  --bad: #f6a38e;
  --warn: #f2c770;
  --shadow: 0 1px 2px #0006, 0 22px 44px -26px #000c;
  --st-lead: #a6b3cc; --st-trial: #67e8f9; --st-paying: #86efac; --st-expired: #fcd34d; --st-churned: #fca5a5; --st-comp: #c4b5fd;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: var(--font); font-size: 15px; font-weight: 500; line-height: 1.45;
  color: var(--ink); background: var(--bg); -webkit-font-smoothing: antialiased;
  font-feature-settings: "tnum" on;
}
[hidden] { display: none !important; }
a { color: var(--accent); }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.min0 { min-width: 0; }
.muted { color: var(--muted); }

/* Buttons & inputs */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem; min-height: 42px;
  padding: .55rem 1rem; border-radius: 12px; border: 1px solid var(--line-2); background: var(--surface);
  color: var(--ink); font: inherit; font-weight: 700; cursor: pointer; text-decoration: none;
  transition: transform 140ms var(--ease), filter 140ms var(--ease), background-color 140ms;
}
.btn:active:not(:disabled) { transform: scale(0.97); }
.btn:disabled { opacity: .55; cursor: default; }
.btn--primary { border-color: transparent; color: var(--on-accent); background: linear-gradient(135deg, var(--accent-from), var(--accent) 55%, var(--accent-to)); box-shadow: 0 10px 22px -14px var(--accent); }
.btn--ghost { background: transparent; }
.btn--danger { color: var(--bad); }
.btn--sm { min-height: 36px; padding: .35rem .75rem; font-size: .86rem; }
.btn--block { width: 100%; }
.btn:focus-visible, .input:focus-visible, .icon-btn:focus-visible, .chip:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.icon-btn { width: 40px; height: 40px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); cursor: pointer; font-size: 1rem; }
.input { width: 100%; min-height: 42px; padding: .5rem .8rem; border-radius: 12px; border: 1px solid var(--line-2); background: var(--surface); color: var(--ink); font: inherit; }
.input--auto { width: auto; }
textarea.input { min-height: 84px; resize: vertical; }

/* Login */
.gate { min-height: 100dvh; display: grid; place-items: center; padding: 1.25rem;
  background: radial-gradient(60rem 30rem at 15% -10%, #3387c826, transparent 60%), radial-gradient(40rem 24rem at 100% 110%, #12c1dc1f, transparent 60%), var(--bg); }
.gate__card { width: min(420px, 100%); background: var(--surface); border: 1px solid var(--line); border-radius: 24px; padding: 2rem 1.5rem; box-shadow: var(--shadow); text-align: center; }
.gate__mark { border-radius: 16px; box-shadow: 0 14px 30px -16px #1a4172; }
.gate__title { margin: .9rem 0 .25rem; font-size: 1.9rem; font-weight: 800; letter-spacing: -.03em; }
.gate__sub { margin: 0 0 1.4rem; color: var(--muted); }
.gate__msg { min-height: 1.3em; margin: .9rem 0 .6rem; color: var(--muted); font-size: .9rem; }

/* Shell */
.shell { display: grid; grid-template-columns: 236px minmax(0, 1fr); min-height: 100dvh; }
.side { position: sticky; top: 0; height: 100dvh; display: flex; flex-direction: column; gap: 1rem; padding: 1.2rem .9rem; border-right: 1px solid var(--line); background: var(--surface); }
.brand { display: flex; align-items: center; gap: .6rem; font-weight: 800; font-size: 1.15rem; letter-spacing: -.02em; padding: 0 .4rem; }
.brand img { border-radius: 10px; }
.nav { display: grid; gap: .25rem; }
.nav a, .tabbar a { display: flex; align-items: center; gap: .65rem; text-decoration: none; color: var(--muted); font-weight: 700; border-radius: 12px; padding: .65rem .75rem; transition: background-color 140ms, color 140ms; }
.nav a:hover { background: var(--surface-2); color: var(--ink); }
.nav a.is-on { background: linear-gradient(135deg, var(--accent-from), var(--accent-to)); color: var(--on-accent); }
.nav__badge { margin-left: auto; min-width: 22px; padding: 1px 7px; border-radius: 999px; background: var(--bad); color: #fff; font-size: .72rem; text-align: center; }
.side__foot { margin-top: auto; display: flex; gap: .4rem; }
.main { min-width: 0; padding: 1.4rem clamp(1rem, 3vw, 2rem) 6rem; }
.top { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.2rem; }
.top__title { margin: 0; font-size: 1.7rem; font-weight: 800; letter-spacing: -.03em; }
.top__sub { margin: .15rem 0 0; color: var(--muted); }
.app-pick select { min-height: 42px; padding: .45rem 2rem .45rem .8rem; border-radius: 12px; border: 1px solid var(--line-2); background: var(--surface); color: var(--ink); font: inherit; font-weight: 700; }
.tabbar { display: none; }

/* Icons (CSS masks, no network) */
.ico { width: 20px; height: 20px; flex: 0 0 20px; background: currentColor; -webkit-mask: var(--i) center / contain no-repeat; mask: var(--i) center / contain no-repeat; }
.ico--home { --i: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 12l9-8 9 8'/%3E%3Cpath d='M5 10v10h14V10'/%3E%3C/svg%3E"); }
.ico--users { --i: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='9' cy='8' r='3.5'/%3E%3Cpath d='M2.5 20c.8-3.6 3.4-5.5 6.5-5.5s5.7 1.9 6.5 5.5'/%3E%3Cpath d='M16 4.6a3.5 3.5 0 0 1 0 6.8M18 14.8c1.9.7 3.1 2.4 3.5 5.2'/%3E%3C/svg%3E"); }
.ico--funnel { --i: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linejoin='round'%3E%3Cpath d='M3 4h18l-7 9v6l-4 2v-8z'/%3E%3C/svg%3E"); }
.ico--check { --i: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3' y='3' width='18' height='18' rx='5'/%3E%3Cpath d='M8 12.5l3 3 5-6'/%3E%3C/svg%3E"); }
.ico--grid { --i: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2'%3E%3Crect x='3' y='3' width='7.5' height='7.5' rx='2'/%3E%3Crect x='13.5' y='3' width='7.5' height='7.5' rx='2'/%3E%3Crect x='3' y='13.5' width='7.5' height='7.5' rx='2'/%3E%3Crect x='13.5' y='13.5' width='7.5' height='7.5' rx='2'/%3E%3C/svg%3E"); }

/* Cards & KPIs */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.1rem 1.15rem; }
.card h3 { margin: 0 0 .8rem; font-size: 1rem; font-weight: 800; letter-spacing: -.01em; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: .8rem; margin-bottom: 1rem; }
.kpi { position: relative; overflow: hidden; }
.kpi::before { content: ""; position: absolute; inset: 0 0 auto; height: 3px; background: var(--brand-grad); opacity: .85; }
.kpi__label { color: var(--muted); font-size: .82rem; font-weight: 700; }
.kpi__value { font-size: 1.9rem; font-weight: 800; letter-spacing: -.035em; margin-top: .2rem; line-height: 1.1; }
.kpi__hint { color: var(--muted); font-size: .78rem; margin-top: .2rem; }
.split { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 1rem; margin-bottom: 1rem; }
.chart-box { position: relative; height: 260px; }
.bars { display: grid; gap: .6rem; }
.bar__row { display: grid; grid-template-columns: 96px 1fr 36px; align-items: center; gap: .6rem; font-size: .88rem; }
.bar__track { height: 10px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.bar__fill { display: block; height: 100%; border-radius: inherit; transition: width 500ms var(--ease); }
.list { display: grid; gap: .5rem; }
.empty { text-align: center; padding: 2rem 1rem; color: var(--muted); }
.empty strong { display: block; color: var(--ink); margin-bottom: .25rem; }

/* Stage pills */
.pill { display: inline-flex; align-items: center; gap: .3rem; padding: 2px 9px; border-radius: 999px; font-size: .74rem; font-weight: 800; white-space: nowrap; }
.pill--lead { color: var(--st-lead); background: var(--st-lead-bg); }
.pill--trial { color: var(--st-trial); background: var(--st-trial-bg); }
.pill--paying { color: var(--st-paying); background: var(--st-paying-bg); }
.pill--expired { color: var(--st-expired); background: var(--st-expired-bg); }
.pill--churned { color: var(--st-churned); background: var(--st-churned-bg); }
.pill--comp { color: var(--st-comp); background: var(--st-comp-bg); }
.tag { display: inline-flex; padding: 1px 8px; border-radius: 8px; background: var(--surface-2); color: var(--ink-2); font-size: .74rem; font-weight: 700; }

/* Customers */
.toolbar { display: flex; gap: .6rem; margin-bottom: .8rem; }
.chips { display: flex; gap: .4rem; overflow-x: auto; padding-bottom: .3rem; margin-bottom: .8rem; scrollbar-width: none; }
.chip { flex: 0 0 auto; min-height: 38px; padding: .35rem .85rem; border-radius: 999px; border: 1px solid var(--line-2); background: var(--surface); color: var(--muted); font: inherit; font-weight: 700; font-size: .86rem; cursor: pointer; }
.chip.is-on { background: var(--ink); color: var(--surface); border-color: var(--ink); }
.chip b { margin-left: .3rem; opacity: .7; }
.table-wrap { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--line); background: var(--surface); box-shadow: var(--shadow); }
table { width: 100%; border-collapse: collapse; min-width: 720px; }
th, td { text-align: left; padding: .7rem .9rem; border-bottom: 1px solid var(--line); font-size: .9rem; white-space: nowrap; }
th { font-size: .74rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); background: var(--surface-2); }
tbody tr { cursor: pointer; transition: background-color 120ms; }
tbody tr:hover { background: var(--surface-2); }
tbody tr:last-child td { border-bottom: 0; }
.who { display: flex; align-items: center; gap: .6rem; }
.avatar { width: 34px; height: 34px; flex: 0 0 34px; border-radius: 50%; display: grid; place-items: center; font-weight: 800; font-size: .85rem; color: var(--on-accent); background: linear-gradient(135deg, var(--accent-from), var(--accent-to)); }
.who__name { font-weight: 800; }
.who__sub { color: var(--muted); font-size: .8rem; }
.ccards { display: none; }

/* Board */
.board { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(250px, 1fr); gap: .8rem; overflow-x: auto; padding-bottom: .5rem; }
.col { background: var(--surface-2); border-radius: var(--radius); padding: .7rem; min-height: 200px; }
.col__head { display: flex; justify-content: space-between; align-items: center; padding: .2rem .3rem .7rem; font-weight: 800; }
.col__body { display: grid; gap: .5rem; }
.bcard { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: .7rem .8rem; cursor: pointer; box-shadow: var(--shadow); transition: transform 140ms var(--ease); }
.bcard:hover { transform: translateY(-2px); }
.bcard__name { font-weight: 800; }
.bcard__meta { color: var(--muted); font-size: .8rem; margin-top: .15rem; }

/* Tasks */
.task { display: flex; align-items: flex-start; gap: .7rem; padding: .75rem .9rem; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; }
.task input { width: 20px; height: 20px; margin-top: 2px; accent-color: var(--accent); }
.task__title { font-weight: 700; }
.task__meta { color: var(--muted); font-size: .8rem; }
.task__meta a { font-weight: 700; }
.task--late .task__meta .due { color: var(--bad); font-weight: 800; }
.group-title { margin: 1.2rem 0 .5rem; font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 800; }

/* Apps */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 1rem; }
.status { display: inline-flex; align-items: center; gap: .35rem; font-weight: 800; font-size: .8rem; }
.status::before { content: ""; width: 9px; height: 9px; border-radius: 50%; background: currentColor; }
.status--ok { color: var(--good); }
.status--down { color: var(--bad); }

/* Drawer */
.scrim { position: fixed; inset: 0; background: #0a122466; backdrop-filter: blur(2px); z-index: 40; }
.drawer { position: fixed; top: 0; right: 0; height: 100dvh; width: min(560px, 100vw); background: var(--bg); border-left: 1px solid var(--line); box-shadow: -30px 0 60px -30px #0007; z-index: 50; display: flex; flex-direction: column; transform: translateX(105%); transition: transform 280ms var(--ease); }
.drawer.is-open { transform: none; }
.drawer__head { display: flex; justify-content: space-between; gap: 1rem; align-items: flex-start; padding: 1.1rem 1.2rem; border-bottom: 1px solid var(--line); background: var(--surface); }
.drawer__name { margin: 0; font-size: 1.35rem; font-weight: 800; letter-spacing: -.02em; overflow-wrap: anywhere; }
.drawer__meta { margin: .3rem 0 0; display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; color: var(--muted); font-size: .86rem; }
.drawer__body { overflow-y: auto; padding: 1rem 1.2rem 2rem; display: grid; gap: .9rem; }
.facts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .6rem; }
.fact { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: .65rem .8rem; }
.fact span { display: block; color: var(--muted); font-size: .76rem; font-weight: 700; }
.fact b { font-size: 1.05rem; }
.actions { display: flex; flex-wrap: wrap; gap: .5rem; }
.tags-edit { display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; }
.tags-edit .tag button { border: 0; background: none; color: inherit; margin-left: .25rem; cursor: pointer; padding: 0; font-weight: 800; }
.row { display: flex; gap: .5rem; }
.note { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: .6rem .75rem; }
.note__meta { display: flex; justify-content: space-between; color: var(--muted); font-size: .76rem; margin-top: .3rem; }
.note__meta button { border: 0; background: none; color: var(--bad); cursor: pointer; font: inherit; font-weight: 700; }
.tl { list-style: none; margin: 0; padding: 0 0 0 1rem; border-left: 2px solid var(--line-2); display: grid; gap: .7rem; }
.tl li { position: relative; font-size: .88rem; }
.tl li::before { content: ""; position: absolute; left: calc(-1rem - 6px); top: .35rem; width: 10px; height: 10px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 3px var(--bg); }
.tl li.tl--payment::before { background: var(--good); }
.tl li.tl--note::before, .tl li.tl--crm::before { background: #fadc54; }
.tl small { display: block; color: var(--muted); }

/* Toasts */
.toasts { position: fixed; left: 50%; bottom: 1.2rem; transform: translateX(-50%); display: grid; gap: .4rem; z-index: 60; width: min(420px, calc(100vw - 2rem)); }
.toast { background: var(--ink); color: var(--surface); padding: .7rem 1rem; border-radius: 12px; font-weight: 700; box-shadow: var(--shadow); animation: toast-in 220ms var(--ease); }
.toast--error { background: var(--bad); color: #fff; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

/* Mobile */
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .side { display: none; }
  .split { grid-template-columns: 1fr; }
  .main { padding: 1rem 1rem 6.5rem; }
  .top__title { font-size: 1.45rem; }
  .table-wrap { display: none; }
  .ccards { display: grid; gap: .6rem; }
  .ccard { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: .8rem .9rem; box-shadow: var(--shadow); display: grid; gap: .45rem; cursor: pointer; }
  .ccard__top { display: flex; justify-content: space-between; gap: .5rem; align-items: center; }
  .ccard__meta { display: flex; flex-wrap: wrap; gap: .35rem .8rem; color: var(--muted); font-size: .8rem; }
  .tabbar { display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; background: var(--surface); border-top: 1px solid var(--line); padding: .35rem .3rem calc(.35rem + env(safe-area-inset-bottom)); }
  .tabbar a { flex-direction: column; gap: .15rem; font-size: .7rem; padding: .35rem .2rem; min-height: 52px; justify-content: center; }
  .tabbar a.is-on { color: var(--accent); background: var(--accent-soft); }
  .toolbar { flex-direction: column; }
  .input--auto { width: 100%; }
  .facts { grid-template-columns: 1fr 1fr; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
