:root {
  --bg: #090d16;
  --bg-surface: #0f172a;
  --bg-card: rgba(15, 23, 42, 0.75);
  --bg-card-hover: rgba(22, 34, 56, 0.9);
  --border: rgba(255, 255, 255, 0.08);
  --border-focus: rgba(16, 185, 129, 0.4);
  --text: #f1f5f9;
  --text-muted: #94a3b8;
  --text-dim: #64748b;
  --accent: #10b981;
  --accent-glow: rgba(16, 185, 129, 0.2);
  --primary: #3b82f6;
  --danger: #ef4444;
  --warning: #f59e0b;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --font-main: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
}

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

body {
  background-color: var(--bg);
  color: var(--text);
  font-family: var(--font-main);
  line-height: 1.5;
  min-height: 100vh;
  background-image: 
    radial-gradient(circle at 50% 0%, rgba(16, 185, 129, 0.08) 0%, transparent 60%),
    radial-gradient(circle at 10% 30%, rgba(59, 130, 246, 0.05) 0%, transparent 50%);
}

/* ==========================================================================
   LOGIN SCREEN
   ========================================================================== */
.view-screen {
  min-height: 100vh;
}

#login-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.login-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  backdrop-filter: blur(16px);
  padding: 40px;
  width: 100%;
  max-width: 440px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.6);
}

.brand-header {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 32px;
}

.logo-icon {
  width: 48px;
  height: 48px;
  background: linear-gradient(135deg, #10b981, #059669);
  color: #fff;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 24px;
  box-shadow: 0 4px 14px var(--accent-glow);
}

.logo-icon.sm {
  width: 36px;
  height: 36px;
  font-size: 18px;
  border-radius: 8px;
}

.brand-text h1 {
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.brand-text span {
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* ==========================================================================
   APP HEADER & NAVIGATION
   ========================================================================== */
.app-header {
  background: rgba(10, 15, 26, 0.85);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(12px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 28px;
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 14px;
}

.header-title strong {
  font-size: 1.1rem;
  font-weight: 800;
  margin-right: 8px;
}

.badge-role {
  background: rgba(16, 185, 129, 0.15);
  color: var(--accent);
  border: 1px solid rgba(16, 185, 129, 0.3);
  font-size: 0.7rem;
  padding: 2px 8px;
  border-radius: 100px;
  font-weight: 700;
  letter-spacing: 0.05em;
}

.header-nav {
  display: flex;
  gap: 6px;
}

.nav-tab {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: baseline;
  gap: 6px;
  transition: all 0.15s ease;
}

.nav-tab small {
  font-size: 0.72rem;
  color: var(--text-dim);
  font-weight: 500;
}

.nav-tab:hover {
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
}

.nav-tab.active {
  background: rgba(16, 185, 129, 0.12);
  border-color: rgba(16, 185, 129, 0.25);
  color: #fff;
}

.nav-tab.active small {
  color: var(--accent);
}

.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.user-pill {
  font-size: 0.85rem;
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.05);
  padding: 4px 10px;
  border-radius: 6px;
}

/* ==========================================================================
   MAIN CONTENT & TABS
   ========================================================================== */
.app-main {
  max-width: 1300px;
  margin: 0 auto;
  padding: 28px 24px;
}

.tab-pane {
  display: none;
}

.tab-pane.active {
  display: block;
}

.pane-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  margin-bottom: 24px;
}

.pane-header h2 {
  font-size: 1.45rem;
  font-weight: 800;
}

.pane-header .subtitle {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-top: 2px;
}

/* ==========================================================================
   CARDS & GRIDS
   ========================================================================== */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  backdrop-filter: blur(12px);
  padding: 24px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

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

.stat-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--primary);
}

.stat-card.green::before { background: var(--accent); }
.stat-card.yellow::before { background: var(--warning); }
.stat-card.red::before { background: var(--danger); }
.stat-card.muted::before { background: var(--text-dim); }

.stat-meta {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-weight: 600;
}

.stat-value {
  font-size: 2.2rem;
  font-weight: 800;
  margin: 8px 0;
  letter-spacing: -0.02em;
}

.stat-sub {
  font-size: 0.75rem;
  color: var(--text-dim);
}

.grid-two-cols {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}

@media (max-width: 900px) {
  .grid-two-cols {
    grid-template-columns: 1fr;
  }
}

/* ==========================================================================
   TABLES
   ========================================================================== */
.table-card {
  padding: 0;
  overflow: hidden;
}

.table-responsive {
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.88rem;
}

.data-table th {
  background: rgba(255, 255, 255, 0.03);
  color: var(--text-muted);
  font-weight: 600;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  text-transform: uppercase;
  font-size: 0.75rem;
  letter-spacing: 0.04em;
}

.data-table td {
  padding: 14px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  vertical-align: middle;
}

.data-table tr:hover td {
  background: rgba(255, 255, 255, 0.02);
}

/* ==========================================================================
   BADGES & PILLS
   ========================================================================== */
.badge {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 4px;
  letter-spacing: 0.04em;
}

