/* The one hand-written stylesheet (SPEC §2.1). Class names stay generic (S24). */

/* --- Design tokens --------------------------------------------------------- */

:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #f0f2f5;
  --surface-3: #e7eaef;
  --border: #e1e5eb;
  --border-strong: #c9d0da;
  --text: #19212c;
  --muted: #5a6575;
  --faint: #8b95a4;

  --primary: #3454d1;
  --primary-hover: #2a46b5;
  --primary-soft: #eef2ff;
  --primary-text: #2a43a8;

  --danger: #c0262d;
  --danger-soft: #fff1f1;
  --danger-border: #f4c4c6;
  --warning: #9a5600;
  --warning-soft: #fff6e6;
  --warning-border: #f3d9a8;
  --ok: #26803a;
  --ok-soft: #edf9f0;
  --ok-border: #bfe5c8;

  --radius: 8px;
  --radius-lg: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.05), 0 1px 3px rgba(16, 24, 40, 0.07);
  --shadow-pop: 0 10px 28px rgba(16, 24, 40, 0.14), 0 2px 6px rgba(16, 24, 40, 0.08);
  --focus: 0 0 0 3px rgba(52, 84, 209, 0.3);
  --control-height: 2.35rem;

  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
}

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

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
}

h1,
h2,
h3 {
  line-height: 1.25;
  margin: 0 0 0.5rem;
}

h1 {
  font-size: 1.55rem;
  font-weight: 700;
}

h2 {
  font-size: 1.05rem;
  font-weight: 650;
}

h3 {
  font-size: 0.95rem;
  font-weight: 650;
}

p {
  margin: 0 0 0.75rem;
}

a {
  color: var(--primary);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

:focus-visible {
  outline: none;
  box-shadow: var(--focus);
  border-radius: 4px;
}

.skip-link {
  position: absolute;
  left: -9999px;
}

.skip-link:focus {
  left: 1rem;
  top: 1rem;
  z-index: 100;
  padding: 0.4rem 0.7rem;
  background: var(--surface);
  border-radius: var(--radius);
}

/* --- Top bar and navigation ------------------------------------------------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.topbar-inner {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  max-width: 82rem;
  margin: 0 auto;
  padding: 0.55rem 1.25rem;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
}

.brand:hover {
  text-decoration: none;
}

.brand-mark {
  display: inline-grid;
  place-items: center;
  width: 1.9rem;
  height: 1.9rem;
  border-radius: 7px;
  background: var(--primary);
  color: #fff;
  font-size: 0.78rem;
  letter-spacing: 0.02em;
}

.tabs {
  display: flex;
  gap: 0.15rem;
  flex: 1;
  overflow-x: auto;
  scrollbar-width: none;
}

.tabs a {
  padding: 0.4rem 0.75rem;
  border-radius: 999px;
  color: var(--muted);
  font-weight: 550;
  white-space: nowrap;
}

.tabs a:hover {
  color: var(--text);
  background: var(--surface-2);
  text-decoration: none;
}

.tabs a[aria-current="page"] {
  color: var(--primary-text);
  background: var(--primary-soft);
}

.avatar {
  display: inline-grid;
  place-items: center;
  width: 1.9rem;
  height: 1.9rem;
  border-radius: 50%;
  background: var(--surface-3);
  color: var(--text);
  font-weight: 700;
  font-size: 0.85rem;
}

/* --- Menus (details/summary, no JavaScript needed) ---------------------------- */

.menu {
  position: relative;
  display: inline-block;
}

.menu > summary {
  list-style: none;
  cursor: pointer;
}

.menu > summary::-webkit-details-marker {
  display: none;
}

.menu-panel {
  position: absolute;
  right: 0;
  top: calc(100% + 0.35rem);
  z-index: 40;
  min-width: 15rem;
  padding: 0.4rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-pop);
  text-align: left;
  white-space: normal;
}

.menu-panel > a,
.menu-panel .menu-item {
  display: flex;
  width: 100%;
  align-items: center;
  justify-content: flex-start;
  min-height: 2.1rem;
  padding: 0.35rem 0.6rem;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
}

.menu-panel > a:hover,
.menu-panel .menu-item:hover {
  background: var(--surface-2);
  text-decoration: none;
}

.menu-panel .menu-item.danger,
.menu-panel > a.danger {
  color: var(--danger);
}

.menu-panel form {
  margin: 0;
}

