:root {
  --primary: #f97316;
  --primary-dark: #ea580c;
  --primary-light: #fed7aa;
  --sidebar-bg: #0f172a;
  --sidebar-text: #94a3b8;
  --sidebar-active: #f97316;
  --bg: #f1f5f9;
  --card: #ffffff;
  --text: #1e293b;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --danger: #ef4444;
  --success: #22c55e;
  --warning: #f59e0b;
  --info: #3b82f6;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md: 0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.06);
  --radius: 8px;
  --sidebar-w: 240px;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}

/* ── LOGIN ─────────────────────────────────── */
#login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
}
.login-box {
  background: var(--card);
  border-radius: 16px;
  padding: 48px 40px;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 20px 60px rgba(0,0,0,.3);
}
.login-logo {
  text-align: center;
  margin-bottom: 32px;
}
.login-logo .icon { font-size: 48px; }
.login-logo h1 { font-size: 22px; font-weight: 700; color: var(--text); margin-top: 8px; }
.login-logo p { color: var(--text-muted); font-size: 13px; }
.login-box label { display: block; font-size: 13px; font-weight: 600; color: var(--text); margin-bottom: 6px; }
.login-box input {
  width: 100%; padding: 10px 14px; border: 1.5px solid var(--border);
  border-radius: var(--radius); font-size: 14px; outline: none; transition: border .2s;
}
.login-box input:focus { border-color: var(--primary); }
.login-box .field { margin-bottom: 18px; }
.login-btn {
  width: 100%; padding: 12px; background: var(--primary); color: #fff;
  border: none; border-radius: var(--radius); font-size: 15px; font-weight: 600;
  cursor: pointer; transition: background .2s; margin-top: 8px;
}
.login-btn:hover { background: var(--primary-dark); }
.login-error {
  background: #fef2f2; color: var(--danger); border: 1px solid #fecaca;
  border-radius: var(--radius); padding: 10px 14px; font-size: 13px;
  margin-top: 14px; display: none;
}

