/* ============================================================
   OnliDeskWhatch — Cockpit de Monitoramento
   Tema profissional escuro (padrão) + claro. Sem dependências.
   ============================================================ */
:root {
  --bg: #080b14;
  --bg-grid: rgba(120, 160, 255, .04);
  --panel: #0f1526;
  --surface: #141c31;
  --surface-2: #1a2340;
  --surface-hover: #202b4d;
  --border: rgba(148, 170, 220, .10);
  --border-strong: rgba(148, 170, 220, .20);
  --text: #e8eefc;
  --text-dim: #9aa8c7;
  --text-mute: #64708f;
  --accent: #38bdf8;
  --accent-2: #6366f1;
  --accent-grad: linear-gradient(135deg, #38bdf8 0%, #6366f1 100%);
  --ok: #34d399;
  --warn: #fbbf24;
  --danger: #fb7185;
  --info: #818cf8;
  --shadow: 0 18px 44px rgba(0, 0, 0, .45);
  --shadow-sm: 0 6px 18px rgba(0, 0, 0, .30);
  --radius: 16px;
  --radius-sm: 10px;
  --sidebar-w: 246px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: "SFMono-Regular", ui-monospace, "Cascadia Mono", Consolas, monospace;
}
:root[data-theme="light"] {
  --bg: #eef2f9;
  --bg-grid: rgba(60, 90, 160, .05);
  --panel: #ffffff;
  --surface: #ffffff;
  --surface-2: #f4f7fc;
  --surface-hover: #eaf0fb;
  --border: rgba(30, 50, 90, .10);
  --border-strong: rgba(30, 50, 90, .18);
  --text: #101a30;
  --text-dim: #47546f;
  --text-mute: #8592ab;
  --shadow: 0 18px 44px rgba(40, 60, 110, .14);
  --shadow-sm: 0 6px 18px rgba(40, 60, 110, .10);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  color: var(--text);
  background:
    radial-gradient(1100px 620px at 84% -12%, rgba(99, 102, 241, .14), transparent 60%),
    radial-gradient(900px 500px at 6% 108%, rgba(56, 189, 248, .10), transparent 55%),
    var(--bg);
  -webkit-font-smoothing: antialiased;
  line-height: 1.5;
}
a { color: inherit; text-decoration: none; }
::selection { background: rgba(56, 189, 248, .30); }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 20px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-mute); }

/* ---------- Login ---------- */
.login-overlay {
  position: fixed; inset: 0; z-index: 100;
  display: flex; align-items: center; justify-content: center;
  background:
    radial-gradient(700px 480px at 50% 8%, rgba(99, 102, 241, .18), transparent 60%),
    var(--bg);
}
.login-card {
  width: min(400px, 92vw);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  box-shadow: var(--shadow);
  padding: 38px 34px;
  animation: pop .4s cubic-bezier(.2, .8, .2, 1);
}
.login-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 22px; }
.login-brand .logo { width: 44px; height: 44px; }
.login-brand h1 { font-size: 19px; margin: 0; letter-spacing: .2px; }
.login-brand p { margin: 2px 0 0; font-size: 12.5px; color: var(--text-mute); }
.login-card label { display: block; font-size: 12.5px; color: var(--text-dim); margin: 14px 0 7px; font-weight: 600; }
.field { position: relative; }
.login-card input {
  width: 100%; padding: 13px 15px; font-size: 15px;
  background: var(--surface-2); border: 1px solid var(--border-strong);
  border-radius: 12px; color: var(--text); outline: none; transition: .18s;
}
.login-card input:focus { border-color: var(--accent); box-shadow: 0 0 0 4px rgba(56, 189, 248, .15); }
.login-error { color: var(--danger); font-size: 13px; margin-top: 12px; min-height: 18px; }

