/* Painel RPT — Design System v2 (NOC Command Studio)
   Identidade visual: Laranja Sinal RPT + Cobalto RPT sobre grafite tecnico / papel claro */

@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;500;600&family=Plus+Jakarta+Sans:wght@400;500;600;700&family=Space+Grotesk:wght@600;700&display=swap');

*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  color-scheme: dark;
  --font-display: 'Space Grotesk', system-ui, -apple-system, sans-serif;
  --font-sans: 'Plus Jakarta Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, 'Cascadia Code', Consolas, monospace;

  --radius-sm: 4px;
  --radius: 6px;
  --radius-lg: 8px;

  /* Dark Theme — Obsidian Carbon (default) */
  --bg: #0B0E14;
  --bg-grid: rgba(148, 163, 184, 0.035);
  --surface: #121720;
  --surface-2: #181F2B;
  --surface-hover: #202938;
  --bg-hover: #181F2B;
  --topbar-bg: rgba(18, 23, 32, 0.94);

  --border: #253042;
  --border-strong: #37465E;

  --text: #F1F5F9;
  --text-2: #CBD5E1;
  --muted: #94A3B8;

  /* RPT Signal Orange + Cobalt */
  --accent: #F97316;
  --accent-hover: #FB923C;
  --accent-ink: #0B0E14;
  --accent-text: #FB923C;
  --accent-soft: rgba(249, 115, 22, 0.13);
  --accent-border: rgba(249, 115, 22, 0.35);

  --cobalt: #3B82F6;
  --cobalt-text: #60A5FA;
  --cobalt-soft: rgba(59, 130, 246, 0.14);
  --cobalt-border: rgba(59, 130, 246, 0.32);

  /* Status tokens */
  --green: #10B981;
  --green-soft: rgba(16, 185, 129, 0.13);
  --green-border: rgba(16, 185, 129, 0.32);
  --amber: #F59E0B;
  --yellow: #FBBF24;
  --yellow-soft: rgba(245, 158, 11, 0.13);
  --yellow-border: rgba(245, 158, 11, 0.34);
  --orange: #F97316;
  --orange-soft: rgba(249, 115, 22, 0.14);
  --orange-border: rgba(249, 115, 22, 0.35);
  --red: #F43F5E;
  --red-soft: rgba(244, 63, 94, 0.13);
  --red-border: rgba(244, 63, 94, 0.34);

  --card-shadow: 0 1px 2px rgba(0, 0, 0, 0.35), 0 8px 24px -12px rgba(0, 0, 0, 0.55);
  --modal-shadow: 0 24px 64px rgba(0, 0, 0, 0.65);
  --code-bg: #080B10;
  --code-text: #E2E8F0;
}

body.theme-medium {
  color-scheme: dark;
  --bg: #17202D;
  --bg-grid: rgba(148, 163, 184, 0.045);
  --surface: #1E293B;
  --surface-2: #263347;
  --surface-hover: #2F3E56;
  --bg-hover: #263347;
  --topbar-bg: rgba(30, 41, 59, 0.94);

  --border: #33435B;
  --border-strong: #475D7D;

  --text: #F8FAFC;
  --text-2: #E2E8F0;
  --muted: #A3B3C6;

  --accent: #F97316;
  --accent-hover: #FB923C;
  --accent-ink: #0B0E14;
  --accent-text: #FDBA74;
  --accent-soft: rgba(249, 115, 22, 0.16);
  --accent-border: rgba(251, 146, 60, 0.4);

  --card-shadow: 0 1px 3px rgba(0, 0, 0, 0.28), 0 10px 24px -14px rgba(0, 0, 0, 0.45);
  --code-bg: #111926;
  --code-text: #E2E8F0;
}

