/*
 * Shell: navigation on the left, status bar on top, stage in between.
 *
 * Contains no numeric values with design meaning -- everything comes from
 * tokens.css. The only exceptions are values without design character
 * (0, 100%, 1fr, auto, 50%).
 */

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

html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: var(--text-md);
  line-height: var(--leading-normal);
  color: var(--fg);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  /* Numbers in tables should line up. */
  font-variant-numeric: tabular-nums;
}

h1, h2, h3, p, ul, ol { margin: 0; }
ul, ol { padding: 0; list-style: none; }

button, input, select, textarea { font: inherit; color: inherit; }

a { color: var(--accent); }

/* Visible focus throughout, not only where it happens to stand out. */
:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
  border-radius: var(--radius-sm);
}

[hidden] { display: none !important; }

.icon-sprite { display: none; }

/* --- Brand ----------------------------------------------------------- */
.brand {
  font-size: var(--text-lg);
  font-weight: var(--weight-bold);
  letter-spacing: var(--tracking-tight);
  /* The one place the accent appears without meaning anything: the product name.
     accent-strong rather than accent -- at 16px bold on the light sidebar the
     lighter one lands at 4.25:1, just under what body-sized text needs. */
  color: var(--accent-strong);
}
.tag {
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wide);
  color: var(--fg-on-sidebar-muted);
}

/* --- Splash ---------------------------------------------------------- */
/* Prevents the sign-in screen from flashing up on reload while already
   signed in. */
.splash {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: var(--bg);
  z-index: 50;
}
.splash__inner { text-align: center; }
.splash__text {
  margin-top: var(--space-3);
  color: var(--fg-muted);
  font-size: var(--text-sm);
}

/* --- Sign-in --------------------------------------------------------- */
.login-screen {
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: var(--space-6);
}
.login-card {
  width: 100%;
  max-width: 22rem;
  display: grid;
  gap: var(--space-4);
}
.login-card__subtitle {
  margin-top: calc(var(--space-1) * -1);
  color: var(--fg-muted);
  font-size: var(--text-sm);
}
.login-card__footer {
  display: flex;
  gap: var(--space-2);
  justify-content: center;
  color: var(--fg-subtle);
  font-size: var(--text-xs);
}
/* What a card of the sign-in is for, where it is not the sign-in itself
   (1.9.0): asking for a link, setting a new password. The sign-in has no title
   -- nothing there says what this is before somebody is in. */
.login-card__title {
  font-size: var(--text-lg);
  font-weight: var(--weight-bold);
  margin: 0;
}
/* A way to another card: looks like a link, is a button -- it leads nowhere
   one could bookmark. */
.link {
  border: 0;
  padding: 0;
  background: none;
  color: var(--accent);
  font: inherit;
  cursor: pointer;
  text-decoration: underline;
}
.link:hover,
.link:focus-visible { color: var(--fg); }

/* --- Shell ----------------------------------------------------------- */
.shell {
  display: grid;
  grid-template-columns: var(--sidebar-width) 1fr;
  grid-template-rows: var(--statusbar-height) 1fr;
  grid-template-areas:
    "sidebar statusbar"
    "sidebar stage";
  height: 100%;
}

/* Folded: a rail, so the stage gets the width. The rail keeps every page as
   its icon -- clickable, named by its tooltip -- and the way back stays where
   the way in was: left of the name. */
.shell--folded { grid-template-columns: var(--sidebar-rail) 1fr; }
.shell--folded .sidebar__brand,
.shell--folded .nav__text,
.shell--folded .nav__chevron,
.shell--folded .sidebar__version,
.shell--folded .sidebar__user { display: none; }
.shell--folded .sidebar__head { justify-content: center; padding: 0; }
/* Every page shows, whether its group is open or folded: in a rail a folded
   group would hide the very icons the rail is there for. The reset's
   [hidden] is !important, so this has to be as well. */
.shell--folded .nav__group-items[hidden] { display: block !important; }
.shell--folded .nav__link,
.shell--folded .nav__group {
  justify-content: center;
  padding-left: 0;
  padding-right: 0;
}
/* The group head becomes a divider carrying the group's icon. */
.shell--folded .nav__group { opacity: 0.55; pointer-events: none; }
.shell--folded .sidebar__middle {
  padding-left: 0;
  padding-right: 0;
  /* No gutter on the rail: it is four rem of icons, and half a rem of
     reserved scrollbar there would push every one of them off centre. The
     rail scrolls with an overlay bar instead (0.73.0). */
  scrollbar-gutter: auto;
}
.shell--folded .sidebar__foot { padding-left: 0; padding-right: 0; }
.shell--folded .sidebar__actions { flex-direction: column; align-items: center; margin: 0; }
.sidebar__toggle { flex: 0 0 auto; }

