/*
 * Legevaktlag - components.
 *
 * Every colour, size and radius comes from tokens.css, which is generated from
 * design/tokens.json and shared with the apps. Do not write raw values here;
 * add a token instead. The profile is described in docs/visuell-profil.md.
 *
 * No build step. Mobile first; the layout widens at 720px.
 */

@font-face {
  font-family: "Schibsted Grotesk";
  src: url("../fonts/SchibstedGrotesk-latin-wght.woff2") format("woff2");
  font-weight: 400 900;
  font-style: normal;
  font-display: swap;
}

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

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

body {
  margin: 0;
  background: var(--color-bg);
  color: var(--color-text);
  font: var(--text-body);
  -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3,
p {
  margin: 0;
}

a {
  color: var(--color-brand-text);
}

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

/* --- page frame --------------------------------------------------------- */

/*
 * The zone: a deep green band at the top of every page that holds the
 * header. It is what keeps the product from looking like white paper - the
 * brand colour fills the top of the screen, and the browser's status bar is
 * tinted to match (theme-color in base.html).
 */
.zone {
  position: relative;
  overflow: hidden;
  background: var(--color-zone);
  color: var(--color-on-zone);
  border-radius: 0 0 var(--radius-xl) var(--radius-xl);
}

/* One soft glow in the corner. */
.zone::before {
  content: "";
  position: absolute;
  top: -180px;
  right: -140px;
  width: 420px;
  height: 420px;
  border-radius: var(--radius-pill);
  background: radial-gradient(
    closest-side,
    color-mix(in srgb, var(--color-zone-glow) 55%, transparent),
    transparent
  );
  pointer-events: none;
}

.zone-inner {
  position: relative;
  max-width: var(--size-page);
  margin: 0 auto;
  padding: max(var(--space-4), env(safe-area-inset-top)) var(--space-4) var(--space-6);
}

/* Room for the first card on the page to sit across the zone's edge. */
.zone.overlapped .zone-inner {
  padding-bottom: calc(var(--space-6) + 64px);
}

.page {
  max-width: var(--size-page);
  margin: 0 auto;
  padding: var(--space-5) var(--space-4) max(var(--space-6), env(safe-area-inset-bottom));
}

.page > .next:first-child {
  margin-top: calc(-64px - var(--space-5));
  position: relative;
}

body.has-tabbar .page {
  padding-bottom: calc(112px + env(safe-area-inset-bottom));
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  min-height: var(--size-tap);
  margin-bottom: var(--space-5);
}

.topbar form {
  margin: 0;
}

/* The wordmark: the name, and one small light. */
.brand {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font: var(--text-headline);
  font-family: var(--font-display);
  font-weight: 800;
  letter-spacing: -0.01em;
  color: var(--color-on-zone);
  text-decoration: none;
}

.brand::before {
  content: "";
  width: 12px;
  height: 12px;
  border-radius: var(--radius-pill);
  background: var(--color-accent);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

/* The bell: a round outlined button, with the unread count on its shoulder. */
.bell {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border: 1px solid color-mix(in srgb, var(--color-on-zone) 45%, transparent);
  border-radius: var(--radius-pill);
  color: var(--color-on-zone);
}

.bell svg {
  width: 20px;
  height: 20px;
}

.bell .count {
  position: absolute;
  top: -4px;
  right: -4px;
}

/* Your initials, leading to settings. Filled when you are there. */
.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: var(--radius-pill);
  background: color-mix(in srgb, var(--color-on-zone) 16%, transparent);
  color: var(--color-on-zone);
  font: var(--text-callout);
  font-weight: 700;
  text-decoration: none;
}

.avatar[aria-current="page"] {
  background: var(--color-on-zone);
  color: var(--color-zone);
}

/* Outlined pill for the quiet actions in the zone. */
.button.outline {
  width: auto;
  min-height: 40px;
  padding: 0 var(--space-4);
  background: transparent;
  border: 1px solid color-mix(in srgb, var(--color-on-zone) 45%, transparent);
  color: var(--color-on-zone);
  font: var(--text-callout);
  font-weight: 500;
}

.button.outline:active {
  background: color-mix(in srgb, var(--color-on-zone) 14%, transparent);
}

/* --- text --------------------------------------------------------------- */

.display {
  font: var(--text-display);
  letter-spacing: -0.02em;
  margin-bottom: var(--space-2);
}

.title {
  font: var(--text-title);
  letter-spacing: -0.01em;
  margin: var(--space-6) 0 var(--space-3);
}

/* "2027" once above the first month of a new year in a list of shifts. */
.display.year {
  margin: var(--space-7) 0 0;
}

.lead {
  color: var(--color-text-muted);
  margin-bottom: var(--space-5);
  max-width: 34em;
}

.zone .lead {
  color: var(--color-on-zone-muted);
  margin-bottom: 0;
}

.meta {
  font: var(--text-callout);
  color: var(--color-text-muted);
}

.caption {
  font: var(--text-caption);
  color: var(--color-text-muted);
}

/* --- buttons ------------------------------------------------------------ */

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: var(--size-tap);
  padding: 0 var(--space-5);
  border: 0;
  border-radius: var(--radius-pill);
  background: var(--color-cta);
  color: var(--color-on-cta);
  font: var(--text-headline);
  text-decoration: none;
  cursor: pointer;
  transition:
    background var(--motion-fast) var(--motion-ease),
    transform var(--motion-fast) var(--motion-ease);
}

