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

:root {
  /* Chrome */
  --sidebar-bg: #0B2538;
  --sidebar-width: 78px;
  --topbar-height: 60px;
  --nav-hover-bg: rgba(255,255,255,0.06);
  --content-radius: 16px;

  /* Accent — overridden per-swatch via JS */
  --accent: #F87060;

  /* Surface (light mode defaults) */
  --body-bg: #f0f2f5;
  --surface-bg: #ffffff;
  --surface-header-bg: #f4f6f9;
  --surface-hover-bg: #f7f9fc;
  --surface-border: #e2e6ec;

  /* Text (light mode defaults) */
  --text-primary: #1a1f36;
  --text-secondary: #6b7280;
  --text-muted: #9ca3af;

  /* Inputs (light mode defaults) */
  --input-bg: #f9fafb;
  --input-border: #d1d5db;

  /* Stat cards */
  --card-bg: #33566C;
  --card-text: #ffffff;

  /* Fixed semantic colours */
  --accent-green: #4caf7d;
  --accent-red: #e53935;
}

/* ── Dark theme overrides ───────────────────── */
html[data-theme="dark"] {
  --body-bg: #071d2b;
  --surface-bg: #0f2a3d;
  --surface-header-bg: #0B2538;
  --surface-hover-bg: #132f45;
  --surface-border: #1e3f55;
  --text-primary: #e2e8f0;
  --text-secondary: #859AA7;
  --text-muted: #55788e;
  --input-bg: #0B2538;
  --input-border: #1e3f55;
}

body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background: var(--sidebar-bg);
  color: var(--text-primary);
  height: 100vh;
  overflow: hidden;
}

.app-layout {
  display: flex;
  height: 100vh;
}

/* ─────────────────────────────
   Sidebar
───────────────────────────── */
.sidebar {
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  overflow: hidden;
  z-index: 100;
}

.sidebar-logo {
  height: var(--topbar-height);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  border-bottom: 1px solid rgba(255,255,255,0.07);
}

.sidebar-logo-img {
  width: 36px;
  height: 36px;
  object-fit: contain;
  filter: drop-shadow(0 2px 6px rgba(248,112,96,0.2));
}

.sidebar-nav {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 12px 0;
  gap: 2px;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: none;
}
.sidebar-nav::-webkit-scrollbar { display: none; }

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 10px 6px;
  color: rgba(255,255,255,0.45);
  text-decoration: none;
  font-size: 10px;
  font-weight: 500;
  text-align: center;
  gap: 5px;
  transition: color 0.15s;
  cursor: pointer;
}

