/* =============================================================================
   FFI Skill Tracker — "Modern fire service" theme
   Loaded after styles.css. Colours come from the branding tokens in layout.html
   (--accent, --bg, --surface …); this file adds the app shell and restyles the
   shared components. Page-specific layout rules in styles.css still apply.
   ============================================================================= */

:root {
  --font-ui: "Inter", "Segoe UI", Roboto, "Helvetica Neue", Arial, system-ui, sans-serif;
  --font-display: "Barlow Semi Condensed", "Roboto Condensed", "Arial Narrow", "Segoe UI", Roboto, sans-serif;
  --nav-bg: #15181c;
  --nav-bg-raised: #1e2228;
  --nav-ink: #c3c9d1;
  --nav-ink-strong: #ffffff;
  --nav-muted: #7d8591;
  --nav-hover: rgba(255, 255, 255, 0.06);
  --sidebar-width: 264px;
  --topbar-height: 64px;
  --tabbar-height: 64px;
  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 14px;
  --focus-ring: 0 0 0 3px color-mix(in srgb, var(--accent) 28%, transparent);
  --warning-ink: #8a5300;
  --warning-bg: #fff4dc;
  --danger: #b42318;
  --stripe: repeating-linear-gradient(-45deg, var(--accent) 0 10px, #f2b300 10px 20px);
}

:root[data-theme="dark"] {
  --nav-bg: #0b0d10;
  --nav-bg-raised: #15181c;
  --warning-ink: #ffcc66;
  --warning-bg: rgba(255, 190, 60, 0.12);
  --danger: #ff8a8a;
}

/* ---------- Base ---------------------------------------------------------- */

html {
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-ui);
  font-size: 15px;
  line-height: 1.5;
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 {
  font-family: var(--font-display);
  line-height: 1.2;
  letter-spacing: -0.005em;
  color: var(--ink);
}

h1 { font-size: 1.9rem; font-weight: 800; margin: 0 0 0.25rem; }
h2 { font-size: 1.3rem; font-weight: 700; margin: 0 0 0.75rem; }
h3 { font-size: 1.05rem; font-weight: 700; }

a {
  color: var(--accent);
  text-underline-offset: 2px;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.material-symbols-outlined {
  font-size: 22px;
  line-height: 1;
  user-select: none;
}

.is-hidden,
[hidden] {
  display: none !important;
}

/* ---------- App shell ------------------------------------------------------ */

.app-main {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.app-topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  height: var(--topbar-height);
  padding: 0 1.5rem;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--line);
}

.app-topbar::before {
  /* Thin fire-red rule along the very top of the page */
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 3px;
  background: var(--accent);
}

.topbar-brand {
  display: none;
  align-items: center;
  gap: 0.5rem;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.1rem;
  color: var(--ink);
  text-decoration: none;
  white-space: nowrap;
}

.topbar-brand .material-symbols-outlined {
  color: var(--accent);
  font-size: 26px;
}

.topbar-brand-public {
  display: inline-flex;
}

.topbar-logo {
  max-height: 36px;
  max-width: 7rem;
  object-fit: contain;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-left: auto;
}

.topbar-icon,
.notification-link {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  min-width: 40px;
  height: 40px;
  padding: 0;
  border-radius: var(--radius);
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  text-decoration: none;
  transition: background 120ms ease, color 120ms ease;
}

.topbar-icon,
.notification-link,
.topbar-icon:hover,
.notification-link:hover,
.sidebar-close:hover,
.app-tabbar button:hover {
  box-shadow: none;
  filter: none;
}

.topbar-icon:hover,
.notification-link:hover {
  background: color-mix(in srgb, var(--ink) 7%, transparent);
  color: var(--ink);
}

.topbar-menu {
  display: none;
}

.icon-theme-toggle {
  border-radius: var(--radius);
}

.icon-theme-toggle svg {
  width: 20px;
  height: 20px;
}

.notification-badge {
  position: absolute;
  top: 3px;
  right: 2px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  line-height: 16px;
  text-align: center;
  box-shadow: 0 0 0 2px var(--surface);
  box-sizing: border-box;
}

.profile-avatar-button,
.profile-avatar-preview {
  width: 38px;
  height: 38px;
  border-radius: 999px;
  background: var(--nav-bg);
  color: #fff;
  border: 2px solid var(--surface);
  box-shadow: 0 0 0 1px var(--line);
  font-size: 0.8rem;
}

.notification-popover,
.profile-popover {
  border-radius: var(--radius-lg);
  border: 1px solid var(--line);
  background: var(--surface);
  box-shadow: 0 12px 32px rgba(16, 24, 40, 0.16);
}

.page-shell {
  width: 100%;
  max-width: 1400px;
  margin: 0 auto;
  padding: 1.75rem 2rem 3rem;
  flex: 1;
}

/* ---------- Sidebar -------------------------------------------------------- */

.app-sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 40;
  width: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  background: var(--nav-bg);
  color: var(--nav-ink);
  border-right: 1px solid rgba(255, 255, 255, 0.04);
}

