/* ═══════════════════════════════════════════════════════
   Painel4Four Activation System — Premium UI v2
   ═══════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800;900&display=swap');

:root {
  --bg: #000000;
  --bg-elevated: #060806;
  --bg-card: #080a08;
  --bg-card-hover: #0c100c;
  --surface: rgba(255, 255, 255, 0.025);
  --surface-hover: rgba(255, 255, 255, 0.05);
  --border: rgba(0, 255, 70, 0.08);
  --border-hover: rgba(0, 255, 70, 0.18);
  --border-accent: rgba(0, 255, 70, 0.45);
  --text: #eafff0;
  --text-secondary: #a0c4a8;
  --text-tertiary: #5a7a60;
  --accent: #00ff66;
  --accent-bright: #66ffaa;
  --accent-dim: #00dd55;
  --accent-deep: #00bb44;
  --accent-glow: rgba(0, 255, 102, 0.10);
  --accent-glow-strong: rgba(0, 255, 102, 0.30);
  --green: #00ff66;
  --green-dim: #00bb44;
  --green-glow: rgba(0, 255, 102, 0.15);
  --amber: #fbbf24;
  --amber-dim: #d97706;
  --amber-glow: rgba(251, 191, 36, 0.12);
  --red: #ff4d5d;
  --red-dim: #dc2626;
  --red-glow: rgba(255, 77, 93, 0.12);
  --cyan: #00ffd5;
  --cyan-glow: rgba(0, 255, 213, 0.12);
  --neon-glow: 0 0 8px rgba(0, 255, 102, 0.4), 0 0 24px rgba(0, 255, 102, 0.15);
  --neon-glow-strong: 0 0 12px rgba(0, 255, 102, 0.5), 0 0 40px rgba(0, 255, 102, 0.2);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.6);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.5);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.7);
  --shadow-glow: 0 0 60px rgba(0, 255, 102, 0.05);
  --transition: 200ms cubic-bezier(0.4, 0, 0.2, 1);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

/* ── Reset & Base ── */

html {
  height: 100%;
  scrollbar-gutter: stable;
}

* {
  box-sizing: border-box;
  scrollbar-width: thin;
  scrollbar-color: rgba(34, 197, 94, 0.25) transparent;
}

