/* Umbrella — app layout on top of zap's theme tokens. Colours come only from
   var(--zap-*), so light / dark follow the theme without extra rules. */

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--zap-bg, #fff); }
#app { min-height: 100%; }
.app-root, .app-root__view { min-height: 100vh; }
.muted { color: var(--zap-muted); }
.boot { display: grid; place-items: center; min-height: 100vh; }

/* shell */
.shell { display: flex; align-items: stretch; min-height: 100vh; }
.shell__main { flex: 1; min-width: 0; background: var(--zap-elevated); }
.page { padding: 28px 32px 48px; max-width: 1400px; margin: 0 auto; display: grid; gap: 20px; align-content: start;
  /* one column that may shrink: a wide table scrolls inside itself instead of widening the page */
  grid-template-columns: minmax(0, 1fr); }
.page > *, .stack > *, .grid-2 > *, .grid-3 > * { min-width: 0; }
@media (max-width: 900px) {
  .shell { flex-direction: column; }
  .page { padding: 16px; }
}

.brand { display: flex; align-items: center; gap: 10px; }
.brand__logo { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 10px; font-size: 20px;
  background: var(--zap-primary); color: var(--zap-primary-contrast); }
.brand b { display: block; font-size: 16px; }
.brand small { display: block; color: var(--zap-muted); font-size: 12px; }
.side-user { width: 100%; }
.side-user__btn { all: unset; box-sizing: border-box; cursor: pointer; width: 100%; padding: 6px; border-radius: var(--zap-radius-sm); }
.side-user__btn:hover, .side-user__btn:focus-visible { background: var(--zap-primary-soft); }

/* page header */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.page-head__title { margin: 0; font-size: 24px; letter-spacing: -.01em; }
.page-head__sub { margin: 4px 0 0; color: var(--zap-muted); }
.page-head__actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* layout helpers */
.stack { display: grid; gap: 14px; }
.stack--tight { display: grid; gap: 8px; }
.cluster { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.spread { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.grid-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; align-items: start; }
@media (max-width: 900px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }

/* definition lists (read-only company info) */
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px 24px; margin: 0; }
.facts div { min-width: 0; }
.facts dt { font-size: 12px; color: var(--zap-muted); text-transform: uppercase; letter-spacing: .04em; }
.facts dd { margin: 2px 0 0; font-weight: 500; overflow-wrap: anywhere; }

/* editable child lists (owners, employees…) */
.rows { display: grid; gap: 10px; }
.rows__item { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)) auto; align-items: end;
  padding: 12px; border: 1px solid var(--zap-border); border-radius: var(--zap-radius-sm); background: var(--zap-surface); }
.rows__empty { color: var(--zap-muted); padding: 12px 0; }
.rows__total { font-size: 13px; color: var(--zap-muted); }
.rows__total.is-bad { color: var(--zap-danger); font-weight: 600; }

/* sticky save bar on long forms */
.savebar { position: sticky; bottom: 0; z-index: 5; display: flex; justify-content: flex-end; gap: 8px; padding: 12px 0;
  background: linear-gradient(to top, var(--zap-elevated) 70%, transparent); }

/* tasks */
.view-switch { display: inline-flex; border: 1px solid var(--zap-border); border-radius: 999px; padding: 3px; background: var(--zap-surface); }
.view-switch button { all: unset; cursor: pointer; padding: 5px 14px; border-radius: 999px; font-size: 13px; }
.view-switch button.is-active { background: var(--zap-primary); color: var(--zap-primary-contrast); }
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.filters > * { min-width: 180px; }
.task-meta { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; font-size: 13px; color: var(--zap-muted); }
.subtask { display: flex; align-items: center; gap: 10px; padding: 6px 0; border-bottom: 1px solid var(--zap-border); }
.subtask:last-child { border-bottom: 0; }
.subtask.is-done span { text-decoration: line-through; color: var(--zap-muted); }
.subtask span { flex: 1; }
.comment { padding: 10px 12px; border-radius: var(--zap-radius-sm); background: var(--zap-elevated); }
.comment header { display: flex; justify-content: space-between; font-size: 12px; color: var(--zap-muted); margin-bottom: 4px; }
.comment p { margin: 0; white-space: pre-wrap; }
.link { color: var(--zap-primary); cursor: pointer; text-decoration: none; background: none; border: 0; padding: 0; font: inherit; }
.link:hover { text-decoration: underline; }

/* document templates */
.tpl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.money-pos { color: var(--zap-success); font-variant-numeric: tabular-nums; }
.money-neg { color: var(--zap-danger); font-variant-numeric: tabular-nums; }

/* signed-out pages */
.auth-area { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px;
  background: radial-gradient(1200px 600px at 10% -10%, var(--zap-primary-soft), transparent), var(--zap-elevated); }
