/* ── Sidebar ──────────────────────────────────────────────── */
.sidebar {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  border-right: 1px solid var(--sidebar-border);
  display: flex;
  flex-direction: column;
  z-index: var(--z-sticky);
  transition: width var(--duration-slow) var(--ease-out);
  overflow: hidden;
}

.sidebar.collapsed { width: var(--sidebar-w-collapsed); }

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-5) var(--space-4);
  border-bottom: 1px solid var(--sidebar-border);
  min-height: var(--nav-h);
  text-decoration: none;
}

.sidebar-logo {
  width: 36px; height: 36px;
  background: linear-gradient(135deg, var(--clr-brand), var(--clr-brand-dark));
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: var(--weight-black);
  font-size: 14px;
  color: white;
  flex-shrink: 0;
  box-shadow: var(--shadow-brand);
}

.sidebar-brand-text {
  overflow: hidden;
  transition: opacity var(--duration-base) var(--ease-out), width var(--duration-base) var(--ease-out);
}

.sidebar-brand-name {
  font-size: var(--text-sm);
  font-weight: var(--weight-bold);
  color: white;
  white-space: nowrap;
  display: block;
}

.sidebar-brand-sub {
  font-size: var(--text-xs);
  color: var(--sidebar-text);
  white-space: nowrap;
  display: block;
  margin-top: 1px;
}

.sidebar.collapsed .sidebar-brand-text { opacity: 0; width: 0; }

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: var(--space-3) 0;
}

.sidebar-section-label {
  font-size: var(--text-xs);
  font-weight: var(--weight-semi);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--sidebar-text);
  padding: var(--space-4) var(--space-4) var(--space-2);
  white-space: nowrap;
  overflow: hidden;
  transition: opacity var(--duration-base) var(--ease-out);
}

.sidebar.collapsed .sidebar-section-label { opacity: 0; }

.sidebar-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-4);
  margin: 1px var(--space-2);
  border-radius: var(--radius-md);
  color: var(--sidebar-text);
  text-decoration: none;
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  white-space: nowrap;
  cursor: pointer;
  transition: background var(--duration-fast) var(--ease-out),
              color var(--duration-fast) var(--ease-out);
  position: relative;
}

.sidebar-item:hover {
  background: rgba(255,255,255,0.06);
  color: var(--sidebar-text-hover);
  text-decoration: none;
}

.sidebar-item.active {
  background: var(--sidebar-active-bg);
  color: var(--sidebar-active-text);
}

.sidebar-item.active .sidebar-item-icon { color: var(--clr-brand); }

.sidebar-item-icon {
  width: 18px; height: 18px;
  color: var(--sidebar-icon);
  flex-shrink: 0;
  transition: color var(--duration-fast) var(--ease-out);
}

.sidebar-item:hover .sidebar-item-icon { color: var(--sidebar-text-hover); }

.sidebar-item-text {
  overflow: hidden;
  transition: opacity var(--duration-base) var(--ease-out), width var(--duration-base) var(--ease-out);
}

.sidebar.collapsed .sidebar-item-text { opacity: 0; width: 0; }

.sidebar-badge {
  margin-left: auto;
  background: var(--clr-brand);
  color: white;
  font-size: var(--text-xs);
  font-weight: var(--weight-bold);
  padding: 1px 6px;
  border-radius: var(--radius-full);
  line-height: 1.5;
  flex-shrink: 0;
  transition: opacity var(--duration-base) var(--ease-out);
}

.sidebar.collapsed .sidebar-badge { opacity: 0; }

.sidebar-footer {
  padding: var(--space-3);
  border-top: 1px solid var(--sidebar-border);
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background var(--duration-fast) var(--ease-out);
  text-decoration: none;
}

.sidebar-user:hover { background: rgba(255,255,255,0.06); }

.sidebar-user-avatar {
  width: 32px; height: 32px;
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, var(--clr-brand), #8b5cf6);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-xs);
  font-weight: var(--weight-bold);
  color: white;
  flex-shrink: 0;
}

.sidebar-user-info {
  overflow: hidden;
  transition: opacity var(--duration-base) var(--ease-out);
}

.sidebar.collapsed .sidebar-user-info { opacity: 0; width: 0; }

.sidebar-user-name {
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: white;
  white-space: nowrap;
  display: block;
}

.sidebar-user-role {
  font-size: var(--text-xs);
  color: var(--sidebar-text);
  white-space: nowrap;
  display: block;
}

.sidebar-collapse-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: var(--space-2);
  border-radius: var(--radius-md);
  color: var(--sidebar-text);
  cursor: pointer;
  transition: background var(--duration-fast), color var(--duration-fast);
  margin-top: var(--space-2);
}

