/* ── Reset & Base ─────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }

/* ── CSS Variables ────────────────────────────────────────────── */
:root {
  --background:        hsl(220, 20%, 95%);
  --foreground:        hsl(222.2, 84%, 4.9%);
  --card:              hsl(0, 0%, 100%);
  --card-foreground:   hsl(222.2, 84%, 4.9%);
  --primary:           hsl(195, 20%, 60%);
  --primary-fg:        hsl(210, 40%, 98%);
  --secondary:         hsl(210, 40%, 96.1%);
  --secondary-fg:      hsl(222.2, 47.4%, 11.2%);
  --muted:             hsl(210, 40%, 96.1%);
  --muted-fg:          hsl(215.4, 16.3%, 46.9%);
  --accent:            hsl(210, 40%, 96.1%);
  --accent-fg:         hsl(222.2, 47.4%, 11.2%);
  --destructive:       hsl(0, 84.2%, 60.2%);
  --destructive-fg:    hsl(210, 40%, 98%);
  --border:            hsl(214.3, 31.8%, 91.4%);
  --input:             hsl(214.3, 31.8%, 91.4%);
  --ring:              hsl(220, 13%, 69%);
  --radius:            0.5rem;
  --sidebar-bg:        hsl(222, 47%, 11%);
  --sidebar-fg:        hsl(210, 40%, 98%);
  --sidebar-accent:    hsl(217.2, 32.6%, 17.5%);
  --sidebar-accent-fg: hsl(210, 40%, 98%);
  --brand-orange:      #F97316;
  --brand-green:       #43A047;
  --submit-flight:     rgb(120, 162, 181);
  --font-body:         'PT Sans', sans-serif;
  --font-headline:     'Space Grotesk', sans-serif;
}

/* ── Body & Layout ────────────────────────────────────────────── */
html, body {
  min-height: 100vh;
}

body {
  display: flex;
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.6;
  color: var(--foreground);
  background: var(--background);
}

body.noframe {
  display: block;
  background: var(--background);
}

/* ── Sidebar ──────────────────────────────────────────────────── */
.sidebar {
  width: 240px;
  min-height: 100vh;
  background: var(--sidebar-bg);
  color: var(--sidebar-fg);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  z-index: 100;
  transition: transform 0.25s ease, width 0.25s ease;
}

.sidebar-header {
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  flex-shrink: 0;
}

.sidebar-logo {
  max-height: 36px;
  max-width: 160px;
  width: auto;
  margin-left: 8px;
}

.sidebar-hamburger {
  color: rgba(248,250,252,0.6);
  cursor: pointer;
  background: none;
  border: none;
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
}
.sidebar-hamburger:hover { background: rgba(255,255,255,0.05); }

.sidebar-nav {
  list-style: none;
  padding: 8px;
  flex: 1;
  overflow-y: auto;
}

.sidebar-nav li { margin: 0; }

/* ── Sidebar Nav (design system sd-* classes) ─────────────────── */
.sd-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 8px;
  border-radius: 4px;
  font-size: 13px;
  font-weight: 500;
  color: rgba(248,250,252,0.75);
  cursor: pointer;
  position: relative;
  text-decoration: none;
  transition: background 0.1s;
}

.sd-item.active {
  background: var(--sidebar-accent);
  color: var(--sidebar-fg);
  font-weight: 600;
}

.sd-item:hover:not(.active) {
  background: rgba(255,255,255,0.05);
  color: rgba(248,250,252,0.9);
}

.sd-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  opacity: 0.8;
}

.sd-badge {
  margin-left: auto;
  border-radius: 999px;
  padding: 0 6px;
  font-size: 10px;
  font-weight: 700;
  min-width: 18px;
  text-align: center;
  line-height: 18px;
  height: 18px;
}

.sd-section {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: rgba(248,250,252,0.35);
  padding: 10px 8px 4px;
  font-weight: 700;
}

.sd-sep {
  height: 1px;
  background: rgba(255,255,255,0.07);
  margin: 8px 0;
}

.sd-group {
  padding-left: 24px;
  border-left: 1px solid rgba(255,255,255,0.1);
  margin: 2px 0 2px 17px;
}

.nav-label { /* kept for collapse toggling */
  flex: 1;
}

/* ── Sidebar Footer ───────────────────────────────────────────── */
.sidebar-footer {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid rgba(255,255,255,0.08);
  font-size: 11px;
  color: rgba(248,250,252,0.6);
  flex-shrink: 0;
}

