/* ==========================================================================
   PSU Phuket Student Loan Portal (studentlaon-psuphuket)
   Design System CSS — Institutional Civic Clarity + Personalization Studio
   ========================================================================== */

:root {
  /* Default Theme: PSU Deep Navy & Andaman Sky */
  --brand-primary: #003c71;
  --brand-primary-hover: #002b52;
  --brand-accent: #0284c7;
  --brand-accent-soft: rgba(2, 132, 199, 0.11);
  --brand-highlight: #38bdf8;
  --brand-sritrang: #6d5acf;

  /* Light Surface Tokens */
  --bg-ground: #f4f7fb;
  --bg-surface: #ffffff;
  --bg-subtle: #eef3f9;
  --bg-elevated: #ffffff;
  --border-subtle: #dbe4f0;
  --border-strong: #b9c8dc;

  /* Typography Ink */
  --ink-primary: #0f1d33;
  --ink-secondary: #3f526d;
  --ink-muted: #647792;
  --ink-on-brand: #ffffff;

  /* Semantic Status Colors */
  --status-open: #059669;
  --status-open-bg: rgba(5, 150, 105, 0.11);
  --status-warn: #d97706;
  --status-warn-bg: rgba(217, 119, 6, 0.12);
  --status-danger: #dc2626;
  --status-danger-bg: rgba(220, 38, 38, 0.11);
  --status-override: #7c3aed;
  --status-override-bg: rgba(124, 58, 237, 0.12);

  /* Typography & Scale */
  --font-sans: 'Anuphan', 'Sarabun', system-ui, -apple-system, sans-serif;
  --root-font-size: 16px;

  /* Radius Grammar */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --radius-pill: 999px;

  /* Controlled Elevation */
  --shadow-xs: 0 1px 2px rgba(15, 29, 51, 0.05);
  --shadow-sm: 0 4px 12px rgba(15, 29, 51, 0.06);
  --shadow-md: 0 12px 28px rgba(15, 29, 51, 0.09);
  --shadow-lg: 0 24px 48px rgba(15, 29, 51, 0.16);
}

/* Color Theme Presets */
[data-theme="andaman-teal"] {
  --brand-primary: #0f5c6e;
  --brand-primary-hover: #0a4250;
  --brand-accent: #0d9488;
  --brand-accent-soft: rgba(13, 148, 136, 0.12);
  --brand-highlight: #2dd4bf;
}

[data-theme="sritrang-royal"] {
  --brand-primary: #3b2d71;
  --brand-primary-hover: #291e54;
  --brand-accent: #6d5acf;
  --brand-accent-soft: rgba(109, 90, 207, 0.12);
  --brand-highlight: #a78bfa;
}

[data-theme="emerald-civic"] {
  --brand-primary: #14532d;
  --brand-primary-hover: #0d3b20;
  --brand-accent: #059669;
  --brand-accent-soft: rgba(5, 150, 105, 0.12);
  --brand-highlight: #34d399;
}

[data-theme="warm-sand"] {
  --brand-primary: #5c3d2e;
  --brand-primary-hover: #422a1f;
  --brand-accent: #b45309;
  --brand-accent-soft: rgba(180, 83, 9, 0.12);
  --brand-highlight: #f59e0b;
  --bg-ground: #faf7f2;
  --bg-subtle: #f3ede3;
  --border-subtle: #e5dccf;
}

/* Dark Mode Surface Overrides */
[data-mode="dark"] {
  --bg-ground: #0a1220;
  --bg-surface: #111d32;
  --bg-subtle: #172640;
  --bg-elevated: #192a47;
  --border-subtle: #243757;
  --border-strong: #36507a;
  --ink-primary: #f1f5f9;
  --ink-secondary: #cbd5e1;
  --ink-muted: #94a3b8;
  --shadow-xs: 0 1px 3px rgba(0, 0, 0, 0.35);
  --shadow-sm: 0 6px 16px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 14px 32px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 24px 56px rgba(0, 0, 0, 0.65);
}

