:root {
  /* Light SaaS palette */
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface2: #f3f4f6;
  --surface3: #e9ecef;
  --border: #e8eaed;
  --border2: #d7dbe0;
  --text: #1a1d24;
  --muted: #6b7280;
  --accent: #4f46e5;       /* indigo */
  --accent2: #6366f1;
  --accent-soft: rgba(79,70,229,0.10);
  --green: #16a34a;
  --amber: #d97706;
  --red: #dc2626;
  --coral: #e11d48;
  --teal: #0d9488;
  --purple: #7c3aed;
  --font-head: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --r: 9px;
  --r-lg: 14px;
  --shadow-sm: 0 1px 2px rgba(16,24,40,0.05);
  --shadow: 0 1px 3px rgba(16,24,40,0.08), 0 1px 2px rgba(16,24,40,0.05);
  --shadow-md: 0 8px 24px rgba(16,24,40,0.10), 0 2px 6px rgba(16,24,40,0.06);
}
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body { background: var(--bg); color: var(--text); font-family: var(--font-body); font-size: 14px; line-height: 1.5; min-height: 100vh; -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; }
body.app { display: flex; }

/* SIDEBAR */
#sidebar {
  width: 232px; min-height: 100vh; background: var(--surface);
  border-right: 1px solid var(--border); display: flex; flex-direction: column;
  position: fixed; top: 0; left: 0; z-index: 100;
}
.logo { padding: 22px 20px 18px; border-bottom: 1px solid var(--border); }
.logo-name { font-family: var(--font-head); font-size: 17px; font-weight: 800; color: var(--text); letter-spacing: -0.02em; display: flex; align-items: center; }
.logo-tag { font-size: 10px; color: var(--muted); margin-top: 3px; letter-spacing: 0.06em; text-transform: uppercase; font-weight: 600; }
.logo-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--accent); margin-right: 8px; }
nav { flex: 1; padding: 12px 12px; }
.nav-section { padding: 14px 8px 6px; font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.07em; font-weight: 700; }
.nav-item {
  display: flex; align-items: center; gap: 11px; padding: 9px 12px; margin: 1px 0; border-radius: 8px;
  color: #4b5563; cursor: pointer; font-size: 13px; font-weight: 500; transition: all 0.13s;
}
.nav-item:hover { color: var(--text); background: var(--surface2); }
.nav-item.active { color: var(--accent); background: var(--accent-soft); font-weight: 600; }
.nav-item .icon { font-size: 15px; width: 18px; text-align: center; }
.nav-item.hidden { display: none; }
.nav-badge { margin-left: auto; background: var(--red); color: #fff; font-size: 10px; font-weight: 700; padding: 1px 7px; border-radius: 10px; }
.nav-badge.green { background: var(--green); color: #fff; }
.nav-badge.amber { background: var(--amber); color: #fff; }
.sidebar-footer { padding: 14px 18px; border-top: 1px solid var(--border); font-size: 12px; color: var(--muted); }
.user-row { display: flex; align-items: center; gap: 10px; }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: linear-gradient(135deg, var(--accent), var(--accent2)); display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 700; color: #fff; }

/* MAIN */
#main { margin-left: 232px; flex: 1; display: flex; flex-direction: column; min-height: 100vh; }
.topbar { background: rgba(255,255,255,0.85); backdrop-filter: saturate(180%) blur(8px); border-bottom: 1px solid var(--border); padding: 13px 28px; display: flex; align-items: center; justify-content: space-between; position: sticky; top: 0; z-index: 50; }
.topbar-title { font-family: var(--font-head); font-size: 19px; font-weight: 700; letter-spacing: -0.02em; }
.topbar-actions { display: flex; gap: 10px; align-items: center; }
.btn { padding: 8px 15px; border-radius: var(--r); font-size: 13px; font-weight: 600; cursor: pointer; border: 1px solid transparent; font-family: var(--font-body); transition: all 0.13s; }
.btn-primary { background: var(--accent); color: #fff; box-shadow: var(--shadow-sm); }
.btn-primary:hover { background: #4338ca; }
.btn-secondary { background: var(--surface); color: var(--text); border: 1px solid var(--border2); }
.btn-secondary:hover { background: var(--surface2); border-color: #c4cad1; }
.btn-danger { background: #fff; color: var(--red); border: 1px solid rgba(220,38,38,0.3); }
.btn-danger:hover { background: rgba(220,38,38,0.06); }
.search-box { background: var(--surface2); border: 1px solid var(--border); border-radius: var(--r); padding: 8px 12px 8px 32px; color: var(--text); font-family: var(--font-body); font-size: 13px; width: 230px; }
.search-box::placeholder { color: var(--muted); }
.search-box:focus { outline: none; border-color: var(--accent); background: #fff; box-shadow: 0 0 0 3px var(--accent-soft); }
.search-wrap { position: relative; }
.search-wrap::before { content: '🔍'; position: absolute; left: 10px; top: 50%; transform: translateY(-50%); font-size: 12px; opacity: 0.6; pointer-events: none; }

.content { padding: 26px 28px; flex: 1; }
.page { display: none; }
.page.active { display: block; }

/* CARDS */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); padding: 20px; box-shadow: var(--shadow-sm); }
.card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.card-title { font-family: var(--font-head); font-size: 15px; font-weight: 700; letter-spacing: -0.01em; }

/* STAT GRID */
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 16px; }
.stat-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); padding: 18px 20px; position: relative; overflow: hidden; box-shadow: var(--shadow-sm); transition: box-shadow 0.15s; }
.stat-card:hover { box-shadow: var(--shadow); }
.stat-card::before { content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px; }
.stat-card.blue::before { background: var(--accent); }
.stat-card.green::before { background: var(--green); }
.stat-card.amber::before { background: var(--amber); }
.stat-card.red::before { background: var(--red); }
.stat-card.purple::before { background: var(--purple); }
.stat-card.teal::before { background: var(--teal); }
.stat-label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; font-weight: 600; margin-bottom: 8px; }
.stat-value { font-family: var(--font-head); font-size: 28px; font-weight: 700; letter-spacing: -0.02em; }
.stat-sub { font-size: 11px; color: var(--muted); margin-top: 5px; }
.stat-icon { position: absolute; right: 16px; top: 16px; font-size: 22px; opacity: 0.5; }

/* TABLE */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; padding: 10px 12px; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; font-weight: 600; border-bottom: 1px solid var(--border); background: var(--surface2); }
th:first-child { border-top-left-radius: 8px; }
th:last-child { border-top-right-radius: 8px; }
td { padding: 12px; border-bottom: 1px solid var(--border); font-size: 13px; vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: var(--surface2); }
.badge { display: inline-flex; align-items: center; padding: 3px 9px; border-radius: 6px; font-size: 11px; font-weight: 600; line-height: 1.4; }
.badge-green { background: rgba(22,163,74,0.10); color: #15803d; }
.badge-red { background: rgba(220,38,38,0.10); color: #b91c1c; }
.badge-amber { background: rgba(217,119,6,0.12); color: #b45309; }
.badge-blue { background: var(--accent-soft); color: #4338ca; }
.badge-purple { background: rgba(124,58,237,0.10); color: #6d28d9; }
.badge-teal { background: rgba(13,148,136,0.12); color: #0f766e; }
.badge-coral { background: rgba(225,29,72,0.10); color: #be123c; }
.badge-gray { background: #eef0f2; color: #4b5563; }

/* GRID */
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }
.mt16 { margin-top: 16px; }
.mt20 { margin-top: 20px; }
.mb16 { margin-bottom: 16px; }

/* FORM */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; }
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group.full { grid-column: 1 / -1; }
label { font-size: 12px; color: #374151; font-weight: 600; }
input, select, textarea {
  background: var(--surface); border: 1px solid var(--border2);
  border-radius: var(--r); padding: 9px 12px; color: var(--text);
  font-family: var(--font-body); font-size: 13px; width: 100%; transition: border 0.13s, box-shadow 0.13s;
}
input::placeholder, textarea::placeholder { color: #9aa1ac; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
textarea { resize: vertical; min-height: 80px; }
select option { background: var(--surface); }
.form-actions { display: flex; gap: 10px; margin-top: 18px; }

/* PROGRESS */
.progress-bar { background: var(--surface3); border-radius: 100px; height: 7px; overflow: hidden; }
.progress-fill { height: 100%; border-radius: 100px; transition: width 0.5s; }

/* MODAL */
#modal-overlay { display: none; position: fixed; inset: 0; background: rgba(17,24,39,0.45); backdrop-filter: blur(2px); z-index: 200; align-items: center; justify-content: center; }
#modal-overlay.open { display: flex; }
.modal { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); padding: 24px; width: 560px; max-width: calc(100vw - 32px); max-height: 86vh; overflow-y: auto; box-shadow: var(--shadow-md); }
.modal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.modal-title { font-family: var(--font-head); font-size: 16px; font-weight: 700; letter-spacing: -0.01em; }
.close-btn { background: none; border: none; color: var(--muted); cursor: pointer; font-size: 20px; line-height: 1; padding: 2px 6px; border-radius: 6px; }
.close-btn:hover { color: var(--text); background: var(--surface2); }

/* NOTIFICATION BELL */
.notif-btn { position: relative; background: var(--surface); border: 1px solid var(--border2); border-radius: var(--r); padding: 7px 10px; cursor: pointer; font-size: 15px; }
.notif-btn:hover { background: var(--surface2); }
.notif-dot { position: absolute; top: 5px; right: 5px; width: 7px; height: 7px; background: var(--red); border-radius: 50%; border: 2px solid var(--surface); }

/* CHART BARS */
.bar-chart { display: flex; align-items: flex-end; gap: 8px; height: 100px; }
.bar { flex: 1; border-radius: 5px 5px 0 0; transition: opacity 0.15s; min-width: 20px; }
.bar:hover { opacity: 0.82; }
.bar-labels { display: flex; gap: 8px; margin-top: 6px; }
.bar-label { flex: 1; text-align: center; font-size: 10px; color: var(--muted); min-width: 20px; }

/* DONUT */
.donut-wrap { display: flex; align-items: center; gap: 20px; }
.donut-legend { display: flex; flex-direction: column; gap: 8px; }
.donut-item { display: flex; align-items: center; gap: 8px; font-size: 12px; }
.donut-dot { width: 10px; height: 10px; border-radius: 3px; flex-shrink: 0; }

/* TICKET CARDS */
.ticket-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); padding: 14px 16px; margin-bottom: 10px; transition: border-color 0.13s, box-shadow 0.13s; }
.ticket-card:hover { border-color: var(--border2); box-shadow: var(--shadow-sm); }
.ticket-meta { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }

/* QUICK STAT ROW */
.qs-row { display: flex; align-items: center; justify-content: space-between; padding: 11px 0; border-bottom: 1px solid var(--border); gap: 10px; }
.qs-row:last-child { border-bottom: none; }
.qs-label { font-size: 13px; color: #4b5563; }
.qs-value { font-size: 13px; font-weight: 600; }

/* EMPTY STATE */
.empty-state { text-align: center; padding: 40px; color: var(--muted); }
.empty-state .emoji { font-size: 34px; margin-bottom: 10px; opacity: 0.7; }
.empty-state p { font-size: 13px; }

/* TABS */
.tabs { display: inline-flex; gap: 2px; background: var(--surface2); padding: 4px; border-radius: var(--r); margin-bottom: 18px; }
.tab { padding: 7px 16px; border-radius: 7px; font-size: 13px; font-weight: 500; cursor: pointer; color: var(--muted); transition: all 0.13s; }
.tab.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); font-weight: 600; }
.tab:hover:not(.active) { color: var(--text); }

/* row action buttons */
.row-actions { display: flex; gap: 6px; }
.icon-btn { font-size: 11px; padding: 5px 10px; }

/* Scrollbar */
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd2da; border-radius: 6px; border: 2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: #aeb6c1; }

/* ANIMATIONS */
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }
.page.active { animation: fadeIn 0.2s ease; }

/* Toast */
#toast { position: fixed; bottom: 24px; right: 24px; background: var(--surface); border: 1px solid var(--border2); border-left: 3px solid var(--green); color: var(--text); padding: 12px 18px; border-radius: var(--r); font-size: 13px; font-weight: 600; z-index: 999; display: none; box-shadow: var(--shadow-md); }
#toast.error { border-left-color: var(--red); }

/* LOGIN */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px;
  background: radial-gradient(1200px 600px at 50% -10%, rgba(79,70,229,0.08), transparent 60%), var(--bg); }
.login-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); padding: 34px; width: 380px; box-shadow: var(--shadow-md); }
.login-logo { font-family: var(--font-head); font-size: 24px; font-weight: 800; margin-bottom: 4px; letter-spacing: -0.02em; display: flex; align-items: center; }
.login-sub { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.07em; font-weight: 600; margin-bottom: 26px; }
.login-field { margin-bottom: 15px; display: flex; flex-direction: column; gap: 6px; }
.login-error { color: var(--red); font-size: 12px; margin-bottom: 12px; min-height: 16px; }
.login-hint { font-size: 11px; color: var(--muted); margin-top: 18px; text-align: center; }
