/* ── Reset & Base ─────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --bg:        #0f1117;
  --bg2:       #161b27;
  --bg3:       #1e2538;
  --card:      #1a2035;
  --border:    #2a3352;
  --accent:    #6c63ff;
  --accent2:   #4f46e5;
  --green:     #10b981;
  --red:       #ef4444;
  --orange:    #f59e0b;
  --blue:      #3b82f6;
  --purple:    #8b5cf6;
  --text:      #e2e8f0;
  --text2:     #94a3b8;
  --text3:     #64748b;
  --radius:    10px;
  --shadow:    0 4px 24px rgba(0,0,0,0.4);
  --sidebar-w: 240px;
  --transition: 0.2s ease;
}
html, body { height: 100%; font-family: 'Inter', system-ui, -apple-system, sans-serif; background: var(--bg); color: var(--text); font-size: 14px; }
a { text-decoration: none; color: inherit; }
button { cursor: pointer; border: none; background: none; font: inherit; }
input, select, textarea { font: inherit; }

/* ── Scrollbar ────────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: var(--bg2); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 99px; }

/* ── Login Screen ─────────────────────────────────────────────────────────── */
.login-screen { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: radial-gradient(ellipse at 50% 0%, #1e2538 0%, var(--bg) 70%); }
.login-card { width: 380px; background: var(--card); border: 1px solid var(--border); border-radius: 16px; padding: 40px; box-shadow: var(--shadow); }
.login-logo { text-align: center; margin-bottom: 32px; }
.login-logo i { font-size: 42px; color: var(--accent); }
.login-logo h1 { font-size: 24px; font-weight: 700; margin: 8px 0 4px; }
.login-logo p { color: var(--text2); font-size: 13px; }

/* ── Forms ────────────────────────────────────────────────────────────────── */
.form-group { margin-bottom: 18px; }
.form-group label { display: block; font-size: 12px; font-weight: 600; color: var(--text2); margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.05em; }
.form-group input, .form-group select, .form-group textarea {
  width: 100%; padding: 10px 14px; background: var(--bg3); border: 1px solid var(--border);
  border-radius: var(--radius); color: var(--text); outline: none; transition: border-color var(--transition);
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus { border-color: var(--accent); }
.form-group select option { background: var(--bg3); }
.input-eye { position: relative; }
.input-eye input { padding-right: 40px; }
.eye-btn { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); color: var(--text3); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-inline { display: flex; gap: 10px; align-items: flex-end; }
.form-inline .form-group { flex: 1; margin-bottom: 0; }

/* ── Buttons ──────────────────────────────────────────────────────────────── */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 9px 18px; border-radius: var(--radius); font-weight: 600; font-size: 13px; transition: all var(--transition); }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent2); }
.btn-danger { background: var(--red); color: #fff; }
.btn-danger:hover { opacity: 0.85; }
.btn-success { background: var(--green); color: #fff; }
.btn-success:hover { opacity: 0.85; }
.btn-warning { background: var(--orange); color: #000; }
.btn-warning:hover { opacity: 0.85; }
.btn-ghost { background: transparent; color: var(--text2); border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--bg3); color: var(--text); }
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-full { width: 100%; justify-content: center; padding: 12px; }
.btn-icon { padding: 7px; border-radius: 8px; }
.btn-loader { margin-left: 6px; }

/* ── App Shell ────────────────────────────────────────────────────────────── */
.app-shell { display: flex; height: 100vh; overflow: hidden; }

/* ── Sidebar ──────────────────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w); min-width: var(--sidebar-w); background: var(--bg2);
  border-right: 1px solid var(--border); display: flex; flex-direction: column;
  transition: width var(--transition); overflow: hidden;
}
.sidebar.collapsed { width: 60px; min-width: 60px; }
.sidebar-header {
  display: flex; align-items: center; gap: 12px; padding: 18px 16px;
  border-bottom: 1px solid var(--border); font-weight: 700; font-size: 16px; color: var(--accent);
}
.sidebar-header i { font-size: 22px; flex-shrink: 0; }
.sidebar-header span { white-space: nowrap; overflow: hidden; }
.sidebar-toggle-btn { margin-left: auto; color: var(--text3); flex-shrink: 0; }
.sidebar-nav { flex: 1; overflow-y: auto; padding: 12px 8px; display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px;
  border-radius: var(--radius); color: var(--text2); font-weight: 500;
  transition: all var(--transition); white-space: nowrap; overflow: hidden;
}
.nav-item:hover { background: var(--bg3); color: var(--text); }
.nav-item.active { background: rgba(108,99,255,0.15); color: var(--accent); font-weight: 600; }
.nav-item i { font-size: 16px; flex-shrink: 0; width: 20px; text-align: center; }
.sidebar.collapsed .nav-item span,
.sidebar.collapsed .sidebar-header span { display: none; }
.sidebar.collapsed .sidebar-footer span { display: none; }
.sidebar-footer { padding: 16px; border-top: 1px solid var(--border); display: flex; align-items: center; gap: 10px; overflow: hidden; }
.admin-name { font-size: 12px; color: var(--text3); flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ── Main Content ─────────────────────────────────────────────────────────── */
.main-content { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
.topbar {
  display: flex; align-items: center; gap: 16px; padding: 0 24px;
  height: 60px; border-bottom: 1px solid var(--border); background: var(--bg2); flex-shrink: 0;
}
.page-title { font-size: 18px; font-weight: 700; flex: 1; }
.topbar-right { display: flex; align-items: center; gap: 14px; }
.live-badge { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--green); font-weight: 600; }
.pulse { width: 8px; height: 8px; border-radius: 50%; background: var(--green); animation: pulse 2s infinite; }
@keyframes pulse { 0%,100%{ box-shadow: 0 0 0 0 rgba(16,185,129,0.4); } 50%{ box-shadow: 0 0 0 6px rgba(16,185,129,0); } }
.topbar-time { font-size: 12px; color: var(--text3); }
.page-content { flex: 1; overflow-y: auto; padding: 24px; }

/* ── Cards ────────────────────────────────────────────────────────────────── */
.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; }
.card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.card-header h3 { font-size: 15px; font-weight: 600; }
.card-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* ── Stat Grid ────────────────────────────────────────────────────────────── */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; display: flex; align-items: flex-start; gap: 16px; }
.stat-icon { width: 44px; height: 44px; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 20px; flex-shrink: 0; }
.stat-info { flex: 1; }
.stat-label { font-size: 12px; color: var(--text3); font-weight: 500; text-transform: uppercase; letter-spacing: 0.05em; }
.stat-value { font-size: 26px; font-weight: 800; margin: 2px 0; }
.stat-sub { font-size: 11px; color: var(--text3); }

