/* ══════════════════════════════════════════════════
   BusinessOS — The Living Map
   Dark navy + orange design system (KrewBase style)
   Vanilla CSS. No frameworks.
   ══════════════════════════════════════════════════ */

:root {
  --bg: #0b0f1a;
  --bg-2: #0e1424;
  --panel: #121a2e;
  --panel-2: #16203a;
  --line: #1f2b47;
  --line-2: #2a3a5f;
  --text: #e8edf7;
  --muted: #8b97b3;
  --dim: #5c6a8c;
  --orange: #f97316;
  --orange-2: #fb923c;
  --blue: #38bdf8;
  --purple: #a78bfa;
  --green: #34d399;
  --red: #f87171;
  --yellow: #fbbf24;
  --radius: 12px;
  --shadow: 0 8px 24px rgba(0,0,0,.35);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body { height: 100%; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  /* ambient glow */
  background-image:
    radial-gradient(ellipse 40% 30% at 15% 0%, rgba(249,115,22,.05), transparent 60%),
    radial-gradient(ellipse 40% 30% at 85% 10%, rgba(56,189,248,.05), transparent 60%),
    radial-gradient(ellipse 50% 40% at 50% 100%, rgba(167,139,250,.04), transparent 60%);
  background-attachment: fixed;
  overflow-x: hidden;
}

/* ── scrollbars ─────────────────────────────── */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--line-2); border-radius: 5px; }
::-webkit-scrollbar-thumb:hover { background: #3a4d7a; }

/* ── top bar ─────────────────────────────────── */
.topbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; gap: 20px;
  padding: 12px 22px;
  background: rgba(11,15,26,.88);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}

.brand { display: flex; align-items: baseline; gap: 10px; white-space: nowrap; }
.brand-dot {
  width: 12px; height: 12px; border-radius: 4px;
  background: linear-gradient(135deg, var(--orange), var(--purple));
  align-self: center;
  box-shadow: 0 0 12px rgba(249,115,22,.6);
}
.brand-name { font-weight: 800; font-size: 19px; letter-spacing: -.02em; }
.brand-accent { color: var(--orange); }
.brand-tag { color: var(--dim); font-size: 12px; font-style: italic; }

.tabs { display: flex; gap: 4px; flex: 1; overflow-x: auto; }
.tab {
  background: transparent; border: 1px solid transparent; color: var(--muted);
  padding: 8px 14px; border-radius: 9px; cursor: pointer;
  font-size: 14px; font-family: inherit; white-space: nowrap;
  transition: all .15s;
}
.tab:hover { color: var(--text); background: var(--panel); }
.tab.is-active {
  background: linear-gradient(135deg, rgba(249,115,22,.16), rgba(249,115,22,.05));
  border-color: rgba(249,115,22,.4);
  color: var(--orange-2);
  font-weight: 600;
}

.top-actions { display: flex; gap: 6px; }
.icon-btn {
  background: var(--panel); border: 1px solid var(--line); color: var(--muted);
  width: 34px; height: 34px; border-radius: 9px; cursor: pointer; font-size: 15px;
  transition: all .15s;
}
.icon-btn:hover { color: var(--text); border-color: var(--line-2); transform: translateY(-1px); }
.icon-btn.danger:hover { color: var(--red); border-color: rgba(248,113,113,.4); }

/* ── capture strip ───────────────────────────── */
.capture-strip {
  display: flex; gap: 10px; padding: 12px 22px;
  border-bottom: 1px solid var(--line);
  background: var(--bg-2);
}
.capture-strip input {
  flex: 1;
  background: var(--panel); border: 1px solid var(--line); color: var(--text);
  padding: 11px 14px; border-radius: 10px; font-size: 14.5px; font-family: inherit;
  outline: none; transition: border-color .15s;
}
.capture-strip input:focus { border-color: var(--orange); box-shadow: 0 0 0 3px rgba(249,115,22,.15); }
.capture-strip input::placeholder { color: var(--dim); }
.capture-strip select {
  background: var(--panel); border: 1px solid var(--line); color: var(--text);
  padding: 10px 12px; border-radius: 10px; font-size: 14px; font-family: inherit; outline: none;
}