.sidebar-collapse-btn:hover {
  background: rgba(255,255,255,0.06);
  color: var(--sidebar-text-hover);
}

/* ── Navbar ───────────────────────────────────────────────── */
.navbar {
  position: fixed;
  top: 0;
  left: var(--sidebar-w);
  right: 0;
  height: var(--nav-h);
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 var(--space-6);
  gap: var(--space-4);
  z-index: var(--z-sticky);
  transition: left var(--duration-slow) var(--ease-out);
  backdrop-filter: blur(8px);
  background: rgba(255,255,255,0.92);
}

[data-theme="dark"] .navbar { background: rgba(15,23,42,0.92); }

.sidebar.collapsed ~ .navbar,
body.sidebar-collapsed .navbar { left: var(--sidebar-w-collapsed); }

.navbar-breadcrumb {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex: 1;
  min-width: 0;
}

.navbar-breadcrumb-item {
  font-size: var(--text-sm);
  color: var(--text-tertiary);
}

.navbar-breadcrumb-item.active {
  font-weight: var(--weight-semi);
  color: var(--text-primary);
}

.navbar-breadcrumb-sep {
  color: var(--text-tertiary);
  font-size: var(--text-xs);
}

.navbar-actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-left: auto;
}

.navbar-icon-btn {
  width: 36px; height: 36px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  cursor: pointer;
  transition: background var(--duration-fast), color var(--duration-fast);
  position: relative;
}

.navbar-icon-btn:hover { background: var(--bg-hover); color: var(--text-primary); }

.notification-dot {
  position: absolute;
  top: 6px; right: 6px;
  width: 8px; height: 8px;
  background: var(--clr-brand);
  border-radius: var(--radius-full);
  border: 2px solid var(--bg);
}

.navbar-avatar {
  width: 32px; height: 32px;
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, var(--clr-brand), #8b5cf6);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-xs);
  font-weight: var(--weight-bold);
  color: white;
  cursor: pointer;
  border: 2px solid transparent;
  transition: border-color var(--duration-fast);
}

.navbar-avatar:hover { border-color: var(--clr-brand); }

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

.main-content {
  flex: 1;
  margin-left: var(--sidebar-w);
  margin-top: var(--nav-h);
  padding: var(--space-8) var(--space-6);
  min-width: 0;
  transition: margin-left var(--duration-slow) var(--ease-out);
}

body.sidebar-collapsed .main-content { margin-left: var(--sidebar-w-collapsed); }

@media (max-width: 1024px) and (min-width: 769px) {
  .main-content { padding: var(--space-5) var(--space-4); }
}

@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); width: var(--sidebar-w) !important; }
  .sidebar.mobile-open { transform: translateX(0); }
  .main-content { margin-left: 0; padding: var(--space-4) var(--space-3); }
  .navbar { left: 0; }
  .page-header { flex-direction: column; align-items: flex-start; gap: 12px; }
  .page-header .page-actions { width: 100%; }
  .page-title { font-size: 20px; }
}

@media (max-width: 480px) {
  .main-content { padding: var(--space-3) var(--space-2); }
  .card-body { padding: var(--space-4); }
  .card-header { padding: var(--space-4); flex-wrap: wrap; gap: 8px; }
  .stat-card { padding: var(--space-4); }
  .stat-card-value { font-size: 26px; }
  .btn-full-mobile { width: 100%; }
}