.sidebar-username {
  flex: 1;
  font-size: 13px;
  color: rgba(248,250,252,0.9);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-logout {
  font-size: 13px;
  color: rgba(248,250,252,0.5);
  text-decoration: none;
  white-space: nowrap;
}

.sidebar-logout:hover { color: var(--sidebar-fg); }

/* ── Main Content ─────────────────────────────────────────────── */
.main-content {
  margin-left: 240px;
  flex: 1;
  padding: 24px;
  min-height: 100vh;
  overflow-x: auto;
}

.container {
  max-width: 1200px;
}

/* ── Report Topbar ────────────────────────────────────────────── */
.report-topbar {
  position: fixed;
  top: 0;
  left: 240px;
  right: 0;
  z-index: 40;
  height: 64px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0 24px;
  transition: left 0.25s ease;
}
.report-topbar h1 {
  font-family: var(--font-headline);
  font-size: 18px;
  font-weight: 700;
  color: var(--foreground);
  margin: 0;
  flex: 1;
}

.report-topbar.sidebar-collapsed { left: 56px; }
.report-body { padding-top: 80px; }

/* ── Topbar (mobile) ──────────────────────────────────────────── */
.topbar {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 56px;
  background: var(--sidebar-bg);
  align-items: center;
  padding: 0 1rem;
  gap: 1rem;
  z-index: 101;
}

.topbar-hamburger {
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 6px;
  color: rgba(248,250,252,0.85);
  cursor: pointer;
  padding: 6px 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-left: 8px;
  transition: background 0.15s;
}

.topbar-hamburger:hover {
  background: rgba(255,255,255,0.15);
}

.topbar-logo {
  max-height: 26px;
  width: auto;
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
}

/* ── Overlay ──────────────────────────────────────────────────── */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 99;
}

.sidebar-overlay.active { display: block; }

/* ── Desktop sidebar collapse ─────────────────────────────────── */
.sidebar.collapsed { width: 56px; }

.sidebar.collapsed .nav-label,
.sidebar.collapsed .sidebar-username,
.sidebar.collapsed .sidebar-logout,
.sidebar.collapsed .sidebar-logo,
.sidebar.collapsed .sd-section,
.sidebar.collapsed .sd-sep {
  display: none;
}

.sidebar.collapsed .sd-item {
  justify-content: center;
  padding: 7px;
}

.sidebar.collapsed .sd-icon { opacity: 1; }

.main-content.sidebar-collapsed { margin-left: 56px; }

/* ── Button ───────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  white-space: nowrap;
  border-radius: calc(var(--radius) - 2px);
  font-size: 13px;
  font-weight: 500;
  font-family: var(--font-body);
  transition: background 0.15s, opacity 0.15s;
  cursor: pointer;
  border: none;
  text-decoration: none;
  outline-offset: 2px;
}

.btn:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; }
.btn:disabled { pointer-events: none; opacity: 0.5; }

/* sizes */
.btn-default { height: 40px; padding: 0 16px; }
.btn-sm      { height: 36px; padding: 0 12px; font-size: 12px; }
.btn-lg      { height: 44px; padding: 0 32px; font-size: 14px; }
.btn-icon    { height: 28px; width: 28px; padding: 0; font-size: 14px; }

/* variants */
.btn-v-default       { background: var(--primary); color: var(--primary-fg); }
.btn-v-default:hover { background: hsl(195, 20%, 52%); color: var(--primary-fg); }

.btn-v-destructive       { background: var(--destructive); color: var(--destructive-fg); }
.btn-v-destructive:hover { background: hsl(0, 84%, 52%); color: var(--destructive-fg); }

.btn-v-outline       { background: var(--card); color: var(--foreground); border: 1px solid var(--input); }
.btn-v-outline:hover { background: var(--accent); }

.btn-v-secondary       { background: var(--secondary); color: var(--secondary-fg); }
.btn-v-secondary:hover { background: hsl(210, 40%, 90%); }

.btn-v-ghost       { background: transparent; color: var(--foreground); }
.btn-v-ghost:hover { background: var(--accent); }

.btn-v-link { background: transparent; color: var(--primary); text-decoration: underline; text-underline-offset: 4px; }