/* ── buttons ─────────────────────────────────── */
.btn {
  border: none; cursor: pointer; font-family: inherit; font-weight: 600; font-size: 14px;
  padding: 10px 18px; border-radius: 10px; transition: all .15s; white-space: nowrap;
}
.btn-orange {
  background: linear-gradient(135deg, var(--orange), #ea580c);
  color: #fff; box-shadow: 0 4px 14px rgba(249,115,22,.3);
}
.btn-orange:hover { transform: translateY(-1px); box-shadow: 0 6px 18px rgba(249,115,22,.4); }
.btn-ghost { background: var(--panel); color: var(--text); border: 1px solid var(--line); }
.btn-ghost:hover { border-color: var(--line-2); background: var(--panel-2); }
.btn-danger { background: rgba(248,113,113,.12); color: var(--red); border: 1px solid rgba(248,113,113,.3); }
.btn-danger:hover { background: rgba(248,113,113,.2); }
.btn-sm { padding: 6px 12px; font-size: 13px; border-radius: 8px; }
.btn-xs { padding: 4px 9px; font-size: 12px; border-radius: 7px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ── main / views ────────────────────────────── */
main { padding: 26px 22px 60px; max-width: 1400px; margin: 0 auto; }

.view { display: none; animation: fadeIn .25s ease; }
.view.is-active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.view-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; margin-bottom: 22px; flex-wrap: wrap;
}
.view-head h1 { font-size: 23px; font-weight: 800; letter-spacing: -.02em; }
.hint { color: var(--dim); font-size: 14px; font-weight: 400; }
.count-pill {
  background: var(--panel); border: 1px solid var(--line);
  padding: 6px 14px; border-radius: 99px; font-size: 13px; color: var(--muted);
}

/* ── THE LIVING MAP ──────────────────────────── */
.legend { display: flex; gap: 16px; font-size: 12.5px; color: var(--muted); }
.legend span { display: flex; align-items: center; gap: 6px; }
.lg { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.lg-core { background: var(--orange); box-shadow: 0 0 8px rgba(249,115,22,.7); }
.lg-biz { background: var(--blue); }
.lg-shared { background: var(--purple); }

.map-wrap {
  position: relative;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  overflow: hidden;
  min-height: 560px;
  box-shadow: var(--shadow);
}
.map-lines { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 1; }
.map-line { fill: none; stroke: var(--line-2); stroke-width: 2; stroke-dasharray: 6 5; opacity: .8; }
.map-line.core { stroke: rgba(249,115,22,.45); }
.map-line.biz { stroke: rgba(56,189,248,.35); }
.map-line.shared { stroke: rgba(167,139,250,.35); }
.map-line.cross { stroke: rgba(139,151,179,.18); stroke-dasharray: 2 6; stroke-width: 1.5; }
.map-canvas { position: relative; z-index: 2; min-height: 560px; }

.map-node {
  position: absolute;
  transform: translate(-50%, -50%);
  width: 210px;
  background: linear-gradient(160deg, var(--panel-2), var(--panel));
  border: 1px solid var(--line-2);
  border-radius: 14px;
  padding: 14px 16px;
  cursor: pointer;
  transition: all .18s;
  box-shadow: 0 4px 14px rgba(0,0,0,.3);
  user-select: none;
}
.map-node:hover { transform: translate(-50%, -50%) scale(1.04); z-index: 5; border-color: var(--orange); box-shadow: 0 0 0 3px rgba(249,115,22,.15), 0 10px 30px rgba(0,0,0,.45); }
.map-node.core { border-color: rgba(249,115,22,.55); }
.map-node.core .node-title { color: var(--orange-2); }
.map-node.biz { border-color: rgba(56,189,248,.35); }
.map-node.biz .node-title { color: var(--blue); }
.map-node.shared { border-color: rgba(167,139,250,.35); }
.map-node.shared .node-title { color: var(--purple); }

.node-emoji { font-size: 22px; margin-bottom: 6px; display: block; }
.node-title { font-weight: 800; font-size: 15px; margin-bottom: 2px; }
.node-sub { color: var(--dim); font-size: 12px; margin-bottom: 8px; }
.node-counts { display: flex; gap: 8px; font-size: 11px; color: var(--muted); }
.node-counts b { color: var(--text); font-weight: 700; }

.map-tip { margin-top: 14px; color: var(--dim); font-size: 13px; text-align: center; }

/* ── kanban (leads) ──────────────────────────── */
.kanban {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 14px;
  align-items: start;
}
@media (max-width: 1100px) { .kanban { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 620px) { .kanban { grid-template-columns: 1fr; } }

.kb-col {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px;
  min-height: 200px;
}
.kb-col-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 12px; padding: 0 4px;
}
.kb-col-title { font-weight: 700; font-size: 14px; }
.kb-col-count {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 99px; padding: 2px 10px; font-size: 12px; color: var(--muted);
}
.kb-col.stage-new .kb-col-title { color: var(--yellow); }
.kb-col.stage-contacted .kb-col-title { color: var(--blue); }
.kb-col.stage-quoted .kb-col-title { color: var(--purple); }
.kb-col.stage-won .kb-col-title { color: var(--green); }
.kb-col.stage-lost .kb-col-title { color: var(--red); }

.kb-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 11px;
  padding: 12px;
  margin-bottom: 10px;
  cursor: pointer;
  transition: all .15s;
}
.kb-card:hover { border-color: var(--line-2); transform: translateY(-2px); box-shadow: 0 6px 16px rgba(0,0,0,.25); }
.kb-card .kb-name { font-weight: 700; font-size: 14px; margin-bottom: 3px; }
.kb-card .kb-biz { font-size: 11.5px; color: var(--muted); margin-bottom: 8px; }
.kb-badge {
  display: inline-block; font-size: 11px; font-weight: 700;
  padding: 3px 9px; border-radius: 99px; margin-right: 6px;
}
.badge-krewbase { background: rgba(56,189,248,.14); color: var(--blue); }
.badge-la { background: rgba(249,115,22,.14); color: var(--orange-2); }
.badge-dragon { background: rgba(167,139,250,.14); color: var(--purple); }
.badge-hq { background: rgba(139,151,179,.14); color: var(--muted); }
.kb-value { font-size: 13px; color: var(--green); font-weight: 700; }
.kb-value.zero { color: var(--dim); font-weight: 400; }
.kb-when { font-size: 11px; color: var(--dim); margin-top: 4px; }

/* ── finance ─────────────────────────────────── */
.fin-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}
.fin-stat {
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px;
  padding: 16px 18px;
}
.fin-stat .fs-label { color: var(--muted); font-size: 12.5px; text-transform: uppercase; letter-spacing: .04em; }
.fin-stat .fs-value { font-size: 24px; font-weight: 800; margin-top: 4px; }
.fs-income .fs-value { color: var(--green); }
.fs-expense .fs-value { color: var(--red); }
.fs-net .fs-value { color: var(--text); }
.fs-tax .fs-value { color: var(--yellow); }

