:root {
  --azure: #00A3FF; --azure-ink: #0077BB; --azure-soft: #E6F6FF;
  --ink: #0A0A0A; --gray: #6B7280; --gray-2: #9CA3AF; --line: #E5E7EB; --bg: #FFFFFF; --panel: #FAFAFA;
  --ok: #10915A; --warn: #B7791F; --bad: #D92D20;
  --radius: 12px; --tab-h: 64px;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", "Segoe UI", Roboto, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); -webkit-text-size-adjust: 100%; }
body { font-size: 15px; line-height: 1.45; }
.hidden { display: none !important; }
a { color: var(--azure-ink); }
h1, h2, h3 { margin: 0; letter-spacing: -0.01em; }
h3 { font-size: 15px; margin-bottom: 10px; }
small, .muted { color: var(--gray); }
.err { color: var(--bad); min-height: 1.2em; font-size: 14px; }

/* Login */
.login { min-height: 100dvh; display: grid; place-items: center; padding: 24px; }
.login-card { width: 100%; max-width: 340px; display: grid; gap: 12px; text-align: center; }
.login-logo { width: 88px; height: 88px; margin: 0 auto; }
.login h1 { font-size: 22px; margin-bottom: 8px; }

/* Shell */
.shell { display: grid; grid-template-columns: 232px 1fr; min-height: 100dvh; }
.side { border-right: 1px solid var(--line); padding: 18px 12px; position: sticky; top: 0; height: 100dvh; }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 18px; font-size: 16px; }
.brand img { width: 34px; height: 34px; }
.brand b { color: var(--azure); font-weight: 700; }
#nav a { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 8px; color: var(--ink);
  text-decoration: none; font-weight: 500; }
#nav a:hover { background: var(--panel); }
#nav a.active { background: var(--azure-soft); color: var(--azure-ink); }
main { min-width: 0; }
.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 24px 8px;
  position: sticky; top: 0; background: rgba(255,255,255,.94); backdrop-filter: blur(8px); z-index: 5; }