/* ---------- Botões ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 16px; font-size: 13.5px; font-weight: 600; font-family: var(--font);
  border: 1px solid var(--border-strong); border-radius: 11px;
  background: var(--surface-2); color: var(--text); cursor: pointer;
  transition: .16s; white-space: nowrap; user-select: none;
}
.btn:hover { background: var(--surface-hover); border-color: var(--accent); transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn.primary { background: var(--accent-grad); border: none; color: #04121f; box-shadow: 0 8px 22px rgba(56, 137, 248, .35); }
.btn.primary:hover { filter: brightness(1.06); }
.btn.ghost { background: transparent; }
.btn.sm { padding: 7px 12px; font-size: 12.5px; border-radius: 9px; }
.btn.ok { color: var(--ok); border-color: rgba(52, 211, 153, .4); }
.btn.ok:hover { background: rgba(52, 211, 153, .12); }
.btn.danger { color: var(--danger); border-color: rgba(251, 113, 133, .4); }
.btn.danger:hover { background: rgba(251, 113, 133, .12); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.icon-btn {
  display: inline-grid; place-items: center; width: 40px; height: 40px;
  border-radius: 11px; border: 1px solid var(--border-strong); background: var(--surface-2);
  color: var(--text-dim); cursor: pointer; transition: .16s;
}
.icon-btn:hover { color: var(--text); border-color: var(--accent); background: var(--surface-hover); }

/* ---------- Shell ---------- */
.app-shell { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; }
.app-shell[hidden] { display: none; }

.sidebar {
  position: sticky; top: 0; height: 100vh;
  background: linear-gradient(180deg, var(--panel), rgba(8, 11, 20, .6));
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column; padding: 20px 14px; gap: 6px; z-index: 20;
}
.brand { display: flex; align-items: center; gap: 11px; padding: 6px 8px 18px; }
.brand .logo { width: 38px; height: 38px; flex: none; }
.brand .txt strong { font-size: 15.5px; letter-spacing: .2px; display: block; }
.brand .txt span { font-size: 11px; color: var(--text-mute); letter-spacing: .3px; }
.nav-label { font-size: 10.5px; letter-spacing: 1.2px; text-transform: uppercase; color: var(--text-mute); padding: 14px 12px 6px; font-weight: 700; }
.nav-item {
  display: flex; align-items: center; gap: 12px; padding: 11px 12px;
  border-radius: 11px; color: var(--text-dim); font-size: 14px; font-weight: 500;
  cursor: pointer; transition: .15s; position: relative;
}
.nav-item svg { width: 19px; height: 19px; flex: none; }
.nav-item:hover { background: var(--surface); color: var(--text); }
.nav-item.active { background: var(--surface-2); color: var(--text); }
.nav-item.active::before {
  content: ""; position: absolute; left: -14px; top: 50%; transform: translateY(-50%);
  width: 4px; height: 22px; border-radius: 0 4px 4px 0; background: var(--accent-grad);
}
.nav-item .count { margin-left: auto; font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 20px; background: var(--surface-hover); color: var(--text-dim); }
.nav-item .count.alert { background: rgba(251, 113, 133, .18); color: var(--danger); }
.sidebar-foot { margin-top: auto; padding-top: 14px; border-top: 1px solid var(--border); }
.user-chip { display: flex; align-items: center; gap: 10px; padding: 8px 10px; font-size: 13px; color: var(--text-dim); }
.user-chip .av { width: 32px; height: 32px; border-radius: 9px; background: var(--accent-grad); display: grid; place-items: center; color: #04121f; font-weight: 800; font-size: 13px; }

/* ---------- Topbar ---------- */
.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 15;
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  padding: 16px 26px; background: rgba(8, 11, 20, .72);
  backdrop-filter: blur(14px); border-bottom: 1px solid var(--border);
}
:root[data-theme="light"] .topbar { background: rgba(255, 255, 255, .78); }
.topbar .page-title { font-size: 20px; font-weight: 700; letter-spacing: .2px; }
.topbar .page-sub { font-size: 12.5px; color: var(--text-mute); margin-top: 1px; }
.topbar .spacer { flex: 1 1 auto; }
.live { display: inline-flex; align-items: center; gap: 7px; font-size: 12px; color: var(--ok); font-weight: 600; padding: 6px 11px; border: 1px solid rgba(52, 211, 153, .3); border-radius: 20px; }
.live .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 0 rgba(52, 211, 153, .6); animation: pulse 1.8s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(52, 211, 153, .55); } 70% { box-shadow: 0 0 0 8px rgba(52, 211, 153, 0); } 100% { box-shadow: 0 0 0 0 rgba(52, 211, 153, 0); } }