.fin-layout { display: grid; grid-template-columns: 1fr 320px; gap: 16px; align-items: start; }
@media (max-width: 900px) { .fin-layout { grid-template-columns: 1fr; } }

.fin-table-wrap {
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px;
  overflow: auto; max-height: 520px;
}
.fin-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.fin-table th {
  position: sticky; top: 0; background: var(--panel-2); color: var(--muted);
  text-align: left; padding: 11px 14px; font-size: 12px; text-transform: uppercase; letter-spacing: .04em;
  border-bottom: 1px solid var(--line);
}
.fin-table td { padding: 10px 14px; border-bottom: 1px solid var(--line); }
.fin-table tr:last-child td { border-bottom: none; }
.fin-table tr:hover td { background: rgba(255,255,255,.02); }
.amt-in { color: var(--green); font-weight: 700; }
.amt-out { color: var(--red); font-weight: 700; }
.fin-del { background: none; border: none; color: var(--dim); cursor: pointer; font-size: 14px; }
.fin-del:hover { color: var(--red); }

.fin-side { display: flex; flex-direction: column; gap: 14px; }
.fin-side-card {
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 16px;
}
.fin-side-card h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin-bottom: 10px; }
.tax-bar { height: 10px; background: var(--panel-2); border-radius: 99px; overflow: hidden; margin: 10px 0 6px; }
.tax-bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--yellow), var(--orange)); border-radius: 99px; transition: width .4s; }
.res-list { list-style: none; }
.res-list li {
  display: flex; justify-content: space-between; gap: 10px;
  padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 13.5px;
}
.res-list li:last-child { border-bottom: none; }
.res-list .rl-label { color: var(--muted); }
.res-list .rl-val { font-weight: 600; text-align: right; }

