:root {
  --bg: #f5f6fb;
  --surface: #ffffff;
  --surface-2: #f0f1f8;
  --border: #e3e5ef;
  --text: #171a2c;
  --muted: #6b7088;
  --brand: #5b45f5;
  --brand-2: #4f46e5;
  --brand-soft: #ece9ff;
  --ok: #16a34a;
  --ok-soft: #dcfce7;
  --warn: #d97706;
  --warn-soft: #fef3c7;
  --danger: #dc2626;
  --danger-soft: #fee2e2;
  --off: #94a3b8;
  --off-soft: #eef1f5;
  --shadow: 0 1px 2px rgba(20, 22, 50, .05), 0 4px 16px rgba(20, 22, 50, .05);
  --radius: 14px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1020;
    --surface: #161930;
    --surface-2: #1d2140;
    --border: #2a2f52;
    --text: #e8eaf6;
    --muted: #9aa0c0;
    --brand: #8b7bff;
    --brand-2: #7c6cff;
    --brand-soft: #2a2560;
    --ok: #34d399;
    --ok-soft: #0f3a2b;
    --warn: #fbbf24;
    --warn-soft: #3d2f0d;
    --danger: #f87171;
    --danger-soft: #45161a;
    --off: #7c86a8;
    --off-soft: #232845;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 20px rgba(0, 0, 0, .25);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: Inter, "Segoe UI", system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--brand); }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.hidden { display: none !important; }

.boot { min-height: 100vh; display: grid; place-items: center; }
.spinner { width: 28px; height: 28px; border-radius: 50%; border: 3px solid var(--border); border-top-color: var(--brand); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Botões / campos ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  padding: 9px 16px; border-radius: 10px; font-weight: 600; cursor: pointer;
  transition: background .15s, border-color .15s, transform .05s, opacity .15s;
  white-space: nowrap;
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-2); }
.btn.ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn.warn { background: var(--warn); border-color: var(--warn); color: #fff; }
.btn.danger-ghost { color: var(--danger); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.lg { padding: 14px 22px; font-size: 15px; border-radius: 12px; }
.btn.sm { padding: 6px 10px; font-size: 12px; border-radius: 8px; }
.btn.block { width: 100%; }

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field label { font-weight: 600; font-size: 13px; }
.input, select.input, textarea.input {
  width: 100%; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--surface); outline: none; transition: border-color .15s, box-shadow .15s;
}
.input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
textarea.input { resize: vertical; min-height: 70px; }
.hint { font-size: 12px; color: var(--muted); }
.error-msg { background: var(--danger-soft); color: var(--danger); padding: 10px 12px; border-radius: 10px; font-size: 13px; margin-bottom: 14px; }

/* ---------- Login ---------- */
.auth-wrap { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.auth-side {
  background: radial-gradient(1200px 600px at -10% -10%, #8a74ff 0%, transparent 60%), linear-gradient(135deg, #4f46e5, #2d1f8f);
  color: #fff; padding: 56px; display: flex; flex-direction: column; justify-content: space-between; position: relative; overflow: hidden;
}
.auth-side h1 { font-size: 38px; line-height: 1.12; margin: 0 0 14px; letter-spacing: -.02em; }
.auth-side p { opacity: .85; font-size: 16px; max-width: 420px; margin: 0; }
.auth-side .pulse-line { position: absolute; left: 0; right: 0; bottom: 120px; opacity: .2; }
.auth-feats { display: grid; gap: 12px; margin-top: 32px; }
.auth-feats div { display: flex; gap: 10px; align-items: center; opacity: .92; }
.auth-feats span { width: 26px; height: 26px; border-radius: 8px; background: rgba(255,255,255,.16); display: grid; place-items: center; font-size: 13px; }
.auth-main { display: grid; place-items: center; padding: 32px 16px; }
.auth-card { width: 100%; max-width: 380px; }
.auth-card h2 { font-size: 24px; margin: 0 0 6px; letter-spacing: -.01em; }
.auth-card .sub { color: var(--muted); margin: 0 0 24px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 17px; letter-spacing: -.01em; }
.brand img { width: 32px; height: 32px; }
.brand small { display: block; font-weight: 500; font-size: 11px; opacity: .7; letter-spacing: .02em; }
.link-btn { background: none; border: 0; color: var(--brand); cursor: pointer; padding: 0; font-weight: 600; }
.email-chip { display: flex; align-items: center; justify-content: space-between; padding: 10px 12px; border-radius: 10px; background: var(--surface-2); margin-bottom: 16px; font-weight: 500; }
@media (max-width: 860px) {
  .auth-wrap { grid-template-columns: 1fr; }
  .auth-side { display: none; }
}

/* ---------- Layout ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20; background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: blur(10px); border-bottom: 1px solid var(--border);
}
.topbar-inner { max-width: 1280px; margin: 0 auto; padding: 0 20px; height: 62px; display: flex; align-items: center; gap: 24px; }
.nav { display: flex; gap: 4px; flex: 1; overflow-x: auto; scrollbar-width: none; }
.nav a {
  text-decoration: none; color: var(--muted); font-weight: 600; padding: 8px 12px; border-radius: 9px; white-space: nowrap;
}
.nav a:hover { color: var(--text); background: var(--surface-2); }
.nav a.active { color: var(--brand); background: var(--brand-soft); }
.user-menu { position: relative; }
.avatar {
  width: 34px; height: 34px; border-radius: 50%; background: var(--brand-soft); color: var(--brand);
  display: grid; place-items: center; font-weight: 700; font-size: 13px; flex: none;
}
.user-btn { display: flex; align-items: center; gap: 10px; background: none; border: 0; cursor: pointer; padding: 4px; border-radius: 10px; }
.user-btn:hover { background: var(--surface-2); }
.user-btn .meta { text-align: left; line-height: 1.2; }
.user-btn .meta b { display: block; font-size: 13px; max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-btn .meta span { font-size: 11px; color: var(--muted); }
.dropdown {
  position: absolute; right: 0; top: calc(100% + 6px); background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; box-shadow: var(--shadow); min-width: 200px; padding: 6px; z-index: 30;
}
.dropdown button { display: block; width: 100%; text-align: left; background: none; border: 0; padding: 9px 12px; border-radius: 8px; cursor: pointer; }
.dropdown button:hover { background: var(--surface-2); }
.page { max-width: 1280px; margin: 0 auto; padding: 24px 20px 64px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head h1 { margin: 0; font-size: 24px; letter-spacing: -.02em; }
.page-head p { margin: 4px 0 0; color: var(--muted); }
@media (max-width: 720px) {
  .topbar-inner { gap: 12px; padding: 0 12px; }
  .brand .txt, .user-btn .meta { display: none; }
  .page { padding: 18px 16px 48px; }
}

/* ---------- Cards ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-pad { padding: 20px; }
.card h3 { margin: 0 0 14px; font-size: 15px; }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: 1.35fr 1fr; }
@media (max-width: 980px) { .grid-2 { grid-template-columns: 1fr; } }
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
@media (max-width: 760px) { .kpis { grid-template-columns: repeat(2, 1fr); } }
.kpi { padding: 16px; }
.kpi .label { color: var(--muted); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.kpi .value { font-size: 24px; font-weight: 750; margin-top: 4px; letter-spacing: -.02em; }
.kpi .value.ok { color: var(--ok); } .kpi .value.warn { color: var(--warn); } .kpi .value.danger { color: var(--danger); } .kpi .value.off { color: var(--off); }

/* ---------- Status hero ---------- */
.hero { padding: 28px; display: flex; flex-direction: column; gap: 22px; position: relative; overflow: hidden; }
.hero::before { content: ""; position: absolute; inset: 0 0 auto 0; height: 4px; background: var(--hero-color, var(--off)); }
.hero.s-active { --hero-color: var(--ok); }
.hero.s-pause { --hero-color: var(--warn); }
.hero.s-over { --hero-color: var(--danger); }
.hero-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; }
.state-label { display: inline-flex; align-items: center; gap: 10px; font-weight: 700; font-size: 13px; text-transform: uppercase; letter-spacing: .05em; color: var(--hero-color, var(--off)); }
.dot { width: 10px; height: 10px; border-radius: 50%; background: currentColor; position: relative; flex: none; }
.dot.live::after { content: ""; position: absolute; inset: -4px; border-radius: 50%; border: 2px solid currentColor; opacity: .5; animation: ping 1.6s ease-out infinite; }
@keyframes ping { from { transform: scale(.6); opacity: .7; } to { transform: scale(1.6); opacity: 0; } }
.state-title { font-size: 30px; font-weight: 800; letter-spacing: -.02em; margin: 6px 0 2px; }
.timer { font-size: 54px; font-weight: 800; letter-spacing: -.03em; line-height: 1; font-variant-numeric: tabular-nums; }
.hero.s-over .timer { color: var(--danger); }
.limit-bar { height: 8px; border-radius: 99px; background: var(--surface-2); overflow: hidden; margin-top: 10px; }
.limit-bar > i { display: block; height: 100%; background: var(--warn); border-radius: 99px; transition: width .5s; }
.hero.s-over .limit-bar > i { background: var(--danger); }
.hero-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.notice { padding: 12px 14px; border-radius: 10px; background: var(--danger-soft); color: var(--danger); font-weight: 600; font-size: 13px; }

/* ---------- Timeline ---------- */
.timeline { position: relative; height: 36px; background: var(--surface-2); border-radius: 10px; overflow: hidden; }
.timeline .seg { position: absolute; top: 0; bottom: 0; min-width: 2px; }
.timeline .seg.active { background: var(--ok); opacity: .8; }
.timeline .now { position: absolute; top: -2px; bottom: -2px; width: 2px; background: var(--text); opacity: .6; }
.tl-axis { display: flex; justify-content: space-between; font-size: 11px; color: var(--muted); margin-top: 6px; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 12px; font-size: 12px; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }

/* ---------- Lists / tabelas ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 11px 14px; border-bottom: 1px solid var(--border); white-space: nowrap; }
th { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 700; background: var(--surface); position: sticky; top: 0; }
tbody tr:hover { background: var(--surface-2); }
tbody tr:last-child td { border-bottom: 0; }
tr.clickable { cursor: pointer; }
td.right, th.right { text-align: right; }
.person { display: flex; align-items: center; gap: 10px; }
.person b { display: block; font-weight: 600; max-width: 240px; overflow: hidden; text-overflow: ellipsis; }
.person span { font-size: 12px; color: var(--muted); }
.empty { padding: 40px 20px; text-align: center; color: var(--muted); }

.pill { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 99px; font-size: 12px; font-weight: 600; }
.pill.active { background: var(--ok-soft); color: var(--ok); }
.pill.pause { background: var(--warn-soft); color: var(--warn); }
.pill.over { background: var(--danger-soft); color: var(--danger); }
.pill.offline { background: var(--off-soft); color: var(--off); }
.pill.brand { background: var(--brand-soft); color: var(--brand); }
.pill .dot { width: 7px; height: 7px; }
.tag { display: inline-block; padding: 2px 8px; border-radius: 6px; background: var(--surface-2); font-size: 11px; color: var(--muted); margin: 1px 2px 1px 0; }

.pause-list { display: flex; flex-direction: column; }
.pause-item { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.pause-item:last-child { border-bottom: 0; }
.pause-item .sw { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.pause-item .grow { flex: 1; min-width: 0; }
.pause-item .grow b { font-weight: 600; }
.pause-item .grow div { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; padding: 14px; border-bottom: 1px solid var(--border); }
.toolbar .input { width: auto; min-width: 160px; }
.toolbar .search { flex: 1; min-width: 200px; }
.seg-ctl { display: inline-flex; background: var(--surface-2); padding: 3px; border-radius: 10px; }
.seg-ctl button { border: 0; background: none; padding: 6px 12px; border-radius: 8px; cursor: pointer; font-weight: 600; color: var(--muted); font-size: 13px; }
.seg-ctl button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }

.bars { display: flex; flex-direction: column; gap: 10px; }
.bar-row { display: grid; grid-template-columns: 150px 1fr 70px; gap: 10px; align-items: center; font-size: 13px; }
.bar-row .track { height: 10px; background: var(--surface-2); border-radius: 99px; overflow: hidden; }
.bar-row .track i { display: block; height: 100%; border-radius: 99px; }
.bar-row .lbl { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Modal ---------- */
.modal-bg { position: fixed; inset: 0; background: rgba(10, 12, 30, .5); display: grid; place-items: center; z-index: 50; padding: 16px; animation: fade .15s; }
.modal { width: 100%; max-width: 520px; max-height: calc(100vh - 32px); overflow: auto; padding: 24px; animation: pop .18s ease-out; }
.modal.wide { max-width: 920px; }
.modal-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 16px; }
.modal-head h2 { margin: 0; font-size: 19px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { transform: translateY(8px) scale(.98); opacity: 0; } }
.reason-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.reason-opt {
  border: 2px solid var(--border); background: var(--surface); border-radius: 12px; padding: 14px; text-align: left; cursor: pointer;
  display: flex; flex-direction: column; gap: 6px; transition: border-color .15s, background .15s;
}
.reason-opt:hover { border-color: color-mix(in srgb, var(--c) 60%, var(--border)); }
.reason-opt.on { border-color: var(--c); background: color-mix(in srgb, var(--c) 10%, var(--surface)); }
.reason-opt i { width: 12px; height: 12px; border-radius: 4px; background: var(--c); }
.reason-opt b { font-weight: 650; }
.reason-opt span { font-size: 12px; color: var(--muted); }

/* ---------- Toasts ---------- */
#toasts { position: fixed; bottom: 18px; right: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 60; }
.toast { background: var(--text); color: var(--bg); padding: 12px 16px; border-radius: 10px; box-shadow: var(--shadow); font-weight: 500; max-width: 380px; animation: pop .2s; }
.toast.error { background: var(--danger); color: #fff; }
.toast.ok { background: var(--ok); color: #fff; }
@media (max-width: 600px) { #toasts { left: 16px; right: 16px; } .toast { max-width: none; } }

.row-actions { display: flex; gap: 6px; justify-content: flex-end; }
.color-input { width: 44px; height: 40px; padding: 2px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); cursor: pointer; }
.inline-form { display: grid; grid-template-columns: 1fr 140px 60px auto; gap: 10px; align-items: end; }
@media (max-width: 640px) { .inline-form { grid-template-columns: 1fr 1fr; } }
.section-gap { margin-top: 16px; }