.menu-label {
  margin: 0;
  padding: 0.35rem 0.6rem;
  color: var(--muted);
  font-size: 0.82rem;
}

.menu-divider {
  height: 1px;
  margin: 0.35rem 0;
  background: var(--border);
}

.menu-inline {
  display: flex;
  gap: 0.4rem;
  padding: 0.35rem 0.4rem;
}

.menu-inline input {
  flex: 1;
  min-width: 0;
}

.user-menu > summary {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.2rem 0.4rem 0.2rem 0.2rem;
  border-radius: 999px;
}

.user-menu > summary:hover {
  background: var(--surface-2);
}

.user-name {
  font-weight: 550;
  font-size: 0.9rem;
}

/* --- Page layout -------------------------------------------------------------- */

.container {
  max-width: 82rem;
  margin: 0 auto;
  padding: 1.5rem 1.25rem 3rem;
}

.page-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 0.75rem 1.5rem;
  margin-bottom: 1.25rem;
}

.page-header h1 {
  margin: 0;
}

.page-header .subtitle {
  margin: 0.2rem 0 0;
  color: var(--muted);
}

.eyebrow {
  display: inline-block;
  margin-bottom: 0.25rem;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.page-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 20rem;
  gap: 1.25rem;
  align-items: start;
}

.layout > * {
  min-width: 0;
}

.stack > * + * {
  margin-top: 1.25rem;
}

/* --- Cards -------------------------------------------------------------------- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}

.card + .card {
  margin-top: 1.25rem;
}

.card-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem 0.6rem;
  padding: 0.85rem 1.1rem;
  border-bottom: 1px solid var(--border);
}

.card-header h2,
.card-header h3 {
  margin: 0;
}

.card-header .spacer {
  flex: 1;
}

.card-body {
  padding: 1rem 1.1rem;
}

.card-empty .card-header {
  border-bottom: 0;
}

.card-danger {
  border-color: var(--danger-border);
}

.card-danger .card-header h2 {
  color: var(--danger);
}

.count {
  display: inline-grid;
  place-items: center;
  min-width: 1.5rem;
  height: 1.35rem;
  padding: 0 0.4rem;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}

.count-alert {
  background: var(--danger-soft);
  color: var(--danger);
}

.empty-note {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

/* --- Stat tiles and stage strip -------------------------------------------------- */

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr));
  gap: 0.85rem;
  margin-bottom: 1rem;
}

.stat {
  display: block;
  padding: 0.9rem 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  color: var(--text);
}

.stat:hover {
  border-color: var(--border-strong);
  text-decoration: none;
}

.stat-value {
  display: block;
  font-size: 1.6rem;
  font-weight: 700;
  line-height: 1.2;
}

.stat-label {
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 550;
}

.stat-alert .stat-value {
  color: var(--danger);
}

.stage-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: 0 0 1.25rem;
  padding: 0;
  list-style: none;
}

.stage-strip a {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.25rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 550;
}

.stage-strip a:hover {
  border-color: var(--border-strong);
  color: var(--text);
  text-decoration: none;
}

.stage-strip strong {
  color: var(--text);
}

/* --- Tables ------------------------------------------------------------------- */

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}

.table th {
  padding: 0.55rem 0.75rem;
  border-bottom: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 650;
  letter-spacing: 0.04em;
  text-align: left;
  text-transform: uppercase;
  white-space: nowrap;
}

.table tbody th {
  padding: 0.65rem 0.75rem;
  color: var(--text);
  font-size: inherit;
  font-weight: 400;
  letter-spacing: normal;
  text-transform: none;
  white-space: normal;
}

.table th a {
  color: inherit;
}

