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

:root {
  --bg: #080c18;
  --surface: #0f1623;
  --surface2: #141d2e;
  --border: #1a2540;
  --accent: #00d4ff;
  --accent2: #7c3aed;
  --accent-dim: rgba(0,212,255,0.1);
  --text: #e2e8f0;
  --text-muted: #64748b;
  --success: #10b981;
  --warning: #f59e0b;
  --error: #ef4444;
  --sidebar-w: 230px;
}

body { font-family: 'DM Sans', sans-serif; background: var(--bg); color: var(--text); min-height: 100vh; }

/* ─── Layout ─── */
#app { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  min-height: 100vh;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
}

.sidebar-logo {
  font-family: 'Space Mono', monospace;
  font-size: 18px;
  font-weight: 700;
  color: var(--accent);
  padding: 24px 20px 20px;
  border-bottom: 1px solid var(--border);
  letter-spacing: -0.5px;
}
.sidebar-logo span { color: var(--accent2); }

.sidebar-nav { flex: 1; padding: 16px 12px; display: flex; flex-direction: column; gap: 4px; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 8px;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  transition: all .15s;
  cursor: pointer;
}
.nav-item svg { width: 18px; height: 18px; flex-shrink: 0; }
.nav-item:hover { background: var(--surface2); color: var(--text); }
.nav-item.active { background: var(--accent-dim); color: var(--accent); border: 1px solid rgba(0,212,255,0.15); }

.sidebar-footer {
  padding: 16px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
}
.user-info { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }
.user-avatar {
  width: 32px; height: 32px;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700; color: #fff; flex-shrink: 0;
}
.user-name { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: 11px; color: var(--text-muted); }
.btn-logout {
  background: none; border: none; cursor: pointer;
  color: var(--text-muted); padding: 6px; border-radius: 6px;
  display: flex; transition: color .15s, background .15s;
}
.btn-logout:hover { color: var(--error); background: rgba(239,68,68,.1); }

.main-content { margin-left: var(--sidebar-w); flex: 1; padding: 32px; min-height: 100vh; }

/* ─── Page Header ─── */
.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 28px; }
.page-title { font-size: 26px; font-weight: 600; letter-spacing: -.5px; }
.page-title span { color: var(--accent); }

/* ─── Stats Grid ─── */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; margin-bottom: 28px; }
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  position: relative;
  overflow: hidden;
}
.stat-card::after {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0; height: 2px;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
}
.stat-label { font-size: 12px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .08em; margin-bottom: 8px; }
.stat-value { font-size: 28px; font-weight: 600; font-family: 'Space Mono', monospace; }
.stat-value.accent { color: var(--accent); }

/* ─── Table ─── */
.table-card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
.table-toolbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid var(--border); gap: 12px; flex-wrap: wrap;
}
.search-input {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-family: 'DM Sans', sans-serif;
  font-size: 14px;
  padding: 8px 14px;
  outline: none;
  width: 240px;
  transition: border-color .2s;
}
.search-input:focus { border-color: var(--accent); }
.search-input::placeholder { color: var(--text-muted); }

table { width: 100%; border-collapse: collapse; }
thead tr { border-bottom: 1px solid var(--border); }
th { text-align: left; padding: 12px 20px; font-size: 11px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: .08em; white-space: nowrap; }
td { padding: 14px 20px; font-size: 14px; border-bottom: 1px solid rgba(26,37,64,.5); vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: var(--surface2); }
.empty-row td { text-align: center; color: var(--text-muted); padding: 40px; font-size: 14px; }

/* ─── Badges ─── */
.badge {
  display: inline-flex; align-items: center;
  padding: 3px 10px; border-radius: 20px;
  font-size: 12px; font-weight: 500; white-space: nowrap;
}
.badge-success { background: rgba(16,185,129,.15); color: var(--success); }
.badge-warning { background: rgba(245,158,11,.15); color: var(--warning); }
.badge-error { background: rgba(239,68,68,.15); color: var(--error); }
.badge-info { background: rgba(0,212,255,.12); color: var(--accent); }

/* ─── Buttons ─── */
.btn-primary {
  background: var(--accent);
  color: #000;
  border: none;
  border-radius: 8px;
  font-family: 'DM Sans', sans-serif;
  font-size: 14px;
  font-weight: 600;
  padding: 9px 18px;
  cursor: pointer;
  transition: opacity .15s;
  display: inline-flex; align-items: center; gap: 6px;
  white-space: nowrap;
}
.btn-primary:hover { opacity: .88; }