*::-webkit-scrollbar { width: 6px; height: 6px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb {
  background: rgba(34, 197, 94, 0.25);
  border-radius: 999px;
}
*::-webkit-scrollbar-thumb:hover { background: rgba(34, 197, 94, 0.45); }

body {
  margin: 0;
  height: 100%;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body.auth-locked .app-shell {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

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

/* ── App Shell ── */

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

/* ── Sidebar ── */

.sidebar {
  width: 300px;
  min-width: 300px;
  padding: 24px 16px;
  background: var(--bg);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 32px;
  height: 100vh;
  overflow-y: auto;
}

.brand {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.5px;
  padding: 0 8px;
}

.brand-accent {
  background: linear-gradient(135deg, var(--accent-dim), var(--accent-bright));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.nav-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav-item,
.ghost-btn,
.secondary-btn,
.primary-btn,
.tab-btn,
.icon-btn {
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: var(--transition);
  font-weight: 500;
}

.nav-item {
  background: transparent;
  color: var(--text-tertiary);
  text-align: left;
  padding: 10px 12px;
  font-size: 14px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 10px;
}

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

.nav-item.active {
  color: var(--accent);
  background: rgba(0, 255, 102, 0.06);
  border-color: var(--border-accent);
  text-shadow: 0 0 12px rgba(0, 255, 102, 0.4);
}

.sidebar-footer {
  margin-top: auto;
  padding: 0 4px;
}

/* ── Main Area ── */

.main-area {
  flex: 1;
  min-width: 0;
  padding: 0;
  height: 100vh;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  background:
    radial-gradient(ellipse 80% 50% at 50% -20%, rgba(0, 255, 102, 0.04), transparent),
    var(--bg);
}

/* ── Topbar ── */

.topbar {
  display: flex;
  gap: 20px;
  justify-content: space-between;
  align-items: center;
  padding: 20px 32px 16px;
  position: sticky;
  top: 0;
  z-index: 15;
  background: rgba(0, 0, 0, 0.92);
  backdrop-filter: blur(16px) saturate(180%);
  border-bottom: 1px solid var(--border);
}

.eyebrow {
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 1.5px;
  font-size: 11px;
  font-weight: 600;
  margin: 0;
}

.topbar h1 {
  margin: 4px 0 0;
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* ── Inputs ── */

.search-input,
.select-input,
.login-card input,
.form-grid input,
.form-grid textarea {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  outline: none;
  font-size: 14px;
  transition: var(--transition);
}

.search-input { width: 320px; }

.search-input:focus,
.select-input:focus,
.login-card input:focus,
.form-grid input:focus,
.form-grid textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(0, 255, 102, 0.12), 0 0 16px rgba(0, 255, 102, 0.08);
  background: rgba(255, 255, 255, 0.04);
}

.search-input::placeholder,
.login-card input::placeholder,
.form-grid input::placeholder,
.form-grid textarea::placeholder {
  color: var(--text-tertiary);
}

/* ── Buttons ── */

.primary-btn,
.secondary-btn,
.ghost-btn {
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 600;
}

.primary-btn {
  background: linear-gradient(135deg, var(--accent-deep), var(--accent-dim));
  color: #000;
  font-weight: 700;
  border-color: transparent;
  box-shadow: var(--neon-glow);
}

.primary-btn:hover {
  background: linear-gradient(135deg, var(--accent-dim), var(--accent));
  transform: translateY(-1px);
  box-shadow: var(--neon-glow-strong);
}

.primary-btn:active { transform: translateY(0); }

.secondary-btn {
  background: var(--surface);
  border-color: var(--border);
  color: var(--text-secondary);
}

.secondary-btn:hover {
  border-color: var(--border-hover);
  background: var(--surface-hover);
  color: var(--text);
}

.ghost-btn {
  background: transparent;
  border-color: var(--border);
  color: var(--text-secondary);
}

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

.full-width { width: 100%; }

/* ── Views ── */

.view { display: none; }
.view.active {
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: 24px 32px 32px;
}

/* ═══════════════════════════════════════════════════════
   DASHBOARD
   ═══════════════════════════════════════════════════════ */

.stats-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 12px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  position: relative;
  overflow: hidden;
  transition: var(--transition);
  box-shadow: none;
}

.stat-card::after {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  width: 80px;
  height: 80px;
  border-radius: 0 0 0 80px;
  background: radial-gradient(circle at top right, rgba(0, 255, 102, 0.08), transparent 70%);
  pointer-events: none;
  opacity: 1;
}

.stat-card:hover {
  border-color: var(--border-hover);
  background: var(--bg-card-hover);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.stat-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.stat-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: var(--neon-glow);
  animation: pulse-dot 2s ease-in-out infinite;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; box-shadow: var(--neon-glow-strong); }
  50% { opacity: 0.5; box-shadow: 0 0 4px rgba(0, 255, 102, 0.2); }
}

.stat-label {
  color: var(--text-tertiary);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.stat-value {
  margin-top: 12px;
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -1px;
  background: linear-gradient(180deg, var(--text) 40%, var(--text-secondary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.stat-foot {
  margin-top: 8px;
  color: var(--text-tertiary);
  font-size: 12px;
  line-height: 1.4;
}

.stat-card.tone-paused .stat-dot {
  background: var(--amber);
  box-shadow: 0 0 8px var(--amber-glow);
}

.stat-card.tone-paused::after {
  background: radial-gradient(circle at top right, var(--amber-glow), transparent 70%);
}

.stat-card.tone-inactive .stat-dot {
  background: var(--cyan);
  box-shadow: 0 0 8px var(--cyan-glow);
}

.stat-card.tone-inactive::after {
  background: radial-gradient(circle at top right, var(--cyan-glow), transparent 70%);
}

.stat-card.tone-expired .stat-dot {
  background: var(--red);
  box-shadow: 0 0 8px var(--red-glow);
}

.stat-card.tone-expired::after {
  background: radial-gradient(circle at top right, var(--red-glow), transparent 70%);
}

/* ── Dashboard Grid ── */

.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr 380px;
  gap: 16px;
  align-items: start;
  margin-top: 16px;
}

.panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: none;
}

.panel-header,
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.panel-header h2,
.modal-header h3 {
  margin: 0;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.3px;
}

.panel-kicker {
  margin: 0 0 4px;
  color: var(--text-tertiary);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 1px;
  text-transform: uppercase;
}

.panel-badge {
  padding: 5px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.5px;
  color: var(--accent);
  border: 1px solid var(--border-accent);
  background: var(--accent-glow);
  display: flex;
  align-items: center;
  gap: 6px;
}

.panel-badge::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  animation: pulse-dot 2s ease-in-out infinite;
}

.split { gap: 16px; }

.activity-panel,
.overview-panel,
.logs-panel { min-height: 0; }

.overview-panel {
  position: sticky;
  top: 80px;
}

/* ── Insight Cards ── */

.insight-stack {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.insight-card {
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  transition: var(--transition);
}

.insight-card:hover {
  border-color: var(--border-hover);
  background: var(--surface-hover);
}

.insight-card.highlight {
  border-color: var(--border-accent);
  background: var(--accent-glow);
}

.insight-label {
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 1px;
  font-size: 10px;
  font-weight: 700;
}

.insight-value {
  margin-top: 8px;
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.5px;
}

.insight-subline {
  margin-top: 6px;
  color: var(--text-tertiary);
  font-size: 12px;
  line-height: 1.5;
}

.insight-row {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-top: 12px;
}

.insight-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 500;
}

.insight-pill strong {
  color: var(--text);
  font-weight: 700;
}

/* ═══════════════════════════════════════════════════════
   KEYS VIEW
   ═══════════════════════════════════════════════════════ */

.tab-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 16px;
  padding: 4px;
  background: var(--surface);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  width: fit-content;
}

.tab-btn {
  background: transparent;
  border-color: transparent;
  color: var(--text-tertiary);
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 500;
  border-radius: var(--radius-sm);
}

.tab-btn:hover {
  color: var(--text-secondary);
  background: var(--surface-hover);
}

.tab-btn.active {
  color: var(--text);
  background: var(--bg-card);
  border-color: var(--border);
  box-shadow: var(--shadow-sm);
}

.keys-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
  gap: 12px;
}

.key-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px;
  transition: var(--transition);
  box-shadow: none;
}