/* The same two buttons, once they have been moved into the status bar on a
   narrow screen (sidebar.js): a row, not a column, and no margin of the foot
   they came from. */
.statusbar__actions {
  display: flex;
  flex-direction: row;
  gap: var(--space-1);
  margin: 0;
}
.statusbar__actions .icon-btn { color: var(--fg-muted); }
.statusbar__actions .icon-btn:hover { color: var(--fg); background: var(--surface-muted); }

/* --- Sidebar --------------------------------------------------------- */
.sidebar {
  grid-area: sidebar;
  display: grid;
  /* Head and foot fixed, only the middle scrolls. */
  grid-template-rows: auto 1fr auto;
  background: var(--surface-sidebar);
  color: var(--fg-on-sidebar);
  min-height: 0;
  /* In light mode the sidebar is a light surface next to a light stage, so it
     needs an edge of its own -- without it the two run into each other. */
  border-right: var(--border-width) solid var(--border);
}
.sidebar__head {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  height: var(--statusbar-height);
  padding: 0 var(--space-4);
  border-bottom: var(--border-width) solid var(--sidebar-border);
}
/* The scrolling part of the menu sits in a recess: a slightly darker ground and
   a shadow at each edge, so it reads as a panel one scrolls IN rather than as a
   part of the sidebar that happens to move. Inset shadows, not a gradient
   background, because they stay put while the content scrolls under them. */
.sidebar__middle {
  overflow-y: auto;
  /*
   * The place for the scrollbar is reserved, always (0.73.0, asked for).
   *
   * Without it the menu jumped sideways the moment it grew long enough to
   * scroll: the vertical bar takes its width out of the content box, and what
   * no longer fitted came back as a HORIZONTAL bar -- so one had to scroll
   * the menu sideways by exactly the width of the other scrollbar to see the
   * ends of the words. With a stable gutter the room is there from the start,
   * nothing shifts when the bar appears, and the sidebar is a touch wider to
   * give the words back what the gutter takes.
   *
   * overflow-x: hidden underneath it, for browsers that do not know the
   * gutter yet: the names shrink with an ellipsis anyway (see .nav__text),
   * so nothing is lost -- only the sideways scrolling.
   */
  scrollbar-gutter: stable;
  overflow-x: hidden;
  padding: var(--space-3) var(--space-2);
  min-height: 0;
  background: var(--sidebar-inset);
  border-top: var(--border-width) solid var(--sidebar-border);
  border-bottom: var(--border-width) solid var(--sidebar-border);
  box-shadow:
    inset 0 7px 6px -7px var(--sidebar-inset-edge),
    inset 0 -7px 6px -7px var(--sidebar-inset-edge);
}
.sidebar__foot {
  padding: var(--space-3) var(--space-4) var(--space-4);
  border-top: var(--border-width) solid var(--sidebar-border);
  display: grid;
  gap: var(--space-2);
}

.sidebar__version {
  display: flex;
  gap: var(--space-1);
  font-size: var(--text-xs);
  color: var(--fg-on-sidebar-muted);
}
.sidebar__user {
  display: grid;
  gap: calc(var(--space-1) / 2);
  min-width: 0;
}
.sidebar__username {
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--fg-on-sidebar);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sidebar__actions {
  display: flex;
  gap: var(--space-1);
  margin-top: var(--space-1);
}

/* --- Navigation ------------------------------------------------------ */
.nav { display: grid; gap: calc(var(--space-1) / 2); }
.nav__group {
  padding: var(--space-4) var(--space-3) var(--space-1);
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wide);
  color: var(--fg-on-sidebar-muted);
}
.nav__link {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  width: 100%;
  padding: var(--space-2) var(--space-3);
  border: 0;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--fg-on-sidebar-muted);
  font-size: var(--text-md);
  text-align: left;
  text-decoration: none;
  cursor: pointer;
  transition: background var(--duration) var(--easing), color var(--duration) var(--easing);
}
.nav__link:hover { background: var(--sidebar-hover); color: var(--fg-on-sidebar); }
.nav__link[aria-current="page"] {
  background: var(--sidebar-active);
  color: var(--fg-on-sidebar);
  font-weight: var(--weight-medium);
}
.nav__icon { flex: 0 0 auto; }
/* min-width: 0 is the load-bearing part: a flex item does not shrink below its
   own content without it, so a long heading ("Ansagen und Aufnahmen") pushed the
   chevron out of the sidebar instead of being cut short itself. */