body.theme-light {
  color-scheme: light;
  --bg: #F2F4F7;
  --bg-grid: rgba(15, 23, 42, 0.04);
  --surface: #FFFFFF;
  --surface-2: #E9EDF3;
  --surface-hover: #DFE5EE;
  --bg-hover: #F6F8FB;
  --topbar-bg: rgba(255, 255, 255, 0.96);

  --border: #D2D9E4;
  --border-strong: #AEB9CB;

  --text: #0F172A;
  --text-2: #1E293B;
  --muted: #475569;

  /* Burnt Copper-Orange for WCAG AA >= 5.1:1 on white/stone surfaces */
  --accent: #C2410C;
  --accent-hover: #9A3412;
  --accent-ink: #FFFFFF;
  --accent-text: #B43403;
  --accent-soft: rgba(194, 65, 12, 0.10);
  --accent-border: rgba(194, 65, 12, 0.30);

  --cobalt: #1D4ED8;
  --cobalt-text: #1E40AF;
  --cobalt-soft: rgba(29, 78, 216, 0.09);
  --cobalt-border: rgba(29, 78, 216, 0.25);

  --green: #047857;
  --green-soft: rgba(4, 120, 87, 0.10);
  --green-border: rgba(4, 120, 87, 0.28);
  --amber: #B45309;
  --yellow: #A16207;
  --yellow-soft: rgba(180, 83, 9, 0.10);
  --yellow-border: rgba(180, 83, 9, 0.28);
  --orange: #C2410C;
  --orange-soft: rgba(194, 65, 12, 0.10);
  --orange-border: rgba(194, 65, 12, 0.30);
  --red: #DC2626;
  --red-soft: rgba(220, 38, 38, 0.09);
  --red-border: rgba(220, 38, 38, 0.28);

  --card-shadow: 0 1px 2px rgba(15, 23, 42, 0.05), 0 4px 14px -6px rgba(15, 23, 42, 0.08);
  --modal-shadow: 0 20px 50px rgba(15, 23, 42, 0.20);
  --code-bg: #0F172A;
  --code-text: #F1F5F9;
}

/* Base & Scrollbars */
html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

body.app-shell {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

a {
  color: var(--accent-text);
}

button, input, select, textarea {
  font-family: inherit;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--accent);
}

/* ── SVG Icons ──────────────────────────────────────────── */
.svg-ico {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  display: inline-block;
  vertical-align: middle;
}
.svg-ico-sm {
  width: 14px;
  height: 14px;
}
.svg-ico-lg {
  width: 22px;
  height: 22px;
}
.spin {
  animation: rptSpin 0.9s linear infinite;
}

/* ── Sidebar ────────────────────────────────────────────── */
#sidebar {
  width: 252px;
  min-width: 252px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 120;
  transition: transform 0.24s cubic-bezier(0.16, 1, 0.3, 1);
}

.sidebar-header {
  padding: 16px 16px 14px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: 0;
  text-decoration: none;
  color: inherit;
}

/* Logo RPT limpa sem caixa branca opaca */
.sidebar-logo {
  height: 38px;
  width: auto;
  display: block;
  flex-shrink: 0;
  object-fit: contain;
}

.brand-meta {
  min-width: 0;
}

.brand-meta h1, .brand-meta h2 {
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
  line-height: 1.15;
  display: flex;
  align-items: center;
  gap: 6px;
}

.brand-meta p {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--muted);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-close-btn {
  display: none;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-2);
  width: 32px;
  height: 32px;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

nav#nav {
  flex: 1;
  padding: 10px 10px 16px;
  overflow-y: auto;
}

.nav-head {
  font-size: 0.67rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  padding: 14px 10px 5px;
  user-select: none;
}
.nav-head:first-child {
  padding-top: 4px;
}

.nav-item {
  width: 100%;
  background: transparent;
  border: 1px solid transparent;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  cursor: pointer;
  border-radius: var(--radius-sm);
  font-size: 0.86rem;
  font-weight: 500;
  color: var(--muted);
  text-align: left;
  text-decoration: none;
  transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
  margin-bottom: 2px;
}

.nav-item:hover {
  background: var(--surface-2);
  color: var(--text);
}

