/* Admin panel styles v1.2: responsive (phone, tablet, desktop), light and dark mode, Font Awesome icons (self-hosted) */
:root {
  --bg: #f4f6fa; --surface: #ffffff; --surface-2: #f1f4f9; --text: #101828; --muted: #667085;
  --border: #e4e8f0; --primary: #2f5fe8; --primary-2: #5b82f5; --primary-text: #ffffff; --focus: rgba(47, 95, 232, .30);
  --ok: #0f7a5c; --ok-bg: #e2f6ee; --warn: #9a5a07; --warn-bg: #fcefd6; --err: #c0262f; --err-bg: #fde9ea;
  --info: #1d5fbf; --info-bg: #e4edfb; --off: #596273; --off-bg: #eceff3;
  --violet: #6d4fd6; --violet-bg: #eee9fb; --teal: #0e7f8c; --teal-bg: #def4f6; --blue: #2f5fe8; --blue-bg: #e6edfd;
  --radius: 14px; --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 2px 6px rgba(16, 24, 40, .05);
  --shadow-hover: 0 6px 20px rgba(16, 24, 40, .10);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b0f16; --surface: #131a23; --surface-2: #1a222d; --text: #e7eaf0; --muted: #9aa4b2;
    --border: #263040; --primary: #6e93ff; --primary-2: #8aa8ff; --primary-text: #0b0f17; --focus: rgba(110, 147, 255, .4);
    --ok: #4cd4a0; --ok-bg: #11322a; --warn: #f2b755; --warn-bg: #392a0f; --err: #ff7a80; --err-bg: #3c1a1d;
    --info: #7db1ff; --info-bg: #172746; --off: #a8b0bd; --off-bg: #222a34;
    --violet: #b5a2ff; --violet-bg: #251f45; --teal: #5fd3df; --teal-bg: #0f2e33; --blue: #8aa8ff; --blue-bg: #172746;
    --shadow: none; --shadow-hover: 0 6px 20px rgba(0, 0, 0, .4);
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", sans-serif; -webkit-font-smoothing: antialiased; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
code, pre, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
h1 { font-size: 1.45rem; margin: 0; letter-spacing: -.015em; line-height: 1.25; display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; }
h2 { font-size: 1rem; margin: 0 0 12px; }
h3 { font-size: .92rem; margin: 18px 0 8px; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.hidden { display: none !important; }
::selection { background: var(--focus); }

/* ---- Icons (Font Awesome). One fixed square box so every icon sits on the text centre line ---- */
.ico { display: inline-block; width: 1.25em; height: 1em; line-height: 1; text-align: center; flex: none; font-size: 1em; }
.btn .ico { font-size: .95em; }
.btn.lg .ico { font-size: 1em; }

/* ---- Shell ---- */
.topbar { position: sticky; top: 0; z-index: 20; background: color-mix(in srgb, var(--surface) 88%, transparent); backdrop-filter: saturate(160%) blur(10px); -webkit-backdrop-filter: saturate(160%) blur(10px); border-bottom: 1px solid var(--border); }
.topbar-inner { max-width: 1120px; margin: 0 auto; padding: 0 16px; height: 60px; display: flex; align-items: center; gap: 16px; }
.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 700; letter-spacing: -.01em; white-space: nowrap; color: var(--text); line-height: 1; }
.brand:hover { text-decoration: none; }
.brand-mark { width: 30px; height: 30px; border-radius: 9px; background: linear-gradient(135deg, var(--primary-2), var(--primary)); display: grid; place-items: center; flex: none; }
.brand-mark svg { width: 16px; height: 16px; fill: #fff; display: block; }
.nav { display: flex; gap: 4px; flex: 1; align-items: center; }
.nav a { height: 38px; padding: 0 14px; border-radius: 10px; color: var(--muted); font-weight: 600; white-space: nowrap; transition: background .15s, color .15s; display: inline-flex; align-items: center; gap: 8px; line-height: 1; }
.nav a:hover { color: var(--text); text-decoration: none; background: var(--surface-2); }
.nav a.active { background: var(--blue-bg); color: var(--primary); }
.nav-ico { position: relative; display: inline-grid; place-items: center; width: 20px; height: 20px; flex: none; }
.nav-ico .ico { width: auto; font-size: 1rem; }
.nav-label { line-height: 1; }
/* Health dot on the Status icon */
a[data-state] .nav-ico::after { content: ""; position: absolute; top: -3px; right: -5px; width: 9px; height: 9px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 2px var(--surface); }
a[data-state="warn"] .nav-ico::after { background: var(--warn); }
a[data-state="error"] .nav-ico::after { background: var(--err); }
.icon-btn { margin-left: auto; width: 38px; height: 38px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); color: var(--muted); display: inline-grid; place-items: center; cursor: pointer; font-size: 1rem; padding: 0; flex: none; transition: background .15s, color .15s, border-color .15s; }
.icon-btn:hover { background: var(--surface-2); color: var(--err); }
.icon-btn .ico { width: auto; }
.container { max-width: 1120px; margin: 0 auto; padding: 24px 16px 64px; }
.page-head { display: flex; flex-wrap: wrap; gap: 12px 16px; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.page-head .actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.page-head.tight { margin: 4px 0 12px; }
.section-title { margin: 0; display: inline-flex; align-items: center; gap: 8px; }
.section-title .ico { color: var(--primary); }
.title-block { min-width: 0; }
.title-row { display: flex; align-items: center; gap: 14px; margin-top: 8px; }
.updated { white-space: nowrap; }
.back-link { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; font-size: .9rem; color: var(--muted); }
.back-link:hover { color: var(--primary); text-decoration: none; }
.back-link .ico { width: auto; font-size: .85em; }

/* ---- Cards and grids ---- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); margin-bottom: 16px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; min-height: 30px; }
.card-head h2 { margin: 0; display: inline-flex; align-items: center; gap: 9px; }
.card-head h2 .ico { color: var(--primary); font-size: 1rem; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid2 > * { min-width: 0; }
@media (max-width: 860px) { .grid2 { grid-template-columns: 1fr; } }
.stats { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; margin-bottom: 16px; }
@media (max-width: 860px) { .stats { grid-template-columns: repeat(2, 1fr); } }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); display: grid; grid-template-columns: 1fr auto; grid-template-areas: "n ico" "l l"; align-items: center; gap: 2px 8px; --c: var(--blue); --cbg: var(--blue-bg); }
.stat.violet { --c: var(--violet); --cbg: var(--violet-bg); }
.stat.green { --c: var(--ok); --cbg: var(--ok-bg); }
.stat.red { --c: var(--err); --cbg: var(--err-bg); }
.stat.teal { --c: var(--teal); --cbg: var(--teal-bg); }
.stat.grey { --c: var(--off); --cbg: var(--off-bg); }
.stat-ico { grid-area: ico; width: 34px; height: 34px; border-radius: 10px; background: var(--cbg); color: var(--c); display: grid; place-items: center; font-size: .95rem; }
.stat-ico .ico { width: auto; }
.stat .n { grid-area: n; font-size: 1.6rem; font-weight: 700; letter-spacing: -.02em; line-height: 1.15; font-variant-numeric: tabular-nums; }
.stat .l { grid-area: l; color: var(--muted); font-size: .82rem; }
@media (max-width: 520px) { .stats .stat:last-child:nth-child(odd) { grid-column: 1 / -1; } }

/* ---- Buttons and inputs ---- */
.btn { font: inherit; font-weight: 600; line-height: 1; border: 1px solid var(--border); background: var(--surface); color: var(--text); padding: 0 14px; border-radius: 10px; cursor: pointer; height: 38px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; white-space: nowrap; transition: background .15s, border-color .15s, filter .15s; }
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn.primary { background: var(--primary); color: var(--primary-text); border-color: var(--primary); }
.btn.primary:hover { background: var(--primary); filter: brightness(1.08); }
.btn.danger { color: var(--err); border-color: color-mix(in srgb, var(--err) 55%, var(--border)); background: transparent; }
.btn.danger:hover { background: var(--err-bg); }
.btn.sm { padding: 0 11px; height: 32px; font-size: .85rem; gap: 6px; border-radius: 9px; }
.btn.lg { height: 46px; font-size: 1rem; border-radius: 11px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; background: var(--surface); height: 38px; }
.seg button { font: inherit; font-weight: 600; border: 0; background: transparent; color: var(--muted); padding: 0 14px; cursor: pointer; transition: background .15s, color .15s; }
.seg button.active { background: var(--blue-bg); color: var(--primary); }
input, select, textarea { font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 9px 12px; width: 100%; height: 42px; transition: border-color .15s, box-shadow .15s; }
select { padding-right: 8px; }
textarea { resize: vertical; height: auto; min-height: 88px; line-height: 1.5; }
input::placeholder, textarea::placeholder { color: color-mix(in srgb, var(--muted) 75%, transparent); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--focus); }
.btn:focus-visible, .client-row:focus-visible, .nav a:focus-visible, .icon-btn:focus-visible, .tabbar a:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.field { margin-bottom: 16px; min-width: 0; }
.field label { display: block; font-weight: 600; margin-bottom: 6px; font-size: .9rem; }
.field .hint, .hint { color: var(--muted); font-size: .83rem; margin-top: 5px; display: block; line-height: 1.45; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 18px; }
@media (max-width: 720px) { .form-grid { grid-template-columns: 1fr; } }
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 14px; align-items: center; }
.toolbar input, .toolbar select { width: auto; min-width: 150px; }
.toolbar .grow { flex: 1; min-width: 200px; }
.search { position: relative; }
.search .ico { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; width: auto; font-size: .9rem; }
.search input { padding-left: 38px; width: 100%; }
.date-f { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); font-size: .85rem; font-weight: 600; }
.date-f input { min-width: 150px; }

