/* ===== Custom Properties ===== */
:root {
  --bg: #0f1117;
  --panel: #1c1e26;
  --surface: var(--panel);
  --text: #e8e8ea;
  --muted: #8b8d9a;
  --placeholder: color-mix(in srgb, var(--muted) 72%, transparent);
  --accent: #3b7cf4;
  --accent-fg: #ffffff;
  --border: rgba(255,255,255,0.1);
  --shadow: 0 1px 3px rgba(0,0,0,0.25);
  --radius: 8px;
  --max: 1600px;
  --status-ok: #16a34a;
  --status-err: #dc2626;
  --status-warn: #d97706;
  --status-info: #3b7cf4;
  --form-error-fg: #ff8a80;
  --msg-success-fg: #c8f5e8;
  --msg-error-fg: #ffc9c9;
  --msg-warn-fg: #ffe8b8;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f4f5f7;
    --panel: #ffffff;
    --surface: var(--panel);
    --text: #111318;
    --muted: #6b7280;
    --placeholder: color-mix(in srgb, var(--muted) 72%, transparent);
    --accent: #2563eb;
    --accent-fg: #ffffff;
    --border: #e2e4e9;
    --shadow: 0 1px 3px rgba(0,0,0,0.08);
    --form-error-fg: #dc2626;
    --msg-success-fg: #166534;
    --msg-error-fg: #991b1b;
    --msg-warn-fg: #92400e;
  }
}

/* ===== Reset / Base ===== */
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
}

a { color: inherit; text-decoration: none; }
.container { max-width: var(--max); margin: 0 auto; padding: 0 18px; }

/* ===== Navbar ===== */
/* Site navbar only — avoid sticky/z-index on nested page headers (e.g. BELLE toolbar). */
body > header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
}

.nav {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 12px;
  padding: 14px 0;
}

.nav-start {
  display: flex;
  align-items: center;
  gap: 16px;
  flex: 1;
  min-width: 0;
  flex-wrap: nowrap;
}

.nav-start .nav-links {
  flex: 0 1 auto;
  min-width: 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  letter-spacing: 0.3px;
}

.logo {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--accent);
  color: var(--accent-fg);
  font-weight: 900;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 16px;
}

.nav-auth {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
  flex-shrink: 0;
}

.nav-auth .dropdown-menu {
  left: auto;
  right: 0;
}

.nav-user {
  font-size: 0.875rem;
  color: var(--muted);
  max-width: 12rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nav-logout-form {
  margin: 0;
  display: inline;
}

.nav-link-btn {
  padding: 10px 12px;
  border-radius: 8px;
  border: none;
  background: transparent;
  cursor: pointer;
  font: inherit;
  color: var(--muted);
  transition: 160ms ease;
}

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

.nav-auth a.nav-login {
  padding: 10px 12px;
  border-radius: 8px;
  color: var(--muted);
  transition: 160ms ease;
}

.nav-auth a.nav-login:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.06);
}

.nav-links a {
  padding: 10px 12px;
  border-radius: 8px;
  color: var(--muted);
  transition: 160ms ease;
}

.nav-links a:hover {
  color: var(--text);
  background: rgba(255,255,255,0.06);
}

.nav-links a.active {
  color: var(--text);
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--accent) 35%, transparent);
}

.cta {
  padding: 10px 14px;
  border-radius: 8px;
  background: var(--accent);
  color: var(--accent-fg);
  font-weight: 700;
  border: none;
  cursor: pointer;
  transition: filter 120ms ease;
}
.cta:hover { filter: brightness(1.08); }

/* ===== Navbar Dropdowns ===== */
.nav-dropdown {
  position: relative;
}

/* Invisible bridge so the pointer can reach the menu without losing :hover */
.nav-dropdown::after {
  content: "";
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  height: 12px;
  z-index: 19;
}

.nav-trigger {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 12px;
  border-radius: 8px;
  color: var(--muted);
  cursor: pointer;
  transition: 160ms ease;
  user-select: none;
}

.nav-trigger::after {
  content: "\25BE";
  font-size: 11px;
  transition: transform 200ms ease;
}

.nav-dropdown:hover .nav-trigger,
.nav-trigger:hover {
  color: var(--text);
  background: rgba(255,255,255,0.06);
}

.nav-dropdown:hover .nav-trigger::after {
  transform: rotate(180deg);
}