.nav-item:hover { color: rgba(255,255,255,0.8); }
.nav-item:hover .nav-icon-wrap { background: var(--nav-hover-bg); }
.nav-item.active { color: #ffffff; }
.nav-item.active .nav-icon-wrap { background: var(--accent); }

/* Hide items that don't belong to the active view */
.mode-admin .nav-item[data-view="court"] { display: none; }
.mode-court .nav-item[data-view="admin"] { display: none; }

.nav-icon-wrap {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
  flex-shrink: 0;
}

.nav-icon-wrap svg {
  width: 20px;
  height: 20px;
  fill: currentColor;
}

.nav-label {
  line-height: 1.2;
  letter-spacing: 0.1px;
  max-width: 68px;
  word-break: break-word;
}


.sidebar-footer {
  padding: 14px 8px 18px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
  border-top: 1px solid rgba(255,255,255,0.06);
  flex-shrink: 0;
}

.sidebar-footer-badge {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: linear-gradient(135deg, #c9a84c 0%, #e8c96a 60%, #a07830 100%);
  display: flex;
  align-items: center;
  justify-content: center;
}

.sidebar-footer-badge svg { width: 20px; height: 20px; fill: #fff; }

.sidebar-footer-text {
  font-size: 8px;
  color: rgba(255,255,255,0.35);
  text-align: center;
  line-height: 1.4;
  letter-spacing: 0.2px;
  text-transform: uppercase;
}

/* ─────────────────────────────
   Main wrapper + Topbar
───────────────────────────── */
.main-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

.topbar {
  height: var(--topbar-height);
  background: var(--sidebar-bg);
  display: flex;
  align-items: center;
  padding: 0 20px 0 18px;
  gap: 16px;
  flex-shrink: 0;
}

.topbar-brand { flex: 1; display: flex; align-items: center; }

.topbar-brand-name {
  font-size: 17px;
  font-weight: 700;
  color: #ffffff;
  letter-spacing: 0.3px;
}

.topbar-actions { display: flex; align-items: center; gap: 10px; }

.topbar-bell {
  position: relative;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  cursor: pointer;
  transition: background 0.15s;
  color: rgba(255,255,255,0.6);
}

.topbar-bell:hover { background: rgba(255,255,255,0.1); color: #fff; }
.topbar-bell svg { width: 20px; height: 20px; fill: currentColor; }

.bell-badge {
  position: absolute;
  top: 6px; right: 6px;
  width: 8px; height: 8px;
  background: var(--accent);
  border-radius: 50%;
  border: 2px solid var(--sidebar-bg);
}

/* ─────────────────────────────
   Bell wrapper + notifications panel
───────────────────────────── */
.bell-wrapper { position: relative; }

.notifications-panel {
  display: none;
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  background: var(--surface-bg);
  border: 1px solid var(--surface-border);
  border-radius: 10px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.18);
  width: 300px;
  z-index: 999;
  overflow: hidden;
}

.bell-wrapper.open .notifications-panel { display: block; }

.notif-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 13px 16px 11px;
  border-bottom: 1px solid var(--surface-border);
  background: var(--surface-header-bg);
  font-size: 13px;
  font-weight: 700;
  color: var(--text-primary);
}

.notif-count {
  font-size: 11px;
  font-weight: 600;
  color: var(--accent);
}

.notif-body { max-height: 320px; overflow-y: auto; }

.notif-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 32px 20px;
  color: var(--text-muted);
}

.notif-empty svg {
  width: 32px;
  height: 32px;
  fill: var(--surface-border);
}

.notif-empty p { font-size: 13px; text-align: center; }

.notif-item {
  padding: 12px 16px;
  border-bottom: 1px solid var(--surface-border);
  cursor: default;
  transition: background 0.1s;
}
.notif-item:last-child { border-bottom: none; }
.notif-item:hover { background: var(--surface-hover-bg); }

.notif-title { font-size: 13px; font-weight: 600; color: var(--text-primary); margin-bottom: 2px; }
.notif-body-text { font-size: 12px; color: var(--text-secondary); line-height: 1.4; }
.notif-time { font-size: 11px; color: var(--text-muted); margin-top: 4px; }

/* ─────────────────────────────
   Theme / palette button + panel
───────────────────────────── */
.theme-wrapper { position: relative; }

.topbar-theme-btn {
  position: relative;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  cursor: pointer;
  transition: background 0.15s;
  color: rgba(255,255,255,0.6);
  background: none;
  border: none;
  padding: 0;
}
.topbar-theme-btn:hover { background: rgba(255,255,255,0.1); color: #fff; }
.topbar-theme-btn svg { width: 20px; height: 20px; fill: currentColor; }

.theme-panel {
  display: none;
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  background: var(--surface-bg);
  border: 1px solid var(--surface-border);
  border-radius: 10px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.18);
  width: 240px;
  z-index: 999;
  padding: 16px;
}
.theme-wrapper.open .theme-panel { display: block; }

.theme-section-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--text-secondary);
  margin-bottom: 10px;
}

.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}

.toggle-row-label {
  font-size: 13px;
  color: var(--text-primary);
  font-weight: 500;
}