/* ── content board ───────────────────────────── */
.content-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
}
.content-card {
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px;
  padding: 16px; cursor: pointer; transition: all .15s;
}
.content-card:hover { border-color: var(--line-2); transform: translateY(-2px); box-shadow: 0 8px 20px rgba(0,0,0,.25); }
.content-card .cc-idea { font-weight: 600; font-size: 14.5px; margin-bottom: 10px; }
.cc-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 12px; color: var(--dim); }
.cc-status { font-weight: 700; }
.cc-status.s-idea { color: var(--muted); }
.cc-status.s-draft { color: var(--blue); }
.cc-status.s-posted { color: var(--green); }
.cc-status.s-archived { color: var(--dim); }

/* ── systems list ────────────────────────────── */
.sys-list { display: flex; flex-direction: column; gap: 12px; }
.sys-card {
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px;
  padding: 16px 18px; cursor: pointer; transition: all .15s;
}
.sys-card:hover { border-color: var(--line-2); transform: translateX(3px); }
.sys-card .sc-title { font-weight: 700; font-size: 15px; margin-bottom: 4px; }
.sys-card .sc-desc { color: var(--muted); font-size: 13px; margin-bottom: 8px; }
.sys-card .sc-meta { display: flex; gap: 8px; flex-wrap: wrap; }

/* ── capture list ────────────────────────────── */
.board { display: flex; flex-direction: column; gap: 10px; }
.capture-item {
  display: flex; align-items: center; gap: 14px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  padding: 13px 16px; transition: all .15s;
}
.capture-item:hover { border-color: var(--line-2); }
.capture-item.done { opacity: .45; }
.capture-item.done .ci-text { text-decoration: line-through; }
.ci-check {
  width: 22px; height: 22px; border-radius: 7px; border: 2px solid var(--line-2);
  background: transparent; cursor: pointer; flex-shrink: 0; display: grid; place-items: center;
  color: transparent; font-size: 13px; transition: all .15s;
}
.capture-item.done .ci-check { background: var(--green); border-color: var(--green); color: #06281c; }
.ci-text { flex: 1; font-size: 14.5px; }
.ci-meta { display: flex; align-items: center; gap: 8px; }
.ci-when { color: var(--dim); font-size: 12px; }
.ci-del { background: none; border: none; color: var(--dim); cursor: pointer; font-size: 14px; padding: 4px; }
.ci-del:hover { color: var(--red); }
.empty-state {
  text-align: center; color: var(--dim); padding: 60px 20px; font-size: 15px;
}
.empty-state .big { font-size: 40px; margin-bottom: 10px; display: block; }

/* ── drawer ──────────────────────────────────── */
.drawer-backdrop {
  position: fixed; inset: 0; background: rgba(4,7,14,.6);
  backdrop-filter: blur(3px); z-index: 90; opacity: 0; pointer-events: none; transition: opacity .2s;
}
.drawer-backdrop.open { opacity: 1; pointer-events: auto; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: 460px; max-width: 94vw;
  background: var(--bg-2); border-left: 1px solid var(--line);
  z-index: 91; transform: translateX(100%); transition: transform .25s ease;
  display: flex; flex-direction: column;
  box-shadow: -20px 0 50px rgba(0,0,0,.5);
}
.drawer.open { transform: none; }
.drawer-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 20px; border-bottom: 1px solid var(--line);
}
.drawer-head h2 { font-size: 18px; font-weight: 800; }
.drawer-close { background: none; border: none; color: var(--muted); font-size: 22px; cursor: pointer; }
.drawer-close:hover { color: var(--text); }
.drawer-body { flex: 1; overflow-y: auto; padding: 20px; }
.drawer-foot { padding: 16px 20px; border-top: 1px solid var(--line); display: flex; gap: 10px; justify-content: flex-end; }