.app-sidebar::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 3px;
  background: var(--accent);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 1.1rem 1rem 1rem 1.1rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
}

.sidebar-brand-link {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  min-width: 0;
  color: var(--nav-ink-strong);
  text-decoration: none;
}

.sidebar-logo {
  width: 42px;
  height: 42px;
  object-fit: contain;
  border-radius: var(--radius-sm);
  background: #fff;
  padding: 3px;
  flex: 0 0 auto;
}

.sidebar-logo-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: #fff;
  font-size: 26px;
}

.sidebar-brand-text {
  display: grid;
  min-width: 0;
}

.sidebar-brand-text strong {
  font-family: var(--font-display);
  font-size: 1.08rem;
  font-weight: 800;
  letter-spacing: 0.01em;
  white-space: nowrap;
}

.sidebar-brand-text small {
  color: var(--nav-muted);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
}

.sidebar-close {
  display: none;
  border: 0;
  box-shadow: none;
  margin-left: auto;
  width: 36px;
  min-width: 36px;
  height: 36px;
  padding: 0;
  border-radius: var(--radius);
  background: transparent;
  color: var(--nav-ink);
  align-items: center;
  justify-content: center;
}

.sidebar-close:hover {
  background: var(--nav-hover);
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 0.75rem 0.75rem 1rem;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.14) transparent;
}

.side-group + .side-group {
  margin-top: 1rem;
}

.side-group-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  width: 100%;
  margin: 0 0 0.35rem;
  padding: 0.2rem 0.75rem;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--nav-muted);
  background: none;
  border: none;
  cursor: pointer;
  border-radius: var(--radius);
}

.side-group-title:hover,
.side-group-title:focus-visible {
  color: var(--nav-ink-strong);
}

.side-group-caret {
  font-size: 18px;
  transition: transform 150ms ease;
}

.side-group-title[aria-expanded="false"] .side-group-caret {
  transform: rotate(-90deg);
}

.side-group-links {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.side-group-links[hidden] {
  display: none;
}

.side-link {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.55rem 0.75rem;
  border-radius: var(--radius);
  color: var(--nav-ink);
  text-decoration: none;
  font-weight: 500;
  font-size: 0.93rem;
  transition: background 120ms ease, color 120ms ease;
}

.side-link .material-symbols-outlined {
  font-size: 21px;
  color: var(--nav-muted);
  transition: color 120ms ease;
}

.side-link:hover {
  background: var(--nav-hover);
  color: var(--nav-ink-strong);
}

.side-link:hover .material-symbols-outlined {
  color: var(--nav-ink-strong);
}

.side-link.is-active {
  background: color-mix(in srgb, var(--accent) 22%, transparent);
  color: #fff;
  font-weight: 600;
}

.side-link.is-active::before {
  content: "";
  position: absolute;
  left: -0.75rem;
  top: 0.4rem;
  bottom: 0.4rem;
  width: 4px;
  border-radius: 0 4px 4px 0;
  background: var(--accent);
}

.side-link.is-active .material-symbols-outlined {
  color: #ff6b7d;
}

.side-link:focus-visible {
  outline: 2px solid #fff;
  outline-offset: -2px;
}

.side-count {
  margin-left: auto;
  min-width: 22px;
  height: 20px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 20px;
  text-align: center;
}

.sidebar-footer {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem;
  border-top: 1px solid rgba(255, 255, 255, 0.07);
  background: var(--nav-bg-raised);
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  min-width: 0;
  flex: 1;
  padding: 0.35rem;
  border-radius: var(--radius);
  color: var(--nav-ink-strong);
  text-decoration: none;
}

.sidebar-user:hover {
  background: var(--nav-hover);
}

.sidebar-avatar {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  flex: 0 0 auto;
  border-radius: 999px;
  overflow: hidden;
  background: var(--accent);
  color: #fff;
  font-size: 0.78rem;
  font-weight: 700;
}

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

.sidebar-user-text {
  display: grid;
  min-width: 0;
}

.sidebar-user-text strong,
.sidebar-user-text small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-user-text strong {
  font-size: 0.88rem;
}

.sidebar-user-text small {
  color: var(--nav-muted);
  font-size: 0.75rem;
}

.sidebar-logout {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius);
  color: var(--nav-muted);
}