/* ── Page Header ─────────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--space-4);
  margin-bottom: var(--space-8);
}

.page-title {
  font-size: var(--text-2xl);
  font-weight: var(--weight-black);
  color: var(--text-primary);
  letter-spacing: -0.02em;
  line-height: var(--leading-tight);
}

.page-subtitle {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  margin-top: var(--space-1);
  line-height: var(--leading-normal);
}

.page-actions {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-wrap: wrap;
}

/* ── Buttons ──────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: 0 var(--space-4);
  height: 36px;
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  white-space: nowrap;
  transition:
    background var(--duration-fast) var(--ease-out),
    border-color var(--duration-fast) var(--ease-out),
    color var(--duration-fast) var(--ease-out),
    transform var(--duration-fast) var(--ease-out),
    box-shadow var(--duration-fast) var(--ease-out);
  text-decoration: none;
  user-select: none;
}

.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; pointer-events: none; }

.btn-primary {
  background: var(--clr-brand);
  color: white;
  border-color: var(--clr-brand);
  box-shadow: 0 1px 2px rgba(233,69,96,0.2);
}
.btn-primary:hover { background: var(--clr-brand-dark); border-color: var(--clr-brand-dark); box-shadow: var(--shadow-brand); }

.btn-secondary {
  background: var(--bg);
  color: var(--text-primary);
  border-color: var(--border-strong);
}
.btn-secondary:hover { background: var(--bg-hover); }

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border-color: transparent;
}
.btn-ghost:hover { background: var(--bg-hover); color: var(--text-primary); }

.btn-danger {
  background: var(--clr-danger);
  color: white;
  border-color: var(--clr-danger);
}
.btn-danger:hover { background: var(--clr-danger-text); }

.btn-success {
  background: var(--clr-success);
  color: white;
  border-color: var(--clr-success);
}
.btn-success:hover { background: var(--clr-success-text); }

.btn-outline-danger {
  background: transparent;
  color: var(--clr-danger-text);
  border-color: var(--clr-danger);
}
.btn-outline-danger:hover { background: var(--clr-danger-bg); }

.btn-sm { height: 30px; padding: 0 var(--space-3); font-size: var(--text-xs); }
.btn-lg { height: 44px; padding: 0 var(--space-6); font-size: var(--text-md); }
.btn-xl { height: 52px; padding: 0 var(--space-8); font-size: var(--text-lg); font-weight: var(--weight-semi); }
.btn-full { width: 100%; }
.btn-icon { width: 36px; padding: 0; }
.btn-icon.btn-sm { width: 30px; }

/* ── Forms ────────────────────────────────────────────────── */
.form-group { display: flex; flex-direction: column; gap: var(--space-2); margin-bottom: var(--space-5); }
.form-group:last-child { margin-bottom: 0; }

.form-label {
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--text-secondary);
}

.form-label .required { color: var(--clr-brand); margin-left: 3px; }

.form-control {
  width: 100%;
  height: 40px;
  padding: 0 var(--space-3);
  font-size: var(--text-sm);
  color: var(--text-primary);
  background: var(--bg);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  transition: border-color var(--duration-fast), box-shadow var(--duration-fast), background var(--duration-fast);
  -webkit-appearance: none;
  appearance: none;
}

.form-control:hover { border-color: var(--border-strong); }

.form-control:focus {
  outline: none;
  border-color: var(--clr-brand);
  box-shadow: 0 0 0 3px var(--clr-brand-ring);
  background: var(--bg);
}

.form-control::placeholder { color: var(--text-tertiary); }
.form-control:disabled { background: var(--bg-tertiary); color: var(--text-tertiary); cursor: not-allowed; }

.form-control.error { border-color: var(--clr-danger); }
.form-control.error:focus { box-shadow: 0 0 0 3px rgba(239,68,68,0.2); }

.form-control.success { border-color: var(--clr-success); }

textarea.form-control { height: auto; min-height: 100px; padding: var(--space-3); resize: vertical; line-height: var(--leading-normal); }
select.form-control { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%2394a3b8' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 36px; cursor: pointer; }

/* ── Universal input styling (catches Django bare widget renders) ── */
input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="date"],
input[type="tel"],
input[type="url"],
input[type="search"],
textarea,
select {
  width: 100%;
  height: 40px;
  padding: 0 var(--space-3);
  font-size: var(--text-sm);
  font-family: var(--font-sans);
  color: var(--text-primary);
  background: var(--bg);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  transition: border-color var(--duration-fast), box-shadow var(--duration-fast), background var(--duration-fast);
  -webkit-appearance: none;
  appearance: none;
  box-sizing: border-box;
}

textarea {
  height: auto;
  min-height: 100px;
  padding: var(--space-3);
  resize: vertical;
  line-height: var(--leading-normal);
}

select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%2394a3b8' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
  cursor: pointer;
}

input[type="text"]:hover,
input[type="email"]:hover,
input[type="password"]:hover,
input[type="number"]:hover,
input[type="date"]:hover,
input[type="tel"]:hover,
input[type="url"]:hover,
input[type="search"]:hover,
textarea:hover,
select:hover {
  border-color: var(--border-strong);
}

input[type="text"]:focus,
input[type="email"]:focus,
input[type="password"]:focus,
input[type="number"]:focus,
input[type="date"]:focus,
input[type="tel"]:focus,
input[type="url"]:focus,
input[type="search"]:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: var(--clr-brand);
  box-shadow: 0 0 0 3px var(--clr-brand-ring);
  background: var(--bg);
}

input::placeholder,
textarea::placeholder {
  color: var(--text-tertiary);
}

input:disabled,
textarea:disabled,
select:disabled {
  background: var(--bg-tertiary);
  color: var(--text-tertiary);
  cursor: not-allowed;
}