.nav-item.active {
  background: var(--accent-soft);
  color: var(--accent-text);
  font-weight: 600;
  border-color: var(--accent-border);
  box-shadow: inset 3px 0 0 var(--accent);
}

.nav-item .ico {
  width: 18px;
  height: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  opacity: 0.85;
}

.nav-item.active .ico {
  opacity: 1;
  color: var(--accent-text);
}

.sidebar-footer {
  padding: 12px 14px;
  border-top: 1px solid var(--border);
  background: var(--surface-2);
}

.user-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.avatar {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: var(--accent-ink);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-size: 0.9rem;
  font-weight: 700;
  flex-shrink: 0;
}

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

.user-info span {
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-info small {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.logout-btn {
  margin-left: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--muted);
  cursor: pointer;
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
  flex-shrink: 0;
}

.logout-btn:hover {
  color: var(--red);
  background: var(--red-soft);
  border-color: var(--red-border);
}

#sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(5, 8, 14, 0.65);
  z-index: 110;
}
#sidebar-backdrop.show {
  display: block;
}

/* ── Main & Topbar ──────────────────────────────────────── */
#main {
  flex: 1;
  min-width: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}

#topbar {
  padding: 12px 28px;
  min-height: 58px;
  border-bottom: 1px solid var(--border);
  background: var(--topbar-bg);
  display: flex;
  align-items: center;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 90;
}

.menu-btn {
  display: none;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  width: 36px;
  height: 36px;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
}

.topbar-title-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

#topbar h2 {
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.noc-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-mono);
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--green);
  background: var(--green-soft);
  border: 1px solid var(--green-border);
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  flex-shrink: 0;
}

.noc-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--green);
}

.theme-selector {
  margin-left: auto;
  display: inline-flex;
  gap: 3px;
  background: var(--surface-2);
  padding: 3px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  flex-shrink: 0;
}

.theme-btn {
  background: transparent;
  border: 1px solid transparent;
  color: var(--muted);
  cursor: pointer;
  padding: 5px 10px;
  border-radius: var(--radius-sm);
  font-size: 0.76rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: all 0.15s ease;
}

.theme-btn:hover {
  color: var(--text);
}

.theme-btn.active {
  background: var(--surface);
  color: var(--accent-text);
  border-color: var(--border);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.14);
}

#content {
  flex: 1;
  padding: 24px 28px 36px;
  width: 100%;
  max-width: 1480px;
  margin: 0 auto;
}

/* ── View Headers & Section Structures ──────────────────── */
.view-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.view-header h2, .view-header h3 {
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
}

.view-sub {
  color: var(--muted);
  font-size: 0.82rem;
  margin-top: 3px;
}

.view-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.toolbar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 14px;
}

.toolbar-spacer {
  margin-left: auto;
}

.section-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin: 4px 0 10px;
}

.section-bar h3 {
  font-family: var(--font-display);
  font-size: 0.96rem;
  font-weight: 700;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
}

.narrow-wrap {
  max-width: 840px;
}

.narrow-sm {
  max-width: 780px;
}

/* ── Cards & KPI Strip ──────────────────────────────────── */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 22px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--card-shadow);
  color: var(--text);
  transition: border-color 0.18s ease, transform 0.18s cubic-bezier(0.16, 1, 0.3, 1);
}

.cards > .card {
  position: relative;
  border-top: 2px solid var(--border-strong);
  animation: fadeUp 0.24s cubic-bezier(0.16, 1, 0.3, 1) backwards;
}
.cards > .card:nth-child(1) { border-top-color: var(--accent); animation-delay: 0ms; }
.cards > .card:nth-child(2) { border-top-color: var(--cobalt); animation-delay: 35ms; }
.cards > .card:nth-child(3) { border-top-color: var(--green); animation-delay: 70ms; }
.cards > .card:nth-child(4) { border-top-color: var(--amber); animation-delay: 105ms; }