.top h2 { font-size: 22px; }
.top-status { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.view { padding: 8px 24px 40px; max-width: 1100px; }
.tabbar { display: none; }

@media (max-width: 820px) {
  .shell { grid-template-columns: 1fr; }
  .side { display: none; }
  .top { padding: calc(env(safe-area-inset-top) + 12px) 16px 8px; }
  .top h2 { font-size: 20px; }
  .view { padding: 4px 16px calc(var(--tab-h) + env(safe-area-inset-bottom) + 24px); }
  .tabbar { display: flex; position: fixed; bottom: 0; left: 0; right: 0; z-index: 10; background: #fff;
    border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); height: calc(var(--tab-h) + env(safe-area-inset-bottom)); }
  .tabbar a { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
    font-size: 11px; color: var(--gray); text-decoration: none; font-weight: 500; }
  .tabbar a.active { color: var(--azure); }
  .tabbar svg { width: 22px; height: 22px; }
}
svg.i { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* Building blocks */
.grid { display: grid; gap: 12px; }
.kpis { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
.two { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.card { border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; background: #fff; min-width: 0; }
.kpi .label { color: var(--gray); font-size: 13px; }
.kpi .value { font-size: clamp(18px, 5vw, 26px); font-weight: 650; margin-top: 2px; font-variant-numeric: tabular-nums; }
.kpi .sub { font-size: 12px; color: var(--gray); }
.section { margin-top: 22px; }
.section-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 10px; flex-wrap: wrap; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.between { justify-content: space-between; }
.stack { display: grid; gap: 10px; }

.pill { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 999px; font-size: 12px;
  font-weight: 600; background: var(--panel); color: var(--gray); border: 1px solid var(--line); white-space: nowrap; }
.pill.ok { color: var(--ok); background: #EAF7F0; border-color: #CDEBDB; }
.pill.warn { color: var(--warn); background: #FFF7E6; border-color: #F5DDB0; }
.pill.bad { color: var(--bad); background: #FDECEA; border-color: #F6CBC6; }
.pill.blue { color: var(--azure-ink); background: var(--azure-soft); border-color: #BFE6FF; }
.dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }

.btn { appearance: none; border: 1px solid var(--line); background: #fff; color: var(--ink); padding: 9px 14px;
  border-radius: 10px; font: inherit; font-weight: 600; font-size: 14px; cursor: pointer; display: inline-flex;
  align-items: center; justify-content: center; gap: 6px; min-height: 40px; text-decoration: none; }
.btn:hover { border-color: #cfd4da; }
.btn.primary { background: var(--azure); border-color: var(--azure); color: #fff; }
.btn.primary:hover { background: #0094E8; }
.btn.dark { background: var(--ink); color: #fff; border-color: var(--ink); }
.btn.danger { color: var(--bad); }
.btn.sm { padding: 5px 10px; min-height: 32px; font-size: 13px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .5; cursor: default; }

input, select, textarea { font: inherit; font-size: 16px; padding: 9px 11px; border: 1px solid var(--line);
  border-radius: 10px; background: #fff; color: var(--ink); width: 100%; min-height: 40px; }
textarea { min-height: 96px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--azure-soft); border-color: var(--azure); }
input[type=checkbox] { width: 20px; height: 20px; min-height: 0; accent-color: var(--azure); }
input[type=range] { padding: 0; accent-color: var(--azure); border: 0; }
label.f { display: grid; gap: 5px; font-size: 13px; color: var(--gray); font-weight: 500; }
label.f > span { color: var(--ink); }
label.chk { display: flex; gap: 10px; align-items: center; font-size: 14px; }
.form-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }

/* Queue */
.job { display: grid; grid-template-columns: 64px 1fr auto; gap: 12px; align-items: center; padding: 10px;
  border: 1px solid var(--line); border-radius: var(--radius); cursor: pointer; background: #fff; }
.job:hover { border-color: #cfd4da; }
.thumb { width: 64px; height: 96px; border-radius: 8px; background: var(--panel) center/cover no-repeat;
  border: 1px solid var(--line); display: grid; place-items: center; color: var(--gray-2); font-size: 11px; }
.job .cap { font-size: 14px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.job .meta { font-size: 12px; color: var(--gray); margin-top: 4px; display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.job .when { font-weight: 650; font-size: 13px; }
.order { display: grid; gap: 4px; }
.order button { border: 1px solid var(--line); background: #fff; border-radius: 8px; width: 34px; height: 30px; cursor: pointer; color: var(--gray); }

.day { margin-top: 18px; }
.day h4 { margin: 0 0 8px; font-size: 13px; color: var(--gray); text-transform: uppercase; letter-spacing: .05em; }
.slot { display: grid; grid-template-columns: 78px 1fr auto; gap: 10px; align-items: center; padding: 8px 10px;
  border-left: 3px solid var(--azure); background: var(--panel); border-radius: 0 10px 10px 0; margin-bottom: 6px; cursor: pointer; }
.slot .t { font-weight: 650; font-variant-numeric: tabular-nums; }
.slot .c { font-size: 13px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }

/* Tables */
.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl th, .tbl td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
.tbl th { color: var(--gray); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
.tbl td.num, .tbl th.num { text-align: right; font-variant-numeric: tabular-nums; }
.scroll-x { overflow-x: auto; }

.bar { height: 6px; background: var(--line); border-radius: 999px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--azure); }

/* Trends */
.trend { border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; display: grid; gap: 8px; }
.trend .topic { font-weight: 650; }
.trend .ex { font-size: 14px; color: #333; background: var(--panel); border-radius: 8px; padding: 8px 10px; white-space: pre-wrap; }
.tag { font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--gray); font-weight: 700; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { display: inline-flex; gap: 6px; align-items: center; padding: 4px 10px; border-radius: 999px; background: var(--panel);
  border: 1px solid var(--line); font-size: 14px; font-variant-numeric: tabular-nums; }
.chip button { border: 0; background: none; cursor: pointer; color: var(--gray); font-size: 15px; padding: 0; }

/* Branding preview */
.preview-wrap { display: grid; grid-template-columns: 220px 1fr; gap: 16px; align-items: start; }
@media (max-width: 600px) { .preview-wrap { grid-template-columns: 1fr; } .phone { margin: 0 auto; } }
.phone { position: relative; width: 220px; aspect-ratio: 9/16; border-radius: 16px; overflow: hidden; background: #222;
  border: 1px solid var(--line); }
.phone > img.bg { width: 100%; height: 100%; object-fit: cover; }
.phone .ov { position: absolute; height: auto; }
.phone .safe { position: absolute; left: 0; right: 0; border: 1px dashed rgba(255,255,255,.5); pointer-events: none; }
.phone .ui { position: absolute; right: 8px; bottom: 60px; display: grid; gap: 14px; }
.phone .ui i { width: 18px; height: 18px; border-radius: 50%; background: rgba(255,255,255,.65); display: block; }

/* Modal */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.38); z-index: 50; display: grid; place-items: center; padding: 16px; }
.sheet { background: #fff; border-radius: 16px; width: 100%; max-width: 640px; max-height: 92dvh; overflow: auto; padding: 18px; }
@media (max-width: 820px) {
  .modal { place-items: end center; padding: 0; }
  .sheet { border-radius: 16px 16px 0 0; max-height: 94dvh; padding-bottom: calc(18px + env(safe-area-inset-bottom)); }
}
.sheet video { width: 100%; max-height: 52dvh; background: #000; border-radius: 10px; }
.events { font-size: 12px; color: var(--gray); max-height: 180px; overflow: auto; border-top: 1px solid var(--line); padding-top: 8px; }
.events div { padding: 2px 0; }
.events .error { color: var(--bad); } .events .warn { color: var(--warn); }

.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--tab-h) + env(safe-area-inset-bottom) + 16px);
  background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 10px; font-size: 14px; z-index: 60; max-width: 90vw; }
@media (min-width: 821px) { .toast { bottom: 24px; } }
.empty { text-align: center; color: var(--gray); padding: 36px 12px; border: 1px dashed var(--line); border-radius: var(--radius); }
.empty img { width: 56px; opacity: .9; }
.code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; background: var(--panel);
  border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; word-break: break-all; }
.note { font-size: 13px; color: var(--gray); }
.log { font-family: ui-monospace, Menlo, monospace; font-size: 12px; }
.log .error { color: var(--bad); } .log .warn { color: var(--warn); }