.toggle-switch {
  position: relative;
  width: 40px;
  height: 22px;
  flex-shrink: 0;
}
.toggle-switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.toggle-slider {
  position: absolute;
  inset: 0;
  background: var(--surface-border);
  border-radius: 22px;
  cursor: pointer;
  transition: background 0.2s;
}
.toggle-slider::before {
  content: '';
  position: absolute;
  width: 16px; height: 16px;
  left: 3px; top: 3px;
  background: white;
  border-radius: 50%;
  transition: transform 0.2s;
}
.toggle-switch input:checked + .toggle-slider { background: var(--accent); }
.toggle-switch input:checked + .toggle-slider::before { transform: translateX(18px); }

.swatches {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
}
.swatch {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  cursor: pointer;
  border: 3px solid transparent;
  transition: transform 0.12s, border-color 0.12s;
  outline: none;
}
.swatch:hover { transform: scale(1.18); }
.swatch.active { border-color: var(--text-primary); }

/* ─────────────────────────────
   User dropdown
───────────────────────────── */
.user-dropdown-wrapper { position: relative; }

.user-info {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, #4a7fa5 0%, #2d5f82 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: box-shadow 0.15s;
  border: 2px solid rgba(255,255,255,0.2);
  user-select: none;
  flex-shrink: 0;
}

.user-info:hover { box-shadow: 0 0 0 3px rgba(255,255,255,0.15); }
.user-initials { font-size: 13px; font-weight: 700; color: #ffffff; }

.user-dropdown-menu {
  display: none;
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  background: var(--surface-bg);
  border: 1px solid var(--surface-border);
  border-radius: 10px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.18);
  min-width: 210px;
  z-index: 999;
  overflow: hidden;
}

.user-dropdown-wrapper.open .user-dropdown-menu { display: block; }

.dropdown-header {
  padding: 14px 16px 12px;
  border-bottom: 1px solid var(--surface-border);
  background: var(--surface-header-bg);
}

.dropdown-header .dh-email { font-size: 12px; font-weight: 700; color: var(--text-primary); }
.dropdown-header .dh-label { font-size: 10px; color: var(--text-muted); margin-top: 2px; }

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 16px;
  font-size: 13px;
  color: var(--text-primary);
  cursor: pointer;
  transition: background 0.12s;
  text-decoration: none;
}