.button:active {
  background: var(--color-cta-pressed);
  transform: scale(0.98);
}

.button.soft {
  background: var(--color-brand-soft);
  color: var(--color-on-brand-soft);
}

.button.plain {
  width: auto;
  min-height: 44px;
  padding: 0 var(--space-2);
  background: transparent;
  color: var(--color-brand-text);
  font-weight: 500;
}

.button.small {
  width: auto;
  min-height: 40px;
  padding: 0 var(--space-4);
  font: var(--text-callout);
  font-weight: 600;
}

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

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

.button.on-brand {
  background: var(--color-surface);
  color: var(--color-on-brand-soft);
}

.actions {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  margin-top: var(--space-5);
}

.actions form {
  margin: 0;
}

/* --- surfaces ----------------------------------------------------------- */

.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  margin-bottom: var(--space-4);
}

.card h2 {
  font: var(--text-title);
  margin-bottom: var(--space-1);
}

.empty {
  text-align: left;
}

.empty .button {
  margin-top: var(--space-4);
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 var(--space-3);
  border-radius: var(--radius-pill);
  background: var(--color-surface-sunken);
  color: var(--color-text-muted);
  font: var(--text-caption);
  white-space: nowrap;
}

.pill.accent {
  background: var(--color-accent);
  color: var(--color-on-accent);
  font-weight: 700;
}

/* --- next shift: the one loud thing on the page ------------------------- */

.next {
  background: var(--color-brand);
  color: var(--color-on-brand);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  margin-bottom: var(--space-4);
}

.next-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
  font: var(--text-callout);
  color: var(--color-on-brand-muted);
}

.next-day {
  font: var(--text-title);
}

.next-time {
  font: var(--text-numeral);
  letter-spacing: -0.02em;
  margin: var(--space-1) 0;
}

.next-where {
  font: var(--text-callout);
  color: var(--color-on-brand-muted);
}

/* Døgnlinja: where in the 24 hours the shift sits. A night shift wraps. */
.daytrack {
  margin-top: var(--space-5);
}

.daytrack-bar {
  position: relative;
  height: 12px;
  border-radius: var(--radius-pill);
  background: color-mix(in srgb, var(--color-on-brand) 22%, transparent);
  overflow: hidden;
}

.daytrack-bar span {
  position: absolute;
  top: 0;
  bottom: 0;
  background: var(--color-accent);
  border-radius: var(--radius-pill);
  transform-origin: left center;
  animation: daytrack-grow 700ms var(--motion-ease) both;
}

.daytrack-scale {
  display: flex;
  justify-content: space-between;
  margin-top: var(--space-2);
  font: var(--text-caption);
  font-variant-numeric: tabular-nums;
  color: var(--color-on-brand-muted);
}

@keyframes daytrack-grow {
  from {
    transform: scaleX(0);
  }
}

.next-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  margin-top: var(--space-5);
}

.next .pill {
  background: color-mix(in srgb, var(--color-on-brand) 18%, transparent);
  color: var(--color-on-brand);
}

.next .pill.accent {
  background: var(--color-accent);
  color: var(--color-on-accent);
}