.sidebar-logout:hover {
  background: var(--nav-hover);
  color: #fff;
}

.nav-drawer-backdrop {
  position: fixed;
  inset: 0;
  z-index: 39;
  border: 0;
  border-radius: 0;
  padding: 0;
  background: rgba(10, 12, 15, 0.55);
  backdrop-filter: blur(2px);
}

.nav-drawer-backdrop::before {
  display: none;
}

.nav-drawer-backdrop:hover,
.nav-drawer-backdrop:focus {
  background: rgba(10, 12, 15, 0.55);
  filter: none;
  box-shadow: none;
}

/* Desktop: sidebar always visible */
@media (min-width: 1024px) {
  .has-app-shell .app-main {
    margin-left: var(--sidebar-width);
  }

  .has-app-shell .profile-menu {
    display: none; /* the sidebar footer shows the profile on desktop */
  }

  .nav-drawer-backdrop {
    display: none;
  }
}

/* Tablet / phone: slide-in drawer + bottom tab bar */
@media (max-width: 1023px) {
  .app-sidebar {
    width: min(300px, 86vw);
    transform: translateX(-102%);
    transition: transform 200ms ease, box-shadow 200ms ease;
  }

  .app-sidebar.is-open {
    transform: translateX(0);
    box-shadow: 0 0 40px rgba(0, 0, 0, 0.35);
  }

  .sidebar-close {
    display: inline-flex;
  }

  .topbar-menu {
    display: inline-flex;
  }

  .topbar-brand {
    display: inline-flex;
  }

  .app-topbar {
    padding: 0 0.75rem;
  }

  .page-shell {
    padding: 1.25rem 1rem calc(var(--tabbar-height) + 1.5rem + env(safe-area-inset-bottom));
  }

  .is-public .page-shell {
    padding-bottom: 2rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .app-sidebar {
    transition: none;
  }
}

/* ---------- Bottom tab bar (phones / tablets) ------------------------------- */

.app-tabbar {
  display: none;
}

@media (max-width: 1023px) {
  .app-tabbar {
    position: fixed;
    inset: auto 0 0 0;
    z-index: 35;
    display: flex;
    justify-content: space-around;
    height: calc(var(--tabbar-height) + env(safe-area-inset-bottom));
    padding-bottom: env(safe-area-inset-bottom);
    background: var(--nav-bg);
    border-top: 1px solid rgba(255, 255, 255, 0.06);
  }

  .app-tabbar a,
  .app-tabbar button {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    min-width: 0;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    color: var(--nav-muted);
    font: 600 0.7rem/1.2 var(--font-ui);
    text-decoration: none;
    cursor: pointer;
  }

  .app-tabbar .material-symbols-outlined {
    font-size: 24px;
  }

  .app-tabbar .is-active {
    color: #fff;
  }

  .app-tabbar .is-active .material-symbols-outlined {
    color: #ff6b7d;
    font-variation-settings: "FILL" 1;
  }

  .tabbar-icon-wrap {
    position: relative;
    display: inline-flex;
  }

  .tabbar-badge {
    position: absolute;
    top: -4px;
    right: -10px;
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    border-radius: 999px;
    background: var(--accent);
    color: #fff;
    font-size: 10px;
    line-height: 16px;
    text-align: center;
  }

  .fit-test-badge {
    bottom: calc(var(--tabbar-height) + 1rem);
  }
}

@media print {
  .app-sidebar,
  .app-topbar,
  .app-tabbar,
  .nav-drawer-backdrop {
    display: none !important;
  }

  .has-app-shell .app-main {
    margin-left: 0 !important;
  }

  .page-shell {
    padding: 0 !important;
    max-width: none;
  }
}

/* ---------- Page header (hero) -------------------------------------------- */

.hero {
  gap: 1.25rem;
  margin-bottom: 1.5rem;
  align-items: start;
}

.hero h1 {
  font-size: 1.9rem;
}

.hero > div:first-child > .eyebrow,
.hero > .hero-copy > .eyebrow {
  display: block;
  margin: 0 0 0.2rem;
}

.eyebrow {
  margin: 0;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
}

.eyebrow a {
  text-decoration: none;
}

.hero-actions {
  gap: 0.5rem;
  align-items: center;
}

/* ---------- Cards ---------------------------------------------------------- */

.card,
.stat-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 1.35rem 1.5rem;
}