.card-hover:hover, .cards > .card:hover {
  border-color: var(--border-strong);
  transform: translateY(-2px);
}

.card .label {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.card .val {
  font-family: var(--font-display);
  font-variant-numeric: tabular-nums;
  font-size: 1.8rem;
  font-weight: 700;
  margin-top: 8px;
  color: var(--text);
  letter-spacing: -0.025em;
  line-height: 1.1;
}

.card .val.val-sm {
  font-size: 1.05rem;
  line-height: 1.35;
}

.card .sub {
  font-family: var(--font-mono);
  font-size: 0.76rem;
  color: var(--muted);
  margin-top: 6px;
}

.meter {
  height: 5px;
  background: var(--surface-2);
  border-radius: 2px;
  overflow: hidden;
  margin-top: 10px;
}
.meter-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
  transition: width 0.35s ease;
}
.meter-fill.ok { background: var(--green); }
.meter-fill.warn { background: var(--amber); }
.meter-fill.crit { background: var(--red); }

/* ── Banner / Notice ────────────────────────────────────── */
.banner {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  border-radius: var(--radius);
  font-size: 0.83rem;
  line-height: 1.5;
  margin-bottom: 16px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-2);
}

.banner-warn {
  background: var(--yellow-soft);
  border-color: var(--yellow-border);
  border-left: 3px solid var(--amber);
}

.banner-err {
  background: var(--red-soft);
  border-color: var(--red-border);
  border-left: 3px solid var(--red);
}

.banner-ok {
  border-color: var(--green-border);
  border-left: 3px solid var(--green);
}

/* ── Tables ─────────────────────────────────────────────── */
.table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow-x: auto;
  margin-bottom: 22px;
  box-shadow: var(--card-shadow);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.87rem;
}