.next a {
  color: var(--color-on-brand);
}

/* --- lists -------------------------------------------------------------- */

.list {
  list-style: none;
  margin: 0 0 var(--space-4);
  padding: 0;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.list > li {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  padding: var(--space-4);
}

.list > li + li {
  border-top: 1px solid var(--color-border);
}

.list > li.inline {
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
}

.list form {
  margin: 0;
}

/* One shift: the date, a stripe in the shift type's colour, and the rest. */
.shift {
  display: grid;
  grid-template-columns: 44px 5px 1fr;
  gap: var(--space-3);
  align-items: stretch;
}

.shift-date {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font: var(--text-caption);
  color: var(--color-text-muted);
}

.shift-date strong {
  font: var(--text-title);
  font-variant-numeric: tabular-nums;
  color: var(--color-text);
}

.shift-stripe {
  border-radius: var(--radius-pill);
  background: var(--shift-colour, var(--color-border));
}

.shift-body {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-width: 0;
}

.shift-name {
  font: var(--text-headline);
}

.shift-time {
  font: var(--text-callout);
  font-variant-numeric: tabular-nums;
  color: var(--color-text-muted);
}

.row-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding-left: 61px;
}

.row-footer > :first-child {
  min-width: 0;
}

.row-footer form,
.row-footer .button {
  flex: none;
  white-space: nowrap;
}

/* --- give a shift away (expands in place) ------------------------------- */

details.offer {
  padding-left: 61px;
}

details.offer summary {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  padding: 0 var(--space-4);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-pill);
  color: var(--color-text);
  font: var(--text-callout);
  font-weight: 500;
  cursor: pointer;
  list-style: none;
}

details.offer[open] summary {
  margin-bottom: var(--space-3);
}

details.offer summary::-webkit-details-marker {
  display: none;
}

details.offer form {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  padding-bottom: var(--space-2);
}

.next details.offer {
  padding-left: 0;
}

.next details.offer {
  margin-top: var(--space-5);
}

.next details.offer summary {
  border-color: color-mix(in srgb, var(--color-on-brand) 50%, transparent);
  color: var(--color-on-brand);
}

.next details.offer label,
.next details.offer .hint {
  color: var(--color-on-brand-muted);
}

/* --- forms -------------------------------------------------------------- */

label {
  display: block;
  font: var(--text-callout);
  color: var(--color-text-muted);
  margin-bottom: var(--space-2);
}

input[type="email"],
input[type="password"],
input[type="text"] {
  width: 100%;
  min-height: var(--size-tap);
  padding: 0 var(--space-4);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  color: var(--color-text);
  font: var(--text-body);
}

.hint {
  font: var(--text-caption);
  color: var(--color-text-muted);
}

.error {
  color: var(--color-danger);
  margin-bottom: var(--space-4);
}

/* A rule the person may overrule: not an error, and not to be missed. */
.warning {
  margin-top: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  background: var(--color-warning-soft);
  color: var(--color-warning);
}

.warning ul {
  margin: var(--space-1) 0 0;
  padding-left: var(--space-4);
}

.warning li + li {
  margin-top: var(--space-1);
}

.notice {
  font: var(--text-callout);
  color: var(--color-text-muted);
  margin-top: var(--space-4);
}

/* --- messages ----------------------------------------------------------- */

.messages {
  margin-top: var(--space-4);
}

.message {
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  background: var(--color-success-soft);
  color: var(--color-success);
  font: var(--text-callout);
  font-weight: 500;
}

.message + .message {
  margin-top: var(--space-2);
}

.message.error {
  background: var(--color-danger-soft);
  color: var(--color-danger);
}

/* --- tab bar: a dark floating pill on phones, part of the zone when wide - */

.tabbar {
  position: fixed;
  z-index: 10;
  left: 50%;
  bottom: calc(var(--space-4) + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  display: flex;
  gap: var(--space-1);
  width: min(calc(100% - var(--space-6)), 400px);
  padding: 6px;
  border: 1px solid color-mix(in srgb, var(--color-on-nav) 16%, transparent);
  border-radius: var(--radius-pill);
  background: color-mix(in srgb, var(--color-nav) 92%, transparent);
  -webkit-backdrop-filter: saturate(160%) blur(18px);
  backdrop-filter: saturate(160%) blur(18px);
}

.tabbar a {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-height: 54px;
  border-radius: var(--radius-pill);
  color: var(--color-on-nav);
  font: var(--text-caption);
  text-decoration: none;
  transition: background var(--motion-base) var(--motion-ease);
}

.tabbar svg {
  width: 22px;
  height: 22px;
}

.count,
.tabbar .count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: var(--radius-pill);
  background: var(--color-accent);
  color: var(--color-on-accent);
  font: var(--text-caption);
  font-size: 11px;
  font-weight: 700;
}