.nav__text {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* --- Groups in the menu ---------------------------------------------------
   Sixteen entries in a flat list is something one reads rather than uses. The
   heading is a button, because folding is an action; the items below it are
   indented so the level is visible without a line. */
.nav__group-holder { display: block; }
.nav__group {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  width: 100%;
  padding: var(--space-2) var(--space-3);
  border: 0;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--fg-on-sidebar-muted);
  font-size: var(--text-sm);
  font-weight: var(--weight-bold);
  letter-spacing: var(--tracking-caps);
  text-transform: uppercase;
  text-align: left;
  cursor: pointer;
}
.nav__group:hover { background: var(--sidebar-hover); color: var(--fg-on-sidebar); }
/* --- What KIND of thing is in a group (0.96.0) -----------------------------
   Asked for so that a block of functions is recognisable without being opened:
   the name, and under it in a quieter voice what one is looking at -- something
   one works in, something one sets up and then transfers, something that takes
   effect at once. The four "Einrichten" groups also share a band on the left, so
   one sees how far configuration reaches without reading a word. */
.nav__group-name { display: block; overflow: hidden; text-overflow: ellipsis; }
.nav__group-kind {
  display: block;
  overflow: hidden;
  font-size: var(--text-xs);
  font-weight: var(--weight-normal);
  letter-spacing: normal;
  text-overflow: ellipsis;
  text-transform: none;
  opacity: 0.75;
}
/* --- The colour of a group (0.97.1) ---------------------------------------
   Asked for: "die farbigen markierungen im menü sollen keinen linken rand haben
   und die hauptmenüpunkte sollen unterschiedliche farben haben." So no edge
   anywhere -- the colour sits behind the group's ICON and tints the highlight of
   the open entry underneath it. The default per group comes from the tokens; the
   system administration overrides it as --nav-colour on the group. */
.nav__group-holder[data-group="work"] { --nav-colour: var(--menu-colour-work); }
.nav__group-holder[data-group="in"] { --nav-colour: var(--menu-colour-in); }
.nav__group-holder[data-group="out"] { --nav-colour: var(--menu-colour-out); }
.nav__group-holder[data-group="phones"] { --nav-colour: var(--menu-colour-phones); }
.nav__group-holder[data-group="targets"] { --nav-colour: var(--menu-colour-targets); }
.nav__group-holder[data-group="admin"] { --nav-colour: var(--menu-colour-admin); }
/* The icon carries the colour: a square of it, the symbol on top. Not the text --
   coloured words at four different hues read as four different kinds of warning. */
.nav__group .nav__icon,
.nav__group-items .nav__link[aria-current="page"] .nav__icon {
  padding: var(--space-1);
  border-radius: var(--radius-sm);
  background: var(--nav-colour, var(--sidebar-marker));
  color: var(--surface-sidebar);
}
/* The open entry underneath: the same colour, as a quiet ground rather than an
   edge. `color-mix` keeps it one definition per theme instead of six. */
.nav__group-items .nav__link[aria-current="page"] {
  background: color-mix(in srgb, var(--nav-colour, var(--sidebar-marker)) 24%, transparent);
  box-shadow: none;
}
.nav__group-items .nav__link:hover {
  background: color-mix(in srgb, var(--nav-colour, var(--sidebar-marker)) 12%, transparent);
}
/* Folded to a rail there is no room for a second line. */
.shell--folded .nav__group-kind { display: none; }
/* Always visible, and always last: it is what says the heading can be folded.
   No margin-left:auto any more -- the text takes the free space now. */
.nav__chevron {
  flex: 0 0 auto;
  transition: transform var(--duration) var(--easing);
}
.nav__group--open .nav__chevron { transform: rotate(180deg); }
/* The dot sits before the chevron, so a folded group still says that something
   inside it is waiting -- hiding that would be the one thing folding must not do.
   It never shrinks: it is the smallest element in the row and the only one that
   carries a message, so if anything has to give way it is the text. */
.nav__group .nav__pending { margin-left: 0; }
.nav__pending { flex: 0 0 auto; }
.nav__group-items {
  list-style: none;
  margin: 0;
  padding: 0 0 var(--space-1) var(--space-5);
  display: grid;
  gap: var(--space-1);
}
@media (prefers-reduced-motion: reduce) {
  .nav__chevron { transition: none; }
}

/* --- The page's own symbol (0.97.1) ---------------------------------------
   Left of the title, in the colour of its menu group -- the same square as in the
   menu, so a block is recognisable on the page one lands on. The group decides the
   colour; --nav-colour overrides it where the system administration set one. */