.table td {
  padding: 0.65rem 0.75rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.table tbody tr:last-child td,
.table tbody tr:last-child th {
  border-bottom: 0;
}

.table tbody tr:hover td {
  background: #fafbfc;
}

.table .actions {
  text-align: right;
  white-space: nowrap;
}

.table .num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.cell-main {
  font-weight: 550;
}

.cell-sub {
  display: block;
  color: var(--muted);
  font-size: 0.82rem;
}

.ref {
  display: inline-block;
  padding: 0.05rem 0.4rem;
  border-radius: 5px;
  background: var(--surface-2);
  color: var(--text);
  font-family: var(--mono);
  font-size: 0.82rem;
  font-weight: 600;
  white-space: nowrap;
}

a.ref:hover {
  background: var(--primary-soft);
  color: var(--primary-text);
  text-decoration: none;
}

.row-actions {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

/* --- Buttons ------------------------------------------------------------------- */

button,
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  min-height: var(--control-height);
  padding: 0 0.95rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-weight: 550;
  line-height: 1.2;
  white-space: nowrap;
  cursor: pointer;
}

button:hover,
.btn:hover {
  background: var(--surface-2);
  text-decoration: none;
}

.btn-primary,
button.primary {
  border-color: var(--primary);
  background: var(--primary);
  color: #fff;
}

.btn-primary:hover,
button.primary:hover {
  border-color: var(--primary-hover);
  background: var(--primary-hover);
}

.btn-danger {
  border-color: var(--danger-border);
  color: var(--danger);
}

.btn-danger:hover {
  background: var(--danger-soft);
}

.btn-sm {
  min-height: 1.95rem;
  padding: 0 0.7rem;
  font-size: 0.86rem;
}

.btn-ghost {
  border-color: transparent;
  background: transparent;
  color: var(--muted);
}

.btn-ghost:hover {
  background: var(--surface-2);
  color: var(--text);
}

.btn-icon {
  width: 1.95rem;
  min-height: 1.95rem;
  padding: 0;
  font-size: 1.05rem;
  letter-spacing: 0.05em;
}

/* --- Form controls ------------------------------------------------------------- */

input[type="text"],
input[type="email"],
input[type="url"],
input[type="password"],
input[type="number"],
input[type="date"],
input[type="search"],
input:not([type]),
select,
textarea {
  width: 100%;
  min-height: var(--control-height);
  padding: 0.4rem 0.7rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background-color: var(--surface);
  color: var(--text);
  font: inherit;
  line-height: 1.4;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: var(--focus);
}

select:not([multiple]) {
  appearance: none;
  padding-right: 2.2rem;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='none' stroke='%235a6575' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round' d='M2.5 4.5 6 8l3.5-3.5'/%3E%3C/svg%3E");
  background-position: right 0.75rem center;
  background-repeat: no-repeat;
}

select[multiple] {
  padding: 0.3rem;
}

textarea {
  min-height: 5.5rem;
  resize: vertical;
}

input[type="checkbox"],
input[type="radio"] {
  width: 1rem;
  height: 1rem;
  margin: 0;
  accent-color: var(--primary);
}

.input-sm {
  min-height: 1.95rem !important;
  padding: 0.2rem 0.5rem !important;
  font-size: 0.86rem;
}

/* One field: label, control, help and errors (templates/django/forms/field.html). */
.field {
  margin-bottom: 1rem;
}

.field > label,
.field legend,
.label {
  display: block;
  margin-bottom: 0.3rem;
  font-size: 0.87rem;
  font-weight: 600;
}

.field fieldset {
  margin: 0;
  padding: 0;
  border: 0;
  min-width: 0;
}

.help {
  margin: 0.3rem 0 0;
  color: var(--muted);
  font-size: 0.82rem;
}

.errorlist {
  margin: 0.3rem 0 0;
  padding: 0;
  list-style: none;
  color: var(--danger);
  font-size: 0.85rem;
  font-weight: 550;
}

.field-error input,
.field-error select,
.field-error textarea {
  border-color: var(--danger);
}

.check {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  font-weight: 550;
  cursor: pointer;
}

/* Multiple choices as chips: checkbox lists and radio groups. */
.field fieldset > div {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.field fieldset > div > div {
  display: contents;
}

.field fieldset label {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.3rem 0.7rem;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: var(--surface);
  font-size: 0.86rem;
  font-weight: 500;
  cursor: pointer;
}

.field fieldset label:hover {
  border-color: var(--primary);
}

.field fieldset label:has(input:checked) {
  border-color: var(--primary);
  background: var(--primary-soft);
  color: var(--primary-text);
}

.field fieldset > div.choices-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(4.1rem, 1fr));
  max-height: 10.5rem;
  overflow-y: auto;
  padding: 0.15rem;
}

.field fieldset > div.choices-grid label {
  justify-content: center;
  padding: 0.25rem 0.4rem;
  font-family: var(--mono);
  font-size: 0.8rem;
}

.form-card {
  max-width: 50rem;
}

.layout .form-card {
  max-width: none;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0 1rem;
}

.form-grid .span-2 {
  grid-column: 1 / -1;
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem;
  margin-top: 0.5rem;
}

.form-section {
  margin: 1.25rem 0 0.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.form-section:first-child {
  margin-top: 0;
  padding-top: 0;
  border-top: 0;
}

/* --- Search and filters ----------------------------------------------------------- */

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 1rem;
}

