:root {
  --bg: #f6f4f0;
  --panel: #ffffff;
  --ink: #16130f;
  --ink-2: #4a443c;
  --muted: #8a8277;
  --line: #e7e2da;
  --accent: #e8590c;
  --accent-soft: #fdeee4;
  --red: #c92a2a;
  --red-soft: #fdecec;
  --amber: #b76e00;
  --amber-soft: #fff3db;
  --green: #2b8a3e;
  --green-soft: #e8f6eb;
  --blue: #1c64b8;
  --blue-soft: #e7f0fb;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(22, 19, 15, .05), 0 4px 16px rgba(22, 19, 15, .04);
  --font: ui-sans-serif, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12100d; --panel: #1c1915; --ink: #f3efe8; --ink-2: #cfc7bb; --muted: #8f877b; --line: #2e2a24;
    --accent: #ff7a33; --accent-soft: #3a2416; --red: #ff6b6b; --red-soft: #3a1c1c; --amber: #f2b24c; --amber-soft: #3a2c12;
    --green: #6fcf7f; --green-soft: #17301d; --blue: #7ab3ff; --blue-soft: #16273d;
    --shadow: none;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.45 var(--font); -webkit-font-smoothing: antialiased; }
.hidden { display: none !important; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }
.muted { color: var(--muted); }
.err { color: var(--red); min-height: 1.2em; margin: 8px 0 0; font-size: 14px; }

