:root {
  --bg: #f5f6f8; --panel: #fff; --ink: #1d2433; --muted: #6b7385; --line: #e3e6ec;
  --accent: #2f6f5e; --accent-soft: #e4f1ed; --warn: #b4531a; --warn-soft: #fbeee4;
  --danger: #b42318; --danger-soft: #fdecea; --side: #1f2a2e; --side-ink: #cfd8d6;
  --radius: 10px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14181d; --panel: #1c2128; --ink: #e6e9ee; --muted: #9aa3b2; --line: #2c333d;
    --accent: #5fb89d; --accent-soft: #1e3530; --warn: #f0a46a; --warn-soft: #3a2a1d;
    --danger: #f28b82; --danger-soft: #3b2220; --side: #0f1316; --side-ink: #b9c3c1;
  }
}
* { box-sizing: border-box; }
body { margin: 0; font: 14px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--ink); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
.shell { display: flex; min-height: 100vh; }
.sidebar { width: 210px; flex-shrink: 0; background: var(--side); padding: 18px 12px; display: flex; flex-direction: column; gap: 2px; position: sticky; top: 0; height: 100vh; }
.brand { color: #fff; font-weight: 700; font-size: 18px; padding: 4px 10px 18px; }
.sidebar a { color: var(--side-ink); padding: 8px 10px; border-radius: 8px; display: flex; justify-content: space-between; }
.sidebar a:hover { background: rgba(255,255,255,.06); text-decoration: none; }
.sidebar a.active { background: rgba(255,255,255,.12); color: #fff; }
.add-btn { margin-top: 16px; }
main { flex: 1; padding: 24px 28px; min-width: 0; }
h1 { font-size: 22px; margin: 0 0 16px; }
h2 { font-size: 15px; margin: 0 0 10px; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.grid { display: grid; gap: 16px; }
.kpis { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); margin-bottom: 16px; }
.kpi .label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
.kpi .value { font-size: 28px; font-weight: 700; margin-top: 4px; }
.kpi.alert .value { color: var(--warn); }
.two { grid-template-columns: 1fr 1fr; }
.person-layout { grid-template-columns: 300px 1fr 320px; align-items: start; }
@media (max-width: 1100px) { .two, .person-layout { grid-template-columns: 1fr; } }
@media (max-width: 720px) { .sidebar { display: none; } main { padding: 16px; } }

.btn { border: 1px solid var(--line); background: var(--panel); color: var(--ink); padding: 7px 12px; border-radius: 8px; cursor: pointer; font: inherit; }
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.small { padding: 3px 8px; font-size: 12px; }
.btn.danger { color: var(--danger); }
input, select, textarea { font: inherit; color: var(--ink); background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 7px 9px; width: 100%; }
textarea { resize: vertical; min-height: 70px; }
label { display: block; font-size: 12px; color: var(--muted); margin: 10px 0 3px; }

table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 600; padding: 8px; border-bottom: 1px solid var(--line); white-space: nowrap; cursor: pointer; }
td { padding: 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr.clickable:hover td { background: var(--accent-soft); cursor: pointer; }
td select { width: auto; padding: 3px 6px; font-size: 12px; }

.chips { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.chip { border: 1px solid var(--line); background: var(--panel); border-radius: 999px; padding: 4px 11px; cursor: pointer; font-size: 13px; color: var(--ink); }
.chip.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.chip .x { margin-left: 6px; opacity: .7; }
.tag { display: inline-block; background: var(--accent-soft); color: var(--accent); border-radius: 6px; padding: 1px 7px; font-size: 12px; margin: 1px 2px 1px 0; }
.pill { display: inline-block; border-radius: 6px; padding: 1px 7px; font-size: 12px; background: var(--bg); border: 1px solid var(--line); }
.overdue { color: var(--danger); font-weight: 600; }
.due-today { color: var(--warn); font-weight: 600; }
.badge:empty { display: none; }
.badge { background: var(--warn); color: #fff; border-radius: 999px; font-size: 11px; padding: 0 7px; line-height: 18px; }

.timeline { list-style: none; padding: 0; margin: 12px 0 0; }
.timeline li { border-left: 2px solid var(--line); padding: 2px 0 14px 14px; position: relative; }
.timeline li::before { content: ""; position: absolute; left: -6px; top: 6px; width: 10px; height: 10px; border-radius: 50%; background: var(--line); }
.timeline li.call::before, .timeline li.text::before, .timeline li.email::before, .timeline li.showing::before, .timeline li.meeting::before { background: var(--accent); }
.timeline li.note::before { background: var(--warn); }
.timeline .meta { font-size: 12px; color: var(--muted); }
.timeline .body { white-space: pre-wrap; }
.composer-tabs { display: flex; gap: 4px; margin-bottom: 8px; flex-wrap: wrap; }
.quick { display: flex; gap: 6px; margin-top: 10px; }

.task { display: flex; gap: 10px; align-items: flex-start; padding: 8px 0; border-bottom: 1px solid var(--line); }
.task:last-child { border-bottom: 0; }
.task input[type=checkbox] { width: auto; margin-top: 3px; }
.task.done .title { text-decoration: line-through; color: var(--muted); }

.board { display: grid; grid-template-columns: repeat(6, minmax(190px, 1fr)); gap: 12px; overflow-x: auto; align-items: start; }
.col { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px; min-height: 200px; }
.col.drag-over { outline: 2px dashed var(--accent); }
.col-head { display: flex; justify-content: space-between; font-weight: 600; margin-bottom: 4px; }
.col-sum { font-size: 12px; color: var(--muted); margin-bottom: 10px; }
.deal { background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 9px; margin-bottom: 8px; cursor: grab; }
.deal .t { font-weight: 600; }

.bar { height: 8px; background: var(--accent-soft); border-radius: 4px; overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--accent); }
.list-row { display: flex; justify-content: space-between; align-items: center; padding: 7px 0; border-bottom: 1px solid var(--line); gap: 10px; }
.list-row:last-child { border-bottom: 0; }

.modal { position: fixed; inset: 0; background: rgba(10,15,20,.45); display: flex; align-items: flex-start; justify-content: center; padding: 60px 16px; z-index: 10; overflow-y: auto; }
.modal.hidden { display: none; }
.modal-box { background: var(--panel); border-radius: 12px; padding: 20px; width: 100%; max-width: 560px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.form-grid .full { grid-column: 1 / -1; }
.toast { position: fixed; bottom: 20px; right: 20px; background: var(--ink); color: var(--panel); padding: 10px 16px; border-radius: 8px; z-index: 20; }
.toast.hidden { display: none; }
.empty { color: var(--muted); padding: 20px 0; text-align: center; }
.step-row { display: grid; grid-template-columns: 70px 110px 1fr 30px; gap: 6px; margin-bottom: 6px; }

/* ---------- login */
.hidden { display: none !important; }
.login { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; }
.login-box { width: 100%; max-width: 360px; text-align: center; }
.login-box img { width: 72px; height: 72px; margin-bottom: 8px; border-radius: 16px; }
.login-box input { margin: 14px 0 10px; text-align: center; font-size: 16px; }
.login-box .btn { width: 100%; padding: 10px; }
.login-err { color: var(--danger); min-height: 20px; margin-top: 8px; }

/* ---------- nav icons (desktop shows labels only) */
.sidebar .ico { display: none; }
.sidebar a .lbl { flex: 1; }
.fab { display: none; }

/* ---------- phone layout */
@media (max-width: 720px) {
  body { font-size: 15px; }
  .shell { display: block; }
  .sidebar {
    display: flex; position: fixed; top: auto; bottom: 0; left: 0; right: 0; height: auto; width: auto;
    flex-direction: row; justify-content: space-around; padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
    z-index: 8; border-top: 1px solid rgba(255,255,255,.08);
  }
  .brand, .add-btn { display: none; }
  .sidebar a { flex-direction: column; align-items: center; gap: 1px; font-size: 11px; padding: 4px 6px; position: relative; flex: 1; }
  .sidebar .ico { display: block; font-size: 18px; line-height: 22px; }
  .sidebar a .lbl { flex: none; }
  .sidebar .badge { position: absolute; top: 0; right: 14%; font-size: 10px; padding: 0 5px; line-height: 15px; }
  main { padding: calc(14px + env(safe-area-inset-top)) 14px calc(90px + env(safe-area-inset-bottom)); }
  h1 { font-size: 20px; }
  .fab {
    display: block; position: fixed; right: 18px; bottom: calc(78px + env(safe-area-inset-bottom)); z-index: 9;
    width: 54px; height: 54px; border-radius: 50%; border: 0; background: var(--accent); color: #fff;
    font-size: 30px; line-height: 54px; box-shadow: 0 4px 14px rgba(0,0,0,.3); cursor: pointer;
  }
  .form-grid { grid-template-columns: 1fr; }
  .modal { padding: 16px 8px; }
  input, select, textarea { font-size: 16px; } /* stops iPhone zooming into fields */
  .people-table th:nth-child(n+3), .people-table td:nth-child(n+3) { display: none; }
  .people-table th:nth-child(6), .people-table td:nth-child(6) { display: table-cell; }
  .desk-only { display: none; }
  .kpis { grid-template-columns: 1fr 1fr; gap: 10px; }
  .kpi .value { font-size: 24px; }
  .board { grid-auto-flow: column; }
}

/* ---------- reports bar chart (single series, accent color) */
.bars { display: flex; align-items: flex-end; gap: 6px; height: 200px; padding-top: 24px; border-bottom: 1px solid var(--line); }
.bar-col { flex: 1; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; position: relative; cursor: default; outline: none; }
.bar-fill { width: 100%; max-width: 28px; background: var(--accent); border-radius: 4px 4px 0 0; }
.bar-lbl { position: absolute; bottom: -20px; font-size: 11px; color: var(--muted); }
.bar-tip { display: none; position: absolute; bottom: calc(100% - 18px); left: 50%; transform: translateX(-50%); background: var(--ink); color: var(--panel);
  font-size: 12px; padding: 5px 8px; border-radius: 6px; white-space: nowrap; z-index: 2; pointer-events: none; }
.bar-col:hover .bar-tip, .bar-col:focus .bar-tip { display: block; }
.bar-col:first-child .bar-tip { left: 0; transform: none; }
.bar-col:last-child .bar-tip { left: auto; right: 0; transform: none; }
.bar-col:hover .bar-fill { opacity: .8; }
a.list-row { color: var(--ink); }
a.list-row:hover { text-decoration: none; background: var(--accent-soft); }
.mob-only { display: none !important; }
@media (max-width: 720px) {
  .mob-only { display: flex !important; }
  .mob-hide { display: none !important; }
}
