/* ============================================================
   CampusFix — Design Tokens
   ============================================================ */
:root {
  --brand: #2563eb;
  --brand-dark: #1d4ed8;
  --brand-light: #dbeafe;
  --success: #16a34a;
  --success-light: #dcfce7;
  --warning: #d97706;
  --warning-light: #fef3c7;
  --danger: #dc2626;
  --danger-light: #fee2e2;
  --urgent: #991b1b;
  --urgent-light: #fecaca;

  --bg: #f4f6fb;
  --surface: #ffffff;
  --border: #e2e8f0;
  --text: #0f172a;
  --muted: #64748b;
  --muted-light: #94a3b8;

  /* Chart series — validated per the data-viz method (see references/palette.md).
     Status/priority are fixed semantic scales, not generic categorical hues. */
  --chart-track: #eef1f6;
  --chart-status-open: #86b6ef;
  --chart-status-assigned: #5598e7;
  --chart-status-in-progress: #2a78d6;
  --chart-status-resolved: #1c5cab;
  --chart-status-closed: #104281;
  --chart-priority-low: #0ca30c;
  --chart-priority-medium: #fab219;
  --chart-priority-high: #ec835a;
  --chart-priority-urgent: #d03b3b;
  --chart-category: #eb6834;

  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
  --shadow: 0 4px 16px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 12px 32px rgba(15, 23, 42, 0.12);

  --sidebar-w: 232px;
  --topbar-h: 64px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 { margin: 0 0 4px; line-height: 1.25; }
p { margin: 0 0 12px; color: var(--muted); }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
ul { list-style: none; margin: 0; padding: 0; }
button { font-family: inherit; }

.small { font-size: 12.5px; color: var(--muted); }
.hidden { display: none !important; }

/* ============================================================
   Buttons & form controls
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 16px;
  font-size: 14px;
  font-weight: 600;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  transition: background .15s ease, border-color .15s ease, transform .05s ease;
  white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-dark); }
.btn-secondary { background: #fff; color: var(--text); border-color: var(--border); }
.btn-secondary:hover { background: #f1f5f9; }
.btn-danger { background: #fff; color: var(--danger); border-color: #fecaca; }
.btn-danger:hover { background: var(--danger-light); }
.btn-block { width: 100%; }
.btn-sm { padding: 5px 10px; font-size: 12.5px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

.field { margin-bottom: 16px; }
.field label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--text);
}
.field .hint { font-size: 12px; color: var(--muted-light); margin-top: 4px; }
input[type=text], input[type=email], input[type=password], input[type=search],
select, textarea {
  width: 100%;
  padding: 10px 12px;
  font-size: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--text);
  font-family: inherit;
}
textarea { resize: vertical; min-height: 96px; }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-light);
}
.field.error input, .field.error select, .field.error textarea { border-color: var(--danger); }
.field .error-msg { color: var(--danger); font-size: 12.5px; margin-top: 5px; display: none; }
.field.error .error-msg { display: block; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 620px) { .form-row { grid-template-columns: 1fr; } }

/* ============================================================
   Alerts / flash messages
   ============================================================ */
.alert {
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  margin-bottom: 16px;
  border: 1px solid transparent;
}
.alert-error { background: var(--danger-light); color: #991b1b; border-color: #fca5a5; }
.alert-success { background: var(--success-light); color: #14532d; border-color: #86efac; }
.alert-info { background: var(--brand-light); color: #1e3a8a; border-color: #93c5fd; }

/* ============================================================
   Auth pages (login / register)
   ============================================================ */
.auth-wrap {
  min-height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(circle at 15% 15%, #dbeafe 0%, transparent 45%),
    radial-gradient(circle at 85% 85%, #dcfce7 0%, transparent 45%),
    var(--bg);
}
.auth-card {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 32px 30px;
  border: 1px solid var(--border);
}
.auth-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 22px; }
.auth-brand .logo-mark {
  width: 38px; height: 38px; border-radius: 10px;
  background: linear-gradient(135deg, var(--brand), #7c3aed);
  color: #fff; display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 16px;
}
.auth-brand .brand-name { font-size: 18px; font-weight: 800; }
.auth-card h1 { font-size: 21px; }
.auth-card > p.sub { margin-bottom: 22px; font-size: 13.5px; }
.auth-switch { text-align: center; font-size: 13.5px; margin-top: 4px; }

/* ============================================================
   App shell — sidebar + topbar
   ============================================================ */
.app-shell { min-height: 100%; }
.sidebar {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: var(--sidebar-w);
  background: #0f172a;
  color: #cbd5e1;
  display: flex;
  flex-direction: column;
  padding: 18px 14px;
  z-index: 40;
  transition: transform .2s ease;
}
.sidebar .brand {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 8px 22px;
  color: #fff;
}
.sidebar .brand .logo-mark {
  width: 32px; height: 32px; border-radius: 8px;
  background: linear-gradient(135deg, var(--brand), #7c3aed);
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 14px; flex: none;
}
.sidebar .brand .brand-name { font-weight: 800; font-size: 16px; }
.nav-section-label {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: .06em;
  color: #64748b; margin: 14px 8px 6px;
}
.nav-link {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  color: #cbd5e1;
  cursor: pointer;
}
.nav-link:hover { background: #1e293b; text-decoration: none; color: #fff; }
.nav-link.active { background: var(--brand); color: #fff; }
.nav-link .ic { width: 18px; text-align: center; flex: none; }
.sidebar-footer { margin-top: auto; padding-top: 14px; border-top: 1px solid #1e293b; }
.side-user { display: flex; align-items: center; gap: 10px; padding: 8px; }
.side-user .avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: #334155; color: #fff; display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 13px; flex: none;
}
.side-user .who { min-width: 0; }
.side-user .who .name { font-size: 13.5px; font-weight: 600; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.side-user .who .role { font-size: 11.5px; color: #94a3b8; text-transform: capitalize; }
.logout-btn {
  width: 100%; margin-top: 8px;
  background: transparent; border: 1px solid #334155; color: #cbd5e1;
  border-radius: 8px; padding: 8px; font-size: 13px; cursor: pointer;
}
.logout-btn:hover { background: #1e293b; color: #fff; }

.main-area { margin-left: var(--sidebar-w); min-height: 100%; }
.topbar {
  height: var(--topbar-h);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 20;
}
.topbar .title-block h1 { font-size: 19px; }
.topbar .title-block .crumb { font-size: 12.5px; color: var(--muted); }
.hamburger {
  display: none;
  background: none; border: 1px solid var(--border); border-radius: 8px;
  width: 36px; height: 36px; cursor: pointer; font-size: 16px;
}
.page-content { padding: 24px; max-width: 1180px; }
.sidebar-scrim { display: none; }

@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-area { margin-left: 0; }
  .hamburger { display: inline-flex; align-items: center; justify-content: center; }
  .sidebar-scrim.open {
    display: block; position: fixed; inset: 0; background: rgba(15,23,42,.45); z-index: 30;
  }
}

/* ============================================================
   Cards, stats, badges
   ============================================================ */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.card-pad { padding: 20px; }
.section-title {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 14px;
}
.section-title h2 { font-size: 16px; }

.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}
@media (max-width: 900px) { .stat-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 520px) { .stat-grid { grid-template-columns: 1fr; } }
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow-sm);
}
.stat-card .stat-label { font-size: 12.5px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
.stat-card .stat-value { font-size: 28px; font-weight: 800; margin-top: 6px; }
.stat-card .stat-icon {
  width: 34px; height: 34px; border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  font-size: 15px; margin-bottom: 10px;
}
.stat-icon.tot { background: var(--brand-light); color: var(--brand-dark); }
.stat-icon.open { background: #e0e7ff; color: #4338ca; }
.stat-icon.prog { background: var(--warning-light); color: #b45309; }
.stat-icon.done { background: var(--success-light); color: #15803d; }

/* ============================================================
   Analytics — breakdown bar charts
   ============================================================ */
.analytics-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 24px;
  align-items: start;
}
@media (max-width: 1080px) { .analytics-grid { grid-template-columns: 1fr 1fr; } }
@media (max-width: 700px) { .analytics-grid { grid-template-columns: 1fr; } }

.chart-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 16px;
}
.chart-head h2 { font-size: 14.5px; }
.chart-head .chart-sub { font-size: 12px; color: var(--muted); font-weight: 700; white-space: nowrap; }

.bar-list { display: flex; flex-direction: column; gap: 11px; }
.bar-row {
  display: grid;
  grid-template-columns: minmax(70px, 112px) 1fr 26px;
  align-items: center;
  gap: 10px;
  padding: 3px 5px;
  border-radius: 6px;
  cursor: default;
}
.bar-row:hover, .bar-row:focus-visible {
  background: #f8fafc;
  outline: none;
}
.bar-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.bar-track {
  position: relative;
  height: 16px;
  background: var(--chart-track);
  border-radius: 4px;
  overflow: hidden;
}
.bar-fill {
  position: absolute;
  left: 0; top: 0; bottom: 0;
  border-radius: 0 4px 4px 0;
  transition: width .3s ease;
}
.bar-value {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text);
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.chart-empty { font-size: 12.5px; color: var(--muted); padding: 10px 0 2px; text-align: center; }
.chart-fold-note { font-size: 11.5px; color: var(--muted-light); margin-top: 10px; text-align: right; }
.chart-fold-note a { font-weight: 600; }

.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .02em;
  white-space: nowrap;
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-status-open { background: #e0e7ff; color: #4338ca; }
.badge-status-assigned { background: #ede9fe; color: #6d28d9; }
.badge-status-in-progress { background: var(--warning-light); color: #b45309; }
.badge-status-resolved { background: var(--success-light); color: #15803d; }
.badge-status-closed { background: #e2e8f0; color: #475569; }

.badge-priority-low { background: #f1f5f9; color: #475569; }
.badge-priority-medium { background: var(--brand-light); color: #1d4ed8; }
.badge-priority-high { background: var(--warning-light); color: #b45309; }
.badge-priority-urgent { background: var(--urgent-light); color: var(--urgent); }

/* ============================================================
   Toolbar / filters
   ============================================================ */
.toolbar {
  display: flex; flex-wrap: wrap; gap: 10px; align-items: center;
  margin-bottom: 16px;
}
.toolbar .search-box { position: relative; flex: 1 1 220px; min-width: 180px; }
.toolbar .search-box input { padding-left: 34px; }
.toolbar .search-box .ic { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--muted-light); font-size: 13px; }
.toolbar select { width: auto; min-width: 130px; }
.toolbar .spacer { flex: 1; }

/* ============================================================
   Table
   ============================================================ */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
thead th {
  text-align: left; padding: 10px 14px;
  font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em;
  color: var(--muted); border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
tbody td { padding: 12px 14px; border-bottom: 1px solid #f1f5f9; vertical-align: middle; }
tbody tr:hover { background: #f8fafc; }
tbody tr:last-child td { border-bottom: none; }
.ref-link { font-weight: 700; color: var(--brand); }
.row-title { font-weight: 600; color: var(--text); }
.row-sub { font-size: 12px; color: var(--muted-light); }

.empty-state {
  text-align: center; padding: 48px 20px; color: var(--muted);
}
.empty-state .ic { font-size: 30px; margin-bottom: 10px; }

/* ============================================================
   Request detail
   ============================================================ */
.detail-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 20px; align-items: start; }
@media (max-width: 860px) { .detail-grid { grid-template-columns: 1fr; } }

.stepper { display: flex; align-items: center; margin: 6px 0 4px; }
.stepper .step { display: flex; flex-direction: column; align-items: center; flex: 1; position: relative; }
.stepper .dot {
  width: 26px; height: 26px; border-radius: 50%;
  background: #e2e8f0; color: #94a3b8;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; z-index: 1;
}
.stepper .step.done .dot { background: var(--success); color: #fff; }
.stepper .step.current .dot { background: var(--brand); color: #fff; }
.stepper .label { font-size: 10.5px; color: var(--muted); margin-top: 6px; text-align: center; }
.stepper .step::after {
  content: ""; position: absolute; top: 13px; left: 50%; width: 100%; height: 2px;
  background: #e2e8f0; z-index: 0;
}
.stepper .step:last-child::after { display: none; }
.stepper .step.done::after { background: var(--success); }

.meta-list { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 16px; margin-top: 14px; }
.meta-list .mi .k { font-size: 11.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
.meta-list .mi .v { font-size: 14px; font-weight: 600; margin-top: 2px; }

.comment { display: flex; gap: 10px; padding: 12px 0; border-bottom: 1px solid #f1f5f9; }
.comment:last-child { border-bottom: none; }
.comment .avatar {
  width: 32px; height: 32px; border-radius: 50%; flex: none;
  background: var(--brand-light); color: var(--brand-dark);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 12.5px;
}
.comment .who { font-size: 13px; font-weight: 700; }
.comment .who .role-tag {
  font-size: 10px; font-weight: 700; text-transform: uppercase;
  background: var(--brand-light); color: var(--brand-dark);
  padding: 1px 6px; border-radius: 999px; margin-left: 6px;
}
.comment .when { font-size: 11.5px; color: var(--muted-light); margin-left: 8px; font-weight: 400; }
.comment .body { font-size: 13.5px; margin-top: 3px; color: var(--text); }

.admin-panel { display: flex; flex-direction: column; gap: 14px; }
.admin-panel .field { margin-bottom: 0; }

/* ============================================================
   Misc
   ============================================================ */
.divider { height: 1px; background: var(--border); margin: 18px 0; }
.pill-list { display: flex; flex-wrap: wrap; gap: 8px; }
.pill {
  display: flex; align-items: center; gap: 8px;
  background: #f1f5f9; border: 1px solid var(--border);
  padding: 6px 8px 6px 12px; border-radius: 999px; font-size: 13px; font-weight: 600;
}
.pill button {
  background: none; border: none; color: var(--muted); cursor: pointer;
  width: 18px; height: 18px; border-radius: 50%; font-size: 13px; line-height: 1;
}
.pill button:hover { background: #e2e8f0; color: var(--danger); }
.pill button:disabled { cursor: not-allowed; opacity: .4; }
.pill button:disabled:hover { background: none; color: var(--muted); }

.footer-note { text-align: center; color: var(--muted-light); font-size: 12px; margin-top: 28px; }
