:root {
  --bg: #f6f6f3; --panel: #fff; --ink: #1b1d1c; --muted: #6b706d; --line: #e4e4df;
  --accent: #127a52; --accent-ink: #fff; --bubble-out: #dcf3e6; --bubble-in: #fff; --danger: #b42318;
  font: 14px/1.45 ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif; color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #121413; --panel: #1b1e1c; --ink: #e8eae8; --muted: #949a96; --line: #2b2f2d;
    --accent: #3fbf86; --accent-ink: #08130e; --bubble-out: #1f3a2c; --bubble-in: #232725; --danger: #f97066; }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); }
[hidden] { display: none !important; }
button { font: inherit; border: 0; border-radius: 8px; padding: 8px 14px; background: var(--accent); color: var(--accent-ink); cursor: pointer; font-weight: 600; }
button.ghost { background: transparent; color: var(--muted); border: 1px solid var(--line); font-weight: 500; }
button:active { transform: scale(.97); }
input, select, textarea { font: inherit; color: inherit; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; width: 100%; }
code, .mono { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 12.5px; }
.err { color: var(--danger); min-height: 1.2em; }

.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login form { width: min(380px, 100%); display: grid; gap: 12px; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 28px; }
.login h1 { margin: 0; font-size: 22px; }
.login p { margin: 0; color: var(--muted); }
.login .fine { font-size: 12px; } .login a { color: var(--muted); }
.tabs { display: flex; gap: 4px; background: var(--bg); padding: 3px; border-radius: 9px; }
.tab { flex: 1; background: transparent; color: var(--muted); padding: 6px 8px; font-weight: 500; font-size: 13px; }
.tab.on { background: var(--panel); color: var(--ink); box-shadow: 0 1px 2px rgb(0 0 0 / .08); }
.meter { height: 8px; border-radius: 99px; background: var(--bg); border: 1px solid var(--line); overflow: hidden; margin: 6px 0 2px; }
.meter i { display: block; height: 100%; background: var(--accent); }
.meter i.hot { background: var(--danger); }
.plans { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; }
.plan { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 16px; display: flex; flex-direction: column; gap: 6px; }
.plan.current { border-color: var(--accent); }
.plan .price { font-size: 22px; font-weight: 700; }
.plan ul { margin: 4px 0 8px; padding-left: 18px; color: var(--muted); }
.plan button { margin-top: auto; }
.banner { background: var(--bubble-out); border-radius: 12px; padding: 14px 16px; margin-bottom: 16px; }

.shell { display: grid; grid-template-columns: 200px 1fr; min-height: 100vh; }
nav { border-right: 1px solid var(--line); padding: 18px 12px; display: flex; flex-direction: column; gap: 2px; background: var(--panel); }
nav .brand { font-weight: 800; font-size: 18px; padding: 0 10px 14px; }
nav a { color: var(--muted); text-decoration: none; padding: 7px 10px; border-radius: 7px; }
nav a.on { background: var(--bg); color: var(--ink); font-weight: 600; }
nav button { margin-top: auto; }
main { padding: 24px 28px; min-width: 0; }
h2 { margin: 0 0 16px; font-size: 20px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 16px; margin-bottom: 16px; }
.card h3 { margin: 0 0 10px; font-size: 14px; }
table { width: 100%; border-collapse: collapse; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
th, td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 500; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
tr:last-child td { border-bottom: 0; }
.pill { display: inline-block; padding: 1px 8px; border-radius: 99px; font-size: 12px; background: var(--bg); border: 1px solid var(--line); }
.pill.good { color: var(--accent); } .pill.bad { color: var(--danger); }
.secret { background: var(--bg); padding: 10px; border-radius: 8px; word-break: break-all; }

.inbox { display: grid; grid-template-columns: 300px 1fr; height: max(420px, calc(100vh - 200px)); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: var(--panel); }
.convs { border-right: 1px solid var(--line); overflow: auto; }
.conv { padding: 12px 14px; border-bottom: 1px solid var(--line); cursor: pointer; }
.conv.on { background: var(--bg); }
.conv b { display: block; }
.conv span { color: var(--muted); font-size: 13px; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.thread { display: flex; flex-direction: column; min-width: 0; }
.thread header { padding: 12px 16px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.msgs { flex: 1; overflow: auto; padding: 16px; display: flex; flex-direction: column; gap: 6px; background: var(--bg); }
.bubble { max-width: 70%; padding: 7px 11px; border-radius: 10px; background: var(--bubble-in); border: 1px solid var(--line); white-space: pre-wrap; word-wrap: break-word; }
.bubble.out { align-self: flex-end; background: var(--bubble-out); border-color: transparent; }
.bubble small { display: block; color: var(--muted); font-size: 11px; margin-top: 2px; text-align: right; }
.composer { display: flex; gap: 8px; padding: 12px; border-top: 1px solid var(--line); }
.empty { color: var(--muted); padding: 24px; text-align: center; }

.sub { color: var(--muted); margin: -8px 0 16px; max-width: 760px; }
.biz { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 16px; align-items: start; }
.biz-form { display: grid; gap: 12px; margin: 0; }
.biz-form label { display: grid; gap: 4px; font-size: 13px; font-weight: 600; }
.biz-form label small, .biz-form legend { color: var(--muted); font-weight: 400; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; }
.days { border: 0; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.days legend { font-size: 13px; margin-bottom: 4px; }
.days label, .switch { display: inline-flex !important; align-items: center; gap: 6px; font-weight: 500 !important; border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; cursor: pointer; }
.days input, .switch input { width: auto; margin: 0; accent-color: var(--accent); }
.ok { color: var(--accent); font-weight: 600; }
.cmds { color: var(--muted); font-size: 13px; } .cmds summary { cursor: pointer; } .cmds ul { margin: 8px 0 0; padding-left: 18px; }
.phone { padding: 0; overflow: hidden; display: flex; flex-direction: column; position: sticky; top: 16px; margin: 0; }
.phone header { padding: 12px 14px; background: var(--accent); color: var(--accent-ink); display: grid; }
.phone header small { opacity: .8; font-size: 12px; }
.phone .msgs { height: 460px; flex: none; }
.phone .bubble { max-width: 85%; }
.chips { display: grid; gap: 4px; margin-top: 8px; }
.chip { background: var(--panel); color: var(--accent); border: 1px solid var(--line); padding: 6px 10px; font-weight: 600; text-align: center; }
.chip small { display: block; color: var(--muted); font-weight: 400; font-size: 11px; }

@media (max-width: 1000px) { .biz { grid-template-columns: 1fr; } .phone { position: static; } }
@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; }
  nav { flex-direction: row; overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--line); padding: 8px; }
  nav .brand { padding: 7px 10px; } nav button { margin: 0 0 0 auto; }
  main { padding: 16px; }
  .inbox { grid-template-columns: 1fr; height: auto; }
  .convs { max-height: 40vh; border-right: 0; border-bottom: 1px solid var(--line); }
  .msgs { min-height: 50vh; }
  table { display: block; overflow-x: auto; }
}