/* Input with a leading icon (login) */
.input-icon { position: relative; }
.input-icon > .ico { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; width: auto; font-size: .95rem; }
.input-icon input { padding-left: 42px; height: 46px; }
.input-icon .eye { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); width: 36px; height: 36px; border: 0; background: transparent; color: var(--muted); border-radius: 8px; cursor: pointer; display: grid; place-items: center; padding: 0; }
.input-icon .eye:hover { background: var(--surface-2); color: var(--text); }
.input-icon .eye .ico { position: static; transform: none; width: auto; pointer-events: none; }
.input-icon:has(.eye) input { padding-right: 46px; }

/* Toggle switch: the whole row is clickable and the knob is centred on the first line of text */
.switch-row { display: flex; align-items: flex-start; gap: 14px; padding: 14px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface-2); cursor: pointer; margin: 4px 0 0; }
.switch { position: relative; flex: none; width: 44px; height: 26px; margin-top: 1px; }
.switch input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; margin: 0; cursor: pointer; z-index: 1; }
.switch .track { position: absolute; inset: 0; border-radius: 999px; background: color-mix(in srgb, var(--muted) 45%, var(--surface)); transition: background .18s; }
.switch .track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .3); transition: transform .18s; }
.switch input:checked + .track { background: var(--primary); }
.switch input:checked + .track::after { transform: translateX(18px); }
.switch input:focus-visible + .track { box-shadow: 0 0 0 3px var(--focus); }
.switch-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.switch-text b { line-height: 26px; }
.switch-text .hint { margin-top: 0; }

