/* The header every app page shares (nav.js builds the menus from the links in the page). Loaded after dashboard.css and admin.css, so it wins over their older tab rules. */

.bar { row-gap: 8px; }
.bar .brand { white-space: nowrap; }
.bar .tabs { flex-wrap: wrap; }
.bar nav[hidden] { display: none; }
.bar .tabs a { padding: 4px 10px; border: 1px solid var(--line); border-radius: 6px; color: var(--text); text-decoration: none; }
.bar .tabs a[aria-current="page"] { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.bar .symbols { flex-basis: 100%; }
.bar .symbols:empty { display: none; }

.bar .menus, .bar .menu-list { list-style: none; margin: 0; padding: 0; }
.bar .menus { display: flex; gap: 2px; }
.bar .menu { position: relative; }
.bar .menu[hidden] { display: none; }

.bar .menu-button, .bar .menu-toggle, .bar .theme-toggle {
  border: 1px solid transparent;
  background: transparent;
  color: var(--text);
  padding: 6px 12px;
  border-radius: 8px;
  font: inherit;
  cursor: pointer;
}
.bar .menu-button::after { content: ""; display: inline-block; margin-left: 7px; width: 6px; height: 6px; border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor; transform: translateY(-2px) rotate(45deg); opacity: 0.6; }
.bar .menu-button:hover, .bar .menu-toggle:hover, .bar .theme-toggle:hover { background: var(--bg); border-color: var(--line); }
.bar .menu-button[aria-current="true"] { color: var(--accent); font-weight: 600; }
.bar .menu-button[aria-expanded="true"] { background: var(--bg); border-color: var(--line); }
.bar .menu-button:focus-visible, .bar .menu-toggle:focus-visible, .bar .theme-toggle:focus-visible, .bar .menu-link:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.bar .menu-list {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  min-width: 190px;
  padding: 6px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(16, 24, 40, 0.14);
  z-index: 10;
}
.bar .menu-list[hidden] { display: none; }
.bar .menu-link { display: block; padding: 7px 10px; border-radius: 6px; color: var(--text); text-decoration: none; white-space: nowrap; }
.bar .menu-link:hover { background: var(--bg); }
.bar .menu-link[aria-current="page"] { background: var(--accent); color: var(--on-accent); }

.bar .menu-toggle { display: none; border-color: var(--line); }
.bar .theme-toggle { padding: 4px 10px; font-size: 12px; color: var(--muted); border-color: var(--line); }

/* Narrow screens: a Menu button opens the four menus as one stacked list under the header. */
@media (max-width: 860px) {
  .bar { gap: 10px; padding: 8px 14px; }
  .bar .menu-toggle { display: inline-block; }
  .bar .menus { display: none; flex-basis: 100%; flex-direction: column; order: 5; }
  .bar.menus-open .menus { display: flex; }
  .bar .menu-list { position: static; box-shadow: none; border: 0; padding: 0 0 6px 14px; min-width: 0; }
  .bar .menu-button { width: 100%; text-align: left; }
  .bar .status { flex-wrap: wrap; }
}

@media (prefers-reduced-motion: no-preference) {
  .bar .menu-button, .bar .menu-toggle, .bar .theme-toggle, .bar .menu-link { transition: background-color 0.12s, border-color 0.12s; }
}

/* ---- The look of the whole app: shared parts, loaded after each page's own style so they win. ---- */

html { -webkit-text-size-adjust: 100%; scrollbar-width: thin; scrollbar-color: var(--line) transparent; }
body { font-size: 14px; line-height: 1.5; -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; }
::selection { background: color-mix(in srgb, var(--accent) 28%, transparent); }
a { color: var(--accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
h1, h2, h3 { letter-spacing: -0.01em; }
main h1 { font-size: 22px; margin: 4px 0 14px; }

/* The header: translucent over what scrolls under it, with a small mark before the name. */
.bar { background: color-mix(in srgb, var(--surface) 90%, transparent); -webkit-backdrop-filter: saturate(1.4) blur(10px); backdrop-filter: saturate(1.4) blur(10px); padding: 10px 24px; }
.bar .brand { display: flex; align-items: center; margin: 0; font-size: 17px; font-weight: 700; letter-spacing: -0.01em; }
.bar .brand::before { content: ""; width: 20px; height: 20px; margin-right: 9px; border-radius: 6px; background: linear-gradient(135deg, var(--accent), color-mix(in srgb, var(--accent) 45%, #a855f7)); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.25); }
.bar .brand .muted { font-weight: 500; font-size: 13px; margin-left: 10px; padding-left: 10px; border-left: 1px solid var(--line); }
.bar .status { gap: 12px; font-size: 13px; }

/* Cards, key figures, empty states. */
.card { border-radius: var(--radius); padding: 16px 18px; margin-bottom: 16px; }
.card h2 { font-size: 16px; font-weight: 650; }
.card h3 { font-size: 11px; font-weight: 650; letter-spacing: 0.08em; margin: 18px 0 8px; }
.kpis { gap: 14px; }
.kpi { border-radius: var(--radius); padding: 14px 16px; position: relative; overflow: hidden; }
.kpi::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 3px; background: var(--accent); opacity: 0.85; }
.kpi .label { font-size: 11px; font-weight: 600; letter-spacing: 0.08em; }
.kpi .value { font-size: 24px; font-weight: 700; letter-spacing: -0.02em; margin-top: 4px; }
.empty { margin: 28px auto; max-width: 640px; padding: 36px 24px; border: 1px dashed var(--line); border-radius: var(--radius); background: color-mix(in srgb, var(--surface) 60%, transparent); color: var(--muted); }
.empty h2 { color: var(--text); font-size: 18px; }
.none { padding: 12px 0; }

/* Tables: quiet headers, a row you can follow with the pointer. */
th { font-size: 11px; font-weight: 650; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); padding: 7px 8px; border-bottom: 1px solid var(--line); }
td { padding: 7px 8px; }
tbody tr:hover > td { background: color-mix(in srgb, var(--accent) 6%, transparent); }
.chain-wrap, .scroll { scrollbar-width: thin; }

/* Buttons and fields. */
.admin .primary, dialog .primary, .login .primary {
  padding: 8px 16px; border-radius: var(--radius-sm); font-weight: 600; box-shadow: 0 1px 2px rgba(16, 24, 40, 0.12);
}
.admin .primary:hover, dialog .primary:hover, .login .primary:hover { background: color-mix(in srgb, var(--accent) 88%, #000); }
.admin .primary:active, dialog .primary:active, .login .primary:active { transform: translateY(1px); }
.admin .small { padding: 4px 11px; border-radius: var(--radius-sm); font-weight: 500; }
.admin .small:hover { border-color: var(--accent); color: var(--accent); }
.admin .danger:hover { border-color: var(--neg); color: var(--neg); background: color-mix(in srgb, var(--neg) 8%, transparent); }
button:disabled, .admin .primary:disabled, .admin .small:disabled { opacity: 0.5; cursor: not-allowed; }
.admin input:not([type="checkbox"]):not([type="radio"]):not([type="range"]), .admin select, .admin textarea, dialog input, .login input, select {
  background: var(--surface); color: var(--text); border: 1px solid var(--line); border-radius: var(--radius-sm); font: inherit;
}
.admin input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):hover, .admin select:hover, .admin textarea:hover, select:hover { border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); }
.admin input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):focus, .admin select:focus, .admin textarea:focus, dialog input:focus, .login input:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent);
}
.admin label { font-size: 12px; font-weight: 500; color: var(--muted); }
.admin label input, .admin label select { font-size: 14px; color: var(--text); }
input[type="checkbox"], input[type="radio"] { accent-color: var(--accent); }

/* Messages, status pills, chips, notes. */
.admin .note, dialog .note, .login .note { background: color-mix(in srgb, var(--warn) 9%, var(--surface)); border-color: color-mix(in srgb, var(--warn) 55%, transparent); border-radius: var(--radius-sm); }
.state { border-radius: var(--radius-sm); background: color-mix(in srgb, var(--accent) 5%, var(--surface)); }
.pill { padding: 3px 11px; display: inline-flex; align-items: center; gap: 6px; }
.pill-live::before, .pill-wait::before, .pill-lost::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill-live::before { box-shadow: 0 0 0 3px color-mix(in srgb, var(--pos) 25%, transparent); }
.chip { padding: 3px 11px; background: var(--surface); }
code { background: color-mix(in srgb, var(--text) 7%, transparent); padding: 1px 5px; border-radius: 5px; }
pre code { background: none; padding: 0; }
details > summary { cursor: pointer; font-weight: 600; }
.notes { color: var(--muted); }
.link:hover { text-decoration: none; }

/* The login and invitation pages. */
.login { margin-top: 10vh; }
.login h1 { font-size: 24px; font-weight: 700; letter-spacing: -0.02em; }
.login .card { padding: 22px; box-shadow: var(--shadow-lg); }

/* Phones and small windows: tighter page, fields that fill the row, tables that scroll sideways rather than push the page. */
@media (max-width: 700px) {
  main, .admin { padding: 12px 12px 32px; }
  .card { padding: 12px 14px; border-radius: 10px; }
  .admin .row > label, .admin .row > .field { flex: 1 1 140px; }
  .admin input[type="email"] { min-width: 0; width: 100%; }
  .admin select, .admin input:not([type="checkbox"]):not([type="radio"]) { max-width: 100%; }
  .kpi .value { font-size: 20px; }
  table { display: block; overflow-x: auto; max-width: 100%; }
  .scroll > table { display: table; overflow: visible; max-width: none; } /* inside a .scroll box the box scrolls (it is focusable, so a keyboard can reach it), not the table */
  .bar .brand .muted { display: none; }
  .bar .status #age { display: none; }
  .bar .status { flex-wrap: nowrap; gap: 8px; }
  .bar .status #who { max-width: 130px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .bar { position: static; } /* a tall header would take a phone's screen: it scrolls away */
}

@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; scroll-behavior: auto !important; } }

/* Choices and text areas: a radio or box sits beside its words, and a text area takes the width of its row. */
.admin input[type="radio"], .admin input[type="checkbox"] { display: inline-block; width: auto; margin: 0 7px 0 0; padding: 0; vertical-align: middle; }
.admin label:has(> input[type="radio"]), .admin label:has(> input[type="checkbox"]) { display: inline-flex; align-items: center; margin-right: 16px; color: var(--text); font-size: 14px; font-weight: 400; }
.admin label:has(> input[type="radio"]) input:not([type="radio"]) { margin: 0 0 0 8px; }
.admin textarea { display: block; width: 100%; min-height: 84px; margin-top: 4px; padding: 9px 10px; resize: vertical; line-height: 1.45; }
fieldset { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 8px 14px 10px; }
legend { padding: 0 6px; color: var(--muted); font-size: 12px; font-weight: 600; }
fieldset.intents { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 4px; }