.dropdown-menu {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  min-width: 200px;
  padding: 6px;
  border-radius: 8px;
  background: var(--panel);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(-4px);
  transition: opacity 160ms ease, transform 160ms ease, visibility 0ms ease 160ms;
  z-index: 20;
}

.dropdown-menu::before {
  content: "";
  position: absolute;
  top: -8px;
  left: 0;
  right: 0;
  height: 8px;
}

.nav-dropdown:hover .dropdown-menu,
.nav-dropdown.open .dropdown-menu {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateY(0);
  transition: opacity 160ms ease, transform 160ms ease, visibility 0ms ease 0ms;
}

.nav-dropdown.open .nav-trigger::after {
  transform: rotate(180deg);
}

.dropdown-menu a {
  display: block;
  padding: 10px 14px;
  border-radius: 6px;
  color: var(--muted);
  font-size: 14px;
  transition: 140ms ease;
  white-space: nowrap;
}

.dropdown-menu a:hover {
  color: var(--text);
  background: rgba(255,255,255,0.06);
}

/* Mobile menu button */
.menu-btn {
  display: none;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  color: var(--text);
  cursor: pointer;
}

.menu-icon {
  width: 22px;
  height: 16px;
  position: relative;
  display: inline-block;
}
.menu-icon span {
  position: absolute;
  left: 0;
  width: 100%;
  height: 2px;
  background: var(--text);
  border-radius: 999px;
  transition: 180ms ease;
}
.menu-icon span:nth-child(1) { top: 0; }
.menu-icon span:nth-child(2) { top: 7px; }
.menu-icon span:nth-child(3) { top: 14px; }

/* ===== Main ===== */
main { padding: 44px 0 70px; }
.hero {
  margin-top: 10px;
  width: 100%;
}

.main-content {
  min-width: 0;
  width: 100%;
}

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px;
}

.data-control-card {
  position:absolute;
  left:0;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px;
}

h1 { margin: 0 0 10px; font-size: 40px; line-height: 1.12; }
p { margin: 0 0 14px; color: var(--muted); line-height: 1.65; }

.actions { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 16px; }
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 11px 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.06);
  color: var(--text);
  font-weight: 650;
  cursor: pointer;
}
.btn.primary {
  border: none;
  background: var(--accent);
  color: var(--accent-fg);
}
.btn:hover { filter: brightness(1.1); }

.list {
  display: grid;
  gap: 10px;
  margin: 14px 0 0;
  padding: 0;
  list-style: none;
}
.list li {
  padding: 12px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.04);
  color: var(--muted);
}

footer {
  border-top: 1px solid var(--border);
  padding: 18px 0;
  color: var(--muted);
}

/* ===== Utility Classes ===== */
.section-title { margin: 0 0 10px; }
.section-subtitle { margin: 0 0 12px; }
.section-text { margin: 0; }
.card-section { margin-top: 22px; }

/* ===== Responsive ===== */
@media (max-width: 860px) {
  h1 { font-size: 34px; }

  .nav-start {
    flex-wrap: wrap;
  }

  .menu-btn { display: inline-flex; align-items: center; gap: 10px; }
  .nav-links {
    display: none;
    width: 100%;
    flex-direction: column;
    align-items: stretch;
    gap: 4px;
    padding: 10px 0 0;
  }
  .nav.open {
    flex-wrap: wrap;
  }
  .nav.open .nav-links {
    display: flex;
  }
  .nav-links a {
    padding: 12px;
  }
  .cta { width: 100%; }

  /* Dropdowns on mobile: static positioning, click-to-toggle */
  .nav-dropdown::after {
    display: none;
  }
  .nav-dropdown {
    position: static;
  }
  .nav-trigger {
    width: 100%;
    padding: 12px;
  }
  .dropdown-menu {
    position: static;
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: none;
    display: none;
    min-width: 0;
    background: transparent;
    border: none;
    box-shadow: none;
    padding: 0 0 0 16px;
  }
  .nav-dropdown.open .dropdown-menu {
    display: block;
  }
  .dropdown-menu a {
    padding: 10px 12px;
  }

  .quick-links-menu {
    max-height: 50vh;
    min-width: 0;
    width: 100%;
  }
}

/* ===== Quick Links Navbar Dropdown ===== */
.quick-links-dropdown {
  position: relative;
}