/* ── Badge ────────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  border: 1px solid transparent;
  padding: 2px 10px;
  font-size: 11px;
  font-weight: 600;
  transition: background 0.15s;
}

.badge-default     { background: var(--primary); color: var(--primary-fg); border-color: var(--primary); }
.badge-secondary   { background: var(--secondary); color: var(--secondary-fg); }
.badge-destructive { background: var(--destructive); color: var(--destructive-fg); }
.badge-outline     { background: transparent; color: var(--foreground); border-color: var(--border); }
.badge-warn        { background: #facc15; color: #713f12; }
.badge-danger      { background: #ef4444; color: #fff; }

/* ── Input / Textarea ─────────────────────────────────────────── */
.inp {
  display: flex;
  height: 40px;
  width: 100%;
  border-radius: calc(var(--radius) - 2px);
  border: 1px solid var(--input);
  background: var(--card);
  padding: 0 12px;
  font-size: 13px;
  font-family: var(--font-body);
  color: var(--foreground);
  outline: none;
  transition: box-shadow 0.15s;
}

.inp::placeholder { color: var(--muted-fg); }
.inp:focus { box-shadow: 0 0 0 2px var(--ring); border-color: var(--ring); }
.inp:disabled { cursor: not-allowed; opacity: 0.5; background: var(--muted); }
.inp-error { border-color: var(--destructive) !important; }
textarea.inp { height: 80px; padding: 8px 12px; resize: vertical; }

/* Auto-apply inp styles to form fields inside .form-item */
.form-item input[type="text"],
.form-item input[type="email"],
.form-item input[type="password"],
.form-item input[type="number"],
.form-item input[type="date"],
.form-item input[type="tel"],
.form-item select,
.form-item textarea {
  display: flex;
  height: 40px;
  width: 100%;
  border-radius: calc(var(--radius) - 2px);
  border: 1px solid var(--input);
  background: var(--card);
  padding: 0 12px;
  font-size: 13px;
  font-family: var(--font-body);
  color: var(--foreground);
  outline: none;
  transition: box-shadow 0.15s;
  box-sizing: border-box;
}

.form-item textarea {
  height: 80px;
  padding: 8px 12px;
  resize: vertical;
}

.form-item input:focus,
.form-item select:focus,
.form-item textarea:focus {
  box-shadow: 0 0 0 2px var(--ring);
  border-color: var(--ring);
}

/* ── Card ─────────────────────────────────────────────────────── */
.card {
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--card-foreground);
  box-shadow: 0 1px 2px rgba(0,0,0,0.05);
  transition: box-shadow 0.15s, border-color 0.15s;
}
a.card:hover {
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.card-header  { display: flex; flex-direction: column; gap: 6px; padding: 24px; }
.card-title   { font-size: 16px; font-weight: 600; line-height: 1; letter-spacing: -0.01em; font-family: var(--font-headline); }
.card-desc    { font-size: 13px; color: var(--muted-fg); }
.card-content { padding: 24px; padding-top: 0; }
.card-footer  { display: flex; align-items: center; gap: 8px; padding: 24px; padding-top: 0; }

/* ── Alert ────────────────────────────────────────────────────── */
.alert {
  position: relative;
  width: 100%;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 12px 16px 12px 48px;
  margin-bottom: 12px;
}

.alert-icon {
  position: absolute;
  left: 16px;
  top: 14px;
  font-size: 16px;
}

.alert-default     { background: var(--card); color: var(--foreground); }
.alert-destructive { border-color: hsl(0, 84.2%, 75%); color: var(--destructive); background: hsl(0, 84.2%, 98%); }
.alert-info        { border-color: hsl(195, 60%, 75%); color: hsl(195, 60%, 30%); background: hsl(195, 60%, 97%); }
.alert-success     { border-color: hsl(130, 50%, 70%); color: hsl(130, 50%, 28%); background: hsl(130, 50%, 97%); }
.alert-warning     { border-color: hsl(40, 90%, 70%); color: hsl(40, 90%, 30%); background: hsl(40, 90%, 97%); }

.alert-title { font-weight: 600; font-size: 13px; margin-bottom: 3px; line-height: 1; }
.alert-desc  { font-size: 12.5px; opacity: 0.9; line-height: 1.5; }

/* ── Spinner ──────────────────────────────────────────────────── */
.spinner {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 4px solid var(--border);
  border-top-color: var(--primary);
  animation: spin 0.75s linear infinite;
}

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

/* ── Toast ────────────────────────────────────────────────────── */
.toast {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
  max-width: 380px;
  position: relative;
}

.toast-destructive { background: var(--destructive); border-color: var(--destructive); color: var(--destructive-fg); }
.toast-title { font-size: 13px; font-weight: 600; }
.toast-desc  { font-size: 12.5px; opacity: 0.9; margin-top: 2px; }
.toast-close { position: absolute; right: 8px; top: 8px; background: none; border: none; cursor: pointer; opacity: 0.5; font-size: 14px; padding: 2px; }
.toast-close:hover { opacity: 1; }

/* ── Dialog ───────────────────────────────────────────────────── */
.dialog-box {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  width: 360px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.15);
  position: relative;
}