th {
  padding: 11px 16px;
  text-align: left;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

td {
  padding: 11px 16px;
  border-bottom: 1px solid var(--border);
  color: var(--text-2);
  vertical-align: middle;
}

tr:last-child td {
  border-bottom: none;
}

tbody tr:hover td {
  background: var(--surface-hover);
}

.mono {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

.muted {
  color: var(--muted);
}

/* ── Buttons ────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 15px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  font-size: 0.84rem;
  font-weight: 600;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease, transform 0.12s ease;
  text-decoration: none;
  white-space: nowrap;
  line-height: 1.25;
}

.btn:active:not(:disabled) {
  transform: scale(0.98);
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: var(--accent);
}
.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

.btn-ghost {
  background: var(--surface-2);
  color: var(--text-2);
  border-color: var(--border);
}
.btn-ghost:hover:not(:disabled) {
  background: var(--surface-hover);
  color: var(--text);
  border-color: var(--border-strong);
}

.btn-danger {
  background: var(--red-soft);
  color: var(--red);
  border-color: var(--red-border);
}
.btn-danger:hover:not(:disabled) {
  background: var(--red);
  color: #FFFFFF;
  border-color: var(--red);
}

.btn-success {
  background: var(--green-soft);
  color: var(--green);
  border-color: var(--green-border);
}
.btn-success:hover:not(:disabled) {
  background: var(--green);
  color: #FFFFFF;
}

.btn-sm {
  padding: 5px 10px;
  font-size: 0.77rem;
}

.btn-icon {
  padding: 5px 7px;
}

.btn-motor {
  flex: 1;
  min-width: 155px;
  flex-direction: column;
  align-items: flex-start;
  padding: 12px 14px;
  text-align: left;
  gap: 3px;
}

/* ── Badges & Chips ─────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-2);
  white-space: nowrap;
}

.badge-green {
  background: var(--green-soft);
  color: var(--green);
  border-color: var(--green-border);
}
.badge-red {
  background: var(--red-soft);
  color: var(--red);
  border-color: var(--red-border);
}
.badge-yellow {
  background: var(--yellow-soft);
  color: var(--yellow);
  border-color: var(--yellow-border);
}
.badge-blue {
  background: var(--cobalt-soft);
  color: var(--cobalt-text);
  border-color: var(--cobalt-border);
}
.badge-orange {
  background: var(--orange-soft);
  color: var(--accent-text);
  border-color: var(--orange-border);
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 4px 9px;
  font-size: 0.78rem;
  color: var(--text-2);
}

.chip-del {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  display: inline-flex;
  padding: 1px;
}
.chip-del:hover {
  color: var(--red);
}

/* ── Forms & Inputs (corrige classes faltantes .input e .form-grid) ── */
.input,
.field input,
.field select,
.field textarea,
.av-f input,
.av-f select,
.av-f textarea {
  width: 100%;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 11px;
  font-size: 0.87rem;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.input-sm {
  padding: 5px 9px;
  font-size: 0.79rem;
}

.input:focus,
.field input:focus,
.field select:focus,
.field textarea:focus,
.av-f input:focus,
.av-f select:focus,
.av-f textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-soft);
}

select option {
  background-color: var(--surface);
  color: var(--text);
}

.field {
  margin-bottom: 16px;
}
.field label, .av-f {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.74rem;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.field label {
  margin-bottom: 6px;
}
.field textarea, .av-f textarea {
  resize: vertical;
  min-height: 84px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px 14px;
}
.form-grid .full {
  grid-column: 1 / -1;
}
.form-grid .field {
  margin-bottom: 0;
}

/* Segmented Controls */
.seg {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  padding: 2px;
  gap: 2px;
  flex-shrink: 0;
}
.seg-btn {
  background: transparent;
  color: var(--muted);
  border: none;
  border-radius: 3px;
  padding: 6px 14px;
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 600;
  transition: all 0.15s ease;
}
.seg-btn:hover {
  color: var(--text);
}
.seg-btn.active {
  background: var(--surface-2);
  color: var(--text);
}
.seg-btn.seg-on.active {
  background: var(--green);
  color: #FFFFFF;
}

.seg-tun {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--bg);
}
.seg-tun button {
  border: 0;
  padding: 3px 9px;
  font-size: 0.71rem;
  font-weight: 600;
  cursor: pointer;
  background: transparent;
  color: var(--muted);
  transition: all 0.15s ease;
}
.seg-tun button.is-on {
  background: var(--accent);
  color: var(--accent-ink);
}

/* ── Resource Grids (WireGuard, GOWA, Links) ───────────── */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(268px, 1fr));
  gap: 14px;
}

.peer-card, .gowa-card {
  padding: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.peer-card:hover, .gowa-card:hover {
  border-color: var(--border-strong);
}

.peer-head {
  background: var(--surface-2);
  padding: 13px 14px 11px;
  border-bottom: 1px solid var(--border);
}

.peer-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 9px;
}

.peer-ico-box {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  background: var(--surface);
  border: 1px solid var(--border);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--accent-text);
}

.peer-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.96rem;
  color: var(--text);
  margin-bottom: 4px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  word-break: break-word;
}
.peer-title:hover {
  color: var(--accent-text);
}

.peer-ip {
  font-family: var(--font-mono);
  font-size: 0.77rem;
  color: var(--cobalt-text);
}

.peer-body {
  padding: 11px 14px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.peer-foot {
  padding: 9px 12px;
  border-top: 1px solid var(--border);
  background: var(--bg-hover);
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
  align-items: center;
}

.peer-foot .btn-sm {
  padding: 5px 8px;
  font-size: 0.77rem;
  gap: 4px;
}

.peer-foot .btn-icon.btn-sm {
  padding: 5px 7px;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}
.status-dot.ok { background: var(--green); }
.status-dot.warn { background: var(--amber); }
.status-dot.err { background: var(--red); }
.status-dot.muted { background: var(--muted); }

/* Link Cards */
.link-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(268px, 1fr));
  gap: 14px;
}