.quick-links-menu {
  min-width: 280px;
  max-height: 70vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.quick-links-menu > a,
.quick-links-menu > details {
  width: 100%;
  flex-shrink: 0;
}

.ql-nav-cat {
  margin: 0;
  display: block;
  width: 100%;
}

.ql-nav-cat summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 14px;
  border-radius: 8px;
  color: var(--text);
  font-size: 14px;
  font-weight: 500;
  transition: 140ms ease;
}

.ql-nav-cat summary::-webkit-details-marker {
  display: none;
}

.ql-nav-cat summary::after {
  content: "\25BE";
  color: var(--muted);
  font-size: 11px;
  transition: transform 160ms ease;
}

.ql-nav-cat[open] > summary::after {
  transform: rotate(180deg);
}

.ql-nav-cat summary:hover {
  color: var(--text);
  background: rgba(255,255,255,0.06);
}

.ql-nav-sub {
  display: flex;
  flex-direction: column;
  padding-left: 12px;
  margin-top: 4px;
  border-left: 1px solid var(--border);
  margin-left: 14px;
}

.ql-nav-sub a {
  display: block;
  width: 100%;
  padding: 8px 12px;
  border-radius: 8px;
  color: var(--muted);
  font-size: 13px;
  transition: 140ms ease;
  white-space: nowrap;
}

.ql-nav-sub a:hover {
  color: var(--text);
  background: rgba(255,255,255,0.06);
}

.ql-nav-sub .ql-nav-cat {
  margin-top: 4px;
}

.ql-nav-sub .ql-nav-cat summary {
  padding: 8px 12px;
  font-size: 13px;
}

/* ===== Audit Calendar Widget ===== */
.audit-calendar {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.calendar-input-wrapper {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.calendar-input-wrapper label {
  font-size: 14px;
  color: var(--muted);
  font-weight: 500;
}

.calendar-input {
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  cursor: pointer;
  transition: 160ms ease;
}

.calendar-input:hover {
  border-color: var(--accent);
  background: rgba(255, 255, 255, 0.08);
}

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

.calendar-input::-webkit-calendar-picker-indicator {
  filter: invert(0.8);
  cursor: pointer;
}

.audit-dates {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.audit-date-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  transition: 160ms ease;
}

.audit-date-row:hover {
  background: rgba(255, 255, 255, 0.06);
}

.audit-label {
  font-size: 13px;
  color: var(--muted);
  font-weight: 500;
}

.audit-value {
  font-size: 13px;
  color: var(--text);
  font-weight: 600;
  text-align: right;
}

/* Floating audit calendar trigger + panel */
.audit-calendar-fab {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 100;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-fg);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
  cursor: pointer;
  transition: transform 160ms ease, filter 160ms ease, box-shadow 160ms ease;
}

.audit-calendar-fab:hover {
  filter: brightness(1.08);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.4);
}

.audit-calendar-fab:focus-visible {
  outline: none;
  box-shadow:
    0 0 0 3px color-mix(in srgb, var(--accent) 35%, transparent),
    0 4px 14px rgba(0, 0, 0, 0.35);
}

.audit-calendar-fab[aria-expanded="true"] {
  transform: scale(0.96);
}

.audit-calendar-fab__icon {
  display: block;
}

.audit-calendar-backdrop {
  position: fixed;
  inset: 0;
  z-index: 101;
  background: rgba(0, 0, 0, 0.45);
}

.audit-calendar-backdrop[hidden],
.audit-calendar-panel[hidden] {
  display: none;
}

.audit-calendar-panel {
  position: fixed;
  right: 24px;
  bottom: 92px;
  z-index: 102;
  width: min(360px, calc(100vw - 48px));
  max-height: min(90vh, 660px);
  overflow-y: auto;
  margin: 0;
  padding: 22px;
}

.audit-calendar-panel__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.audit-calendar-panel__header .section-title {
  margin: 0;
}

.audit-calendar-panel__close {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--muted);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  transition: 160ms ease;
}

.audit-calendar-panel__close:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.1);
}

.audit-calendar-panel__close:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent);
}

@media (max-width: 480px) {
  .audit-calendar-fab {
    right: 16px;
    bottom: 16px;
  }

  .audit-calendar-panel {
    right: 16px;
    bottom: 84px;
    width: calc(100vw - 32px);
  }
}

