/* ==========================================================================
   Gestão Central · WebNett — painel premium de assinaturas das empresas
   Tema único (dark), paleta validada (ver skill dataviz / references/palette.md)
   ========================================================================== */

:root {
  color-scheme: dark;

  /* superfícies */
  --page-plane:   #0a0b0d;
  --surface-1:    #14161a;
  --surface-2:    #1a1d22;
  --surface-glass: rgba(26, 29, 34, 0.72);
  --border-hair:  rgba(255, 255, 255, 0.08);
  --border-hair-strong: rgba(255, 255, 255, 0.14);

  /* tinta */
  --text-primary:   #f5f6f8;
  --text-secondary: #b7bac2;
  --text-muted:     #7d818c;

  /* categórico (ordem fixa, ver palette.md) */
  --series-1: #3987e5; /* blue   */
  --series-2: #d95926; /* orange */
  --series-3: #199e70; /* aqua   */
  --series-4: #c98500; /* yellow */
  --series-5: #d55181; /* magenta*/
  --series-6: #008300; /* green  */
  --series-7: #9085e9; /* violet */
  --series-8: #e66767; /* red    */

  /* status (fixo, nunca reaproveitado como série) */
  --status-good:     #0ca30c;
  --status-warning:  #fab219;
  --status-serious:  #ec835a;
  --status-critical: #d03b3b;

  --radius-lg: 20px;
  --radius-md: 14px;
  --radius-sm: 10px;
  --shadow-card: 0 1px 0 rgba(255,255,255,0.04) inset, 0 20px 40px -24px rgba(0,0,0,0.6);
}

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

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  background:
    radial-gradient(1100px 600px at 84% -10%, rgba(57,135,229,0.16), transparent 60%),
    radial-gradient(900px 500px at -10% 110%, rgba(144,133,233,0.12), transparent 55%),
    var(--page-plane);
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
}

svg { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* ---------------------------------------------------------------- layout */

.app {
  display: grid;
  grid-template-columns: 264px 1fr;
  min-height: 100vh;
}

.sidebar {
  border-right: 1px solid var(--border-hair);
  background: rgba(15, 16, 19, 0.55);
  backdrop-filter: blur(20px);
  padding: 24px 18px;
  display: flex;
  flex-direction: column;
  gap: 28px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand { display: flex; align-items: center; gap: 12px; padding: 0 6px; }
.brand-mark {
  width: 40px; height: 40px; border-radius: 12px;
  background: linear-gradient(135deg, var(--series-1), var(--series-7));
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 14px; letter-spacing: 0.02em;
  box-shadow: 0 8px 20px -6px rgba(57,135,229,0.5);
}
.brand-text { display: flex; flex-direction: column; line-height: 1.25; }
.brand-text strong { font-size: 14.5px; font-weight: 650; }
.brand-text span { font-size: 12px; color: var(--text-muted); }

.nav { display: flex; flex-direction: column; gap: 4px; }
.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border-radius: var(--radius-sm);
  background: transparent; border: none;
  color: var(--text-secondary); font-size: 14px; font-weight: 500;
  cursor: pointer; text-align: left; width: 100%;
  transition: background 0.15s ease, color 0.15s ease;
}
.nav-item svg { width: 18px; height: 18px; flex: none; opacity: 0.8; }
.nav-item:hover { background: var(--surface-2); color: var(--text-primary); }
.nav-item.is-active {
  background: linear-gradient(135deg, rgba(57,135,229,0.16), rgba(144,133,233,0.10));
  color: var(--text-primary);
  border: 1px solid rgba(57,135,229,0.28);
}
.nav-item.is-active svg { opacity: 1; color: var(--series-1); }

.sidebar-footer { margin-top: auto; display: flex; flex-direction: column; gap: 10px; }
.sync-status { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--text-secondary); padding: 0 6px; }
.sync-status .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--status-good); box-shadow: 0 0 0 3px rgba(12,163,12,0.18); }
.sync-status.is-error .dot { background: var(--status-critical); box-shadow: 0 0 0 3px rgba(208,59,59,0.18); }
.readonly-note { font-size: 11px; color: var(--text-muted); padding: 0 6px; line-height: 1.5; margin: 0; }

.main { display: flex; flex-direction: column; min-width: 0; }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 24px 36px; border-bottom: 1px solid var(--border-hair);
  position: sticky; top: 0; z-index: 5;
  background: rgba(10,11,13,0.72); backdrop-filter: blur(16px);
}
.topbar-title h1 { margin: 0 0 4px; font-size: 21px; font-weight: 650; letter-spacing: -0.01em; }
.topbar-title p { margin: 0; font-size: 13px; color: var(--text-muted); }
.topbar-actions { display: flex; align-items: center; gap: 14px; }