.link-card {
  display: flex;
  gap: 13px;
  align-items: center;
  padding: 15px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-decoration: none;
  color: var(--text);
  transition: border-color 0.16s ease, transform 0.16s ease;
}

.link-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
}

.lc-ico {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--accent-soft);
  color: var(--accent-text);
  border: 1px solid var(--accent-border);
  border-radius: var(--radius-sm);
  flex-shrink: 0;
}

.lc-body { min-width: 0; flex: 1; }
.lc-title {
  font-weight: 700;
  font-size: 0.93rem;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 6px;
}
.lc-desc {
  font-size: 0.78rem;
  color: var(--muted);
  margin-top: 2px;
}
.lc-url {
  font-family: var(--font-mono);
  font-size: 0.71rem;
  color: var(--accent-text);
  margin-top: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* WG Type Cards */
.wg-type-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.wg-type-card {
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 8px;
  text-align: center;
  cursor: pointer;
  color: var(--muted);
  background: var(--bg);
  transition: all 0.15s ease;
  user-select: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}
.wg-type-card:hover {
  border-color: var(--border-strong);
  color: var(--text);
}
.wg-type-card.selected {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-text);
}

/* Attendants & Horario */
.at-row {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 10px;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.hr-lbl {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  user-select: none;
  font-size: 0.84rem;
  color: var(--text-2);
}

#hr-dias input[type=time] {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 4px 7px;
  font-family: var(--font-mono);
}
#hr-dias input[type=time]:disabled {
  opacity: 0.4;
}

/* ── Modals & Overlays ──────────────────────────────────── */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(5, 8, 14, 0.78);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 200;
}
.overlay.show {
  display: flex;
  animation: fadeIn 0.16s ease;
}

.modal {
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-top: 3px solid var(--accent);
  border-radius: var(--radius-lg);
  padding: 24px;
  width: 100%;
  max-width: 540px;
  max-height: 88vh;
  overflow-y: auto;
  box-shadow: var(--modal-shadow);
  animation: scaleIn 0.18s cubic-bezier(0.16, 1, 0.3, 1);
}
.modal.modal-lg { max-width: 780px; }
.modal.modal-sm { max-width: 440px; }
.modal.modal-danger { border-top-color: var(--red); }

.modal h3 {
  font-family: var(--font-display);
  font-size: 1.12rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 16px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 11px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.modal-sub {
  font-size: 0.8rem;
  color: var(--muted);
  margin: -10px 0 16px;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 20px;
  flex-wrap: wrap;
}

/* Code / Diag / SNMP / QR */
.pre-code {
  background: var(--code-bg);
  color: var(--code-text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  line-height: 1.5;
  white-space: pre-wrap;
  overflow-x: auto;
  margin-top: 8px;
}

.diag-section {
  margin-bottom: 14px;
  background: var(--surface-2);
  padding: 12px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}
.diag-section .diag-title {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.diag-section pre {
  max-height: 185px;
  overflow-y: auto;
  font-size: 0.76rem;
}

.qcmd-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
}
.qcmd {
  padding: 4px 9px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-2);
  cursor: pointer;
  font-size: 0.76rem;
  font-weight: 500;
  transition: all 0.14s ease;
}
.qcmd:hover {
  border-color: var(--accent);
  color: var(--accent-text);
}

.qr-frame {
  background: #FFFFFF;
  display: inline-block;
  padding: 12px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  margin: 8px auto 14px;
}

/* ── Toasts & Empty & Skeletons ─────────────────────────── */
#toasts {
  position: fixed;
  bottom: 20px;
  right: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 300;
  max-width: calc(100vw - 32px);
}