.dialog-title       { font-size: 16px; font-weight: 600; margin-bottom: 4px; }
.dialog-description { font-size: 13px; color: var(--muted-fg); margin-bottom: 16px; }
.dialog-footer      { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }

/* ── Table ────────────────────────────────────────────────────── */
.tbl-wrap { width: 100%; overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--border); }

table.tbl { width: 100%; font-size: 13px; border-collapse: collapse; }
table.tbl thead tr { border-bottom: 1px solid var(--border); }
table.tbl tbody tr { border-bottom: 1px solid var(--border); transition: background 0.1s; }
table.tbl tbody tr:last-child { border-bottom: none; }
table.tbl tbody tr:hover { background: var(--muted); }

table.tbl th {
  height: 48px;
  padding: 0 16px;
  text-align: left;
  font-weight: 500;
  font-size: 12px;
  color: var(--muted-fg);
  border-right: 1px solid var(--border);
  white-space: nowrap;
}

table.tbl th:last-child { border-right: none; }

table.tbl td {
  padding: 12px 16px;
  border-right: 1px solid var(--border);
  vertical-align: middle;
}

table.tbl td:last-child { border-right: none; }

/* ── Form Field ───────────────────────────────────────────────── */
.form-item  { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.form-label { font-size: 13px; font-weight: 500; color: var(--foreground); }
.form-label.error { color: var(--destructive); }
.form-desc  { font-size: 12px; color: var(--muted-fg); }
.form-msg   { font-size: 12px; font-weight: 500; color: var(--destructive); }

/* ── Specialized: File Input ──────────────────────────────────── */
.file-input-wrap {
  display: flex;
  height: 40px;
  width: 100%;
  align-items: center;
  justify-content: space-between;
  border: 1px solid var(--input);
  background: var(--card);
  border-radius: calc(var(--radius) - 2px);
  padding: 0 12px;
  font-size: 13px;
  cursor: pointer;
}

.file-input-wrap:hover { background: var(--accent); }
.file-input-wrap span  { color: var(--muted-fg); }
.file-input-wrap .has-file { color: #16a34a; }

/* ── DataTables support ───────────────────────────────────────── */
.dataTables_wrapper {
  width: 100%;
  background: var(--card);
  border-radius: var(--radius);
  padding: 12px;
  margin: 12px 0;
  box-shadow: 0 1px 2px rgba(0,0,0,0.05);
  overflow-x: visible;
  border: 1px solid var(--border);
}

.dataTables_wrapper .dataTables_scrollBody {
  overflow-x: auto !important;
}

/* ── DataTables — design system overrides ─────────────────────── */
.dataTables_filter input,
.dataTables_length select {
  height: 40px !important;
  min-width: 240px !important;
  border-radius: calc(var(--radius) - 2px) !important;
  border: 1px solid var(--input) !important;
  background: var(--card) !important;
  color: var(--foreground) !important;
  font-size: 13px !important;
  font-family: var(--font-body) !important;
  padding: 0 10px !important;
  outline: none !important;
  transition: box-shadow 0.15s !important;
  box-shadow: none !important;
}
.dataTables_filter input:focus,
.dataTables_length select:focus {
  box-shadow: 0 0 0 2px var(--ring) !important;
  border-color: var(--ring) !important;
}
.dataTables_paginate .paginate_button {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  height: 32px !important;
  min-width: 32px !important;
  padding: 0 8px !important;
  border-radius: calc(var(--radius) - 2px) !important;
  border: 1px solid var(--input) !important;
  background: var(--card) !important;
  color: var(--foreground) !important;
  font-size: 13px !important;
  font-family: var(--font-body) !important;
  cursor: pointer !important;
  transition: background 0.15s !important;
  margin: 0 2px !important;
  box-sizing: border-box !important;
}
.dataTables_paginate .paginate_button:hover {
  background: var(--accent) !important;
  color: var(--foreground) !important;
}
.dataTables_paginate .paginate_button.current,
.dataTables_paginate .paginate_button.current:hover {
  background: var(--primary) !important;
  color: var(--primary-fg) !important;
  border-color: var(--primary) !important;
}
.dataTables_paginate .paginate_button.disabled,
.dataTables_paginate .paginate_button.disabled:hover {
  opacity: 0.4;
  cursor: not-allowed;
  background: var(--card) !important;
}
.dataTables_info {
  font-size: 13px;
  color: var(--muted-fg);
  font-family: var(--font-body);
}

#report-table {
  width: auto;
  min-width: 100%;
  table-layout: auto;
}

#report-table td, #report-table th {
  white-space: nowrap;
  padding: 10px 16px;
  font-size: 14px;
}
#report-table th {
  text-transform: uppercase !important;
  text-align: left !important;
}
#report-table td { text-align: left !important; }
.dataTables_scrollHeadInner th { white-space: nowrap; text-transform: uppercase !important; text-align: left !important; }