.key-card:hover {
  border-color: var(--border-hover);
  box-shadow: var(--shadow-md);
}

.key-card-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin-bottom: 14px;
}

.key-code {
  font-size: 15px;
  font-weight: 700;
  font-family: 'SF Mono', 'Fira Code', 'JetBrains Mono', monospace;
  letter-spacing: 0.5px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.copy-btn {
  background: none;
  border: 1px solid rgba(0, 255, 102, 0.2);
  border-radius: 6px;
  color: var(--accent);
  font-size: 14px;
  cursor: pointer;
  padding: 2px 6px;
  line-height: 1;
  transition: var(--transition);
  opacity: 0.6;
}

.copy-btn:hover {
  opacity: 1;
  background: rgba(0, 255, 102, 0.1);
  border-color: var(--accent);
  box-shadow: 0 0 8px rgba(0, 255, 102, 0.2);
}

.status-pill {
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border: 1px solid transparent;
}

.status-pill.active,
.status-pill.expiring {
  background: var(--green-glow);
  color: var(--green);
  border-color: rgba(74, 222, 128, 0.2);
}

.status-pill.inactive {
  background: var(--cyan-glow);
  color: var(--cyan);
  border-color: rgba(34, 211, 238, 0.2);
}

.status-pill.paused {
  background: var(--amber-glow);
  color: var(--amber);
  border-color: rgba(251, 191, 36, 0.2);
}

.status-pill.expired {
  background: var(--red-glow);
  color: var(--red);
  border-color: rgba(248, 113, 113, 0.2);
}

.key-data-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.data-tile {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px;
}

.data-tile.span-2 { grid-column: span 2; }

.tile-label {
  color: var(--text-tertiary);
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 6px;
}

.tile-value {
  font-size: 13px;
  font-weight: 600;
  line-height: 1.4;
  color: var(--text-secondary);
}

.key-actions {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
  margin-top: 14px;
}

.icon-btn {
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--surface);
  color: var(--text-secondary);
  font-size: 14px;
  border-radius: var(--radius-sm);
}

