:root {
  /* Design tokens — SHA Building Parking Management System */
  --primary: #16A34A;
  --primary-dark: #15803D;
  --dark-green: #14532D;
  --accent: #F59E0B;
  --success: #22C55E;
  --info: #2563EB;
  --danger: #DC2626;
  --warning: #D97706;
  --bg: #F8FAFC;
  --surface: #FFFFFF;
  --border: #E5E7EB;
  --text: #1F2937;
  --muted: #6B7280;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.05);
  --shadow-lg: 0 8px 24px rgba(16, 24, 40, 0.08);
  --sidebar-w: 248px;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  font-size: 14px;
  font-weight: 400;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-dark); }

h1, h2, h3, h4 { font-weight: 700; margin: 0; }

/* ---------------------------------------------------------------------
   App shell
--------------------------------------------------------------------- */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  background: var(--dark-green);
  color: #E7F5EC;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 50;
  transition: width 0.18s ease, transform 0.18s ease;
  overflow: hidden;
}

.brand {
  display: flex; align-items: center; gap: 10px;
  padding: 18px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.10);
}

.brand-mark {
  width: 38px; height: 38px; flex-shrink: 0;
  background: var(--primary);
  border-radius: 10px;
  display: grid; place-items: center;
  color: #fff;
}

.brand-text { display: flex; flex-direction: column; line-height: 1.25; }
.brand-text strong { font-size: 13.5px; color: #fff; white-space: nowrap; }
.brand-text span { font-size: 11px; color: rgba(255,255,255,0.65); white-space: nowrap; }

.sidebar-scroll { flex: 1; overflow-y: auto; padding: 12px 10px 24px; }
.sidebar-scroll::-webkit-scrollbar { width: 6px; }
.sidebar-scroll::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.18); border-radius: 3px; }

.nav-group-label {
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.45);
  padding: 16px 12px 6px;
}
.nav-list { display: flex; flex-direction: column; gap: 2px; }