.card > h2:first-child,
.card > .hero-heading-row:first-child h2 {
  font-size: 1.15rem;
}

.card + .card,
section.card {
  margin-bottom: 1.25rem;
}

.stat-card {
  position: relative;
  overflow: hidden;
  padding-top: 1.5rem;
}

.stat-card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 4px;
  background: var(--accent);
}

.stat-card span {
  font-family: var(--font-display);
  font-size: 2.2rem;
  font-weight: 800;
  line-height: 1.1;
  color: var(--ink);
}

/* ---------- Buttons -------------------------------------------------------- */

button,
.button-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  min-height: 40px;
  padding: 0.55rem 1.1rem;
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  background: var(--accent);
  color: #fff;
  font: 600 0.9rem/1.2 var(--font-ui);
  letter-spacing: 0.01em;
  text-decoration: none;
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.12);
  transition: background 120ms ease, border-color 120ms ease, box-shadow 120ms ease, transform 60ms ease;
}

/* Zero-specificity hover so page-specific button styles keep their own colours */
:where(button:not(:disabled), .button-link):hover {
  filter: brightness(0.92);
}

button:active,
.button-link:active {
  transform: translateY(1px);
}

button:focus-visible,
.button-link:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
  transform: none;
}

.secondary-button,
.theme-toggle,
.button-link.secondary-button {
  background: var(--surface);
  color: var(--ink);
  border: 1px solid color-mix(in srgb, var(--ink) 22%, var(--line));
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.06);
}

.secondary-button:hover,
.theme-toggle:hover,
.button-link.secondary-button:hover {
  background: color-mix(in srgb, var(--ink) 6%, var(--surface));
  border-color: color-mix(in srgb, var(--ink) 35%, var(--line));
  color: var(--ink);
}

.button-danger {
  background: var(--danger);
  border-color: var(--danger);
}

.icon-link,
.icon-button {
  min-width: 40px;
  min-height: 40px;
  padding: 0.4rem 0.6rem;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  box-shadow: none;
}

.icon-link:hover,
.icon-button:hover {
  background: color-mix(in srgb, var(--ink) 6%, var(--surface));
  border-color: color-mix(in srgb, var(--ink) 30%, var(--line));
  color: var(--ink);
}

.hero-cta {
  min-height: 44px;
}

/* Old drawer-style nav links (any page that still uses .site-nav) */
.site-nav a {
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--line);
}

/* ---------- Forms ---------------------------------------------------------- */

label {
  font-weight: 600;
  font-size: 0.88rem;
  color: var(--ink);
}

input,
select,
textarea {
  min-height: 40px;
  padding: 0.55rem 0.75rem;
  border-radius: var(--radius-sm);
  border: 1px solid color-mix(in srgb, var(--ink) 20%, var(--line));
  background: var(--surface);
  color: var(--ink);
  font: 400 0.95rem/1.4 var(--font-ui);
  transition: border-color 120ms ease, box-shadow 120ms ease;
}

input:hover,
select:hover,
textarea:hover {
  border-color: color-mix(in srgb, var(--ink) 35%, var(--line));
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: var(--focus-ring);
}

input[type="checkbox"],
input[type="radio"] {
  min-height: 0;
  width: 18px;
  height: 18px;
  padding: 0;
  accent-color: var(--accent);
  box-shadow: none;
}

input[type="file"] {
  padding: 0.4rem;
  background: color-mix(in srgb, var(--ink) 3%, var(--surface));
}