.dropdown-item:hover { background: var(--surface-hover-bg); }
.dropdown-item svg { width: 16px; height: 16px; fill: var(--text-secondary); flex-shrink: 0; }
.dropdown-divider { height: 1px; background: var(--surface-border); margin: 4px 0; }
.dropdown-item.switch-view { color: #1a6bb5; font-weight: 600; }
.dropdown-item.switch-view svg { fill: #1a6bb5; }
.dropdown-item.logout { color: #c0392b; }
.dropdown-item.logout svg { fill: #c0392b; }

/* ─────────────────────────────
   Content shell
───────────────────────────── */
.content-shell {
  flex: 1;
  overflow: hidden;
  background: var(--body-bg);
  border-radius: var(--content-radius) 0 0 0;
  display: flex;
  flex-direction: column;
}

.content {
  flex: 1;
  overflow-y: auto;
  padding: 28px;
}

.page { display: none; }
.page.active { display: block; }

/* ─────────────────────────────
   Page header & placeholders
───────────────────────────── */
.page-header {
  margin-bottom: 20px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--surface-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.page-header h2 {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
}

.placeholder-text {
  color: var(--text-secondary);
  font-size: 14px;
  margin-top: 8px;
}

/* ─────────────────────────────
   Dashboard greeting
───────────────────────────── */
.dashboard-greeting {
  font-size: 15px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 18px;
}

/* ─────────────────────────────
   Stats Grid — 3 columns × 2 rows
───────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

/* ─────────────────────────────
   Stat Card
───────────────────────────── */
.stat-card {
  background: linear-gradient(135deg, var(--card-bg) 0%, color-mix(in srgb, var(--card-bg) 80%, #0B2538 100%) 100%);
  color: var(--card-text);
  border-radius: 10px;
  padding: 18px 20px 16px;
  position: relative;
  min-height: 120px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  box-shadow: 0 4px 16px rgba(0,0,0,0.18);
  border-left: 3px solid rgba(248,112,96,0.6);
}

.stat-card.loading { opacity: 0.35; }

.stat-card .card-title {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.7px;
  text-transform: uppercase;
  opacity: 0.75;
  margin-bottom: 5px;
}

.stat-card .card-value {
  font-size: 38px;
  font-weight: 700;
  line-height: 1;
  margin-bottom: 5px;
}

.stat-card .card-label {
  font-size: 11px;
  opacity: 0.75;
  line-height: 1.4;
}

.stat-card .card-sub-label {
  display: block;
  font-size: 11px;
  opacity: 0.6;
  margin-top: 2px;
}

/* Trend icons */
.trend-icon {
  position: absolute;
  top: 14px;
  right: 14px;
}

.trend-icon svg { width: 18px; height: 18px; }
.trend-icon.up   svg { fill: var(--accent-green); }
.trend-icon.down svg { fill: var(--accent-red); }

/* Duration sub-block (Case Throughput tile) */
.card-durations {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid rgba(255,255,255,0.15);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.card-durations-label {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  opacity: 0.6;
  margin-bottom: 4px;
}

.card-duration-row {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  opacity: 0.85;
}

.dur-type { opacity: 0.75; }
.dur-val  { font-weight: 600; }

.loading-text { color: white; font-size: 13px; opacity: 0.5; }

/* ─────────────────────────────
   Tables
───────────────────────────── */
.table-wrapper {
  background: var(--surface-bg);
  border-radius: 10px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.07);
  overflow: hidden;
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  min-width: 860px;
}

thead tr {
  background: var(--surface-header-bg);
  border-bottom: 2px solid var(--surface-border);
}

thead th {
  padding: 13px 14px;
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--text-secondary);
  white-space: nowrap;
}

tbody tr {
  border-bottom: 1px solid var(--surface-border);
  transition: background 0.1s;
}

tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--surface-hover-bg); }

tbody td {
  padding: 13px 14px;
  color: var(--text-primary);
  vertical-align: middle;
}

.case-number {
  font-weight: 600;
  color: #1a6bb5;
  white-space: nowrap;
}

.directive-cell {
  font-size: 12px;
  color: var(--text-secondary);
  max-width: 180px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.action-cell {
  width: 90px;
  text-align: right;
  display: flex;
  gap: 6px;
  justify-content: flex-end;
  align-items: center;
  padding-right: 8px;
}

.btn-edit, .btn-delete {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 6px;
  cursor: pointer;
  border: 1.5px solid var(--surface-border);
  background: var(--surface-bg);
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  flex-shrink: 0;
}

.btn-edit svg, .btn-delete svg { width: 15px; height: 15px; fill: currentColor; }

.btn-edit { color: var(--text-secondary); }
.btn-edit:hover { border-color: var(--accent); background: var(--surface-hover-bg); color: var(--accent); }

.btn-delete { color: var(--text-secondary); }
.btn-delete:hover { border-color: #e11d48; background: #fff0f3; color: #e11d48; }
html[data-theme="dark"] .btn-delete:hover { background: #2d1520; }

.table-loading, .table-error {
  text-align: center;
  padding: 28px;
  font-size: 13px;
  color: var(--text-muted);
}

.table-error { color: var(--accent-red); }

/* ─────────────────────────────
   Buttons
───────────────────────────── */
.btn-primary {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 9px 18px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s;
  white-space: nowrap;
}
.btn-primary:hover { opacity: 0.88; }
.btn-primary:disabled { opacity: 0.5; cursor: default; }

.btn-secondary {
  background: var(--surface-header-bg);
  color: var(--text-primary);
  border: 1px solid var(--input-border);
  border-radius: 8px;
  padding: 9px 18px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}
.btn-secondary:hover { background: var(--surface-hover-bg); }


/* ─────────────────────────────
   Modal overlay
───────────────────────────── */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(11, 37, 56, 0.78);
  backdrop-filter: blur(3px);
  z-index: 1000;
  align-items: center;
  justify-content: center;
}
.modal-overlay.open { display: flex; }

.modal-card {
  background: var(--surface-bg);
  border-radius: 14px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.22);
  width: 480px;
  max-width: 95vw;
  max-height: 90vh;
  overflow-y: auto;
  padding: 28px 28px 24px;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 22px;
}
.modal-header h3 { font-size: 17px; font-weight: 700; color: var(--text-primary); }

.modal-close {
  background: none;
  border: none;
  font-size: 18px;
  cursor: pointer;
  color: var(--text-muted);
  line-height: 1;
  padding: 2px 6px;
  border-radius: 4px;
}
.modal-close:hover { color: var(--text-primary); background: var(--surface-hover-bg); }

.form-section-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px 16px;
  margin-bottom: 16px;
}

.form-field { display: flex; flex-direction: column; gap: 5px; }
.form-field-full { grid-column: 1 / -1; }

.form-field label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-primary);
}

.form-field input,
.form-field select {
  padding: 9px 12px;
  border: 1px solid var(--input-border);
  border-radius: 7px;
  font-size: 13px;
  color: var(--text-primary);
  background: var(--input-bg);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.form-field input:focus,
.form-field select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 20%, transparent);
  background: var(--surface-bg);
}
.form-field input[readonly] { color: var(--text-muted); cursor: default; }

.form-error {
  font-size: 13px;
  color: #c0392b;
  min-height: 18px;
  margin-bottom: 8px;
}

.form-error:not(:empty) {
  background: rgba(248,112,96,0.12);
  border: 1px solid rgba(248,112,96,0.35);
  border-left: 3px solid #F87060;
  border-radius: 6px;
  padding: 9px 12px;
  color: #c0392b;
}

html[data-theme="dark"] .form-error:not(:empty) {
  background: rgba(248,112,96,0.10);
  color: #fca5a5;
}

.form-success {
  font-size: 13px;
  color: var(--accent-green);
  min-height: 18px;
  margin-bottom: 8px;
}

.modal-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 4px;
}