/* ── DataTables layout (shared across all report templates) ───── */
.dt-top    { display:flex; justify-content:space-between; align-items:center; margin-bottom:8px; margin-top:14px; }
.dt-bottom { display:flex; justify-content:space-between; align-items:center; margin-top:8px; }
.dt-right  { display:flex; align-items:center; gap:8px; }
.dt-records { margin-left:auto; }
.dt-scroll,
.dataTables_scrollBody {
  overflow-x: auto;
  width: 100%;
  scrollbar-width: thin;
  scrollbar-color: transparent transparent;
}
.dt-scroll:hover,
.dataTables_scrollBody:hover {
  scrollbar-color: var(--border) var(--muted);
}
.dataTables_scrollBody::-webkit-scrollbar                    { height: 6px; }
.dataTables_scrollBody::-webkit-scrollbar-track              { background: transparent; margin: 0 16px; border-radius: 999px; }
.dataTables_scrollBody:hover::-webkit-scrollbar-track        { background: var(--muted); }
.dataTables_scrollBody::-webkit-scrollbar-thumb              { background: transparent; border-radius: 999px; transition: background 0.2s; }
.dataTables_scrollBody:hover::-webkit-scrollbar-thumb        { background: var(--border); border-radius: 999px; }

/* ── Section heading ──────────────────────────────────────────── */
.section-heading {
  font-family: var(--font-headline);
  font-size: 15px;
  font-weight: 600;
  color: var(--muted-fg);
  margin-bottom: 16px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* ── Typography helpers ───────────────────────────────────────── */
h1, h2, h3 {
  font-family: var(--font-headline);
  color: var(--foreground);
  line-height: 1.2;
}

/* ── Portal-specific ──────────────────────────────────────────── */
.portal-header {
  background: var(--sidebar-bg);
  color: var(--sidebar-fg);
  padding: 14px 40px;
  display: flex;
  align-items: center;
  min-height: 56px;
  box-sizing: border-box;
}

.portal-header-inner {
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 40px;
}

.portal-logo {
  height: 36px;
  width: auto;
  display: block;
  margin: 0;
  object-fit: contain;
  flex-shrink: 0;
}

.portal-header-title {
  font-size: 13px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(248,250,252,0.5);
  line-height: 1;
  margin: 0;
  font-family: var(--font-headline);
}

.portal-main {
  flex: 1;
  padding: 40px 24px 48px;
  display: flex;
  justify-content: center;
}

.portal-content {
  max-width: 960px;
  width: 100%;
}

.portal-hero-title {
  font-family: var(--font-headline);
  font-size: 28px;
  font-weight: 700;
  color: var(--foreground);
  margin-bottom: 8px;
}

.portal-hero-subtitle {
  font-size: 15px;
  color: var(--muted-fg);
  max-width: 540px;
  margin-bottom: 24px;
}

.portal-card {
  margin-top: 24px;
  background: var(--card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: 0 4px 12px rgba(0,0,0,0.06);
  padding: 24px 28px 32px;
}

.section-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 20px;
}

.section-pill {
  width: 28px;
  height: 28px;
  border-radius: 999px;
  background: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--primary-fg);
  font-weight: 700;
  font-size: 13px;
  flex-shrink: 0;
}

.section-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--foreground);
  font-family: var(--font-headline);
}

.competency-section {
  border: 1px solid var(--border);
  padding: 16px 18px 20px;
  margin-bottom: 20px;
  border-radius: var(--radius);
  background: var(--secondary);
}

.competency-section h3 {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 12px;
  color: var(--foreground);
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px 24px;
  margin-bottom: 20px;
}

/* ── Login page layout ────────────────────────────────────────── */
.auth-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  min-height: 100vh;
}
.auth-layout--single {
  grid-template-columns: 1fr;
  max-width: 480px;
  margin: 0 auto;
}
.auth-layout--single .auth-left {
  border-right: none;
}

