:root {
  --bg: #0f1013; --panel: #16181c; --panel-2: #1c1f24; --hover: #22262c; --line: #2a2e35;
  --text: #e9eaee; --muted: #8d929c; --faint: #5d626c;
  --accent: #2f6bff; --accent-text: #79aaff; --accent-soft: rgba(47,107,255,.14);
  --green: #34d399; --green-soft: rgba(52,211,153,.13); --red: #ff6b6b; --red-soft: rgba(255,107,107,.13);
  --amber: #f5a623; --amber-soft: rgba(245,166,35,.13); --violet: #b794ff; --violet-soft: rgba(183,148,255,.13);
  --radius: 10px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font: 14px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; }
[hidden] { display: none !important; }
.muted { color: var(--muted); } .small { font-size: 12px; } .err { color: var(--red); min-height: 18px; margin: 0; }
kbd { background: var(--panel-2); border: 1px solid var(--line); border-radius: 4px; padding: 0 5px; font-size: 11px; }
button { font: inherit; color: inherit; cursor: pointer; }
.btn { border: 1px solid var(--line); background: var(--panel-2); border-radius: 8px; padding: 7px 12px; transition: background .12s, border-color .12s; }
.btn:hover { background: var(--hover); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.btn-primary:hover { background: #255cf0; }
.btn-primary[disabled] { background: #2a3550; border-color: #2a3550; color: #9fb3dd; cursor: not-allowed; }
.btn-ghost { background: transparent; }
.btn-danger { color: var(--red); } .btn-ok { color: var(--green); }
.btn-sm { padding: 4px 9px; font-size: 12.5px; }

/* login */
.login { height: 100%; display: grid; place-items: center; }
.login-card { width: 320px; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 28px; display: flex; flex-direction: column; gap: 10px; text-align: center; }
.login-card h1 { margin: 8px 0 0; font-size: 20px; } .login-card p { margin: 0 0 8px; }
.login-card input { background: var(--bg); border: 1px solid var(--line); color: var(--text); border-radius: 8px; padding: 10px; }
.brand-mark { width: 34px; height: 34px; border-radius: 9px; background: linear-gradient(135deg, #2f6bff, #79aaff); display: grid; place-items: center; font-weight: 800; font-size: 13px; color: #fff; margin: 0 auto; }

/* shell */
.app { height: 100%; display: flex; flex-direction: column; }
.top { display: flex; align-items: center; gap: 18px; padding: 10px 16px; border-bottom: 1px solid var(--line); background: var(--panel); }
.brand { display: flex; align-items: center; gap: 10px; } .brand .brand-mark { margin: 0; }
.brand-name { font-weight: 700; } .brand-sub { font-size: 11.5px; color: var(--muted); }
.tabs { display: flex; gap: 4px; margin-left: 10px; }
.tab { background: none; border: 0; padding: 7px 12px; border-radius: 8px; color: var(--muted); font-weight: 600; }
.tab.active { background: var(--accent-soft); color: var(--accent-text); }
.top-right { margin-left: auto; display: flex; align-items: center; gap: 14px; }
.kpi { display: flex; flex-direction: column; align-items: center; line-height: 1.1; min-width: 58px; }
.kpi span { font-size: 17px; font-weight: 700; } .kpi small { color: var(--muted); font-size: 10.5px; }
.kpi.warn span { color: var(--amber); }
.me { font-size: 12.5px; color: var(--muted); }
.banner { background: var(--amber-soft); color: var(--amber); border-bottom: 1px solid rgba(245,166,35,.3); padding: 6px 16px; font-size: 12.5px; text-align: center; }

.inbox { flex: 1; display: grid; grid-template-columns: 220px 360px 1fr; min-height: 0; }
.side { border-right: 1px solid var(--line); background: var(--panel); overflow: auto; padding: 12px 8px; }
.side-title { font-size: 10.5px; text-transform: uppercase; letter-spacing: .07em; color: var(--faint); font-weight: 700; padding: 10px 10px 6px; }
.box { display: flex; align-items: center; justify-content: space-between; width: 100%; background: none; border: 0; padding: 7px 10px; border-radius: 8px; text-align: left; color: var(--text); }
.box:hover { background: var(--hover); } .box.active { background: var(--accent-soft); color: var(--accent-text); font-weight: 600; }
.box .n { font-size: 12px; color: var(--muted); background: var(--panel-2); border-radius: 10px; padding: 0 7px; }
.box.active .n { color: var(--accent-text); }
.side-foot { padding: 14px 10px; font-size: 11.5px; color: var(--faint); }

.list { border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.list-head { padding: 10px; border-bottom: 1px solid var(--line); display: flex; flex-direction: column; gap: 6px; }
.list-head input { background: var(--panel); border: 1px solid var(--line); color: var(--text); border-radius: 8px; padding: 8px 10px; }
.threads { overflow: auto; flex: 1; }
.th { padding: 11px 12px; border-bottom: 1px solid var(--line); cursor: pointer; display: flex; flex-direction: column; gap: 4px; }
.th:hover { background: var(--panel); } .th.active { background: var(--accent-soft); box-shadow: inset 3px 0 0 var(--accent); }
.th-top { display: flex; align-items: center; gap: 6px; }
.th-name { font-weight: 600; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.th-age { font-size: 11.5px; color: var(--muted); white-space: nowrap; }
.th-age.late { color: var(--red); font-weight: 600; }
.th-sub { font-size: 12.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.th-tags { display: flex; gap: 5px; flex-wrap: wrap; }
.dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.s-calme { background: var(--green); } .s-inquiet { background: var(--amber); } .s-fache { background: #ff8f5a; } .s-menacant { background: var(--red); }

.chip { font-size: 11px; border-radius: 10px; padding: 1px 8px; background: var(--panel-2); color: var(--muted); border: 1px solid var(--line); white-space: nowrap; }
.chip.cat { color: var(--accent-text); background: var(--accent-soft); border-color: transparent; }
.chip.money { color: var(--amber); background: var(--amber-soft); border-color: transparent; }
.chip.ok { color: var(--green); background: var(--green-soft); border-color: transparent; }
.chip.red { color: var(--red); background: var(--red-soft); border-color: transparent; }
.chip.violet { color: var(--violet); background: var(--violet-soft); border-color: transparent; }

/* detail */
.detail { overflow: auto; min-height: 0; }
.empty { height: 100%; display: grid; place-content: center; text-align: center; color: var(--muted); }
.empty-icon { font-size: 34px; }
.d-head { position: sticky; top: 0; z-index: 2; background: var(--bg); border-bottom: 1px solid var(--line); padding: 12px 18px; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.d-head h2 { margin: 0; font-size: 17px; } .d-head .email { color: var(--muted); font-size: 12.5px; }
.d-actions { margin-left: auto; display: flex; gap: 6px; flex-wrap: wrap; }
.d-body { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 16px; padding: 16px 18px 28px; }
@media (max-width: 1350px) { .d-body { grid-template-columns: 1fr; } .inbox { grid-template-columns: 190px 320px 1fr; } }

.conv { display: flex; flex-direction: column; gap: 10px; }
.msg { max-width: 88%; border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; background: var(--panel); }
.msg.out { align-self: flex-end; background: #17223a; border-color: #23345a; }
.msg-meta { font-size: 11.5px; color: var(--muted); margin-bottom: 4px; display: flex; gap: 8px; flex-wrap: wrap; }
.msg-subj { font-weight: 600; font-size: 12.5px; margin-bottom: 4px; }
.msg-text { white-space: pre-wrap; word-wrap: break-word; }
.msg-text.clamp { max-height: 190px; overflow: hidden; -webkit-mask-image: linear-gradient(#000 75%, transparent); mask-image: linear-gradient(#000 75%, transparent); }
.msg .more { background: none; border: 0; color: var(--accent-text); padding: 4px 0 0; font-size: 12px; }
.atts { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.atts a { color: var(--accent-text); font-size: 12px; text-decoration: none; border: 1px solid var(--line); border-radius: 6px; padding: 2px 7px; }
.atts img { max-width: 140px; max-height: 120px; border-radius: 6px; border: 1px solid var(--line); display: block; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; margin-bottom: 12px; }
.card h3 { margin: 0 0 8px; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); display: flex; align-items: center; gap: 8px; }
.order { border-top: 1px solid var(--line); padding-top: 9px; margin-top: 9px; }
.order:first-of-type { border-top: 0; padding-top: 0; margin-top: 0; }
.order-head { display: flex; justify-content: space-between; font-weight: 600; }
.order-line { font-size: 12.5px; color: var(--muted); }
.stepper { display: flex; gap: 3px; margin: 8px 0 4px; }
.stepper i { flex: 1; height: 5px; border-radius: 3px; background: var(--line); }
.stepper i.on { background: var(--accent); } .stepper.done i.on { background: var(--green); } .stepper.stuck i.on { background: var(--red); }
.track-lbl { font-size: 12.5px; }
.track-ev { font-size: 11.5px; color: var(--muted); }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 2px 10px; font-size: 12.5px; }

.advice { border-color: #2b3a63; background: linear-gradient(180deg, #161d2f, var(--panel)); }
.advice .resume { font-size: 13.5px; margin: 0 0 6px; }
.advice ul { margin: 4px 0 0 18px; padding: 0; color: var(--amber); font-size: 12.5px; }
.decision { background: var(--amber-soft); border: 1px solid rgba(245,166,35,.35); color: #ffd28a; border-radius: 8px; padding: 8px 10px; font-size: 12.5px; margin-top: 8px; }

.composer { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); margin-top: 6px; }
.composer-head { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.composer textarea { width: 100%; min-height: 300px; resize: vertical; background: transparent; border: 0; color: var(--text); padding: 12px 14px; font: 14px/1.55 inherit; font-family: inherit; outline: none; }
.composer-foot { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 10px 12px; border-top: 1px solid var(--line); }
.composer-foot .spacer { flex: 1; }
.warns { padding: 0 12px 4px; display: flex; flex-direction: column; gap: 4px; }
.warn-b { color: var(--red); font-size: 12.5px; } .warn-a { color: var(--amber); font-size: 12.5px; } .warn-ok { color: var(--green); font-size: 12.5px; }
.instr { display: flex; gap: 6px; padding: 10px 12px; border-top: 1px solid var(--line); }
.instr input { flex: 1; background: var(--bg); border: 1px solid var(--line); color: var(--text); border-radius: 8px; padding: 7px 10px; }
select { background: var(--panel-2); color: var(--text); border: 1px solid var(--line); border-radius: 8px; padding: 5px 8px; font: inherit; font-size: 12.5px; max-width: 260px; }

.review { border-color: #3b2f5c; background: linear-gradient(180deg, #1c1830, var(--panel)); }
.review textarea { width: 100%; min-height: 60px; background: var(--bg); border: 1px solid var(--line); color: var(--text); border-radius: 8px; padding: 8px; font: inherit; margin-top: 8px; }
.verdicts { display: flex; gap: 6px; }
.verdicts .btn.sel { outline: 2px solid var(--violet); }

.doc { flex: 1; overflow: auto; padding: 24px clamp(16px, 5vw, 80px); }
.doc .md { max-width: 920px; }
.doc h1 { font-size: 24px; } .doc h2 { font-size: 18px; margin-top: 28px; border-bottom: 1px solid var(--line); padding-bottom: 6px; } .doc h3 { font-size: 15px; }
.doc table { border-collapse: collapse; margin: 10px 0; font-size: 13px; } .doc td, .doc th { border: 1px solid var(--line); padding: 5px 9px; text-align: left; vertical-align: top; }
.doc th { background: var(--panel-2); } .doc code { background: var(--panel-2); padding: 1px 5px; border-radius: 4px; }
.doc blockquote { border-left: 3px solid var(--accent); margin: 8px 0; padding: 2px 12px; color: var(--muted); }
.tpl { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; margin: 10px 0; max-width: 920px; }
.tpl pre { white-space: pre-wrap; font: 13px/1.5 inherit; font-family: inherit; margin: 8px 0 0; color: #cfd3da; }
.tpl-head { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.doc-search { background: var(--panel); border: 1px solid var(--line); color: var(--text); border-radius: 8px; padding: 8px 10px; width: min(520px, 100%); margin-bottom: 8px; }

.toast { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); background: #23272e; border: 1px solid var(--line); border-radius: 10px; padding: 9px 14px; box-shadow: 0 8px 30px rgba(0,0,0,.4); z-index: 50; max-width: 80vw; }
.toast.bad { border-color: var(--red); color: #ffb3b3; }
.spin { display: inline-block; width: 12px; height: 12px; border: 2px solid var(--line); border-top-color: var(--accent-text); border-radius: 50%; animation: sp .7s linear infinite; vertical-align: -2px; }
@keyframes sp { to { transform: rotate(360deg); } }
.th.urg0 { box-shadow: inset 3px 0 0 var(--red); } .th.urg1 { box-shadow: inset 3px 0 0 var(--amber); }
.th.urg0.active, .th.urg1.active { background: var(--accent-soft); }

/* attachments we send (2026-11-29) */
.att-bar { display: flex; flex-direction: column; gap: 8px; padding: 8px 12px; border-top: 1px solid var(--line); }
.att-list { display: flex; flex-wrap: wrap; gap: 8px; }
.att-list:empty { display: none; }
.att-chip { display: flex; align-items: center; gap: 8px; border: 1px solid var(--line); border-radius: 8px; padding: 4px 6px 4px 4px; background: var(--panel-2); max-width: 100%; }
.att-chip img { width: 54px; height: 54px; object-fit: cover; object-position: top; border-radius: 6px; display: block; }
.att-chip a { text-decoration: none; font-size: 26px; }
.att-name { font-size: 12px; overflow-wrap: anywhere; }
.att-x { border: 0; background: none; color: var(--muted); font-size: 18px; cursor: pointer; line-height: 1; padding: 0 4px; }
.att-x:hover { color: var(--red); }
.att-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.composer.drop { outline: 2px dashed var(--accent-text); outline-offset: -4px; }

/* AI cost per conversation (2026-11-29) */
.costs .cost-total { display: flex; align-items: baseline; gap: 8px; margin-bottom: 6px; }
.costs .cost-total b { font-size: 20px; font-variant-numeric: tabular-nums; }
.costs .cost-row { display: flex; justify-content: space-between; gap: 10px; padding: 4px 0; border-top: 1px solid var(--line); }
.costs .cost-v { font-variant-numeric: tabular-nums; white-space: nowrap; font-size: 12.5px; }

/* refund (admin only, 2026-11-29) */
.refund-zone { margin: 6px 0; }
.btn-refund { border-color: var(--red); color: var(--red); }
.refund-panel { display: flex; flex-direction: column; gap: 8px; padding: 10px; border: 1px solid var(--red); border-radius: 8px; background: var(--red-soft); }
.refund-panel input { display: block; margin-top: 4px; width: 140px; background: var(--bg); color: var(--text); border: 1px solid var(--line); border-radius: 6px; padding: 5px 8px; font-variant-numeric: tabular-nums; }
.refund-btns { display: flex; gap: 8px; }

.refund-notify { display: flex; gap: 6px; align-items: flex-start; }
.refund-notify input { width: auto !important; margin-top: 2px !important; display: inline !important; }

/* feedback for the AI (2026-11-29) */
.feedback textarea { width: 100%; min-height: 64px; background: var(--bg); color: var(--text); border: 1px solid var(--line); border-radius: 8px; padding: 8px; margin-bottom: 6px; }
.fb-item { border-top: 1px solid var(--line); padding: 6px 0; display: flex; flex-direction: column; gap: 2px; }

/* tracking links (2026-11-29, free: public tracking pages) */
.track-no { color: var(--accent-text); text-decoration: none; font-variant-numeric: tabular-nums; }
.track-no:hover { text-decoration: underline; }
.track-links { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0; }
.track-links a, .track-copy { font-size: 11.5px; color: var(--accent-text); text-decoration: none; border: 1px solid var(--line); border-radius: 6px; padding: 1px 7px; background: none; cursor: pointer; }
.track-links a:hover, .track-copy:hover { border-color: var(--accent-text); }

/* 2026-11-30 time-zone picker */
.tz-pick { background: var(--bg); color: var(--text); border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; font-size: 12.5px; }
.tz-wrap { display: flex; align-items: center; gap: 6px; } .tz-ico { font-size: 16px; }