/* ─────────────────────────────
   Login page
───────────────────────────── */
body.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100vh;
  overflow: hidden;
  background: radial-gradient(ellipse at 50% 20%, #1a3d55 0%, #0B2538 45%, #071d2b 100%);
}

.login-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 32px;
  width: 100%;
  max-width: 400px;
  padding: 24px;
}

/* Brand block */
.login-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  text-align: center;
}

.login-icon {
  margin-bottom: 4px;
}

.login-icon img {
  filter: drop-shadow(0 4px 20px rgba(255,255,255,0.15));
}

.login-brand-name {
  font-size: 26px;
  font-weight: 700;
  color: #ffffff;
  letter-spacing: 0.5px;
}

.login-tagline {
  font-size: 18px;
  color: rgba(255,255,255,0.85);
  font-weight: 400;
}

.login-tagline-accent {
  color: var(--accent);
  font-style: italic;
  font-weight: 600;
}

/* Form card */
.login-card {
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 16px;
  padding: 32px 32px 28px;
  width: 100%;
  backdrop-filter: blur(8px);
}

.login-card-title {
  font-size: 15px;
  font-weight: 600;
  color: rgba(255,255,255,0.6);
  margin-bottom: 22px;
  letter-spacing: 0.2px;
}

#loginForm { width: 100%; display: flex; flex-direction: column; gap: 14px; }

.login-field { display: flex; flex-direction: column; gap: 6px; }

.login-field label {
  font-size: 12px;
  font-weight: 600;
  color: rgba(255,255,255,0.5);
  letter-spacing: 0.2px;
}