.icon-btn:hover {
  background: var(--surface-hover);
  color: var(--text);
  transform: translateY(-1px);
}

.icon-btn.extend { border-color: rgba(74, 222, 128, 0.25); }
.icon-btn.extend:hover { background: var(--green-glow); color: var(--green); }
.icon-btn.reset { border-color: rgba(34, 211, 238, 0.25); }
.icon-btn.reset:hover { background: var(--cyan-glow); color: var(--cyan); }
.icon-btn.pause { border-color: rgba(251, 191, 36, 0.25); }
.icon-btn.pause:hover { background: var(--amber-glow); color: var(--amber); }
.icon-btn.delete { border-color: rgba(248, 113, 113, 0.25); }
.icon-btn.delete:hover { background: var(--red-glow); color: var(--red); }

/* ═══════════════════════════════════════════════════════
   LOGS
   ═══════════════════════════════════════════════════════ */

.log-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: calc(100vh - 220px);
  overflow-y: auto;
  padding-right: 4px;
}

.log-list.compact {
  min-height: 480px;
  max-height: 480px;
}

.log-card {
  position: relative;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px 16px 14px 18px;
  background: var(--surface);
  overflow: hidden;
  transition: var(--transition);
}

.log-card::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--border-hover);
}

.log-card:hover {
  background: var(--surface-hover);
  border-color: var(--border-hover);
}

.log-card.outcome-allowed::before {
  background: var(--accent);
}

.log-card.outcome-blocked::before {
  background: var(--red);
}

.log-card.outcome-info::before {
  background: var(--cyan);
}

.log-card.compact { padding: 12px 14px 12px 16px; }

.log-head-group {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.log-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  border: 1px solid transparent;
}

.log-chip.allowed {
  color: var(--accent);
  border-color: rgba(74, 222, 128, 0.2);
  background: var(--green-glow);
}

.log-chip.blocked {
  color: var(--red);
  border-color: rgba(248, 113, 113, 0.2);
  background: var(--red-glow);
}

.log-chip.info {
  color: var(--cyan);
  border-color: rgba(34, 211, 238, 0.2);
  background: var(--cyan-glow);
}

.log-event {
  font-weight: 600;
  font-size: 14px;
}

.log-topline {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
  align-items: flex-start;
}

.log-message {
  font-size: 13px;
  line-height: 1.5;
  margin-bottom: 10px;
  color: var(--text-secondary);
}

.log-meta,
.empty-state,
.feedback-line {
  color: var(--text-tertiary);
}

.log-meta {
  font-size: 11px;
  line-height: 1.4;
}

.log-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.log-tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-secondary);
  font-size: 11px;
  line-height: 1.3;
}