.btn-ghost {
  display: flex; align-items: center; gap: 8px;
  padding: 9px 14px; border-radius: var(--radius-sm);
  background: var(--surface-2); border: 1px solid var(--border-hair-strong);
  color: var(--text-secondary); font-size: 13px; font-weight: 500; cursor: pointer;
  transition: transform 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
.btn-ghost svg { width: 15px; height: 15px; }
.btn-ghost:hover { color: var(--text-primary); border-color: rgba(57,135,229,0.4); }
.btn-ghost.is-spinning svg { animation: spin 0.7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.user-chip {
  display: flex; align-items: center; gap: 10px; padding: 4px 12px 4px 4px; border-radius: 999px;
  background: var(--surface-2); border: 1px solid var(--border-hair); cursor: pointer;
  font-family: inherit; transition: border-color 0.15s ease;
}
.user-chip:hover { border-color: rgba(208,59,59,0.4); }
.user-chip .logout-icon { width: 15px; height: 15px; color: var(--text-muted); margin-left: 2px; }
.user-chip:hover .logout-icon { color: var(--status-critical); }
.user-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: linear-gradient(135deg, var(--series-3), var(--series-1));
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700;
}
.user-meta { display: flex; flex-direction: column; line-height: 1.25; }
.user-meta strong { font-size: 12.5px; font-weight: 600; }
.user-meta span { font-size: 11px; color: var(--text-muted); }

.content { padding: 28px 36px 60px; }

/* ---------------------------------------------------------------- views */
.view { display: none; flex-direction: column; gap: 22px; animation: fadeUp 0.35s ease; }
.view.is-active { display: flex; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }

/* ---------------------------------------------------------------- KPIs */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; }
.kpi-card {
  position: relative; overflow: hidden;
  padding: 20px 20px 18px;
  border-radius: var(--radius-lg);
  background: linear-gradient(160deg, var(--surface-2), var(--surface-1));
  border: 1px solid var(--border-hair);
  box-shadow: var(--shadow-card);
}
.kpi-card::after {
  content: ""; position: absolute; inset: -40% -40% auto auto; width: 140px; height: 140px;
  background: radial-gradient(circle, var(--kpi-glow, rgba(57,135,229,0.25)), transparent 70%);
  pointer-events: none;
}
.kpi-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.kpi-icon {
  width: 36px; height: 36px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  background: var(--kpi-icon-bg, rgba(57,135,229,0.14));
  color: var(--kpi-icon-fg, var(--series-1));
}
.kpi-icon svg { width: 18px; height: 18px; }
.kpi-trend { font-size: 12px; font-weight: 600; padding: 3px 8px; border-radius: 999px; }
.kpi-trend.good { color: var(--status-good); background: rgba(12,163,12,0.14); }
.kpi-trend.warn { color: var(--status-warning); background: rgba(250,178,25,0.14); }
.kpi-trend.bad { color: var(--status-critical); background: rgba(208,59,59,0.14); }
.kpi-value { font-size: 27px; font-weight: 680; letter-spacing: -0.01em; font-variant-numeric: tabular-nums; margin-bottom: 2px; }
.kpi-label { font-size: 12.5px; color: var(--text-muted); }

/* ---------------------------------------------------------------- cards */
.panel-grid { display: grid; grid-template-columns: 1.5fr 1fr; gap: 16px; align-items: stretch; }
.card {
  border-radius: var(--radius-lg);
  background: var(--surface-glass);
  border: 1px solid var(--border-hair);
  box-shadow: var(--shadow-card);
  padding: 22px 22px 8px;
  backdrop-filter: blur(10px);
  display: flex; flex-direction: column;
}
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding-bottom: 16px; }
.card-head h2 { margin: 0 0 3px; font-size: 15px; font-weight: 620; }
.card-head p { margin: 0; font-size: 12.5px; color: var(--text-muted); }
.btn-link { background: none; border: none; color: var(--series-1); font-size: 12.5px; font-weight: 600; cursor: pointer; padding: 4px; white-space: nowrap; }
.btn-link:hover { text-decoration: underline; }

.chart-wrap { flex: 1; min-height: 220px; }

