:root {
  --bg: #f4f6f7;
  --panel: #ffffff;
  --panel-2: #f8fafa;
  --ink: #1a2b32;
  --ink-2: #5b7079;
  --line: #dde5e8;
  --brand: #128c7e;
  --brand-dark: #075e54;
  --brand-soft: #e7f4f1;
  --ok: #1a8754;
  --warn: #b26a00;
  --warn-soft: #fff6e5;
  --danger: #c0392b;
  --danger-soft: #fdecea;
  --info-soft: #e8f1fb;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(16,32,38,.08), 0 4px 14px rgba(16,32,38,.05);
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b141a; --panel: #131f26; --panel-2: #18262e; --ink: #e6edf0; --ink-2: #93a6ae;
    --line: #26363f; --brand: #25d366; --brand-dark: #128c7e; --brand-soft: #10261f;
    --warn-soft: #2a2011; --danger-soft: #2a1512; --info-soft: #101f2e;
    --shadow: 0 1px 3px rgba(0,0,0,.4);
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font: 15px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg); color: var(--ink); -webkit-font-smoothing: antialiased;
}
.boot { padding: 3rem; text-align: center; color: var(--ink-2); }
a { color: var(--brand); }
h1, h2, h3 { margin: 0 0 .5rem; line-height: 1.25; }
h1 { font-size: 1.4rem; } h2 { font-size: 1.15rem; } h3 { font-size: 1rem; }
p { margin: 0 0 .75rem; }
code, .mono { font-family: var(--mono); font-size: .85em; }

/* ---------------- layout ---------------- */
.app { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.sidebar {
  background: var(--panel); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
}
.brand { padding: 1.1rem 1rem .8rem; font-weight: 700; display: flex; gap: .55rem; align-items: center; }
.brand svg { width: 26px; height: 26px; flex: none; }
.nav { flex: 1; overflow-y: auto; padding: .25rem .5rem; }
.nav button {
  display: flex; width: 100%; gap: .6rem; align-items: center; text-align: left;
  padding: .55rem .7rem; margin-bottom: 2px; border: 0; border-radius: 8px;
  background: none; color: var(--ink-2); font: inherit; cursor: pointer;
}
.nav button:hover { background: var(--panel-2); color: var(--ink); }
.nav button.active { background: var(--brand-soft); color: var(--brand-dark); font-weight: 600; }
@media (prefers-color-scheme: dark) { .nav button.active { color: var(--brand); } }
.nav .count { margin-left: auto; font-size: .75rem; opacity: .7; }
.sidebar-foot { padding: .75rem 1rem; border-top: 1px solid var(--line); font-size: .8rem; color: var(--ink-2); }
.main { padding: 1.25rem 1.5rem 4rem; max-width: 1200px; }
.page-head { display: flex; align-items: flex-start; gap: 1rem; margin-bottom: 1rem; flex-wrap: wrap; }
.page-head .sub { color: var(--ink-2); font-size: .9rem; margin: 0; }
.spacer { flex: 1; }

@media (max-width: 820px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; border-right: 0; border-bottom: 1px solid var(--line); }
  .nav { display: flex; overflow-x: auto; padding: .4rem; }
  .nav button { width: auto; white-space: nowrap; }
  .nav .count { display: none; }
  .sidebar-foot { display: none; }
  .main { padding: 1rem; }
}

/* ---------------- components ---------------- */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; box-shadow: var(--shadow); margin-bottom: 1rem; }
.card h2, .card h3 { margin-top: 0; }
.grid { display: grid; gap: 1rem; }
.grid.cols-2 { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }
.grid.cols-4 { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }

.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: .85rem 1rem; }
.stat .v { font-size: 1.6rem; font-weight: 700; line-height: 1.1; }
.stat .l { font-size: .78rem; color: var(--ink-2); text-transform: uppercase; letter-spacing: .04em; margin-top: .2rem; }
.stat.ok .v { color: var(--ok); } .stat.warn .v { color: var(--warn); } .stat.danger .v { color: var(--danger); }

button.btn, .btn {
  display: inline-flex; align-items: center; gap: .4rem; justify-content: center;
  padding: .5rem .9rem; border-radius: 8px; border: 1px solid var(--line);
  background: var(--panel); color: var(--ink); font: inherit; cursor: pointer; text-decoration: none;
}
.btn:hover:not(:disabled) { background: var(--panel-2); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 600; }
.btn.primary:hover:not(:disabled) { background: var(--brand-dark); }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.sm { padding: .3rem .6rem; font-size: .82rem; }
.btn-row { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }

label { display: block; font-size: .85rem; font-weight: 600; margin: 0 0 .3rem; }
label .hint { display: block; font-weight: 400; color: var(--ink-2); font-size: .8rem; margin-top: .1rem; }
input[type=text], input[type=email], input[type=password], input[type=number],
input[type=datetime-local], input[type=file], select, textarea {
  width: 100%; padding: .5rem .6rem; border: 1px solid var(--line); border-radius: 8px;
  background: var(--panel-2); color: var(--ink); font: inherit;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand); outline-offset: -1px; }