.log-tag strong {
  color: var(--text-tertiary);
  font-weight: 600;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.logs-panel {
  display: flex;
  flex-direction: column;
  min-height: calc(100vh - 180px);
}

.logs-panel .log-list {
  flex: 1;
  min-height: 0;
  max-height: none;
}

/* ═══════════════════════════════════════════════════════
   LOGIN SCREEN
   ═══════════════════════════════════════════════════════ */

.overlay-screen {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(ellipse 50% 40% at 50% 45%, rgba(0, 255, 102, 0.05), transparent),
    radial-gradient(ellipse 30% 30% at 20% 80%, rgba(0, 255, 102, 0.03), transparent),
    #000000;
  z-index: 100;
}

.overlay-screen.active {
  display: flex;
}

.login-card {
  width: min(420px, calc(100vw - 32px));
  background:
    linear-gradient(180deg, rgba(6, 10, 6, 0.98), rgba(0, 0, 0, 0.99));
  border: 1px solid rgba(0, 255, 102, 0.15);
  border-radius: var(--radius-xl);
  padding: 40px 36px;
  box-shadow:
    0 0 0 1px rgba(0, 255, 102, 0.05),
    0 24px 64px rgba(0,0,0,0.7),
    0 0 100px rgba(0, 255, 102, 0.06);
  display: flex;
  flex-direction: column;
  gap: 8px;
  position: relative;
  overflow: hidden;
}

.login-card::before {
  content: "";
  position: absolute;
  top: -1px;
  left: 50%;
  transform: translateX(-50%);
  width: 60%;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  box-shadow: 0 0 12px rgba(0, 255, 102, 0.5);
  border-radius: 999px;
}

.login-brand {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 3px;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 4px;
}

.login-card h2 {
  margin: 0 0 20px;
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.5px;
}

.login-card input {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-md);
  padding: 13px 16px;
  font-size: 14px;
  color: var(--text);
  margin-bottom: 4px;
}

.login-card input:focus {
  border-color: var(--accent-dim);
  box-shadow: 0 0 0 3px var(--accent-glow);
  background: rgba(255, 255, 255, 0.06);
}

.login-card .primary-btn {
  margin-top: 8px;
  padding: 13px 20px;
  font-size: 15px;
  border-radius: var(--radius-md);
}

.login-card .feedback-line {
  text-align: center;
  font-size: 13px;
  min-height: 20px;
  color: var(--red);
}

/* ═══════════════════════════════════════════════════════
   MODALS
   ═══════════════════════════════════════════════════════ */

.modal {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(6, 10, 6, 0.92);
  backdrop-filter: blur(8px);
  z-index: 100;
}

.modal:not(.hidden) {
  display: flex;
}