.page__heading {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-width: 0;
}
.page__icon {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  width: var(--control-height);
  height: var(--control-height);
  border-radius: var(--radius-md);
  background: var(--nav-colour, var(--accent));
  color: var(--surface);
}
.page__icon[data-group="work"] { --nav-colour: var(--menu-colour-work); }
.page__icon[data-group="in"] { --nav-colour: var(--menu-colour-in); }
.page__icon[data-group="out"] { --nav-colour: var(--menu-colour-out); }
.page__icon[data-group="phones"] { --nav-colour: var(--menu-colour-phones); }
.page__icon[data-group="targets"] { --nav-colour: var(--menu-colour-targets); }
.page__icon[data-group="admin"] { --nav-colour: var(--menu-colour-admin); }

/* --- Status bar ------------------------------------------------------ */
.statusbar {
  grid-area: statusbar;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  padding: 0 var(--space-5);
  background: var(--surface);
  border-bottom: var(--border-width) solid var(--border);
}
.statusbar__left {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: var(--space-4);
}

/* The quick access: the pages this installation is worked in most.
   Hidden below the width where it would push the clock off the bar -- it is a
   shortcut, and a shortcut that takes the room of the thing it shortens is not
   one. */
.quick {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  min-width: 0;
  overflow: hidden;
}
.quick__link {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-md);
  color: var(--fg-muted);
  font-size: var(--text-sm);
  white-space: nowrap;
  text-decoration: none;
}
/* Something here is waiting to reach the PBX. Same mark as in the menu -- the
   status bar is on every screen, and a folded menu group hides the one that
   asks for an action. */
.quick__link--pending { color: var(--fg); }
.quick__link:hover,
.quick__link:focus-visible {
  background: var(--surface-muted);
  color: var(--fg);
}
.quick__link[aria-current="page"] {
  color: var(--fg);
  background: var(--surface-muted);
}
@media (max-width: 70rem) {
  .quick { display: none; }
}
.statusbar__right {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  flex: 0 0 auto;
}
.breadcrumb {
  font-size: var(--text-sm);
  color: var(--fg-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  display: block;
}
.clock {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  color: var(--fg);
  letter-spacing: var(--tracking-mono);
}

/* --- Stage ----------------------------------------------------------- */
/*
 * The stage is the only part that moves, and it is meant to look as if it sits
 * BEHIND the two parts that do not: the sidebar casts a shadow onto it from the
 * left, the status bar from the top. Inset, so the shadow stays with the recess
 * while the content scrolls past underneath it.
 *
 * The spread is negative and larger than the blur, so the shadow only appears
 * along the two edges it comes from and nowhere else.
 */
.stage {
  grid-area: stage;
  overflow-y: auto;
  padding: var(--space-6);
  min-height: 0;
  background: var(--bg);
  box-shadow:
    inset 8px 0 10px -8px var(--shadow-inset),
    inset 0 8px 10px -8px var(--shadow-inset);
}
.stage:focus { outline: none; }

.page { display: grid; gap: var(--space-5); max-width: 78rem; }
.page--wide { max-width: none; }
.page__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-4);
  flex-wrap: wrap;
}
.page__title {
  font-size: var(--text-xl);
  font-weight: var(--weight-bold);
  letter-spacing: var(--tracking-tight);
}
.page__subtitle {
  margin-top: var(--space-1);
  color: var(--fg-muted);
  font-size: var(--text-sm);
  max-width: 52rem;
}
/* Centred, not stretched: a switch beside the buttons must not make them tall. */
.page__actions { display: flex; gap: var(--space-2); flex-wrap: wrap; align-items: center; }

/* The button that opens the drawer, and the shade beside it. Both exist only on
   a narrow screen -- see the media query at the end of this file.

   Written with the status bar in front of it, because components.css is loaded
   AFTER this file and .icon-btn sets a display of its own: as a single class
   this rule lost, and the button stood in the bar on every screen -- two
   hamburgers, one of them useless (19.09.2026). */
.statusbar .statusbar__menu { display: none; }
.scrim {
  position: fixed;
  inset: 0;
  z-index: 55;
  border: 0;
  padding: 0;
  background: var(--overlay);
  cursor: pointer;
}

/* --- On a telephone --------------------------------------------------- */
/*
 * Until 0.53.0 the menu simply stacked on top: it took up to 60% of the height
 * and the content lived in what was left, folding it away removed it entirely
 * (no way back), and the quick access was hidden below 70rem -- so on a
 * telephone one had a long menu, a short page and no shortcuts.
 *
 * Now: the status bar is the whole chrome. It carries the button that opens the
 * menu as a DRAWER over the page, and underneath it the quick access as a row
 * one can push sideways. The page gets the rest of the screen, which on a
 * telephone is all of it.
 */