.tabbar a[aria-current="page"] {
  background: var(--color-nav-active);
  color: var(--color-on-nav-active);
  font-weight: 700;
}

@media (min-width: 720px) {
  body.has-tabbar .page {
    padding-bottom: var(--space-6);
  }

  .tabbar {
    position: static;
    transform: none;
    width: auto;
    margin: 0 0 var(--space-5);
  }

  .tabbar a {
    flex-direction: row;
    gap: var(--space-2);
    min-height: 44px;
    font: var(--text-callout);
    font-weight: 500;
  }
}

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

/* --- a planner's decision on a swap ------------------------------------- */

.reason {
  font: var(--text-callout);
  font-weight: 600;
  color: var(--color-text);
}

.decision {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  padding-left: 61px;
  margin-top: var(--space-2);
}

.decision-buttons {
  display: flex;
  gap: var(--space-2);
}

.decision-buttons .button {
  flex: 1;
}

/* --- notifications ------------------------------------------------------ */

.list > li:has(.notice-row) {
  flex-direction: row;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-3);
}

.notice-row {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  min-width: 0;
}

.notice-title {
  font: var(--text-headline);
}

/* Unread: a small dot in the accent colour before the title. */
.notice-row.unread .notice-title::before {
  content: "";
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-right: var(--space-2);
  border-radius: var(--radius-pill);
  background: var(--color-accent);
  vertical-align: middle;
}

/* --- settings ----------------------------------------------------------- */

.settings-form {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.field-readonly {
  display: flex;
  justify-content: space-between;
  gap: var(--space-3);
}

/* An on/off switch, from a plain checkbox. */
.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  margin: 0;
  color: var(--color-text);
  font: var(--text-body);
  cursor: pointer;
}

.switch-row .caption {
  display: block;
}

.switch {
  appearance: none;
  flex: none;
  position: relative;
  width: 52px;
  height: 32px;
  margin: 0;
  border-radius: var(--radius-pill);
  background: var(--color-surface-sunken);
  border: 1px solid var(--color-border);
  cursor: pointer;
  transition: background var(--motion-base) var(--motion-ease);
}

.switch::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 24px;
  height: 24px;
  border-radius: var(--radius-pill);
  background: var(--color-surface);
  box-shadow: 0 1px 2px color-mix(in srgb, var(--color-text) 30%, transparent);
  transition: transform var(--motion-base) var(--motion-ease);
}

.switch:checked {
  background: var(--color-brand);
  border-color: var(--color-brand);
}

.switch:checked::after {
  transform: translateX(20px);
}

.signout {
  margin-top: var(--space-6);
}

/* --- administration ----------------------------------------------------- */

.nav-list > li {
  padding: 0;
}

.nav-list a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  min-height: 64px;
  padding: var(--space-4);
  color: var(--color-text);
  text-decoration: none;
}

.nav-list a::after {
  content: "";
  flex: none;
  width: 8px;
  height: 8px;
  border-top: 2px solid var(--color-text-muted);
  border-right: 2px solid var(--color-text-muted);
  transform: rotate(45deg);
}

.nav-title {
  display: block;
  font: var(--text-headline);
}

.person {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.invite summary {
  list-style: none;
}

.invite summary::-webkit-details-marker {
  display: none;
}

.invite[open] summary {
  margin-bottom: var(--space-5);
}

.field-pair {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-3);
}

select {
  width: 100%;
  min-height: var(--size-tap);
  padding: 0 var(--space-4);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  color: var(--color-text);
  font: var(--text-body);
}

/* --- vaktmal (the standing template) ------------------------------------ */

.list > li.template-item {
  flex-direction: row;
  flex-wrap: wrap;
  align-items: center;
}

.template-item .template-row {
  flex: 1;
  min-width: 0;
}