/* ---- Badges ---- */
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 0 10px; height: 22px; line-height: 1; border-radius: 999px; font-size: .76rem; font-weight: 700; white-space: nowrap; vertical-align: middle; }
.pill.ok, .pill.success, .pill.active { color: var(--ok); background: var(--ok-bg); }
.pill.warn, .pill.pending, .pill.paused { color: var(--warn); background: var(--warn-bg); }
.pill.error, .pill.failed { color: var(--err); background: var(--err-bg); }
.pill.test { color: var(--info); background: var(--info-bg); }
.pill.off, .pill.skipped, .pill.archived { color: var(--off); background: var(--off-bg); }
h1 .pill { font-size: .72rem; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; display: inline-block; flex: none; }
.live { color: var(--ok); font-weight: 700; font-size: .78rem; display: inline-flex; align-items: center; gap: 6px; line-height: 1; vertical-align: middle; }
.live .dot { animation: pulse 1.6s infinite; }
.name .live { margin-left: 8px; }
@keyframes pulse { 0% { opacity: 1; } 50% { opacity: .25; } 100% { opacity: 1; } }
.chips { display: flex; gap: 4px; flex-wrap: wrap; }
.chip { font-size: .72rem; padding: 2px 7px; border-radius: 6px; background: var(--surface-2); color: var(--muted); font-weight: 600; line-height: 1.2; }
.chip.on { background: var(--ok-bg); color: var(--ok); }

