/* Shared styles of the department apps on top of Ionic; colours follow the system (light and dark).
   Secondary grey text: var(--ion-text-color-step-350, var(--ion-color-step-650, #595959)). Ionic 8+ sets only
   --ion-text-color-step-* in its dark palette (#acacac there, 7.3:1 on a card); the old --ion-color-step-650 is unset
   in both modes, so its #595959 fallback stood on dark too (2.4:1). In light the step is unset and #595959 stays. */

:root {
  /* One spacing scale for every margin, padding and gap: 4, 8, 12, 16, 24; 2 only between a title and its line. */
  --space-hair: 2px;
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-6: 24px;
}

/* Keyboard focus: Ionic marks the element with .ion-focused but on iOS leaves a row white. A ring in the primary colour
   shows where the focus is; inside the row (negative offset) so the list does not clip it.
   Ionic sets .ion-focused only after a key press; :focus-visible on the inner part catches every other way the browser
   shows focus (a screen reader, focus moved by script). On a tab button Ionic's grey focus layer would cover the ring,
   so that layer is made clear there: the ring alone shows the focus. */
ion-tab-button {
  --background-focused-opacity: 0;
}
ion-item.ion-focused::part(native),
ion-item::part(native):focus-visible,
ion-tab-button.ion-focused::part(native) {
  outline: 2px solid var(--ion-color-primary);
  outline-offset: -2px;
}
ion-button.ion-focused::part(native),
ion-button::part(native):focus-visible,
ion-chip.ion-focused {
  outline: 2px solid var(--ion-color-primary);
  outline-offset: 2px;
}

/* Segments read the same on Android as on the iPhone: Ionic's Material style sets them in capitals with letter
   spacing, and "Einstellungen" in the agent sheet no longer fit (126 px text in 98 px at 390 px, measured 03.12.2026). */
ion-segment-button {
  text-transform: none;
  letter-spacing: 0;
}

ion-chip.draft {
  --color: var(--ion-color-medium);
  font-size: 12px;
  height: 26px;
  /* In the start slot of the toolbar: away from the screen edge, the title keeps the middle. */
  margin-inline: var(--space-2) 0;
}

.section-title {
  margin: var(--space-6) var(--space-4) var(--space-1);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ion-color-medium);
}


/* Ionic's iOS card title is 28px; on a phone a card should show more than its heading. */
ion-card-title {
  font-size: 20px;
  line-height: 1.25;
}



.meta {
  margin: var(--space-hair) 0 0;
  font-size: 13px;
  color: var(--ion-color-medium);
}

.plan-context,
.plan-count {
  font-size: 14px;
  color: var(--ion-color-medium);
}

.plan-warning {
  margin: var(--space-3) 0;
  padding: var(--space-3) var(--space-3);
  border-radius: 8px;
  font-size: 14px;
  background: rgba(var(--ion-color-warning-rgb), 0.16);
}