.template-item .row-edit[open] {
  flex-basis: 100%;
}

.row-edit summary {
  list-style: none;
  align-self: flex-start;
}

.row-edit summary::-webkit-details-marker {
  display: none;
}

.row-edit[open] {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  padding-top: var(--space-2);
}

input[type="time"],
input[type="date"],
input[type="number"] {
  width: 100%;
  min-height: var(--size-tap);
  margin-top: var(--space-2);
  padding: 0 var(--space-4);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  color: var(--color-text);
  font: var(--text-body);
  font-variant-numeric: tabular-nums;
}

input[type="color"] {
  width: var(--size-tap);
  height: var(--size-tap);
  padding: var(--space-1);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
}

.daypick {
  margin: 0;
  padding: 0;
  border: 0;
}

.daypick legend {
  margin-bottom: var(--space-2);
  font: var(--text-callout);
  color: var(--color-text-muted);
}

.daypick-days {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-bottom: var(--space-2);
}

/* A checkbox that looks like a toggle chip. The box itself stays focusable. */
.chip {
  position: relative;
  margin: 0;
}

.chip input {
  position: absolute;
  opacity: 0;
  inset: 0;
  margin: 0;
  cursor: pointer;
}

.chip span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 48px;
  min-height: 44px;
  padding: 0 var(--space-3);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-pill);
  background: var(--color-surface);
  color: var(--color-text);
  font: var(--text-callout);
  transition: background var(--motion-fast) var(--motion-ease);
}

.chip input:checked + span {
  background: var(--color-brand);
  border-color: var(--color-brand);
  color: var(--color-on-brand);
}

.chip input:focus-visible + span {
  outline: 2px solid var(--color-focus);
  outline-offset: 2px;
}

.rules ol {
  margin: var(--space-3) 0 0;
  padding-left: var(--space-5);
  font: var(--text-callout);
}

.rules li + li {
  margin-top: var(--space-2);
}

.section-hint {
  margin: calc(-1 * var(--space-2)) 0 var(--space-3);
}

.week-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  margin-bottom: var(--space-2);
}

.week-preview > li {
  gap: var(--space-1);
}

.preview-slot {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font: var(--text-callout);
  font-variant-numeric: tabular-nums;
}

.preview-slot .dot {
  flex: none;
  width: 10px;
  height: 10px;
  border-radius: var(--radius-pill);
  background: var(--shift-colour, var(--color-border));
}

.input-with-button {
  display: flex;
  gap: var(--space-2);
}

/* --- planning screen ------------------------------------------------------ */

/* The planner works across the whole screen, not in a phone-width column. */
.wide .zone-inner,
.wide .page {
  max-width: none;
}

.back {
  display: inline-block;
  margin-bottom: var(--space-3);
  color: var(--color-on-zone-muted);
  font: var(--text-callout);
  text-decoration: none;
}

.plan-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--space-3);
}

.plan-head form {
  margin: 0;
}

.planner {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--space-4);
}

/* Grid items default to their content's width; the table must scroll instead. */
.planner > * {
  min-width: 0;
}

/* Made for a PC (decision 0014). Below this the page still works, but says so. */
.desktop-hint {
  display: none;
  margin-bottom: var(--space-4);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  background: var(--color-warning-soft);
  color: var(--color-warning);
  font: var(--text-callout);
}

@media (max-width: 1023px) {
  .desktop-hint {
    display: block;
  }
}

.plan-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: var(--space-2);
}

.plan-period summary {
  list-style: none;
}

.plan-period summary::-webkit-details-marker {
  display: none;
}

.plan-period[open] form {
  width: 420px;
  margin: var(--space-3) 0 0;
  color: var(--color-text);
}

.planner-toolbar {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  margin-bottom: var(--space-3);
}

.planner-toolbar .button {
  flex: none;
}

.day-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
}

.add-here {
  width: 28px;
  height: 28px;
  border: 1px dashed var(--color-border);
  border-radius: var(--radius-pill);
  background: transparent;
  color: var(--color-text-muted);
  font: var(--text-callout);
  cursor: pointer;
  opacity: 0;
  transition: opacity var(--motion-fast) var(--motion-ease);
}

.planner-grid tr:hover .add-here,
.add-here:focus-visible {
  opacity: 1;
}