/* ---------- Filtros ---------- */
.filter-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 20px; }
.select, .input {
  padding: 9px 13px; font-size: 13.5px; font-family: var(--font);
  background: var(--surface-2); border: 1px solid var(--border-strong);
  border-radius: 10px; color: var(--text); outline: none; transition: .15s; max-width: 100%;
}
.select { padding-right: 30px; appearance: none; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%239aa8c7' stroke-width='2.5'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center; }
.input:focus, .select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(56, 189, 248, .13); }
.search { position: relative; }
.search svg { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--text-mute); pointer-events: none; }
.search .input { padding-left: 34px; min-width: 220px; }
.seg { display: inline-flex; background: var(--surface-2); border: 1px solid var(--border-strong); border-radius: 10px; padding: 3px; gap: 2px; }
.seg button { border: none; background: transparent; color: var(--text-dim); font: 600 12.5px var(--font); padding: 6px 12px; border-radius: 8px; cursor: pointer; transition: .14s; }
.seg button.active { background: var(--accent-grad); color: #04121f; }
.filter-spacer { flex: 1 1 auto; }

/* ---------- Conteúdo / grids ---------- */
.content { padding: 22px 26px 40px; }
.page { animation: fade .35s ease; }
.grid { display: grid; gap: 16px; }
.kpi-grid { grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); margin-bottom: 20px; }
.cols-2 { grid-template-columns: repeat(2, 1fr); }
.cols-3 { grid-template-columns: repeat(3, 1fr); }
@media (max-width: 1100px) { .cols-2, .cols-3 { grid-template-columns: 1fr; } }

/* ---------- KPI cards (clicáveis) ---------- */
.kpi {
  position: relative; overflow: hidden;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px 18px 16px; cursor: pointer;
  transition: .18s; box-shadow: var(--shadow-sm);
}
.kpi:hover { transform: translateY(-3px); border-color: var(--border-strong); box-shadow: var(--shadow); }
.kpi::after { content: ""; position: absolute; right: -30px; top: -30px; width: 120px; height: 120px; border-radius: 50%; background: var(--accent); opacity: .06; transition: .2s; }
.kpi:hover::after { opacity: .12; transform: scale(1.15); }
.kpi .k-top { display: flex; align-items: center; justify-content: space-between; }
.kpi .k-ico { width: 40px; height: 40px; border-radius: 11px; display: grid; place-items: center; background: var(--surface-2); }
.kpi .k-ico svg { width: 20px; height: 20px; }
.kpi .k-arrow { color: var(--text-mute); opacity: 0; transition: .18s; }
.kpi:hover .k-arrow { opacity: 1; transform: translateX(2px); }
.kpi .k-val { font-size: 30px; font-weight: 800; letter-spacing: -.5px; margin-top: 12px; font-variant-numeric: tabular-nums; }
.kpi .k-lbl { font-size: 12.5px; color: var(--text-dim); margin-top: 2px; font-weight: 500; }
.kpi.accent .k-ico { background: rgba(56, 189, 248, .14); color: var(--accent); }
.kpi.violet .k-ico { background: rgba(129, 140, 248, .16); color: var(--info); }
.kpi.ok .k-ico { background: rgba(52, 211, 153, .14); color: var(--ok); }
.kpi.warn .k-ico { background: rgba(251, 191, 36, .14); color: var(--warn); }
.kpi.warn.pulse { border-color: rgba(251, 191, 36, .4); }

