* { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --bg:#0f1419; --panel:#171d26; --panel2:#1f2733; --line:#2a3441;
  --txt:#e6edf3; --muted:#8a96a3; --accent:#3b82f6; --green:#22c55e;
  --red:#ef4444; --amber:#f59e0b; --in:#243447; --out:#1e3a2e;
}
body { background:var(--bg); color:var(--txt); font:14px/1.5 -apple-system,Segoe UI,Roboto,sans-serif; }
header { background:var(--panel); border-bottom:1px solid var(--line); padding:14px 20px; position:sticky; top:0; z-index:10; }
h1 { font-size:18px; margin-bottom:10px; }
.ranges { display:flex; align-items:center; gap:8px; flex-wrap:wrap; }
.ranges button, .tabs button, #applyCustom {
  background:var(--panel2); color:var(--txt); border:1px solid var(--line);
  padding:6px 14px; border-radius:6px; cursor:pointer; font-size:13px;
}
.ranges button.active, .tabs button.active { background:var(--accent); border-color:var(--accent); }
.ranges button:hover, .tabs button:hover { border-color:var(--accent); }
.tabs { margin-top:10px; display:flex; gap:8px; }
input[type=date] { background:var(--panel2); color:var(--txt); border:1px solid var(--line); padding:5px; border-radius:6px; }
.status { color:var(--muted); font-size:12px; margin-left:auto; }
.hidden { display:none !important; }
main { padding:18px 20px; }