.card-body.toolbar {
  margin-bottom: 0;
}

.toolbar .search {
  flex: 1 1 18rem;
}

.toolbar label {
  font-size: 0.87rem;
  font-weight: 600;
  color: var(--muted);
}

.toolbar select {
  width: auto;
  min-width: 9rem;
}

.filters {
  margin-bottom: 1rem;
}

.filters > summary {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  min-height: var(--control-height);
  padding: 0 0.95rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface);
  font-weight: 550;
  list-style: none;
  cursor: pointer;
}

.filters > summary::-webkit-details-marker {
  display: none;
}

.filters > summary::after {
  content: "▾";
  color: var(--muted);
  font-size: 0.8em;
}

.filters[open] > summary::after {
  content: "▴";
}

.filters-panel {
  margin-top: 0.75rem;
  padding: 1rem 1.1rem 0.25rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}

.filters-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr));
  gap: 0 1.1rem;
}

.filters-grid .wide {
  grid-column: 1 / -1;
}

/* --- Badges, deadlines and notes --------------------------------------------------- */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.12rem 0.55rem;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 650;
  white-space: nowrap;
}

.badge-stage {
  background: #e9eef6;
  color: #34445c;
}

.badge-you {
  background: var(--primary-soft);
  color: var(--primary-text);
}

.badge-them {
  background: var(--surface-2);
  color: var(--muted);
}

.badge-warn {
  background: var(--warning-soft);
  color: var(--warning);
}

.badge-danger {
  background: var(--danger-soft);
  color: var(--danger);
}

.badge-ok {
  background: var(--ok-soft);
  color: var(--ok);
}

.badges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

/* Hard deadlines get the loudest styling, always with words (§6.1). */
.hard-deadline {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.12rem 0.55rem;
  border: 1px solid var(--danger-border);
  border-radius: 999px;
  background: var(--danger-soft);
  color: var(--danger);
  font-size: 0.78rem;
  font-weight: 700;
  white-space: nowrap;
}

.overdue {
  color: var(--danger);
  font-weight: 650;
}

.muted {
  color: var(--muted);
}

.small {
  font-size: 0.85rem;
}

.nowrap {
  white-space: nowrap;
}

.mono {
  font-family: var(--mono);
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* --- Alerts and messages --------------------------------------------------------- */

.alert,
.message {
  margin: 0 0 1rem;
  padding: 0.7rem 0.9rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.alert p:last-child {
  margin-bottom: 0;
}

.alert-error,
.message-error {
  border-color: var(--danger-border);
  background: var(--danger-soft);
  color: #8a1c21;
}

.alert-warn,
.message-warning {
  border-color: var(--warning-border);
  background: var(--warning-soft);
  color: #6f3f00;
}

.alert-ok,
.message-success {
  border-color: var(--ok-border);
  background: var(--ok-soft);
  color: #1d5f2c;
}

.alert-info,
.message-info {
  border-color: #c9d4fb;
  background: var(--primary-soft);
  color: var(--primary-text);
}

.messages {
  margin: 0 0 1.25rem;
  padding: 0;
  list-style: none;
}

/* --- Detail pages ------------------------------------------------------------------ */

.facts {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(13rem, 1fr));
  gap: 0.9rem 1.25rem;
  margin: 0;
}

.facts dt {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 650;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.facts dd {
  margin: 0.15rem 0 0;
}

.facts-list {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 0.45rem 1rem;
  margin: 0;
}

.facts-list dt {
  color: var(--muted);
  font-size: 0.85rem;
}

.facts-list dd {
  margin: 0;
}

.action-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.action-list > li {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem 1rem;
  padding: 0.85rem 1.1rem;
  border-bottom: 1px solid var(--border);
}

.action-list > li:last-child {
  border-bottom: 0;
}

.action-title {
  font-weight: 600;
}

.action-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.3rem 0.6rem;
  margin-top: 0.2rem;
  color: var(--muted);
  font-size: 0.85rem;
}

.timeline {
  margin: 0;
  padding: 0 1.1rem 0 2.2rem;
  list-style: none;
  position: relative;
}

.timeline::before {
  content: "";
  position: absolute;
  left: 1.35rem;
  top: 1.1rem;
  bottom: 1.1rem;
  width: 2px;
  background: var(--border);
}

.timeline > li {
  position: relative;
  padding: 0.85rem 0;
  border-bottom: 1px solid var(--border);
}

.timeline > li:last-child {
  border-bottom: 0;
}

.timeline > li::before {
  content: "";
  position: absolute;
  left: -1.1rem;
  top: 1.2rem;
  width: 0.6rem;
  height: 0.6rem;
  border-radius: 50%;
  background: var(--surface);
  border: 2px solid var(--primary);
}

.timeline-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.3rem 0.6rem;
}

