/* ==========================================================================
   PDV Updater — Design System (protótipo visual)
   Tema: tecnológico, denso, escuro por padrão, com acento laranja VR.
   Sem dependências externas (sem CDN de fontes/ícones) — fonte de sistema.
   ========================================================================== */

:root {
  /* ---- paleta base (modo escuro = padrão) ---- */
  --bg: #0a0d14;
  --bg-elevated: #10141d;
  --surface: #141925;
  --surface-2: #1a2030;
  --border: rgba(255, 255, 255, 0.07);
  --border-strong: rgba(255, 255, 255, 0.14);

  --text: #e8eaf0;
  --text-dim: #8b93a7;
  --text-faint: #5b6478;

  /* ---- acentos ---- */
  --orange: #ff7a1a;
  --orange-dim: #ff7a1a22;
  --orange-glow: #ff7a1a55;
  --cyan: #34d6e0;
  --cyan-dim: #34d6e022;

  --green: #2bd576;
  --green-dim: #2bd57618;
  --amber: #f5b94d;
  --amber-dim: #f5b94d18;
  --red: #ff5c72;
  --red-dim: #ff5c7218;

  /* ---- tipografia ---- */
  --font-ui: -apple-system, "Segoe UI", "Inter", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: ui-monospace, "Cascadia Mono", "SF Mono", Consolas, monospace;

  --radius: 10px;
  --radius-sm: 7px;
  --shadow-soft: 0 8px 24px rgba(0, 0, 0, 0.35);
}

[data-theme="light"] {
  --bg: #f4f5f8;
  --bg-elevated: #ffffff;
  --surface: #ffffff;
  --surface-2: #eef0f5;
  --border: rgba(15, 23, 42, 0.09);
  --border-strong: rgba(15, 23, 42, 0.16);
  --text: #161a23;
  --text-dim: #5b6478;
  --text-faint: #95a0b5;
  --orange-dim: #ff7a1a14;
  --shadow-soft: 0 8px 24px rgba(20, 25, 40, 0.08);
}

* { box-sizing: border-box; }
html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

/* leve textura tecnológica no fundo: grade pontilhada muito sutil */
body.app-bg {
  background-image:
    radial-gradient(circle at 1px 1px, rgba(255,255,255,0.035) 1px, transparent 0);
  background-size: 28px 28px;
}
[data-theme="light"] body.app-bg {
  background-image:
    radial-gradient(circle at 1px 1px, rgba(15,23,42,0.05) 1px, transparent 0);
}

a { color: inherit; text-decoration: none; }
code, .mono { font-family: var(--font-mono); }

/* ---------------------------------------------------------------- layout */
.shell {
  display: grid;
  grid-template-columns: 248px 1fr;
  min-height: 100vh;
}
.shell.collapsed { grid-template-columns: 72px 1fr; }

/* ---------------------------------------------------------------- sidebar */
.sidebar {
  background: var(--bg-elevated);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 18px 12px;
  position: sticky;
  top: 0;
  height: 100vh;
}
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 8px 22px;
}
.brand-mark {
  width: 30px; height: 30px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--orange), #ff9a4d);
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; color: #1a0f00; font-size: 14px;
  box-shadow: 0 0 0 1px var(--orange-glow), 0 4px 14px var(--orange-dim);
  flex-shrink: 0;
}
.brand-name { font-weight: 650; letter-spacing: .2px; font-size: 14.5px; white-space: nowrap; }
.brand-name span { color: var(--orange); }
.shell.collapsed .brand-name, .shell.collapsed .nav-label,
.shell.collapsed .nav-section-title, .shell.collapsed .ctx-text,
.shell.collapsed .sidebar-foot-text { display: none; }

.nav-section { margin-top: 14px; }
.nav-section-title {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: .08em;
  color: var(--text-faint); padding: 0 10px; margin-bottom: 6px; font-weight: 650;
}
.nav-item {
  display: flex; align-items: center; gap: 11px;
  padding: 8px 10px; border-radius: var(--radius-sm);
  color: var(--text-dim); font-size: 13.3px; font-weight: 500;
  cursor: pointer; position: relative; white-space: nowrap;
  transition: background .15s ease, color .15s ease;
}
.nav-item svg { width: 17px; height: 17px; flex-shrink: 0; opacity: .85; }
.nav-item:hover { background: var(--surface); color: var(--text); }
.nav-item.active {
  background: var(--orange-dim); color: #fff;
}
.nav-item.active svg { opacity: 1; color: var(--orange); }
.nav-item.active::before {
  content: ""; position: absolute; left: -12px; top: 6px; bottom: 6px; width: 3px;
  background: var(--orange); border-radius: 0 4px 4px 0;
}
.nav-badge {
  margin-left: auto; font-size: 10.5px; font-weight: 700;
  background: var(--surface-2); color: var(--text-dim);
  padding: 1px 7px; border-radius: 99px; font-family: var(--font-mono);
}