.badge-active {
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.badge-revoked {
  background: rgba(239, 68, 68, 0.15);
  color: #f87171;
  border: 1px solid rgba(239, 68, 68, 0.3);
}

.badge-expiry {
  font-size: 0.8rem;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 4px;
}

.badge-expiry.valid {
  color: #34d399;
}

.badge-expiry.warn {
  color: #fbbf24;
}

.badge-expiry.expired {
  color: #f87171;
}

/* ==========================================================================
   BUTTONS & FORMS
   ========================================================================== */
.btn {
  font-family: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: all 0.15s ease;
}

.btn-primary {
  background: linear-gradient(135deg, #10b981, #059669);
  color: #fff;
  box-shadow: 0 2px 8px var(--accent-glow);
}

.btn-primary:hover {
  background: linear-gradient(135deg, #059669, #047857);
}

.btn-secondary {
  background: #1e293b;
  border-color: rgba(255, 255, 255, 0.1);
  color: var(--text);
}

.btn-secondary:hover {
  background: #334155;
}

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

.btn-ghost:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
}

.btn-sm {
  padding: 4px 10px;
  font-size: 0.78rem;
}

.btn-block {
  width: 100%;
}

.btn-outline-danger {
  background: transparent;
  border-color: rgba(239, 68, 68, 0.4);
  color: #f87171;
}

.btn-outline-danger:hover {
  background: rgba(239, 68, 68, 0.15);
}

.btn-outline-success {
  background: transparent;
  border-color: rgba(16, 185, 129, 0.4);
  color: #34d399;
}

.btn-outline-success:hover {
  background: rgba(16, 185, 129, 0.15);
}

.btn-outline-warning {
  background: transparent;
  border-color: rgba(245, 158, 11, 0.4);
  color: #fbbf24;
}

.btn-outline-warning:hover {
  background: rgba(245, 158, 11, 0.15);
}

.btn-outline-primary {
  background: transparent;
  border-color: rgba(59, 130, 246, 0.4);
  color: #60a5fa;
}

.btn-outline-primary:hover {
  background: rgba(59, 130, 246, 0.15);
}

.form-group {
  margin-bottom: 16px;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 6px;
}

input[type="text"],
input[type="password"],
input[type="number"],
select,
textarea {
  width: 100%;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: inherit;
  font-size: 0.9rem;
  padding: 10px 12px;
  outline: none;
  transition: border-color 0.15s ease;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.12);
}

.mono-input,
.mono-key {
  font-family: var(--font-mono);
  font-size: 0.82rem;
}

.helper-text {
  font-size: 0.75rem;
  color: var(--text-dim);
  display: block;
  margin-top: 4px;
}

.alert-error {
  margin-top: 14px;
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: #fca5a5;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.84rem;
}

/* ==========================================================================
   RESULT & KEY BOX
   ========================================================================== */
.result-card {
  background: rgba(16, 185, 129, 0.05);
  border-color: rgba(16, 185, 129, 0.25);
}

.success-badge {
  color: #34d399;
  font-weight: 700;
  font-size: 0.95rem;
  margin-bottom: 14px;
}

.meta-row {
  margin-bottom: 10px;
  font-size: 0.9rem;
}

.meta-lbl {
  color: var(--text-muted);
  margin-right: 8px;
}

.key-box {
  margin-top: 20px;
}

.key-box textarea {
  background: #020617;
  border: 1px solid rgba(16, 185, 129, 0.3);
  color: #a7f3d0;
  margin: 6px 0 10px 0;
  resize: none;
}

.key-actions {
  display: flex;
  gap: 10px;
}

/* ==========================================================================
   CMS SECTIONS
   ========================================================================== */
.cms-section {
  padding-bottom: 24px;
  margin-bottom: 24px;
  border-bottom: 1px solid var(--border);
}

.cms-section:last-child {
  border-bottom: none;
  padding-bottom: 0;
  margin-bottom: 0;
}

.section-title {
  font-size: 1.05rem;
  font-weight: 700;
  margin-bottom: 16px;
  color: #e2e8f0;
}

.toggle-container {
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  margin-bottom: 12px;
}

.toggle-container input {
  display: none;
}

.toggle-slider {
  width: 44px;
  height: 24px;
  background: #334155;
  border-radius: 100px;
  position: relative;
  transition: 0.2s;
}

.toggle-slider::before {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  background: #fff;
  border-radius: 50%;
  transition: 0.2s;
}

.toggle-container input:checked + .toggle-slider {
  background: var(--accent);
}

.toggle-container input:checked + .toggle-slider::before {
  transform: translateX(20px);
}

/* ==========================================================================
   MODAL & TIMELINE
   ========================================================================== */
.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-dialog {
  background: #0f172a;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  max-width: 650px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 25px 50px rgba(0, 0, 0, 0.8);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
}

.btn-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.2rem;
  cursor: pointer;
}

.modal-body {
  padding: 24px;
}

.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  font-size: 0.88rem;
  margin-bottom: 24px;
}

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

.modal-actions-bar {
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px;
  margin-bottom: 24px;
}

.modal-actions-bar h4 {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.action-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.timeline {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 10px;
}

.timeline-item {
  font-size: 0.82rem;
  background: rgba(255, 255, 255, 0.02);
  border-left: 3px solid var(--accent);
  padding: 8px 12px;
  border-radius: 0 4px 4px 0;
}

.timeline-item.revoked {
  border-left-color: var(--danger);
}

.timeline-time {
  color: var(--text-dim);
  font-size: 0.74rem;
  margin-bottom: 2px;
}

/* ==========================================================================
   TOAST
   ========================================================================== */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: #1e293b;
  border: 1px solid var(--border);
  color: #fff;
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 500;
  box-shadow: 0 10px 25px rgba(0,0,0,0.5);
  display: none;
  z-index: 300;
  animation: slideIn 0.2s ease;
}

.toast.success {
  border-color: rgba(16, 185, 129, 0.4);
  background: #064e3b;
}

.toast.error {
  border-color: rgba(239, 68, 68, 0.4);
  background: #7f1d1d;
}

@keyframes slideIn {
  from { transform: translateY(20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.metric-row {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  font-size: 0.88rem;
}
