:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #f9fafb;
  --text: #171a21;
  --muted: #667085;
  --border: #e3e6ec;
  --accent: #4f46e5;
  --accent-ink: #ffffff;
  --accent-weak: #eef0ff;
  --good: #11795a;
  --good-weak: #e2f5ee;
  --bad: #c0332b;
  --bad-weak: #fdeceb;
  --warn: #a55a06;
  --warn-weak: #fdf1dc;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .06);
  --shadow-lg: 0 12px 32px rgba(16, 24, 40, .18);
  --s-lead: #8b95a7;
  --s-qualified: #3b82f6;
  --s-proposal: #8b5cf6;
  --s-negotiation: #f59e0b;
  --s-won: #11795a;
  --s-lost: #c0332b;
  --s-5: #14a89a;
  --s-6: #d9468f;
  --s-7: #5667e8;
  --s-8: #7fa21a;
  --radius: 10px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1217;
    --surface: #171b22;
    --surface-2: #1c212a;
    --text: #e8eaee;
    --muted: #98a2b3;
    --border: #2a303b;
    --accent: #818cf8;
    --accent-ink: #11131a;
    --accent-weak: #232748;
    --good: #4cc9a0;
    --good-weak: #14312a;
    --bad: #f27a72;
    --bad-weak: #3a1b19;
    --warn: #f0b252;
    --warn-weak: #382a10;
    --shadow: none;
    --shadow-lg: 0 12px 32px rgba(0, 0, 0, .6);
    --s-lead: #7d889b;
    --s-won: #4cc9a0;
    --s-lost: #f27a72;
  }
}
:root[data-theme="dark"] {
    --bg: #0f1217;
    --surface: #171b22;
    --surface-2: #1c212a;
    --text: #e8eaee;
    --muted: #98a2b3;
    --border: #2a303b;
    --accent: #818cf8;
    --accent-ink: #11131a;
    --accent-weak: #232748;
    --good: #4cc9a0;
    --good-weak: #14312a;
    --bad: #f27a72;
    --bad-weak: #3a1b19;
    --warn: #f0b252;
    --warn-weak: #382a10;
    --shadow: none;
    --shadow-lg: 0 12px 32px rgba(0, 0, 0, .6);
    --s-lead: #7d889b;
    --s-won: #4cc9a0;
    --s-lost: #f27a72;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0; line-height: 1.2; }
h1 { font-size: 22px; font-weight: 650; }
h2 { font-size: 15px; font-weight: 650; }
h3 { font-size: 13px; font-weight: 650; }
a { color: var(--accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Layout */
.app { display: grid; grid-template-columns: 220px 1fr; height: 100vh; }
.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 18px 12px;
  display: flex; flex-direction: column; gap: 18px;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 16px; padding: 0 8px; }
.logo {
  width: 28px; height: 28px; border-radius: 8px; background: var(--accent); color: var(--accent-ink);
  display: grid; place-items: center; font-weight: 800;
}
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a {
  display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 8px;
  color: var(--muted); text-decoration: none; font-weight: 550;
}
.nav a svg { width: 18px; height: 18px; fill: currentColor; }
.nav a:hover { background: var(--surface-2); color: var(--text); }
.nav a.active { background: var(--accent-weak); color: var(--accent); }
.nav-count {
  margin-left: auto; background: var(--bad); color: #fff; border-radius: 999px;
  font-size: 11px; font-weight: 700; padding: 1px 7px;
}
.link-btn { background: none; border: 0; padding: 0; color: var(--muted); cursor: pointer; font-size: 12px; text-decoration: underline; }
.view { overflow: auto; padding: 28px 32px 40px; outline: none; }

.page-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head p { margin: 4px 0 0; color: var(--muted); }

/* Buttons & fields */
.btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--surface); cursor: pointer; font-weight: 600;
}
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--bad); }
.btn.small { padding: 5px 10px; font-size: 13px; }
.icon-btn {
  border: 0; background: none; cursor: pointer; color: var(--muted); width: 28px; height: 28px;
  border-radius: 6px; font-size: 18px; line-height: 1;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }

.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.field > span { font-size: 12px; font-weight: 600; color: var(--muted); }
input[type=text], input[type=email], input[type=tel], input[type=number], input[type=date], input[type=search], select, textarea {
  width: 100%; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface); min-width: 0;
}
textarea { resize: vertical; min-height: 90px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }

/* Cards */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; }
.card h2 { margin-bottom: 14px; }
.card-sub { color: var(--muted); font-weight: 400; font-size: 12px; margin-left: 6px; }

/* Dashboard */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; margin-bottom: 14px; }
.kpi { padding: 16px 18px; }
.kpi .label { color: var(--muted); font-size: 12px; font-weight: 600; }
.kpi .value { font-size: 26px; font-weight: 700; margin-top: 4px; font-variant-numeric: tabular-nums; }
.kpi .note { color: var(--muted); font-size: 12px; margin-top: 2px; }
.dash-grid { display: grid; grid-template-columns: repeat(12, 1fr); gap: 14px; }
.span-4 { grid-column: span 4; } .span-5 { grid-column: span 5; } .span-6 { grid-column: span 6; }
.span-7 { grid-column: span 7; } .span-8 { grid-column: span 8; } .span-12 { grid-column: span 12; }