.slot-time {
  margin-left: auto;
  flex: none;
  color: var(--color-text-muted);
  font: var(--text-caption);
  font-variant-numeric: tabular-nums;
}

@media (min-width: 1024px) {
  .planner {
    grid-template-columns: 320px minmax(0, 1fr);
    align-items: start;
  }

  .planner-doctors {
    position: sticky;
    top: var(--space-4);
    max-height: calc(100vh - 2 * var(--space-4));
    overflow-y: auto;
  }
}


.planner-help {
  margin-bottom: var(--space-3);
}

#doctor-list,
.sheet-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}


.doctor {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  width: 100%;
  min-height: var(--size-tap);
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  color: var(--color-text);
  text-align: left;
  cursor: grab;
}

.doctor.active {
  border-color: var(--color-brand);
  background: var(--color-brand-soft);
  box-shadow: inset 0 0 0 1px var(--color-brand);
}

.doctor:focus-visible,
.slot:focus-visible {
  outline: 2px solid var(--color-focus);
  outline-offset: 2px;
}

.doctor-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.doctor-name {
  font: var(--text-callout);
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.initials {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-pill);
  background: var(--color-brand);
  color: var(--color-on-brand);
  font: var(--text-caption);
  font-weight: 700;
}

.planner-grid-wrap {
  overflow: auto;
  max-height: calc(100vh - 2 * var(--space-4));
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  background: var(--color-surface);
}

.planner-grid {
  border-collapse: separate;
  border-spacing: 0;
  min-width: 100%;
  font: var(--text-callout);
}

.planner-grid th,
.planner-grid td {
  padding: var(--space-1) var(--space-2);
  border-bottom: 1px solid var(--color-border);
  vertical-align: middle;
}

.planner-grid thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  min-width: 150px;
  padding-top: var(--space-3);
  background: var(--color-surface);
  text-align: left;
  border-top: 4px solid var(--shift-colour, var(--color-border));
}

.planner-grid .col-type {
  display: block;
  font-weight: 600;
}