.field { margin-bottom: .85rem; }
.inline { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.inline > * { flex: 1 1 auto; }
.inline > .fixed { flex: 0 0 auto; }
input[type=checkbox], input[type=radio] { width: auto; }

table { width: 100%; border-collapse: collapse; font-size: .88rem; }
th, td { text-align: left; padding: .5rem .6rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-2); font-weight: 600; }
tbody tr:hover { background: var(--panel-2); }
.table-wrap { overflow-x: auto; }

.badge { display: inline-block; padding: .12rem .5rem; border-radius: 99px; font-size: .74rem; font-weight: 600; border: 1px solid transparent; white-space: nowrap; }
.badge.grey { background: var(--panel-2); color: var(--ink-2); border-color: var(--line); }
.badge.green { background: var(--brand-soft); color: var(--ok); }
.badge.blue { background: var(--info-soft); color: #1b6ec2; }
.badge.amber { background: var(--warn-soft); color: var(--warn); }
.badge.red { background: var(--danger-soft); color: var(--danger); }

.alert { padding: .7rem .9rem; border-radius: 8px; border: 1px solid; margin-bottom: .8rem; font-size: .9rem; }
.alert.info { background: var(--info-soft); border-color: #b9d5f2; color: var(--ink); }
.alert.warn { background: var(--warn-soft); border-color: #e8cf9a; color: var(--ink); }
.alert.error { background: var(--danger-soft); border-color: #eab5ae; color: var(--ink); }
.alert.ok { background: var(--brand-soft); border-color: #a8ddd0; color: var(--ink); }
.alert ul { margin: .35rem 0 0; padding-left: 1.1rem; }

.demo-banner {
  background: repeating-linear-gradient(45deg, #b26a00, #b26a00 12px, #96590a 12px, #96590a 24px);
  color: #fff; padding: .45rem 1rem; font-size: .82rem; font-weight: 600; text-align: center; letter-spacing: .02em;
}
.live-banner { background: var(--danger); color: #fff; padding: .45rem 1rem; font-size: .82rem; font-weight: 600; text-align: center; }

.bubble {
  background: #d9fdd3; color: #111b21; border-radius: 8px 8px 8px 2px; padding: .55rem .7rem;
  max-width: 420px; white-space: pre-wrap; word-break: break-word; font-size: .9rem;
  box-shadow: 0 1px 1px rgba(0,0,0,.12); position: relative;
}
.bubble .footer-text { display: block; margin-top: .4rem; font-size: .78rem; color: #5b7079; }
.phone-frame { background: #e5ddd5; padding: 1rem; border-radius: 12px; border: 1px solid var(--line); }
@media (prefers-color-scheme: dark) { .phone-frame { background: #0d1a17; } }

.modal-backdrop { position: fixed; inset: 0; background: rgba(10,20,26,.55); display: flex; align-items: center; justify-content: center; padding: 1rem; z-index: 50; }
.modal { background: var(--panel); border-radius: 12px; max-width: 720px; width: 100%; max-height: 88vh; overflow-y: auto; box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.modal-head { padding: 1rem; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 1rem; position: sticky; top: 0; background: var(--panel); }
.modal-body { padding: 1rem; }
.modal-foot { padding: 1rem; border-top: 1px solid var(--line); display: flex; gap: .5rem; justify-content: flex-end; position: sticky; bottom: 0; background: var(--panel); }

.toast-wrap { position: fixed; bottom: 1rem; right: 1rem; display: flex; flex-direction: column; gap: .5rem; z-index: 100; max-width: 380px; }
.toast { padding: .7rem .9rem; border-radius: 8px; color: #fff; box-shadow: var(--shadow); font-size: .88rem; }
.toast.ok { background: var(--ok); } .toast.error { background: var(--danger); } .toast.info { background: #1b6ec2; }

.login-wrap { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 1rem; }
.login-card { width: 100%; max-width: 380px; }

.progress { height: 8px; background: var(--panel-2); border-radius: 99px; overflow: hidden; display: flex; border: 1px solid var(--line); }
.progress span { display: block; height: 100%; }
.muted { color: var(--ink-2); }
.small { font-size: .82rem; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
pre.raw { background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; padding: .6rem; overflow-x: auto; font-size: .78rem; margin: 0; }
.steps { counter-reset: s; list-style: none; padding: 0; }
.steps li { counter-increment: s; position: relative; padding-left: 2rem; margin-bottom: .8rem; }
.steps li::before {
  content: counter(s); position: absolute; left: 0; top: .05rem; width: 1.4rem; height: 1.4rem;
  border-radius: 99px; background: var(--brand-soft); color: var(--brand-dark);
  display: grid; place-items: center; font-size: .78rem; font-weight: 700;
}
.wizard-steps { display: flex; gap: .4rem; margin-bottom: 1rem; flex-wrap: wrap; }
.wizard-steps div { flex: 1 1 100px; padding: .4rem .6rem; border-radius: 8px; background: var(--panel-2); border: 1px solid var(--line); font-size: .8rem; color: var(--ink-2); }
.wizard-steps div.on { background: var(--brand-soft); border-color: var(--brand); color: var(--brand-dark); font-weight: 600; }