/* ── LOADING ────────────────────────────────── */
#loading-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--sidebar-bg);
  flex-direction: column;
  gap: 16px;
}
.spinner {
  width: 40px; height: 40px;
  border: 3px solid rgba(249,115,22,.3);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
#loading-screen p { color: var(--sidebar-text); font-size: 14px; }

/* ── APP SHELL ──────────────────────────────── */
#app { display: none; min-height: 100vh; }

.sidebar {
  position: fixed; top: 0; left: 0; bottom: 0;
  width: var(--sidebar-w); background: var(--sidebar-bg);
  display: flex; flex-direction: column; z-index: 100;
  transition: width .25s;
  overflow: hidden;
}
.sidebar-logo {
  display: flex; align-items: center; gap: 10px;
  padding: 20px 20px 16px;
  border-bottom: 1px solid rgba(255,255,255,.06);
}
.sidebar-logo .logo-icon { font-size: 26px; flex-shrink: 0; }
.sidebar-logo .logo-text { font-size: 15px; font-weight: 700; color: #fff; white-space: nowrap; }
.sidebar-logo .logo-sub { font-size: 11px; color: var(--sidebar-text); }

nav { flex: 1; padding: 12px 0; overflow-y: auto; }
.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 20px; color: var(--sidebar-text);
  cursor: pointer; transition: all .15s;
  white-space: nowrap; border-left: 3px solid transparent;
}
.nav-item:hover { background: rgba(255,255,255,.05); color: #fff; }
.nav-item.active { background: rgba(249,115,22,.12); color: var(--primary); border-left-color: var(--primary); }
.nav-item .nav-icon { font-size: 18px; flex-shrink: 0; width: 22px; text-align: center; }
.nav-item .nav-label { font-size: 13.5px; font-weight: 500; }
.nav-badge {
  margin-left: auto; background: var(--danger); color: #fff;
  font-size: 10px; font-weight: 700; padding: 1px 6px; border-radius: 10px;
}

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid rgba(255,255,255,.06);
}
.sidebar-footer .admin-info { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.sidebar-footer .avatar {
  width: 32px; height: 32px; border-radius: 50%; background: var(--primary);
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 700; color: #fff; flex-shrink: 0;
}
.sidebar-footer .admin-name { font-size: 13px; font-weight: 600; color: #fff; }
.sidebar-footer .admin-role { font-size: 11px; color: var(--sidebar-text); }
.logout-btn {
  width: 100%; padding: 8px 12px; background: rgba(239,68,68,.12);
  color: #ef4444; border: 1px solid rgba(239,68,68,.2);
  border-radius: var(--radius); font-size: 13px; font-weight: 500;
  cursor: pointer; transition: all .2s;
}
.logout-btn:hover { background: rgba(239,68,68,.2); }

/* ── MAIN CONTENT ──────────────────────────── */
.main {
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  display: flex; flex-direction: column;
}
.topbar {
  position: sticky; top: 0; z-index: 50;
  background: var(--card); border-bottom: 1px solid var(--border);
  padding: 0 24px; height: 60px;
  display: flex; align-items: center; justify-content: space-between;
  box-shadow: var(--shadow);
}
.topbar-title { font-size: 18px; font-weight: 700; color: var(--text); }
.topbar-right { display: flex; align-items: center; gap: 16px; }
.topbar-clock { font-size: 13px; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.live-badge {
  display: flex; align-items: center; gap: 6px;
  background: #f0fdf4; color: var(--success); border: 1px solid #bbf7d0;
  padding: 4px 10px; border-radius: 20px; font-size: 12px; font-weight: 600;
}
.live-dot {
  width: 7px; height: 7px; background: var(--success); border-radius: 50%;
  animation: pulse 2s infinite;
}
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:.4} }

.page-content { flex: 1; padding: 24px; }

/* ── PAGE HEADER ──────────────────────────── */
.page-header { margin-bottom: 24px; }
.page-header h2 { font-size: 20px; font-weight: 700; }
.page-header p { color: var(--text-muted); font-size: 13px; margin-top: 2px; }

/* ── STAT CARDS ──────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px; margin-bottom: 24px;
}
.stat-card {
  background: var(--card); border-radius: var(--radius);
  padding: 20px; box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 8px;
}
.stat-card .stat-label { font-size: 12px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: .04em; }
.stat-card .stat-value { font-size: 28px; font-weight: 800; color: var(--text); }
.stat-card .stat-icon { font-size: 24px; margin-bottom: 4px; }

/* ── CARDS / GRIDS ───────────────────────── */
.card {
  background: var(--card); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 20px; margin-bottom: 16px;
}
.card-title {
  font-size: 15px; font-weight: 700; margin-bottom: 16px;
  padding-bottom: 12px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }

/* ── TABLES ─────────────────────────────── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
thead th {
  background: var(--bg); padding: 10px 14px;
  text-align: left; font-size: 12px; font-weight: 600;
  color: var(--text-muted); text-transform: uppercase; letter-spacing: .04em;
  border-bottom: 1px solid var(--border);
}
tbody td {
  padding: 12px 14px; border-bottom: 1px solid var(--border);
  font-size: 13.5px; color: var(--text);
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #fafafa; }

/* ── BADGES ──────────────────────────────── */
.badge {
  display: inline-flex; align-items: center;
  padding: 2px 8px; border-radius: 20px;
  font-size: 11px; font-weight: 600;
}
.badge-green { background: #f0fdf4; color: #16a34a; }
.badge-red { background: #fef2f2; color: #dc2626; }
.badge-yellow { background: #fffbeb; color: #d97706; }
.badge-blue { background: #eff6ff; color: #2563eb; }
.badge-gray { background: #f1f5f9; color: #64748b; }
.badge-orange { background: #fff7ed; color: #c2410c; }

/* ── BUTTONS ─────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px; border-radius: var(--radius);
  font-size: 13px; font-weight: 600; cursor: pointer;
  border: none; transition: all .15s;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #dc2626; }
.btn-secondary { background: var(--bg); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--border); }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-ghost { background: transparent; color: var(--text-muted); }
.btn-ghost:hover { background: var(--bg); color: var(--text); }

/* ── FORM ELEMENTS ────────────────────────── */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; }
input[type="text"], input[type="email"], input[type="number"],
input[type="url"], input[type="password"], textarea, select {
  width: 100%; padding: 9px 12px; border: 1.5px solid var(--border);
  border-radius: var(--radius); font-size: 14px; outline: none;
  font-family: inherit; transition: border .2s; background: var(--card);
}
input:focus, textarea:focus, select:focus { border-color: var(--primary); }
textarea { resize: vertical; min-height: 80px; }
.search-bar {
  display: flex; gap: 8px; margin-bottom: 16px; align-items: center;
}
.search-input {
  flex: 1; padding: 9px 12px; border: 1.5px solid var(--border);
  border-radius: var(--radius); font-size: 14px; outline: none;
  transition: border .2s;
}
.search-input:focus { border-color: var(--primary); }

/* ── FILTER TABS ─────────────────────────── */
.filter-tabs { display: flex; gap: 4px; margin-bottom: 16px; flex-wrap: wrap; }
.filter-tab {
  padding: 6px 14px; border-radius: 20px; font-size: 12px; font-weight: 600;
  cursor: pointer; border: 1.5px solid var(--border); background: var(--card);
  color: var(--text-muted); transition: all .15s;
}
.filter-tab.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.filter-tab:hover:not(.active) { border-color: var(--primary); color: var(--primary); }

/* ── TOGGLE ──────────────────────────────── */
.toggle-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 0; border-bottom: 1px solid var(--border);
}
.toggle-row:last-child { border-bottom: none; }
.toggle-info .toggle-label { font-size: 14px; font-weight: 600; }
.toggle-info .toggle-desc { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.toggle {
  position: relative; width: 44px; height: 24px;
  flex-shrink: 0;
}
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute; inset: 0; cursor: pointer;
  background: #cbd5e1; border-radius: 24px; transition: .2s;
}
.toggle-slider:before {
  content: ''; position: absolute; width: 18px; height: 18px;
  left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .2s;
}
.toggle input:checked + .toggle-slider { background: var(--primary); }
.toggle input:checked + .toggle-slider:before { transform: translateX(20px); }

/* ── MODAL ───────────────────────────────── */
.modal-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,.5); z-index: 1000;
  align-items: center; justify-content: center; padding: 16px;
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--card); border-radius: 12px;
  padding: 28px; width: 100%; max-width: 520px;
  max-height: 90vh; overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,.3);
  animation: modalIn .2s ease;
}
.modal-lg { max-width: 720px; }
@keyframes modalIn { from { opacity:0; transform: scale(.95) } to { opacity:1; transform: scale(1) } }
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 20px; padding-bottom: 16px; border-bottom: 1px solid var(--border);
}
.modal-header h3 { font-size: 17px; font-weight: 700; }
.modal-close {
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--bg); border: none; cursor: pointer;
  font-size: 16px; display: flex; align-items: center; justify-content: center;
  color: var(--text-muted); transition: all .15s;
}
.modal-close:hover { background: var(--border); color: var(--text); }
.modal-footer {
  display: flex; gap: 10px; justify-content: flex-end;
  margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--border);
}