[data-mode="dark"][data-theme="psu-navy"] {
  --brand-primary: #0ea5e9;
  --brand-primary-hover: #38bdf8;
  --brand-accent: #38bdf8;
  --brand-accent-soft: rgba(56, 189, 248, 0.15);
  --ink-on-brand: #08111f;
}

[data-mode="dark"][data-theme="andaman-teal"] {
  --brand-primary: #2dd4bf;
  --brand-primary-hover: #5eead4;
  --brand-accent: #14b8a6;
  --brand-accent-soft: rgba(45, 212, 191, 0.15);
  --ink-on-brand: #06181a;
}

[data-mode="dark"][data-theme="sritrang-royal"] {
  --brand-primary: #a78bfa;
  --brand-primary-hover: #c4b5fd;
  --brand-accent: #8b5cf6;
  --brand-accent-soft: rgba(167, 139, 250, 0.16);
  --ink-on-brand: #130d26;
}

[data-mode="dark"][data-theme="emerald-civic"] {
  --brand-primary: #34d399;
  --brand-primary-hover: #6ee7b7;
  --brand-accent: #10b981;
  --brand-accent-soft: rgba(52, 211, 153, 0.15);
  --ink-on-brand: #061c12;
}

[data-mode="dark"][data-theme="warm-sand"] {
  --brand-primary: #fbbf24;
  --brand-primary-hover: #fcd34d;
  --brand-accent: #f59e0b;
  --brand-accent-soft: rgba(251, 191, 36, 0.15);
  --ink-on-brand: #1c1208;
}

/* Font Scale Presets */
html[data-font-scale="sm"] { font-size: 14.75px; }
html[data-font-scale="md"] { font-size: 16px; }
html[data-font-scale="lg"] { font-size: 17.25px; }
html[data-font-scale="xl"] { font-size: 18.75px; }

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

body {
  margin: 0;
  padding: 0;
  font-family: var(--font-sans);
  background-color: var(--bg-ground);
  color: var(--ink-primary);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-wrap: pretty;
  padding-bottom: env(safe-area-inset-bottom, 0);
}

h1, h2, h3, h4 {
  margin: 0 0 0.5rem 0;
  line-height: 1.3;
  letter-spacing: -0.01em;
  color: var(--ink-primary);
}

p {
  margin: 0 0 0.75rem 0;
}

a {
  color: var(--brand-accent);
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}

button, input, select, textarea {
  font-family: inherit;
}

/* Keep form inputs >= 16px so mobile Safari never auto-zooms */
input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="date"],
input[type="datetime-local"],
input[type="tel"],
input[type="url"],
input[type="search"],
select,
textarea {
  width: 100%;
  min-height: 44px;
  padding: 0.625rem 0.875rem;
  font-size: max(1rem, 16px);
  color: var(--ink-primary);
  background-color: var(--bg-surface);
  border: 1.5px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

textarea {
  min-height: 104px;
  resize: vertical;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--brand-accent);
  box-shadow: 0 0 0 3px var(--brand-accent-soft);
}

input[readonly], input:disabled, select:disabled, textarea:disabled {
  background-color: var(--bg-subtle);
  color: var(--ink-muted);
  cursor: not-allowed;
}

/* Permanent Field Labels & Hints (GOV.UK / Singpass Civic Clarity) */
.field-group {
  display: flex;
  flex-direction: column;
  gap: 0.32rem;
  margin-bottom: 1.1rem;
}

.field-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.field-label {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--ink-primary);
}

.field-req {
  color: var(--status-danger);
  margin-left: 0.2rem;
}

.field-hint {
  font-size: 0.84rem;
  color: var(--ink-muted);
  line-height: 1.45;
}

/* Layout Containers */
.container {
  width: 100%;
  max-width: 1260px;
  margin: 0 auto;
  padding: 0 1.25rem;
}

