:root {
  --bg: #f3f5f2;
  --panel: #ffffff;
  --line: #e1e6df;
  --line-strong: #c9d2c7;
  --text: #1b2a21;
  --muted: #5c6c61;
  --faint: #8a978d;
  --brand: #17583a;
  --brand-dark: #12482f;
  --brand-soft: #e5f1ea;
  --ok: #1f7a4a;
  --ok-soft: #e3f3ea;
  --warn: #9a5a0b;
  --warn-soft: #fbf0df;
  --bad: #a8322d;
  --bad-soft: #fbe7e5;
  color-scheme: light;
  font: 15px/1.6 system-ui, -apple-system, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--text);
  background: var(--bg);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid #2f8f5f; outline-offset: 2px; }
h1, h2, h3 { margin: 0; line-height: 1.3; }
p { margin: 0; }
.muted { color: var(--muted); }
.faint { color: var(--faint); font-size: 13px; }

.btn { display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 6px 14px; border-radius: 8px;
  border: 1px solid var(--brand); background: var(--brand); color: #fff; white-space: nowrap; }
.btn:hover { background: var(--brand-dark); }
.btn.secondary { background: #fff; color: var(--brand); border-color: var(--line-strong); }
.btn.secondary:hover { background: var(--brand-soft); }
.btn.quiet { background: transparent; border-color: transparent; color: var(--muted); }
.btn.quiet:hover { background: #eef1ed; color: var(--text); }
.btn.small { min-height: 30px; padding: 3px 10px; font-size: 14px; }
.btn:disabled { opacity: .5; cursor: default; }

.toast { position: fixed; top: 16px; left: 50%; transform: translateX(-50%); z-index: 40; max-width: min(560px, 92vw);
  background: var(--bad-soft); color: var(--bad); border: 1px solid #ecc4c0; border-radius: 10px; padding: 10px 16px; }

/* Invite and login */
.center { min-height: 100vh; display: grid; place-items: center; padding: 32px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 36px 40px; }
.card.narrow { width: min(460px, 100%); }
.card.narrow h1 { font-size: 22px; margin-bottom: 8px; }
.card.narrow .row { margin-top: 16px; }
.login-card { width: min(880px, 100%); display: grid; grid-template-columns: 1fr 300px; gap: 40px; }
.login-card h1 { font-size: 26px; margin-bottom: 10px; }
.lead { color: var(--muted); margin-bottom: 26px; }
.steps { list-style: none; padding: 0; margin: 0 0 22px; display: grid; gap: 14px; }
.steps li { display: grid; grid-template-columns: 28px 1fr; gap: 12px; }
.steps b { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%;
  background: var(--brand-soft); color: var(--brand); font-size: 14px; }
.steps small { display: block; color: var(--muted); font-size: 13px; }
.note { font-size: 13px; color: var(--muted); background: #f6f8f5; border-radius: 8px; padding: 10px 12px; }
.qr-box { text-align: center; }
.qr { width: 260px; height: 260px; margin: 0 auto 12px; padding: 10px; border: 1px solid var(--line); border-radius: 12px;
  background: #fff; display: grid; place-items: center; }
.qr img { width: 100%; height: auto; display: block; }
.qr-state { font-weight: 600; }
.qr-box .btn { margin-top: 12px; }

/* Frame */
.topbar { position: sticky; top: 0; z-index: 5; background: #fff; border-bottom: 1px solid var(--line); }
.topbar-inner { max-width: 1160px; margin: 0 auto; padding: 0 24px; height: 60px; display: flex; align-items: center; gap: 16px; }
.product { font-weight: 700; font-size: 16px; white-space: nowrap; }
.switcher { position: relative; }
.switcher-btn { display: flex; align-items: center; gap: 10px; min-height: 40px; padding: 4px 12px 4px 6px;
  background: #f6f8f5; border: 1px solid var(--line); border-radius: 10px; max-width: 320px; }
.switcher-btn .name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.avatar { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; flex: none;
  background: var(--brand-soft); color: var(--brand); font-weight: 700; font-size: 14px; }
.caret { color: var(--faint); font-size: 12px; }
.menu { position: absolute; top: calc(100% + 6px); left: 0; min-width: 300px; background: #fff; border: 1px solid var(--line);
  border-radius: 12px; box-shadow: 0 10px 30px rgba(20, 40, 30, .12); padding: 6px; z-index: 6; }
.menu button { width: 100%; display: flex; align-items: center; gap: 10px; padding: 8px; border: 0; background: none;
  border-radius: 8px; text-align: left; }
.menu button:hover { background: #f3f6f2; }
.menu .grow { flex: 1; min-width: 0; }
.menu small { display: block; color: var(--muted); font-size: 12px; }
.menu-sep { height: 1px; background: var(--line); margin: 6px 4px; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex: none; background: #a8b2aa; }
.dot.online { background: #27a061; } .dot.starting { background: #6fb88f; }
.dot.expired, .dot.error { background: #d9891a; } .dot.paused { background: #a8b2aa; }
.tabs { display: flex; gap: 4px; margin-left: 12px; }
.tab { border: 0; background: none; padding: 8px 14px; border-radius: 8px; color: var(--muted); font-weight: 600; }
.tab:hover { background: #f1f4f0; color: var(--text); }
.tab[aria-current="page"] { background: var(--brand-soft); color: var(--brand); }
.count { display: inline-block; min-width: 20px; padding: 0 6px; margin-left: 6px; border-radius: 10px;
  background: var(--warn); color: #fff; font-size: 12px; line-height: 20px; }
.top-actions { margin-left: auto; }
main { max-width: 1160px; margin: 0 auto; padding: 24px 24px 80px; }

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 20px 22px; }
.stack > * + * { margin-top: 16px; }
.panel-title { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.panel-title h2 { font-size: 17px; }
.empty { color: var(--muted); padding: 18px 0; text-align: center; }

/* Home */
.status { display: grid; grid-template-columns: auto 1fr auto; gap: 18px; align-items: center; padding: 22px 24px;
  border-radius: 12px; border: 1px solid; }
.status.online, .status.starting { background: var(--ok-soft); border-color: #bfe0cb; }
.status.expired, .status.error { background: var(--warn-soft); border-color: #ecd3a8; }
.status.paused { background: #eef1ee; border-color: var(--line-strong); }
.status-icon { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; font-size: 20px;
  font-weight: 700; color: #fff; background: var(--ok); }
.status.expired .status-icon, .status.error .status-icon { background: #c77a12; }
.status.paused .status-icon { background: #8d998f; }
.status h2 { font-size: 20px; margin-bottom: 4px; }
.status p { color: var(--muted); }
.grid-2 { display: grid; grid-template-columns: 1.4fr 1fr; gap: 16px; margin-top: 16px; align-items: start; }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.stat { background: #f7f9f6; border-radius: 10px; padding: 14px 16px; }
.stat b { display: block; font-size: 26px; line-height: 1.2; }
.stat span { color: var(--muted); font-size: 13px; }
.todo { list-style: none; margin: 0; padding: 0; }
.todo li { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line); }
.todo li:first-child { border-top: 0; padding-top: 0; }
.todo .grow { flex: 1; }
.badge { min-width: 30px; text-align: center; font-weight: 700; border-radius: 8px; padding: 2px 8px; }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.activity { list-style: none; margin: 0; padding: 0; }
.activity li { display: grid; grid-template-columns: 76px 1fr; gap: 10px; padding: 9px 0; border-top: 1px solid var(--line); font-size: 14px; }
.activity li:first-child { border-top: 0; }
.activity time { color: var(--faint); }
.activity .pill { margin-top: 4px; }

.pill { display: inline-flex; align-items: center; padding: 2px 10px; border-radius: 20px; font-size: 13px; white-space: nowrap; }
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.bad { background: var(--bad-soft); color: var(--bad); }
.pill.off { background: #edf0ec; color: var(--muted); }

/* Comments */
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 16px; }
.toolbar .spacer { flex: 1; }
.segmented { display: inline-flex; flex-wrap: wrap; background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 3px; }
.segmented button { border: 0; background: none; padding: 6px 12px; border-radius: 7px; color: var(--muted); }
.segmented button[aria-pressed="true"] { background: var(--brand); color: #fff; }
.segmented .n { opacity: .75; margin-left: 4px; }
select, input[type="text"], textarea { border: 1px solid var(--line-strong); border-radius: 8px; padding: 7px 10px; background: #fff; }
textarea { width: 100%; resize: vertical; line-height: 1.55; }
.comment { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 16px 18px; }
.comment + .comment { margin-top: 12px; }
.comment-head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; font-size: 14px; }
.comment-head .who { font-weight: 600; }
.comment-head .work { color: var(--muted); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.comment-head .pill { margin-left: auto; }
.comment-text { font-size: 16px; margin-bottom: 12px; overflow-wrap: anywhere; }
.reply-box { border-left: 3px solid var(--brand-soft); padding-left: 12px; }
.reply-box label, .reply-box .label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; }
.reply-final { overflow-wrap: anywhere; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; align-items: center; }
.actions .faint { margin-left: auto; }
.reason { font-size: 14px; color: var(--warn); margin-bottom: 8px; }

/* Settings */
.settings { display: grid; grid-template-columns: 200px 1fr; gap: 24px; align-items: start; }
.side-nav { position: sticky; top: 84px; display: grid; gap: 2px; }
.side-nav a { padding: 8px 12px; border-radius: 8px; color: var(--muted); text-decoration: none; }
.side-nav a:hover { background: #eaeee9; color: var(--text); }
.settings .panel { scroll-margin-top: 80px; }
.field { margin-top: 16px; }
.field:first-child { margin-top: 0; }
.field > label, .field > .label { display: block; font-weight: 600; margin-bottom: 4px; }
.help { color: var(--muted); font-size: 13px; margin-bottom: 8px; }
.choices { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.choice { display: block; border: 1px solid var(--line-strong); border-radius: 10px; padding: 12px 14px; cursor: pointer; background: #fff; }
.choice:hover { border-color: var(--brand); }
.choice input { margin: 0 6px 0 0; accent-color: var(--brand); }
.choice p { color: var(--muted); font-size: 13px; margin-top: 4px; }
.choice.selected { border-color: var(--brand); background: #f4faf6; box-shadow: 0 0 0 1px var(--brand) inset; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row > input[type="text"] { flex: 1; min-width: 200px; }
.rules { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; }
.rules li { display: flex; gap: 8px; font-size: 14px; color: var(--muted); }
.rules li::before { content: "✓"; color: var(--ok); font-weight: 700; }
.save-row { display: flex; align-items: center; gap: 12px; margin-top: 18px; }
.saved { color: var(--ok); font-size: 14px; }
.try { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.try select { width: 100%; }
.try-result { background: #f7f9f6; border-radius: 10px; padding: 14px; min-height: 120px; overflow-wrap: anywhere; }
.try-result .faint { margin-bottom: 6px; }
.acct-row { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line); }
.acct-row:first-of-type { border-top: 0; }
.acct-row .grow { flex: 1; min-width: 0; }

/* Modal */
.backdrop { position: fixed; inset: 0; background: rgba(20, 30, 24, .35); display: grid; place-items: center; z-index: 20; }
.modal { width: min(420px, calc(100% - 32px)); background: #fff; border-radius: 14px; padding: 24px; text-align: center; }
.modal h2 { font-size: 18px; margin-bottom: 8px; }
.modal .qr { width: 240px; height: 240px; margin: 14px auto; }
.modal-actions { margin-top: 14px; }