/* Ionic's success green is too light for text on white (about 1.9:1); the text keeps the text colour, the icon is green. */
.plan-result {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-weight: 600;
  color: var(--ion-text-color, #000);
}
.plan-result ion-icon {
  font-size: 22px;
  color: var(--ion-color-success);
}
.plan-result[hidden] {
  display: none;
}

.draft-note {
  font-weight: 600;
  color: var(--ion-text-color, #000);
}

/* Keep the last card clear of the tab bar and the home indicator. */
[data-area] {
  padding-bottom: calc(var(--space-4) + var(--ion-safe-area-bottom, 0px));
}

/* ---- The shared card pattern (shared/card.js): head, title, why, facts, next step, plan ---- */

:root {
  /* Fixed in both schemes: Ionic's dark danger red is too light for white text. White on it measures about 6:1. */
  --tone-cost: #c5000f;
  --tone-cost-text: #ffffff;
  /* Orange for "tips today or tomorrow"; white text on it measures about 5:1. */
  --tone-soon: #b84d00;
  --tone-soon-text: #ffffff;
}


.filter-chips {
  display: flex;
  gap: var(--space-2);
  margin: var(--space-2) 0 0;
  padding: 0 var(--space-4) var(--space-1);
  overflow-x: auto;
  scrollbar-width: none;
}
.filter-chips ion-chip {
  flex: none;
  margin: 0;
  font-size: 14px;
}

/* Class names carry the rh- prefix: Ionic itself uses .item and .rh-label on ion-item. */
ion-card.rh-card.soon,
ion-card.rh-card.cost {
  border-inline-start: 5px solid var(--tone-soon);
}
ion-card.rh-card.cost {
  border-inline-start-color: var(--tone-cost);
}
.rh-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
}
.tone-badge {
  padding: var(--space-1) var(--space-2);
  border-radius: 6px;
  font-size: 13px;
  font-weight: 700;
  color: var(--tone-soon-text);
  background: var(--tone-soon);
}
.tone-badge.cost {
  color: var(--tone-cost-text);
  background: var(--tone-cost);
}
.rh-label {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ion-color-medium);
}
ion-card-content h3.rh-title {
  margin: var(--space-3) 0 var(--space-hair);
  font-size: 17px;
  font-weight: 700;
  color: var(--ion-text-color, #000);
}
ion-card-content p.rh-why {
  margin: var(--space-1) 0;
  font-size: 15px;
  font-weight: 600;
  color: var(--ion-text-color, #000);
}
ion-card-content p.rh-meta {
  margin: 0;
  font-size: 13px;
}
ion-card-content p.rh-next {
  margin: var(--space-2) 0 var(--space-1);
  font-size: 15px;
  color: var(--ion-text-color, #000);
}
ion-card.rh-card ion-button {
  margin-top: var(--space-2);
}

.empty {
  margin: var(--space-6) var(--space-4);
  color: var(--ion-color-medium);
}

/* ---- The compact row (shared/row.js): stripe in the tone, title, why in one line; the card opens in a sheet ---- */
.rh-stripe {
  align-self: stretch;
  width: 4px;
  margin: var(--space-2) var(--space-3) var(--space-2) 0;
  border-radius: 2px;
}
.rh-stripe.cost {
  background: var(--tone-cost);
}
.rh-stripe.soon {
  background: var(--tone-soon);
}
ion-item.rh-row ion-label h3.rh-row-title {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  color: var(--ion-text-color, #000);
}
ion-item.rh-row ion-label p.rh-row-why {
  margin: var(--space-hair) 0 0;
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--ion-text-color-step-350, var(--ion-color-step-650, #595959));
}
.rh-detail ion-card {
  margin-top: var(--space-2);
}

/* ---- Avatar (shared/avatar.js) and the head with a lead: who the card is about, in front ---- */
.rh-avatar {
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  font-size: 18px;
  font-weight: 700;
  color: #fff;
}
.rh-avatar.person {
  border-radius: 50%;
}
.rh-head.with-lead {
  align-items: center;
  justify-content: flex-start;
  gap: var(--space-3);
}
.rh-who {
  flex: 1;
  min-width: 0;
}
.rh-head.with-lead h3.rh-title {
  margin: 0;
  font-size: 19px;
  line-height: 1.25;
}
ion-card-content p.rh-sub {
  margin: var(--space-hair) 0 0;
  font-size: 13px;
  color: var(--ion-text-color-step-350, var(--ion-color-step-650, #595959));
}
.rh-head.rh-status {
  margin-top: var(--space-3);
}

/* "Beispiel" on an invented case among real ones: small and grey, so real ones read first. */
.rh-sample {
  display: inline-block;
  margin-inline: 0 var(--space-1);
  padding: 0 var(--space-1);
  border: 1px solid currentColor;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: none;
  vertical-align: 1px;
  color: var(--ion-text-color-step-350, var(--ion-color-step-650, #595959));
}
h3.rh-row-title .rh-sample {
  margin-inline: var(--space-1) 0;
}

/* ---- Counter tiles (shared/tiles.js) ---- */
/* Up to four tiles sharing the row equally; colour only as a thin stripe on top, after the worst case inside. */
.tiles {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(0, 1fr);
  gap: var(--space-2);
  margin: var(--space-3) var(--space-4) 0;
}
.tile {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  min-height: 64px;
  padding: var(--space-2) var(--space-2) var(--space-2);
  overflow: hidden;
  border: 1px solid var(--ion-color-step-150, rgba(127, 127, 127, 0.25));
  border-radius: 10px;
  font: inherit;
  text-align: start;
  color: var(--ion-text-color, #000);
  background: var(--ion-color-step-50, rgba(127, 127, 127, 0.06));
  cursor: pointer;
}
.tile.cost::before,
.tile.soon::before {
  content: '';
  position: absolute;
  inset: 0 0 auto;
  height: 3px;
  background: var(--tone-soon);
}
.tile.cost::before {
  background: var(--tone-cost);
}
.tile.on {
  border-color: var(--ion-text-color, #000);
  box-shadow: inset 0 0 0 1px var(--ion-text-color, #000);
}
.tile:focus-visible {
  outline: 2px solid var(--ion-color-primary);
  outline-offset: 2px;
}
.tile-n {
  font-size: 22px;
  font-weight: 700;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}
.tile-word {
  font-size: 12px;
  font-weight: 600;
}
.tile-sub {
  margin-top: var(--space-hair);
  font-size: 11px;
  line-height: 1.25;
  color: var(--ion-color-medium);
  font-variant-numeric: tabular-nums;
}

/* ---- Goods of an order or delivery (shared/lines.js): closed until tapped, one slim line per product ---- */
details.goods {
  margin: var(--space-2) 0 0;
  border-top: 1px solid var(--ion-color-step-150, rgba(127, 127, 127, 0.3));
}
summary.goods-summary {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  min-height: 44px;
  font-size: 14px;
  font-weight: 600;
  color: var(--ion-text-color, #000);
  cursor: pointer;
  list-style: none;
}
summary.goods-summary::-webkit-details-marker {
  display: none;
}
summary.goods-summary:focus-visible {
  outline: 2px solid var(--ion-color-primary);
  outline-offset: 2px;
  border-radius: 6px;
}
.goods-summary .rh-sample {
  margin-inline: var(--space-hair) 0;
}
.goods-toggle {
  margin-inline-start: auto;
  font-size: 20px;
  line-height: 1;
  transition: transform 0.15s;
}
details.goods[open] .goods-toggle {
  transform: rotate(90deg);
}
.goods-body {
  padding-bottom: var(--space-2);
}
.goods-head,
.goods-line {
  display: flex;
  justify-content: space-between;
  gap: var(--space-3);
}
.goods-head {
  margin: 0 0 var(--space-hair);
  font-size: 12px;
  color: var(--ion-text-color-step-350, var(--ion-color-step-650, #595959));
}
.goods-container {
  margin: var(--space-2) 0 var(--space-hair);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ion-text-color-step-350, var(--ion-color-step-650, #595959));
}
.goods-list {
  margin: 0;
  padding: 0;
  list-style: none;
}
.goods-line {
  padding: var(--space-1) 0;
  font-size: 14px;
  color: var(--ion-text-color, #000);
  border-bottom: 1px solid var(--ion-color-step-100, rgba(127, 127, 127, 0.15));
}
.goods-product {
  min-width: 0;
  overflow-wrap: anywhere;
}
.goods-qty {
  flex: none;
  font-variant-numeric: tabular-nums;
}
/* Open after its date: the quantity in orange text, dark on light and light on dark, both at least 4.5:1. */
.goods-line.late .goods-qty {
  font-weight: 700;
  color: var(--tone-soon);
}
@media (prefers-color-scheme: dark) {
  .goods-line.late .goods-qty {
    color: #ffa552;
  }
}
.goods-more {
  min-height: 44px;
  padding: 0;
  border: 0;
  font: inherit;
  font-size: 14px;
  color: var(--ion-color-primary);
  background: none;
  cursor: pointer;
}

/* The real plan of a tool, as it answered. */
pre.plan-real {
  margin: 0;
  font-size: 13px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

/* "Termin setzen" (dispo/views/termin.js): date and source, then the plan. */
.termin-body {
  display: grid;
  gap: var(--space-2);
  padding-bottom: var(--space-3);
}
.termin-label {
  font-size: 13px;
  color: var(--ion-text-color-step-350, var(--ion-color-step-650, #595959));
}
.termin-input {
  min-height: 44px;
  padding: 0 var(--space-3);
  border: 1px solid var(--ion-color-step-400, #8a8a8a);
  border-radius: 8px;
  font: inherit;
  font-size: 16px;
  color: var(--ion-text-color, #000);
  background: var(--ion-background-color, #fff);
}
.termin-input:focus-visible,
.termin-show:focus-visible {
  outline: 2px solid var(--ion-color-primary);
  outline-offset: 2px;
}
.termin-show {
  justify-self: start;
  min-height: 44px;
  margin-top: var(--space-1);
  padding: 0 var(--space-4);
  border: 1px solid var(--ion-color-primary);
  border-radius: 8px;
  font: inherit;
  font-size: 15px;
  font-weight: 600;
  color: var(--ion-color-primary);
  background: none;
}
.termin-show:disabled {
  border-color: var(--ion-color-step-300, #b3b3b3);
  color: var(--ion-color-step-500, #808080);
}
.termin-hint {
  margin: 0 0 var(--space-hair);
  font-size: 13px;
  color: var(--ion-text-color-step-350, var(--ion-color-step-650, #595959));
}
.termin-refusal {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  color: var(--tone-soon);
}
/* A reader sees the form, the button stays off (shared/plan.js canWrite). */
.termin-readonly {
  margin: 0;
  font-size: 14px;
  color: var(--ion-color-step-600, var(--ion-text-color-step-400, #666));
}
@media (prefers-color-scheme: dark) {
  .termin-refusal {
    color: #ffa552;
  }
}

/* An order whose positions could not be loaded (lines_error): said calmly, not an empty list. */
.goods-missing {
  margin: var(--space-2) 0 0;
  padding-top: var(--space-3);
  border-top: 1px solid var(--ion-color-step-150, rgba(127, 127, 127, 0.3));
  font-size: 14px;
  color: var(--ion-text-color-step-350, var(--ion-color-step-650, #595959));
}