/* Top Official Bar & Navigation */
.top-notice-bar {
  background-color: #002649;
  color: #e0f2fe;
  font-size: 0.84rem;
  padding: 0.45rem 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.top-notice-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background-color: var(--bg-surface);
  border-bottom: 1px solid var(--border-subtle);
  box-shadow: var(--shadow-xs);
  backdrop-filter: blur(10px);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 70px;
  gap: 1rem;
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  cursor: pointer;
  user-select: none;
}

.brand-crest {
  width: 44px;
  height: 44px;
  border-radius: 11px;
  flex-shrink: 0;
}

.brand-title {
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--ink-primary);
  line-height: 1.2;
}

.brand-subtitle {
  font-size: 0.78rem;
  color: var(--ink-muted);
}

.desktop-nav {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex-wrap: wrap;
}

.nav-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  min-height: 40px;
  padding: 0.45rem 0.85rem;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: transparent;
  color: var(--ink-secondary);
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.nav-btn:hover {
  background-color: var(--bg-subtle);
  color: var(--ink-primary);
}

.nav-btn.active {
  background-color: var(--brand-accent-soft);
  color: var(--brand-primary);
  border-color: rgba(2, 132, 199, 0.22);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.55rem;
}

.user-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.3rem 0.7rem 0.3rem 0.35rem;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border-subtle);
  background-color: var(--bg-subtle);
  cursor: pointer;
  min-height: 42px;
}

.avatar-circle {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background-color: var(--brand-primary);
  color: var(--ink-on-brand);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.86rem;
  overflow: hidden;
  flex-shrink: 0;
}

.avatar-circle img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.48rem;
  min-height: 44px;
  padding: 0.55rem 1.1rem;
  border-radius: var(--radius-sm);
  font-size: 0.94rem;
  font-weight: 600;
  border: 1.5px solid transparent;
  cursor: pointer;
  transition: transform 0.1s ease, background-color 0.15s ease, border-color 0.15s ease, opacity 0.15s ease;
  text-decoration: none;
}

.btn:active:not(:disabled) {
  transform: translateY(1px);
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn-sm {
  min-height: 36px;
  padding: 0.35rem 0.75rem;
  font-size: 0.85rem;
}

.btn-primary {
  background-color: var(--brand-primary);
  color: var(--ink-on-brand);
}
.btn-primary:hover:not(:disabled) {
  background-color: var(--brand-primary-hover);
  text-decoration: none;
}

.btn-accent {
  background-color: var(--brand-accent);
  color: #ffffff;
}
.btn-accent:hover:not(:disabled) {
  filter: brightness(0.93);
  text-decoration: none;
}

.btn-outline {
  background-color: var(--bg-surface);
  border-color: var(--border-strong);
  color: var(--ink-primary);
}
.btn-outline:hover:not(:disabled) {
  background-color: var(--bg-subtle);
  text-decoration: none;
}

.btn-ghost {
  background-color: transparent;
  color: var(--ink-secondary);
}
.btn-ghost:hover:not(:disabled) {
  background-color: var(--bg-subtle);
  color: var(--ink-primary);
}

.btn-success {
  background-color: var(--status-open);
  color: #ffffff;
}

.btn-danger {
  background-color: var(--status-danger);
  color: #ffffff;
}

.btn-override {
  background-color: var(--status-override);
  color: #ffffff;
}

.icon-help-btn {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 1px solid var(--border-strong);
  background-color: var(--bg-surface);
  color: var(--brand-accent);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.82rem;
  cursor: pointer;
}
.icon-help-btn:hover {
  background-color: var(--brand-accent-soft);
}

/* Badges & Pills */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.22rem 0.65rem;
  border-radius: var(--radius-pill);
  font-size: 0.79rem;
  font-weight: 600;
  white-space: nowrap;
}

.badge-open {
  background-color: var(--status-open-bg);
  color: var(--status-open);
}

.badge-warn {
  background-color: var(--status-warn-bg);
  color: var(--status-warn);
}