/* Date input calendar icon colour */
input[type="date"]::-webkit-calendar-picker-indicator {
  opacity: 0.5;
  cursor: pointer;
}


.form-hint  { font-size: var(--text-xs); color: var(--text-tertiary); }
.form-error { font-size: var(--text-xs); color: var(--clr-danger-text); display: flex; align-items: center; gap: 4px; }

.form-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-4); }
.form-grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: var(--space-4); }

@media (max-width: 640px) {
  .form-grid-2, .form-grid-3 { grid-template-columns: 1fr; }
}

.form-section { padding-bottom: var(--space-6); margin-bottom: var(--space-6); border-bottom: 1px solid var(--border); }
.form-section:last-child { border-bottom: none; margin-bottom: 0; padding-bottom: 0; }

.form-section-title {
  font-size: var(--text-sm);
  font-weight: var(--weight-semi);
  color: var(--text-primary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: var(--space-4);
}

/* Checkbox & Radio */
.form-check {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  cursor: pointer;
}

.form-check-input {
  width: 16px; height: 16px;
  margin-top: 2px;
  border: 1.5px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--bg);
  cursor: pointer;
  flex-shrink: 0;
  accent-color: var(--clr-brand);
}

.form-check-label {
  font-size: var(--text-sm);
  color: var(--text-primary);
  cursor: pointer;
  line-height: var(--leading-snug);
}

/* ── Cards ────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  overflow: hidden;
  transition: box-shadow var(--duration-base) var(--ease-out);
}

.card-hover:hover { box-shadow: var(--shadow-md); }

[data-theme="dark"] .card {
  background: #111c35;
  border-color: rgba(255,255,255,0.11);
  box-shadow: 0 1px 3px rgba(0,0,0,0.4);
}

[data-theme="dark"] .card-header {
  border-bottom-color: rgba(255,255,255,0.07);
}

[data-theme="dark"] .card-footer {
  background: #141e36;
  border-top-color: rgba(255,255,255,0.07);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-5) var(--space-6);
  border-bottom: 1px solid var(--border);
  gap: var(--space-4);
}

.card-title {
  font-size: var(--text-md);
  font-weight: var(--weight-semi);
  color: var(--text-primary);
  letter-spacing: -0.01em;
}

.card-subtitle {
  font-size: var(--text-xs);
  color: var(--text-tertiary);
  margin-top: 2px;
}

.card-body { padding: var(--space-6); }
.card-body-sm { padding: var(--space-4); }
.card-footer { padding: var(--space-4) var(--space-6); border-top: 1px solid var(--border); background: var(--bg-secondary); }

/* Stat card */
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: var(--space-5) var(--space-6);
  position: relative;
  overflow: hidden;
  transition: transform var(--duration-base) var(--ease-out), box-shadow var(--duration-base) var(--ease-out);
}

.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }

[data-theme="dark"] .stat-card {
  background: #182240;
  border-color: rgba(255,255,255,0.12);
  box-shadow: 0 2px 8px rgba(0,0,0,0.4);
}

.stat-card-accent {
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
}

.stat-card-icon {
  width: 40px; height: 40px;
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: var(--space-4);
}

.stat-card-label {
  font-size: var(--text-xs);
  font-weight: var(--weight-semi);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-tertiary);
  margin-bottom: var(--space-2);
}

.stat-card-value {
  font-size: var(--text-3xl);
  font-weight: var(--weight-black);
  letter-spacing: -0.03em;
  color: var(--text-primary);
  line-height: 1;
  margin-bottom: var(--space-1);
}

.stat-card-sub {
  font-size: var(--text-xs);
  color: var(--text-tertiary);
  margin-top: var(--space-1);
}

.stat-card-trend {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: var(--text-xs);
  font-weight: var(--weight-semi);
  margin-top: var(--space-2);
}

.stat-card-trend.up { color: var(--clr-success-text); }
.stat-card-trend.down { color: var(--clr-danger-text); }

/* KPI Grid */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: var(--space-4);
  margin-bottom: var(--space-8);
}

@media (max-width: 1200px) {
  .kpi-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 900px) {
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 560px) {
  .kpi-grid { grid-template-columns: 1fr; }
}

