:root {
  --nav: #0f1b2d; --nav-ink: #c9d3e0; --nav-active: #ffffff; --brand: #12a37f;
  --bg: #f3f5f8; --card: #ffffff; --ink: #1c2430; --muted: #6a7686; --line: #e2e7ee; --head: #f7f9fb;
  --t-grey: #6f7782; --t-blue: #3aa0c8; --t-green: #3d9a50; --t-yellow: #c9c21a; --t-orange: #d98a2b; --t-red: #c8423c;
  --ok: #2f9e5e; --bad: #c8423c; --warn: #d98a2b;
  --row-ready: #e3f3fa; --row-call: #e3f4e6; --row-dispo: #fbf8d9; --row-pause: #fbeedd; --row-dead: #f9e1df;
  font-size: 14px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--ink); font-family: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif; }
button, input, select { font: inherit; }
.hidden { display: none !important; }

/* ---------- login ---------- */
.login-wrap { min-height: 100%; display: grid; grid-template-columns: 1.1fr 1fr; }
.login-art { background: radial-gradient(1200px 600px at -10% 110%, #1d6e5a 0%, transparent 60%), linear-gradient(160deg, #0f1b2d 0%, #13263f 100%);
  color: #dfe7f1; padding: 56px; display: flex; flex-direction: column; justify-content: space-between; }
.login-art h2 { font-size: 34px; line-height: 1.15; margin: 0 0 14px; color: #fff; font-weight: 650; letter-spacing: -0.02em; }
.login-art p { color: #a9b6c8; max-width: 440px; line-height: 1.55; margin: 0; }
.login-stats { display: flex; gap: 36px; }
.login-stats b { display: block; color: #fff; font-size: 22px; font-weight: 650; }
.login-stats span { color: #8fa0b6; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; }
.login-panel { display: flex; align-items: center; justify-content: center; padding: 32px 16px; background: #fff; }
.login-card { width: 100%; max-width: 360px; }
.login-card h1 { font-size: 22px; margin: 22px 0 6px; font-weight: 650; }
.login-card .sub { color: var(--muted); margin: 0 0 26px; }
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 12px; font-weight: 600; color: #3b4656; margin-bottom: 6px; }
.field input { width: 100%; padding: 11px 12px; border: 1px solid #cfd6df; border-radius: 8px; background: #fff; color: var(--ink); }
.field input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(18,163,127,.15); }
.btn-primary { width: 100%; padding: 11px; border: 0; border-radius: 8px; background: var(--brand); color: #fff; font-weight: 600; cursor: pointer; }
.btn-primary:hover { filter: brightness(1.05); }
.btn-primary:disabled { opacity: .6; cursor: default; }
.login-err { color: var(--bad); font-size: 13px; min-height: 18px; margin: 4px 0 10px; }
.login-foot { margin-top: 28px; font-size: 12px; color: var(--muted); }
.logo { display: inline-flex; align-items: center; gap: 10px; font-weight: 700; font-size: 18px; letter-spacing: -.01em; }
.logo i { width: 28px; height: 28px; border-radius: 8px; background: linear-gradient(135deg, #18c497, #0e8a6b); position: relative; }
.logo i::after { content: ""; position: absolute; inset: 29%; border: 2.5px solid #fff; border-radius: 2px; transform: rotate(45deg); }
.login-art .logo { color: #fff; }
@media (max-width: 820px) { .login-wrap { grid-template-columns: 1fr; } .login-art { display: none; } }

/* ---------- shell ---------- */
.topbar { height: 56px; background: var(--nav); display: flex; align-items: center; padding: 0 20px; gap: 28px; position: sticky; top: 0; z-index: 10; }
.topbar .logo { color: #fff; font-size: 16px; }
.topbar .logo i { width: 24px; height: 24px; }
.nav { display: flex; gap: 4px; height: 100%; }
.nav a { display: flex; align-items: center; gap: 8px; padding: 0 14px; color: var(--nav-ink); text-decoration: none; font-weight: 500; border-bottom: 3px solid transparent; }
.nav a:hover { color: #fff; }
.nav a.active { color: var(--nav-active); border-bottom-color: var(--brand); }
.nav svg { width: 16px; height: 16px; }
.topbar .spacer { flex: 1; }
.user-chip { display: flex; align-items: center; gap: 10px; color: var(--nav-ink); }
.user-chip .av { width: 30px; height: 30px; border-radius: 50%; background: #25344a; color: #fff; display: grid; place-items: center; font-weight: 600; font-size: 12px; }
.user-chip small { display: block; font-size: 11px; color: #7f8fa5; text-transform: capitalize; }
.user-chip button { background: transparent; border: 1px solid #2b3b52; color: var(--nav-ink); border-radius: 6px; padding: 5px 10px; cursor: pointer; }
.user-chip button:hover { color: #fff; border-color: #44587a; }
main.page { padding: 20px 24px 40px; max-width: 1680px; margin: 0 auto; }
.page-head { display: flex; align-items: center; gap: 14px; margin-bottom: 16px; flex-wrap: wrap; }
.page-head h1 { font-size: 22px; margin: 0; font-weight: 650; letter-spacing: -.01em; display: flex; align-items: center; gap: 10px; }
.page-head .grow { flex: 1; }
.select, .input { padding: 7px 10px; border: 1px solid #cfd6df; border-radius: 6px; background: #fff; color: var(--ink); }
.btn { padding: 7px 12px; border: 1px solid #cfd6df; border-radius: 6px; background: #fff; color: var(--ink); cursor: pointer; font-weight: 500; }
.btn:hover { background: #f4f6f9; }
.btn.solid { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.danger { background: var(--bad); border-color: var(--bad); color: #fff; }
.seg { display: inline-flex; border: 1px solid #cfd6df; border-radius: 6px; overflow: hidden; }
.seg button { border: 0; background: #fff; padding: 7px 12px; cursor: pointer; border-right: 1px solid #cfd6df; font-weight: 500; }
.seg button:last-child { border-right: 0; }
.seg button.on { background: var(--nav); color: #fff; }
.clock { font-variant-numeric: tabular-nums; color: var(--muted); font-size: 15px; }
.pill { font-size: 12px; padding: 3px 9px; border-radius: 99px; font-weight: 600; }
.pill.ok { background: #e2f4ea; color: var(--ok); } .pill.bad { background: #fbe4e2; color: var(--bad); }

/* ---------- monitor ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; }
.counters { display: grid; grid-template-columns: repeat(5, 1fr); border-bottom: 1px solid var(--line); }
.counters div { padding: 14px 16px; border-right: 1px solid var(--line); display: flex; align-items: baseline; gap: 8px; }
.counters div:last-child { border-right: 0; }
.counters b { font-size: 30px; font-weight: 600; font-variant-numeric: tabular-nums; }
.counters span { color: var(--muted); }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); }
.stats div { padding: 10px 16px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); font-size: 13px; text-transform: uppercase; color: #3b4656; position: relative; }
.stats div:nth-child(4n) { border-right: 0; }
.stats div b { color: var(--ink); font-weight: 600; font-variant-numeric: tabular-nums; }
.stats .meter { position: absolute; left: 0; top: 0; bottom: 0; background: rgba(61,154,80,.18); z-index: 0; }
.stats .meter.bad { background: rgba(200,66,60,.20); }
.stats div > span { position: relative; z-index: 1; }
.tiles { display: grid; grid-template-columns: repeat(6, 1fr); gap: 14px; margin: 16px 0; }
.tile { border-radius: 10px; color: #fff; padding: 14px 18px 12px; position: relative; overflow: hidden; }
.tile b { font-size: 54px; line-height: 1; font-weight: 300; font-variant-numeric: tabular-nums; }
.tile span { display: block; margin-top: 8px; font-weight: 500; opacity: .95; }
.tile svg { position: absolute; right: 14px; top: 16px; width: 40px; height: 40px; opacity: .9; }
.tile.grey { background: var(--t-grey); } .tile.blue { background: var(--t-blue); } .tile.green { background: var(--t-green); }
.tile.yellow { background: var(--t-yellow); } .tile.orange { background: var(--t-orange); } .tile.red { background: var(--t-red); }
.actions { display: flex; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.actions .grow { flex: 1; }
.droprow { display: flex; gap: 10px; flex-wrap: wrap; margin: 0 0 12px; }
.dropchip { background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px; font-size: 13px; }
.dropchip b { font-variant-numeric: tabular-nums; }
.dropchip.warn { border-color: var(--warn); } .dropchip.bad { border-color: var(--bad); background: #fdf1f0; }

/* ---------- tables ---------- */
.table-wrap { overflow: auto; max-height: calc(100vh - 260px); border-radius: 10px; }
table.grid { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13px; }
table.grid th { position: sticky; top: 0; background: var(--head); text-align: left; font-weight: 600; color: #3b4656; padding: 9px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; z-index: 1; }
table.grid td { padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; font-variant-numeric: tabular-nums; }
table.grid td.num, table.grid th.num { text-align: right; }
table.grid tr.total td { font-weight: 700; background: #f7f9fb; position: sticky; bottom: 0; border-top: 2px solid var(--line); }
table.grid tr.r-wait td { background: var(--row-ready); } table.grid tr.r-talk td { background: var(--row-call); }
table.grid tr.r-wrap td { background: var(--row-dispo); } table.grid tr.r-pause td { background: var(--row-pause); }
table.grid tr.r-dead td { background: var(--row-dead); }
table.grid .icon-btn { border: 0; background: transparent; cursor: pointer; padding: 2px 4px; color: #3b4656; }
table.grid .icon-btn:hover { color: var(--bad); }
table.grid td.sup .icon-btn { font-size: 12px; border: 1px solid var(--line); border-radius: 5px; margin-right: 4px; padding: 2px 6px; background: #fff; }
.empty { padding: 40px; text-align: center; color: var(--muted); }

/* ---------- reports ---------- */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 14px; overflow-x: auto; }
.tabs button { border: 0; background: transparent; padding: 10px 16px; cursor: pointer; color: var(--muted); font-weight: 600; border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs button:hover { color: var(--ink); }
.tabs button.on { color: var(--ink); border-bottom-color: var(--brand); }
.filters { display: flex; gap: 10px; align-items: end; flex-wrap: wrap; margin-bottom: 14px; }
.filters label { display: block; font-size: 11px; font-weight: 600; color: var(--muted); margin-bottom: 4px; text-transform: uppercase; letter-spacing: .04em; }
.toast { position: fixed; bottom: 18px; right: 18px; background: #1c2430; color: #fff; padding: 10px 14px; border-radius: 8px; font-size: 13px; }
/* ---------- admin ---------- */
.user-chip #pwBtn { margin-right: 4px; }
.drawer { position: fixed; inset: 0; background: rgba(15, 27, 45, .35); display: flex; justify-content: flex-end; z-index: 50; }
.drawer-card { width: min(560px, 100%); height: 100%; background: #fff; overflow-y: auto; padding: 18px 22px 40px; box-shadow: -8px 0 24px rgba(0,0,0,.12); }
.drawer-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.drawer-head h2 { font-size: 18px; margin: 0; }
.icon-x { border: 0; background: transparent; font-size: 26px; cursor: pointer; color: var(--muted); line-height: 1; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 14px; }
.form-grid .full { grid-column: 1 / -1; }
.form-grid label { display: block; font-size: 11px; font-weight: 600; color: var(--muted); margin-bottom: 4px; text-transform: uppercase; letter-spacing: .04em; }
.form-grid input, .form-grid select, .form-grid textarea { width: 100%; padding: 8px 10px; border: 1px solid #cfd6df; border-radius: 6px; font: inherit; background: #fff; }
.form-grid textarea { min-height: 90px; resize: vertical; font-family: ui-monospace, Menlo, monospace; font-size: 12px; }
.form-grid .hint { font-size: 11px; color: var(--muted); margin-top: 3px; }
.form-actions { display: flex; gap: 8px; margin-top: 16px; }
.section-title { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 22px 0 8px; border-top: 1px solid var(--line); padding-top: 14px; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; font-size: 13px; margin: 8px 0; }
.kv b { font-variant-numeric: tabular-nums; }
.secret { font-family: ui-monospace, Menlo, monospace; background: #fff6d6; border: 1px solid #e8c95b; padding: 8px 10px; border-radius: 6px; user-select: all; }
.tag { display: inline-block; font-size: 11px; padding: 1px 7px; border-radius: 99px; background: #eef1f5; color: #3b4656; font-weight: 600; }
.tag.on { background: #e2f4ea; color: var(--ok); } .tag.off { background: #fbe4e2; color: var(--bad); }
table.grid td .btn { padding: 3px 9px; font-size: 12px; }
@media (max-width: 1100px) { .tiles { grid-template-columns: repeat(3, 1fr); } .counters { grid-template-columns: repeat(2, 1fr); } .stats { grid-template-columns: repeat(2, 1fr); } }

/* outage alerts banner (watchdog) */
.alertbar { position: sticky; top: 56px; z-index: 9; }
.alertbar .al { display: flex; gap: 12px; align-items: center; padding: 8px 20px; color: #fff; font-size: 13px; background: var(--bad); border-bottom: 1px solid rgba(0,0,0,.15); }
.alertbar .al.warn { background: var(--warn); }
.alertbar .al b { white-space: nowrap; }
.alertbar .al .fix { opacity: .9; font-size: 12px; }
.alertbar .al .sp { flex: 1; }
.alertbar .al button { background: rgba(255,255,255,.2); border: 1px solid rgba(255,255,255,.5); color: #fff; border-radius: 4px; padding: 2px 10px; cursor: pointer; font-size: 12px; }

/* checkbox grids (targeting states/sub-IDs, manager campaigns) */
.chkgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 2px 10px; max-height: 260px; overflow: auto; padding: 4px 0; }
.chkgrid.states { grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); max-height: none; }
.chkgrid .chk small { color: var(--muted, #888); margin-left: 2px; }
.chkgrid .chk.hidden { display: none; }
#tgBox label.chk, #u_scope label.chk { display: flex; gap: 6px; align-items: center; text-transform: none; letter-spacing: 0; font-size: 13px; font-weight: 400; color: inherit; margin: 0; }
#tgBox select.tgmode { width: 180px; flex: none; }
#tgBox textarea { width: auto; }
#tgBox label.chk input, #u_scope label.chk input { width: auto; flex: none; margin: 0; }
#tgBox label.chk, #u_scope label.chk { justify-content: flex-start; text-align: left; }
