/*
Förskolebemanning styles. Plain modern CSS, no build step, no Tailwind.
- Tokens: css/tokens.css (FVK brand on top of Open Props scales).
- Cascade layers: reset < tokens < base < components < views.
- Native nesting and container queries; works in all current browsers.
House style is Frånvarokollen's: navy sidebar with the white logo, warm paper, white cards,
Geist, tactile buttons (lift on hover, press on click).
*/

@layer reset {
  * { box-sizing: border-box; min-width: 0; }
  html { scroll-padding-top: 20px; }
}

@layer base {
  body {
    margin: 0; background: var(--page); color: var(--ink); overflow-x: clip; -webkit-font-smoothing: antialiased;
    font: 15px/1.45 var(--font);
  }
  h1, h2, h3, h4 { line-height: 1.15; margin: 0; text-wrap: balance; color: var(--ink); }
  h1 { font-size: clamp(22px, 3vw, 28px); font-weight: var(--weight-bold); letter-spacing: -0.015em; }
  h2 { font-size: 18px; font-weight: var(--weight-bold); }
  h3 { font-size: 16px; font-weight: var(--weight-semibold); }
  h4 { font-size: 14px; font-weight: var(--weight-semibold); margin: 12px 0 6px; }
  p { margin: 6px 0; }
  a { color: var(--blue); }
  small, .small { font-size: 13px; }
  .muted { color: var(--muted); }
  .nowrap { white-space: nowrap; }
  .scroll { overflow-x: auto; }
  :focus-visible { outline: var(--focus-ring); outline-offset: 2px; }
  /* a dialog heading takes focus so screen readers start there (js/ui-a11y.js); it needs no ring */
  [tabindex="-1"]:focus { outline: none; }

  button, select, input, textarea { font: inherit; color: inherit; }
  input:is([type=text], [type=number], [type=time], [type=date], [type=search], [type=email], [type=tel]), select, textarea {
    min-height: 40px; padding: 7px 10px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--bg); font-size: 15px; width: 100%;
  }
  :is(input, select, textarea) {
    &:focus { border-color: var(--blue); outline: 2px solid rgb(15 113 246 / .2); outline-offset: 0; }
    &:disabled { background: var(--soft); color: var(--muted); }
  }
  input {
    &[type=number] { max-width: 120px; }
    &[type=color] { width: 56px; height: 40px; padding: 2px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--bg); }
    &[type=checkbox], &[type=radio] { width: 20px; height: 20px; accent-color: var(--blue); }
  }
  textarea { resize: vertical; font-size: 15px; }
}