/* ---- Avatar ---- */
.avatar { --hue: 220; width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; flex: none; font-weight: 700; font-size: .9rem; letter-spacing: .02em; color: hsl(var(--hue) 55% 32%); background: hsl(var(--hue) 70% 92%); }
.avatar.lg { width: 52px; height: 52px; border-radius: 15px; font-size: 1.1rem; }
@media (prefers-color-scheme: dark) { .avatar { color: hsl(var(--hue) 80% 78%); background: hsl(var(--hue) 40% 20%); } }

/* ---- Client list ---- */
.clients { display: flex; flex-direction: column; gap: 10px; margin-bottom: 8px; scroll-margin-top: 76px; }
.client-head, .client-row { display: grid; grid-template-columns: minmax(200px, 2.2fr) minmax(130px, 1.5fr) repeat(3, 64px) 100px 190px; gap: 12px; align-items: center; }
.client-head { padding: 0 18px; color: var(--muted); font-size: .74rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; }
.client-row { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 18px; cursor: pointer; box-shadow: var(--shadow); transition: box-shadow .15s, border-color .15s; position: relative; }
.client-row::before { content: ""; position: absolute; left: 0; top: 14px; bottom: 14px; width: 4px; border-radius: 0 4px 4px 0; background: var(--border); }
.client-row:hover { box-shadow: var(--shadow-hover); border-color: color-mix(in srgb, var(--primary) 50%, var(--border)); }
.client-row[data-health="ok"]::before { background: var(--ok); }
.client-row[data-health="warn"]::before { background: var(--warn); }
.client-row[data-health="error"]::before { background: var(--err); }
.client-row[data-health="off"]::before { background: var(--off); }
.client-row[data-health="off"] { opacity: .88; }
.c-name { display: flex; align-items: center; gap: 12px; min-width: 0; }
.c-name-text { min-width: 0; }
.client-row .name { font-weight: 700; display: flex; align-items: center; flex-wrap: wrap; line-height: 1.3; }
.client-row .num { font-variant-numeric: tabular-nums; font-weight: 700; }
.client-row .ctrl { display: flex; gap: 8px; align-items: center; justify-content: flex-end; }
.client-row .m { display: none; }
.ch-line { display: inline-flex; align-items: center; gap: 7px; min-width: 0; overflow-wrap: anywhere; }
.ch-line .ico, .ch-name .ico { color: #2a9bd8; font-size: 1.05rem; width: auto; }
.c-channel { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; min-width: 0; }
@media (max-width: 960px) { .client-head, .client-row { grid-template-columns: minmax(180px, 2fr) minmax(110px, 1.3fr) repeat(3, 56px) 90px 170px; gap: 10px; } }
@media (max-width: 860px) {
  .client-head { display: none; }
  .client-row { grid-template-columns: repeat(4, 1fr); gap: 12px 8px; padding: 16px; }
  .client-row::before { top: 16px; bottom: 16px; }
  .client-row .c-name, .client-row .c-channel, .client-row .ctrl { grid-column: 1 / -1; }
  .client-row .ctrl { justify-content: space-between; padding-top: 12px; border-top: 1px solid var(--border); }
  .client-row .m { display: block; color: var(--muted); font-size: .72rem; margin-bottom: 1px; }
  .client-row > div:not(.c-name):not(.c-channel):not(.ctrl) { display: flex; flex-direction: column; }
}

/* ---- Pager ---- */
.pager { display: flex; gap: 12px; align-items: center; justify-content: space-between; margin: 14px 0 4px; flex-wrap: wrap; }
.pager.only { justify-content: center; margin-top: 8px; }
.pager-btns { display: inline-flex; align-items: center; gap: 10px; }
.page-ind { min-width: 54px; text-align: center; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--muted); font-size: .88rem; }
.card > .pager { margin-bottom: 0; padding-top: 14px; border-top: 1px solid var(--border); }
@media (max-width: 520px) {
  .pager { flex-direction: column-reverse; align-items: stretch; gap: 10px; }
  .pager-btns { display: grid; grid-template-columns: 1fr auto 1fr; }
  .pager-btns .btn { width: 100%; height: 42px; }
  .pager > .muted { text-align: center; }
}