.modal-card {
  width: min(460px, calc(100vw - 32px));
  background: linear-gradient(180deg, var(--bg-card) 0%, #000 100%);
  border: 1px solid rgba(0, 255, 102, 0.1);
  border-radius: var(--radius-xl);
  padding: 28px;
  box-shadow:
    0 0 0 1px rgba(0, 255, 102, 0.04),
    0 24px 64px rgba(0, 0, 0, 0.7),
    0 0 80px rgba(0, 255, 102, 0.03);
  position: relative;
  overflow: hidden;
}

.modal-card::before {
  content: "";
  position: absolute;
  top: -1px;
  left: 50%;
  transform: translateX(-50%);
  width: 40%;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  box-shadow: 0 0 10px rgba(0, 255, 102, 0.4);
  border-radius: 999px;
}

.compact-modal {
  width: min(400px, calc(100vw - 32px));
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.form-grid label {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-grid span {
  color: var(--text-tertiary);
  font-size: 12px;
  font-weight: 600;
}

.full-span { grid-column: span 2; }

.checkbox-row {
  flex-direction: row !important;
  align-items: center;
  gap: 8px !important;
}

.checkbox-row input {
  width: 16px;
  height: 16px;
  accent-color: var(--accent-dim);
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 4px;
}

/* ── Confirm Modal ── */

.confirm-modal-card {
  text-align: center;
  padding: 32px 28px 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.confirm-icon {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  margin-bottom: 8px;
  border: 2px solid;
}

.confirm-icon.icon-danger {
  background: rgba(255, 77, 93, 0.1);
  border-color: rgba(255, 77, 93, 0.3);
  color: var(--red);
}

.confirm-icon.icon-warning {
  background: rgba(251, 191, 36, 0.1);
  border-color: rgba(251, 191, 36, 0.3);
  color: var(--amber);
}

.confirm-icon.icon-info {
  background: rgba(0, 255, 102, 0.08);
  border-color: rgba(0, 255, 102, 0.25);
  color: var(--accent);
}

.confirm-title {
  margin: 0;
  font-size: 17px;
  font-weight: 700;
  color: var(--text);
}

.confirm-message {
  margin: 4px 0 16px;
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.5;
}

.confirm-actions {
  display: flex;
  gap: 10px;
  width: 100%;
}

.confirm-actions .ghost-btn,
.confirm-actions .primary-btn {
  flex: 1;
  padding: 11px 16px;
}

.danger-btn {
  background: linear-gradient(135deg, #dc2626, #ef4444) !important;
  color: #fff !important;
  border-color: transparent !important;
  box-shadow: 0 0 8px rgba(255, 77, 93, 0.3) !important;
}

.danger-btn:hover {
  background: linear-gradient(135deg, #ef4444, #f87171) !important;
  box-shadow: 0 0 16px rgba(255, 77, 93, 0.4) !important;
}

.warning-btn {
  background: linear-gradient(135deg, #d97706, #f59e0b) !important;
  color: #000 !important;
  border-color: transparent !important;
  box-shadow: 0 0 8px rgba(251, 191, 36, 0.3) !important;
}

.success-btn {
  background: linear-gradient(135deg, var(--accent-deep), var(--accent-dim)) !important;
  color: #000 !important;
}

.close-modal {
  background: transparent;
  border: none;
  color: var(--text-tertiary);
  font-size: 24px;
  cursor: pointer;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  transition: var(--transition);
}

.close-modal:hover {
  color: var(--text);
  background: var(--surface);
}

/* ── Toast ── */

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  min-width: 200px;
  max-width: 340px;
  padding: 12px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border-accent);
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 500;
  opacity: 0;
  transform: translateY(8px);
  transition: var(--transition);
  pointer-events: none;
  box-shadow: var(--shadow-lg);
  z-index: 200;
}

.toast.visible {
  opacity: 1;
  transform: translateY(0);
}

/* ── Empty State ── */

.empty-state {
  padding: 32px;
  text-align: center;
  border: 1px dashed var(--border);
  border-radius: var(--radius-lg);
  min-height: 100px;
  display: grid;
  place-items: center;
  font-size: 14px;
  color: var(--text-tertiary);
}

/* ═══════════════════════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════════════════════ */

@media (max-width: 1280px) {
  .stats-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (max-width: 1120px) {
  .app-shell { flex-direction: column; }

  .sidebar {
    width: auto;
    min-width: auto;
    border-right: none;
    border-bottom: 1px solid var(--border);
    height: auto;
    padding: 16px;
    flex-direction: row;
    align-items: center;
    gap: 16px;
    overflow-x: auto;
  }

  .nav-list { flex-direction: row; }
  .sidebar-footer { margin-top: 0; margin-left: auto; }

  .main-area { height: auto; }

  .topbar {
    flex-direction: column;
    align-items: flex-start;
  }

  .topbar-actions { flex-wrap: wrap; }
  .search-input { width: min(100%, 320px); }

  .dashboard-grid { grid-template-columns: 1fr; }
  .overview-panel { position: static; }

  .stats-grid { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 720px) {
  .view.active { padding: 16px; }

  .topbar { padding: 16px; }

  .stats-grid { grid-template-columns: repeat(2, 1fr); }

  .form-grid,
  .key-data-grid { grid-template-columns: 1fr; }

  .full-span,
  .data-tile.span-2 { grid-column: auto; }

  .topbar h1 { font-size: 20px; }

  .log-list.compact {
    min-height: 360px;
    max-height: 360px;
  }

  .log-topline,
  .insight-row {
    flex-direction: column;
    align-items: flex-start;
  }

  .keys-grid {
    grid-template-columns: 1fr;
  }

  .login-card {
    padding: 28px 24px;
  }
}