.bars { display: flex; flex-direction: column; gap: 10px; }
.bar-row { display: grid; grid-template-columns: 96px 1fr auto; gap: 10px; align-items: center; }
.bar-row .name { font-weight: 550; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-track { background: var(--surface-2); border-radius: 6px; height: 14px; overflow: hidden; border: 1px solid var(--border); }
.bar-fill { height: 100%; background: var(--c, var(--accent)); border-radius: 5px; min-width: 2px; }
.bar-row .num { text-align: right; font-variant-numeric: tabular-nums; color: var(--muted); font-size: 12px; white-space: nowrap; }
.bar-row .num b { color: var(--text); }

.forecast { display: flex; align-items: flex-end; gap: 14px; height: 200px; padding-top: 10px; }
.fc-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; min-width: 0; }
.fc-bars { flex: 1; display: flex; align-items: flex-end; gap: 4px; width: 100%; justify-content: center; }
.fc-bar { width: 38%; max-width: 34px; border-radius: 5px 5px 0 0; min-height: 2px; position: relative; }
.fc-bar.total { background: var(--accent-weak); border: 1px solid var(--accent); border-bottom: 0; }
.fc-bar.weighted { background: var(--accent); }
.fc-val { font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.fc-label { font-size: 12px; font-weight: 600; }
.legend { display: flex; gap: 16px; color: var(--muted); font-size: 12px; margin-top: 12px; flex-wrap: wrap; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }

.donut-wrap { display: flex; align-items: center; gap: 22px; flex-wrap: wrap; }
.donut {
  --won: 0; width: 140px; height: 140px; border-radius: 50%; flex: none;
  background: conic-gradient(var(--s-won) calc(var(--won) * 1%), var(--s-lost) 0);
  display: grid; place-items: center; position: relative;
}
.donut.empty { background: var(--border); }
.donut::after { content: ""; position: absolute; inset: 22px; background: var(--surface); border-radius: 50%; }
.donut-center { position: relative; z-index: 1; text-align: center; }
.donut-center b { font-size: 24px; display: block; }
.donut-center span { font-size: 11px; color: var(--muted); }
.wl-list { display: flex; flex-direction: column; gap: 8px; }
.wl-list div { display: flex; align-items: center; gap: 8px; }
.wl-list i { width: 10px; height: 10px; border-radius: 3px; }

.progress-list { display: flex; flex-direction: column; }
.progress-row {
  display: grid; grid-template-columns: minmax(0, 1.4fr) 150px 110px 90px; gap: 14px; align-items: center;
  padding: 10px 6px; border-top: 1px solid var(--border); cursor: pointer; border-radius: 6px;
  background: none; border-left: 0; border-right: 0; border-bottom: 0; text-align: left; width: 100%;
}
.progress-row:first-child { border-top: 0; }
.progress-row:hover { background: var(--surface-2); }
.progress-row .t { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.progress-row .s { color: var(--muted); font-size: 12px; }
.segs { display: flex; gap: 3px; }
.segs i { flex: 1; height: 8px; border-radius: 3px; background: var(--border); }
.segs i.on { background: var(--c); }
.progress-row .stage-name { font-size: 12px; font-weight: 600; }
.progress-row .amt { text-align: right; font-weight: 650; font-variant-numeric: tabular-nums; }

.mini-tasks { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.mini-tasks li { display: flex; gap: 10px; align-items: center; justify-content: space-between; }
.mini-tasks .tt { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.empty { color: var(--muted); padding: 16px 0; text-align: center; }

/* Badges */
.badge {
  display: inline-flex; align-items: center; gap: 4px; font-size: 11px; font-weight: 700; padding: 2px 8px;
  border-radius: 999px; white-space: nowrap; background: var(--surface-2); color: var(--muted); border: 1px solid var(--border);
}
.badge.high { background: var(--bad-weak); color: var(--bad); border-color: transparent; }
.badge.medium { background: var(--warn-weak); color: var(--warn); border-color: transparent; }
.badge.low { background: var(--accent-weak); color: var(--accent); border-color: transparent; }
.due { font-size: 12px; font-weight: 600; color: var(--muted); white-space: nowrap; }
.due.overdue { color: var(--bad); }
.due.today { color: var(--warn); }

/* Pipeline */
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.toolbar input[type=search] { width: 220px; }
.toolbar select { width: auto; }
.board { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(250px, 1fr); gap: 12px; overflow-x: auto; padding-bottom: 12px; align-items: start; }
.col { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px; min-height: 140px; }
.col.drag-over { outline: 2px dashed var(--accent); outline-offset: -2px; background: var(--accent-weak); }
.col-head { display: flex; align-items: center; gap: 8px; padding: 2px 4px 10px; }
.col-head .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--c); }
.col-head .total { margin-left: auto; color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.col-head .count { color: var(--muted); font-weight: 600; }
.col-cards { display: flex; flex-direction: column; gap: 8px; min-height: 40px; }
.deal-card {
  background: var(--surface); border: 1px solid var(--border); border-left: 3px solid var(--c);
  border-radius: 8px; padding: 10px 12px; cursor: grab; box-shadow: var(--shadow); text-align: left; width: 100%;
  display: block;
}
.deal-card:hover { border-color: var(--accent); border-left-color: var(--c); }
.deal-card.dragging { opacity: .4; }
.deal-card .title { font-weight: 650; margin-bottom: 2px; }
.deal-card .co { color: var(--muted); font-size: 12px; }
.deal-card .row { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 8px; }
.deal-card .val { font-weight: 700; font-variant-numeric: tabular-nums; }
.deal-card .foot { display: flex; justify-content: space-between; gap: 8px; margin-top: 8px; font-size: 12px; color: var(--muted); }
.add-card { width: 100%; margin-top: 8px; background: none; border: 1px dashed var(--border); border-radius: 8px; padding: 6px; color: var(--muted); cursor: pointer; }
.add-card:hover { color: var(--text); border-color: var(--muted); }

/* Tasks */
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  border: 1px solid var(--border); background: var(--surface); border-radius: 999px; padding: 6px 12px;
  cursor: pointer; font-weight: 600; color: var(--muted);
}
.chip:hover { color: var(--text); }
.chip.active { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.chip .n { opacity: .75; margin-left: 4px; font-weight: 500; }
.chip.overdue:not(.active) .n { color: var(--bad); opacity: 1; font-weight: 700; }
.task-controls { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin: 16px 0; align-items: center; }
.task-controls label.inline { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); }
.task-controls label.inline input { width: auto; }
.task-list { list-style: none; margin: 0; padding: 0; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.task { display: grid; grid-template-columns: 22px minmax(0, 1fr) auto auto 28px; gap: 12px; align-items: center; padding: 11px 14px; border-top: 1px solid var(--border); }
.task:first-child { border-top: 0; }
.task input[type=checkbox] { width: 17px; height: 17px; accent-color: var(--accent); cursor: pointer; margin: 0; }
.task .t-title { font-weight: 600; }
.task.done .t-title { text-decoration: line-through; color: var(--muted); }
.task .t-meta { color: var(--muted); font-size: 12px; }
.task .t-meta button { background: none; border: 0; padding: 0; color: var(--accent); cursor: pointer; font-size: 12px; }
.task .t-meta button:hover { text-decoration: underline; }
.task .t-note { color: var(--muted); font-size: 12px; margin-top: 2px; }

/* Scrim */
.scrim { position: fixed; inset: 0; background: rgba(10, 14, 22, .45); z-index: 20; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--accent-weak); color: var(--accent); display: inline-grid; place-items: center; font-weight: 700; font-size: 12px; flex: none; }
.avatar.xs { width: 20px; height: 20px; font-size: 9px; vertical-align: middle; }
.owner-tag { display: inline-flex; align-items: center; gap: 6px; }

/* Deal page */
.back { display: inline-block; margin-bottom: 12px; color: var(--muted); text-decoration: none; font-weight: 600; }
.back:hover { color: var(--text); }
.deal-head { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; }
.deal-title { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; min-width: 0; }
.deal-title h1 { font-size: 24px; }
.deal-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.owner-pick { display: flex; align-items: center; gap: 10px; margin-right: 8px; }
.owner-pick select { border: 0; background: transparent; font-weight: 650; padding: 0 16px 0 0; width: auto; cursor: pointer; }
.owner-pick small { display: block; color: var(--muted); }
.btn.won { background: var(--good); border-color: var(--good); color: #fff; }
.btn.lost { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn.won:hover, .btn.lost:hover { filter: brightness(1.1); background: inherit; }
.status-pill { padding: 3px 12px; border-radius: 999px; font-weight: 700; font-size: 12px; }
.status-pill.won { background: var(--good-weak); color: var(--good); }
.status-pill.lost { background: var(--bad-weak); color: var(--bad); }

.stagebar { list-style: none; display: flex; margin: 18px 0 22px; padding: 0; }
.stagebar li { flex: 1; min-width: 0; margin-left: -8px; }
.stagebar li:first-child { margin-left: 0; }
.stage {
  width: 100%; height: 46px; border: 0; cursor: pointer; background: var(--border); color: var(--muted);
  display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1.2;
  clip-path: polygon(0 0, calc(100% - 14px) 0, 100% 50%, calc(100% - 14px) 100%, 0 100%, 14px 50%);
  padding: 0 18px;
}
li:first-child > .stage { clip-path: polygon(0 0, calc(100% - 14px) 0, 100% 50%, calc(100% - 14px) 100%, 0 100%); border-radius: 8px 0 0 8px; }
li:last-child > .stage { border-radius: 0 8px 8px 0; }
.stage:hover { filter: brightness(.96); }
.stage .s-name { font-weight: 700; font-size: 12px; }
.stage .s-days { font-size: 12px; }
.stage.visited { background: var(--accent-weak); color: var(--accent); }
.stage.current { background: var(--accent); color: var(--accent-ink); }
.stage.visited.won { background: var(--good-weak); color: var(--good); }
.stage.visited.lost { background: var(--bad-weak); color: var(--bad); }

.deal-layout { display: grid; grid-template-columns: 310px minmax(0, 1fr); gap: 16px; align-items: start; }
.deal-main { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.summary h2 { margin-bottom: 8px; }
.kv { margin: 0; }
.kv > div { display: grid; grid-template-columns: 100px minmax(0, 1fr); gap: 8px; align-items: center; padding: 6px 0; border-top: 1px solid var(--border); }
.kv > div:first-child { border-top: 0; }
.kv dt { color: var(--muted); font-size: 12px; font-weight: 600; }
.kv dd { margin: 0; min-width: 0; }
.kv input, .kv select { border-color: transparent; background: transparent; padding: 5px 6px; margin-left: -6px; width: calc(100% + 6px); }
.kv input:hover, .kv select:hover, .kv input:focus, .kv select:focus { border-color: var(--border); background: var(--surface); }
.kv .static { padding: 5px 0; display: inline-block; }
.kv.plain input { margin: 0; }
.kv.plain > div { grid-template-columns: 100px 1fr; }
.contacts { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; }
.contact-link { display: inline-flex; align-items: center; gap: 6px; background: none; border: 0; padding: 0; color: var(--accent); cursor: pointer; font-weight: 600; text-align: left; }
.contact-link:hover { text-decoration: underline; }
.contact-head { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 14px; }
.tab { background: none; border: 0; padding: 8px 14px; cursor: pointer; font-weight: 600; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tab:hover { color: var(--text); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.tab .n { font-size: 11px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 999px; padding: 0 6px; margin-left: 2px; }
#d-composer { padding-bottom: 14px; }
#d-composer .tabs { margin-bottom: 12px; }
.compose { display: flex; flex-direction: column; gap: 10px; }
.compose .actions { display: flex; justify-content: flex-end; }
.grid4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.dropzone { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 22px; border: 2px dashed var(--border); border-radius: 10px; cursor: pointer; text-align: center; }
.dropzone:hover { border-color: var(--accent); background: var(--accent-weak); }
.dropzone span { color: var(--muted); font-size: 12px; }
.dropzone input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.dropzone:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; }

.focus-table { display: flex; flex-direction: column; }
.focus-row { display: grid; grid-template-columns: 22px minmax(0, 2fr) 100px minmax(0, 1.3fr) minmax(0, 1.2fr) minmax(0, 1.2fr); gap: 12px; align-items: center; padding: 10px 4px; border-top: 1px solid var(--border); }
.focus-row.focus-head { border-top: 0; color: var(--muted); font-size: 12px; font-weight: 600; padding-top: 0; }
.focus-row input[type=checkbox] { width: 17px; height: 17px; accent-color: var(--accent); cursor: pointer; margin: 0; }
.f-title { font-weight: 600; }
.f-title .badge { margin-left: 6px; }
.f-person { display: inline-flex; align-items: center; gap: 6px; }
.focus-row > span { overflow-wrap: anywhere; }

.note { border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; margin-bottom: 8px; background: var(--surface-2); }
.note header { display: flex; align-items: center; gap: 8px; }
.note .when { color: var(--muted); font-size: 12px; }
.note .icon-btn { margin-left: auto; }
.note p { margin: 6px 0 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.file { display: grid; grid-template-columns: 40px minmax(0, 1fr) auto 28px; gap: 12px; align-items: center; padding: 10px 0; border-top: 1px solid var(--border); }
.file:first-child { border-top: 0; }
.file-ico { width: 40px; height: 40px; border-radius: 8px; background: var(--accent-weak); color: var(--accent); display: grid; place-items: center; font-size: 10px; font-weight: 800; }
.file .btn { text-decoration: none; }
.hist-body .task-list { box-shadow: none; }
.task .t-meta a { color: var(--accent); }

.modal {
  position: fixed; z-index: 40; top: 50%; left: 50%; transform: translate(-50%, -50%);
  width: min(560px, calc(100vw - 24px)); max-height: calc(100vh - 24px); overflow: auto;
  background: var(--surface); border-radius: 14px; box-shadow: var(--shadow-lg); padding: 22px;
}
.modal h2 { font-size: 18px; margin-bottom: 16px; }
.form { display: flex; flex-direction: column; gap: 12px; }
.form .actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 6px; }
.form fieldset { border: 1px solid var(--border); border-radius: 8px; padding: 12px; margin: 0; }
.form legend { font-size: 12px; font-weight: 600; color: var(--muted); padding: 0 6px; }

@media (max-width: 960px) {
  .deal-layout { grid-template-columns: 1fr; }
  .grid4 { grid-template-columns: 1fr 1fr; }
  .focus-row.focus-head { display: none; }
  .focus-row { grid-template-columns: 22px 1fr; }
  .focus-row > span[data-label] { grid-column: 2; }
  .focus-row > span[data-label]::before { content: attr(data-label) ": "; color: var(--muted); font-size: 12px; }
  .span-4, .span-5, .span-6, .span-7, .span-8 { grid-column: span 12; }
  .progress-row { grid-template-columns: 1fr 90px; }
  .progress-row .segs, .progress-row .stage-name { grid-column: 1 / -1; }
}
@media (max-width: 720px) {
  .app { grid-template-columns: 1fr; grid-template-rows: auto 1fr; height: auto; min-height: 100vh; }
  .sidebar { flex-direction: row; align-items: center; padding: 10px 12px; gap: 10px; overflow-x: auto; }
  .brand span:not(.logo) { display: none; }
  .nav { flex-direction: row; }
  .sidebar-foot { display: none; }
  .view { padding: 18px 16px 32px; overflow: visible; }
  .grid2, .grid3 { grid-template-columns: 1fr; }
  .task { grid-template-columns: 22px minmax(0, 1fr) 28px; }
  .task .badge, .task .due { grid-column: 2; justify-self: start; }
  .bar-row { grid-template-columns: 80px 1fr auto; }
}

/* Pipeline: stage columns run to the bottom of the screen */
.view.fill { display: flex; flex-direction: column; overflow: hidden; padding-bottom: 20px; }
.view.fill .board { flex: 1; min-height: 0; align-items: stretch; padding-bottom: 0; }
.view.fill .col { display: flex; flex-direction: column; min-height: 0; }
.view.fill .col-cards { flex: 1; overflow-y: auto; min-height: 0; }
@media (max-width: 720px) {
  .view.fill { display: block; overflow: visible; }
  .view.fill .board { min-height: 70vh; }
}

/* Pipeline editor */
.modal.wide { width: min(680px, calc(100vw - 24px)); }
.pl-bar { display: flex; gap: 10px; margin-bottom: 14px; align-items: center; }
.pl-bar select { flex: 1; }
.stage-edit { list-style: none; margin: 10px 0 12px; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.stage-edit li { display: grid; grid-template-columns: 18px 10px minmax(0, 1fr) 84px 28px 28px 28px; gap: 8px; align-items: center; padding: 6px 8px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface-2); }
.stage-edit li.dragging { opacity: .4; }
.stage-edit li.drag-over { border-color: var(--accent); background: var(--accent-weak); }
.stage-edit .grip { cursor: grab; color: var(--muted); user-select: none; letter-spacing: -2px; }
.stage-edit .swatch { width: 10px; height: 10px; border-radius: 50%; }
.stage-edit .prob { display: flex; align-items: center; gap: 4px; color: var(--muted); }
.icon-btn:disabled { opacity: .3; cursor: default; }
@media (max-width: 720px) { .toolbar > select, .toolbar > .btn { flex: 1; } }
.pl-bar input[type=text] { flex: 1; font-weight: 650; }
.pl-bar .edit-ico { border: 1px solid var(--border); width: 34px; height: 34px; font-size: 16px; flex: none; }

/* Filters popover */
.filter-wrap { position: relative; }
.filter-count { background: var(--accent); color: var(--accent-ink); border-radius: 999px; font-size: 11px; padding: 0 6px; min-width: 18px; text-align: center; }
.filter-panel {
  position: absolute; right: 0; top: calc(100% + 6px); width: 300px; z-index: 15; background: var(--surface);
  border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow-lg); padding: 14px;
  display: flex; flex-direction: column; gap: 10px;
}
.filter-panel[hidden] { display: none; }
.filter-panel select { width: 100%; }
.filter-actions { display: flex; justify-content: space-between; align-items: center; margin-top: 2px; }

/* Closed / all deals list */
.deal-list { overflow: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.view.fill .deal-list { flex: 1; min-height: 0; }
.deal-table { width: 100%; border-collapse: collapse; }
.deal-table th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 600; padding: 10px 14px; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--surface); white-space: nowrap; }
.deal-table td { padding: 11px 14px; border-top: 1px solid var(--border); white-space: nowrap; }
.deal-table tbody tr { cursor: pointer; }
.deal-table tbody tr:hover { background: var(--surface-2); }
.deal-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.deal-table .strong { font-weight: 600; }
.status-pill.open { background: var(--accent-weak); color: var(--accent); }
.deal-table .status-pill { font-size: 11px; padding: 2px 10px; }

/* Win / lose drop zones while dragging */
.dropbar { position: fixed; bottom: 0; left: 220px; right: 0; z-index: 25; display: flex; gap: 14px; padding: 14px 20px; background: linear-gradient(to top, var(--bg) 70%, transparent); animation: rise .15s ease-out; }
.dropbar[hidden] { display: none; }
@keyframes rise { from { transform: translateY(30px); opacity: 0; } }
.dz { flex: 1; border: 2px dashed var(--c); border-radius: 12px; padding: 16px; text-align: center; background: var(--surface); display: flex; flex-direction: column; gap: 2px; color: var(--c); }
.dz b { font-size: 16px; }
.dz span { font-size: 12px; color: var(--muted); }
.dz.won { --c: var(--good); } .dz.lost { --c: var(--bad); }
.dz.over { background: var(--c); color: #fff; border-style: solid; }
.dz.over span { color: #fff; }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 50; background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 10px; box-shadow: var(--shadow-lg); display: flex; gap: 14px; align-items: center; max-width: calc(100vw - 24px); }
.toast[hidden] { display: none; }
.toast .link-btn { color: inherit; font-weight: 700; }
@media (max-width: 720px) { .dropbar { left: 0; } .filter-panel { position: fixed; left: 12px; right: 12px; top: 90px; width: auto; max-height: calc(100vh - 110px); overflow: auto; } }

.page-head > .toolbar { flex-wrap: wrap; }
.toolbar .btn { white-space: nowrap; }

.filter-panel { max-height: calc(100vh - 140px); overflow-y: auto; }
.saved-views { border-top: 1px solid var(--border); padding-top: 12px; display: flex; flex-direction: column; gap: 6px; }
.view-row { display: flex; align-items: center; justify-content: space-between; border-radius: 8px; padding: 0 0 0 10px; }
.view-row:hover { background: var(--surface-2); }
.view-row.active { background: var(--accent-weak); }
.view-name { flex: 1; background: none; border: 0; text-align: left; padding: 6px 0; cursor: pointer; font-weight: 600; }
.view-row.active .view-name { color: var(--accent); }
.save-view { display: flex; gap: 8px; margin-top: 4px; }
.save-view input { flex: 1; }

/* Pipeline picker with per-pipeline edit icon */
.pl-menu-wrap { position: relative; }
.pl-menu { position: absolute; left: 0; top: calc(100% + 6px); min-width: 260px; z-index: 15; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow-lg); padding: 6px; display: flex; flex-direction: column; gap: 2px; }
.pl-menu[hidden] { display: none; }
.pl-item { display: flex; align-items: center; border-radius: 8px; padding-right: 4px; }
.pl-item:hover { background: var(--surface-2); }
.pl-item.active { background: var(--accent-weak); }
.pl-pick { flex: 1; display: flex; flex-direction: column; align-items: flex-start; background: none; border: 0; padding: 8px 10px; cursor: pointer; font-weight: 650; text-align: left; }
.pl-item.active .pl-pick { color: var(--accent); }
.pl-pick .card-sub { margin: 0; font-weight: 400; }
.pl-item .icon-btn { display: grid; place-items: center; }
@media (max-width: 720px) { .pl-menu-wrap { flex: 1; } .pl-menu-wrap > .btn { width: 100%; } }
.pl-add { margin-top: 4px; border: 0; border-top: 1px solid var(--border); background: none; padding: 10px; text-align: left; cursor: pointer; font-weight: 650; color: var(--accent); border-radius: 0 0 8px 8px; }
.pl-add:hover { background: var(--surface-2); }

/* Modern checkboxes */
input[type=checkbox],
.task input[type=checkbox],
.focus-row input[type=checkbox],
.task-controls label.inline input[type=checkbox] {
  -webkit-appearance: none; appearance: none;
  width: 20px; height: 20px; margin: 0; padding: 0; flex: none; cursor: pointer;
  border: 1.5px solid var(--muted); border-radius: 7px; background: transparent no-repeat center / 14px;
  transition: background-color .15s, border-color .15s, box-shadow .15s, transform .1s;
}
input[type=checkbox]:hover { border-color: var(--accent); background-color: var(--accent-weak); }
input[type=checkbox]:active { transform: scale(.9); }
input[type=checkbox]:checked {
  background-color: var(--accent); border-color: var(--accent);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23fff' stroke-width='3.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12.5l4.5 4.5L19 7.5'/%3E%3C/svg%3E");
}
input[type=checkbox]:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--accent-weak), 0 0 0 4.5px var(--accent); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) input[type=checkbox]:checked {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2311131a' stroke-width='3.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12.5l4.5 4.5L19 7.5'/%3E%3C/svg%3E");
  }
}
:root[data-theme="dark"] input[type=checkbox]:checked {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2311131a' stroke-width='3.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12.5l4.5 4.5L19 7.5'/%3E%3C/svg%3E");
}

.task-controls select { min-width: 180px; }

/* Settings */
.set-layout { display: grid; grid-template-columns: 200px minmax(0, 1fr); gap: 20px; align-items: start; }
.set-nav { display: flex; flex-direction: column; gap: 2px; position: sticky; top: 0; }
.set-tab { text-align: left; background: none; border: 0; padding: 9px 12px; border-radius: 8px; cursor: pointer; font-weight: 600; color: var(--muted); }
.set-tab:hover { background: var(--surface-2); color: var(--text); }
.set-tab.active { background: var(--accent-weak); color: var(--accent); }
.set-body { display: flex; flex-direction: column; gap: 16px; max-width: 860px; }
.set-card { display: flex; flex-direction: column; gap: 14px; }
.set-card h2 { margin: 0; }
.set-card h3 { display: flex; align-items: center; gap: 8px; }
.muted { color: var(--muted); margin: 0; }
.muted.small { font-size: 12px; }
.field small { color: var(--muted); font-size: 12px; font-weight: 400; }
.grow { flex: 1; min-width: 0; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; }
.danger-zone { border-color: var(--bad); }
.conn-banner { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2); flex-wrap: wrap; }
.conn-banner.ok { border-color: var(--good); background: var(--good-weak); }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--good); flex: none; }
.dot.off { background: var(--muted); }
.provider-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.provider { border: 1px solid var(--border); border-radius: 10px; padding: 14px; display: flex; flex-direction: column; gap: 12px; align-items: flex-start; }
.provider .field { width: 100%; }
.provider details { width: 100%; color: var(--muted); font-size: 13px; }
.provider summary { cursor: pointer; color: var(--accent); font-weight: 600; }
.provider ol { padding-left: 18px; margin: 8px 0 0; display: flex; flex-direction: column; gap: 6px; }
.provider code { background: var(--surface-2); border: 1px solid var(--border); border-radius: 5px; padding: 0 5px; word-break: break-all; color: var(--text); }
.p-logo { width: 22px; height: 22px; border-radius: 6px; display: inline-grid; place-items: center; color: #fff; font-size: 12px; font-weight: 800; }
.p-logo.g { background: #ea4335; } .p-logo.o { background: #0a64ad; }
.form-error { color: var(--bad); background: var(--bad-weak); border-radius: 8px; padding: 8px 12px; margin: 0; }
.form-ok { color: var(--good); background: var(--good-weak); border-radius: 8px; padding: 8px 12px; margin: 0; }
.team-list, .plain-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.team-list li { display: grid; grid-template-columns: 34px minmax(0, 1fr) minmax(0, 1fr) 40px; gap: 10px; align-items: center; }
.plain-list li { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; }
.chip-list { display: flex; flex-wrap: wrap; gap: 8px; }
.tag { display: inline-flex; align-items: center; gap: 6px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 999px; padding: 4px 6px 4px 12px; font-weight: 600; }
.tag button { border: 0; background: none; cursor: pointer; color: var(--muted); font-size: 16px; line-height: 1; border-radius: 50%; width: 20px; height: 20px; }
.tag button:hover { background: var(--border); color: var(--text); }

/* Email composer + history */
.notice { border: 1px dashed var(--border); border-radius: 10px; padding: 18px; display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.notice p { margin: 0; color: var(--muted); }
.mail-from { color: var(--muted); }
.mail-from b { color: var(--text); }
.provider-tag { background: var(--accent-weak); color: var(--accent); border-radius: 999px; padding: 1px 8px; font-size: 11px; font-weight: 700; margin-left: 6px; }
.mail-body { min-height: 200px; font-family: inherit; line-height: 1.5; }
.email-item details { margin-top: 6px; }
.email-item summary { cursor: pointer; color: var(--accent); font-weight: 600; font-size: 12px; }
.email-item details p { margin: 8px 0 0; white-space: pre-wrap; overflow-wrap: anywhere; }
@media (max-width: 960px) { .set-layout { grid-template-columns: 1fr; } .set-nav { flex-direction: row; flex-wrap: wrap; position: static; } .provider-grid { grid-template-columns: 1fr; } .team-list li { grid-template-columns: 34px 1fr 40px; } .team-list li input[type=email] { grid-column: 2; } }

.signin-row { display: flex; gap: 12px; flex-wrap: wrap; }
.btn.signin { padding: 10px 18px; gap: 10px; }
.btn.signin:disabled { opacity: .55; cursor: not-allowed; }
.btn:disabled { cursor: not-allowed; }
.admin-help { border-top: 1px solid var(--border); padding-top: 12px; color: var(--muted); font-size: 13px; }
.admin-help summary { cursor: pointer; color: var(--accent); font-weight: 600; }
.admin-help p { margin: 10px 0; }
.admin-help code { background: var(--surface-2); border: 1px solid var(--border); border-radius: 5px; padding: 0 5px; word-break: break-all; color: var(--text); }
.admin-help ol { padding-left: 18px; margin: 8px 0 0; display: flex; flex-direction: column; gap: 6px; }
.admin-help h3 { color: var(--text); margin-bottom: 4px; }
.notice .signin-row { margin-top: 4px; }

/* ---------- Automations ---------- */
.au-note { background: var(--accent-weak); color: var(--text); border-radius: 10px; padding: 10px 14px; margin: 0 0 16px; font-size: 13px; }
.au-tabs { flex-wrap: wrap; }
.au-list { display: flex; flex-direction: column; gap: 10px; }
.au-row { display: flex; align-items: center; gap: 16px; padding: 14px 16px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); cursor: pointer; box-shadow: var(--shadow); }
.au-row:hover { border-color: var(--accent); }
.au-meta { text-align: right; font-size: 12px; min-width: 190px; }
.run-badge { display: inline-block; padding: 1px 9px; border-radius: 999px; font-size: 11px; font-weight: 700; background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); }
.run-badge.success { background: var(--good-weak); color: var(--good); border-color: transparent; }
.run-badge.failed { background: var(--bad-weak); color: var(--bad); border-color: transparent; }
.run-badge.waiting, .run-badge.running { background: var(--warn-weak); color: var(--warn); border-color: transparent; }
.au-empty { display: flex; flex-direction: column; gap: 14px; }
.au-tpl { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 12px; }
.au-tplcard { text-align: left; background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 14px; cursor: pointer; display: flex; flex-direction: column; gap: 6px; }
.au-tplcard:hover { border-color: var(--accent); }
.au-tplcard span { color: var(--muted); font-size: 13px; }

/* toggle switch */
.switch { position: relative; display: inline-flex; align-items: center; gap: 8px; cursor: pointer; flex: none; }
.switch input[type=checkbox] { position: absolute; opacity: 0; inset: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.switch span { display: inline-block; width: 40px; height: 23px; border-radius: 999px; background: var(--border); position: relative; transition: background .15s; }
.switch span::after { content: ""; position: absolute; top: 3px; left: 3px; width: 17px; height: 17px; border-radius: 50%; background: #fff; transition: transform .15s; box-shadow: 0 1px 2px rgba(0,0,0,.3); }
.switch input:checked + span { background: var(--good); }
.switch input:checked + span::after { transform: translateX(17px); }
.switch input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.switch.big b { min-width: 24px; }

/* builder */
.au-head { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.au-name { font-size: 22px; font-weight: 650; background: transparent; border: 1px solid transparent; border-radius: 8px; padding: 4px 8px; margin-left: -8px; min-width: 260px; flex: 1; max-width: 560px; }
.au-name:hover, .au-name:focus { border-color: var(--border); background: var(--surface); }
.au-actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.au-canvas { max-width: 720px; margin: 0 auto; display: flex; flex-direction: column; align-items: stretch; }
.au-step { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.au-step.open { border-color: var(--accent); }
.au-card-head { display: flex; align-items: center; gap: 12px; padding: 12px 14px; cursor: pointer; border-radius: var(--radius); }
.au-trigger .au-card-head { cursor: default; }
.au-title { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.au-title .muted { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 12px; }
.au-ctrl { display: flex; gap: 2px; }
.au-body { padding: 4px 14px 14px; display: flex; flex-direction: column; gap: 12px; border-top: 1px solid var(--border); padding-top: 14px; }
.au-badge { --c: var(--muted); flex: none; min-width: 46px; text-align: center; font-size: 10px; font-weight: 800; letter-spacing: .04em; padding: 5px 6px; border-radius: 6px; color: var(--c); background: color-mix(in srgb, var(--c) 16%, transparent); }
.tone-trigger { --c: var(--accent); } .tone-crm { --c: var(--s-qualified); } .tone-search { --c: var(--s-5); } .tone-logic { --c: var(--s-negotiation); }
.tone-data { --c: var(--s-proposal); } .tone-time { --c: var(--s-6); } .tone-db { --c: var(--s-8); } .tone-api { --c: var(--s-7); } .tone-code { --c: var(--muted); }
.au-conn { display: flex; justify-content: center; position: relative; height: 30px; }
.au-conn::before { content: ""; position: absolute; top: 0; bottom: 0; left: 50%; width: 2px; background: var(--border); transform: translateX(-1px); }
.au-plus { position: relative; align-self: center; width: 22px; height: 22px; border-radius: 50%; border: 1.5px solid var(--border); background: var(--surface); color: var(--muted); cursor: pointer; font-size: 15px; line-height: 1; padding: 0; opacity: .6; }
.au-conn:hover .au-plus, .au-plus:focus-visible { opacity: 1; border-color: var(--accent); color: var(--accent); }
.au-end { align-self: center; font-size: 11px; font-weight: 700; color: var(--muted); border: 1px dashed var(--border); border-radius: 999px; padding: 2px 14px; }
.au-branches { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; padding: 0 12px 14px; }
.au-branch { background: var(--surface-2); border: 1px dashed var(--border); border-radius: 10px; padding: 10px; min-width: 0; }
.au-branch.loop { margin: 0 12px 14px; border-left: 3px solid var(--s-negotiation); }
.au-branch.yes { border-top: 3px solid var(--good); } .au-branch.no { border-top: 3px solid var(--bad); }
.au-blabel { font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.au-branch .au-conn { height: 22px; }
.au-empty-branch { display: flex; justify-content: center; padding: 10px 0; }
.au-tags { margin: 28px auto 0; max-width: 720px; }
.au-tags summary { cursor: pointer; font-weight: 650; }
.au-tags code, .ff-key { background: var(--surface-2); border: 1px solid var(--border); border-radius: 5px; padding: 0 5px; font-size: 12px; }
.tag-chip { background: var(--surface-2); border: 1px solid var(--border); border-radius: 999px; padding: 3px 10px; font: 12px ui-monospace, Menlo, monospace; cursor: pointer; color: var(--text); }
.tag-chip:hover { border-color: var(--accent); color: var(--accent); }
.au-tags .chip-list { margin-top: 10px; }

.check-row { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
.au-coe { color: var(--muted); font-size: 13px; }
.conds { display: flex; flex-direction: column; gap: 8px; }
.cond-match { display: flex; align-items: center; gap: 6px; color: var(--muted); }
.cond-match select { width: auto; padding: 4px 8px; }
.cond-row { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr) minmax(0, 1.2fr) 28px; gap: 6px; align-items: center; }
.kv-row { display: grid; grid-template-columns: 1fr 1.4fr 28px; gap: 6px; margin-bottom: 6px; }
.col-in { display: grid; grid-template-columns: 110px 1fr; gap: 8px; align-items: center; margin-bottom: 6px; }
.col-in em { font-style: normal; color: var(--muted); font-size: 12px; }
.codebox { font: 12.5px/1.5 ui-monospace, Menlo, Consolas, monospace; white-space: pre; tab-size: 2; }

/* picker */
.au-picker { display: flex; flex-direction: column; gap: 18px; }
.au-picker h3 { margin-bottom: 8px; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .05em; }
.au-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 8px; }
.au-pick { display: flex; gap: 10px; align-items: flex-start; text-align: left; background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 10px; cursor: pointer; }
.au-pick:hover { border-color: var(--accent); }
.au-pick small { display: block; color: var(--muted); font-size: 12px; margin-top: 2px; }
.au-testres { border: 1px solid var(--border); border-radius: 10px; padding: 12px; background: var(--surface-2); }

/* forms + databases + history */
.au-two { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.ff-list { display: flex; flex-direction: column; gap: 10px; }
.ff-row { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr) auto auto; gap: 8px; align-items: center; padding: 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface-2); }
.ff-wide { grid-column: 1 / -1; }
.ff-key { grid-column: 1 / -1; width: fit-content; color: var(--muted); }
.ff-ctrl { display: inline-flex; }
.tc-list { display: flex; flex-direction: column; gap: 8px; }
.tc-row { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr) auto 28px; gap: 8px; align-items: center; }
.au-tablewrap { overflow: auto; border: 1px solid var(--border); border-radius: 8px; }
.au-tablewrap .deal-table td input[type=text], .au-tablewrap .deal-table td input[type=number], .au-tablewrap .deal-table td input[type=date] { min-width: 120px; }
.au-run { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 10px 14px; }
.au-run summary { cursor: pointer; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.runlog { list-style: none; margin: 10px 0 0; padding: 0; display: flex; flex-direction: column; gap: 4px; font-size: 13px; }
.runlog li { padding: 4px 8px; border-radius: 6px; overflow-wrap: anywhere; }
.runlog li.error { background: var(--bad-weak); color: var(--bad); }
.runlog li.skip { color: var(--muted); }
.pf-wrap { min-height: 100%; display: grid; place-items: start center; padding: 40px 16px; }
.pf { width: min(560px, 100%); display: flex; flex-direction: column; gap: 14px; padding: 28px; }
body.public .sidebar { display: none; }
body.public .app { grid-template-columns: 1fr; }
body.public .view { padding: 0; }
@media (max-width: 960px) { .au-two { grid-template-columns: 1fr; } .au-branches { grid-template-columns: 1fr; } .au-meta { display: none; } }
input[type=time], input[type=url] { width: 100%; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); min-width: 0; color-scheme: light dark; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) input[type=time], :root:not([data-theme="light"]) input[type=date] { color-scheme: dark; } }
:root[data-theme="dark"] input[type=time], :root[data-theme="dark"] input[type=date] { color-scheme: dark; }

/* ---------- Calendar ---------- */
.cal-icon { width: 44px; height: 44px; border-radius: 12px; object-fit: cover; flex: none; background: var(--surface-2); }
.cal-icon.big { width: 64px; height: 64px; border-radius: 16px; }
.cal-icon.ph { display: grid; place-items: center; background: var(--accent-weak); color: var(--accent); font-weight: 800; font-size: 20px; }
.icon-row { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.chip-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.av-row { display: grid; grid-template-columns: 48px 100px minmax(0, 1fr); gap: 10px; align-items: start; padding: 10px 0; border-top: 1px solid var(--border); }
.av-day { padding-top: 3px; }
.av-ranges { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.av-range { display: flex; align-items: center; gap: 8px; }
.av-range input { width: 120px; }
.cal-preview { width: 100%; height: 640px; border: 1px solid var(--border); border-radius: 10px; background: var(--bg); }
.cal-split { grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); }
.cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.cal-h { text-align: center; font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; padding: 4px 0; }
.cal-cell { min-height: 86px; display: flex; flex-direction: column; align-items: stretch; gap: 3px; padding: 6px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface-2); text-align: left; cursor: pointer; overflow: hidden; }
.cal-cell.off { background: transparent; border-color: transparent; cursor: default; }
.cal-cell:not(.off):hover { border-color: var(--accent); }
.cal-cell.today > span { background: var(--accent); color: var(--accent-ink); border-radius: 999px; width: 22px; height: 22px; display: grid; place-items: center; }
.cal-cell.sel { border-color: var(--accent); background: var(--accent-weak); }
.cal-cell > span { font-weight: 650; font-size: 12px; }
.cal-chip, .cal-more { font-style: normal; font-size: 11px; background: var(--accent-weak); color: var(--accent); border-radius: 5px; padding: 1px 5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal-more { background: none; color: var(--muted); }
.bk-card { display: flex; gap: 10px; align-items: center; justify-content: space-between; flex-wrap: wrap; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2); }
.bk-line { padding: 4px 0; border-top: 1px solid var(--border); font-size: 13px; }

/* public booking page */
.bk { width: min(860px, 100%); display: flex; flex-direction: column; gap: 16px; padding: 28px; }
.bk-head { display: flex; align-items: center; gap: 16px; }
.bk-head h1 { font-size: 24px; }
.bk-desc { margin: 0; color: var(--muted); white-space: pre-wrap; }
.bk-body { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 28px; align-items: start; border-top: 1px solid var(--border); padding-top: 18px; }
.bk-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; margin-top: 8px; }
.bk-day { aspect-ratio: 1; display: grid; place-items: center; border-radius: 50%; border: 0; background: transparent; font-weight: 600; color: var(--muted); opacity: .45; }
button.bk-day { opacity: 1; background: var(--accent-weak); color: var(--accent); cursor: pointer; }
button.bk-day:hover { outline: 2px solid var(--accent); }
.bk-day.sel { background: var(--accent); color: var(--accent-ink); }
.bk-day.today:not(.sel) { box-shadow: inset 0 0 0 1.5px var(--muted); }
.bk-slots { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; max-height: 360px; overflow: auto; padding: 2px; }
.bk-slot { padding: 11px; border: 1.5px solid var(--accent); border-radius: 8px; background: transparent; color: var(--accent); font-weight: 700; cursor: pointer; }
.bk-slot:hover { background: var(--accent); color: var(--accent-ink); }
.bk-form { display: flex; flex-direction: column; gap: 12px; }
.bk-pick { padding: 12px; border-radius: 10px; background: var(--accent-weak); }
.bk-hint { padding: 30px 8px; text-align: center; }
.bk-ok { display: flex; flex-direction: column; gap: 10px; border-top: 1px solid var(--border); padding-top: 18px; }
body.embed .pf-wrap { padding: 0; }
body.embed .bk { box-shadow: none; border: 0; padding: 20px; background: transparent; }
body.embed { background: transparent; }
@media (max-width: 960px) { .cal-split { grid-template-columns: 1fr; } .bk-body { grid-template-columns: 1fr; } .av-row { grid-template-columns: 48px 1fr; } .av-ranges { grid-column: 1 / -1; } .cal-cell { min-height: 60px; } .cal-chip { display: none; } }

/* shared helpers (section headers + inline forms) */
.sec-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 10px; flex-wrap: wrap; }
.inline-form { background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: 12px; display: flex; flex-direction: column; gap: 10px; margin-top: 8px; }
.inline-form .actions { display: flex; gap: 8px; justify-content: flex-end; }

.sync-badge { display: inline-block; font-size: 11px; font-weight: 700; padding: 1px 8px; border-radius: 999px; background: var(--surface); border: 1px solid var(--border); color: var(--muted); text-decoration: none; margin-left: 4px; }
.sync-badge.ok { background: var(--good-weak); color: var(--good); border-color: transparent; }
.sync-badge.bad { background: var(--bad-weak); color: var(--bad); border-color: transparent; }

.sync-found { border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; background: var(--surface-2); }
.sync-found .runlog { margin-top: 8px; }

/* ---------- Marketing ---------- */
.mk-split { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.mk-side { position: sticky; top: 0; display: flex; flex-direction: column; gap: 16px; }
.mk-block { border: 1px solid var(--border); border-radius: 10px; padding: 12px; background: var(--surface-2); display: flex; flex-direction: column; gap: 8px; }
.mk-block .sec-head { margin-bottom: 0; }
.mk-btype { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.mk-cond { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1.1fr) 28px; gap: 8px; align-items: center; margin-bottom: 8px; }
.mk-frame-wrap { display: flex; justify-content: center; background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 12px; overflow: auto; }
.mk-frame { width: 100%; height: 520px; border: 0; border-radius: 8px; background: #f3f4f6; transition: width .2s; }
.mk-frame.mobile { width: 375px; max-width: 100%; }
.mk-bar { height: 10px; border-radius: 999px; background: var(--border); overflow: hidden; }
.mk-bar i { display: block; height: 100%; background: var(--good); transition: width .3s; }
.mk-todo { margin: 0; padding-left: 18px; color: var(--warn); font-size: 13px; }
@media (max-width: 960px) { .mk-split { grid-template-columns: 1fr; } .mk-side { position: static; } .mk-cond { grid-template-columns: 1fr 1fr; } }

/* ---- Cloud mode: sign-in screens, workspace box, team ---- */
body.cloud-locked > :not(#cloud-root):not(script) { display: none !important; }
#cloud-root[hidden] { display: none; }
.cloud-screen { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; background: var(--bg, #f6f7fb); }
.cloud-card { width: 100%; max-width: 420px; background: var(--surface, #fff); color: var(--text, #1b1f2a); border: 1px solid var(--border, #e3e6ee); border-radius: 14px; padding: 28px; box-shadow: 0 10px 30px rgba(20, 24, 40, .08); display: flex; flex-direction: column; gap: 12px; }
.cloud-card h1 { font-size: 22px; margin: 0; }
.cloud-card form { display: flex; flex-direction: column; gap: 12px; }
.cloud-card .field { display: flex; flex-direction: column; gap: 4px; }
.cloud-brand { display: flex; align-items: center; gap: 8px; font-weight: 600; margin-bottom: 4px; }
.cloud-brand .logo { width: 28px; height: 28px; border-radius: 8px; background: var(--accent, #4f46e5); color: #fff; display: grid; place-items: center; font-weight: 700; }
.cloud-center { text-align: center; padding: 24px 0; }
.cloud-links { display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; font-size: 13px; margin: 0; }
.cloud-invite { background: color-mix(in srgb, var(--accent, #4f46e5) 10%, transparent); border-radius: 8px; padding: 10px 12px; font-size: 14px; margin: 0; }
.cloud-or { display: flex; align-items: center; gap: 10px; color: var(--muted, #6b7280); font-size: 12px; }
.cloud-or::before, .cloud-or::after { content: ''; flex: 1; border-top: 1px solid var(--border, #e3e6ee); }
.cloud-list { display: flex; flex-direction: column; gap: 8px; }
.cloud-ws { display: flex; justify-content: space-between; padding: 12px 14px; border: 1px solid var(--border, #e3e6ee); border-radius: 10px; background: transparent; color: inherit; cursor: pointer; font: inherit; }
.cloud-ws:hover { border-color: var(--accent, #4f46e5); }
.link-btn { background: none; border: 0; padding: 0; color: var(--accent, #4f46e5); cursor: pointer; font: inherit; text-decoration: underline; }
.form-error { color: #b42318; background: #fef3f2; border-radius: 8px; padding: 8px 10px; font-size: 13px; margin: 0; }
.cloud-user { margin-top: auto; padding: 12px; border-top: 1px solid var(--border, #e3e6ee); display: flex; flex-direction: column; gap: 4px; font-size: 13px; }
.cloud-ws-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cloud-actions { display: flex; gap: 12px; }
.cloud-status.saving { color: var(--muted, #6b7280); }
.cloud-status.error { color: #b42318; }
.cloud-status.saved { color: #067647; }
.cloud-team li { display: flex; align-items: center; gap: 10px; }
.cloud-team .grow, .grow { flex: 1; min-width: 0; }
.invite-link { display: flex; gap: 8px; } .invite-link input { flex: 1; min-width: 0; }
.notice { background: color-mix(in srgb, var(--accent, #4f46e5) 8%, transparent); border-radius: 10px; padding: 10px 12px; margin-bottom: 12px; font-size: 13px; }
.cloud-card input { width: 100%; box-sizing: border-box; padding: 9px 10px; border: 1px solid var(--border, #e3e6ec); border-radius: 8px; background: var(--surface-2, #f9fafb); color: inherit; font: inherit; }
.cloud-card input:focus { outline: 2px solid var(--accent, #4f46e5); outline-offset: 1px; }
.cloud-card .btn { width: 100%; }
.cloud-legal { margin: 4px 0 0; text-align: center; font-size: 12px; color: var(--muted, #667085); }
.cloud-legal a, .cloud-card .check a { color: inherit; }
.cloud-card .check { display: flex; gap: 8px; align-items: flex-start; font-size: 13px; }
.cloud-card .check input { width: auto; margin-top: 2px; }
.danger-zone hr { border: 0; border-top: 1px solid var(--border, #e3e6ec); margin: 14px 0; }
.cf-box { display: flex; justify-content: center; min-height: 65px; }