/* ── ACTIVITY FEED ────────────────────────── */
.activity-list { display: flex; flex-direction: column; gap: 0; }
.activity-item {
  display: flex; gap: 12px; align-items: flex-start;
  padding: 12px 0; border-bottom: 1px solid var(--border);
}
.activity-item:last-child { border-bottom: none; }
.activity-icon {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--bg); display: flex; align-items: center;
  justify-content: center; font-size: 16px; flex-shrink: 0;
}
.activity-text { font-size: 13px; color: var(--text); line-height: 1.4; }
.activity-time { font-size: 11px; color: var(--text-muted); margin-top: 2px; }

/* ── SKT ALERTS ───────────────────────────── */
.skt-list { display: flex; flex-direction: column; gap: 8px; }
.skt-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px; border-radius: var(--radius);
  background: #fffbeb; border: 1px solid #fef3c7;
}
.skt-item.critical { background: #fef2f2; border-color: #fecaca; }
.skt-item-name { font-size: 13px; font-weight: 600; }
.skt-item-date { font-size: 12px; color: var(--text-muted); }

/* ── PAGINATION ───────────────────────────── */
.pagination { display: flex; align-items: center; justify-content: space-between; margin-top: 16px; }
.pagination-info { font-size: 13px; color: var(--text-muted); }
.pagination-btns { display: flex; gap: 6px; }
.page-btn {
  padding: 6px 12px; border: 1.5px solid var(--border); border-radius: var(--radius);
  background: var(--card); font-size: 13px; font-weight: 600; cursor: pointer;
  transition: all .15s;
}
.page-btn:hover:not(:disabled) { border-color: var(--primary); color: var(--primary); }
.page-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.page-btn:disabled { opacity: .4; cursor: not-allowed; }

/* ── CHART WRAPPER ────────────────────────── */
.chart-wrap { position: relative; height: 240px; }
.period-select {
  padding: 5px 10px; border: 1.5px solid var(--border); border-radius: var(--radius);
  font-size: 12px; font-weight: 600; background: var(--card); cursor: pointer;
}

/* ── NOTIFICATION HISTORY ─────────────────── */
.notif-status-sent { color: var(--success); font-weight: 600; }
.notif-status-failed { color: var(--danger); font-weight: 600; }
.notif-status-queued { color: var(--warning); font-weight: 600; }

/* ── SUPPORT TICKET ───────────────────────── */
.ticket-detail { background: var(--bg); border-radius: var(--radius); padding: 14px; margin-bottom: 14px; }
.ticket-reply-area { margin-top: 10px; }

/* ── EMPTY STATE ─────────────────────────── */
.empty-state {
  text-align: center; padding: 48px 24px; color: var(--text-muted);
}
.empty-state .empty-icon { font-size: 40px; margin-bottom: 12px; }
.empty-state p { font-size: 14px; }

/* ── TOAST ───────────────────────────────── */
#toast-container {
  position: fixed; bottom: 24px; right: 24px; z-index: 9999;
  display: flex; flex-direction: column; gap: 8px;
}
.toast {
  padding: 12px 18px; border-radius: var(--radius); background: #1e293b;
  color: #fff; font-size: 13px; font-weight: 500; min-width: 240px;
  box-shadow: var(--shadow-md); animation: slideIn .25s ease;
}
.toast.success { background: #166534; }
.toast.error { background: #991b1b; }
.toast.info { background: #1e40af; }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* ── RESPONSIVE ───────────────────────────── */
@media (max-width: 768px) {
  .sidebar { width: 0; }
  .main { margin-left: 0; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
}