/* ---------- Panels / charts ---------- */
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow-sm); }
.panel-head { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.panel-head h3 { font-size: 15px; margin: 0; font-weight: 700; }
.panel-head .sub { font-size: 12px; color: var(--text-mute); }
.panel-head .actions { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.chart-wrap { position: relative; height: 300px; }
.chart-wrap.sm { height: 230px; }

/* ---------- Tabela ---------- */
.table-wrap { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface); box-shadow: var(--shadow-sm); }
table.data { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.data thead th {
  position: sticky; top: 0; text-align: left; padding: 13px 16px; font-size: 11.5px;
  letter-spacing: .5px; text-transform: uppercase; color: var(--text-mute); font-weight: 700;
  background: var(--surface-2); border-bottom: 1px solid var(--border); white-space: nowrap;
}
table.data tbody td { padding: 12px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.data tbody tr { transition: background .12s; }
table.data tbody tr:hover { background: var(--surface-2); }
table.data tbody tr:last-child td { border-bottom: none; }
table.data .mono { font-family: var(--mono); font-size: 12.5px; color: var(--text-dim); }
.t-target { display: inline-flex; align-items: center; gap: 8px; max-width: 340px; }
.t-target .fav { width: 22px; height: 22px; border-radius: 6px; display: grid; place-items: center; background: var(--surface-2); color: var(--accent); flex: none; font-size: 11px; }
.t-target .txt { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.clip { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Badges / pills ---------- */
.badge { display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; font-weight: 600; padding: 4px 10px; border-radius: 20px; border: 1px solid transparent; }
.badge .d { width: 6px; height: 6px; border-radius: 50%; }
.badge.approved { color: var(--ok); background: rgba(52, 211, 153, .12); }
.badge.approved .d { background: var(--ok); }
.badge.pending { color: var(--warn); background: rgba(251, 191, 36, .12); }
.badge.pending .d { background: var(--warn); }
.badge.blocked { color: var(--danger); background: rgba(251, 113, 133, .12); }
.badge.blocked .d { background: var(--danger); }
.tag { font-size: 11px; font-weight: 600; padding: 3px 9px; border-radius: 7px; background: var(--surface-2); color: var(--text-dim); }
.tag.site { color: var(--accent); background: rgba(56, 189, 248, .1); }
.tag.file { color: var(--info); background: rgba(129, 140, 248, .12); }

/* ---------- Device cards ---------- */
.dev-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow-sm); transition: .18s; cursor: pointer; }
.dev-card:hover { transform: translateY(-3px); border-color: var(--border-strong); box-shadow: var(--shadow); }
.dev-card .dc-top { display: flex; align-items: center; gap: 12px; }
.dev-card .dc-ico { width: 44px; height: 44px; border-radius: 12px; background: var(--surface-2); display: grid; place-items: center; color: var(--accent); flex: none; }
.dev-card .dc-name { font-weight: 700; font-size: 15px; }
.dev-card .dc-sub { font-size: 12px; color: var(--text-mute); }
.dev-card .dc-stats { display: flex; gap: 18px; margin-top: 16px; }
.dev-card .dc-stat b { font-size: 19px; font-weight: 800; display: block; font-variant-numeric: tabular-nums; }
.dev-card .dc-stat span { font-size: 11px; color: var(--text-mute); }
.dev-card .dc-actions { display: flex; gap: 8px; margin-top: 16px; }

/* ---------- Feed ---------- */
.feed { display: flex; flex-direction: column; }
.feed-item { display: flex; gap: 12px; padding: 11px 4px; border-bottom: 1px solid var(--border); }
.feed-item:last-child { border-bottom: none; }
.feed-item .fi-ico { width: 32px; height: 32px; border-radius: 9px; flex: none; display: grid; place-items: center; background: var(--surface-2); }
.feed-item .fi-main { min-width: 0; flex: 1; }
.feed-item .fi-t { font-size: 13.5px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.feed-item .fi-s { font-size: 12px; color: var(--text-mute); }
.feed-item .fi-time { font-size: 11.5px; color: var(--text-mute); white-space: nowrap; }

/* ---------- Empty / loading ---------- */
.empty { text-align: center; padding: 50px 20px; color: var(--text-mute); }
.empty svg { width: 46px; height: 46px; opacity: .4; margin-bottom: 12px; }
.skeleton { background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-hover) 37%, var(--surface-2) 63%); background-size: 400% 100%; animation: shimmer 1.3s infinite; border-radius: 8px; }
@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: -100% 0; } }
.spinner { width: 18px; height: 18px; border: 2.5px solid var(--border-strong); border-top-color: var(--accent); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Pagination ---------- */
.pager { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 14px; flex-wrap: wrap; }
.pager .info { font-size: 12.5px; color: var(--text-mute); }

/* ---------- Toasts ---------- */
.toast-wrap { position: fixed; top: 18px; right: 18px; z-index: 200; display: flex; flex-direction: column; gap: 10px; max-width: 360px; }
.toast {
  display: flex; align-items: flex-start; gap: 11px; padding: 13px 15px;
  background: var(--surface); border: 1px solid var(--border-strong);
  border-left: 3px solid var(--accent); border-radius: 12px; box-shadow: var(--shadow);
  animation: toastIn .32s cubic-bezier(.2, .9, .2, 1); transition: .3s;
}
.toast.out { opacity: 0; transform: translateX(30px); }
.toast .ic { flex: none; margin-top: 1px; }
.toast .tt { font-weight: 700; font-size: 13.5px; }
.toast .ts { font-size: 12.5px; color: var(--text-dim); margin-top: 1px; }
.toast.ok { border-left-color: var(--ok); }
.toast.ok .ic { color: var(--ok); }
.toast.err { border-left-color: var(--danger); }
.toast.err .ic { color: var(--danger); }
.toast.warn { border-left-color: var(--warn); }
.toast.warn .ic { color: var(--warn); }
.toast.info .ic { color: var(--accent); }
@keyframes toastIn { from { opacity: 0; transform: translateX(40px); } to { opacity: 1; transform: none; } }

/* ---------- Tooltip (balão discreto) ---------- */
#tip {
  position: fixed; z-index: 300; pointer-events: none; opacity: 0; transform: translateY(4px);
  transition: opacity .13s, transform .13s; max-width: 300px;
  background: #05070d; color: #eef3ff; border: 1px solid var(--border-strong);
  padding: 8px 11px; border-radius: 9px; font-size: 12px; line-height: 1.45;
  box-shadow: 0 12px 30px rgba(0, 0, 0, .5);
}
#tip.show { opacity: 1; transform: none; }
#tip .tip-k { color: var(--text-mute); }
#tip b { color: #fff; }

/* ---------- Misc ---------- */
.muted { color: var(--text-mute); }
.dim { color: var(--text-dim); }
.mono { font-family: var(--mono); }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.hint { font-size: 12px; color: var(--text-mute); display: inline-flex; align-items: center; gap: 6px; cursor: help; }
.divider { height: 1px; background: var(--border); margin: 18px 0; }
.stat-inline { display: inline-flex; align-items: baseline; gap: 6px; }
.stat-inline b { font-size: 17px; font-weight: 800; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes pop { from { opacity: 0; transform: scale(.96); } to { opacity: 1; transform: none; } }

.menu-toggle { display: none; }
@media (max-width: 860px) {
  :root { --sidebar-w: 0px; }
  .sidebar { position: fixed; left: 0; top: 0; height: 100vh; transform: translateX(-100%); transition: .25s; box-shadow: var(--shadow); }
  .sidebar.open { transform: none; }
  .app-shell { grid-template-columns: 1fr; }
  .content { padding: 16px; }
  .topbar { padding: 12px 16px; }
  .menu-toggle { display: inline-grid; }
}