/* ── Badges ───────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  font-size: var(--text-xs);
  font-weight: var(--weight-semi);
  border-radius: var(--radius-full);
  white-space: nowrap;
  line-height: 1.6;
}

.badge-dot {
  width: 6px; height: 6px;
  border-radius: var(--radius-full);
  flex-shrink: 0;
}

.badge-success  { background: var(--clr-success-bg);  color: var(--clr-success-text); }
.badge-warning  { background: var(--clr-warning-bg);  color: var(--clr-warning-text); }
.badge-danger   { background: var(--clr-danger-bg);   color: var(--clr-danger-text);  }
.badge-info     { background: var(--clr-info-bg);     color: var(--clr-info-text);    }
.badge-brand    { background: var(--clr-brand-muted); color: var(--clr-brand-dark);   }
.badge-neutral  { background: var(--bg-tertiary);     color: var(--text-secondary);   }

.badge-sm { padding: 1px 6px; font-size: 10px; }
.badge-lg { padding: 4px 12px; font-size: var(--text-sm); border-radius: var(--radius-md); }

/* ── Tables ───────────────────────────────────────────────── */
.table-wrapper {
  overflow-x: auto;
  border-radius: var(--radius-xl);
  border: 1px solid var(--border);
  -webkit-overflow-scrolling: touch;
}

@media (max-width: 768px) {
  .table th, .table td { padding: var(--space-2) var(--space-3); font-size: 12px; }
  .table-filter-bar { flex-direction: column; }
  .search-input { min-width: 100%; }
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
  background: var(--surface);
}

[data-theme="dark"] .table {
  background: #111c35;
}

.table th {
  padding: var(--space-3) var(--space-4);
  text-align: left;
  font-size: var(--text-xs);
  font-weight: var(--weight-semi);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-tertiary);
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  user-select: none;
}

[data-theme="dark"] .table th {
  background: #0d1628;
  border-bottom-color: rgba(255,255,255,0.08);
  color: rgba(255,255,255,0.4);
}

[data-theme="dark"] .table td {
  border-bottom-color: rgba(255,255,255,0.05);
}

[data-theme="dark"] .table tbody tr:hover td {
  background: rgba(255,255,255,0.04);
}

.table th.sortable { cursor: pointer; }
.table th.sortable:hover { color: var(--text-primary); }
.table th .sort-icon { display: inline-flex; flex-direction: column; gap: 1px; margin-left: var(--space-1); vertical-align: middle; }
.table th .sort-icon span { display: block; width: 0; height: 0; border-left: 4px solid transparent; border-right: 4px solid transparent; }
.table th .sort-icon .asc-arrow  { border-bottom: 5px solid currentColor; }
.table th .sort-icon .desc-arrow { border-top: 5px solid currentColor; }
.table th.sort-asc  .sort-icon .asc-arrow  { color: var(--clr-brand); }
.table th.sort-desc .sort-icon .desc-arrow { color: var(--clr-brand); }

.table td {
  padding: var(--space-3) var(--space-4);
  color: var(--text-primary);
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.table tbody tr:last-child td { border-bottom: none; }

.table tbody tr:hover td { background: var(--bg-hover); }

.table-striped tbody tr:nth-child(even) td { background: var(--bg-secondary); }
.table-striped tbody tr:nth-child(even):hover td { background: var(--bg-hover); }

.table-actions { display: flex; align-items: center; gap: var(--space-2); }

.table-empty {
  text-align: center;
  padding: var(--space-12) var(--space-6);
  color: var(--text-tertiary);
}

.table-empty-icon {
  width: 48px; height: 48px;
  margin: 0 auto var(--space-4);
  color: var(--border-strong);
}

.table-filter-bar {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-6);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

.search-input {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0 var(--space-3);
  height: 36px;
  min-width: 260px;
  transition: border-color var(--duration-fast), box-shadow var(--duration-fast);
}

.search-input:focus-within {
  border-color: var(--clr-brand);
  box-shadow: 0 0 0 3px var(--clr-brand-ring);
  background: var(--bg);
}

.search-input input {
  flex: 1;
  border: none;
  background: transparent;
  font-size: var(--text-sm);
  color: var(--text-primary);
  outline: none;
}

.search-input input::placeholder { color: var(--text-tertiary); }

/* ── Modals ───────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg-overlay);
  z-index: var(--z-overlay);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-4);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--duration-base) var(--ease-out);
  backdrop-filter: blur(4px);
}

.modal-overlay.open {
  opacity: 1;
  pointer-events: all;
}

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-2xl);
  width: 100%;
  max-width: 520px;
  max-height: calc(100vh - 48px);
  overflow-y: auto;
  box-shadow: var(--shadow-xl);
  transform: scale(0.96) translateY(8px);
  transition: transform var(--duration-base) var(--ease-out);
}

.modal-overlay.open .modal { transform: scale(1) translateY(0); }

.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: var(--space-6);
  border-bottom: 1px solid var(--border);
  gap: var(--space-4);
}

.modal-title { font-size: var(--text-lg); font-weight: var(--weight-bold); color: var(--text-primary); }
.modal-subtitle { font-size: var(--text-sm); color: var(--text-secondary); margin-top: var(--space-1); }

.modal-close {
  width: 32px; height: 32px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-tertiary);
  cursor: pointer;
  flex-shrink: 0;
  transition: background var(--duration-fast), color var(--duration-fast);
}

.modal-close:hover { background: var(--bg-hover); color: var(--text-primary); }

.modal-body { padding: var(--space-6); }
.modal-footer {
  padding: var(--space-4) var(--space-6);
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: var(--space-3);
  background: var(--bg-secondary);
  border-radius: 0 0 var(--radius-2xl) var(--radius-2xl);
}

.modal-lg { max-width: 720px; }
.modal-sm { max-width: 400px; }

/* ── Toast Notifications ─────────────────────────────────── */
.toast-container {
  position: fixed;
  bottom: var(--space-6);
  right: var(--space-6);
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-5);
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  max-width: 380px;
  pointer-events: all;
  animation: fadeUp var(--duration-base) var(--ease-out) both;
}