.nav-item {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 12px;
  border-radius: 8px;
  color: rgba(255,255,255,0.82);
  font-weight: 500;
  transition: background 0.12s ease, color 0.12s ease;
}
.nav-item:hover { background: rgba(255,255,255,0.08); color: #fff; }
.nav-item.is-active { background: var(--primary); color: #fff; }
.nav-icon { flex-shrink: 0; opacity: 0.9; }
.nav-item span { white-space: nowrap; }

.sidebar-footer { padding: 10px; border-top: 1px solid rgba(255,255,255,0.10); }

.collapse-btn {
  width: 100%;
  background: transparent; border: none; cursor: pointer;
  color: rgba(255,255,255,0.6); border-radius: 8px;
  padding: 8px; display: flex; align-items: center; justify-content: center;
}
.collapse-btn:hover { background: rgba(255,255,255,0.08); color: #fff; }

/* Collapsed (desktop) */
.sidebar.is-collapsed { width: 68px; }
.sidebar.is-collapsed .brand-text,
.sidebar.is-collapsed .nav-group-label,
.sidebar.is-collapsed .nav-item span,
.sidebar.is-collapsed .collapse-btn svg { display: none; }
.sidebar.is-collapsed .nav-item { justify-content: center; padding: 10px; }
.sidebar.is-collapsed .brand { justify-content: center; padding: 16px 0; }

/* ---------------------------------------------------------------------
   Main
--------------------------------------------------------------------- */
.main { flex: 1; margin-left: var(--sidebar-w); display: flex; flex-direction: column; min-width: 0; transition: margin-left 0.18s ease; }
.sidebar.is-collapsed ~ .main { margin-left: 68px; }

.topbar {
  height: 60px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 12px;
  padding: 0 20px;
  position: sticky; top: 0; z-index: 40;
}
.topbar-title { font-weight: 600; font-size: 15px; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-right { display: flex; align-items: center; gap: 6px; }

.icon-btn {
  width: 36px; height: 36px;
  display: grid; place-items: center;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 8px;
  color: var(--muted);
  cursor: pointer;
}
.icon-btn:hover { color: var(--text); border-color: #CBD5E1; background: #F8FAFC; }

.user-chip { display: flex; align-items: center; gap: 9px; padding: 0 10px; }
.avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--dark-green); color: #fff;
  display: grid; place-items: center; font-weight: 600; font-size: 14px;
}
.user-meta { display: flex; flex-direction: column; line-height: 1.2; }
.user-meta strong { font-size: 12.5px; }
.user-meta span { font-size: 11px; color: var(--muted); }

.content { padding: 24px; flex: 1; }
.footer {
  padding: 16px 24px;
  color: var(--muted); font-size: 12px;
  border-top: 1px solid var(--border);
}

/* ---------------------------------------------------------------------
   Page header
--------------------------------------------------------------------- */
.page-header {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 16px;
  margin-bottom: 20px; flex-wrap: wrap;
}
.page-title { font-size: 20px; font-weight: 700; }
.page-subtitle { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
.page-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* ---------------------------------------------------------------------
   Cards & stats
--------------------------------------------------------------------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.card + .card { }
.card-pad { padding: 18px; }
.card-title { font-size: 14px; font-weight: 600; margin-bottom: 12px; }
.card-header { padding: 14px 18px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.card-body { padding: 18px; }
.card-header + .card-body { padding-top: 16px; }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; margin-bottom: 20px; }
.stat-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px;
  display: flex; align-items: flex-start; gap: 13px;
  box-shadow: var(--shadow);
}
.stat-icon {
  width: 42px; height: 42px; border-radius: 10px; flex-shrink: 0;
  display: grid; place-items: center; color: #fff;
}
.stat-icon.green { background: var(--primary); }
.stat-icon.dark  { background: var(--dark-green); }
.stat-icon.amber { background: var(--accent); }
.stat-icon.blue  { background: var(--info); }
.stat-icon.red   { background: var(--danger); }
.stat-icon.gray  { background: #64748B; }
.stat-value { font-size: 20px; font-weight: 700; line-height: 1.1; }
.stat-label { font-size: 12px; color: var(--muted); margin-top: 2px; }
.stat-sub { font-size: 11.5px; color: var(--muted); margin-top: 3px; }

/* ---------------------------------------------------------------------
   Tables
--------------------------------------------------------------------- */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data th {
  text-align: left; font-weight: 600; font-size: 11.5px;
  text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted);
  background: #F9FAFB; padding: 10px 12px; border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
table.data td { padding: 11px 12px; border-bottom: 1px solid #F1F5F9; vertical-align: middle; }
table.data tbody tr:hover { background: #F8FAFC; }
table.data tbody tr:last-child td { border-bottom: 0; }

.badge {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11.5px; font-weight: 600;
  padding: 3px 10px; border-radius: 999px; line-height: 1.4; white-space: nowrap;
}
.badge-green  { background: #F0FDF4; color: #15803D; }
.badge-red    { background: #FEF2F2; color: #B91C1C; }
.badge-amber  { background: #FFFBEB; color: #B45309; }
.badge-blue   { background: #EFF6FF; color: #1D4ED8; }
.badge-gray   { background: #F3F4F6; color: #4B5563; }
.badge-purple { background: #F5F3FF; color: #6D28D9; }

/* ---------------------------------------------------------------------
   Forms
--------------------------------------------------------------------- */
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; }
.form-group { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.form-group label { font-size: 12.5px; font-weight: 500; color: var(--text); }
.form-group .hint { font-size: 11.5px; color: var(--muted); }
.form-group.span-2 { grid-column: span 2; }

input[type=text], input[type=email], input[type=password], input[type=number],
input[type=date], input[type=datetime-local], input[type=tel], select, textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid #D1D5DB;
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--text);
  font-family: inherit; font-size: 13.5px;
  transition: border-color 0.12s ease, box-shadow 0.12s ease;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(22, 163, 74, 0.15);
}
input.invalid { border-color: var(--danger); }
.readonly-field, input[readonly] { background: #F9FAFB; color: var(--muted); }

.check-list { display: flex; flex-direction: column; gap: 8px; }
.check-item { display: flex; align-items: flex-start; gap: 8px; font-size: 13px; }
.check-item input { margin-top: 2px; width: auto; }

/* ---------------------------------------------------------------------
   Buttons
--------------------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  font-family: inherit; font-weight: 600; font-size: 13px;
  padding: 9px 16px; border-radius: var(--radius-sm);
  border: 1px solid transparent; cursor: pointer;
  transition: background 0.12s ease, border-color 0.12s ease, color 0.12s ease;
  text-decoration: none; white-space: nowrap;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); color: #fff; }
.btn-dark { background: var(--dark-green); color: #fff; }
.btn-dark:hover { background: #0F3F23; color: #fff; }
.btn-accent { background: var(--accent); color: #fff; }
.btn-accent:hover { background: #D97706; color: #fff; }
.btn-soft { background: #F0FDF4; color: #15803D; border-color: #BBF7D0; }
.btn-soft:hover { background: #DCFCE7; }
.btn-outline { background: #fff; color: var(--text); border-color: #D1D5DB; }
.btn-outline:hover { background: #F9FAFB; border-color: #9CA3AF; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #B91C1C; color: #fff; }
.btn-danger-ghost { background: #FEF2F2; color: #B91C1C; border-color: #FECACA; }
.btn-danger-ghost:hover { background: #FEE2E2; }
.btn-sm { padding: 6px 11px; font-size: 12px; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: 0.55; cursor: not-allowed; }

.link-btn { background: none; border: none; color: var(--primary); cursor: pointer; font-weight: 600; font-size: 12.5px; padding: 2px; }
.link-btn:hover { text-decoration: underline; }
.link-btn.danger { color: var(--danger); }

/* ---------------------------------------------------------------------
   Alerts / flash
--------------------------------------------------------------------- */
.alert {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 11px 14px; border-radius: var(--radius-sm);
  margin-bottom: 16px; font-size: 13px; font-weight: 500;
}
.alert-ok   { background: #F0FDF4; color: #14532D; border: 1px solid #BBF7D0; }
.alert-bad  { background: #FEF2F2; color: #991B1B; border: 1px solid #FECACA; }
.alert-warn { background: #FFFBEB; color: #92400E; border: 1px solid #FDE68A; }
.alert-info { background: #EFF6FF; color: #1E40AF; border: 1px solid #BFDBFE; }
.alert-close { background: none; border: none; font-size: 18px; cursor: pointer; color: inherit; opacity: 0.6; line-height: 1; }
.alert-close:hover { opacity: 1; }

/* ---------------------------------------------------------------------
   Empty states
--------------------------------------------------------------------- */
.empty-state { text-align: center; padding: 48px 16px; }
.empty-icon { font-size: 40px; margin-bottom: 12px; }
.empty-title { font-size: 16px; font-weight: 600; margin-bottom: 6px; }
.empty-text { color: var(--muted); font-size: 13px; margin: 0 0 16px; }

/* ---------------------------------------------------------------------
   Modals
--------------------------------------------------------------------- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(15, 23, 42, 0.5);
  display: none; align-items: center; justify-content: center; z-index: 100; padding: 20px;
}
.modal-backdrop.show { display: flex; }
.modal {
  background: #fff; border-radius: var(--radius); box-shadow: var(--shadow-lg);
  width: 100%; max-width: 520px; max-height: 90vh; overflow-y: auto;
}
.modal-head { padding: 16px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.modal-head h3 { font-size: 15px; }
.modal-body { padding: 20px; }
.modal-foot { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; }

/* ---------------------------------------------------------------------
   Slot map
--------------------------------------------------------------------- */
.slot-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 12px; }
.slot {
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 12px; text-align: center; background: #fff;
}
.slot-available { border-color: #BBF7D0; background: #F0FDF4; }
.slot-occupied  { border-color: #FECACA; background: #FEF2F2; }
.slot-maintenance { border-color: #FDE68A; background: #FFFBEB; }
.slot-id { font-weight: 700; font-size: 14px; }
.slot-state { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.03em; margin-top: 3px; }
.slot-plate { font-size: 11.5px; color: var(--muted); margin-top: 4px; font-weight: 600; }

/* ---------------------------------------------------------------------
   Misc / utilities
--------------------------------------------------------------------- */
.flex { display: flex; align-items: center; gap: 8px; }
.flex-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.flex-1 { flex: 1; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; }
.mt-4 { margin-top: 16px; }
.mt-2 { margin-top: 8px; }
.mb-2 { margin-bottom: 8px; }
.text-muted { color: var(--muted); }
.text-danger { color: var(--danger); }
.text-success { color: #15803D; }
.text-sm { font-size: 12.5px; }
.mono { font-family: 'Cascadia Code', 'Consolas', monospace; }
.pill { display: inline-block; padding: 2px 9px; border-radius: 999px; background: #F3F4F6; color: #4B5563; font-size: 11.5px; font-weight: 600; }

.bar { height: 8px; background: #F1F5F9; border-radius: 999px; overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--primary); border-radius: 999px; }

.kpi { font-size: 22px; font-weight: 700; }
.summary-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; }
.summary-box { background: #F9FAFB; border: 1px solid #F1F5F9; border-radius: var(--radius-sm); padding: 12px; text-align: center; }
.summary-box .sm-label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.summary-box .sm-value { font-size: 17px; font-weight: 700; margin-top: 3px; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 18px; }
.tab {
  padding: 9px 14px; font-size: 13px; font-weight: 600; color: var(--muted);
  border-bottom: 2px solid transparent; margin-bottom: -1px; cursor: pointer; background: none; border-top: 0; border-left: 0; border-right: 0;
}
.tab.is-active { color: var(--primary); border-bottom-color: var(--primary); }
.tab:hover { color: var(--text); }

.pagination { display: flex; gap: 6px; align-items: center; justify-content: flex-end; margin-top: 14px; font-size: 12.5px; }
.pagination a, .pagination span {
  min-width: 30px; height: 30px; display: inline-grid; place-items: center;
  border: 1px solid var(--border); border-radius: 6px; padding: 0 6px;
  color: var(--text); background: #fff; font-weight: 500;
}
.pagination a:hover { border-color: var(--primary); color: var(--primary); }
.pagination .current { background: var(--primary); color: #fff; border-color: var(--primary); }

.print-hide { }
@media print {
  .sidebar, .topbar, .footer, .no-print { display: none !important; }
  .main { margin-left: 0; }
  .content { padding: 0; }
  body { background: #fff; }
  .card { box-shadow: none; }
}

/* ---------------------------------------------------------------------
   Login
--------------------------------------------------------------------- */
.login-body {
  min-height: 100vh; display: grid; place-items: center;
  background: var(--dark-green);
  padding: 20px;
}
.login-card { width: 100%; max-width: 400px; }
.login-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 22px; justify-content: center; }
.login-brand .brand-mark { width: 44px; height: 44px; }
.login-brand strong { color: var(--dark-green); font-size: 17px; display: block; }
.login-brand span { color: var(--muted); font-size: 12px; }
.login-title { text-align: center; font-size: 18px; margin-bottom: 4px; }
.login-sub { text-align: center; color: var(--muted); font-size: 13px; margin: 0 0 20px; }

/* ---------------------------------------------------------------------
   Responsive
--------------------------------------------------------------------- */
.menu-toggle { display: none; }

@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); width: var(--sidebar-w); }
  .sidebar.is-open { transform: translateX(0); box-shadow: var(--shadow-lg); }
  .sidebar.is-collapsed { width: var(--sidebar-w); }
  .sidebar.is-collapsed .brand-text,
  .sidebar.is-collapsed .nav-group-label,
  .sidebar.is-collapsed .nav-item span,
  .sidebar.is-collapsed .collapse-btn svg { display: block; }
  .sidebar.is-collapsed .nav-item { justify-content: flex-start; padding: 9px 12px; }
  .menu-toggle { display: grid; }
  .main { margin-left: 0; }
  .sidebar.is-collapsed ~ .main { margin-left: 0; }
  .user-meta { display: none; }
  .content { padding: 16px; }
}

@media print { .menu-toggle { display: none; } }