:root {
  --blue: #2A3FC9;
  --blue-dark: #1F2F9E;
  --blue-soft: #ECEEFB;
  --ink: #14172B;
  --muted: #5b6680;
  --line: #e2e7f0;
  --bg: #f6f8fc;
  --card: #ffffff;
  --ok: #1b7f4b;
  --ok-soft: #e6f5ec;
  --warn: #9a5b00;
  --warn-soft: #fff3dc;
  --danger: #b4232c;
  --radius: 14px;
  color-scheme: light;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
a { color: var(--blue); }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- header ---------- */
.top {
  display: flex; align-items: center; gap: 24px;
  padding: 12px 20px; background: var(--card); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 10;
}
.brand { display: flex; align-items: center; text-decoration: none; }
.brand img { height: 32px; width: auto; display: block; }
.hero-mark { display: block; margin: 0 auto 16px; }
#nav { display: flex; gap: 6px; flex: 1; }
#nav a, .tabs a, .filters a {
  color: var(--muted); text-decoration: none; font-weight: 550; padding: 6px 12px; border-radius: 9px; display: inline-flex; align-items: center; gap: 6px;
}
#nav a:hover, .tabs a:hover, .filters a:hover { background: var(--bg); }
#nav a.active, .tabs a.active, .filters a.active { color: var(--blue); background: var(--blue-soft); }
.count { background: var(--blue); color: #fff; border-radius: 999px; font-size: 12px; padding: 0 7px; line-height: 18px; font-weight: 700; }
#user-button { margin-left: auto; }

main { max-width: 920px; margin: 0 auto; padding: 28px 16px 64px; }
h1 { font-size: 28px; margin: 0 0 18px; font-weight: 650; }
h2 { font-size: 19px; margin: 0 0 6px; font-weight: 620; }
h3 { font-size: 15px; margin: 14px 0 6px; font-weight: 620; }
.inline-h { display: inline; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.strong { font-weight: 650; }
.pre { white-space: pre-wrap; }
.right { text-align: right; }
.center { text-align: center; padding-top: 24px; }
.center #sign-in { display: flex; justify-content: center; margin-top: 24px; }
.loading { padding: 24px 0; }
.back { display: inline-block; margin-bottom: 10px; text-decoration: none; font-weight: 550; }
.ok-text { color: var(--ok); }
.warn-text { color: var(--warn); }

/* ---------- cards & layout ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; margin-bottom: 16px; }
.card.subtle { background: #fbfcfe; }
.card.empty { text-align: center; padding: 36px 22px; }
.card.empty .btn { margin-top: 12px; }
.card.banner { display: block; background: var(--blue-soft); color: var(--blue-dark); border-color: transparent; font-weight: 600; text-decoration: none; }
details.card > summary { cursor: pointer; list-style: none; }
details.card > summary::-webkit-details-marker { display: none; }
details.card > summary::after { content: ' ▾'; color: var(--muted); }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.two-col > .card { margin-bottom: 0; }
.two-col + * { margin-top: 16px; }
.site-head, .row-between, .thread-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.site-head a { text-decoration: none; }
.thread-head h1 { margin-bottom: 2px; }
.billing { margin: 12px 0 16px; }
.billing.alert { color: var(--warn); font-weight: 550; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-top: 4px; }
.row-actions { margin-top: 6px; }
.row-actions a { text-decoration: none; }

/* ---------- badges ---------- */
.badge { display: inline-block; padding: 3px 11px; border-radius: 999px; font-size: 13px; font-weight: 600; white-space: nowrap; margin-right: 4px; }
.badge.live { background: var(--ok-soft); color: var(--ok); }
.badge.paused { background: #f2f3f6; color: #59606f; }
.badge.info { background: var(--blue-soft); color: var(--blue-dark); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.neutral { background: #f2f3f6; color: var(--ink); }

/* ---------- buttons & forms ---------- */
.btn {
  appearance: none; border: 0; border-radius: 10px; padding: 10px 18px; display: inline-flex; align-items: center; justify-content: center;
  background: var(--blue); color: #fff; font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; white-space: nowrap;
}
.btn:hover { background: var(--blue-dark); }
.btn:disabled { opacity: .6; }
.btn.busy { cursor: wait; }
.btn:disabled:not(.busy) { cursor: not-allowed; }
.btn.ghost { background: var(--blue-soft); color: var(--blue); }
.btn.ghost:hover { background: #DDE1F8; }
.btn.small { padding: 6px 12px; font-size: 14px; }
.btn.danger { background: var(--danger); }
.btn.danger:hover { background: #8f1b22; }
form { display: grid; gap: 14px; }
form.grid, .grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
form.grid .check, form.grid .btn { grid-column: 1 / -1; justify-self: start; }
form > .btn, form .actions .btn { justify-self: start; }
label { display: grid; gap: 6px; font-weight: 550; font-size: 15px; }
label.check { display: flex; align-items: center; gap: 8px; font-weight: 500; }
label.inline { display: inline-flex; align-items: center; gap: 8px; }
input, select, textarea {
  font: inherit; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: #fff; color: var(--ink); width: 100%;
}
input[type="checkbox"] { width: auto; }
input:disabled { background: #f4f6fa; color: var(--muted); }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--blue-soft); border-color: var(--blue); }
fieldset { border: 0; padding: 0; margin: 0 0 6px; display: grid; gap: 14px; }
legend { font-weight: 650; font-size: 16px; margin-bottom: 10px; padding: 0; }
.info-form fieldset + fieldset { border-top: 1px solid var(--line); padding-top: 18px; }
.hours-row { display: grid; grid-template-columns: 110px 150px 20px 150px max-content; gap: 10px; align-items: center; }
.hours-row .day { font-weight: 550; }
.form-end { border-top: 1px solid var(--line); padding-top: 16px; }
.create-row { display: flex; gap: 12px; align-items: end; flex-wrap: wrap; margin-top: 10px; }
.create-row label { min-width: 260px; }

/* ---------- lists, tables, facts ---------- */
.facts { display: grid; grid-template-columns: max-content 1fr; gap: 8px 18px; margin: 8px 0 12px; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; }
.list { padding: 6px; }
.list-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 10px; text-decoration: none; color: var(--ink); }
.list-row:hover { background: var(--bg); }
.list-row + .list-row { border-top: 1px solid var(--line); }
.list-main { display: grid; min-width: 0; }
.list-main strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-row.unread strong { color: var(--blue-dark); }
.list-side { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--blue); display: inline-block; }
.table-wrap { overflow-x: auto; margin-top: 12px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 600; }
td select { width: auto; }
.log { list-style: none; padding: 0; margin: 8px 0 0; display: grid; gap: 6px; font-size: 14px; }
.toplist { margin: 0; padding-left: 18px; font-size: 14px; }
.toplist li { display: flex; justify-content: space-between; gap: 12px; padding: 2px 0; }
.toplist li span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
code { font-size: 13px; background: var(--blue-soft); padding: 2px 6px; border-radius: 6px; }
code.big { font-size: 20px; padding: 6px 12px; letter-spacing: 1px; }
.code-box { display: flex; align-items: center; gap: 12px; margin-top: 8px; }
.tabs, .filters { display: flex; gap: 6px; flex-wrap: wrap; margin: -6px 0 18px; }
.filters { margin-top: 0; }

/* ---------- stats ---------- */
.stats { display: flex; gap: 28px; flex-wrap: wrap; margin: 6px 0 12px; }
.stat { display: grid; }
.stat strong { font-size: 26px; font-weight: 700; line-height: 1.1; }
.stat span { color: var(--muted); font-size: 14px; }
.stats.tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.stats.tiles .card { margin: 0; text-decoration: none; color: var(--ink); padding: 16px; }
.chart { width: 100%; height: 64px; display: block; }
.chart rect { fill: var(--blue); opacity: .85; }
.chart rect:hover { opacity: 1; }
.chart-axis { display: flex; justify-content: space-between; color: var(--muted); font-size: 12px; margin-top: 4px; }

/* ---------- conversations ---------- */
.thread { display: grid; gap: 12px; margin: 18px 0; }
.msg { max-width: 80%; padding: 12px 14px; border-radius: 14px; background: var(--card); border: 1px solid var(--line); }
.msg.mine { justify-self: end; background: var(--blue-soft); border-color: transparent; }
.msg.theirs { justify-self: start; }
.msg.system { justify-self: center; background: none; border: 0; color: var(--muted); font-size: 13px; padding: 0; }
.msg-meta { margin-bottom: 4px; }
.msg-body { white-space: pre-wrap; overflow-wrap: anywhere; }
.msg-files { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.thumb { width: 120px; height: 90px; object-fit: cover; border-radius: 8px; display: block; background: var(--bg); }
.reply textarea { min-height: 90px; }
.admin-bar { display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; padding: 14px 18px; }
.admin-bar select { width: auto; }
.picker { display: grid; gap: 8px; }
.picker .attach { justify-self: start; cursor: pointer; }
.file-list { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; background: var(--bg); border: 1px solid var(--line); font-size: 13px; color: var(--ink); text-decoration: none; }
.chip-x { border: 0; background: none; cursor: pointer; font-size: 16px; line-height: 1; color: var(--muted); padding: 0 2px; }

/* ---------- notices & dialog ---------- */
.notice { background: var(--blue-soft); color: var(--blue-dark); border-radius: 10px; padding: 12px 16px; margin-bottom: 20px; }
.notice.inline { margin: 6px 0 10px; }
.notice.error { background: var(--warn-soft); color: var(--warn); }
.confirm { border: 0; border-radius: var(--radius); padding: 0; width: min(480px, calc(100vw - 32px)); color: var(--ink); box-shadow: 0 20px 60px rgba(22, 33, 58, .25); }
.confirm::backdrop { background: rgba(22, 33, 58, .45); }
.confirm form { margin: 0; padding: 24px; gap: 12px; }
.confirm p { margin: 0; color: var(--muted); }

@media (max-width: 720px) {
  .top { gap: 10px; flex-wrap: wrap; padding: 10px 14px; }
  #nav { order: 3; flex-basis: 100%; overflow-x: auto; }
  .two-col, .grid, form.grid { grid-template-columns: 1fr; }
  .two-col > .card { margin-bottom: 0; }
  .stats.tiles { grid-template-columns: 1fr 1fr; }
  .hours-row { grid-template-columns: 1fr 1fr; }
  .hours-row .day { grid-column: 1 / -1; }
  .hours-row .muted { display: none; }
  .msg { max-width: 92%; }
  h1 { font-size: 24px; }
}