.badge-closed, .badge-danger {
  background-color: var(--status-danger-bg);
  color: var(--status-danger);
}

.badge-override {
  background-color: var(--status-override-bg);
  color: var(--status-override);
}

.badge-neutral {
  background-color: var(--bg-subtle);
  color: var(--ink-secondary);
  border: 1px solid var(--border-subtle);
}

.pulse-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: currentColor;
}

/* Cards & Surfaces */
.surface-card {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 1.35rem;
  box-shadow: var(--shadow-xs);
}

.surface-card-lg {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 1.75rem;
  box-shadow: var(--shadow-sm);
}

/* Public Hero (PSU Phuket Institutional Composition) */
.hero-banner {
  background: linear-gradient(135deg, #00284d 0%, #003c71 58%, #0369a1 100%);
  color: #ffffff;
  padding: 2.75rem 0 2.5rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

.hero-grid {
  display: grid;
  grid-template-columns: 1.25fr 0.95fr;
  gap: 2rem;
  align-items: center;
}

.hero-kicker {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.3rem 0.8rem;
  border-radius: var(--radius-pill);
  background: rgba(56, 189, 248, 0.18);
  border: 1px solid rgba(56, 189, 248, 0.35);
  color: #bae6fd;
  font-size: 0.83rem;
  font-weight: 600;
  margin-bottom: 0.9rem;
}

.hero-title {
  color: #ffffff;
  font-size: clamp(1.65rem, 3.2vw, 2.45rem);
  font-weight: 700;
  margin-bottom: 0.85rem;
}

.hero-lead {
  color: #dbeafe;
  font-size: 1.02rem;
  max-width: 62ch;
  margin-bottom: 1.4rem;
}

.hero-status-panel {
  background: rgba(9, 22, 42, 0.62);
  border: 1px solid rgba(186, 230, 253, 0.24);
  border-radius: var(--radius-lg);
  padding: 1.35rem;
  backdrop-filter: blur(8px);
}

.module-live-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.7rem 0.85rem;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.07);
  margin-bottom: 0.55rem;
}
.module-live-row:last-child {
  margin-bottom: 0;
}

/* Grids & Utilities */
.main-content {
  padding: 1.85rem 0 4.5rem;
  min-height: calc(100vh - 220px);
}

.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1.25rem;
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1.25rem;
}

.grid-4 {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1rem;
}

.form-grid-12 {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 0 1.15rem;
}

.col-span-12 { grid-column: span 12; }
.col-span-6 { grid-column: span 6; }

/* Maintenance Alert */
.maintenance-alert {
  background-color: var(--status-warn-bg);
  border: 1.5px solid var(--status-warn);
  color: var(--ink-primary);
  border-radius: var(--radius-md);
  padding: 1rem 1.25rem;
  display: flex;
  align-items: flex-start;
  gap: 0.85rem;
  margin-bottom: 1.5rem;
}

/* Tabs */
.tabs-bar {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  overflow-x: auto;
  padding-bottom: 0.35rem;
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: 1.35rem;
}

.tab-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  min-height: 42px;
  padding: 0.45rem 1rem;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: transparent;
  color: var(--ink-secondary);
  font-weight: 600;
  font-size: 0.92rem;
  white-space: nowrap;
  cursor: pointer;
}

.tab-pill:hover {
  background-color: var(--bg-subtle);
}

.tab-pill.active {
  background-color: var(--brand-primary);
  color: var(--ink-on-brand);
}

/* Tables */
.table-wrap {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  background-color: var(--bg-surface);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.91rem;
}

.data-table th {
  text-align: left;
  padding: 0.8rem 0.95rem;
  background-color: var(--bg-subtle);
  color: var(--ink-secondary);
  font-weight: 700;
  border-bottom: 1px solid var(--border-subtle);
  white-space: nowrap;
}

.data-table td {
  padding: 0.8rem 0.95rem;
  border-bottom: 1px solid var(--border-subtle);
  vertical-align: middle;
}

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