.login-field input {
  padding: 12px 14px;
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 10px;
  background: rgba(255,255,255,0.07);
  color: #ffffff;
  font-size: 14px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.login-field input::placeholder { color: rgba(255,255,255,0.2); }
.login-field input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 20%, transparent);
}

.login-error {
  min-height: 18px;
  font-size: 13px;
  color: #ff6b6b;
  text-align: center;
}

.btn-login {
  width: 100%;
  padding: 14px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  letter-spacing: 0.3px;
  transition: opacity 0.15s, transform 0.1s;
  margin-top: 6px;
  box-shadow: 0 4px 16px rgba(248,112,96,0.35);
}
.btn-login:hover { opacity: 0.9; transform: translateY(-1px); }
.btn-login:active { transform: translateY(0); }
.btn-login:disabled { opacity: 0.5; cursor: default; transform: none; }

.login-footer {
  font-size: 11px;
  color: rgba(255,255,255,0.2);
  text-align: center;
}

/* ─────────────────────────────
   Modal size variants
───────────────────────────── */
.modal-card-sm { max-width: 420px; }
.modal-card-lg {
  max-width: 760px;
  width: 760px;
  max-height: 88vh;
  overflow-y: auto;
}

/* ─────────────────────────────
   Delete confirmation modal
───────────────────────────── */
.delete-confirm-msg {
  color: var(--text-primary);
  font-size: 14px;
  line-height: 1.55;
  margin: 0 0 18px;
}

.delete-confirm-check {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 13px;
  line-height: 1.5;
  margin-bottom: 22px;
  user-select: none;
}

.delete-confirm-check input[type="checkbox"] {
  margin-top: 2px;
  width: 15px;
  height: 15px;
  accent-color: var(--accent);
  flex-shrink: 0;
  cursor: pointer;
}

.btn-danger {
  background: #e11d48;
  color: #fff;
  border: none;
  padding: 0 20px;
  height: 38px;
  border-radius: 7px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s;
}
.btn-danger:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-danger:not(:disabled):hover { opacity: 0.85; }

/* ─────────────────────────────
   Entry form section labels
───────────────────────────── */
.entry-form-section {
  margin-top: 20px;
  padding-top: 14px;
  border-top: 1px solid var(--surface-border);
}
.entry-form-section:first-of-type { margin-top: 0; border-top: none; padding-top: 0; }

/* ─────────────────────────────
   System Settings
───────────────────────────── */
.settings-card {
  background: var(--surface-bg);
  border: 1px solid var(--surface-border);
  border-radius: 12px;
  padding: 22px 24px 20px;
  max-width: 700px;
  margin-bottom: 0;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06), 0 4px 18px rgba(0,0,0,0.05);
}

.settings-card-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--surface-border);
}

.settings-card-header h3 {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
}

.settings-card-desc {
  font-size: 12.5px;
  color: var(--text-secondary);
  margin: 0 0 14px;
  line-height: 1.5;
}

.settings-card-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--surface-border);
}

.settings-grid {
  display: flex;
  flex-direction: column;
  gap: 0;
}

/* Default row: horizontal label + input */
.settings-row {
  display: grid;
  grid-template-columns: 160px 1fr;
  align-items: center;
  padding: 9px 0;
  border-bottom: 1px solid var(--surface-border);
  gap: 12px;
}

.settings-row:last-child { border-bottom: none; }

/* Email card: stacked label-above-input layout */
.settings-card-email .settings-row {
  grid-template-columns: 1fr;
  gap: 5px;
  padding: 10px 0;
}

.settings-card-email .settings-row:has(.settings-checkbox) {
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 12px;
}

.settings-card-email .settings-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-secondary);
}

.settings-card-email .settings-row:has(.settings-checkbox) .settings-label {
  font-size: 13px;
  font-weight: 500;
  text-transform: none;
  letter-spacing: 0;
  color: var(--text-primary);
}

