/* TARTU CRM — gold & ivory theme (matches the TARTU website) */
:root {
  --bg: #f5f0e7;
  --bg-2: #efe8dc;
  --panel: #fffdf9;
  --panel-2: #f8f2e8;
  --line: #e7ddcc;
  --line-2: #d9cbb3;
  --text: #1d1913;
  --text-2: #5f5647;
  --muted: #8f8370;
  --accent: #c9a36a;          /* TARTU gold */
  --accent-2: #b58a4c;
  --accent-ink: #1b1712;      /* text on gold */
  --accent-text: #8a6326;     /* gold that reads on ivory */
  --night: #14110d;           /* sidebar */
  --night-2: #1f1a14;
  --night-text: #ece3d2;
  --night-muted: #9d907a;
  --ok: #2f9e5b;
  --warn: #cf8a1f;
  --bad: #c9485f;
  --info: #3b74d1;
  --wa-bg: #efe7dc;
  --bubble-in: #ffffff;
  --bubble-out: #dcf6d0;
  --radius: 12px;
  --shadow: 0 18px 44px -22px rgba(60, 40, 10, .35);
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --serif: "Noto Serif Display", Georgia, serif;
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body, #root { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font: 14px/1.45 var(--font); -webkit-font-smoothing: antialiased; overflow: hidden; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent-text); text-decoration: none; }
a:hover { text-decoration: underline; }
[hidden] { display: none !important; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #d6c8b0; border-radius: 10px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-track { background: transparent; }

/* ---------- controls ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 36px; padding: 0 14px; border-radius: 10px; border: 1px solid var(--line-2); background: var(--panel); cursor: pointer; white-space: nowrap; font-weight: 500; color: var(--text); transition: background .15s, border-color .15s; }
.btn:hover { background: var(--panel-2); border-color: #cbb994; }
.btn:disabled { opacity: .45; cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.btn.primary:hover { background: #d4b27f; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn.ghost:hover { background: var(--panel-2); color: var(--text); }
.btn.danger { color: var(--bad); }
.btn.sm { height: 30px; padding: 0 10px; font-size: 13px; border-radius: 8px; }
.btn.icon { width: 36px; padding: 0; }
.btn.icon.sm { width: 30px; }
.btn svg { width: 16px; height: 16px; flex: none; }
.input, select.input, textarea.input { width: 100%; height: 36px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--line-2); background: #fff; outline: none; transition: border-color .15s, box-shadow .15s; }
textarea.input { height: auto; padding: 10px 12px; resize: vertical; min-height: 70px; }
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(201, 163, 106, .2); }
.field { display: grid; gap: 6px; }
.field > span { font-size: 12px; color: var(--muted); }
.chip { display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--line-2); background: var(--panel); color: var(--text-2); cursor: pointer; font-size: 13px; text-decoration: none; }
.chip:hover { color: var(--text); text-decoration: none; }
.chip[aria-pressed="true"] { background: #f4e7cf; border-color: var(--accent); color: var(--accent-text); font-weight: 500; }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 2px 9px; border-radius: 999px; font-size: 12px; background: var(--bg-2); color: var(--text-2); white-space: nowrap; }
.pill .dot { width: 7px; height: 7px; border-radius: 50%; }
.badge { min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; background: #25d366; color: #fff; font-size: 11px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; font-style: normal; }
.wa { font-size: 10px; font-weight: 700; letter-spacing: .04em; padding: 2px 6px; border-radius: 6px; background: #e3f7e9; color: #1d8a4a; }
.muted { color: var(--muted); }
.row { display: flex; align-items: center; gap: 10px; }
.grow { flex: 1; min-width: 0; }
.ell { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.toggle { display: flex; align-items: center; gap: 10px; cursor: pointer; }
.toggle input { width: 18px; height: 18px; accent-color: var(--accent-2); flex: none; }

/* ---------- login ---------- */
.login { height: 100%; display: grid; place-items: center; padding: 16px; background: radial-gradient(900px 500px at 15% 0%, #3a2c18 0%, transparent 60%), var(--night); overflow: auto; }
.login form { width: min(380px, 100%); background: var(--panel); border-radius: 18px; padding: 34px 28px; display: grid; gap: 16px; box-shadow: 0 30px 80px -30px rgba(0, 0, 0, .7); }
.login h1 { margin: 0; font: 500 34px/1 var(--serif); letter-spacing: .18em; color: var(--text); }
.login .err { color: var(--bad); font-size: 13px; min-height: 18px; }

/* ---------- shell: sidebar + main ---------- */
.app { height: 100%; display: grid; grid-template-columns: 232px 1fr; }
.sidebar { background: var(--night); color: var(--night-text); display: flex; flex-direction: column; padding: 18px 12px 14px; gap: 18px; min-height: 0; }
.brand { padding: 4px 10px 14px; border-bottom: 1px solid rgba(201, 163, 106, .18); }
.brand b { display: block; font: 500 26px/1 var(--serif); letter-spacing: .2em; color: var(--accent); }
.brand small { display: block; margin-top: 6px; font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--night-muted); }
.nav { display: grid; gap: 2px; }
.nav a { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px; color: var(--night-text); font-weight: 500; text-decoration: none; opacity: .82; }
.nav a:hover { background: var(--night-2); opacity: 1; }
.nav a[aria-current="page"] { background: rgba(201, 163, 106, .16); color: #e9c993; opacity: 1; }
.nav a svg { width: 18px; height: 18px; flex: none; }
.nav a span { flex: 1; }
.nav .badge { background: #25d366; }
.nav .badge.red { background: var(--bad); }
.side-foot { margin-top: auto; display: grid; gap: 8px; border-top: 1px solid rgba(201, 163, 106, .18); padding-top: 12px; }
.side-foot .row { padding: 0 6px; }
.side-foot .btn.ghost { color: var(--night-muted); }
.side-foot .btn.ghost:hover { background: var(--night-2); color: var(--night-text); }
.me { display: flex; align-items: center; gap: 10px; min-width: 0; }
.me b { display: block; font-size: 13px; font-weight: 600; color: var(--night-text); }
.me small { display: block; font-size: 11px; color: var(--night-muted); }
.avatar { width: 32px; height: 32px; border-radius: 50%; display: inline-grid; place-items: center; background: #ead8b6; color: #5a4220; font-size: 12px; font-weight: 700; flex: none; }
.sidebar .avatar { background: #3a2f22; color: #e9c993; }
.avatar.sm { width: 22px; height: 22px; font-size: 10px; }
.main-col { min-width: 0; min-height: 0; display: flex; flex-direction: column; }
.demo-banner { padding: 7px 18px; background: #fbefd7; border-bottom: 1px solid #ecd5a8; color: #7a5410; font-size: 13px; }
main { flex: 1; min-height: 0; overflow: auto; }
.view { padding: 18px 22px 28px; }
.view-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }
.view-head h2 { margin: 0 8px 0 0; font: 500 24px/1.1 var(--serif); }

/* ---------- kanban ---------- */
.kanban-view { height: 100%; display: flex; flex-direction: column; padding-bottom: 0; }
.board { flex: 1; min-height: 0; display: flex; gap: 12px; overflow-x: auto; padding-bottom: 16px; }
.col { flex: 0 0 292px; display: flex; flex-direction: column; min-height: 0; background: var(--bg-2); border-radius: 14px; border-top: 3px solid var(--c, var(--info)); }
.col.drop { outline: 2px dashed var(--accent); outline-offset: -2px; background: #f3ead8; }
.col-head { padding: 11px 12px 8px; }
.col-head .row { justify-content: space-between; }
.col-head b { color: var(--text); font-size: 14px; font-weight: 600; }
.col-head small { display: block; color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.col-count { font-size: 12px; padding: 1px 8px; border-radius: 999px; background: var(--panel); color: var(--text-2); font-weight: 600; }
.col-sum { font-size: 12px; color: var(--accent-text); margin-top: 2px; font-weight: 500; }
.col-body { flex: 1; overflow-y: auto; padding: 4px 8px 10px; display: grid; gap: 8px; align-content: start; }
.col-empty { color: var(--muted); text-align: center; padding: 30px 0; font-style: italic; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 10px 11px; cursor: pointer; display: grid; gap: 5px; box-shadow: 0 1px 2px rgba(60, 40, 10, .05); transition: border-color .15s, box-shadow .15s; }
.card:hover { border-color: var(--line-2); box-shadow: 0 6px 18px -10px rgba(60, 40, 10, .35); }
.card.unread { border-left: 3px solid #25d366; }
.card.dragging { opacity: .4; }
.card .name { font-weight: 600; }
.card .last { color: var(--text-2); font-size: 13px; }
.card .meta { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); }
.card .tags { display: flex; flex-wrap: wrap; gap: 4px; }
.card .tags .pill { font-size: 11px; padding: 1px 7px; background: #f6eedf; color: #7a5a2a; }
.sdot { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); flex: none; }
.sdot.wait { background: var(--warn); }
.sdot.late { background: var(--bad); box-shadow: 0 0 0 3px rgba(201, 72, 95, .18); }
.more-btn { width: 100%; }

/* ---------- WhatsApp-style chats page ---------- */
.chats { height: 100%; display: grid; grid-template-columns: 340px 1fr; min-height: 0; }
.chat-list { display: flex; flex-direction: column; min-height: 0; background: var(--panel); border-right: 1px solid var(--line); }
.cl-head { padding: 16px 14px 10px; display: grid; gap: 10px; border-bottom: 1px solid var(--line); }
.cl-head h2 { margin: 0; font: 500 24px/1.1 var(--serif); }
.cl-tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.cl-tabs .chip { height: 28px; font-size: 12px; padding: 0 10px; }
.cl-items { flex: 1; overflow-y: auto; }
.cl-row { display: flex; gap: 12px; padding: 10px 14px; border-bottom: 1px solid #f1eadf; color: var(--text); text-decoration: none; align-items: center; }
.cl-row:hover { background: var(--panel-2); text-decoration: none; }
.cl-row.active { background: #f4e7cf; }
.cl-av { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; background: #ead8b6; color: #5a4220; font-weight: 700; flex: none; box-shadow: 0 0 0 2px var(--panel), 0 0 0 4px var(--c, transparent); }
.cl-main { flex: 1; min-width: 0; display: grid; gap: 2px; }
.cl-top, .cl-bottom { display: flex; align-items: center; gap: 8px; min-width: 0; }
.cl-name { font-weight: 600; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cl-time { font-size: 12px; color: var(--muted); flex: none; }
.cl-row.unread .cl-time { color: #1aa457; font-weight: 600; }
.cl-last { flex: 1; min-width: 0; font-size: 13px; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cl-stage { font-size: 11px; color: var(--muted); white-space: nowrap; }
.chat-pane { min-width: 0; min-height: 0; display: flex; }
.chat-pane > * { flex: 1; min-width: 0; }
.pane-empty { display: grid; place-items: center; text-align: center; color: var(--muted); background: var(--wa-bg); padding: 24px; }
.pane-empty b { display: block; font: 500 30px/1 var(--serif); letter-spacing: .18em; color: var(--accent-2); margin-bottom: 10px; }

/* ---------- lead drawer / chat ---------- */
.drawer-wrap { position: fixed; inset: 0; z-index: 40; background: rgba(28, 20, 10, .38); display: flex; justify-content: flex-end; }
.drawer { width: min(1180px, 100%); height: 100%; background: var(--bg); display: grid; grid-template-rows: auto 1fr; box-shadow: var(--shadow); animation: slide .2s ease-out; min-height: 0; }
.drawer.in-pane { width: 100%; animation: none; box-shadow: none; }
@keyframes slide { from { transform: translateX(30px); opacity: 0; } }
.d-head { display: flex; align-items: center; gap: 12px; padding: 10px 16px; border-bottom: 1px solid var(--line); background: var(--panel); flex-wrap: wrap; }
.d-head .title { display: grid; min-width: 0; flex: 1; }
.d-head .title input { background: transparent; border: 1px solid transparent; border-radius: 8px; padding: 2px 6px; margin-left: -6px; font-size: 17px; font-weight: 600; width: 100%; outline: none; }
.d-head .title input:hover, .d-head .title input:focus { border-color: var(--line-2); background: #fff; }
.d-head .title small { color: var(--text-2); }
.d-head select { width: auto; }
.d-body { min-height: 0; display: grid; grid-template-columns: 1fr 370px; }
.d-tabs { display: none; }
.chat { min-height: 0; display: grid; grid-template-rows: 1fr auto; border-right: 1px solid var(--line);
  background: var(--wa-bg) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120' viewBox='0 0 120 120'%3E%3Cg fill='none' stroke='%23c9a36a' stroke-opacity='.13' stroke-width='1.2'%3E%3Ccircle cx='20' cy='20' r='6'/%3E%3Cpath d='M70 15l6 6-6 6-6-6z'/%3E%3Cpath d='M95 70c0-6 8-6 8 0s-8 6-8 0'/%3E%3Cpath d='M25 85h12M31 79v12'/%3E%3Ccircle cx='75' cy='100' r='3'/%3E%3C/g%3E%3C/svg%3E"); }
.msgs { overflow-y: auto; padding: 16px 6%; display: flex; flex-direction: column; gap: 4px; }
.day-sep { align-self: center; font-size: 12px; color: var(--text-2); background: #fffaf1; box-shadow: 0 1px 1px rgba(0, 0, 0, .06); padding: 3px 12px; border-radius: 8px; margin: 10px 0 6px; }
.msg { max-width: min(560px, 75%); padding: 6px 9px 4px; border-radius: 10px; background: var(--bubble-in); align-self: flex-start; position: relative; overflow-wrap: anywhere; box-shadow: 0 1px 1px rgba(0, 0, 0, .08); }
.msg .txt { white-space: pre-wrap; }
.msg.out { background: var(--bubble-out); align-self: flex-end; border-top-right-radius: 3px; }
.msg.in { border-top-left-radius: 3px; }
.msg .foot { display: flex; justify-content: flex-end; gap: 4px; align-items: center; font-size: 11px; color: #7d8a7a; margin-top: 1px; white-space: nowrap; }
.msg.in .foot { color: var(--muted); }
.msg .by { font-size: 12px; color: #b07a2a; font-weight: 600; margin-bottom: 1px; }
.msg .tick.read { color: #53bdeb; }
.msg .tick.failed { color: var(--bad); }
.msg .err { font-size: 12px; color: var(--bad); margin-top: 4px; }
.msg img, .msg video { display: block; max-width: 100%; max-height: 320px; border-radius: 8px; margin-bottom: 4px; cursor: zoom-in; }
.msg audio { width: 260px; max-width: 100%; display: block; }
.msg .doc { display: flex; gap: 8px; align-items: center; padding: 8px 10px; background: rgba(0, 0, 0, .04); border-radius: 8px; margin-bottom: 4px; }
.msg .quote { border-left: 3px solid #25d366; background: rgba(0, 0, 0, .05); padding: 4px 8px; border-radius: 6px; font-size: 12px; color: var(--text-2); margin-bottom: 4px; white-space: normal; }
.msg .react { position: absolute; bottom: -12px; right: 8px; background: #fff; border-radius: 999px; padding: 0 5px; font-size: 13px; box-shadow: 0 1px 3px rgba(0, 0, 0, .15); }
.msg .reply-btn { position: absolute; top: 2px; right: -34px; opacity: 0; }
.msg.out .reply-btn { right: auto; left: -34px; }
.msg:hover .reply-btn { opacity: 1; }
.composer { border-top: 1px solid var(--line); padding: 10px 12px; background: #f6f1e8; display: grid; gap: 8px; }
.composer textarea { min-height: 44px; max-height: 180px; resize: none; border-radius: 22px; padding: 11px 16px; }
.composer .bar { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.composer .btn.primary { border-radius: 999px; }
.replying { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--text-2); border-left: 3px solid #25d366; padding-left: 8px; background: #fff; border-radius: 6px; }
.window-closed { background: #fbefd7; border: 1px solid #ecd5a8; color: #7a5410; padding: 8px 10px; border-radius: 10px; font-size: 13px; }
.menu { position: absolute; z-index: 60; background: var(--panel); border: 1px solid var(--line-2); border-radius: 12px; box-shadow: var(--shadow); padding: 6px; min-width: 240px; max-width: 360px; max-height: 360px; overflow: auto; }
.menu button { display: block; width: 100%; text-align: left; background: none; border: 0; padding: 8px 10px; border-radius: 8px; cursor: pointer; }
.menu button:hover { background: var(--panel-2); }
.menu button small { display: block; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.side { min-height: 0; overflow-y: auto; padding: 14px; display: grid; gap: 12px; align-content: start; background: var(--bg); }
.box { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; display: grid; gap: 10px; }
.box h4 { margin: 0; font-size: 12px; text-transform: uppercase; letter-spacing: .1em; color: var(--text-2); display: flex; align-items: center; gap: 8px; }
.box h4 .btn { margin-left: auto; text-transform: none; letter-spacing: 0; }
.box h4 > svg { width: 16px; height: 16px; flex: none; }
.ai-box { border-color: #e4cfa6; background: linear-gradient(180deg, #fbf3e3, var(--panel) 70%); }
.ai-box h4 { color: var(--accent-text); }
.ai-summary { font-size: 14px; }
.ai-next { display: flex; gap: 8px; font-size: 13px; background: #f6ecda; border-radius: 8px; padding: 8px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.conflict { color: var(--bad); font-size: 12px; }
.tasks-list { display: grid; gap: 6px; }
.task { display: flex; gap: 8px; align-items: flex-start; font-size: 13px; }
.task input { margin-top: 3px; accent-color: var(--accent-2); }
.task.done .t { text-decoration: line-through; color: var(--muted); }
.task .due { font-size: 12px; color: var(--muted); }
.task .due.late { color: var(--bad); }
.task-add { display: grid; grid-template-columns: 1fr auto; gap: 6px; }
.task-add #t-title { grid-column: 1 / -1; }
.history { display: grid; gap: 6px; font-size: 12px; color: var(--text-2); max-height: 220px; overflow: auto; }

/* ---------- tables ---------- */
.table-wrap { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid #f0e8db; white-space: nowrap; }
th { font-size: 11px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; position: sticky; top: 0; background: var(--panel); }
tbody tr { cursor: pointer; }
tbody tr:hover { background: var(--panel-2); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- calendar ---------- */
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; }
.cal .dow { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; padding: 0 6px; }
.cal .day { min-height: 112px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 6px; display: flex; flex-direction: column; gap: 4px; }
.cal .day.other { opacity: .4; }
.cal .day.today { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(201, 163, 106, .25); }
.cal .day .n { font-size: 12px; color: var(--text-2); font-weight: 500; }
.ev { font-size: 12px; padding: 3px 6px; border-radius: 6px; cursor: pointer; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; border: 1px dashed var(--line-2); color: var(--text-2); background: #fff; }
.ev.booked { border-style: solid; border-color: #9fd6b2; background: #e6f6ec; color: #1d6b3d; }
.ev.clash { border-color: var(--bad); background: #fbe5e9; color: #9a2a40; }

/* ---------- analytics ---------- */
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; margin-bottom: 14px; }
.kpi { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.kpi span { font-size: 12px; color: var(--muted); }
.kpi b { display: block; font-size: 26px; font-weight: 600; margin-top: 2px; font-variant-numeric: tabular-nums; }
.kpi small { color: var(--text-2); font-size: 12px; }
.charts { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 12px; }
.chart-card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; min-width: 0; }
.chart-card.wide { grid-column: 1 / -1; }
.chart-card h3 { margin: 0 0 2px; font-size: 15px; }
.chart-card p { margin: 0 0 10px; font-size: 12px; color: var(--muted); }
.bars-v { position: relative; }
.bars-v svg { display: block; width: 100%; height: 220px; overflow: visible; }
.bars-v .bar { fill: var(--accent); }
.bars-v .bar.hover { fill: var(--accent-2); }
.bars-v .grid { stroke: #ece3d4; stroke-width: 1; }
.bars-v .axis { fill: var(--muted); font-size: 11px; }
.tip { position: absolute; pointer-events: none; background: var(--night); color: var(--night-text); border-radius: 8px; padding: 6px 9px; font-size: 12px; white-space: nowrap; transform: translate(-50%, -110%); z-index: 5; }
.hbars { display: grid; gap: 8px; }
.hbar { display: grid; grid-template-columns: minmax(110px, 38%) 1fr auto; gap: 10px; align-items: center; font-size: 13px; }
.hbar .track { height: 12px; border-radius: 4px; background: var(--bg-2); overflow: hidden; }
.hbar .fill { height: 100%; border-radius: 0 4px 4px 0; background: var(--accent); min-width: 2px; }
.hbar .v { font-variant-numeric: tabular-nums; color: var(--text-2); min-width: 28px; text-align: right; }

/* ---------- settings ---------- */
.settings { display: grid; grid-template-columns: repeat(auto-fit, minmax(440px, 1fr)); gap: 12px; align-items: start; }
.settings .box { padding: 16px; }
.stage-row { display: grid; grid-template-columns: 34px minmax(0, 1.3fr) minmax(0, 1fr) 112px auto; gap: 6px; align-items: center; }
.stage-row input[type="color"] { width: 34px; height: 34px; border: 0; background: none; padding: 0; cursor: pointer; }
.list-row { display: flex; gap: 6px; }
.code { font-family: ui-monospace, Menlo, monospace; font-size: 12px; background: var(--bg); border: 1px solid var(--line); padding: 8px 10px; border-radius: 8px; word-break: break-all; }
ol.steps { margin: 0; padding-left: 18px; display: grid; gap: 6px; color: var(--text-2); font-size: 13px; }

/* ---------- modal & toast ---------- */
.modal-wrap { position: fixed; inset: 0; z-index: 70; background: rgba(28, 20, 10, .45); display: grid; place-items: center; padding: 16px; }
.modal { width: min(440px, 100%); background: var(--panel); border-radius: 16px; padding: 20px; display: grid; gap: 14px; box-shadow: var(--shadow); }
.modal h3 { margin: 0; font: 500 20px/1.2 var(--serif); }
.modal .actions { display: flex; justify-content: flex-end; gap: 8px; }
.toasts { position: fixed; bottom: 16px; right: 16px; z-index: 80; display: grid; gap: 8px; }
.toast { background: var(--night); color: var(--night-text); border-left: 3px solid var(--accent); border-radius: 10px; padding: 10px 14px; box-shadow: var(--shadow); max-width: 360px; animation: slide .2s; }
.toast.err { border-left-color: var(--bad); }
.lightbox { position: fixed; inset: 0; z-index: 90; background: rgba(0, 0, 0, .88); display: grid; place-items: center; cursor: zoom-out; }
.lightbox img { max-width: 94vw; max-height: 92vh; border-radius: 8px; }

/* ---------- responsive ---------- */
@media (max-width: 1180px) {
  .app { grid-template-columns: 72px 1fr; }
  .brand small, .nav a span, .me div { display: none; }
  .brand { padding: 4px 0 14px; text-align: center; }
  .brand b { font-size: 18px; letter-spacing: .08em; }
  .nav a { justify-content: center; position: relative; padding: 11px 0; }
  .nav .badge { position: absolute; top: 2px; right: 6px; min-width: 16px; height: 16px; font-size: 10px; padding: 0 4px; }
  .side-foot .row { flex-direction: column; padding: 0; }
  .d-body { grid-template-columns: 1fr 320px; }
  .chats { grid-template-columns: 300px 1fr; }
}
@media (max-width: 820px) {
  .app { grid-template-columns: 1fr; grid-template-rows: 1fr auto; }
  .sidebar { order: 2; flex-direction: row; padding: 6px 8px calc(6px + env(safe-area-inset-bottom)); gap: 0; }
  .brand, .side-foot { display: none; }
  .nav { display: flex; width: 100%; justify-content: space-around; }
  .nav a { flex-direction: column; gap: 2px; padding: 6px 4px; font-size: 10px; }
  .nav a span { display: block; flex: none; }
  .nav .badge { top: 0; right: 4px; }
  .main-col { order: 1; }
  .view { padding: 12px; }
  .col { flex-basis: 84vw; }
  .chats { grid-template-columns: 1fr; }
  .chats .chat-pane { display: none; }
  .chats.has-open .chat-list { display: none; }
  .chats.has-open .chat-pane { display: flex; }
  .d-tabs { display: flex; gap: 6px; padding: 8px 12px; border-bottom: 1px solid var(--line); background: var(--panel); }
  .drawer { grid-template-rows: auto auto 1fr; }
  .d-body { grid-template-columns: 1fr; }
  .d-body[data-tab="chat"] .side, .d-body[data-tab="card"] .chat { display: none; }
  .chat { border-right: 0; }
  .msgs { padding: 12px; }
  .msg { max-width: 86%; }
  .msg .reply-btn { display: none; }
  .settings { grid-template-columns: 1fr; }
  .stage-row { grid-template-columns: 34px 1fr 96px auto; }
  .stage-row .desc { display: none; }
  .cal .day { min-height: 70px; }
  .cal .ev { font-size: 10px; padding: 1px 3px; }
  .charts { grid-template-columns: 1fr; }
}