@media (max-width: 54rem) {
  .shell {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
    grid-template-areas:
      "statusbar"
      "stage";
    /* dvh, because the address bar of a telephone browser comes and goes and
       100vh stays as tall as the screen WITHOUT it -- the difference is a page
       whose foot one can never reach. */
    height: 100dvh;
  }
  .statusbar {
    height: auto;
    flex-wrap: wrap;
    padding: var(--space-2) var(--space-3);
    row-gap: var(--space-2);
  }
  .statusbar .statusbar__menu { display: inline-grid; }
  /* And only ONE of them: folding is a wide-screen idea, so the button inside
     the drawer goes away here -- otherwise the open drawer shows a second
     hamburger beside the first, and pressing it folds the menu instead of
     closing the drawer (19.09.2026).

     Written with .sidebar in front of it for the same reason as the button in
     the status bar: components.css comes after this file and .icon-btn sets a
     display of its own, so a single class loses. */
  .sidebar .sidebar__toggle { display: none; }
  .sidebar__head { justify-content: space-between; padding: 0 var(--space-4); }
  /* Room between the menu button and what follows it: at a thumb's width they
     were two things that looked like one (19.09.2026). */
  .statusbar__left { flex: 1 1 100%; gap: var(--space-4); }
  .statusbar .statusbar__menu { margin-right: var(--space-1); }
  /* The clock is the first thing to go when the row gets tight: the two buttons
     that moved here are worth more than the time, which every telephone shows
     anyway. */
  .statusbar .clock { display: none; }
  /* The shortcuts are what one actually uses on a telephone, so they are shown
     here rather than hidden: a row of their own, pushed sideways with a thumb. */
  .quick {
    display: flex;
    flex: 1 1 100%;
    order: 3;
    overflow-x: auto;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }
  .quick::-webkit-scrollbar { display: none; }
  .quick__link { white-space: nowrap; }

  /* The menu itself: a drawer over the page, off to the left until it is
     wanted. Not display:none -- it slides, and a screen reader follows it. */
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    /* Its height as the SCREEN has it, not as the layout viewport has it: with
       top/bottom the drawer ends behind the browser's own bottom bar on a
       telephone, and its foot -- version, account, and on a wide screen the two
       buttons -- is simply not there (19.09.2026). dvh follows the bar as it
       comes and goes; the svh below is for the browsers that know neither. */
    height: 100vh;
    height: 100svh;
    height: 100dvh;
    width: min(20rem, 84vw);
    z-index: 60;
    grid-template-rows: auto minmax(0, 1fr) auto;
    max-height: none;
    transform: translateX(-101%);
    transition: transform var(--duration) ease;
    box-shadow: var(--shadow-float);
  }
  /* And the foot keeps clear of the rounded corner and the home indicator. */
  .sidebar__foot { padding-bottom: calc(var(--space-4) + env(safe-area-inset-bottom)); }
  .shell--folded .sidebar__foot {
    padding-bottom: calc(var(--space-4) + env(safe-area-inset-bottom));
  }
  .shell--menu .sidebar { transform: none; }
  /* With the drawer open the page underneath stays put: scrolling it away while
     reading the menu is how one loses the place one was at. */
  .shell--menu .stage { overflow: hidden; }
  /* Folded is a wide-screen idea: on a telephone the drawer is either open or
     it is not, and it always shows its full self. */
  /* Folded is a wide-screen decision and it is remembered per browser -- so
     somebody who folded the menu on the desk must not find a crippled drawer on
     the telephone. Each of these gets the display it has when nothing is
     folded; `revert` would hand it back to the browser's default instead. */
  .shell--folded .sidebar__brand,
  .shell--folded .sidebar__version { display: inline; }
  .shell--folded .nav__text { display: block; }
  .shell--folded .nav__chevron { display: inline-flex; }
  .shell--folded .sidebar__user { display: grid; }
  .shell--folded .sidebar__middle { display: block; padding: var(--space-3) var(--space-2); }
  .shell--folded .sidebar__foot {
    display: grid;
    padding: var(--space-3) var(--space-4) var(--space-4);
  }
  .shell--folded .sidebar__actions { flex-direction: row; align-items: center; }
  .shell--folded .sidebar__head { justify-content: space-between; padding: 0 var(--space-4); }
  .stage { padding: var(--space-4); }
}

/* --duration goes to 1ms under prefers-reduced-motion (tokens.css), so the
   drawer stops sliding there without a rule of its own. */