.charge-card { background:var(--panel); border:1px solid var(--line); border-radius:8px; padding:12px 16px; margin-bottom:12px; }
.charge-summary { display:flex; gap:20px; flex-wrap:wrap; align-items:center; }
.cs { display:flex; flex-direction:column; }
.cv { font-size:18px; font-weight:700; color:var(--green); }
.cl { font-size:11px; color:var(--muted); }
.price-tag { color:var(--green); font-weight:600; }
.texts-layout { display:grid; grid-template-columns:340px 1fr; gap:16px; height:calc(100vh - 240px); }
.thread-list { overflow-y:auto; border:1px solid var(--line); border-radius:8px; background:var(--panel); }
.thread-item { padding:12px 14px; border-bottom:1px solid var(--line); cursor:pointer; }
.thread-item:hover { background:var(--panel2); }
.thread-item.active { background:var(--panel2); border-left:3px solid var(--accent); }
.thread-item .nm { font-weight:600; }
.thread-item .ph { color:var(--muted); font-size:12px; }
.thread-item .sn { color:var(--muted); font-size:12px; margin-top:4px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.badge { font-size:10px; padding:2px 6px; border-radius:10px; margin-left:6px; }
.badge.reply { background:var(--green); color:#04210f; }
.badge.iso { background:var(--amber); color:#3b2a04; }

.thread-view { overflow-y:auto; border:1px solid var(--line); border-radius:8px; background:var(--panel); padding:16px; }
.tv-head { display:flex; justify-content:space-between; align-items:flex-start; border-bottom:1px solid var(--line); padding-bottom:12px; margin-bottom:14px; }
.tv-head h2 { font-size:17px; }
.tv-head .ph { color:var(--muted); font-size:13px; }
.iso-card { background:var(--panel2); border:1px solid var(--amber); border-radius:8px; padding:12px; margin-bottom:14px; }
.iso-card h3 { font-size:13px; color:var(--amber); margin-bottom:8px; }
.iso-card table { width:100%; font-size:12px; border-collapse:collapse; }
.iso-card td { padding:3px 6px; border-bottom:1px solid var(--line); vertical-align:top; }
.iso-card td:first-child { color:var(--muted); width:38%; }
.bubble { max-width:72%; padding:9px 13px; border-radius:12px; margin:8px 0; clear:both; }
.bubble.out { background:var(--out); float:right; border-bottom-right-radius:3px; }
.bubble.in { background:var(--in); float:left; border-bottom-left-radius:3px; }
.bubble .meta { font-size:11px; color:var(--muted); margin-top:5px; }
.draft-box { clear:both; margin-top:18px; border-top:1px solid var(--line); padding-top:14px; }
.draft-box textarea { width:100%; min-height:80px; background:var(--panel2); color:var(--txt);
  border:1px solid var(--line); border-radius:8px; padding:10px; font:inherit; resize:vertical; }
.draft-box .row { display:flex; gap:8px; margin-top:8px; }
.draft-box button { background:var(--accent); color:#fff; border:0; padding:8px 16px; border-radius:6px; cursor:pointer; }
.draft-box button.ghost { background:var(--panel2); border:1px solid var(--line); color:var(--txt); }
.draft-box button.send { background:var(--green); color:#04210f; font-weight:700; }
.draft-box button.send:disabled { background:var(--panel2); color:var(--muted); cursor:not-allowed; border:1px solid var(--line); }
.send-note { font-size:12px; color:var(--muted); margin-top:6px; }
.convo-cost { font-size:12px; color:var(--green); font-weight:600; margin-left:6px; }
.saved-drafts { margin-top:12px; }
.saved-drafts .d { background:var(--panel2); border:1px solid var(--line); border-radius:6px; padding:8px 10px; margin-top:6px; font-size:13px; display:flex; justify-content:space-between; gap:10px; }
.saved-drafts .d small { color:var(--muted); }
.saved-drafts .d button { background:none; border:0; color:var(--red); cursor:pointer; }

.totals { display:flex; gap:14px; margin-bottom:16px; flex-wrap:wrap; }
.totals .t { background:var(--panel); border:1px solid var(--line); border-radius:8px; padding:14px 20px; min-width:120px; }
.totals .t .n { font-size:24px; font-weight:700; }
.totals .t .l { color:var(--muted); font-size:12px; }
.wf-grid { display:grid; grid-template-columns:repeat(auto-fill,minmax(280px,1fr)); gap:14px; }
.wf-card { background:var(--panel); border:1px solid var(--line); border-radius:8px; padding:16px; }
.wf-card.text { border-color:var(--accent); box-shadow:0 0 0 1px var(--accent); }
.wf-card h3 { font-size:15px; margin-bottom:4px; }
.wf-card .pin { font-size:11px; color:var(--accent); }
.wf-card .stats { display:flex; gap:14px; margin-top:12px; }
.wf-card .stats div { font-size:12px; color:var(--muted); }
.wf-card .stats b { display:block; font-size:20px; color:var(--txt); }
.wf-card .ok b { color:var(--green); } .wf-card .err b { color:var(--red); }
.wf-card .meta { color:var(--muted); font-size:12px; margin-top:10px; }
.warn { color:var(--amber); font-size:12px; margin-top:8px; }

/* Billing */
.bill-header { margin-bottom:20px; }
.bill-num-badge { font-size:13px; font-weight:600; color:var(--accent); margin-bottom:8px; }
.bill-total { display:flex; align-items:baseline; gap:14px; margin-bottom:14px; }
.bill-amt { font-size:36px; font-weight:800; color:var(--green); }
.bill-sub { color:var(--muted); font-size:13px; }
.bill-tiles { display:flex; gap:14px; flex-wrap:wrap; margin-bottom:8px; }
.bill-tile { background:var(--panel2); border:1px solid var(--line); border-radius:8px; padding:12px 18px; }
.bill-tile-val { font-size:22px; font-weight:700; }
.bill-tile-val.green { color:var(--green); }
.bill-tile-val.accent { color:var(--accent); }
.bill-tile-val.amber { color:var(--amber); }
.bill-tile-lbl { font-size:12px; color:var(--muted); margin-top:2px; }
.bill-month-table td.green { color:var(--green); }
.bill-month-table td.accent { color:var(--accent); }
.bill-month-table td.amber { color:var(--amber); }
.bill-groups { display:grid; grid-template-columns:repeat(auto-fill,minmax(320px,1fr)); gap:14px; margin-bottom:28px; }
.bill-group { background:var(--panel); border:1px solid var(--line); border-radius:8px; padding:14px 16px; }
.bill-ghead { display:flex; justify-content:space-between; align-items:center; margin-bottom:6px; }
.bill-gname { font-weight:600; font-size:14px; }
.bill-gprice { font-size:18px; font-weight:700; }
.bill-bar-bg { background:var(--line); border-radius:4px; height:6px; margin-bottom:10px; }
.bill-bar { height:6px; border-radius:4px; transition:width 0.4s; }
.bill-cat-table { width:100%; border-collapse:collapse; font-size:12px; }
.bill-cat-table td { padding:3px 4px; border-bottom:1px solid var(--line); vertical-align:middle; }
.bill-cat-table td.num { text-align:right; font-variant-numeric:tabular-nums; }
.bill-cat-table td.muted { color:var(--muted); }
.bill-cat-table td.bold { font-weight:700; }
.bill-section-title { font-size:16px; margin-bottom:10px; color:var(--txt); }
.bill-month-wrap { overflow-x:auto; }
.bill-month-table { width:100%; border-collapse:collapse; font-size:13px; background:var(--panel); border-radius:8px; overflow:hidden; }
.bill-month-table th { background:var(--panel2); padding:8px 12px; text-align:right; color:var(--muted); font-size:12px; font-weight:600; border-bottom:1px solid var(--line); }
.bill-month-table th:first-child { text-align:left; }
.bill-month-table td { padding:8px 12px; border-bottom:1px solid var(--line); }
.bill-month-table td.num { text-align:right; font-variant-numeric:tabular-nums; }
.bill-month-table td.bold { font-weight:700; color:var(--green); }
.bill-month-table td.month-label { color:var(--txt); font-weight:600; }
.bill-month-table td.muted { color:var(--muted); }
.bill-month-table td.green { color:var(--green); }
.bill-month-table td.accent { color:var(--accent); }
.bill-month-table tr:hover td { background:var(--panel2); }
.empty { color:var(--muted); text-align:center; padding:40px; }
.spin { color:var(--muted); }