.auth-left {
  background: var(--card);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 32px;
  border-right: 1px solid var(--border);
}

.auth-right {
  background: hsl(195, 20%, 97%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 32px;
}

.auth-form-wrap {
  max-width: 300px;
  width: 100%;
}

.auth-logo-block {
  background: var(--sidebar-bg);
  padding: 12px 16px;
  border-radius: 6px;
  text-align: center;
  margin-bottom: 20px;
}

.auth-logo-block img {
  max-height: 32px;
  max-width: 180px;
  width: auto;
  margin: 0;
}

.auth-title {
  font-family: var(--font-headline);
  font-size: 16px;
  font-weight: 600;
  color: var(--foreground);
  margin-bottom: 20px;
}

.auth-notices {
  max-width: 280px;
  width: 100%;
}

.auth-notices-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--foreground);
  margin-bottom: 10px;
  font-family: var(--font-headline);
}

.auth-notice-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 12px;
  font-size: 12px;
  color: var(--muted-fg);
  margin-bottom: 12px;
}

.auth-tagline {
  font-size: 11px;
  color: var(--muted-fg);
  margin-top: 8px;
}

/* ── Report Grid ──────────────────────────────────────────────── */
.report-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
}

/* ── Table Responsive Wrapper ─────────────────────────────────── */
.table-responsive {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* ── Responsive ───────────────────────────────────────────────── */
@media (max-width: 768px) {
  .main-content { max-width: 100vw; }
  .topbar-logo { max-height: 36px; }

  .topbar { display: flex; }

  .sidebar {
    width: 56px;
    transform: translateX(-56px);
  }

  .sidebar.open {
    transform: translateX(0);
    width: 240px;
  }

  .sidebar.open .nav-label,
  .sidebar.open .sidebar-username,
  .sidebar.open .sidebar-logout,
  .sidebar.open .sidebar-logo,
  .sidebar.open .sd-section {
    display: block;
  }

  .sd-item {
    justify-content: flex-start;
    padding: 7px 8px;
  }

  .main-content {
    margin-left: 0;
    padding-top: 72px;
  }

  .report-topbar { left: 0; top: 56px; }
  .report-body   { padding-top: 60px; }

  .auth-layout { grid-template-columns: 1fr; }
  .auth-right  { display: none; }

  .portal-header { padding-inline: 16px; }
  .portal-main   { padding-inline: 16px; }
  .portal-card   { padding-inline: 20px; }

  .form-grid { grid-template-columns: 1fr; }

  .report-grid {
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  }

  .main-content.sidebar-collapsed { margin-left: 0; }
  .report-topbar.sidebar-collapsed { left: 0; }

  .dt-scroll,
  .dataTables_scrollBody { scrollbar-color: var(--border) var(--muted); }
  .dt-scroll::-webkit-scrollbar,
  .dataTables_scrollBody::-webkit-scrollbar       { height: 6px; }
  .dt-scroll::-webkit-scrollbar-track,
  .dataTables_scrollBody::-webkit-scrollbar-track { background: var(--muted); border-radius: 999px; }
  .dt-scroll::-webkit-scrollbar-thumb,
  .dataTables_scrollBody::-webkit-scrollbar-thumb { background: var(--border); border-radius: 999px; }
  .dt-scroll::-webkit-scrollbar-thumb:hover,
  .dataTables_scrollBody::-webkit-scrollbar-thumb:hover { background: var(--muted-fg); }

  /* DataTables controls — stack everything in column on mobile */
  .dt-top    { flex-direction: column; align-items: stretch; gap: 8px; }
  .dt-right  { flex-direction: row; flex-wrap: nowrap; align-items: center; gap: 8px; width: 100%; }
  .dt-records { flex: none; }
  .dt-bottom { flex-wrap: wrap; gap: 6px; }

  /* Search stretches full width; records sits inline with buttons */
  .dataTables_filter { width: 100%; }
  .dataTables_filter label { display: flex; align-items: center; gap: 8px; width: 100%; }
  .dataTables_filter input { min-width: 0 !important; width: 100% !important; flex: 1; box-sizing: border-box; }

  .dataTables_length label { display: flex; align-items: center; gap: 8px; white-space: nowrap; }
  .dataTables_length select { min-width: 0 !important; width: auto !important; }

  /* Buttons sit inline with records */
  .dt-buttons { display: flex; gap: 8px; }
  .dt-buttons .btn { justify-content: center; }

  /* Table-only horizontal scroll — controls stay fixed */
  #report-table { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; }
}

@media (max-width: 480px) {
  .main-content { padding: 16px; padding-top: 72px; }
  .report-body  { padding-top: 52px; }
  .report-grid  { grid-template-columns: 1fr; }
  .card         { border-radius: 6px; width: 100%; max-width: 100% !important; box-sizing: border-box; }
  h1            { font-size: 16px; }
  .form-item input[type="text"],
  .form-item input[type="email"],
  .form-item input[type="password"],
  .form-item input[type="number"],
  .form-item input[type="date"],
  .form-item input[type="tel"],
  .form-item select { max-width: 100%; min-width: 0; }
  .card-footer  { flex-direction: column; align-items: stretch; }
  .card-footer .btn { width: 100%; justify-content: center; }

  /* Bottom: stack info and pagination vertically, centered */
  .dt-bottom { flex-direction: column; align-items: center; gap: 8px; }
  .dataTables_info { text-align: center; width: 100%; }
  .dataTables_paginate { width: 100%; display: flex; justify-content: center; flex-wrap: wrap; gap: 4px; }
  .dataTables_paginate .paginate_button { min-width: 36px; justify-content: center; }
}

/* ── Utility classes (CSP unsafe-inline removal) ─────────────────────────── */
.text-destructive { color: var(--destructive); }
.text-muted       { color: var(--muted-fg); }
.text-foreground  { color: var(--foreground); }
.text-white       { color: #fff; }
.text-base        { font-size: 14px; }
.text-sm          { font-size: 13px; }
.text-xs          { font-size: 12px; }
.text-center      { text-align: center; }
.font-normal      { font-weight: 400; }

.w-full           { width: 100%; }
.max-w-sm         { max-width: 480px; }
.max-w-md         { max-width: 560px; }
.max-w-form       { max-width: 600px; }
.max-w-lg         { max-width: 680px; }

.mt-1             { margin-top: 4px; }
.mt-2             { margin-top: 8px; }
.mt-4             { margin-top: 16px; }
.mt-5             { margin-top: 20px; }
.mt-6             { margin-top: 24px; }
.mb-0             { margin-bottom: 0; }
.mb-2             { margin-bottom: 8px; }
.mb-3             { margin-bottom: 12px; }
.mb-4             { margin-bottom: 16px; }
.mb-5             { margin-bottom: 20px; }
.mb-6             { margin-bottom: 24px; }
.pt-6             { padding-top: 24px; }

.flex             { display: flex; }
.flex-col         { flex-direction: column; }
.flex-1           { flex: 1; }
.flex-shrink-0    { flex-shrink: 0; }
.flex-wrap        { flex-wrap: wrap; }
.items-center     { align-items: center; }
.justify-center   { justify-content: center; }
.justify-between  { justify-content: space-between; }
.justify-end      { justify-content: flex-end; }
.gap-2            { gap: 8px; }
.gap-3            { gap: 12px; }
.gap-4            { gap: 16px; }

.min-h-screen     { min-height: 100vh; }
.pos-relative     { position: relative; }
.opacity-60       { opacity: 0.6; }
.no-underline     { text-decoration: none; }
.cursor-pointer   { cursor: pointer; }
.lh-snug          { line-height: 1.3; }
.ws-normal        { white-space: normal; }

.pwd-toggle {
  position: absolute; right: 10px; top: 50%;
  transform: translateY(-50%);
  background: none; border: none; cursor: pointer;
  padding: 0; color: var(--muted-fg);
  display: flex; align-items: center;
}
.pwd-input        { padding-right: 40px; }

.file-input-hidden {
  width: 0.1px; height: 0.1px; opacity: 0;
  overflow: hidden; position: absolute; z-index: -1;
}
.file-input-wrap  { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.inp-tall         { height: 120px; }

.loading-overlay  {
  display: none; align-items: center; gap: 10px;
  position: absolute; top: 16px; right: 20px;
}
.spinner-sm       { width: 20px; height: 20px; border-width: 2px; flex-shrink: 0; }

.success-icon {
  width: 56px; height: 56px; border-radius: 50%;
  background: var(--primary);
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 24px;
}
.success-title {
  font-family: var(--font-headline); font-size: 22px;
  font-weight: 700; color: var(--foreground); margin-bottom: 12px;
}
.success-body {
  font-size: 14px; color: var(--muted-fg);
  max-width: 360px; margin: 0 auto 28px; line-height: 1.6;
}
.success-content  { text-align: center; padding: 0; }
.success-inner    { padding: 48px 40px; }
.success-wrap     { max-width: 480px; width: 100%; }
.success-main     {
  flex: 1; display: flex; align-items: center;
  justify-content: center; padding: 40px 24px;
}

.sidebar-username-text { color: #fff; font-size: 13px; margin-top: 3px; }
.sidebar-logout-link   { display: flex; align-items: center; gap: 4px; }

.report-topbar-inner {
  display: flex; align-items: center;
  justify-content: space-between; flex-wrap: wrap; gap: 8px;
}
.btn-group        { display: flex; gap: 8px; }
.dt-btn-icon      { margin-right: 5px; vertical-align: middle; }
.dt-buttons button svg,
.dt-buttons a svg { margin-right: 5px; vertical-align: middle; }

.chart-canvas { max-height: 320px; }
.td-empty     { padding: 20px 12px; }

.asset-category-filter                 { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.asset-category-filter > div          { min-width: 160px; }
.asset-category-filter > div > button { width: 100%; justify-content: space-between; height: 40px !important; }

.tbl-scroll       { overflow-x: auto; width: 100%; }
.divider-below {
  margin-top: 20px; margin-bottom: 16px;
  padding-bottom: 16px; border-bottom: 1px solid var(--border);
}
.form-card        { max-width: 680px; position: relative; }
.form-note        { font-size: 13px; color: var(--muted-fg); }

/* Custom select & calendar (moved from report_parameter_form.html <style> block) */
.custom-select-wrap { position: relative; }
.custom-select-trigger {
  display: flex; align-items: center; justify-content: space-between;
  height: 40px; width: 100%; padding: 0 12px;
  border: 1px solid var(--input); border-radius: calc(var(--radius) - 2px);
  background: var(--card); color: var(--foreground);
  font-size: 13px; font-family: var(--font-body); cursor: pointer;
  text-align: left;
}
.custom-select-trigger.open { box-shadow: 0 0 0 2px var(--ring); border-color: var(--ring); }
.custom-select-trigger svg { flex-shrink: 0; opacity: 0.6; }
.custom-select-list {
  position: absolute; top: calc(100% + 4px); left: 0; width: 100%; z-index: 999;
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
  max-height: 240px; overflow-y: auto; display: none; padding: 4px;
}
.custom-select-list.open { display: block; }
.custom-select-option {
  padding: 6px 12px 6px 32px; font-size: 13px; cursor: pointer; color: var(--foreground);
  border-radius: 4px; position: relative;
}
.custom-select-option:hover { background: var(--accent); }
.custom-select-option.selected::before {
  content: '✓'; position: absolute; left: 10px;
  font-size: 12px; color: var(--primary);
}

/* Calendar date picker */
.cal-header      { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; gap: 4px; }
.cal-nav-btn     { background: none; border: 1px solid var(--border); border-radius: 4px; width: 28px; height: 28px; cursor: pointer; color: var(--foreground); font-size: 14px; flex-shrink: 0; }
.cal-month-row   { display: flex; align-items: center; gap: 4px; }
.cal-month-label { font-weight: 600; font-size: 13px; color: var(--foreground); }
.cal-year-wrap   { position: relative; }
.cal-year-btn    { background: var(--muted); border: 1px solid var(--border); border-radius: 4px; padding: 2px 8px; font-size: 13px; font-weight: 600; cursor: pointer; color: var(--foreground); display: inline-flex; align-items: center; gap: 4px; }
.cal-year-list   { display: none; position: absolute; top: calc(100% + 2px); left: 0; background: var(--card); border: 1px solid var(--border); border-radius: 4px; box-shadow: 0 4px 12px rgba(0,0,0,0.12); max-height: 160px; overflow-y: auto; z-index: 10000; min-width: 80px; }
.cal-year-item   { padding: 6px 12px; font-size: 13px; cursor: pointer; color: var(--foreground); }
.cal-year-item.active { background: var(--primary); color: var(--primary-fg); font-weight: 600; }
.cal-days-grid   { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; text-align: center; }
.cal-day-head    { font-size: 11px; font-weight: 600; color: var(--muted-fg); padding: 4px 0; }
.cal-day         { font-size: 13px; padding: 5px 2px; border-radius: 4px; cursor: pointer; color: var(--foreground); }
.cal-day.today   { background: var(--accent); font-weight: 600; }
.cal-day.selected { background: var(--primary); color: var(--primary-fg); font-weight: 600; }