.sidebar-foot {
  margin-top: auto; padding-top: 14px; border-top: 1px solid var(--border);
  display: flex; align-items: center; gap: 10px; padding: 10px 8px 4px;
}
.avatar {
  width: 30px; height: 30px; border-radius: 8px; flex-shrink: 0;
  background: var(--surface-2); color: var(--cyan);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 12.5px; border: 1px solid var(--border-strong);
}
.sidebar-foot-text { line-height: 1.25; overflow: hidden; }
.sidebar-foot-text .name { font-size: 12.8px; font-weight: 600; }
.sidebar-foot-text .role { font-size: 11px; color: var(--text-faint); }

.collapse-btn {
  width: 26px; height: 26px; border-radius: 7px; border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text-dim); cursor: pointer;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}

/* ---------------------------------------------------------------- topbar */
.main { display: flex; flex-direction: column; min-height: 100vh; }
.topbar {
  height: 60px; flex-shrink: 0;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 16px;
  padding: 0 24px; position: sticky; top: 0;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(8px);
  z-index: 5;
}
.crumbs { font-size: 12.5px; color: var(--text-faint); display: flex; align-items: center; gap: 6px; }
.crumbs b { color: var(--text); font-weight: 600; }

.ctx-switch {
  display: flex; align-items: center; gap: 8px;
  background: var(--surface); border: 1px solid var(--border-strong);
  padding: 6px 10px; border-radius: 99px; font-size: 12.5px; cursor: pointer;
}
.ctx-dot { width: 7px; height: 7px; border-radius: 99px; background: var(--green); box-shadow: 0 0 0 3px var(--green-dim); }
.ctx-text b { font-weight: 650; }
.ctx-text .sep { color: var(--text-faint); margin: 0 4px; }

.searchbar {
  flex: 1; max-width: 420px; margin: 0 auto;
  display: flex; align-items: center; gap: 8px;
  background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm); padding: 7px 10px; color: var(--text-faint);
  font-size: 12.8px;
}
.searchbar kbd {
  margin-left: auto; font-family: var(--font-mono); font-size: 10.5px;
  background: var(--surface-2); border: 1px solid var(--border-strong);
  padding: 1px 6px; border-radius: 5px; color: var(--text-faint);
}

.icon-btn {
  width: 34px; height: 34px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong); background: var(--surface);
  color: var(--text-dim); display: flex; align-items: center; justify-content: center;
  cursor: pointer; flex-shrink: 0;
}
.icon-btn:hover { color: var(--text); border-color: var(--text-faint); }

.topbar-right { display: flex; align-items: center; gap: 10px; margin-left: auto; }

/* ---------------------------------------------------------------- content */
.content { padding: 28px 32px 60px; max-width: 1400px; width: 100%; }
.page-head {
  display: flex; align-items: flex-end; justify-content: space-between;
  margin-bottom: 22px; gap: 16px; flex-wrap: wrap;
}
.page-title { font-size: 22px; font-weight: 700; letter-spacing: -.2px; }
.page-sub { color: var(--text-faint); font-size: 13px; margin-top: 4px; }