.plan-dist { display: flex; flex-direction: column; gap: 14px; padding-bottom: 14px; }
.plan-dist-row { display: flex; flex-direction: column; gap: 6px; }
.plan-dist-top { display: flex; align-items: center; justify-content: space-between; font-size: 13px; }
.plan-dist-top .name { display: flex; align-items: center; gap: 8px; color: var(--text-secondary); font-weight: 500; }
.plan-dist-top .swatch { width: 9px; height: 9px; border-radius: 3px; }
.plan-dist-top .count { font-variant-numeric: tabular-nums; color: var(--text-primary); font-weight: 620; }
.plan-dist-bar { height: 6px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.plan-dist-bar > span { display: block; height: 100%; border-radius: 999px; }
.empty-state { padding: 32px 12px; text-align: center; color: var(--text-muted); font-size: 13px; }

/* ---------------------------------------------------------------- tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
thead th {
  text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.04em;
  color: var(--text-muted); font-weight: 600; padding: 10px 14px; border-bottom: 1px solid var(--border-hair);
  white-space: nowrap;
}
tbody td { padding: 13px 14px; border-bottom: 1px solid var(--border-hair); color: var(--text-secondary); vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: rgba(255,255,255,0.02); }
td.numeric, th.numeric { text-align: right; font-variant-numeric: tabular-nums; }
.cell-primary { color: var(--text-primary); font-weight: 560; }
.cell-sub { display: block; font-size: 11.5px; color: var(--text-muted); margin-top: 2px; font-weight: 400; }

.avatar-chip { display: flex; align-items: center; gap: 10px; }
.avatar-chip .initials {
  width: 32px; height: 32px; border-radius: 9px; flex: none;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; color: #fff;
  background: linear-gradient(135deg, var(--avatar-a, var(--series-1)), var(--avatar-b, var(--series-7)));
}

.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px; border-radius: 999px; font-size: 11.5px; font-weight: 640;
  white-space: nowrap;
}
.badge .dot { width: 6px; height: 6px; border-radius: 50%; }
.badge.status-ok { color: var(--status-good); background: rgba(12,163,12,0.13); }
.badge.status-ok .dot { background: var(--status-good); }
.badge.status-warn { color: var(--status-warning); background: rgba(250,178,25,0.15); }
.badge.status-warn .dot { background: var(--status-warning); }
.badge.status-bad { color: var(--status-critical); background: rgba(208,59,59,0.15); }
.badge.status-bad .dot { background: var(--status-critical); }
.badge.status-muted { color: var(--text-muted); background: rgba(255,255,255,0.06); }
.badge.status-muted .dot { background: var(--text-muted); }

/* -------------------------------------------------------------- search / filters */
.search-box { display: flex; align-items: center; gap: 8px; background: var(--surface-2); border: 1px solid var(--border-hair); border-radius: var(--radius-sm); padding: 8px 12px; min-width: 240px; }
.search-box svg { width: 15px; height: 15px; color: var(--text-muted); flex: none; }
.search-box input { background: none; border: none; outline: none; color: var(--text-primary); font-size: 13px; width: 100%; }
.search-box input::placeholder { color: var(--text-muted); }

.filter-pills { display: flex; gap: 6px; flex-wrap: wrap; }
.pill {
  padding: 7px 13px; border-radius: 999px; font-size: 12.5px; font-weight: 560;
  background: var(--surface-2); border: 1px solid var(--border-hair); color: var(--text-secondary);
  cursor: pointer; transition: all 0.15s ease;
}
.pill:hover { color: var(--text-primary); }
.pill.is-active { background: linear-gradient(135deg, rgba(57,135,229,0.22), rgba(144,133,233,0.14)); border-color: rgba(57,135,229,0.4); color: var(--text-primary); }

/* -------------------------------------------------------------- plans grid */
.plans-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 16px; }
.plan-card {
  border-radius: var(--radius-lg); padding: 24px 22px; position: relative; overflow: hidden;
  background: var(--surface-glass); border: 1px solid var(--border-hair); box-shadow: var(--shadow-card);
}
.plan-card::before {
  content: ""; position: absolute; top: -60%; right: -30%; width: 220px; height: 220px; border-radius: 50%;
  background: radial-gradient(circle, var(--plan-glow), transparent 70%); pointer-events: none;
}
.plan-card h3 { margin: 0 0 6px; font-size: 15.5px; font-weight: 640; }
.plan-price { font-size: 30px; font-weight: 700; letter-spacing: -0.01em; margin: 10px 0 4px; font-variant-numeric: tabular-nums; }
.plan-price span { font-size: 13px; font-weight: 500; color: var(--text-muted); }
.plan-meta { display: flex; flex-direction: column; gap: 8px; margin-top: 16px; font-size: 12.5px; color: var(--text-secondary); }
.plan-meta li { list-style: none; display: flex; align-items: center; gap: 8px; }
.plan-meta li svg { width: 14px; height: 14px; color: var(--status-good); flex: none; }
.plan-companies { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--border-hair); font-size: 12px; color: var(--text-muted); }
.plan-companies strong { color: var(--text-primary); font-weight: 650; }

/* -------------------------------------------------------------- chart (svg) */
.svg-chart text { fill: var(--text-muted); font-size: 10.5px; font-family: inherit; }
.svg-chart .bar { rx: 4; }
.svg-chart .gridline { stroke: var(--border-hair); stroke-width: 1; }
.svg-chart .axis { stroke: var(--border-hair-strong); }
.chart-tooltip {
  position: absolute; pointer-events: none; background: var(--surface-2); border: 1px solid var(--border-hair-strong);
  border-radius: 8px; padding: 7px 10px; font-size: 12px; color: var(--text-primary); box-shadow: 0 8px 20px rgba(0,0,0,0.4);
  transform: translate(-50%, -110%); opacity: 0; transition: opacity 0.1s ease; white-space: nowrap; z-index: 10;
}

/* -------------------------------------------------------------- responsive */
@media (max-width: 1100px) {
  .panel-grid { grid-template-columns: 1fr; }
}
@media (max-width: 880px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: row; align-items: center; padding: 14px 18px; overflow-x: auto; }
  .nav { flex-direction: row; }
  .sidebar-footer { display: none; }
  .topbar { padding: 18px 20px; flex-wrap: wrap; gap: 12px; }
  .content { padding: 20px; }
}