.auth { width: min(420px, 100%); display: grid; gap: 18px; }
.auth__brand { display: grid; justify-items: center; gap: 2px; text-align: center; }
.auth__brand b { font-size: 22px; }
.auth__brand small { color: var(--zap-muted); }
.auth__logo { display: grid; place-items: center; width: 52px; height: 52px; border-radius: 14px; font-size: 28px; margin-bottom: 6px;
  background: var(--zap-primary); color: var(--zap-primary-contrast); box-shadow: var(--zap-shadow); }
.auth__link { justify-self: center; font-size: 14px; color: var(--zap-primary); text-decoration: none; }
.auth__link:hover { text-decoration: underline; }

/* language picker on the signed-out pages */
.lang-switch { display: flex; justify-content: center; gap: 4px; }
.lang-switch button { all: unset; cursor: pointer; padding: 4px 10px; border-radius: 999px; font-size: 13px; color: var(--zap-muted); }
.lang-switch button:hover, .lang-switch button:focus-visible { color: var(--zap-text); background: var(--zap-surface); }
.lang-switch button.is-active { color: var(--zap-primary); font-weight: 600; background: var(--zap-primary-soft); }

/* "or" between the Google button and the email form */
.google-signin { display: flex; justify-content: center; min-height: 0; }
.google-signin:empty { display: none; }
.auth__or { display: flex; align-items: center; gap: 10px; color: var(--zap-muted); font-size: 13px; }
.auth__or::before, .auth__or::after { content: ""; flex: 1; border-top: 1px solid var(--zap-border); }
.auth__or[hidden] { display: none; }

/* pending access requests next to "Users" in the side menu */
.side-count { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px;
  font-size: 11px; font-weight: 700; background: var(--zap-danger); color: #fff; }
.side-count[hidden] { display: none; }

/* one access request on the Users page */
.request { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 8px 0; border-bottom: 1px solid var(--zap-border); }
.request:last-child { border-bottom: 0; }
.request > :first-child { flex: 1; min-width: 200px; }
.request__when { font-size: 13px; }

/* ── phones ─────────────────────────────────────────────────────────────── */
@media (max-width: 700px) {
  .page { padding: 14px 12px 32px; gap: 14px; }
  .page-head { align-items: stretch; }
  .page-head__title { font-size: 21px; }
  .page-head__actions { width: 100%; }
  .page-head__actions > .cluster { width: 100%; justify-content: space-between; }
  .grid-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .filters > * { min-width: 0; flex: 1 1 100%; }
  .form-row { grid-template-columns: minmax(0, 1fr); }
  .rows__item { grid-template-columns: minmax(0, 1fr); }
  .rows__item > :last-child { justify-self: end; }
  .facts { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 10px 14px; }
  .request__when { flex-basis: 100%; order: 3; }
  .tpl-grid { grid-template-columns: minmax(0, 1fr); }
  .savebar { padding: 10px 0 calc(10px + env(safe-area-inset-bottom)); }
  .savebar > * { flex: 1; }
}

/* tasks as cards on a phone (the list view) */
.task-cards { display: grid; gap: 10px; }
.task-card { all: unset; box-sizing: border-box; display: grid; gap: 6px; padding: 12px 14px; cursor: pointer;
  border: 1px solid var(--zap-border); border-radius: var(--zap-radius-sm); background: var(--zap-surface); }
.task-card:focus-visible { outline: 2px solid var(--zap-primary); outline-offset: 2px; }
.task-card__title { font-weight: 600; }
.task-card__meta { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: 13px; color: var(--zap-muted); }
.task-card.is-late { border-left: 3px solid var(--zap-danger); }

/* keyboard shortcut hints mean nothing on a touch screen */
@media (hover: none), (max-width: 700px) {
  .zap-btn__kbd { display: none; }
}

@media (max-width: 700px) {
  /* the board: one column per screen, and a swipe stops on the next one */
  .zap-kb { --kb-w: calc(100vw - 48px); scroll-snap-type: x mandatory; }
  .zap-kb__cols > .zap-sort__item { scroll-snap-align: start; }
  /* a row of tabs wider than the phone scrolls; the fade says there is more */
  .zap-tabs__list { -webkit-mask-image: linear-gradient(to right, #000 85%, transparent);
    mask-image: linear-gradient(to right, #000 85%, transparent); scrollbar-width: none; }
}

/* iOS zooms into any field under 16px when it is tapped; keep them at 16 on phones */
@media (max-width: 700px) {
  input, select, textarea, .zap-select__trigger, .zap-input__field { font-size: 16px !important; }
}
/* notched phones in standalone mode: keep content clear of the sensor housing and home bar */
@supports (padding: env(safe-area-inset-left)) {
  .shell__main { padding-left: env(safe-area-inset-left); padding-right: env(safe-area-inset-right); }
}