.timeline-meta {
  color: var(--muted);
  font-size: 0.85rem;
}

.notes {
  margin-top: 0.35rem;
  white-space: pre-wrap;
}

.sent-text {
  margin: 0;
  padding: 0.9rem 1rem;
  max-height: 28rem;
  overflow: auto;
  background: var(--surface-2);
  border-radius: var(--radius);
  font-family: var(--font);
  font-size: 0.92rem;
  white-space: pre-wrap;
}

.disclosure > summary {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.85rem 1.1rem;
  font-weight: 650;
  list-style: none;
  cursor: pointer;
}

.disclosure > summary::-webkit-details-marker {
  display: none;
}

.disclosure > summary::before {
  content: "▸";
  color: var(--muted);
  font-size: 0.85em;
}

.disclosure[open] > summary::before {
  content: "▾";
}

.disclosure[open] > summary {
  border-bottom: 1px solid var(--border);
}

/* --- Search results (ingest) ------------------------------------------------------- */

.search-hero {
  max-width: 46rem;
}

.search-hero input[type="search"] {
  min-height: 2.9rem;
  font-size: 1.05rem;
}

.result-list {
  margin: 0.75rem 0 0;
  padding: 0;
  list-style: none;
}

.result-list > li + li {
  margin-top: 0.4rem;
}

.result-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem 0.75rem;
  padding: 0.65rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
}

button.result-row {
  width: 100%;
  justify-content: flex-start;
  min-height: 0;
  font-weight: 400;
  text-align: left;
  white-space: normal;
}

.result-row:hover {
  border-color: var(--primary);
  background: var(--primary-soft);
  text-decoration: none;
}

/* --- Item table in the event form ------------------------------------------------------- */

.item-results .field {
  margin-bottom: 0.4rem;
}

.item-results .field > label {
  font-size: 0.78rem;
  color: var(--muted);
}

.item-row {
  display: grid;
  grid-template-columns: minmax(10rem, 16rem) 1fr;
  gap: 0 1rem;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--border);
}

.item-row textarea {
  min-height: 2.6rem;
}

.item-results select {
  min-width: 14rem;
}

.item-row:last-child {
  border-bottom: 0;
}

.action-rows input,
.action-rows select {
  min-height: 2rem;
  padding: 0.2rem 0.5rem;
  font-size: 0.88rem;
}

.action-rows select:not([multiple]) {
  padding-right: 1.9rem;
}

/* --- Pagination, sticky bar, auth -------------------------------------------------------- */

.pagination {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.75rem 1.1rem;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.88rem;
}

.sticky-bar {
  position: sticky;
  bottom: 0;
  z-index: 20;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  margin-top: 1.25rem;
  padding: 0.75rem 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-pop);
}

.sticky-bar input[type="date"] {
  width: auto;
}

.auth-wrap {
  display: grid;
  place-items: center;
  min-height: 70vh;
}

.auth-card {
  width: 100%;
  max-width: 24rem;
  padding: 1.75rem;
}

.auth-card .brand {
  margin-bottom: 1.25rem;
}

.auth-card button {
  width: 100%;
}

/* --- Small screens ---------------------------------------------------------------------- */

@media (max-width: 64rem) {
  .layout {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 52rem) {
  /* position: relative keeps absolutely positioned children (hidden labels) inside the
     scrolling area; row menus open in place so the scroll box cannot clip them. */
  .table-wrap {
    position: relative;
    overflow-x: auto;
  }

  .table-wrap .menu-panel {
    position: static;
    margin-top: 0.4rem;
    box-shadow: none;
  }

  /* Brand and account on the first row, tabs scrolling on a full-width second row. */
  .topbar-inner {
    flex-wrap: wrap;
    gap: 0.4rem 1rem;
  }

  .user-menu {
    margin-left: auto;
  }

  .tabs {
    order: 3;
    flex-basis: 100%;
  }

  .hide-sm {
    display: none;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }

  .item-row {
    grid-template-columns: 1fr;
  }

  .user-name {
    display: none;
  }
}