.data-table tbody tr:hover {
  background-color: var(--bg-subtle);
}

/* Checklist Upload Slots */
.checklist-slot {
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--radius-md);
  padding: 1rem 1.15rem;
  background-color: var(--bg-surface);
  margin-bottom: 0.85rem;
  transition: border-color 0.15s ease, background-color 0.15s ease;
}

.checklist-slot.uploaded {
  border-style: solid;
  border-color: var(--status-open);
  background-color: var(--status-open-bg);
}

/* Split-View Reviewer Workspace */
.split-reviewer {
  display: grid;
  grid-template-columns: 1.05fr 1fr;
  gap: 1.25rem;
  min-height: 72vh;
}

.split-pane {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  overflow-y: auto;
  max-height: 80vh;
}

.doc-preview-frame {
  width: 100%;
  height: 500px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  background-color: var(--bg-subtle);
}

/* Form Builder Layout */
.builder-layout {
  display: grid;
  grid-template-columns: 290px 1fr;
  gap: 1.35rem;
  align-items: start;
}

.builder-field-card {
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 1rem;
  background-color: var(--bg-surface);
  margin-bottom: 0.8rem;
}

/* Profile & Theme Studio */
.profile-banner {
  background: linear-gradient(125deg, var(--brand-primary) 0%, var(--brand-accent) 100%);
  border-radius: var(--radius-lg);
  padding: 1.75rem;
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  flex-wrap: wrap;
  margin-bottom: 1.5rem;
}

.profile-avatar-xl {
  width: 92px;
  height: 92px;
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.85);
  background-color: rgba(0, 0, 0, 0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  font-weight: 700;
  color: #ffffff;
  overflow: hidden;
  flex-shrink: 0;
}

.profile-avatar-xl img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.theme-swatch-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(175px, 1fr));
  gap: 0.75rem;
}

.swatch-card {
  border: 2px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 0.8rem;
  background-color: var(--bg-surface);
  cursor: pointer;
  text-align: left;
  transition: border-color 0.15s ease, transform 0.1s ease;
}

.swatch-card.active {
  border-color: var(--brand-accent);
  background-color: var(--brand-accent-soft);
}

.font-option-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 0.75rem;
}

/* Timeline */
.timeline-list {
  list-style: none;
  margin: 0;
  padding: 0 0 0 1.15rem;
  border-left: 2px solid var(--border-strong);
}

.timeline-item {
  position: relative;
  padding-bottom: 1rem;
  padding-left: 0.85rem;
}

.timeline-item::before {
  content: '';
  position: absolute;
  left: -1.52rem;
  top: 0.32rem;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background-color: var(--brand-accent);
  border: 2px solid var(--bg-surface);
}

/* Custom Accessible Modal & Toast System (NEVER native alert/confirm) */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 200;
  background-color: rgba(8, 17, 32, 0.62);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.modal-box {
  width: 100%;
  max-width: 560px;
  max-height: 92vh;
  overflow-y: auto;
  background-color: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow-lg);
}

.modal-box.modal-xl {
  max-width: 1180px;
}

.toast-stack {
  position: fixed;
  top: 1.1rem;
  right: 1.1rem;
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  max-width: 390px;
  width: calc(100% - 2.2rem);
  pointer-events: none;
}

.toast-item {
  pointer-events: auto;
  background-color: var(--bg-elevated);
  color: var(--ink-primary);
  border: 1px solid var(--border-strong);
  border-left: 4px solid var(--brand-accent);
  border-radius: var(--radius-sm);
  padding: 0.85rem 1rem;
  box-shadow: var(--shadow-md);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
}
.toast-item.success { border-left-color: var(--status-open); }
.toast-item.error { border-left-color: var(--status-danger); }
.toast-item.warn { border-left-color: var(--status-warn); }

/* Footer */
.site-footer {
  background-color: var(--bg-surface);
  border-top: 1px solid var(--border-subtle);
  padding: 2rem 0 2.5rem;
  color: var(--ink-secondary);
  font-size: 0.9rem;
}