/* ── Table ────────────────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead th { padding: 10px 14px; text-align: left; font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text3); border-bottom: 1px solid var(--border); white-space: nowrap; }
tbody tr { border-bottom: 1px solid rgba(42,51,82,0.5); transition: background var(--transition); }
tbody tr:hover { background: rgba(255,255,255,0.02); }
tbody td { padding: 11px 14px; vertical-align: middle; }
.td-actions { display: flex; gap: 6px; align-items: center; }

/* ── Badges ───────────────────────────────────────────────────────────────── */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 3px 9px; border-radius: 99px; font-size: 11px; font-weight: 600; }
.badge-green  { background: rgba(16,185,129,0.15);  color: var(--green);  }
.badge-red    { background: rgba(239,68,68,0.15);   color: var(--red);    }
.badge-orange { background: rgba(245,158,11,0.15);  color: var(--orange); }
.badge-blue   { background: rgba(59,130,246,0.15);  color: var(--blue);   }
.badge-purple { background: rgba(139,92,246,0.15);  color: var(--purple); }
.badge-gray   { background: rgba(100,116,139,0.15); color: var(--text2);  }

/* ── Search & Filters ─────────────────────────────────────────────────────── */
.filters-bar { display: flex; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; align-items: center; }
.search-box { position: relative; flex: 1; min-width: 200px; }
.search-box i { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--text3); }
.search-box input { width: 100%; padding: 9px 12px 9px 36px; background: var(--bg3); border: 1px solid var(--border); border-radius: var(--radius); color: var(--text); }
.search-box input:focus { border-color: var(--accent); outline: none; }
.filter-select { padding: 9px 12px; background: var(--bg3); border: 1px solid var(--border); border-radius: var(--radius); color: var(--text); min-width: 130px; }

/* ── Pagination ───────────────────────────────────────────────────────────── */
.pagination { display: flex; align-items: center; justify-content: space-between; margin-top: 16px; }
.pagination-info { font-size: 12px; color: var(--text3); }
.pagination-btns { display: flex; gap: 4px; }
.page-btn { padding: 6px 12px; background: var(--bg3); border: 1px solid var(--border); border-radius: 8px; color: var(--text2); font-size: 12px; transition: all var(--transition); }
.page-btn:hover, .page-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.page-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* ── Modal ────────────────────────────────────────────────────────────────── */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.7); z-index: 1000; display: flex; align-items: center; justify-content: center; backdrop-filter: blur(4px); }
.modal-box { background: var(--card); border: 1px solid var(--border); border-radius: 14px; width: 90%; max-width: 600px; max-height: 90vh; display: flex; flex-direction: column; box-shadow: var(--shadow); animation: modalIn 0.2s ease; }
.modal-box.wide { max-width: 860px; }
@keyframes modalIn { from { opacity: 0; transform: scale(0.95) translateY(-10px); } to { opacity: 1; transform: none; } }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 20px 24px; border-bottom: 1px solid var(--border); flex-shrink: 0; }
.modal-header h3 { font-size: 16px; font-weight: 700; }
.modal-close { width: 30px; height: 30px; border-radius: 50%; display: flex; align-items: center; justify-content: center; color: var(--text2); transition: all var(--transition); }
.modal-close:hover { background: var(--bg3); color: var(--text); }
.modal-body { flex: 1; overflow-y: auto; padding: 24px; }
.modal-footer { padding: 16px 24px; border-top: 1px solid var(--border); display: flex; gap: 10px; justify-content: flex-end; flex-shrink: 0; }