.d-section { margin-bottom: 22px; }
.d-section h3 {
  font-size: 12.5px; text-transform: uppercase; letter-spacing: .05em;
  color: var(--muted); margin-bottom: 10px;
}
.d-item {
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
  padding: 11px 13px; margin-bottom: 8px; display: flex; align-items: center; gap: 10px;
}
.d-item .di-text { flex: 1; font-size: 14px; }
.d-item .di-text.done { text-decoration: line-through; color: var(--dim); }
.d-item .di-num { color: var(--orange); font-weight: 800; font-size: 13px; min-width: 20px; }
.d-item .di-del { background: none; border: none; color: var(--dim); cursor: pointer; font-size: 13px; }
.d-item .di-del:hover { color: var(--red); }
.d-item input[type="checkbox"] { accent-color: var(--orange); width: 16px; height: 16px; cursor: pointer; }
.d-add-row { display: flex; gap: 8px; margin-top: 8px; }
.d-add-row input {
  flex: 1; background: var(--panel); border: 1px solid var(--line); color: var(--text);
  padding: 9px 12px; border-radius: 9px; font-size: 13.5px; font-family: inherit; outline: none;
}
.d-add-row input:focus { border-color: var(--orange); }
.d-note {
  width: 100%; background: var(--panel); border: 1px solid var(--line); color: var(--text);
  padding: 11px 13px; border-radius: 10px; font-size: 14px; font-family: inherit;
  min-height: 80px; resize: vertical; outline: none;
}
.d-note:focus { border-color: var(--orange); }
.d-facts { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 13px; margin-bottom: 8px; }
.d-facts label { display: block; font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; margin-bottom: 4px; }
.d-facts input {
  width: 100%; background: var(--bg); border: 1px solid var(--line); color: var(--text);
  padding: 9px 11px; border-radius: 8px; font-size: 13.5px; font-family: inherit;
  margin-bottom: 10px; outline: none;
}
.d-facts input:focus { border-color: var(--orange); }

/* ── form rows (modals) ──────────────────────── */
.form-row { margin-bottom: 14px; }
.form-row label { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 5px; }
.form-row input, .form-row select, .form-row textarea {
  width: 100%; background: var(--panel); border: 1px solid var(--line); color: var(--text);
  padding: 10px 12px; border-radius: 9px; font-size: 14px; font-family: inherit; outline: none;
}
.form-row input:focus, .form-row select:focus, .form-row textarea:focus { border-color: var(--orange); }
.form-row textarea { min-height: 70px; resize: vertical; }
.form-row .inline { display: flex; gap: 10px; }
.form-row .inline > * { flex: 1; }

/* ── modal ───────────────────────────────────── */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(4,7,14,.65); backdrop-filter: blur(3px);
  z-index: 95; opacity: 0; pointer-events: none; transition: opacity .2s;
}
.modal-backdrop.open { opacity: 1; pointer-events: auto; }
.modal {
  position: fixed; top: 50%; left: 50%; transform: translate(-50%, -46%) scale(.98);
  background: var(--bg-2); border: 1px solid var(--line-2); border-radius: 16px;
  width: 480px; max-width: 94vw; max-height: 88vh; overflow-y: auto;
  z-index: 96; opacity: 0; pointer-events: none; transition: all .2s;
  box-shadow: 0 30px 80px rgba(0,0,0,.6);
}
.modal.open { opacity: 1; pointer-events: auto; transform: translate(-50%, -50%) scale(1); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 20px; border-bottom: 1px solid var(--line); }
.modal-head h2 { font-size: 17px; font-weight: 800; }
.modal-close { background: none; border: none; color: var(--muted); font-size: 20px; cursor: pointer; }
.modal-close:hover { color: var(--text); }
.modal-body { padding: 20px; }
.modal-foot { padding: 16px 20px; border-top: 1px solid var(--line); display: flex; gap: 10px; justify-content: flex-end; }

/* ── toast ───────────────────────────────────── */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translate(-50%, 80px);
  background: var(--panel-2); border: 1px solid var(--line-2); color: var(--text);
  padding: 12px 22px; border-radius: 12px; font-size: 14px; z-index: 120;
  opacity: 0; transition: all .25s; box-shadow: 0 10px 30px rgba(0,0,0,.5);
  pointer-events: none; white-space: nowrap;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.err { border-color: rgba(248,113,113,.5); color: var(--red); }

/* ── responsive ──────────────────────────────── */
@media (max-width: 900px) {
  .topbar { flex-wrap: wrap; gap: 10px; }
  .tabs { order: 3; width: 100%; }
  .capture-strip { flex-wrap: wrap; }
  .capture-strip select { flex: 1; }
  .map-node { width: 150px; padding: 10px 12px; }
  .node-emoji { font-size: 17px; }
  .node-title { font-size: 13px; }
  .node-sub { font-size: 10.5px; }
  .node-counts { font-size: 10px; flex-wrap: wrap; }
  .view-head h1 { font-size: 19px; }
  .legend { display: none; }
}