/* ---- Tables ---- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; color: var(--muted); font-size: .74rem; text-transform: uppercase; letter-spacing: .05em; padding: 8px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; }
td { padding: 11px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tbody tr.click { cursor: pointer; transition: background .12s; }
tbody tr.click:hover { background: var(--surface-2); }
tbody tr:last-child td { border-bottom: 0; }

/* ---- Health, coverage, feed ---- */
.checks { display: flex; flex-direction: column; gap: 13px; }
.check-row { display: flex; gap: 12px; align-items: flex-start; }
.mark { width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; font-size: .7rem; flex: none; }
.mark .ico { width: auto; }
.mark.ok { background: var(--ok-bg); color: var(--ok); }
.mark.bad { background: var(--err-bg); color: var(--err); }
.mark.warn { background: var(--warn-bg); color: var(--warn); }
.mark.todo { background: transparent; border: 2px solid var(--border); }
.cov { display: grid; grid-template-columns: 1fr 110px 46px; gap: 10px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--border); }
.cov:last-of-type { border-bottom: 0; }
.cov > .small:last-child { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
progress { display: block; width: 100%; height: 8px; border-radius: 6px; overflow: hidden; border: 0; background: var(--surface-2); accent-color: var(--primary); margin: 2px 0 14px; -webkit-appearance: none; appearance: none; }
.cov progress { margin: 0; }
progress::-webkit-progress-bar { background: var(--surface-2); }
progress::-webkit-progress-value { background: var(--primary); border-radius: 6px; }
progress::-moz-progress-bar { background: var(--primary); border-radius: 6px; }
.feed { max-height: 420px; overflow-y: auto; }
.feed-item { display: flex; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--border); align-items: center; }
.feed-item:last-child { border-bottom: 0; }
.tag { font-size: .66rem; font-weight: 800; letter-spacing: .05em; padding: 3px 7px; border-radius: 6px; flex: none; min-width: 54px; text-align: center; line-height: 1.2; }
.tag.click { background: var(--surface-2); color: var(--muted); }
.tag.join { background: var(--info-bg); color: var(--info); }
.tag.event { background: var(--ok-bg); color: var(--ok); }
.feed-item .when { margin-left: auto; color: var(--muted); font-size: .8rem; white-space: nowrap; padding-left: 8px; }
.label-sm { font-weight: 700; margin: 14px 0 6px; }
.codebox { position: relative; margin: 0 0 6px; }
pre.code { background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 12px 52px 12px 14px; overflow-x: auto; margin: 0; font-size: .82rem; line-height: 1.55; white-space: pre-wrap; word-break: break-all; }
.copy-btn { position: absolute; top: 8px; right: 8px; width: 32px; height: 32px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); color: var(--muted); display: grid; place-items: center; cursor: pointer; padding: 0; font-size: .9rem; }
.copy-btn:hover { color: var(--primary); border-color: var(--primary); }
.copy-btn .ico { width: auto; }
.kv { display: grid; grid-template-columns: 150px 1fr; gap: 8px 14px; margin: 14px 0 0; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; word-break: break-word; }
.kv-inline { display: inline-flex; flex-wrap: wrap; gap: 8px; align-items: center; }
@media (max-width: 520px) { .kv { grid-template-columns: 1fr; gap: 2px; } .kv dt { margin-top: 10px; font-size: .8rem; } }
.notice { border: 1px solid color-mix(in srgb, var(--warn) 55%, var(--border)); background: var(--warn-bg); color: var(--warn); border-radius: var(--radius); padding: 14px 16px; margin-bottom: 16px; }
.notice-head { display: flex; align-items: center; gap: 10px; margin-bottom: 4px; }
.notice-ico { width: 28px; height: 28px; border-radius: 50%; background: color-mix(in srgb, var(--warn) 18%, transparent); display: grid; place-items: center; font-size: .85rem; }
.notice-ico .ico { width: auto; }
.notice .row { display: flex; gap: 10px; align-items: center; justify-content: space-between; flex-wrap: wrap; margin-top: 10px; padding-top: 10px; border-top: 1px solid color-mix(in srgb, var(--warn) 25%, transparent); color: var(--text); }
.notice .ch-name { display: inline-flex; align-items: center; gap: 8px; flex-wrap: wrap; min-width: 0; overflow-wrap: anywhere; }
.row-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.empty { text-align: center; padding: 34px 12px; color: var(--muted); }
.empty-ico { width: 52px; height: 52px; border-radius: 50%; background: var(--surface-2); display: grid; place-items: center; margin: 0 auto 12px; font-size: 1.2rem; color: var(--muted); }
.empty-ico .ico { width: auto; }
.empty-title { font-weight: 700; color: var(--text); margin-bottom: 2px; }
.empty-actions { margin-top: 14px; display: flex; gap: 8px; justify-content: center; }
.guide { margin: 0 0 16px; padding-left: 22px; display: flex; flex-direction: column; gap: 10px; }
.steps .btn { margin-top: 8px; }