.toast.removing { animation: fadeDown var(--duration-base) var(--ease-in) both; }

.toast-icon {
  width: 20px; height: 20px;
  flex-shrink: 0;
  margin-top: 1px;
}

.toast-content { flex: 1; min-width: 0; }
.toast-title { font-size: var(--text-sm); font-weight: var(--weight-semi); color: var(--text-primary); }
.toast-message { font-size: var(--text-xs); color: var(--text-secondary); margin-top: 2px; }

.toast-close {
  width: 20px; height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-tertiary);
  cursor: pointer;
  border-radius: var(--radius-sm);
  flex-shrink: 0;
  transition: color var(--duration-fast);
}

.toast-close:hover { color: var(--text-primary); }

.toast-success { border-left: 3px solid var(--clr-success); }
.toast-warning { border-left: 3px solid var(--clr-warning); }
.toast-danger  { border-left: 3px solid var(--clr-danger); }
.toast-info    { border-left: 3px solid var(--clr-info); }

/* ── Dropdown ─────────────────────────────────────────────── */
.dropdown-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 180px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  z-index: var(--z-dropdown);
  padding: var(--space-2);
  opacity: 0;
  pointer-events: none;
  transform: scale(0.96) translateY(-4px);
  transition: opacity var(--duration-fast) var(--ease-out), transform var(--duration-fast) var(--ease-out);
}

.dropdown-menu.open {
  opacity: 1;
  pointer-events: all;
  transform: scale(1) translateY(0);
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  color: var(--text-primary);
  cursor: pointer;
  text-decoration: none;
  transition: background var(--duration-fast);
}

.dropdown-item:hover { background: var(--bg-hover); text-decoration: none; }
.dropdown-item.danger { color: var(--clr-danger-text); }
.dropdown-item.danger:hover { background: var(--clr-danger-bg); }

.dropdown-divider { height: 1px; background: var(--border); margin: var(--space-2) 0; }

.dropdown-label {
  padding: var(--space-1) var(--space-3) var(--space-2);
  font-size: var(--text-xs);
  font-weight: var(--weight-semi);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-tertiary);
}

/* ── Progress bars ────────────────────────────────────────── */
.progress-bar {
  height: 6px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  border-radius: var(--radius-full);
  transition: width 0.6s var(--ease-out);
  background: var(--clr-brand);
}

.progress-success { background: var(--clr-success); }
.progress-warning { background: var(--clr-warning); }
.progress-danger  { background: var(--clr-danger); }
.progress-info    { background: var(--clr-info); }

.progress-bar-lg  { height: 10px; }
.progress-bar-sm  { height: 4px; }

/* ── Auth pages ───────────────────────────────────────────── */
.auth-layout {
  min-height: 100vh;
  display: flex;
  align-items: stretch;
}

.auth-left {
  flex: 1;
  position: relative;
  display: none;
  overflow: hidden;
  min-height: 100vh;
  height: 100%;
}

@media (min-width: 1024px) {
  .auth-left { display: flex; flex-direction: column; height: 100%; }
}

.auth-bg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
}

/* Per-page background images — loaded from static/img/ */
.auth-bg-login    { background-image: url("/static/img/login.89afa5a9dc0a.jpg"); }
.auth-bg-student  { background-image: url("/static/img/student.a12b8152533a.jpg"); }
.auth-bg-lecturer { background-image: url("/static/img/lecturer.44c9be73e266.jpg"); }

.auth-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    160deg,
    rgba(10,18,38,0.82) 0%,
    rgba(15,23,42,0.72) 50%,
    rgba(233,69,96,0.22) 100%
  );
  z-index: 1;
}