/* Mobile Bottom Navigation */
.mobile-bottom-nav {
  display: none;
}

/* Responsive Breakpoints */
@media (max-width: 980px) {
  .hero-grid,
  .split-reviewer,
  .builder-layout {
    grid-template-columns: 1fr;
  }
  .grid-4 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .grid-3 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 768px) {
  .desktop-nav {
    display: none;
  }
  .grid-2, .grid-3, .grid-4 {
    grid-template-columns: 1fr;
  }
  .col-span-6 {
    grid-column: span 12;
  }
  .main-content {
    padding-bottom: 5.75rem;
  }
  .site-footer {
    padding-bottom: 5.5rem;
  }
  .mobile-bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 90;
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    background-color: var(--bg-surface);
    border-top: 1px solid var(--border-subtle);
    padding: 0.3rem 0.25rem calc(0.3rem + env(safe-area-inset-bottom, 0));
    box-shadow: 0 -4px 16px rgba(15, 29, 51, 0.08);
  }
  .mobile-nav-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.18rem;
    min-height: 50px;
    border: none;
    background: transparent;
    color: var(--ink-muted);
    font-size: 0.72rem;
    font-weight: 600;
    cursor: pointer;
    padding: 0.2rem;
  }
  .mobile-nav-btn.active {
    color: var(--brand-accent);
  }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* Scrolling Announcement News Ticker (Marquee Bar) */
.news-ticker-bar {
  background-color: #0b2d52;
  color: #f0f9ff;
  border-bottom: 1px solid rgba(56, 189, 248, 0.25);
  overflow: hidden;
  display: flex;
  align-items: center;
  min-height: 38px;
}

.news-ticker-badge {
  background-color: #0284c7;
  color: #ffffff;
  font-weight: 700;
  font-size: 0.78rem;
  padding: 0.45rem 0.9rem;
  white-space: nowrap;
  z-index: 2;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.news-ticker-viewport {
  overflow: hidden;
  flex: 1;
  position: relative;
}

.news-ticker-track {
  display: inline-block;
  white-space: nowrap;
  padding-left: 100%;
  font-size: 0.88rem;
  font-weight: 500;
  animation: psuTickerScroll var(--ticker-duration, 28s) linear infinite;
}

.news-ticker-bar:hover .news-ticker-track {
  animation-play-state: paused;
}

@keyframes psuTickerScroll {
  0% { transform: translateX(0); }
  100% { transform: translateX(-100%); }
}

@media (prefers-reduced-motion: reduce) {
  .news-ticker-track {
    animation: none;
    padding-left: 1rem;
    white-space: normal;
  }
}

/* PDPA Consent Box */
.pdpa-consent-box {
  padding: 0.9rem 1.05rem;
  border-radius: var(--radius-md);
  background-color: var(--brand-accent-soft);
  border: 1.5px solid rgba(2, 132, 199, 0.3);
  margin: 1rem 0;
}

/* ==========================================================================
   V3 UI/UX Polish: High-Contrast Dark Mode, Hamburger Drawer, Loading Modal,
   SweetAlert-Style Result Modal, and Notification Bell
   ========================================================================== */

/* High-Contrast Dark Mode Fixes (Crystal-Clear Readability Everywhere) */
[data-mode="dark"] {
  --bg-ground: #0b1220;
  --bg-surface: #131f35;
  --bg-subtle: #1a2942;
  --bg-elevated: #182741;
  --border-subtle: #2b4063;
  --border-strong: #425e8c;
  --ink-primary: #f8fafc;
  --ink-secondary: #e2e8f0;
  --ink-muted: #cbd5e1;
  --status-open: #34d399;
  --status-open-bg: rgba(16, 185, 129, 0.2);
  --status-warn: #fbbf24;
  --status-warn-bg: rgba(245, 158, 11, 0.22);
  --status-danger: #f87171;
  --status-danger-bg: rgba(239, 68, 68, 0.22);
  --status-override: #c084fc;
  --status-override-bg: rgba(168, 85, 247, 0.22);
}

[data-mode="dark"] a {
  color: #7dd3fc;
}

[data-mode="dark"] h1,
[data-mode="dark"] h2,
[data-mode="dark"] h3,
[data-mode="dark"] h4,
[data-mode="dark"] .field-label {
  color: #f8fafc;
}

[data-mode="dark"] input,
[data-mode="dark"] select,
[data-mode="dark"] textarea {
  background-color: #0f1a2d;
  color: #f8fafc;
  border-color: #36507a;
}

[data-mode="dark"] input::placeholder,
[data-mode="dark"] textarea::placeholder {
  color: #94a3b8;
}

[data-mode="dark"] select option {
  background-color: #131f35;
  color: #f8fafc;
}

[data-mode="dark"] code,
[data-mode="dark"] pre {
  color: #e2e8f0;
  background-color: #0f1a2d;
}

[data-mode="dark"] .badge-neutral {
  background-color: #1e3150;
  color: #e2e8f0;
  border-color: #36507a;
}

[data-mode="dark"] .btn-outline {
  background-color: #182741;
  color: #f8fafc;
  border-color: #4b6899;
}

[data-mode="dark"] .btn-outline:hover:not(:disabled) {
  background-color: #223557;
}

/* Responsive Hamburger Button & Slide-Out Drawer (Tablet & Mobile <= 1080px) */
.hamburger-btn {
  display: none;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border-strong);
  background-color: var(--bg-surface);
  color: var(--ink-primary);
  cursor: pointer;
}