/* ---- Daily bar chart ---- */
.chart { display: flex; align-items: flex-end; gap: 5px; height: 160px; padding-top: 8px; }
.chart .col { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; height: 100%; min-width: 0; }
.chart .bar { width: 100%; background: linear-gradient(180deg, var(--primary-2), var(--primary)); border-radius: 5px 5px 0 0; min-height: 3px; opacity: .92; transition: opacity .15s; }
.chart .col:hover .bar { opacity: 1; }
.chart .val { font-size: .7rem; color: var(--muted); margin-bottom: 2px; min-height: 1em; }
.chart .lbl { font-size: .66rem; color: var(--muted); margin-top: 5px; white-space: nowrap; min-height: 1em; }

/* ---- Loading skeletons ---- */
.skel { border-radius: var(--radius); background: linear-gradient(90deg, var(--surface-2) 25%, var(--border) 37%, var(--surface-2) 63%); background-size: 400% 100%; animation: shimmer 1.4s ease infinite; }
.skel.row { height: 84px; }
.skel.stat { height: 76px; }
.skel.banner { height: 84px; margin-bottom: 16px; }
.skel.card-skel { height: 180px; }
@keyframes shimmer { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }

/* ---- Sign in ---- */
.auth { min-height: 100vh; min-height: 100dvh; display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); background: var(--bg); }
.auth-side { position: relative; overflow: hidden; color: #fff; background: radial-gradient(900px 500px at 10% -10%, #5b82f5 0%, transparent 60%), radial-gradient(700px 500px at 100% 110%, #7a4ff0 0%, transparent 55%), #1b3fbd; display: flex; align-items: center; padding: 48px; }
.auth-side::before { content: ""; position: absolute; inset: 0; background-image: radial-gradient(rgba(255, 255, 255, .12) 1px, transparent 1px); background-size: 22px 22px; mask-image: linear-gradient(180deg, #000, transparent 85%); -webkit-mask-image: linear-gradient(180deg, #000, transparent 85%); }
.auth-side-inner { position: relative; max-width: 460px; }
.auth-side h2 { font-size: 2rem; line-height: 1.2; letter-spacing: -.02em; margin: 40px 0 12px; }
.auth-side p { margin: 0 0 30px; opacity: .85; font-size: 1.02rem; line-height: 1.6; }
.auth-side ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 18px; }
.auth-side li { display: flex; gap: 14px; align-items: flex-start; font-size: .92rem; line-height: 1.45; }
.auth-side li b { display: block; font-size: .98rem; }
.auth-side li div > div { opacity: .78; }
.f-ico { width: 38px; height: 38px; border-radius: 11px; background: rgba(255, 255, 255, .16); border: 1px solid rgba(255, 255, 255, .22); display: grid; place-items: center; flex: none; }
.f-ico .ico { width: auto; }
.auth-main { display: grid; place-items: center; padding: 32px 20px; }
.auth-card { width: 100%; max-width: 400px; }
.auth-card h1 { font-size: 1.7rem; margin: 26px 0 6px; letter-spacing: -.02em; }
.auth-card > p { margin: 0 0 26px; }
.auth-brand { display: flex; align-items: center; gap: 12px; font-weight: 800; font-size: 1.1rem; letter-spacing: -.01em; }
.auth-brand .brand-mark { width: 40px; height: 40px; border-radius: 12px; }
.auth-brand .brand-mark svg { width: 22px; height: 22px; }
.auth-brand.light .brand-mark { background: rgba(255, 255, 255, .2); border: 1px solid rgba(255, 255, 255, .3); }
.auth-card .field { margin-bottom: 16px; }
.auth-card .btn.primary { margin-top: 6px; }
.auth-error { display: flex; align-items: flex-start; gap: 10px; background: var(--err-bg); color: var(--err); border: 1px solid color-mix(in srgb, var(--err) 35%, var(--border)); border-radius: 10px; padding: 11px 13px; font-size: .9rem; font-weight: 600; margin: 0 0 12px; }
.auth-error .ico { margin-top: 2px; }
.auth-foot { margin-top: 26px; text-align: center; color: var(--muted); font-size: .82rem; display: flex; align-items: center; justify-content: center; gap: 8px; }
.auth-card .auth-brand { display: none; }
@media (max-width: 880px) {
  .auth { grid-template-columns: 1fr; background: radial-gradient(700px 360px at 50% -80px, color-mix(in srgb, var(--primary) 20%, transparent), transparent), var(--bg); }
  .auth-side { display: none; }
  .auth-main { align-items: start; padding-top: 12vh; }
  .auth-card .auth-brand { display: flex; }
  .auth-card h1 { margin-top: 22px; }
}
@media (min-width: 881px) { .auth-card { background: transparent; } }

/* ---- Modal and toasts ---- */
.overlay { position: fixed; inset: 0; background: rgba(8, 10, 14, .55); display: grid; place-items: center; z-index: 50; padding: 16px; animation: fade .15s ease; }
.modal { background: var(--surface); border-radius: 16px; border: 1px solid var(--border); width: 100%; max-width: 640px; max-height: 88vh; overflow: auto; padding: 22px; box-shadow: 0 20px 50px rgba(0, 0, 0, .3); }
.modal h2 { font-size: 1.15rem; }
.modal .foot { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; flex-wrap: wrap; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
#toasts { position: fixed; right: 14px; bottom: 14px; display: flex; flex-direction: column; gap: 8px; z-index: 60; max-width: calc(100vw - 28px); }
.toast { background: var(--text); color: var(--bg); padding: 11px 15px; border-radius: 11px; font-weight: 600; box-shadow: 0 6px 20px rgba(0, 0, 0, .25); animation: fade .2s ease; display: flex; align-items: center; gap: 10px; line-height: 1.35; }
.toast .ico { color: #34d399; }
.toast.err { background: var(--err); color: #fff; }
.toast.err .ico { color: #fff; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}

/* ---- Status page ---- */
.status-banner { display: flex; align-items: center; gap: 16px; padding: 18px 20px; border-radius: var(--radius); border: 1px solid var(--border); margin-bottom: 16px; background: var(--surface); box-shadow: var(--shadow); }
.status-banner .big { font-size: 1.15rem; font-weight: 700; letter-spacing: -.01em; }
.status-banner.ok { background: var(--ok-bg); border-color: color-mix(in srgb, var(--ok) 35%, var(--border)); }
.status-banner.warn { background: var(--warn-bg); border-color: color-mix(in srgb, var(--warn) 45%, var(--border)); }
.status-banner.error { background: var(--err-bg); border-color: color-mix(in srgb, var(--err) 45%, var(--border)); }
.status-orb { width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center; background: var(--surface); flex: none; font-size: 1.25rem; }
.status-orb .ico { width: auto; }
.status-banner.ok .status-orb { color: var(--ok); }
.status-banner.warn .status-orb { color: var(--warn); }
.status-banner.error .status-orb { color: var(--err); }
.sdot { width: 10px; height: 10px; border-radius: 50%; flex: none; display: inline-block; background: var(--ok); }
.sdot.warn { background: var(--warn); }
.sdot.error { background: var(--err); }
.sdot.info { background: var(--off); }
.status-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
.status-card { margin-bottom: 0; min-width: 0; }
.status-card.wide { grid-column: 1 / -1; }
.status-card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.status-card-head h2 { margin: 0; display: inline-flex; align-items: center; gap: 10px; }
.sec-ico { width: 32px; height: 32px; border-radius: 10px; display: grid; place-items: center; background: var(--blue-bg); color: var(--primary); font-size: .9rem; flex: none; }
.sec-ico .ico { width: auto; }
.sec-ico.warn { background: var(--warn-bg); color: var(--warn); }
.sec-ico.error { background: var(--err-bg); color: var(--err); }
.sec-ico.ok { background: var(--ok-bg); color: var(--ok); }
.srow { display: flex; gap: 12px; align-items: flex-start; padding: 11px 0; border-bottom: 1px solid var(--border); }
.srow:last-child { border-bottom: 0; }
.srow .sdot { margin-top: 6px; }
.sbody { flex: 1; min-width: 0; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr); gap: 2px 14px; }
.slabel { color: var(--muted); }
.sval { font-weight: 600; overflow-wrap: anywhere; text-align: right; }
.sbody .small { grid-column: 1 / -1; text-align: left; }
.slabel:empty { display: none; }
.slabel:empty + .sval { grid-column: 1 / -1; text-align: left; }
.status-card .actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
@media (max-width: 860px) { .status-grid { grid-template-columns: 1fr; } }
@media (max-width: 520px) {
  .sbody { grid-template-columns: 1fr; }
  .sval { text-align: left; }
  .status-banner { padding: 14px; gap: 12px; }
}

/* ---- Client form ---- */
.client-form { max-width: 860px; }
.form-section { padding: 20px 20px 6px; }
.form-section-head { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.form-section-head h2 { margin: 0; }
.form-actions { display: flex; gap: 10px; flex-wrap: wrap; padding: 4px 0 16px; }
input.masked { letter-spacing: .08em; }

/* ---- Tab bar (phones) ---- */
.tabbar { display: none; }
@media (max-width: 720px) {
  .topbar .nav { display: none; }
  .topbar-inner { padding: 0 14px; height: 56px; }
  .container { padding: 18px 14px calc(92px + env(safe-area-inset-bottom)); }
  h1 { font-size: 1.3rem; }
  .tabbar {
    display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
    background: color-mix(in srgb, var(--surface) 94%, transparent); backdrop-filter: saturate(160%) blur(12px); -webkit-backdrop-filter: saturate(160%) blur(12px);
    border-top: 1px solid var(--border); padding: 6px 10px calc(6px + env(safe-area-inset-bottom));
  }
  .tabbar a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; height: 52px; border-radius: 12px; color: var(--muted); font-size: .72rem; font-weight: 700; line-height: 1; transition: background .15s, color .15s; }
  .tabbar a:hover { text-decoration: none; }
  .tabbar a.active { color: var(--primary); background: var(--blue-bg); }
  .tabbar .nav-ico { width: 24px; height: 22px; }
  .tabbar .nav-ico .ico { font-size: 1.2rem; }
  #toasts { bottom: calc(80px + env(safe-area-inset-bottom)); left: 14px; right: 14px; }
  .page-head .actions { width: 100%; }
  .page-head .actions .btn:not(.sm) { flex: 1 1 auto; }
  .updated { display: none; }
  /* Touch targets, and 16px text so iOS does not zoom into fields */
  input, select, textarea { font-size: 16px; height: 46px; }
  textarea { height: auto; }
  .btn { height: 44px; }
  .btn.sm { height: 38px; padding: 0 13px; }
  .seg { height: 44px; }
  .toolbar input, .toolbar select { flex: 1 1 140px; width: auto; min-width: 0; }
  .toolbar .search { flex: 1 1 100%; }
  .date-f { flex: 1 1 140px; }
  .date-f input { min-width: 0; flex: 1; }
  .card { padding: 16px; }
  .form-section { padding: 16px 16px 4px; }
  .input-icon input { height: 48px; }
  .seg { width: 100%; }
  .seg button { flex: 1; }
}

/* ---- Tables become cards on phones: no sideways scrolling ---- */
@media (max-width: 720px) {
  .card:has(> .table-wrap) { background: transparent; border: 0; box-shadow: none; padding: 0; }
  table.rt, table.rt tbody, table.rt tr, table.rt td { display: block; width: 100%; }
  table.rt thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  table.rt tr { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 6px 14px; margin-bottom: 10px; box-shadow: var(--shadow); }
  table.rt td { display: flex; justify-content: space-between; align-items: center; gap: 14px; border: 0; padding: 8px 0; text-align: right; min-height: 36px; }
  table.rt td + td { border-top: 1px dashed var(--border); }
  table.rt td::before { content: attr(data-label); color: var(--muted); font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; text-align: left; flex: none; }
  table.rt td .chips { justify-content: flex-end; }
  table.rt tbody tr.click:active { background: var(--surface-2); }
  .card:has(> .table-wrap) > .pager { padding-top: 4px; border-top: 0; }
}

/* ---- Modals: bottom sheet on phones ---- */
@media (max-width: 520px) {
  .overlay { align-items: end; padding: 0; }
  .modal { max-width: none; border-radius: 20px 20px 0 0; max-height: 92vh; padding: 20px 16px calc(18px + env(safe-area-inset-bottom)); animation: sheet .2s ease; }
  .modal .foot .btn { flex: 1 1 auto; }
}
@keyframes sheet { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }

/* Wide screens: a little more breathing room */
@media (min-width: 1200px) { .topbar-inner, .container { max-width: 1180px; } }
@media print { .topbar, .tabbar, #toasts { display: none; } }