.settings-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
}

.settings-input {
  width: 100%;
  padding: 8px 11px;
  border: 1px solid var(--input-border);
  border-radius: 7px;
  background: var(--input-bg);
  color: var(--text-primary);
  font-size: 13px;
  box-sizing: border-box;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.settings-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 15%, transparent);
}

.settings-input-sm { max-width: 100px; }

.settings-checkbox {
  display: inline-flex;
  align-items: center;
  cursor: pointer;
  position: relative;
  width: 20px;
  height: 20px;
}

.settings-checkbox input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.settings-checkbox-box {
  width: 18px;
  height: 18px;
  border: 2px solid var(--input-border);
  border-radius: 4px;
  background: var(--input-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s, border-color 0.15s;
}

.settings-checkbox input:checked + .settings-checkbox-box {
  background: var(--accent);
  border-color: var(--accent);
}

.settings-checkbox input:checked + .settings-checkbox-box::after {
  content: '';
  display: block;
  width: 4px;
  height: 8px;
  border: 2px solid #fff;
  border-top: none;
  border-left: none;
  transform: rotate(45deg) translate(-1px, -1px);
}

.settings-actions {
  margin-top: 18px;
  display: flex;
  justify-content: flex-end;
}

/* ─────────────────────────────
   Side-by-side settings layout
───────────────────────────── */
.settings-cards-row {
  display: flex;
  gap: 20px;
  align-items: stretch;
  flex-wrap: wrap;
}

.settings-card-email {
  flex: 0 0 380px;
  max-width: 380px;
  display: flex;
  flex-direction: column;
}

.settings-card-email .settings-grid {
  flex: 1;
  justify-content: space-between;
}

.settings-card-api {
  flex: 1;
  min-width: 400px;
  max-width: none;
}

/* ─────────────────────────────
   API Config — tab nav
───────────────────────────── */
.api-tabs {
  display: flex;
  background: var(--surface-header-bg);
  border: 1px solid var(--surface-border);
  border-radius: 8px;
  padding: 4px;
  gap: 2px;
  margin-bottom: 16px;
}

.api-tab {
  flex: 1;
  background: none;
  border: none;
  border-radius: 6px;
  padding: 7px 10px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  transition: color 0.15s, background 0.15s;
  white-space: nowrap;
  text-align: center;
}

.api-tab:hover { color: var(--text-primary); background: var(--surface-hover-bg); }

.api-tab.active {
  background: var(--surface-bg);
  color: var(--accent);
  font-weight: 600;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

/* ─────────────────────────────
   API Config — tab panes & rows
───────────────────────────── */
.api-tab-pane {
  display: none;
}

.api-tab-pane.active {
  display: block;
  animation: fadeIn 0.15s ease;
}

@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.api-row {
  display: grid;
  grid-template-columns: 170px 1fr;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--surface-border);
  gap: 12px;
  min-height: 44px;
}

.api-tab-pane > .api-row:last-child,
.api-tab-pane > .api-row.api-row-expandable { border-bottom: none; }

.api-row-split {
  grid-template-columns: 170px 120px 68px 1fr;
}

.api-encoding-label { padding-left: 8px; }

.api-row-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  align-self: center;
}

.api-verb-select { max-width: 120px; }

.api-check-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.api-check-input { flex: 1; }

.api-details-btn {
  background: none;
  border: 1px solid var(--surface-border);
  color: var(--accent);
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  padding: 4px 10px;
  border-radius: 5px;
  transition: background 0.12s, border-color 0.12s;
}

.api-details-btn:hover {
  background: var(--surface-hover-bg);
  border-color: var(--accent);
}

.api-expand-pane {
  display: none;
  padding: 10px 0 12px;
  border-bottom: 1px solid var(--surface-border);
}

.api-expand-pane.open { display: block; }

.api-tab-pane > .api-expand-pane:last-child { border-bottom: none; }