.planner-grid .day-col {
  position: sticky;
  left: 0;
  z-index: 1;
  min-width: 120px;
  background: var(--color-surface);
  text-align: left;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.planner-grid thead .day-col {
  z-index: 3;
  border-top-color: transparent;
}

.planner-grid .weekday {
  display: inline-block;
  width: 2.2em;
  color: var(--color-text-muted);
  text-transform: capitalize;
}

.planner-grid .holiday {
  display: block;
  color: var(--color-warning);
  font: var(--text-caption);
  white-space: normal;
}

.planner-grid tr.off td,
.planner-grid tr.off .day-col {
  background: var(--color-surface-sunken);
}

.planner-grid tr.month th {
  position: sticky;
  left: 0;
  padding-top: var(--space-4);
  background: var(--color-surface);
  font: var(--text-headline);
  text-align: left;
  text-transform: capitalize;
}

.slot {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  width: 100%;
  min-height: 40px;
  padding: var(--space-1) var(--space-2);
  border: 1px solid transparent;
  border-left: 4px solid var(--shift-colour, var(--color-border));
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  color: var(--color-text);
  font: var(--text-callout);
  text-align: left;
  cursor: pointer;
  transition: background var(--motion-fast) var(--motion-ease);
}

.slot + .slot {
  margin-top: var(--space-1);
}

.slot .initials {
  width: 24px;
  height: 24px;
}

.slot-text {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.slot.open {
  border: 1px dashed var(--color-border);
  border-left: 4px solid var(--shift-colour, var(--color-border));
  color: var(--color-text-muted);
}

.slot.mine {
  background: var(--color-brand-soft);
  border-color: var(--color-brand);
}

.slot.drop {
  background: var(--color-brand-soft);
  border-style: solid;
  border-color: var(--color-brand);
}

.slot.busy {
  opacity: 0.5;
}

/* Bottom sheet on a phone, a centred panel when wide. */
.sheet {
  width: 100%;
  max-width: 480px;
  max-height: 85vh;
  margin: auto auto 0;
  padding: 0;
  border: 0;
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  background: var(--color-surface);
  color: var(--color-text);
}

@media (min-width: 720px) {
  .sheet {
    margin: auto;
    border-radius: var(--radius-xl);
  }
}

.sheet::backdrop {
  background: color-mix(in srgb, var(--color-text) 40%, transparent);
}

.sheet-inner {
  padding: var(--space-5);
}

.sheet .sheet-list {
  margin-top: var(--space-4);
}

textarea {
  width: 100%;
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  color: var(--color-text);
  font: var(--text-body);
}

.toast {
  position: fixed;
  z-index: 20;
  left: 50%;
  bottom: var(--space-5);
  max-width: calc(100% - 2 * var(--space-4));
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  background: var(--color-text);
  color: var(--color-surface);
  font: var(--text-callout);
  transform: translateX(-50%);
}

.toast.error {
  background: var(--color-danger);
  color: var(--color-on-brand);
}

.doctor-row {
  display: flex;
  align-items: stretch;
  gap: var(--space-1);
}

.doctor-row .doctor {
  flex: 1;
  min-width: 0;
}

.doctor.excluded {
  opacity: 0.6;
}

.settings-line {
  color: var(--color-brand-text);
}

.doctor-gear {
  flex: none;
  width: 40px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  color: var(--color-text-muted);
  font: var(--text-body);
  cursor: pointer;
}

.doctor-gear:hover,
.doctor-gear:focus-visible {
  color: var(--color-brand-text);
  border-color: var(--color-brand);
}

.fravaer-title {
  margin-top: var(--space-5);
}

.planner-toolbar form {
  margin: 0;
}


/* --- wishes and absence (decision 0016) --------------------------------- */

/* A choice of two or three, from plain radio buttons. */
.segmented {
  display: flex;
  margin: 0;
  padding: 3px;
  border: 0;
  border-radius: var(--radius-pill);
  background: var(--color-surface-sunken);
}

.segmented label {
  flex: 1;
  margin: 0;
}

.segmented input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.segmented span {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: calc(var(--size-tap) - 6px);
  padding: 0 var(--space-3);
  border-radius: var(--radius-pill);
  color: var(--color-text-muted);
  font: var(--text-callout);
  text-align: center;
  cursor: pointer;
  transition: background var(--motion-base) var(--motion-ease);
}

.segmented input:checked + span {
  background: var(--color-surface);
  color: var(--color-text);
  font-weight: 600;
  box-shadow: 0 1px 2px color-mix(in srgb, var(--color-text) 20%, transparent);
}

.segmented input[value="want"]:checked + span {
  background: var(--color-success-soft);
}

.segmented input[value="avoid"]:checked + span {
  background: var(--color-warning-soft);
}

.segmented input:focus-visible + span {
  outline: 2px solid var(--color-focus);
  outline-offset: 2px;
}

.segmented.small span {
  min-height: 36px;
  padding: 0 var(--space-1);
  font: var(--text-caption);
  white-space: nowrap;
}

/* Two date fields side by side must shrink with a narrow card. */
.field-pair > * {
  min-width: 0;
}

.field-pair input {
  min-width: 0;
}

.choice-row {
  display: grid;
  grid-template-columns: minmax(4.5rem, auto) minmax(0, 1fr);
  align-items: center;
  gap: var(--space-3);
}

.type-name {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.type-name::before {
  content: "";
  flex: none;
  width: 4px;
  height: 20px;
  border-radius: var(--radius-pill);
  background: var(--shift-colour);
}

.month-heading {
  margin: var(--space-5) 0 var(--space-2);
}

.pill.wish-want,
.pill.status-approved {
  background: var(--color-success-soft);
  color: var(--color-text);
}

.pill.wish-avoid,
.pill.status-pending {
  background: var(--color-warning-soft);
  color: var(--color-text);
}

.pill.status-rejected {
  background: var(--color-danger-soft);
  color: var(--color-text);
}

section + section {
  margin-top: var(--space-6);
}

/* What the doctor being painted with has said about each shift. */
.slot-mark {
  flex: none;
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: var(--radius-pill);
  font: var(--text-caption);
  font-weight: 700;
}

.slot.mark-want .slot-mark,
.pill.mark-want {
  background: var(--color-success-soft);
  color: var(--color-success);
}

.slot.mark-avoid .slot-mark,
.pill.mark-avoid,
.slot.mark-pending .slot-mark,
.pill.mark-pending {
  background: var(--color-warning-soft);
  color: var(--color-warning);
}

.slot.mark-away .slot-mark,
.pill.mark-away {
  background: var(--color-danger-soft);
  color: var(--color-danger);
}

.slot.mark-away:not(.mine) {
  background: var(--color-danger-soft);
}

.doctor-text .pill {
  align-self: flex-start;
  margin-top: var(--space-1);
}

/* --- historikk ----------------------------------------------------------- */

.tabular {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.year-nav {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-bottom: var(--space-5);
}

.year-nav a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: calc(var(--size-tap) + var(--space-4));
  min-height: var(--size-tap);
  padding: 0 var(--space-3);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-pill);
  background: var(--color-surface);
  color: var(--color-text);
  font: var(--text-callout);
  font-variant-numeric: tabular-nums;
  text-decoration: none;
}

.year-nav a[aria-current="page"] {
  background: var(--color-brand);
  border-color: var(--color-brand);
  color: var(--color-on-brand);
  font-weight: 600;
}

.year-nav a:focus-visible {
  outline: 2px solid var(--color-focus);
  outline-offset: 2px;
}

/* Two big figures, then three smaller ones in a row. */
.stats {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: var(--space-4) var(--space-3);
  margin: 0 0 var(--space-4);
}

.stat {
  grid-column: span 2;
  margin: 0;
}

.stat-main {
  grid-column: span 3;
}

.stat dt {
  font: var(--text-caption);
  color: var(--color-text-muted);
}

.stat dd {
  margin: 0;
  font: var(--text-title);
  font-variant-numeric: tabular-nums;
}

.stat-main dd {
  font: var(--text-numeral);
}

.row-footer.history-tags {
  justify-content: flex-start;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.row-footer.history-tags > :first-child {
  margin-right: var(--space-2);
}

/* --- signing in without HelseID (docs/beslutninger/0017) ---------------- */

/* Black on white whatever the theme: a scanner cannot read it otherwise. */
.qr {
  display: block;
  margin: var(--space-3) 0;
  width: 200px;
  max-width: 100%;
  height: auto;
  border-radius: var(--radius-md);
}

.secret {
  font: var(--text-headline);
  letter-spacing: 0.08em;
  overflow-wrap: anywhere;
  user-select: all;
}

/* The calendar link: long, shown once, selected in one tap to copy. */
.calendar-url {
  margin: var(--space-2) 0;
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  background: var(--color-surface-sunken);
  font: var(--text-callout);
  overflow-wrap: anywhere;
  user-select: all;
}

.codes {
  display: grid;
  /* Two columns where they fit, one on a narrow phone. */
  grid-template-columns: repeat(auto-fill, minmax(8.5em, 1fr));
  gap: var(--space-2) var(--space-4);
  margin: 0;
  padding: var(--space-4);
  list-style: none;
  border-radius: var(--radius-md);
  background: var(--color-surface-sunken);
  font: var(--text-body);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.04em;
  user-select: all;
}

.codes li {
  white-space: nowrap;
}

.method-choice {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

/* --- Attest for gjennomførte legevakter (apps/competence) --- */

.attest h3 {
  margin-top: var(--space-5);
}

.attest dd.blank {
  font-style: italic;
}

.attest .signature {
  margin-top: var(--space-6);
}

@media print {
  .zone,
  .tabbar,
  .no-print {
    display: none !important;
  }

  body {
    background: var(--color-surface);
  }

  .page {
    max-width: none;
    margin: 0;
    padding: 0;
  }

  .attest {
    box-shadow: none;
    border: 0;
    padding: 0;
  }
}

/* --- Kompetanse fra HPR i planleggingsskjermen (apps/competence) --- */

.pill.comp {
  min-height: 20px;
  margin-left: var(--space-2);
  padding: 0 var(--space-2);
  font-size: 0.75em;
  vertical-align: middle;
}

.pill.comp-qualified,
.pill.comp-specialist {
  background: var(--color-success-soft);
  color: var(--color-success);
}

.pill.comp-needs_bakvakt,
.pill.comp-unknown {
  background: var(--color-warning-soft);
  color: var(--color-text);
}

.pill.comp-not_doctor {
  background: var(--color-danger-soft);
  color: var(--color-text);
}

.comp-row {
  display: block;
}

.comp-row-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
}

.comp-row p {
  margin: var(--space-2) 0 0;
}

.comp-badges .pill.comp:first-child {
  margin-left: 0;
}