input[type="file"]::file-selector-button {
  margin-right: 0.75rem;
  padding: 0.4rem 0.8rem;
  border: 1px solid color-mix(in srgb, var(--ink) 22%, var(--line));
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
  font: 600 0.85rem var(--font-ui);
  cursor: pointer;
}

input:disabled,
select:disabled,
textarea:disabled {
  background: color-mix(in srgb, var(--ink) 4%, var(--surface));
  color: var(--muted);
}

fieldset {
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

legend {
  font-weight: 700;
  padding: 0 0.35rem;
}

details > summary {
  cursor: pointer;
}

/* ---------- Tables --------------------------------------------------------- */

.table-wrap {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.card .table-wrap {
  margin-top: 0.5rem;
}

table {
  font-size: 0.9rem;
}

th {
  position: sticky;
  top: 0;
  padding: 0.65rem 0.85rem;
  background: color-mix(in srgb, var(--ink) 4%, var(--surface));
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  white-space: nowrap;
  border-bottom: 1px solid var(--line);
}

td {
  padding: 0.7rem 0.85rem;
  border-bottom: 1px solid color-mix(in srgb, var(--line) 70%, transparent);
  vertical-align: middle;
}

tbody tr:last-child td {
  border-bottom: 0;
}

tbody tr:hover td {
  background: color-mix(in srgb, var(--accent) 3.5%, transparent);
}

tbody tr.clickable-row:hover {
  background: transparent;
}

/* ---------- Status chips / alerts ------------------------------------------ */

.status-chip {
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  border: 1px solid transparent;
  background: color-mix(in srgb, var(--ink) 8%, transparent);
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.status-chip.success {
  background: color-mix(in srgb, var(--ok) 14%, transparent);
  color: var(--ok);
}

.status-chip.warning {
  background: var(--warning-bg);
  color: var(--warning-ink);
  border-color: transparent;
}

.status-chip.error {
  background: color-mix(in srgb, var(--danger) 12%, transparent);
  color: var(--danger);
  border-color: transparent;
}

/* ---------- Switch (active/inactive toggle) --------------------------------- */

.switch {
  position: relative;
  display: inline-flex;
  align-items: center;
  width: 2.5rem;
  height: 1.4rem;
  cursor: pointer;
}

.switch input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}

.switch-track {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  background: color-mix(in srgb, var(--ink) 16%, transparent);
  transition: background 150ms ease;
}

.switch-track::before {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: calc(1.4rem - 4px);
  height: calc(1.4rem - 4px);
  border-radius: 50%;
  background: var(--surface);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
  transition: transform 150ms ease;
}

.switch input:checked + .switch-track {
  background: var(--ok);
}

.switch input:checked + .switch-track::before {
  transform: translateX(calc(2.5rem - 1.4rem));
}

.switch input:focus-visible + .switch-track {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.flash {
  position: relative;
  padding: 0.8rem 1rem 0.8rem 1.15rem;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  font-weight: 500;
}

.flash::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  border-radius: var(--radius) 0 0 var(--radius);
  background: var(--muted);
}

.flash.error,
.flash.success,
.flash.warning {
  background: var(--surface);
  color: var(--ink);
}

.flash.error::before { background: var(--danger); }
.flash.success::before { background: var(--ok); }
.flash.warning::before { background: #e29a00; }

.flash-toast {
  box-shadow: 0 12px 32px rgba(16, 24, 40, 0.18);
}

.flash-stack-floating {
  top: calc(var(--topbar-height) + 0.75rem);
}

/* ---------- Dialogs -------------------------------------------------------- */

.app-dialog {
  border-radius: var(--radius-lg);
  border: 1px solid var(--line);
  background: var(--surface);
  box-shadow: 0 24px 64px rgba(16, 24, 40, 0.28);
  padding: 1.5rem;
}

.app-dialog::backdrop {
  background: rgba(10, 12, 15, 0.55);
  backdrop-filter: blur(2px);
}

/* ---------- Login / public pages ------------------------------------------- */

.is-public .app-main {
  background:
    linear-gradient(180deg, transparent 0, var(--bg) 340px),
    var(--stripe) top / 100% 6px no-repeat,
    radial-gradient(ellipse at 50% -10%, color-mix(in srgb, var(--accent) 22%, transparent), transparent 60%),
    var(--bg);
}

.is-public .app-topbar {
  background: transparent;
  backdrop-filter: none;
  border-bottom: 0;
}

.is-public .app-topbar::before {
  display: none;
}

.auth-card {
  max-width: 440px;
  margin: 3vh auto 2rem;
  gap: 1.25rem;
}

.auth-intro h1 {
  font-size: 2.1rem;
}

.auth-card form.card {
  padding: 1.75rem;
  gap: 1.1rem;
  border-top: 4px solid var(--accent);
}

.auth-card form button[type="submit"] {
  min-height: 46px;
  font-size: 1rem;
}

.auth-card > p {
  margin: 0;
  text-align: center;
  color: var(--muted);
  font-size: 0.9rem;
}

/* ---------- Misc shared bits ----------------------------------------------- */

hr {
  border: 0;
  border-top: 1px solid var(--line);
}

kbd {
  padding: 0.1rem 0.4rem;
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 4px;
  font-size: 0.85em;
  background: var(--surface);
}

code {
  padding: 0.05rem 0.3rem;
  border-radius: 4px;
  background: color-mix(in srgb, var(--ink) 7%, transparent);
  font-size: 0.88em;
}

.preview-note {
  color: var(--muted);
}

::selection {
  background: color-mix(in srgb, var(--accent) 25%, transparent);
}

/* Download button feedback keeps its green "done" state */
button.is-downloaded {
  background: var(--ok) !important;
  border-color: var(--ok) !important;
}

/* ---------- Top bar breadcrumb --------------------------------------------- */

.topbar-crumbs {
  display: flex;
  align-items: center;
  gap: 0.2rem;
  min-width: 0;
  font-size: 0.9rem;
  color: var(--muted);
  white-space: nowrap;
}

.topbar-crumbs .material-symbols-outlined {
  font-size: 18px;
  opacity: 0.6;
}

.topbar-crumbs strong {
  color: var(--ink);
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
}

@media (max-width: 1023px) {
  .topbar-crumbs {
    display: none;
  }
}

/* ---------- Dashboard quick links as tiles ---------------------------------- */

.hero-copy-inline > .hero-actions {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 0.75rem;
  width: 100%;
}

.button-link.hero-cta {
  position: relative;
  justify-content: space-between;
  min-height: 64px;
  padding: 0.9rem 1rem 0.9rem 1.15rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  color: var(--ink);
  font-size: 0.95rem;
  font-weight: 700;
  white-space: normal;
  text-align: left;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.button-link.hero-cta::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  background: var(--accent);
}

.button-link.hero-cta::after {
  content: "arrow_forward";
  font-family: "Material Symbols Outlined";
  font-size: 20px;
  font-weight: 400;
  color: var(--accent);
  transition: transform 120ms ease;
}

.button-link.hero-cta:hover {
  background: var(--surface);
  border-color: color-mix(in srgb, var(--accent) 45%, var(--line));
  color: var(--ink);
}

.button-link.hero-cta:hover::after {
  transform: translateX(3px);
}

.hero:has(.hero-copy-inline) {
  grid-template-columns: 1fr;
}

/* ---------- Table action cells (were display:flex, which breaks row lines) -- */

td.user-actions {
  display: table-cell;
  text-align: right;
  white-space: nowrap;
}

td.user-actions > * {
  display: inline-flex;
  vertical-align: middle;
  margin: 0;
}

td.user-actions > * + * {
  margin-left: 0.4rem;
}

.hero-copy-inline > .hero-actions .hero-cta {
  justify-self: stretch;
  align-self: stretch;
}

/* ---------- Calendar uses the full width now that the menu is a sidebar ------ */

.calendar-viewport {
  width: 100%;
  max-width: 100%;
}

.calendar-day {
  min-height: 7.5rem;
  border-radius: var(--radius);
  background: var(--surface);
}

.calendar-day.is-today {
  border-color: var(--accent);
  box-shadow: inset 0 3px 0 var(--accent);
}

/* ---------- Phone spacing ---------------------------------------------------- */

@media (max-width: 640px) {
  h1,
  .hero h1 {
    font-size: 1.45rem;
  }

  .card,
  .stat-card {
    padding: 1rem;
    border-radius: var(--radius);
  }

  .hero {
    margin-bottom: 1rem;
  }

  .button-link.hero-cta {
    min-height: 52px;
  }

  th,
  td {
    padding: 0.6rem 0.65rem;
  }
}