/* ===== Claim Calculator Widget ===== */
.claim-calculator {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.claim-calculator__submit {
  width: 100%;
}

.claim-calculator__message {
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 13px;
  line-height: 1.4;
}

.claim-calculator__message--error {
  color: #ffb4b4;
  background: rgba(220, 60, 60, 0.12);
  border: 1px solid rgba(220, 60, 60, 0.35);
}

.claim-calculator__message[hidden],
.claim-calculator__result[hidden] {
  display: none;
}

.claim-calculator__result {
  padding: 12px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  text-align: center;
}

.claim-calculator-fab {
  position: fixed;
  right: 24px;
  bottom: 92px;
  z-index: 100;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-fg);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
  cursor: pointer;
  transition: transform 160ms ease, filter 160ms ease, box-shadow 160ms ease;
}

.claim-calculator-fab:hover {
  filter: brightness(1.08);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.4);
}

.claim-calculator-fab:focus-visible {
  outline: none;
  box-shadow:
    0 0 0 3px color-mix(in srgb, var(--accent) 35%, transparent),
    0 4px 14px rgba(0, 0, 0, 0.35);
}

.claim-calculator-fab[aria-expanded="true"] {
  transform: scale(0.96);
}

.claim-calculator-fab__icon {
  display: block;
}

.claim-calculator-backdrop {
  position: fixed;
  inset: 0;
  z-index: 101;
  background: rgba(0, 0, 0, 0.45);
}

.claim-calculator-backdrop[hidden],
.claim-calculator-panel[hidden] {
  display: none;
}

.claim-calculator-panel {
  position: fixed;
  right: 24px;
  bottom: 164px;
  z-index: 102;
  width: min(360px, calc(100vw - 48px));
  max-height: min(90vh, 660px);
  overflow-y: auto;
  margin: 0;
  padding: 22px;
}

.claim-calculator-panel__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.claim-calculator-panel__header .section-title {
  margin: 0;
}

.claim-calculator-panel__close {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--muted);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  transition: 160ms ease;
}

.claim-calculator-panel__close:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.1);
}

.claim-calculator-panel__close:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent);
}

@media (max-width: 480px) {
  .claim-calculator-fab {
    right: 16px;
    bottom: 84px;
  }

  .claim-calculator-panel {
    right: 16px;
    bottom: 152px;
    width: calc(100vw - 32px);
  }
}

/* Match Jobs Table Styling */
.comm-table-wrapper {
  margin-top: 20px;
}

.dataframe {
  width: 100%;
  border-collapse: collapse;
  margin-top: 10px;
}

.dataframe thead th {
  text-align: left;
  padding: 12px;
  background: rgba(255,255,255,0.06);
  border-bottom: 1px solid var(--border);
  color: var(--text);
  font-weight: 600;
}

.dataframe tbody td {
  padding: 12px;
  border-bottom: 1px solid var(--border);
  color: var(--muted);
}

.dataframe tbody tr:hover {
  background: rgba(255,255,255,0.04);
}
.jobs-pagination-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 16px;
}

.jobs-show-wrapper {
  display: flex;
  align-items: center;
  gap: 6px;
}

.jobs-show-dropdown {
  padding: 6px 10px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.06);
  color: var(--text);
  cursor: pointer;
}

/* Django messages (django.contrib.messages) */
.app-messages {
  margin-bottom: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.app-message {
  padding: 0.65rem 1rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  font-size: 0.95rem;
}
.app-message--success {
  background: rgba(51, 214, 166, 0.12);
  border-color: rgba(51, 214, 166, 0.35);
  color: var(--msg-success-fg);
}
.app-message--error {
  background: rgba(255, 90, 90, 0.12);
  border-color: rgba(255, 90, 90, 0.35);
  color: var(--msg-error-fg);
}
.app-message--warning {
  background: rgba(255, 200, 80, 0.12);
  border-color: rgba(255, 200, 80, 0.35);
  color: var(--msg-warn-fg);
}
.app-message--info,
.app-message--debug {
  background: rgba(91, 140, 255, 0.12);
  border-color: rgba(91, 140, 255, 0.35);
  color: var(--text);
}

/* Requests dropdown: show All Requests and Incident Request until other types are ready */
.nav-links .nav-dropdown > .dropdown-menu > a[href*="/requests/"]:not([href*="incident"]):not([href*="/requests/all"]) {
  display: none;
}