/* ── Delete Confirmation Modal ────────────────────────────────────────────── */
.delete-modal { text-align: center; }
.delete-icon { font-size: 48px; color: var(--red); margin-bottom: 16px; }
.delete-modal h4 { font-size: 18px; margin-bottom: 8px; }
.delete-modal p { color: var(--text2); margin-bottom: 20px; }
.delete-modal .warn-box { background: rgba(239,68,68,0.1); border: 1px solid rgba(239,68,68,0.3); border-radius: var(--radius); padding: 12px 16px; margin-bottom: 20px; font-size: 12px; color: var(--red); text-align: left; }

/* ── Toggle Switch ────────────────────────────────────────────────────────── */
.toggle-wrap { display: flex; align-items: center; gap: 10px; }
.toggle { position: relative; width: 44px; height: 24px; }
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-slider { position: absolute; cursor: pointer; inset: 0; background: var(--bg3); border: 1px solid var(--border); border-radius: 34px; transition: var(--transition); }
.toggle-slider::before { content: ''; position: absolute; height: 16px; width: 16px; left: 3px; bottom: 3px; background: var(--text3); border-radius: 50%; transition: var(--transition); }
input:checked + .toggle-slider { background: rgba(108,99,255,0.2); border-color: var(--accent); }
input:checked + .toggle-slider::before { transform: translateX(20px); background: var(--accent); }

/* ── Feature Grid (plan editor) ───────────────────────────────────────────── */
.feature-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.feature-item { display: flex; align-items: center; justify-content: space-between; padding: 10px 14px; background: var(--bg3); border-radius: 8px; border: 1px solid var(--border); }
.feature-label { font-size: 12px; font-weight: 500; }

/* ── Sections ─────────────────────────────────────────────────────────────── */
.section { margin-bottom: 24px; }
.section-title { font-size: 13px; font-weight: 700; color: var(--text3); text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 12px; display: flex; align-items: center; gap: 8px; }
.section-title::after { content: ''; flex: 1; height: 1px; background: var(--border); }

/* ── Detail Rows ──────────────────────────────────────────────────────────── */
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.detail-item { background: var(--bg3); border-radius: 8px; padding: 12px 14px; }
.detail-key { font-size: 11px; color: var(--text3); font-weight: 500; text-transform: uppercase; letter-spacing: 0.04em; }
.detail-val { font-size: 14px; font-weight: 600; margin-top: 3px; word-break: break-all; }

/* ── Toast ────────────────────────────────────────────────────────────────── */
.toast-container { position: fixed; bottom: 24px; right: 24px; z-index: 9999; display: flex; flex-direction: column; gap: 8px; }
.toast { display: flex; align-items: center; gap: 12px; padding: 12px 18px; border-radius: var(--radius); font-size: 13px; font-weight: 500; min-width: 280px; box-shadow: var(--shadow); animation: toastIn 0.3s ease; }
@keyframes toastIn { from { opacity: 0; transform: translateX(30px); } to { opacity: 1; transform: none; } }
.toast.fade-out { animation: toastOut 0.3s ease forwards; }
@keyframes toastOut { to { opacity: 0; transform: translateX(30px); } }
.toast-success { background: #065f46; border: 1px solid rgba(16,185,129,0.4); color: #a7f3d0; }
.toast-error   { background: #7f1d1d; border: 1px solid rgba(239,68,68,0.4); color: #fca5a5; }
.toast-info    { background: #1e3a5f; border: 1px solid rgba(59,130,246,0.4); color: #93c5fd; }
.toast-warn    { background: #78350f; border: 1px solid rgba(245,158,11,0.4); color: #fcd34d; }

/* ── Loading & Empty ──────────────────────────────────────────────────────── */
.loading-state { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 60px; gap: 14px; color: var(--text3); }
.loading-state i { font-size: 32px; }
.empty-state { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 60px; gap: 14px; color: var(--text3); }
.empty-state i { font-size: 36px; opacity: 0.4; }
.empty-state p { font-size: 14px; }

/* ── Misc ─────────────────────────────────────────────────────────────────── */
.hidden { display: none !important; }
.text-red { color: var(--red); }
.text-green { color: var(--green); }
.text-orange { color: var(--orange); }
.text-blue { color: var(--blue); }
.text-muted { color: var(--text3); }
.monospace { font-family: 'JetBrains Mono', 'Fira Code', monospace; }
.separator { height: 1px; background: var(--border); margin: 16px 0; }
.mb-0 { margin-bottom: 0 !important; }
.mt-16 { margin-top: 16px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }

/* ── Responsive ───────────────────────────────────────────────────────────── */
.mobile-only { display: none; }
@media (max-width: 768px) {
  .mobile-only { display: flex; }
  .sidebar { position: fixed; left: -var(--sidebar-w); z-index: 500; height: 100%; transition: left var(--transition); }
  .sidebar.mobile-open { left: 0; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .detail-grid { grid-template-columns: 1fr; }
  .feature-grid { grid-template-columns: 1fr; }
  .form-row { grid-template-columns: 1fr; }
  .page-content { padding: 16px; }
}
