:root {
  /* This app only ships a light theme. Without this, a browser/OS set to
     dark mode renders native form controls (select's option list,
     scrollbars, checkboxes) with a dark UA theme while our CSS still paints
     the surrounding chrome light -- e.g. a <select>'s open dropdown list can
     end up rendering with light-on-light or otherwise illegible text/
     background, making the options invisible even though they're there. */
  color-scheme: light;
  --kepla-navy: #1c3144;
  --kepla-teal: #2a6f77;
  --kepla-bg: #f4f6f7;
  --kepla-border: #d6dde0;
  --kepla-danger: #a3242c;
  --kepla-warn-bg: #fff4e5;
  --kepla-warn-border: #e0a63a;
}

* { box-sizing: border-box; }

body {
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  background: var(--kepla-bg);
  color: #1a1a1a;
  margin: 0;
}

header.site-header {
  background: var(--kepla-navy);
  color: #fff;
  padding: 0.75rem 1.5rem;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 0.4rem 1rem;
}

header.site-header a { color: #fff; text-decoration: none; }
header.site-header .brand { font-weight: 600; font-size: 1.05rem; }

/* Nav bar groups: a short "primary" list of daily-use links rendered
   inline, any number of named secondary groups (e.g. "Admin") collapsed
   into a <details> dropdown so a role with many links (LabAdmin) doesn't
   dump 10+ flat items into the bar, and a separate account-actions
   dropdown (name/role, manual, preview-as, password, log out) kept
   visually distinct from feature navigation. Always visible (no JS-less
   hamburger toggle) -- on narrow screens the groups simply wrap onto
   additional rows via flex-wrap below, rather than collapsing into a
   hidden menu. */
.site-nav {
  display: flex;
  flex: 1 1 auto;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.4rem 1rem;
}

.nav-group { display: flex; flex-wrap: wrap; align-items: center; }
.nav-primary a { margin-right: 1.1rem; font-size: 0.9rem; opacity: 0.9; }
.nav-primary a:hover { opacity: 1; text-decoration: underline; }

.nav-dropdown { position: relative; margin-right: 1.1rem; }
.nav-group:last-child .nav-dropdown:last-child,
.nav-primary a:last-child { margin-right: 0; }

.nav-dropdown summary {
  cursor: pointer;
  font-size: 0.9rem;
  opacity: 0.9;
  list-style: none;
}
.nav-dropdown summary::-webkit-details-marker { display: none; }
.nav-dropdown summary:hover, .nav-dropdown[open] summary { opacity: 1; text-decoration: underline; }
.nav-dropdown summary::after { content: "\25BE"; margin-left: 0.3rem; font-size: 0.7em; }

.nav-dropdown-menu {
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 0.6rem;
  background: #fff;
  border: 1px solid var(--kepla-border);
  border-radius: 6px;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.18);
  padding: 0.4rem 0;
  min-width: 220px;
  z-index: 20;
  display: flex;
  flex-direction: column;
}
/* Specificity note: header.site-header a {color:#fff} above outranks a
   plain .nav-dropdown-menu a rule (fewer selector components), so this
   must be qualified with header.site-header too or the dropdown's dark-
   on-white menu renders as invisible white-on-white text. */
header.site-header .nav-dropdown-menu a {
  color: #1a1a1a;
  padding: 0.5rem 1rem;
  font-size: 0.9rem;
  white-space: nowrap;
  margin: 0;
}
.nav-dropdown-menu a:hover { background: var(--kepla-bg); text-decoration: none; }

.nav-account-dropdown summary {
  padding-left: 1.1rem;
  border-left: 1px solid rgba(255, 255, 255, 0.25);
}

@media (max-width: 860px) {
  .site-nav { flex-basis: 100%; flex-direction: column; align-items: stretch; }
  .nav-group { flex-direction: column; align-items: stretch; }
  .nav-primary a, .nav-dropdown { margin: 0.2rem 0; }
  .nav-dropdown-menu {
    position: static;
    box-shadow: none;
    border: none;
    margin-top: 0.2rem;
    padding-left: 1rem;
  }
  header.site-header .nav-dropdown-menu a { padding: 0.35rem 0.75rem; }
  .nav-account-dropdown summary { border-left: none; padding-left: 0; }
}

main.container {
  max-width: 960px;
  margin: 2rem auto;
  padding: 0 1.5rem;
}

.card {
  background: #fff;
  border: 1px solid var(--kepla-border);
  border-radius: 6px;
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}

.narrow-card { max-width: 420px; margin: 3rem auto; }

h1, h2, h3 { color: var(--kepla-navy); }

.dashboard-header { margin-bottom: 1.75rem; }
.dashboard-header h1 { margin-bottom: 0.25rem; }

.dashboard-section { margin-bottom: 2rem; }
.dashboard-section h2 {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #5a6a70;
  margin: 0 0 0.85rem;
}

.tile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 1rem;
}

.tile {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.85rem;
  background: #fff;
  border: 1px solid var(--kepla-border);
  border-radius: 10px;
  padding: 1.25rem;
  color: var(--kepla-navy);
  text-decoration: none;
  transition: box-shadow 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
}
.tile:hover {
  box-shadow: 0 10px 24px rgba(28, 49, 68, 0.14);
  border-color: var(--kepla-teal);
  transform: translateY(-2px);
  text-decoration: none;
}
.tile-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 46px;
  height: 46px;
  border-radius: 10px;
  background: rgba(42, 111, 119, 0.1);
  color: var(--kepla-teal);
  flex: none;
}
.tile-icon svg { width: 24px; height: 24px; }
.tile-label { font-weight: 600; font-size: 0.92rem; line-height: 1.3; }