.nav-drawer-backdrop {
  position: fixed;
  inset: 0;
  z-index: 180;
  background: rgba(8, 17, 32, 0.58);
  backdrop-filter: blur(4px);
  display: flex;
  justify-content: flex-end;
}

.nav-drawer {
  width: min(320px, 86vw);
  height: 100%;
  background: var(--bg-elevated);
  border-left: 1px solid var(--border-subtle);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  padding: 1.25rem;
  overflow-y: auto;
  gap: 0.45rem;
}

.drawer-nav-link {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  min-height: 46px;
  padding: 0.65rem 0.9rem;
  border-radius: var(--radius-sm);
  color: var(--ink-primary);
  font-weight: 600;
  font-size: 0.96rem;
  text-decoration: none;
  border: 1px solid transparent;
}

.drawer-nav-link:hover {
  background-color: var(--bg-subtle);
  text-decoration: none;
}

.drawer-nav-link.active {
  background-color: var(--brand-accent-soft);
  color: var(--brand-accent);
  border-color: rgba(2, 132, 199, 0.28);
}

@media (max-width: 1080px) {
  .desktop-nav {
    display: none !important;
  }
  .hamburger-btn {
    display: inline-flex;
  }
  .user-chip-name {
    display: none;
  }
}

/* Global Loading Modal Overlay (Blocks Double-Clicks) */
.loading-overlay {
  position: fixed;
  inset: 0;
  z-index: 400;
  background: rgba(8, 17, 32, 0.62);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.loading-card {
  background: var(--bg-elevated);
  color: var(--ink-primary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 1.85rem 2.25rem;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.9rem;
  min-width: 260px;
  max-width: 380px;
  text-align: center;
}

.loading-spinner {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 4px solid var(--border-subtle);
  border-top-color: var(--brand-accent);
  animation: psuSpin 0.8s linear infinite;
}

@keyframes psuSpin {
  to { transform: rotate(360deg); }
}

/* Notification Bell with Unread Badge */
.noti-bell-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  background: var(--bg-subtle);
  color: var(--ink-primary);
  cursor: pointer;
}

.noti-count-badge {
  position: absolute;
  top: -5px;
  right: -5px;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  border-radius: 999px;
  background: #dc2626;
  color: #ffffff;
  font-size: 0.72rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