.auth-left-content {
  position: relative;
  z-index: 2;
  padding: 48px 56px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  height: 100%;
  min-height: 100vh;
  flex: 1;
}

.auth-right {
  width: 100%;
  max-width: 520px;
  flex-shrink: 0;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: var(--space-12) var(--space-10);
  background: var(--bg);
  overflow-y: auto;
}

@media (max-width: 1024px) { .auth-right { max-width: 100%; } }

.auth-card { width: 100%; max-width: 400px; }

.auth-logo-mark {
  width: 48px; height: 48px;
  background: linear-gradient(135deg, var(--clr-brand), var(--clr-brand-dark));
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: var(--weight-black);
  font-size: 18px;
  color: white;
  box-shadow: var(--shadow-brand);
  margin-bottom: var(--space-6);
}

.auth-title {
  font-size: var(--text-2xl);
  font-weight: var(--weight-black);
  letter-spacing: -0.02em;
  color: var(--text-primary);
  margin-bottom: var(--space-2);
}

.auth-subtitle {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  margin-bottom: var(--space-8);
  line-height: var(--leading-normal);
}

.auth-divider {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  margin: var(--space-6) 0;
}

.auth-divider::before, .auth-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

.auth-divider-text { font-size: var(--text-xs); color: var(--text-tertiary); white-space: nowrap; }

.auth-footer {
  margin-top: var(--space-6);
  font-size: var(--text-sm);
  color: var(--text-secondary);
  text-align: center;
}

/* Auth left panel */
.auth-brand { display: flex; align-items: center; gap: var(--space-3); text-decoration: none; }
.auth-brand-logo {
  width: 40px; height: 40px;
  background: linear-gradient(135deg, var(--clr-brand), var(--clr-brand-dark));
  border-radius: var(--radius-md);
  display: flex; align-items: center; justify-content: center;
  font-weight: var(--weight-black); font-size: 15px; color: white;
  box-shadow: var(--shadow-brand);
}
.auth-brand-name { font-size: 15px; font-weight: 700; color: #ffffff; text-shadow: 0 1px 4px rgba(0,0,0,0.3); }
.auth-brand-sub  { font-size: 11px; color: rgba(255,255,255,0.65); }

.auth-hero { flex: 1; display: flex; flex-direction: column; justify-content: center; padding: 32px 0; }
.auth-hero-title {
  font-size: 42px;
  font-weight: 900;
  color: #ffffff;
  letter-spacing: -0.04em;
  line-height: 1.15;
  margin-bottom: 16px;
  text-shadow: 0 2px 12px rgba(0,0,0,0.35);
}
.auth-hero-title span { color: var(--clr-brand-light); }
.auth-hero-desc { font-size: 15px; color: rgba(255,255,255,0.82); line-height: 1.7; max-width: 380px; text-shadow: 0 1px 6px rgba(0,0,0,0.3); }

.auth-features { display: flex; flex-direction: column; gap: 10px; }
.auth-feature {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 14px;
  font-weight: 500;
  color: rgba(255,255,255,0.88);
  text-shadow: 0 1px 4px rgba(0,0,0,0.25);
}
.auth-feature-icon {
  width: 34px; height: 34px;
  background: rgba(255,255,255,0.14);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
  backdrop-filter: blur(4px);
}

/* ── Tabs ─────────────────────────────────────────────────── */
.tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  gap: 0;
  overflow-x: auto;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }

.tab {
  padding: var(--space-3) var(--space-5);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--text-secondary);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
  transition: color var(--duration-fast), border-color var(--duration-fast);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
}

.tab:hover { color: var(--text-primary); }
.tab.active { color: var(--clr-brand); border-bottom-color: var(--clr-brand); }

/* ── Empty States ─────────────────────────────────────────── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: var(--space-16) var(--space-8);
}

.empty-state-icon {
  width: 64px; height: 64px;
  border-radius: var(--radius-2xl);
  background: var(--bg-tertiary);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-tertiary);
  margin-bottom: var(--space-6);
}

.empty-state-title { font-size: var(--text-lg); font-weight: var(--weight-semi); color: var(--text-primary); margin-bottom: var(--space-2); }
.empty-state-desc  { font-size: var(--text-sm); color: var(--text-secondary); max-width: 360px; line-height: var(--leading-normal); margin-bottom: var(--space-6); }

/* ── Avatar ───────────────────────────────────────────────── */
.avatar {
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: var(--weight-bold);
  background: linear-gradient(135deg, var(--clr-brand), #8b5cf6);
  color: white;
  flex-shrink: 0;
  user-select: none;
}

.avatar-xs { width: 24px; height: 24px; font-size: 10px; }
.avatar-sm { width: 32px; height: 32px; font-size: 12px; }
.avatar-md { width: 40px; height: 40px; font-size: 14px; }
.avatar-lg { width: 48px; height: 48px; font-size: 16px; }
.avatar-xl { width: 64px; height: 64px; font-size: 20px; }

/* ── Loading spinner ──────────────────────────────────────── */
.spinner {
  width: 20px; height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--clr-brand);
  border-radius: var(--radius-full);
  animation: spin 0.7s linear infinite;
  flex-shrink: 0;
}