label { display: block; font-weight: 600; margin-top: 0.85rem; margin-bottom: 0.25rem; font-size: 0.9rem; }

input[type="text"], input[type="password"], input[type="email"], input[type="number"],
select, textarea {
  width: 100%;
  padding: 0.5rem;
  border: 1px solid var(--kepla-border);
  border-radius: 4px;
  font-size: 1rem;
}

button, .btn {
  display: inline-block;
  background: var(--kepla-teal);
  color: #fff;
  border: none;
  padding: 0.55rem 1.1rem;
  border-radius: 4px;
  font-size: 0.95rem;
  cursor: pointer;
  margin-top: 1rem;
  text-decoration: none;
}
button:hover, .btn:hover { opacity: 0.92; }
.btn-secondary { background: #6b7a80; }

.errorlist { color: var(--kepla-danger); list-style: none; padding: 0; margin: 0.25rem 0; font-size: 0.85rem; }

.messages { list-style: none; padding: 0; }
.messages li { padding: 0.6rem 1rem; border-radius: 4px; margin-bottom: 0.75rem; background: #e7f3ea; border: 1px solid #a9d3b3; }
.messages li.error { background: #fbe7e8; border-color: #e3a5a9; }

.compliance-banner {
  background: var(--kepla-warn-bg);
  border-bottom: 3px solid var(--kepla-warn-border);
  color: #6b4a12;
  padding: 0.6rem 1.5rem;
  font-size: 0.85rem;
  text-align: center;
  font-weight: 600;
}

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 0.5rem 0.6rem; border-bottom: 1px solid var(--kepla-border); font-size: 0.9rem; }
th { background: #eef1f2; }
tr.row-danger td { background: #fbe7e8; }

.status-pill {
  display: inline-block;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  background: #dde7ea;
  color: var(--kepla-navy);
}

.helptext { color: #5a6a70; font-size: 0.85rem; }

.warn-box {
  background: var(--kepla-warn-bg);
  border: 1px solid var(--kepla-warn-border);
  border-radius: 4px;
  padding: 0.75rem 1rem;
  margin: 0.75rem 0;
  color: #6b4a12;
  font-size: 0.9rem;
}

dl.config-list { display: grid; grid-template-columns: max-content 1fr; gap: 0.35rem 1rem; margin: 0; }
dl.config-list dt { font-weight: 600; color: var(--kepla-navy); }
dl.config-list dd { margin: 0; }
.backup-codes { font-family: monospace; font-size: 1.1rem; line-height: 1.8; }

.stat-tiles { display: flex; flex-wrap: wrap; gap: 1.5rem; margin: 0.5rem 0 1rem; }
.stat-tile { min-width: 140px; }
.stat-tile .value { font-size: 2rem; font-weight: 700; color: var(--kepla-navy); line-height: 1.1; }
.stat-tile .label { color: #5a6a70; font-size: 0.85rem; }

.bar-row { display: grid; grid-template-columns: 140px 1fr 60px; align-items: center; gap: 0.6rem; margin: 0.35rem 0; }
.bar-row .bar-label { font-size: 0.85rem; color: var(--kepla-navy); }
.bar-track { background: #eef1f2; border-radius: 3px; height: 14px; overflow: hidden; }
.bar-fill { background: var(--kepla-teal, #2a6f77); height: 100%; }
.bar-row .bar-value { font-size: 0.85rem; text-align: right; color: #5a6a70; }

.timeline { display: flex; flex-direction: column; }
.timeline-step { display: grid; grid-template-columns: 24px 1fr; column-gap: 0.75rem; }
.timeline-rail { display: flex; flex-direction: column; align-items: center; }
.timeline-dot { width: 14px; height: 14px; border-radius: 50%; background: #dde2e3; border: 2px solid #dde2e3; flex: none; margin-top: 0.15rem; }
.timeline-line { width: 2px; flex: 1; background: #dde2e3; min-height: 1.5rem; }
.timeline-step.done .timeline-dot { background: var(--kepla-teal, #2a6f77); border-color: var(--kepla-teal, #2a6f77); }
.timeline-step.done .timeline-line { background: var(--kepla-teal, #2a6f77); }
.timeline-step.current .timeline-dot { background: var(--kepla-navy); border-color: var(--kepla-navy); box-shadow: 0 0 0 3px rgba(28,49,68,0.15); }
.timeline-body { padding-bottom: 1.1rem; }
.timeline-label { font-weight: 600; font-size: 0.9rem; }
.timeline-step.upcoming .timeline-label { color: #93a3ac; font-weight: 500; }
.timeline-meta { font-size: 0.78rem; color: #5a6a70; }

.autocomplete-select { position: relative; }
.autocomplete-results {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  z-index: 30;
  background: #fff;
  border: 1px solid var(--kepla-border);
  border-radius: 4px;
  margin: 0.25rem 0 0;
  padding: 0.25rem 0;
  list-style: none;
  max-height: 220px;
  overflow-y: auto;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.15);
}
.autocomplete-results li { padding: 0.4rem 0.75rem; font-size: 0.9rem; cursor: pointer; }
.autocomplete-results li:hover, .autocomplete-results li:focus { background: var(--kepla-bg); }

@media print {
  header.site-header, .compliance-banner, .no-print { display: none !important; }
  main.container { max-width: none; margin: 0; padding: 0; }
  .card { border: none; padding: 0; margin-bottom: 1rem; }
}