@layer components {
  /* FVK tactile button */
  button {
    min-height: 40px; padding: 7px 14px; border: 1px solid var(--line); background: var(--bg); border-radius: var(--radius);
    font-weight: var(--weight-medium); cursor: pointer; color: var(--ink); box-shadow: var(--shadow);
    transition: background var(--t-fast), border-color var(--t-fast), box-shadow var(--t-fast), transform var(--t-press);

    &:hover { box-shadow: var(--shadow-up); transform: translateY(-1px); }
    &:active { transform: translateY(1px); box-shadow: var(--shadow-press); }
    &:disabled { opacity: .45; cursor: not-allowed; transform: none; box-shadow: none; }

    &.primary {
      background: var(--blue); border-color: var(--blue); color: #fff; box-shadow: var(--shadow-cta);
      &:hover { background: var(--blue-hover); border-color: var(--blue-hover); }
    }
    &.ghost {
      border-color: transparent; background: transparent; box-shadow: none; color: var(--muted);
      &:hover { background: var(--soft); color: var(--ink); }
    }
    &.small { min-height: 32px; padding: 4px 10px; font-size: 13px; }
    &.danger {
      border-color: #f5c2c9; color: var(--red);
      &:hover { background: var(--redbg); }
    }
    &.link {
      border: 0; padding: 0; min-height: 0; background: none; box-shadow: none; color: var(--blue); font-weight: var(--weight-medium); text-align: left;
      &:hover { text-decoration: underline; transform: none; }
    }
    &.x { min-height: 32px; width: 32px; padding: 0; font-size: 18px; line-height: 1; box-shadow: none; }
    &.icon { width: 40px; padding: 0; font-size: 22px; }
  }

  /* boot / welcome */
  .boot { display: grid; place-items: center; min-height: 60vh; color: var(--muted); }
  .spin { width: 32px; height: 32px; border: 4px solid var(--line); border-top-color: var(--blue); border-radius: 50%; animation: spin 1s linear infinite; }
  @keyframes spin { to { transform: rotate(360deg); } }
  @media (prefers-reduced-motion: reduce) { .spin { animation: none; } button, button:hover { transition: none; transform: none; } }
  .welcome {
    max-width: 760px; margin: 0 auto; padding: clamp(32px, 8vw, 96px) var(--space-4);
    & h1 { font-size: clamp(30px, 6vw, 44px); }
    & .lead { font-size: 17px; color: var(--muted); max-width: 60ch; margin: 12px 0 var(--space-5); }
  }
  .wlogo { height: 56px; display: block; margin-bottom: 22px; }
  .choices { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; margin-bottom: var(--space-4); }
  button.big {
    display: grid; gap: 6px; text-align: left; padding: 18px var(--space-4); min-height: 112px; align-content: start;
    & b { font-size: 17px; font-weight: var(--weight-semibold); }
    & span { font-weight: var(--weight-regular); font-size: 14px; color: var(--muted); }
    &.primary span { color: #fff; opacity: .85; }
  }

  /* shell: FVK navy sidebar + paper content */
  .shell { display: grid; grid-template-columns: var(--sbw) minmax(0, 1fr); min-height: 100vh; }
  .sidebar {
    position: sticky; top: 0; height: 100vh; overflow-y: auto; background: var(--navy-deep); color: var(--on-dark);
    display: flex; flex-direction: column; padding: 22px 12px var(--space-3);

    & .nav { display: flex; flex-direction: column; gap: 6px; }
    & .navi {
      display: flex; align-items: center; height: 44px; padding: 0 var(--space-3); border-radius: var(--radius-lg); text-decoration: none; font-size: 14px;
      color: rgb(255 255 255 / .6); background: rgb(255 255 255 / .04); border: 1px solid rgb(255 255 255 / .06);
      transition: background var(--t-nav), transform var(--t-nav), box-shadow var(--t-nav);
      &:hover { background: rgb(255 255 255 / .1); border-color: rgb(255 255 255 / .12); transform: translateY(-1px); box-shadow: 0 4px 8px -2px rgb(0 0 0 / .3); }
      &.on { background: rgb(255 255 255 / .15); border-color: rgb(255 255 255 / .15); color: var(--on-dark); font-weight: var(--weight-medium); box-shadow: 0 2px 6px -1px rgb(0 0 0 / .25); transform: none; }
    }
  }
  .sb-brand {
    padding: 0 6px var(--space-4); display: grid; gap: 2px;
    & img { height: 36px; width: auto; justify-self: start; margin-bottom: 12px; }
    & b { font-size: 14px; font-weight: var(--weight-semibold); color: var(--on-dark); }
    & span { font-size: 12px; color: rgb(255 255 255 / .45); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  }
  .sb-label { font-size: 9px; text-transform: uppercase; letter-spacing: 1.5px; color: rgb(255 255 255 / .3); margin: 0 0 10px var(--space-2); }
  .sb-foot { margin-top: auto; display: grid; gap: 10px; padding-top: var(--space-3); border-top: 1px solid rgb(255 255 255 / .06); }
  .account {
    display: grid; gap: 4px; padding: 0 6px; font-size: 12px;
    & .acct-who { color: var(--on-dark); font-weight: var(--weight-medium); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    & .muted { color: rgb(255 255 255 / .45); }
    & .btnrow { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 4px; }
    & button { background: rgb(255 255 255 / .06); color: rgb(255 255 255 / .75); border-color: rgb(255 255 255 / .1); box-shadow: none; }
    & button:hover { background: rgb(255 255 255 / .12); }
  }
  form.login {
    display: grid; gap: var(--space-3); max-width: 420px; margin-bottom: var(--space-4);
    & input { font-size: 17px; }
    & button.big { min-height: 0; }
  }
  form.invite { align-items: end; margin-top: var(--space-3); }
  .pplcover { margin: var(--space-2) 0 var(--space-3); padding: 10px 14px; border: 1px solid var(--line); border-left: 4px solid var(--line); border-radius: var(--radius); font-size: 14px; }
  .pplcover.one { border-left-color: var(--blue); background: #eef4fe; }
  td > select + .warnmsg { display: block; margin-top: 4px; }
  .langseg {
    display: flex; gap: var(--space-1); padding: var(--space-1); border-radius: var(--radius-lg); background: rgb(255 255 255 / .06);
    & button {
      flex: 1; min-height: 34px; padding: 0; border: 1px solid transparent; border-radius: var(--radius-sm); background: transparent; box-shadow: none;
      color: rgb(255 255 255 / .4); font-size: 13px; font-weight: var(--weight-medium);
      &:hover { background: rgb(255 255 255 / .08); box-shadow: none; }
      &.on { background: rgb(255 255 255 / .15); border-color: rgb(255 255 255 / .1); color: var(--on-dark); box-shadow: 0 1px 3px rgb(0 0 0 / .2); transform: none; }
    }
  }
  .as {
    display: grid; gap: var(--space-1); font-size: 11px; color: rgb(255 255 255 / .45);
    & select { min-height: 36px; padding: 4px 8px; font-size: 13px; background: rgb(255 255 255 / .06); color: var(--on-dark); border-color: rgb(255 255 255 / .1); }
    & select option { color: var(--ink); }
  }
  .savestate {
    font-size: 12px; color: rgb(255 255 255 / .45); min-height: 16px; padding-left: var(--space-1);
    &.saving { color: #fbbf24; }
    &.error { color: #ff8090; font-weight: var(--weight-semibold); }
  }
  .content { min-width: 0; }
  .build { font-size: 11px; color: rgb(255 255 255 / .35); padding-left: var(--space-1); font-variant-numeric: tabular-nums; }
  .mbuild, .wbuild { color: var(--muted); text-align: center; margin-top: var(--space-5); }
  .mbuild { display: none; }
  .top { display: none; }
  .bottomnav { display: none; }
  .main { container: main / inline-size; padding: 22px clamp(14px, 2.4vw, 32px) 80px; max-width: 1480px; margin: 0 auto; }
}

@layer views {

  /* day head */
  .dayhead { display: grid; gap: 12px; margin-bottom: 14px; }
  .datebar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
  .datepick { position: relative; display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 17px; }
  .datepick input { width: auto; }
  .summary {
    background: var(--bg); border: 1px solid var(--line); border-left: 5px solid var(--navy); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 18px;
    display: flex; flex-wrap: wrap; gap: 14px 24px; align-items: center; justify-content: space-between;
  }
  .sumtext { display: grid; gap: 10px; flex: 1 1 420px; }
  .kcta { display: grid; gap: 6px; justify-items: center; text-align: center; flex: 0 1 260px; }
  .kcta button.kollen { min-height: 52px; padding: 10px 26px; font-size: 17px; width: 100%; }
  .summary.bad { border-left-color: var(--red); }
  .summary.warn { border-left-color: var(--amber); }
  .summary.ok { border-left-color: var(--green); }
  .summary.norule { border-left-color: var(--red); }
  .stats { display: flex; flex-wrap: wrap; gap: 6px 28px; margin: 0; }
  .stats div { display: grid; }
  .stats dt { font-size: 12px; color: var(--muted); }
  .stats dd { margin: 0; font-size: clamp(20px, 2.6vw, 26px); font-weight: 650; font-variant-numeric: tabular-nums; white-space: nowrap; }
  .dayactions { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0 16px; }

  /* alerts */
  .alerts { display: grid; gap: 6px; margin: 6px 0 12px; }
  .alert { padding: 10px 14px; border-radius: var(--radius); border: 1px solid var(--line); border-left: 4px solid var(--muted); background: var(--bg); font-size: 15px; margin: 6px 0; }
  .alert.norule, .alert.red { border-color: #f5c2c9; border-left-color: var(--red); background: var(--redbg); }
  .alert.norule b { color: var(--red); letter-spacing: .02em; }
  .alert.amber { border-color: #f6dfa0; border-left-color: var(--amber); background: var(--amberbg); }
  .alert.info { border-left-color: var(--blue); }
  .alert a { font-weight: 600; margin-left: 6px; }
  .setup { background: var(--bg); border: 1.5px dashed var(--navy); border-radius: var(--radius); padding: 14px 18px; margin: 10px 0 16px; }
  .setup ol { margin: 8px 0 0; padding-left: 22px; }
  .setup li { margin: 4px 0; }
  .setup a { font-weight: 500; }
  .closed { padding: 40px 0; }

  /* layout: timeline uses the full width; panels sit below it */
  .panels { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr)); gap: 14px; margin-top: 18px; align-items: start; }
  .panel { background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 16px; }
  .panel h3 { margin-bottom: 8px; }
  .panel.extneed { border-color: var(--ext); border-left: 5px solid var(--ext); }
  .panel.extneed h3 { color: var(--ext); }

  /* whole day at a glance */
  .overview {
    background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 10px 14px; margin-bottom: 18px;
    display: grid; gap: 2px;
  }
  .ovrow {
    display: grid; grid-template-columns: 130px minmax(0, 1fr) 150px; gap: 4px 12px; align-items: center; text-align: left;
    border: 0; box-shadow: none; background: transparent; padding: 6px 4px; min-height: 0; border-radius: 8px; font-weight: inherit;
  }
  button.ovrow:hover { background: var(--soft); transform: none; box-shadow: none; }
  .ovaxis { padding-block: 0; }
  .ovname { display: flex; align-items: center; gap: 8px; font-weight: var(--weight-semibold); font-size: 14px; white-space: nowrap; overflow: hidden; }
  .ovstat { justify-self: end; }
  .ovhours { position: relative; height: 16px; }
  .ovhours span { position: absolute; font-size: 11px; color: var(--muted); transform: translateX(-50%); font-variant-numeric: tabular-nums; }

  /* whole day: hour lines through every row, even rows, a small key */
  .vh { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  .overview { gap: 0; padding: 12px 16px 10px; }
  .overview .ovrow { padding-block: 5px; }
  .overview .ovaxis { padding-block: 0 4px; }
  .ovtrack { position: relative; height: 26px; display: block; }
  .ovtick { position: absolute; top: -5px; bottom: -5px; width: 0; border-left: 1px dashed color-mix(in srgb, var(--line) 80%, transparent); }
  .ovbar { position: absolute; inset-inline: 0; top: 50%; translate: 0 -50%; }
  .ovbar i { position: absolute; top: 0; bottom: 0; display: block; }
  .ovtrack .ovnow { position: absolute; top: -5px; bottom: -5px; width: 2px; background: var(--navy-deep); border-radius: 2px; z-index: 2; }
  .ovfoot { display: flex; justify-content: flex-end; padding: 8px 4px 0; border-top: 1px solid var(--line); margin-top: 6px; }
  .ovkey { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--muted); }
  .ovkey span { display: inline-flex; align-items: center; gap: 6px; }
  .ovkey i { display: inline-block; width: 18px; height: 10px; border-radius: 3px; }
  .ovfoot, .ovkey i { -webkit-print-color-adjust: exact; print-color-adjust: exact; }

  /* calm bar: thin rounded bar in quiet tints; short time stands out taller, striped red */
  .ovbar { height: 12px; border-radius: 99px; background: var(--soft); }
  .ovbar i:first-child { border-radius: 99px 0 0 99px; }
  .ovbar i:last-child { border-radius: 0 99px 99px 0; }
  .ovbar i.green, .ovkey i.green { background: var(--calm-green); }
  .ovbar i.amber, .ovkey i.amber { background: var(--calm-sand); }
  .ovbar i.red, .ovkey i.red, .ovbar i.norule {
    top: -5px; bottom: -5px; border-radius: 5px; z-index: 1;
    background: repeating-linear-gradient(135deg, var(--red) 0 5px, var(--red-deep) 5px 8px);
    box-shadow: 0 0 0 2px var(--bg);
  }
  .ovkey i.red { height: 14px; box-shadow: none; }

  /* rules behind a toggle on each group card */
  details.rules { margin: 2px 0 8px; }
  details.rules summary { cursor: pointer; font-size: 13px; color: var(--muted); width: fit-content; }
  details.rules .rulecard { margin-top: 4px; }

  /* Fråga Kollen panel */
  .klead { font-size: 17px; font-weight: var(--weight-semibold); margin: 0; }
  .kollen h2 { color: var(--navy); }
  .modal:has(.kollen) { width: min(980px, calc(100vw - 24px)); }
  .kbtns { display: flex; gap: 6px; flex-wrap: wrap; }
  .kwho { display: flex; flex-direction: column; gap: 2px; margin: 0 0 6px; color: var(--muted); }
  .kwho select { font-size: inherit; padding: 4px 8px; max-width: 100%; }
  .plancols.busy { opacity: .55; pointer-events: none; }
  .kundo { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 12px; border-radius: 8px; background: var(--page); border: 1px solid var(--line); }
  .kignored { border-top: 1px solid var(--line); padding-top: 10px; display: grid; gap: 6px; & h4, & p { margin: 0; } }
  .sugs, .exts, .plain, .changes, .segs { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }

  .sugs > li { border-bottom: 1px solid var(--line); padding-bottom: 10px; display: grid; gap: 6px; justify-items: start; }
  .sugs p { margin: 0; font-weight: 500; }

  .exts > li { display: grid; gap: 4px; justify-items: start; border-bottom: 1px solid var(--line); padding-bottom: 10px; }
  .changes li { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 15px; }
  .impact { list-style: none; padding: 0; margin: 0; font-size: 14px; display: grid; gap: 2px; }
  .impact li { display: block; border: 0; padding: 0; }
  .sugs p { margin: 0; }
  .impact .better { color: var(--green); }
  .impact .worse { color: var(--red); }
  .impact b { color: var(--ink); }

  /* group timeline */
  .timeline { display: grid; gap: 18px; }
  .gcard { background: var(--bg); border: 1px solid var(--line); border-top: 4px solid var(--gc); border-radius: var(--radius); box-shadow: var(--shadow); padding: 12px 14px; }
  .gcard header { display: flex; justify-content: space-between; gap: 10px; align-items: center; flex-wrap: wrap; }
  .gtitle { display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; }
  .dot { width: 12px; height: 12px; border-radius: 50%; background: var(--gc); display: inline-block; flex: none; }
  .rulecard { font-size: 14px; color: var(--muted); margin: 4px 0 8px; }
  .rulecard.big { font-size: 15px; color: var(--ink); background: var(--soft); padding: 10px 12px; border-radius: 8px; }
  .pill { display: inline-block; padding: 3px 10px; border-radius: 99px; font-size: 12px; font-weight: 600; white-space: nowrap; }
  .pill.red { background: var(--red); color: #fff; }
  .pill.green { background: var(--greenbg); color: var(--green); }
  .pill.amber { background: var(--amberbg); color: var(--ambertext); }
  .pill.norule { background: var(--red); color: #fff; letter-spacing: .03em; font-weight: 700; }
  .pill.off { background: var(--soft); }
  .tlscroll { overflow-x: auto; padding-bottom: 6px; }
  .tl {
    position: relative; display: grid; grid-template-columns: var(--namew) minmax(calc(var(--n) * var(--cw)), 1fr);
    row-gap: 4px; align-items: center;
  }
  .rl { font-size: 12px; color: var(--muted); position: sticky; left: 0; background: var(--bg); z-index: 2; padding-right: 6px; }
  .row { display: grid; grid-template-columns: repeat(var(--n), minmax(0, 1fr)); gap: 1px; }
  .row.hours span { font-size: 12px; color: var(--muted); border-left: 1px solid var(--line); padding-left: 2px; height: 16px; line-height: 16px; }
  .row.hours span:empty { border-left-color: transparent; }
  .row.kids span { text-align: center; font-size: 12px; font-variant-numeric: tabular-nums; color: var(--muted); }
  .cell {
    min-height: 34px; padding: 0; border: 0; border-radius: 3px; font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums;
    background: var(--soft); box-shadow: none; color: var(--muted); display: grid; place-items: center; line-height: 1;
  }
  .cell small { font-size: 10px; font-weight: 500; }
  .cell.green { background: var(--greenbg); color: var(--green); }
  .cell.amber { background: var(--amberbg); color: var(--ambertext); }
  .cell.red { background: var(--red); color: #fff; }
  .cell.red.q { box-shadow: inset 0 -4px 0 var(--navy-deep); }
  .cell.norule { background: repeating-linear-gradient(135deg, var(--red) 0 4px, var(--redbg) 4px 8px); color: #fff; }
  .cell.off { background: transparent; }
  .cell:hover { outline: 2px solid var(--blue); transform: none; }
  .who {
    border: 0; min-height: 30px; padding: 0 6px 0 0; text-align: left; font-size: 13px; font-weight: 500; background: var(--bg); box-shadow: none; border-radius: 6px;
    display: flex; gap: 4px; align-items: center; position: sticky; left: 0; z-index: 2; overflow: hidden; white-space: nowrap;
  }
  .who span { overflow: hidden; text-overflow: ellipsis; }
  .who:hover { background: var(--soft); transform: none; box-shadow: none; }
  .track { position: relative; height: 24px; background: linear-gradient(var(--line), var(--line)) 0 50% / 100% 1px no-repeat; }
  .seg {
    position: absolute; top: 2px; bottom: 2px; border-radius: 4px; font-size: 11px; line-height: 20px; padding: 0 4px;
    overflow: hidden; white-space: nowrap; text-overflow: ellipsis;
  }
  .seg.work { background: color-mix(in srgb, var(--gc, #777) 70%, var(--bg)); color: #fff; }
  .seg.work.in { background: var(--blue); color: #fff; }
  .seg.work { box-shadow: inset 0 0 0 1px rgb(0 0 0 / .06); }
  .seg.work.ext, .seg.ext.work { background: var(--ext); color: #fff; }
  .seg.break { background: repeating-linear-gradient(135deg, var(--line) 0 3px, var(--bg) 3px 6px); color: var(--ink); border: 1px solid var(--muted); }
  .seg.break.auto { border-style: dashed; }
  .seg.plan { background: var(--soft); border: 1px dotted var(--ink); color: var(--ink); }
  .seg.out { background: transparent; border: 1.5px dashed var(--muted); color: var(--muted); }
  .seg.absent { background: repeating-linear-gradient(135deg, var(--redbg) 0 4px, var(--bg) 4px 8px); border: 1px solid var(--red); color: var(--red); font-weight: 700; }
  .seg.unassigned { background: var(--amberbg); border: 1px solid var(--amber); }
  .tag { font-style: normal; font-size: 10px; font-weight: 800; padding: 1px 4px; border-radius: 3px; background: var(--soft); color: var(--muted); }
  .tag.ext { background: var(--ext); color: #fff; }
  .tag.q { background: var(--navy); color: #fff; }
  i.now { position: absolute; top: 0; bottom: 0; left: calc(var(--namew) + (100% - var(--namew)) * var(--x) / 100); width: 2px; background: var(--red); pointer-events: none; z-index: 3; }
  .legend { display: flex; flex-wrap: wrap; gap: 8px 16px; font-size: 13px; align-items: center; border-top: 1px solid var(--line); padding-top: 10px; }
  .legend span { display: flex; align-items: center; gap: 6px; }
  .legend i { display: inline-block; width: 22px; height: 14px; min-height: 0; position: static; border-radius: 3px; }

  /* Fråga Kollen */
  button.kollen { font-weight: 600; }
  button.kollen .kn { display: inline-grid; place-items: center; min-width: 22px; height: 22px; padding: 0 6px; margin-left: 4px; border-radius: 99px; background: rgb(255 255 255 / .22); font-size: 12px; }
  .sugs p.better { color: var(--green); font-weight: 500; }
  .alert.fixrow { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
  .alert.fixrow button { flex: none; }
  .fixbtns { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
  .rulelink { font-size: 12px; color: var(--muted) !important; margin-left: 4px !important; font-weight: 400 !important; }

  /* day plan */
  .plancard {
    border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; margin-bottom: 12px; background: var(--page); display: grid; gap: 8px;
    &.mine { border-color: var(--blue); box-shadow: 0 0 0 1px var(--blue); background: var(--bg); }
    & p { margin: 0; }
  }
  .planhead { display: flex; align-items: center; gap: 8px; justify-content: space-between; }
  .facts {
    /* columns wrap instead of overlapping when labels are long (Swedish) or the card is narrow */
    display: grid; grid-template-columns: repeat(auto-fit, minmax(min(7rem, 100%), 1fr)); gap: 8px 12px; margin: 0; min-width: 0;
    & > div { min-width: 0; }
    & dt { font-size: 11px; color: var(--muted); }
    & dd { margin: 0; font-size: 18px; font-weight: var(--weight-bold); font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
    & small { font-size: 11px; font-weight: var(--weight-regular); color: var(--muted); white-space: nowrap; }
    & .res { grid-column: 1 / -1; padding: 6px 10px; border-radius: 8px; }
    & .res dd { font-size: 22px; }
    & .res.ok { background: var(--greenbg); & dd { color: var(--green); } }
    & .res.bad { background: var(--redbg); & dd { color: var(--red); } }
  }
  .plancols { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(220px, 100%), 1fr)); gap: 10px; & > * { min-width: 0; } }
  /* the three plan cards share one grid (subgrid), so every row lines up across them:
     head, help, figures, notes, button, "show steps", steps */
  .plancard { grid-row: span 7; grid-template-rows: subgrid; margin-bottom: 0; align-items: start; }
  .plancard .planhead { align-self: center; }
  .plancard .puse { min-height: 48px; font-size: 16px; width: 100%; align-self: end; }
  /* .mine is also used by another panel further down; keep the school-choice card the same size as the others */
  .plancard.mine { padding: 10px 12px; gap: 8px; }
  .pnotes { display: grid; gap: 4px; & p { margin: 0; } }
  .plancard .kshow { justify-self: start; font-weight: var(--weight-medium); }
  .ksteps { border-top: 1px solid var(--line); padding-top: 8px; }
  .ksteps > li { font-size: 14px; }
  .ksteps p { font-weight: 500; }
  .kundo button { white-space: nowrap; flex: none; }
  /* phone: one column, the school's own plan first */
  @media (max-width: 700px) { .plancard.mine { order: -1; } }
  .segline {
    display: flex; flex-wrap: wrap; gap: 4px 6px; align-items: center; font-size: 13px;
    & span { display: inline-flex; align-items: center; gap: 4px; }
    & .dot { width: 8px; height: 8px; }
    & b { color: var(--muted); font-weight: var(--weight-regular); }
  }

  /* undo toast */
  .toast {
    position: fixed; z-index: 35; left: calc(50% + var(--sbw) / 2); bottom: 20px; transform: translateX(-50%);
    display: flex; align-items: center; gap: 10px; max-width: min(640px, calc(100vw - var(--sbw) - 32px));
    background: var(--navy-deep); color: #e8edf2; padding: 8px 8px 8px 16px; border-radius: 12px; box-shadow: 0 12px 30px -8px rgb(13 35 64 / .5);
  }
  .toast span { flex: 1; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .toast button.small { background: var(--blue); border-color: var(--blue); color: #fff; font-weight: 600; }
  .toast button.x { background: transparent; border-color: transparent; color: rgb(255 255 255 / .6); }
  .changes button.undo { flex: none; }

  /* modal */
  .scrim { position: fixed; inset: 0; background: rgb(13 35 64 / .45); z-index: 40; }
  .modal {
    position: fixed; z-index: 41; left: 50%; top: 50%; transform: translate(-50%, -50%); width: min(560px, calc(100vw - 24px));
    max-height: calc(100vh - 40px); overflow: auto; background: var(--bg); border-radius: 14px; padding: 20px 22px; border: 1px solid var(--line);
    box-shadow: 0 20px 50px -10px rgb(13 35 64 / .35);
  }
  .modal form, .modal > div { display: grid; gap: 12px; }
  .modal label:not(.check):not(.mini-chk) { display: grid; gap: 4px; font-size: 13px; font-weight: 500; color: var(--muted); }
  .modal label.check { display: flex; gap: 8px; align-items: center; }
  .mbtns { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; margin-top: 6px; }
  .preview { background: var(--soft); border-radius: 8px; padding: 10px 12px; }
  .preview h4 { margin: 0 0 6px; }
  .row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
  .row3 { display: grid; grid-template-columns: 1fr 1fr auto; gap: 10px; align-items: end; }
  .seg2 { display: flex; gap: 16px; flex-wrap: wrap; }
  .seg2 label { display: flex !important; gap: 8px; align-items: center; font-weight: 500; }
  .pactions { display: flex; flex-wrap: wrap; gap: 8px; }
  .segs li { display: flex; gap: 10px; font-size: 15px; padding-left: 10px; border-left: 4px solid var(--line); }
  .segs li.k-absent { border-left-color: var(--red); }
  .segs li.k-break, .segs li.k-plan { border-left-color: var(--muted); }
  .segs li.k-work { border-left-color: var(--green); }
  form.inline { display: flex !important; gap: 8px; align-items: end; flex-wrap: wrap; }
  form.inline input, form.inline select { width: auto; }
  .explain .pill { justify-self: start; }

  /* setup pages */
  .pagehead { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; justify-content: space-between; margin-bottom: 16px; }
  .pagehead h1 { margin-right: auto; }
  .cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 460px), 1fr)); gap: 18px; align-items: start; }
  .cols > div { display: grid; gap: 18px; }
  .card { background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px 18px; display: grid; gap: 12px; }
  .card h3 { display: flex; align-items: center; gap: 8px; }
  .setbody { display: grid; gap: 18px; max-width: 820px; }
  .f { display: grid; gap: 4px; font-size: 13px; font-weight: 500; }
  .f > span { display: grid; gap: 1px; }
  .f small { font-weight: 400; color: var(--muted); }
  .f.check { display: grid; grid-template-columns: 26px 1fr; align-items: start; gap: 8px; }
  .f.warn input { border-color: var(--red); }
  .warnmsg { font-style: normal; font-size: 12px; color: var(--red); font-weight: 700; }
  .ratios { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px; }
  .tabs { display: flex; gap: 4px; overflow-x: auto; margin-bottom: 14px; padding: 4px; background: var(--soft); border: 1px solid var(--line); border-radius: 12px; width: fit-content; max-width: 100%; }
  .tabs.wrap { flex-wrap: wrap; overflow: visible; }
  .tabs button { flex: none; border: 1px solid transparent; background: transparent; box-shadow: none; border-radius: 8px; white-space: nowrap; min-height: 34px; padding: 4px 14px; color: var(--muted); }
  .tabs button:hover { background: var(--line); color: var(--ink); box-shadow: none; }
  .tabs button.on { background: var(--bg); color: var(--ink); border-color: var(--line); box-shadow: var(--shadow); font-weight: 600; transform: none; }
  .tabs.small button { min-height: 36px; padding: 4px 10px; font-size: 14px; }
  .switch { display: flex; gap: 8px; align-items: center; font-weight: 500; }
  .steps { border-collapse: collapse; width: 100%; }
  .steps th, .steps td { padding: 4px 6px 4px 0; text-align: left; font-size: 14px; vertical-align: middle; }
  .steps thead th { font-weight: 500; color: var(--muted); font-size: 13px; }
  .steps input[type=time] { width: 132px; }
  .steps input[type=number] { width: 80px; }
  .steps select { min-width: 8.5em; }
  .sched td:first-child { white-space: nowrap; }
  /* Time boxes fill their cell but never shrink below their content, so neighbours cannot overlap. */
  table.gridrows input[type=time] { width: 100%; min-width: 7.25rem; max-width: 132px; }
  /* Same column widths in every group card, so the rows line up down the page. */
  .sched table.gridrows { table-layout: fixed; }
  .sched table.gridrows th:first-child { width: 9rem; }
  .sched table.gridrows th:not(:first-child):not(.gcol):not(:last-child) { width: 8.6rem; }
  .sched table.gridrows th:last-child { width: 48px; }
  .sched table.gridrows th.gcol { width: auto; min-width: 0; }
  .sched table.gridrows td:first-child { overflow: hidden; text-overflow: ellipsis; }
  /* Breaks: one compact button per person, however many breaks the school has. */
  .brkbtn { display: grid; justify-items: start; gap: 0; width: 100%; min-width: 7.25rem; max-width: 150px; min-height: 40px; padding: 3px 10px; text-align: left; line-height: 1.2; font-size: 14px; }
  .brkbtn span { font-size: 12px; color: var(--muted); font-weight: 400; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
  .brklist { list-style: none; margin: 0; padding: 0; display: grid; gap: 0; }
  .brklist li { display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: center; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid var(--line); }
  .brklist li:last-child { border-bottom: 0; }
  .brklist li.off { opacity: .6; }
  .brklist li > div { display: grid; gap: 2px; min-width: 0; flex: 1 1 14rem; }
  .brklist .pin { display: flex; gap: 6px; align-items: center; }
  .brklist .pin input { width: 132px; }
  .brklist .pin .small, .brklist .autotag { min-width: 6rem; text-align: center; }
  .brklist li:has(.brkctl) { display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; }
  .brklist .brkctl { display: grid; grid-template-columns: 236px 8.5rem; gap: 6px; align-items: center; }
  .brklist .brkctl .onoff { width: 100%; }
  .brklist li.off { opacity: 1; }
  .brklist li.off > div { opacity: .6; }
  .brklist .xname { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
  .brklist .xname input[type=text] { flex: 1 1 8rem; min-width: 0; }
  .brklist .xname select { width: auto; }
  .brklist .xname em { flex-basis: 100%; }
  @media (max-width: 640px) {
    .brklist .brkctl { grid-template-columns: minmax(0, 1fr) 7.5rem; }
    .brklist .brkctl .pin input { width: 118px; }
  }
  .brkbtn.changed { border-color: var(--blue); }
  form.pbrk { display: grid; gap: 8px; justify-items: start; margin-top: 8px; }
  form.pbrk .brklist { width: 100%; }
  .sched + .sched { margin-top: 14px; }
  .navi .ns { display: none; }

  /* Wide setup tables become a wrapping grid of labelled fields when their space is narrow
     (small laptop window, tablet, phone), so no column is cut off or squeezed. */
  .scroll:has(> :is(table.gridrows, table.gridrows-sm)) { container: tbl / inline-size; }
  /* Laptop: one line per person, the little day chart is dropped first; only narrow screens stack into labelled rows. */
  @container tbl (max-width: 1100px) { table.gridrows .gcol { display: none; } }
  @container tbl (max-width: 700px) {
    table.gridrows thead { display: none; }
    table.gridrows tbody { display: grid; gap: 10px; }
    table.gridrows tr { display: grid; grid-template-columns: repeat(auto-fill, minmax(8.6rem, 1fr)); gap: 6px 8px; align-items: end; padding-bottom: 10px; border-bottom: 1px solid var(--line); }
    table.gridrows tr:last-child { border-bottom: 0; }
    table.gridrows th, table.gridrows td { padding: 0; }
    table.gridrows [data-l]::before { content: attr(data-l); display: block; font-size: 12px; font-weight: 400; color: var(--muted); margin-bottom: 2px; }
    table.gridrows input[type=time], table.gridrows select, table.gridrows .brkbtn { width: 100%; min-width: 0; max-width: none; }
    table.gridrows .gcol { display: none; }
    table.gridrows td.wide { grid-column: 1 / -1; }
    table.gridrows tr > :first-child { grid-column: 1 / -2; align-self: center; }
    table.gridrows .endcell { grid-column: -2 / -1; grid-row: 1; justify-self: end; align-self: center; }
  }
  @container tbl (max-width: 560px) {
    table.gridrows-sm thead { display: none; }
    table.gridrows-sm tbody { display: grid; gap: 10px; }
    table.gridrows-sm tr { display: grid; grid-template-columns: repeat(auto-fill, minmax(7.5rem, 1fr)); gap: 6px 8px; align-items: end; padding-bottom: 10px; border-bottom: 1px solid var(--line); }
    table.gridrows-sm tr:last-child { border-bottom: 0; }
    table.gridrows-sm th, table.gridrows-sm td { padding: 0; }
    table.gridrows-sm [data-l]::before { content: attr(data-l); display: block; font-size: 12px; font-weight: 400; color: var(--muted); margin-bottom: 2px; }
    table.gridrows-sm input { width: 100%; min-width: 0; max-width: none; }
    table.gridrows-sm input[type=checkbox] { width: 20px; }
    table.gridrows-sm tr > :first-child { grid-column: 1 / -2; align-self: center; }
    table.gridrows-sm .endcell { grid-column: -2 / -1; grid-row: 1; justify-self: end; align-self: center; }
    table.gridrows-sm .endcell::before { display: none !important; }
  }
  .steps td.days { display: flex; flex-wrap: wrap; gap: 4px; }
  .shifts tr.offrow th { color: var(--muted); }
  .xy { display: inline-flex; gap: 4px; align-items: center; margin-top: 4px; }
  .xy input { width: 64px !important; }
  .mini-chk { display: inline-flex; gap: 4px; align-items: center; font-size: 13px; padding: 4px 8px; border: 1px solid var(--line); border-radius: 99px; background: var(--bg); }
  .chips { display: flex; flex-wrap: wrap; gap: 6px; }
  .btnrow { display: flex; flex-wrap: wrap; gap: 8px; }
  .mini { display: flex; align-items: flex-end; gap: 2px; height: 56px; border-bottom: 1px solid var(--line); }
  .mini i { flex: 1; background: var(--navy); opacity: .8; border-radius: 2px 2px 0 0; min-height: 1px; }
  .rblock { border-top: 1px solid var(--line); padding-top: 10px; display: grid; gap: 8px; }
  .rblock.custom { border-left: 4px solid var(--blue); padding-left: 10px; }
  .rhead { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
  .rhead h4 { margin: 0; margin-right: auto; }
  .badge { font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 99px; }
  .badge.i { background: var(--soft); color: var(--muted); }
  .badge.c { background: var(--blue); color: #fff; }
  .inherited { color: var(--muted); font-size: 14px; margin: 0; }
  .glist { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr)); gap: 14px; }
  .gitem { background: var(--bg); border: 1px solid var(--line); border-top: 5px solid var(--gc); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px; display: grid; gap: 6px; align-content: start; justify-items: start; }
  .gitem header { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
  .empty { padding: 30px; background: var(--bg); border: 1.5px dashed var(--line); border-radius: var(--radius); text-align: center; color: var(--muted); }
  .search { max-width: 360px; margin-bottom: 10px; }
  .list { border-collapse: separate; border-spacing: 0; width: 100%; background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
  .list th, .list td { padding: 10px 8px; border-bottom: 1px solid var(--line); text-align: left; }
  .list th { font-size: 12px; color: var(--muted); font-weight: 500; background: var(--soft); }
  .list tr:last-child td { border-bottom: 0; }
  .list tr.click { cursor: pointer; }
  .list tr.click:hover { background: var(--soft); }
  .num { text-align: right !important; font-variant-numeric: tabular-nums; white-space: nowrap; }
  .addrow { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: space-between; border-top: 1px solid var(--line); padding-top: 10px; }
  .addrow form.inline select { max-width: 220px; }
  .sched h3 .muted { font-weight: 400; font-size: 14px; }
  .gcol { width: 38%; min-width: 220px; }
  .gantt { position: relative; height: 22px; background: var(--soft); border-radius: 6px; }
  .gantt .seg { --gc: inherit; }
  .sched .seg.work { background: var(--gc); }
  .ghours { position: relative; height: 16px; }
  .ghours span { position: absolute; font-size: 11px; transform: translateX(-50%); }
  td.nowrap input { width: 128px !important; display: inline-block; margin-right: 4px; }

  /* first-run guide */
  .wizard { max-width: 860px; }
  .wzsteps { list-style: none; padding: 0; margin: 14px 0; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6px; counter-reset: none; }
  .wzsteps button {
    width: 100%; display: flex; align-items: center; gap: 8px; justify-content: flex-start; padding: 6px 10px; font-size: 14px; box-shadow: none; background: var(--bg);
    & i { font-style: normal; display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; background: var(--soft); font-size: 12px; font-weight: 700; flex: none; }
    & span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  }
  .wzsteps li.done button i { background: var(--greenbg); color: var(--green); }
  .wzsteps li.on button { border-color: var(--blue); box-shadow: 0 0 0 1px var(--blue); font-weight: var(--weight-semibold); }
  .wzsteps li.on button i { background: var(--blue); color: #fff; }
  .wzcard { gap: 14px; }
  .wzfoot { display: flex; gap: 8px; align-items: center; justify-content: space-between; border-top: 1px solid var(--line); padding-top: 12px; margin-top: 4px; }
  .wzfoot .ghost { margin-left: auto; }
  .wz-table input[type=number] { width: 90px; }
  .wz-table select { width: auto; min-width: 70px; }
  .setuphead { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
  .wzlink { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 0 0 14px; }

  /* leadership page (Ledning) */
  .lnow { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px 20px; margin-bottom: 8px; }
  .lnow h2 { font-size: 19px; }
  .lnow .kcta { flex: none; }
  .lnow .ahead { grid-column: 1 / -1; display: grid; gap: 6px; }
  .ahead ul { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
  .aday { width: 100%; display: grid; gap: 2px; text-align: left; justify-items: start; padding: 8px 10px; min-height: 0; font-weight: 400; }
  .aday.short { border-left: 4px solid var(--red); }
  .aday.ok { border-left: 4px solid var(--green); }
  .lperiod { margin: 6px 0 10px; }
  /* planning time the law requires (from 1 July 2027) */
  .llaw { display: grid; gap: 8px; margin-bottom: 14px; border-left: 4px solid var(--line); }
  .llaw.ok { border-left-color: var(--green); }
  .llaw.warn { border-left-color: var(--amber); }
  .llaw.bad { border-left-color: var(--red); }
  .llaw .lawhead { display: grid; gap: 2px; }
  .llaw h3 { margin: 0; font-size: 13px; font-weight: 600; color: var(--muted); }
  .llaw .lawmain { margin: 0; font-size: 18px; font-weight: 650; }
  .llaw .btnrow { margin: 0; }
  .lawrows { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
  .lawrows li { display: grid; grid-template-columns: minmax(120px, 200px) 1fr; gap: 12px; padding: 6px 0; border-top: 1px solid var(--line); font-size: 14px; }
  .lawwarn { margin: 0; padding: 8px 10px; border-radius: var(--radius); background: var(--amberbg); color: var(--ambertext); }
  .lawset .row2 { margin: 6px 0 10px; align-items: end; }
  .lawrep td:first-child { white-space: nowrap; }
  .lawrep tr.total td { border-top: 2px solid var(--line); }
  .lcards { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin: 0 0 14px; }
  .lcard { background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 12px 14px; display: grid; gap: 2px; align-content: start; }
  .lcard dt { font-size: 13px; font-weight: 600; color: var(--ink); }
  .lcard dd { margin: 0; font-size: clamp(22px, 2.6vw, 28px); font-weight: 650; font-variant-numeric: tabular-nums; white-space: nowrap; }
  .lcard p { margin: 0; }
  .lcard dd.lx { font-size: inherit; font-weight: inherit; white-space: normal; display: grid; gap: 2px; }
  .lcard .link { justify-self: start; padding: 0; }
  .trend { font-size: 12px; font-weight: 500; color: var(--muted); }
  .trend.good { color: var(--green); }
  .trend.bad { color: var(--red); }
  .lgrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr)); gap: 14px; margin-bottom: 14px; }
  .lgrid > .card { margin: 0; }
  .heat { border-collapse: separate; border-spacing: 3px; width: 100%; }
  .heat th { font-size: 11px; font-weight: 500; color: var(--muted); text-align: left; padding: 0 2px; white-space: nowrap; }
  .heat td { height: 26px; min-width: 18px; border-radius: 4px; background: color-mix(in srgb, var(--red) calc(var(--a, 0) * 85%), var(--soft)); }
  .sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .mixbar { display: flex; height: 26px; border-radius: 6px; overflow: hidden; border: 1px solid var(--line); }
  .mixbar span { min-width: 3px; }
  .m-moves { background: var(--blue); }
  .m-plan { background: var(--amber); }
  .m-ext { background: var(--ext); }
  .m-short { background: var(--red); }
  .mixkey { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
  .mixkey li { display: grid; grid-template-columns: 12px minmax(0, 1fr) auto 3.5em; gap: 8px; align-items: center; font-size: 14px; }
  .mixkey i { width: 12px; height: 12px; border-radius: 3px; }
  .mixkey b, .mixkey .muted { text-align: right; font-variant-numeric: tabular-nums; }
  .lgroups .num, .lgroups th.num { text-align: right; font-variant-numeric: tabular-nums; }
  .lgroups td.bad, .lload .bad { color: var(--red); font-weight: 600; }
  .lfacts { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
  .lfacts li { display: flex; flex-wrap: wrap; gap: 2px 10px; align-items: baseline; padding-bottom: 8px; border-bottom: 1px solid var(--line); }
  .lfacts li > span:first-child { flex: 1 1 auto; }
  .lfacts li > .small { flex: 1 1 100%; }
  .lfacts b { font-variant-numeric: tabular-nums; }
  .btnrow.col { flex-direction: column; align-items: stretch; }
  .lnote { margin-top: 4px; }
  /* absence reasons: one-tap choice in the report dialogs, totals bars on Ledning */
  .catpick { border: 0; padding: 0; margin: 4px 0 0; min-width: 0; }
  .catpick legend { font-weight: 600; padding: 0; margin-bottom: 6px; }
  .catchips { display: flex; flex-wrap: wrap; gap: 6px; }
  .modal .catpick label.catchip { position: relative; display: inline-flex; align-items: center; min-height: 40px; padding: 6px 14px; border: 1px solid var(--line); border-radius: 99px; background: var(--bg); cursor: pointer; font-weight: 500; }
  .catchip input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
  .catchip:has(input:focus-visible) { outline: 2px solid var(--blue); outline-offset: 2px; }
  .modal .catpick label.catchip { color: var(--ink); font-size: 15px; }
  .modal .catpick label.catchip:has(input:checked), .modal .catpick label.catchip.on { background: var(--navy); border-color: var(--navy); color: #fff; }
  .catpick p { margin: 6px 0 0; }
  .absbars { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
  .absbars li { display: grid; grid-template-columns: minmax(7em, 16em) minmax(0, 1fr) 5.5em; gap: 10px; align-items: center; font-size: 14px; }
  .absbars i { display: block; height: 14px; width: var(--w); min-width: 3px; border-radius: 4px; background: var(--navy); opacity: .75; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .absbars b { text-align: right; font-variant-numeric: tabular-nums; }
  @media (max-width: 640px) { .absbars li { grid-template-columns: minmax(0, 1fr) auto; gap: 4px 10px; } .absbars i { grid-column: 1 / -1; grid-row: 2; } }
  .abscats td:first-child { width: 4.5em; text-align: center; }

  @media print {
    body:has(.lawrep) .shell, body:has(.lawrep) .scrim, .lawrep .mbtns { display: none !important; }
    body:has(.lawrep) .modal { position: static; transform: none; max-height: none; width: auto; box-shadow: none; }
    .sidebar, .top, .bottomnav, .toast, .lnow .kcta, .lnow .ahead, .lrep, .pagehead .tabs button:not(.on), .mbuild { display: none !important; }
    .shell { display: block; }
    .main { padding: 0; }
    .card, .lcard, .summary { box-shadow: none; break-inside: avoid; }
    .heat td { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
    .mixbar span, .mixkey i { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
    /* the day prints as a clean plan: no buttons, no note box when empty */
    .dayactions, .kcta, .datebar button, .datebar input, .panels button, .panels textarea:placeholder-shown, details.rules, .legend .small { display: none !important; }
    .seg, .cell, .ovbar i, .legend i, .tag, .pill { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
    .gcard, .panel { break-inside: avoid; box-shadow: none; }
    .panel:has(textarea:placeholder-shown), .legend .small { display: none !important; }
    .tlscroll { overflow: visible !important; }
  }
  @page { size: A4 landscape; margin: 10mm; }

  /* phone */

  /* the overview follows the space it has (container query), not the window */
  @container main (max-width: 640px) {
    .ovrow { grid-template-columns: minmax(0, 1fr) auto; }
    .ovrow .ovtrack, .ovrow .ovhours { grid-column: 1 / -1; grid-row: 2; }
    .ovfoot { justify-content: flex-start; }
      .ovaxis .ovname { display: none; }
    .ovaxis .ovstat { display: none; }
  }

  @media (max-width: 760px) {
    :root { --namew: 104px; --cw: 26px; }
    .shell { grid-template-columns: minmax(0, 1fr); }
    .sidebar { display: none; }
    .mbuild { display: block; }
    .toast { left: 50%; bottom: calc(70px + env(safe-area-inset-bottom)); max-width: calc(100vw - 20px); width: max-content; }
    .top {
      display: flex; position: sticky; top: 0; z-index: 20; align-items: center; gap: 10px; padding: 8px 12px;
      background: var(--navy-deep); color: #e8edf2;
    }
    .toplogo { height: 26px; width: auto; flex: none; }
    .brand { display: grid; line-height: 1.15; margin-right: auto; }
    .brand b { font-size: 13px; font-weight: 600; }
    .brand span { font-size: 11px; color: rgb(255 255 255 / .45); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
    .tools { display: flex; align-items: center; gap: 6px; flex: none; }
    .brand { min-width: 0; }
    .brand b { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; }
    .top .as span { display: none; }
    .top .as select { min-height: 32px; width: auto; max-width: 96px; padding-inline: 6px; }
    .top .langseg { padding: 3px; }
    .top .langseg button { min-height: 28px; padding: 0 8px; }
    .bottomnav {
      display: flex; position: fixed; bottom: 0; left: 0; right: 0; z-index: 30; background: var(--navy-deep); gap: 4px;
      padding: 6px 6px calc(6px + env(safe-area-inset-bottom)); justify-content: space-around;
    }
    .bottomnav .navi {
      padding: 10px 1px; font-size: 11px; letter-spacing: -0.01em; flex: 1 1 0; text-align: center; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
      text-decoration: none; border-radius: 10px; color: rgb(255 255 255 / .6);
    }
    .bottomnav .navi .nl:has(+ .ns) { display: none; }
    .bottomnav .navi .ns { display: inline; }
    .bottomnav .navi.on { background: rgb(255 255 255 / .15); color: #fff; font-weight: 500; }
    .datebar { flex-wrap: nowrap; }
    .datepick { flex-direction: column; align-items: stretch; gap: 2px; font-size: 15px; flex: 1; }
    .datepick input { width: 100%; }
    .rulecard { font-size: 13px; }
    .main { padding: 12px 12px 90px; }
    .stats { gap: 4px 18px; }
    .dayactions button { flex: 1 1 45%; }
    .kcta { flex: 1 1 100%; }
    .tabs, .tabs.wrap { flex-wrap: wrap; overflow: visible; width: 100%; }
    .tabs button { flex: 1 1 auto; padding-inline: 10px; }
    .steps input[type=time] { width: 100%; min-width: 0; }
    .steps th, .steps td { padding-right: 4px; }
    .wzfoot { flex-wrap: wrap; }
    .wzfoot .ghost { order: 3; flex: 1 1 100%; margin: 0; }
    .wzsteps button { flex-direction: column; gap: 2px; padding: 6px 2px; font-size: 11px; justify-content: center; }
    .wzsteps button span { max-width: 100%; }
    .wz-table:not(.stack) thead { display: none; }
    .wz-table:not(.stack) tr { display: grid; grid-template-columns: 1fr 1fr 1fr auto; gap: 6px; padding: 8px 0; border-bottom: 1px solid var(--line); }
    .wz-table:not(.stack) td:first-child { grid-column: 1 / -1; }
    .wz-table:not(.stack) td { padding: 0; }
    .wz-table:not(.stack) td[data-l]::before { content: attr(data-l); display: block; font-size: 12px; color: var(--muted); }
    .wz-table:not(.stack) td:first-child::before { display: none; }
    .wz-table:not(.stack) input[type=number], .wz-table select { width: 100%; }
    .wz-table.stack td { padding-inline-start: 6.5em; }
    .wz-table.stack td::before { width: 6em; margin-inline-start: -6.5em; }
    .wz-table.stack td input, .wz-table.stack td select { width: 100%; }
    .modal { top: auto; bottom: 0; transform: translateX(-50%); border-radius: 16px 16px 0 0; max-height: 88vh; width: 100vw; }
    .row2 { grid-template-columns: 1fr; }
    .gcol { display: none; }
    .stack thead { display: none; }
    .stack tr { display: grid; padding-block: 10px; border-bottom: 1px solid var(--line); }
    .stack td { display: flow-root; border: 0; padding: 2px 0; padding-inline-start: 7.5em; text-align: start !important; }
    .stack td::before { content: attr(data-l); float: inline-start; width: 7em; margin-inline-start: -7.5em; color: var(--muted); font-size: 13px; }
    .lgroups.stack td { padding-inline-start: 11em; }
    .lgroups.stack td::before { width: 10.5em; margin-inline-start: -11em; }
    .stack td:empty { display: none; }
  }
}

/* Staff phone view ("Min dag"), simulated until real login. Phone-first; on a laptop it sits in a phone-sized column. */
@layer views {
  .simbar {
    display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px;
    padding: 8px clamp(12px, 3vw, 24px); background: var(--amberbg); border-bottom: 1px solid #f6dfa0; color: var(--ambertext); font-size: 13px;
    & .simtxt { flex: 1 1 260px; min-width: 0; }
    & .simtxt b { margin-right: 4px; }
    & .simwho select { min-height: 32px; padding: 3px 8px; font-size: 13px; width: auto; max-width: 180px; }
    & button.small { white-space: nowrap; }
  }
  .phone { max-width: 440px; margin: 0 auto; background: var(--page); min-height: calc(100vh - 50px); display: flex; flex-direction: column; }
  @media (min-width: 761px) {
    .phone { margin: 24px auto 40px; min-height: 0; border: 1px solid var(--line); border-radius: 28px; box-shadow: var(--shadow-up); overflow: hidden; background: var(--page); }
  }
  .mine { padding: 16px 16px 8px; display: grid; gap: 14px; flex: 1; align-content: start; }
  .mhead { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-width: 0; }
  .mhead img { height: 28px; width: auto; flex: none; }
  .mhead span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .gvwho { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: -6px 0 0; min-width: 0; }
  .gvwho span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .mhello { font-size: 26px; margin-top: 4px; }
  .mdate { margin: -10px 0 0; }
  .mchips { display: flex; gap: 6px; overflow-x: auto; padding: 2px 2px 6px; margin-inline: -2px; scrollbar-width: none; }
  .mchip {
    flex: 1 1 0; min-width: 44px; min-height: 66px; padding: 6px 2px; display: grid; justify-items: center; align-content: center; gap: 0; line-height: 1.15;
    & span { font-size: 12px; color: var(--muted); font-weight: var(--weight-medium); }
    & b { font-size: 18px; font-variant-numeric: tabular-nums; }
    & small { font-size: 10px; min-height: 12px; color: var(--muted); }
    &.abs small { color: var(--red); font-weight: var(--weight-semibold); }
    &.off b { color: var(--muted); }
    &.on { background: var(--navy); border-color: var(--navy); color: #fff; }
    &.on span, &.on small, &.on b { color: #fff; }
  }
  .mcard {
    background: var(--bg); border: 1px solid var(--line); border-left: 5px solid var(--blue); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 16px;
    & h2 { font-size: 19px; }
    &.abs { border-left-color: var(--red); background: var(--redbg); border-color: #f5c2c9; }
  }
  .mlabel { margin: 0; font-size: 13px; color: var(--muted); }
  .mbig { font-size: 30px; font-variant-numeric: tabular-nums; letter-spacing: -0.01em; margin: 2px 0 4px; }
  .mhome { display: flex; align-items: center; gap: 8px; margin: 0; font-weight: var(--weight-semibold); }
  .mnote { margin: 8px 0 0; font-size: 13px; color: var(--ambertext); }
  .msec { display: grid; gap: 8px; }
  .msec h3 { font-size: 15px; }
  .gdot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: #9aa3af; flex: none; }
  .gdot.brk { background: var(--calm-sand); outline: 1px solid #cbbfae; }
  .gdot.plan { background: #bfd6fb; outline: 1px solid #8fb6f5; }
  .gdot.abs { background: var(--red); }
  .mrows, .mabs { list-style: none; margin: 0; padding: 0; background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
  .mrow {
    display: grid; grid-template-columns: 7.2em minmax(0, 1fr); gap: 10px; align-items: center; padding: 10px 14px; border-top: 1px solid var(--line);
    &:first-child { border-top: 0; }
    &.break, &.plan { color: var(--muted); }
    &.absent { background: var(--redbg); }
    &.now { background: #eef4fe; box-shadow: inset 4px 0 0 var(--blue); }
  }
  .mtime { font-variant-numeric: tabular-nums; font-weight: var(--weight-semibold); white-space: nowrap; }
  .mwhat { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 8px; min-width: 0; }
  .mtag { font-style: normal; font-size: 11px; font-weight: var(--weight-semibold); padding: 1px 8px; border-radius: var(--radius-pill); background: var(--amberbg); color: var(--ambertext); white-space: nowrap; }
  .mtag.now { background: var(--blue); color: #fff; }
  .mabs li {
    display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 14px; border-top: 1px solid var(--line);
    &:first-child { border-top: 0; }
    & > span { display: grid; gap: 2px; min-width: 0; }
    & b::first-letter { text-transform: uppercase; }
    & small { font-size: 12px; }
  }
  .mreport { display: grid; gap: 6px; margin-top: 4px; }
  .mreport p { margin: 0; text-align: center; }
  button.mbtn { min-height: 52px; font-size: 17px; width: 100%; }
  .mdone {
    display: grid; gap: 8px; padding: 12px 14px; border-radius: var(--radius); background: var(--greenbg); border: 1px solid #a7e3bb; border-left: 5px solid var(--green);
    & p { margin: 0; }
    & button.primary { width: 100%; min-height: 46px; }
    & button.ghost { justify-self: center; }
  }
  .mfoot { display: flex; align-items: center; justify-content: center; gap: 12px; padding: 12px 16px 18px; flex-wrap: wrap; }
  .mfoot .build, .mfoot .savestate { color: var(--muted); padding: 0; }
  .langseg.light { background: var(--soft); }
  .langseg.light button { color: var(--muted); }
  .langseg.light button:hover { background: var(--line); }
  .langseg.light button.on { background: var(--bg); color: var(--ink); border-color: var(--line); box-shadow: var(--shadow); }
  .mform .mapplies { margin: 0; font-size: 14px; }
  .merr { margin: 0; color: var(--red); font-weight: var(--weight-semibold); }
  .selftag { font-style: normal; font-size: 11px; padding: 1px 7px; border-radius: var(--radius-pill); background: var(--soft); color: var(--muted); margin-left: 4px; white-space: nowrap; }
}
/* Rektor second sign-in step: the authenticator QR code (js/app-auth.js) */
.mfaqr svg { display: block; width: 200px; height: 200px; margin: 4px 0 0; }
.mfasteps { margin: 0; padding-left: 1.3em; display: grid; gap: 6px; text-align: left; }
.mfasteps .mfaapp { display: block; margin-top: 4px; }
.welcome .wacts { margin-top: 4px; }
.mfaopen { display: none; align-items: center; justify-content: center; min-height: 48px; padding: 10px 18px; border-radius: 12px; background: var(--blue); color: #fff; font-weight: 600; text-decoration: none; }
@media (pointer: coarse) { .mfaopen { display: inline-flex; } }
.mfakey { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.mfakey code { font-size: 15px; letter-spacing: .04em; white-space: nowrap; padding: 6px 10px; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