/* Brand + header */
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 17px; letter-spacing: -.01em; }
.mark { width: 30px; height: 30px; border-radius: 8px; background: var(--accent); color: #fff; display: grid; place-items: center; font-weight: 800; font-size: 16px; }
.top { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 12px 24px; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.tabs { display: flex; gap: 4px; }
.tabs button { display: flex; align-items: center; gap: 7px; border: 0; background: none; padding: 8px 12px; border-radius: 9px; color: var(--ink-2); cursor: pointer; font-weight: 550; }
.tabs button svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tabs button:hover { background: var(--panel); }
.tabs button.active { background: var(--ink); color: var(--bg); }
@media (max-width: 760px) {
  .top { padding: 10px 16px; backdrop-filter: none; -webkit-backdrop-filter: none; background: var(--bg); }
  .tabs { position: fixed; bottom: 0; left: 0; right: 0; justify-content: space-around; padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); background: var(--panel); border-top: 1px solid var(--line); }
  .tabs button { flex-direction: column; gap: 2px; font-size: 11px; padding: 6px 4px; flex: 1; }
  .tabs button.active { background: none; color: var(--accent); }
  .view { padding-bottom: 90px !important; }
}

.view { max-width: 1180px; margin: 0 auto; padding: 24px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.page-head h1 { margin: 0; font-size: 26px; letter-spacing: -.02em; }
.page-head .sub { color: var(--muted); margin-top: 2px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* Buttons + inputs */
.btn { border: 1px solid var(--line); background: var(--panel); padding: 8px 14px; border-radius: 9px; cursor: pointer; font-weight: 600; font-size: 14px; white-space: nowrap; }
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.dark { background: var(--ink); border-color: var(--ink); color: var(--bg); }
.btn.ghost { background: none; border-color: transparent; color: var(--ink-2); }
.btn.small { padding: 5px 10px; font-size: 13px; }
.btn.danger { color: var(--red); }
.btn:disabled { opacity: .55; cursor: wait; }
input, select, textarea { width: 100%; border: 1px solid var(--line); background: var(--panel); border-radius: 9px; padding: 9px 11px; outline: none; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
textarea { resize: vertical; min-height: 80px; }
label { display: block; font-size: 13px; font-weight: 600; color: var(--ink-2); }
label > input, label > select, label > textarea { margin-top: 5px; font-weight: 400; }
select.inline, input.inline { width: auto; padding: 7px 10px; }

/* Stat tiles */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 20px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.stat .n { font-size: 28px; font-weight: 750; letter-spacing: -.02em; line-height: 1.1; }
.stat .l { color: var(--muted); font-size: 13px; margin-top: 2px; }
.stat.alert .n { color: var(--red); }
@media (max-width: 760px) { .stats { grid-template-columns: repeat(2, 1fr); } }

/* Quick add */
.quick { display: flex; gap: 8px; margin-bottom: 22px; }
.quick input { flex: 1; padding: 12px 14px; font-size: 15px; }
.quick select { width: auto; }
@media (max-width: 760px) { .quick { flex-wrap: wrap; } .quick input { flex-basis: 100%; } .quick select { flex: 1; min-width: 0; } }

/* Panels + lists */
.grid2 { display: grid; grid-template-columns: 1.4fr 1fr; gap: 18px; align-items: start; }
@media (max-width: 900px) { .grid2 { grid-template-columns: 1fr; } }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 18px; overflow: hidden; }
.panel h2 { margin: 0; font-size: 14px; font-weight: 700; padding: 13px 16px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; }
.panel h2 .count { color: var(--muted); font-weight: 600; }
.panel.red h2 { color: var(--red); }
.empty { padding: 16px; color: var(--muted); font-size: 14px; }

.item { display: flex; align-items: flex-start; gap: 12px; padding: 11px 16px; border-bottom: 1px solid var(--line); cursor: pointer; }
.item:last-child { border-bottom: 0; }
.item:hover { background: color-mix(in srgb, var(--bg) 60%, transparent); }
.check { flex: none; width: 21px; height: 21px; border-radius: 50%; border: 2px solid var(--line); background: none; cursor: pointer; margin-top: 1px; display: grid; place-items: center; padding: 0; }
.check:hover { border-color: var(--green); background: var(--green-soft); }
.check.done { background: var(--green); border-color: var(--green); }
.check.done::after { content: ""; width: 6px; height: 10px; border: solid #fff; border-width: 0 2px 2px 0; transform: rotate(45deg) translate(-1px, -1px); }
.item .body { flex: 1; min-width: 0; }
.item .title { font-weight: 550; }
.item.is-done .title { text-decoration: line-through; color: var(--muted); }
.meta { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 3px; font-size: 12.5px; color: var(--muted); align-items: center; }
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 99px; font-size: 12px; font-weight: 600; background: var(--bg); color: var(--ink-2); border: 1px solid var(--line); }
.chip.red { background: var(--red-soft); color: var(--red); border-color: transparent; }
.chip.amber { background: var(--amber-soft); color: var(--amber); border-color: transparent; }
.chip.green { background: var(--green-soft); color: var(--green); border-color: transparent; }
.chip.blue { background: var(--blue-soft); color: var(--blue); border-color: transparent; }
.chip.accent { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.dot.High { background: var(--red); } .dot.Medium { background: var(--amber); } .dot.Low { background: var(--muted); }
.late { color: var(--red); font-weight: 600; }

/* Filters */
.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.filters input { width: 240px; }
.seg { display: inline-flex; background: var(--panel); border: 1px solid var(--line); border-radius: 9px; padding: 3px; }
.seg button { border: 0; background: none; padding: 5px 12px; border-radius: 7px; cursor: pointer; font-weight: 600; font-size: 13px; color: var(--ink-2); }
.seg button.on { background: var(--ink); color: var(--bg); }

/* Client cards */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); cursor: pointer; display: flex; flex-direction: column; gap: 8px; }
.card:hover { border-color: var(--muted); }
.card h3 { margin: 0; font-size: 16px; }
.card .line { font-size: 13.5px; color: var(--ink-2); }
.card .foot { display: flex; justify-content: space-between; align-items: center; margin-top: auto; padding-top: 10px; border-top: 1px solid var(--line); font-size: 13px; color: var(--muted); }

/* Opportunity board */
.board { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; align-items: start; }
@media (max-width: 900px) { .board { grid-template-columns: 1fr; } }
.col { background: color-mix(in srgb, var(--panel) 55%, var(--bg)); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px; }
.col > h3 { margin: 2px 4px 10px; font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-2); display: flex; justify-content: space-between; }
.opp { position: relative; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 12px 12px 12px 16px; margin-bottom: 10px; box-shadow: var(--shadow); }
.opp::before { content: ""; position: absolute; left: 0; top: 10px; bottom: 10px; width: 4px; border-radius: 0 4px 4px 0; background: var(--muted); }
.opp.u-Critical::before { background: var(--red); } .opp.u-High::before { background: var(--accent); } .opp.u-Medium::before { background: var(--amber); } .opp.u-Low::before { background: var(--green); }
.opp h4 { margin: 0 0 3px; font-size: 14.5px; line-height: 1.3; }
.opp .org { font-size: 13px; color: var(--ink-2); }
.opp p { font-size: 13px; color: var(--ink-2); margin: 8px 0 0; }
.opp .acts { display: flex; gap: 6px; margin-top: 10px; flex-wrap: wrap; }
.stars { color: var(--accent); letter-spacing: 1px; font-size: 12px; }
table.list { width: 100%; border-collapse: collapse; font-size: 14px; }
table.list th, table.list td { text-align: left; padding: 9px 14px; border-bottom: 1px solid var(--line); }
table.list th { font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 650; }

/* Settings */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; padding: 16px; }
.form-grid .full { grid-column: 1 / -1; }
@media (max-width: 640px) { .form-grid { grid-template-columns: 1fr; } }
.toggle { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.toggle:last-child { border-bottom: 0; }
.toggle .t { font-weight: 600; } .toggle .d { font-size: 13px; color: var(--muted); }
.switch { position: relative; width: 42px; height: 24px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; background: var(--line); border-radius: 99px; cursor: pointer; transition: .15s; }
.switch span::after { content: ""; position: absolute; width: 18px; height: 18px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .15s; }
.switch input:checked + span { background: var(--green); }
.switch input:checked + span::after { transform: translateX(18px); }
.status-line { display: flex; gap: 8px; align-items: center; padding: 12px 16px; font-size: 14px; border-bottom: 1px solid var(--line); }

/* Modal */
dialog { border: 0; border-radius: 16px; padding: 0; width: min(620px, calc(100vw - 24px)); background: var(--panel); color: var(--ink); box-shadow: 0 20px 60px rgba(0,0,0,.25); }
dialog::backdrop { background: rgba(22, 19, 15, .45); }
dialog .mh { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--line); }
dialog .mh h3 { margin: 0; font-size: 17px; }
dialog .mb { padding: 18px 20px; display: grid; grid-template-columns: 1fr 1fr; gap: 13px; max-height: 68vh; overflow: auto; }
dialog .mb .full { grid-column: 1 / -1; }
dialog .mf { display: flex; justify-content: space-between; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--line); }
@media (max-width: 640px) { dialog .mb { grid-template-columns: 1fr; } }

/* Login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login-card { width: min(380px, 100%); background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 28px; box-shadow: var(--shadow); display: grid; gap: 14px; }
.login-card .muted { margin: -6px 0 4px; }

.toast { position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%) translateY(20px); background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 10px; font-weight: 600; font-size: 14px; opacity: 0; pointer-events: none; transition: .2s; z-index: 50; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
@media (max-width: 760px) { .toast { bottom: 90px; } }
.chip.dark { background: var(--ink); color: var(--bg); border-color: transparent; }