.api-textarea {
  resize: vertical;
  min-height: 72px;
  font-family: 'Consolas', 'Courier New', monospace;
  font-size: 12px;
  line-height: 1.5;
}

.api-obj-attr {
  display: flex;
  gap: 10px;
}

.api-obj-attr-field {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.api-obj-attr-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-secondary);
}

/* ─────────────────────────────
   Upload drop zone
───────────────────────────── */
.upload-drop-zone {
  border: 2px dashed var(--surface-border);
  border-radius: 8px;
  padding: 32px 20px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  margin-bottom: 16px;
}

.upload-drop-zone:hover,
.upload-drop-zone.drag-over {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 6%, transparent);
}

.upload-drop-label {
  margin: 10px 0 4px;
  font-size: 13px;
  color: var(--text-secondary);
}

.upload-browse-link {
  color: var(--accent);
  cursor: pointer;
  text-decoration: underline;
}

.upload-file-name {
  font-size: 12px;
  color: var(--text-secondary);
  margin: 4px 0 0;
  min-height: 16px;
}

/* ─────────────────────────────
   Upload modal meta strip
───────────────────────────── */
.upload-modal-meta {
  display: flex;
  gap: 20px;
  background: var(--surface-hover, rgba(0,0,0,.04));
  border: 1px solid var(--surface-border);
  border-radius: 8px;
  padding: 10px 14px;
  margin-bottom: 16px;
}

.upload-modal-meta-field {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-secondary);
}

.upload-modal-meta-field svg {
  fill: var(--text-secondary);
  flex-shrink: 0;
}

/* ─────────────────────────────
   Upload history section
───────────────────────────── */
.ue-uploads-section {
  margin-top: 28px;
}

.uploads-count {
  font-size: 12px;
  color: var(--text-secondary);
  font-weight: 500;
}

.uploads-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 12px;
}

.upload-card {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--surface);
  border: 1px solid var(--surface-border);
  border-radius: 10px;
  padding: 14px 18px;
  transition: box-shadow 0.15s;
}

.upload-card:hover {
  box-shadow: 0 2px 10px rgba(0,0,0,.08);
}

.upload-card-icon {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.upload-card-icon svg {
  fill: var(--accent);
  width: 22px;
  height: 22px;
}

.upload-card-body {
  flex: 1;
  min-width: 0;
}

.upload-card-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.upload-card-file {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.upload-card-right {
  text-align: right;
  flex-shrink: 0;
}

.upload-card-user {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
}

.upload-card-date {
  font-size: 11px;
  color: var(--text-secondary);
  margin-top: 2px;
}

.upload-card-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
  margin-left: 8px;
}

.btn-sm {
  padding: 5px 10px;
  font-size: 12px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border-radius: 6px;
  border: none;
  cursor: pointer;
  font-weight: 500;
  white-space: nowrap;
}

.btn-sm svg {
  flex-shrink: 0;
}

.btn-outline.btn-sm {
  background: transparent;
  border: 1px solid var(--surface-border);
  color: var(--text-primary);
}

.btn-outline.btn-sm:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.btn-danger.btn-sm {
  background: transparent;
  border: 1px solid #e53e3e;
  color: #e53e3e;
}

.btn-danger.btn-sm:hover {
  background: #e53e3e;
  color: #fff;
}

/* ─────────────────────────────
   PDF Viewer Modal
───────────────────────────── */
.modal-viewer-overlay {
  padding: 24px;
}

.modal-card-viewer {
  width: 100%;
  max-width: 960px;
  height: calc(100vh - 48px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.viewer-header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.viewer-header-actions .btn-outline {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  padding: 6px 14px;
}

.viewer-header-actions .btn-outline svg {
  fill: currentColor;
}

.viewer-loading {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  font-size: 14px;
}

.viewer-frame {
  flex: 1;
  width: 100%;
  border: none;
  border-radius: 0 0 10px 10px;
}