.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 9px 15px; border-radius: var(--radius-sm); font-size: 13px; font-weight: 600;
  border: 1px solid transparent; cursor: pointer; white-space: nowrap;
}
.btn svg { width: 15px; height: 15px; }
.btn-primary { background: var(--orange); color: #1a0f00; box-shadow: 0 4px 16px var(--orange-dim); }
.btn-primary:hover { background: #ff8830; }
.btn-ghost { background: var(--surface); border-color: var(--border-strong); color: var(--text); }
.btn-ghost:hover { border-color: var(--text-faint); }
.btn-sm { padding: 6px 11px; font-size: 12px; }

/* ---------------------------------------------------------------- cards */
.grid { display: grid; gap: 16px; }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-2 { grid-template-columns: repeat(2, 1fr); }

.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px;
}
.card-hover { transition: border-color .15s ease, transform .15s ease; cursor: pointer; }
.card-hover:hover { border-color: var(--border-strong); transform: translateY(-1px); }

.kpi-label { font-size: 12px; color: var(--text-faint); font-weight: 600; display: flex; align-items: center; gap: 7px; }
.kpi-value { font-family: var(--font-mono); font-size: 30px; font-weight: 700; margin-top: 10px; letter-spacing: -.5px; }
.kpi-trend { font-size: 11.5px; margin-top: 6px; display: flex; align-items: center; gap: 5px; }
.kpi-trend.up { color: var(--green); }
.kpi-trend.down { color: var(--red); }

/* ---------------------------------------------------------------- rede card (unidade > redes) */
.rede-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px;
  display: flex; flex-direction: column; gap: 14px;
  transition: border-color .15s ease, transform .15s ease;
  position: relative; overflow: hidden;
}
.rede-card:hover { border-color: var(--orange-glow); transform: translateY(-2px); }
.rede-card::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(120px 80px at 100% 0%, var(--orange-dim), transparent 70%);
  opacity: 0; transition: opacity .2s ease;
}
.rede-card:hover::after { opacity: 1; }
.rede-card-head { display: flex; align-items: center; justify-content: space-between; }
.rede-icon {
  width: 38px; height: 38px; border-radius: 9px; background: var(--surface-2);
  display: flex; align-items: center; justify-content: center; font-weight: 700; color: var(--orange);
  border: 1px solid var(--border-strong); font-size: 14px;
}
.rede-name { font-weight: 650; font-size: 15px; }
.rede-unidade { font-size: 11.5px; color: var(--text-faint); margin-top: 2px; }
.rede-stats { display: flex; gap: 18px; }
.rede-stat { font-size: 12px; color: var(--text-dim); }
.rede-stat b { font-family: var(--font-mono); color: var(--text); display: block; font-size: 16px; }
.rede-status { display: flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; }

/* ---------------------------------------------------------------- badges */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11px; font-weight: 650; padding: 3px 9px; border-radius: 99px;
}
.badge-dot { width: 6px; height: 6px; border-radius: 99px; }
.badge-green { background: var(--green-dim); color: var(--green); }
.badge-green .badge-dot { background: var(--green); box-shadow: 0 0 0 2px var(--green-dim); }
.badge-amber { background: var(--amber-dim); color: var(--amber); }
.badge-amber .badge-dot { background: var(--amber); box-shadow: 0 0 0 2px var(--amber-dim); }
.badge-red { background: var(--red-dim); color: var(--red); }
.badge-red .badge-dot { background: var(--red); box-shadow: 0 0 0 2px var(--red-dim); }
.badge-gray { background: var(--surface-2); color: var(--text-faint); }

/* ---------------------------------------------------------------- filtros */
.filterbar {
  display: flex; gap: 10px; flex-wrap: wrap; align-items: end;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px; margin-bottom: 18px;
}
.field { display: flex; flex-direction: column; gap: 6px; min-width: 160px; flex: 1; }
.field label { font-size: 11px; color: var(--text-faint); font-weight: 650; text-transform: uppercase; letter-spacing: .04em; }
.field input, .field select {
  background: var(--bg-elevated); border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm); padding: 8px 10px; color: var(--text); font-size: 13px;
  font-family: var(--font-ui);
}
.field input:focus, .field select:focus { outline: none; border-color: var(--orange); }

/* ---------------------------------------------------------------- tabela */
.table-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead th {
  text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .05em;
  color: var(--text-faint); font-weight: 650; padding: 11px 16px;
  border-bottom: 1px solid var(--border); background: var(--bg-elevated);
}
tbody td { padding: 12px 16px; border-bottom: 1px solid var(--border); color: var(--text-dim); }
tbody tr:last-child td { border-bottom: none; }
tbody tr { transition: background .12s ease; }
tbody tr:hover { background: var(--surface-2); }
tbody td.strong { color: var(--text); font-weight: 600; }
.row-accent { border-left: 2px solid transparent; }
.row-accent.ok { border-left-color: var(--green); }
.row-accent.warn { border-left-color: var(--amber); }
.row-accent.err { border-left-color: var(--red); }

/* ---------------------------------------------------------------- misc */
.health-bar-wrap { width: 60px; height: 5px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.health-bar { height: 100%; border-radius: 99px; }
.divider { height: 1px; background: var(--border); margin: 24px 0; }

.skeleton {
  background: linear-gradient(90deg, var(--surface) 25%, var(--surface-2) 37%, var(--surface) 63%);
  background-size: 400% 100%; animation: shimmer 1.4s ease infinite; border-radius: 6px;
}
@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: -100% 0; } }
