:root {
  --accent: #1f5eff;
  --bg: #f4f6fa;
  --panel: #ffffff;
  --ink: #172033;
  --muted: #647089;
  --line: #e3e7ef;
  --soft: #eef1f6;
  --side: #0f1b33;
  --side-ink: #c3cde0;
  --good: #12805c;
  --warn: #a8640a;
  --bad: #c2352b;
  --info: #2a62c9;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 1px 3px rgba(16, 24, 40, .07);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  font: 14px/1.45 Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--ink);
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { letter-spacing: -.01em; }

/* ---------- Shell ---------- */
.app { display: grid; grid-template-columns: 236px 1fr; min-height: 100vh; }
.sidebar {
  background: var(--side); color: var(--side-ink);
  padding: 16px 12px; position: sticky; top: 0; height: 100vh; overflow: auto;
  display: flex; flex-direction: column;
}
.brand { display: flex; gap: 10px; align-items: center; padding: 4px 8px 18px; }
.brand b { color: #fff; display: block; font-size: 14px; line-height: 1.2; }
.brand small { font-size: 11px; opacity: .65; }
.logo {
  width: 36px; height: 36px; flex: none; border-radius: 9px; background: var(--accent); color: #fff;
  display: grid; place-items: center; font-weight: 700; font-size: 13px;
}
.nav a {
  display: flex; gap: 10px; align-items: center; padding: 8px 10px; margin: 1px 0; border-radius: 8px;
  color: var(--side-ink); font-weight: 500; text-decoration: none;
}
.nav a:hover { background: rgba(255, 255, 255, .07); color: #fff; }
.nav a.active { background: var(--accent); color: #fff; }
.nav svg { width: 18px; height: 18px; flex: none; }
.nav-label { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; opacity: .45; padding: 16px 10px 6px; }
.side-foot { margin-top: auto; font-size: 11px; opacity: .55; padding: 12px 10px 0; }

.main { min-width: 0; }
.topbar {
  height: 60px; display: flex; align-items: center; gap: 16px; padding: 0 24px;
  background: var(--panel); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5;
}
.search { position: relative; flex: 1; max-width: 520px; }
.search input {
  width: 100%; padding: 9px 12px 9px 36px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--bg); font: inherit; color: inherit;
}
.search > svg { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--muted); }
.search-results {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0; background: #fff; border: 1px solid var(--line);
  border-radius: 10px; box-shadow: 0 12px 32px rgba(16, 24, 40, .14); max-height: 380px; overflow: auto; z-index: 20;
}
.search-results a { display: block; padding: 9px 12px; color: inherit; text-decoration: none; border-bottom: 1px solid var(--soft); }
.search-results a:hover, .search-results a.hl { background: var(--bg); }
.user-chip { margin-left: auto; display: flex; align-items: center; gap: 10px; font-size: 13px; }
.avatar {
  width: 30px; height: 30px; border-radius: 50%; background: #dfe6f5; color: #2b3a5c;
  display: inline-grid; place-items: center; font-size: 11.5px; font-weight: 700; flex: none;
}
.avatar.sm { width: 22px; height: 22px; font-size: 9.5px; }
.content { padding: 24px; max-width: 1440px; }

/* ---------- Page scaffolding ---------- */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head h1 { margin: 0; font-size: 22px; }
.page-head p { margin: 3px 0 0; color: var(--muted); }
.crumbs { margin-bottom: 10px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.mt { margin-top: 16px; }
.empty { padding: 28px; text-align: center; color: var(--muted); }

.btn {
  display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: #fff; color: var(--ink);
  padding: 8px 14px; border-radius: 8px; cursor: pointer; font: inherit; font-weight: 600; text-decoration: none; white-space: nowrap;
}
.btn:hover { border-color: #c4ccdb; text-decoration: none; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { filter: brightness(.94); border-color: var(--accent); }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-danger { color: var(--bad); }
.btn-link { background: none; border: 0; padding: 0; color: var(--accent); font: inherit; font-weight: 600; cursor: pointer; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); min-width: 0; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 13px 16px; border-bottom: 1px solid var(--line); }
.card-head h3 { margin: 0; font-size: 14px; }
.card-body { padding: 16px; }

.grid { display: grid; gap: 16px; align-content: start; }
.kpis { grid-template-columns: repeat(auto-fit, minmax(175px, 1fr)); }
.two-col { grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr); }
.split { grid-template-columns: 1fr 1fr; }
.kpi { padding: 15px 16px; }
.kpi .label { color: var(--muted); font-size: 11.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.kpi .value { font-size: 24px; font-weight: 700; margin-top: 4px; font-variant-numeric: tabular-nums; }
.kpi .sub { font-size: 12px; color: var(--muted); }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; }
.tbl th {
  text-align: left; font-size: 11.5px; color: var(--muted); font-weight: 600; padding: 9px 12px;
  border-bottom: 1px solid var(--line); white-space: nowrap; background: #fafbfd; text-transform: uppercase; letter-spacing: .03em;
}
.tbl td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl tbody tr:last-child td { border-bottom: 0; }
.tbl tbody tr:hover { background: #f7f9fe; }
.tbl tr[data-href], .tbl tr[data-edit-policy], .tbl tr[data-edit-opp], .tbl tr[data-edit-claim], .tbl tr[data-edit-user] { cursor: pointer; }
.tbl tfoot td { font-weight: 700; background: #fafbfd; border-top: 1px solid var(--line); }
.tbl select { padding: 4px 6px; border: 1px solid var(--line); border-radius: 6px; font: inherit; font-size: 12.5px; background: #fff; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.nowrap { white-space: nowrap; }

.badge {
  display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11.5px; font-weight: 600;
  background: var(--soft); color: #3b4760; white-space: nowrap;
}
.badge-good { background: #e2f5ec; color: var(--good); }
.badge-warn { background: #fff1db; color: var(--warn); }
.badge-bad { background: #fde7e5; color: var(--bad); }
.badge-info { background: #e5eeff; color: var(--info); }

.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.toolbar input, .toolbar select { padding: 7px 10px; border: 1px solid var(--line); border-radius: 8px; font: inherit; background: #fff; color: inherit; }
.toolbar input[type=search], .toolbar input.grow { min-width: 220px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 5px 12px; cursor: pointer;
  font: inherit; font-size: 12.5px; font-weight: 600; color: var(--muted);
}
.chip.on { background: var(--accent); border-color: var(--accent); color: #fff; }

/* ---------- Lists, bars, timeline ---------- */
.list-item { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 16px; border-bottom: 1px solid var(--line); }
.list-item:last-child { border-bottom: 0; }
.check { display: flex; gap: 10px; align-items: flex-start; min-width: 0; }
.check input { margin-top: 3px; width: 16px; height: 16px; accent-color: var(--accent); flex: none; }
.check .t { display: block; }
.task.done .t { text-decoration: line-through; color: var(--muted); }

.bar-row { display: grid; grid-template-columns: 150px 1fr 84px; gap: 10px; align-items: center; margin: 9px 0; font-size: 13px; }
.bar-track { height: 8px; background: var(--soft); border-radius: 99px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--accent); border-radius: 99px; }

.timeline .item { display: flex; gap: 10px; padding: 10px 16px; border-bottom: 1px solid var(--line); }
.timeline .item:last-child { border-bottom: 0; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); margin-top: 6px; flex: none; }

/* ---------- Account detail ---------- */
.acct-head { display: flex; gap: 16px; align-items: flex-start; justify-content: space-between; flex-wrap: wrap; padding: 20px; }
.acct-title { display: flex; gap: 14px; align-items: center; min-width: 0; }
.acct-title .logo { width: 50px; height: 50px; font-size: 17px; border-radius: 12px; }
.acct-title h1 { margin: 0 0 4px; font-size: 21px; }
.stat-row { display: flex; gap: 32px; flex-wrap: wrap; padding: 14px 20px; border-top: 1px solid var(--line); }
.stat-row div { font-size: 12px; color: var(--muted); }
.stat-row b { display: block; font-size: 17px; color: var(--ink); }
.gap-card { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; padding: 12px 16px; border-left: 4px solid var(--accent); }
.gap-chip {
  border: 1px dashed var(--accent); color: var(--accent); background: #fff; border-radius: 999px;
  padding: 4px 11px; font: inherit; font-size: 12px; font-weight: 600; cursor: pointer;
}
.gap-chip:hover { background: var(--accent); color: #fff; }
.log-form { display: grid; gap: 8px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.log-form textarea, .log-form select { width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; font: inherit; resize: vertical; }
.log-form .row { display: flex; gap: 8px; }

/* ---------- Kanban ---------- */
.kanban { display: grid; grid-template-columns: repeat(6, minmax(220px, 1fr)); gap: 12px; overflow-x: auto; padding-bottom: 8px; }
.col { background: #e9edf4; border-radius: 10px; padding: 10px; min-height: 460px; transition: outline .1s; }
.col.drag-over { outline: 2px dashed var(--accent); outline-offset: -2px; }
.col-head { display: flex; justify-content: space-between; align-items: baseline; font-weight: 700; font-size: 13px; padding: 2px 4px 10px; }
.col-head small { color: var(--muted); font-weight: 600; }
.opp {
  background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 10px 11px; margin-bottom: 8px;
  cursor: grab; box-shadow: var(--shadow);
}
.opp:hover { border-color: #c4ccdb; }
.opp.dragging { opacity: .45; }
.opp h4 { margin: 0 0 2px; font-size: 13px; }
.opp .meta { display: flex; justify-content: space-between; align-items: center; gap: 6px; margin-top: 8px; font-size: 12px; }

/* ---------- Carriers ---------- */
.carrier-grid { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.carrier .card-body p { margin: 8px 0 0; }
.tags { display: flex; gap: 5px; flex-wrap: wrap; margin-top: 8px; }
.kv { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; margin-top: 12px; }
.kv div { background: var(--bg); border-radius: 8px; padding: 8px 10px; font-size: 11.5px; color: var(--muted); }
.kv b { display: block; font-size: 15px; color: var(--ink); }

/* ---------- Import ---------- */
.steps { display: grid; gap: 16px; }
.step-num {
  width: 24px; height: 24px; border-radius: 50%; background: var(--accent); color: #fff;
  display: inline-grid; place-items: center; font-size: 12px; font-weight: 700; margin-right: 8px;
}
.drop {
  border: 2px dashed var(--line); border-radius: 10px; padding: 22px; text-align: center; color: var(--muted);
}
.drop.drag-over { border-color: var(--accent); background: #f5f8ff; }
.paste { width: 100%; min-height: 110px; margin-top: 12px; padding: 10px; border: 1px solid var(--line); border-radius: 8px; font: 12.5px/1.4 ui-monospace, Consolas, monospace; }

/* ---------- Modal / forms / toast ---------- */
.modal-backdrop { position: fixed; inset: 0; background: rgba(15, 27, 51, .45); display: grid; place-items: center; z-index: 50; padding: 16px; }
.modal { background: #fff; border-radius: 12px; width: min(640px, 100%); max-height: 92vh; overflow: auto; box-shadow: 0 24px 60px rgba(0, 0, 0, .25); }
.modal-wide { width: min(880px, 100%); }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: #fff; }
.modal-head h2 { margin: 0; font-size: 17px; }
.modal-body { padding: 20px; }
.icon-btn { border: 0; background: none; font-size: 24px; line-height: 1; cursor: pointer; color: var(--muted); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 14px; }
.field { display: flex; flex-direction: column; gap: 4px; font-size: 12.5px; font-weight: 600; color: var(--muted); }
.field input, .field select, .field textarea {
  padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; font: inherit; font-weight: 400; color: var(--ink); background: #fff;
}
.field input[type=color] { padding: 2px; height: 38px; }
.field em { font-style: normal; font-weight: 400; font-size: 11.5px; }
.field input:focus, .field select:focus, .field textarea:focus, .toolbar input:focus, .search input:focus {
  outline: 2px solid color-mix(in srgb, var(--accent) 35%, transparent); border-color: var(--accent);
}
.full { grid-column: 1 / -1; }
.form-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 6px; }
.form-actions .btn-danger { margin-right: auto; }
.toast {
  position: fixed; bottom: 22px; right: 22px; background: #172033; color: #fff; padding: 12px 16px;
  border-radius: 10px; z-index: 60; box-shadow: 0 12px 32px rgba(0, 0, 0, .25); max-width: 380px;
  animation: toast-in .18s ease-out;
}
@keyframes toast-in { from { transform: translateY(8px); opacity: 0; } }
.notice { background: #f5f8ff; border: 1px solid #d6e2ff; border-radius: 8px; padding: 10px 12px; font-size: 12.5px; color: #33456b; }

.notice-bad { background: #fdeceb; border-color: #f6c9c5; color: #8a2a22; }
.sync { white-space: nowrap; }

/* ---------- Sign-in ---------- */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 16px; background: linear-gradient(160deg, var(--side) 0%, #1b2d55 100%); }
.auth { width: min(420px, 100%); padding: 28px; }
.auth h2 { margin: 18px 0 14px; font-size: 19px; }
.auth-brand { display: flex; gap: 12px; align-items: center; }
.auth-brand b { font-size: 16px; }
.auth-form { display: grid; gap: 12px; margin-top: 12px; }
.auth-form .btn { justify-content: center; padding: 10px; }
.auth-links { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-top: 16px; font-size: 13px; color: var(--muted); }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .two-col, .split { grid-template-columns: 1fr; }
  .sync, .user-chip > div:has(b) { display: none; }
}
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: row; align-items: center; padding: 8px; gap: 8px; overflow-x: auto; }
  .brand { padding: 0 4px; }
  .brand div:last-child, .nav-label, .side-foot { display: none; }
  .nav { display: flex; gap: 2px; }
  .nav a span { display: none; }
  .topbar { padding: 0 16px; }
  .user-chip > div:last-child { display: none; }
  .content { padding: 16px; }
  .form-grid { grid-template-columns: 1fr; }
  .bar-row { grid-template-columns: 100px 1fr 70px; }
}

/* Demo bar (app.executiveai.company demos) */
.demo-switch { display: flex; align-items: center; gap: 6px; }
.demo-switch select { padding: 5px 8px; border: 1px solid var(--line); border-radius: 8px; font: inherit; font-size: 12.5px; background: #fff; color: var(--ink); }
.demo-book { white-space: nowrap; }
@media (max-width: 900px) { .demo-all, .user-chip .avatar, .user-chip .who { display: none; } }