.toast {
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-left: 3px solid var(--accent);
  color: var(--text);
  border-radius: var(--radius);
  padding: 11px 16px;
  font-size: 0.85rem;
  font-weight: 500;
  box-shadow: var(--card-shadow);
  animation: slideIn 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  max-width: 360px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.toast.ok { border-left-color: var(--green); }
.toast.err { border-left-color: var(--red); }

.empty-state {
  text-align: center;
  padding: 44px 20px;
  color: var(--muted);
  background: var(--surface);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  grid-column: 1 / -1;
}
.empty-state h4 {
  color: var(--text);
  font-size: 0.96rem;
  margin-top: 10px;
  margin-bottom: 4px;
}
.empty-state p {
  font-size: 0.82rem;
}

.skeleton-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}
.skel {
  background: linear-gradient(90deg, var(--surface) 25%, var(--surface-2) 50%, var(--surface) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.2s ease-in-out infinite;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.skel-card { height: 108px; }
.skel-block { height: 220px; }

/* ── Login Stage (index.html) ───────────────────────────── */
body.login-stage {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
  background-color: var(--bg);
  background-image:
    linear-gradient(to right, var(--bg-grid) 1px, transparent 1px),
    linear-gradient(to bottom, var(--bg-grid) 1px, transparent 1px);
  background-size: 28px 28px;
  position: relative;
}

.login-topbar {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 10;
}

.login-shell {
  width: 100%;
  max-width: 416px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-top: 3px solid var(--accent);
  border-radius: var(--radius-lg);
  padding: 34px 30px 28px;
  box-shadow: var(--modal-shadow);
  animation: fadeUp 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 24px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
}
.login-brand img {
  height: 50px;
  width: auto;
  display: block;
  flex-shrink: 0;
}
.login-brand h1 {
  font-family: var(--font-display);
  font-size: 1.38rem;
  font-weight: 700;
  letter-spacing: -0.025em;
  color: var(--text);
  line-height: 1.15;
}
.login-brand p {
  font-size: 0.8rem;
  color: var(--muted);
  margin-top: 3px;
}

.pass-wrap {
  position: relative;
}
.pass-wrap input {
  padding-right: 40px;
}
.pass-toggle {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  background: transparent;
  border: none;
  color: var(--muted);
  cursor: pointer;
  padding: 5px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.pass-toggle:hover {
  color: var(--text);
}

.login-err {
  background: var(--red-soft);
  border: 1px solid var(--red-border);
  border-left: 3px solid var(--red);
  color: var(--red);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 0.83rem;
  font-weight: 500;
  margin-bottom: 16px;
  display: none;
  align-items: center;
  gap: 8px;
}
.login-err.show {
  display: flex;
}

.login-foot {
  margin-top: 20px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--muted);
}

/* ── Animations ─────────────────────────────────────────── */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes fadeUp { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes scaleIn { from { opacity: 0; transform: scale(0.96); } to { opacity: 1; transform: none; } }
@keyframes slideIn { from { opacity: 0; transform: translateX(18px); } to { opacity: 1; transform: none; } }
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
@keyframes rptSpin { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}

/* ── Responsive Breakpoints (Tablet + Mobile Drawer) ─────── */
@media (max-width: 960px) {
  body.app-shell {
    overflow: auto;
    height: auto;
    min-height: 100vh;
  }
  #sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    transform: translateX(-100%);
    box-shadow: var(--modal-shadow);
  }
  #sidebar.open {
    transform: translateX(0);
  }
  .sidebar-close-btn {
    display: inline-flex;
  }
  .menu-btn {
    display: inline-flex;
  }
  #topbar {
    padding: 10px 14px;
  }
  #content {
    padding: 16px 14px 28px;
  }
  .noc-pill {
    display: none;
  }
}

@media (max-width: 600px) {
  .theme-btn .theme-lbl {
    display: none;
  }
  .theme-btn {
    padding: 6px 8px;
  }
  .cards {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }
  .card {
    padding: 14px;
  }
  .card .val {
    font-size: 1.45rem;
  }
  .form-grid {
    grid-template-columns: 1fr;
  }
  .modal {
    padding: 18px 16px;
  }
  .btn-motor {
    min-width: 100%;
  }
}

@media (max-width: 400px) {
  .cards {
    grid-template-columns: 1fr;
  }
}