.btn-sm {
  padding: 5px 10px; font-size: 12px; border-radius: 6px;
  border: none; cursor: pointer; font-family: 'DM Sans', sans-serif;
  font-weight: 500; transition: opacity .15s; display: inline-flex; align-items: center; gap: 4px;
}
.btn-edit { background: rgba(0,212,255,.12); color: var(--accent); }
.btn-delete { background: rgba(239,68,68,.12); color: var(--error); }
.btn-edit:hover, .btn-delete:hover { opacity: .75; }
.action-btns { display: flex; gap: 6px; }

/* ─── Modal ─── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.7);
  backdrop-filter: blur(4px);
  z-index: 200;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.modal-overlay.hidden { display: none; }
.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  width: 100%; max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,.5);
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 24px; border-bottom: 1px solid var(--border);
  position: sticky; top: 0; background: var(--surface); z-index: 1;
}
.modal-header h3 { font-size: 16px; font-weight: 600; }
.modal-close {
  background: none; border: none; color: var(--text-muted);
  font-size: 24px; cursor: pointer; line-height: 1;
  transition: color .15s;
}
.modal-close:hover { color: var(--text); }
.modal-body { padding: 24px; }

/* ─── Forms ─── */
.form-grid { display: grid; gap: 16px; }
.form-grid-2 { grid-template-columns: 1fr 1fr; }
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group.full { grid-column: 1 / -1; }
.form-label { font-size: 12px; font-weight: 500; color: var(--text-muted); text-transform: uppercase; letter-spacing: .07em; }
.form-control {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-family: 'DM Sans', sans-serif;
  font-size: 14px;
  padding: 10px 14px;
  outline: none;
  transition: border-color .2s, box-shadow .2s;
  width: 100%;
}
.form-control:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(0,212,255,.08); }
.form-control::placeholder { color: var(--text-muted); }
select.form-control { cursor: pointer; }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 8px; }
.btn-cancel {
  background: var(--surface2); color: var(--text); border: 1px solid var(--border);
  border-radius: 8px; font-family: 'DM Sans', sans-serif; font-size: 14px;
  padding: 9px 18px; cursor: pointer; transition: opacity .15s;
}
.btn-cancel:hover { opacity: .8; }

/* ─── Tags input ─── */
.tags-container {
  background: var(--bg); border: 1px solid var(--border); border-radius: 8px;
  padding: 6px 10px; display: flex; flex-wrap: wrap; gap: 6px; cursor: text; min-height: 44px;
  transition: border-color .2s;
}
.tags-container:focus-within { border-color: var(--accent); }
.tag-item {
  background: var(--accent-dim); color: var(--accent); border-radius: 4px;
  padding: 3px 8px; font-size: 13px; display: flex; align-items: center; gap: 4px;
}
.tag-remove { cursor: pointer; opacity: .7; font-size: 16px; line-height: 1; }
.tag-remove:hover { opacity: 1; }
.tags-input { background: none; border: none; outline: none; color: var(--text); font-size: 14px; font-family: 'DM Sans', sans-serif; min-width: 120px; flex: 1; }

/* ─── Toast ─── */
.toast {
  position: fixed; bottom: 24px; right: 24px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; padding: 12px 18px; font-size: 14px;
  box-shadow: 0 8px 32px rgba(0,0,0,.4);
  transform: translateY(80px); opacity: 0;
  transition: transform .3s, opacity .3s;
  z-index: 999; max-width: 320px;
}
.toast.show { transform: translateY(0); opacity: 1; }
.toast.success { border-color: rgba(16,185,129,.3); color: var(--success); }
.toast.error { border-color: rgba(239,68,68,.3); color: var(--error); }

/* ─── Dashboard widgets ─── */
.dash-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-top: 24px; }
.widget {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; padding: 20px;
}
.widget-title { font-size: 13px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: .07em; margin-bottom: 16px; }
.widget-row { display: flex; align-items: center; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid rgba(26,37,64,.5); font-size: 14px; }
.widget-row:last-child { border-bottom: none; }
.widget-row-label { color: var(--text-muted); font-size: 13px; }