.spinner-sm { width: 14px; height: 14px; border-width: 1.5px; }
.spinner-lg { width: 32px; height: 32px; border-width: 3px; }

/* ── Responsive dashboard grids ──────────────────────────── */
.dash-2col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-5);
  margin-bottom: var(--space-5);
}

.dash-3col {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--space-4);
  margin-bottom: var(--space-5);
}

@media (max-width: 1024px) {
  .dash-3col { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 768px) {
  .dash-2col { grid-template-columns: 1fr; }
  .dash-3col { grid-template-columns: 1fr; }
}

/* ── Charts wrapper ───────────────────────────────────────── */
.chart-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  overflow: hidden;
}

.chart-header {
  padding: var(--space-5) var(--space-6);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-4);
}

.chart-title { font-size: var(--text-md); font-weight: var(--weight-semi); color: var(--text-primary); }
.chart-sub   { font-size: var(--text-xs); color: var(--text-tertiary); margin-top: 2px; }

.chart-body { padding: var(--space-5) var(--space-6); }

/* ── Pending steps ────────────────────────────────────────── */
.steps { display: flex; flex-direction: column; gap: 0; }
.step  { display: flex; gap: var(--space-4); position: relative; padding-bottom: var(--space-6); }
.step:last-child { padding-bottom: 0; }

.step::before {
  content: '';
  position: absolute;
  left: 15px;
  top: 32px;
  bottom: 0;
  width: 1px;
  background: var(--border);
}

.step:last-child::before { display: none; }

.step-indicator {
  width: 32px; height: 32px;
  border-radius: var(--radius-full);
  border: 2px solid var(--border);
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-xs);
  font-weight: var(--weight-bold);
  color: var(--text-tertiary);
  flex-shrink: 0;
  position: relative;
  z-index: 1;
}

.step.done .step-indicator { background: var(--clr-success); border-color: var(--clr-success); color: white; }
.step.active .step-indicator { background: var(--clr-brand); border-color: var(--clr-brand); color: white; }

.step-content { flex: 1; padding-top: 6px; }
.step-title { font-size: var(--text-sm); font-weight: var(--weight-semi); color: var(--text-primary); }
.step-desc  { font-size: var(--text-xs); color: var(--text-secondary); margin-top: 2px; }

/* ── Detail grid ──────────────────────────────────────────── */
.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-4);
}

.detail-item {}
.detail-label { font-size: var(--text-xs); color: var(--text-tertiary); font-weight: var(--weight-semi); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: var(--space-1); }
.detail-value { font-size: var(--text-sm); color: var(--text-primary); font-weight: var(--weight-medium); }

/* ── Log entry card ───────────────────────────────────────── */
.log-entry-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: var(--space-5);
  transition: box-shadow var(--duration-fast), transform var(--duration-fast);
  cursor: pointer;
}
.log-entry-card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }

.log-entry-meta { display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; margin-bottom: var(--space-3); }
.log-entry-date { font-size: var(--text-xs); font-weight: var(--weight-semi); color: var(--text-tertiary); }
.log-entry-title { font-size: var(--text-md); font-weight: var(--weight-semi); color: var(--text-primary); margin-bottom: var(--space-2); }
.log-entry-desc { font-size: var(--text-sm); color: var(--text-secondary); line-height: var(--leading-normal); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

/* ── Grade display ────────────────────────────────────────── */
.grade-circle {
  width: 64px; height: 64px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-2xl);
  font-weight: var(--weight-black);
  flex-shrink: 0;
}

.grade-A { background: var(--clr-success-bg); color: var(--clr-success-text); }
.grade-B { background: var(--clr-info-bg);    color: var(--clr-info-text); }
.grade-C { background: var(--clr-warning-bg); color: var(--clr-warning-text); }
.grade-D { background: rgba(245,158,11,0.15); color: #b45309; }
.grade-E { background: rgba(139,92,246,0.1);  color: #7c3aed; }
.grade-F { background: var(--clr-danger-bg);  color: var(--clr-danger-text); }