/* EPHOR component styles. Design tokens (colour, radius, shadow, dark theme)
   live in tokens.css, ported from the Pinax design system. */

body {
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--surface);
  color: var(--text-strong);
  padding: 0.7rem 1rem;
  border-radius: var(--radius-sm);
  z-index: 100;
}
.skip-link:focus { left: 1rem; top: 1rem; }

:is(button, a, input, select, textarea):focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

/* ------------------------------------------------------------------ topbar */

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

/* Wider than the 1120px content column on purpose: the brand, six tabs, and
   the identity block do not fit in 1120px, and sharing the cap made the tab
   row wrap onto a second line. */
.topbar-inner {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0.85rem 1.5rem;
  display: flex;
  align-items: center;
  gap: 1.25rem;
  flex-wrap: wrap;
}

.brand { display: flex; align-items: center; gap: 0.65rem; }

.wordmark {
  font-weight: 800;
  letter-spacing: 0.16em;
  font-size: 0.82rem;
  color: var(--accent);
  text-transform: uppercase;
}

.brand-divider {
  width: 1px;
  height: 1.1rem;
  background: var(--border-strong);
}

.brand-subtitle { color: var(--muted); font-size: 0.82rem; }

/* The wordmark ships at 2560x404. Height is fixed and width derived so it
   scales without ever reflowing the row, and the intrinsic width/height
   attributes in the markup reserve the space before the image decodes. */
.operator-wordmark {
  height: 18px;
  width: auto;
  display: block;
  flex-shrink: 0;
}

.operator-wordmark-topbar { height: 16px; opacity: 0.92; }

/* nowrap plus horizontal scroll: a tab row that wraps reads as a layout bug,
   while one that scrolls reads as a deliberate overflow. */
.tabs {
  display: flex;
  gap: 0.15rem;
  flex: 1;
  /* min-width:0 is load-bearing: without it a flex item refuses to shrink
     below its content width, so overflow-x never engages. */
  min-width: 0;
  flex-wrap: nowrap;
  overflow-x: auto;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab { white-space: nowrap; }

.tab {
  background: none;
  border: none;
  padding: 0.45rem 0.8rem;
  border-radius: var(--radius-sm);
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
}
.tab:hover { background: var(--surface-strong); color: var(--text-strong); }
.tab-active { background: var(--accent-soft); color: var(--accent-strong); font-weight: 600; }

.identity { display: flex; align-items: center; gap: 0.65rem; }

.org-badge {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 0.2rem 0.5rem;
  border-radius: 999px;
  background: var(--navy);
  color: #fff;
}

.identity-name {
  font-size: 0.88rem;
  color: var(--text);
  max-width: 18ch;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ----------------------------------------------------------------- notices */

.notice-rail {
  position: fixed;
  right: 1.25rem;
  bottom: 1.25rem;
  z-index: 60;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  max-width: min(420px, calc(100vw - 2.5rem));
}

.notice {
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
  padding: 0.8rem 2.2rem 0.8rem 0.95rem;
  font-size: 0.88rem;
  position: relative;
  line-height: 1.45;
}
.notice-success { border-left-color: var(--normal); }
.notice-warn { border-left-color: var(--watch); }
.notice-error { border-left-color: var(--intervention); }

.notice-dismiss {
  position: absolute;
  top: 0.35rem;
  right: 0.45rem;
  background: none;
  border: none;
  color: var(--subtle);
  font-size: 1.1rem;
  cursor: pointer;
  line-height: 1;
  padding: 0.2rem 0.35rem;
}

/* ------------------------------------------------------------------- shell */

.shell {
  max-width: 1120px;
  margin: 0 auto;
  padding: 2rem 1.5rem 4rem;
}

.view-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.6rem;
  flex-wrap: wrap;
}

.view-head h1 {
  margin: 0;
  font-size: 1.4rem;
  letter-spacing: -0.01em;
  color: var(--text-strong);
}

.view-subtitle {
  margin: 0.3rem 0 0;
  color: var(--muted);
  font-size: 0.92rem;
  max-width: 62ch;
}

/* ------------------------------------------------------------------- cards */

.day-group { margin-bottom: 2rem; }

.day-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
  margin: 0 0 0.7rem;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  padding-bottom: 0.45rem;
  border-bottom: 1px solid var(--border);
}
.day-heading-attention { color: var(--watch); border-bottom-color: var(--watch); }
.day-count { font-weight: 500; letter-spacing: 0; text-transform: none; color: var(--subtle); }

.card-list { display: flex; flex-direction: column; gap: 0.7rem; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.05rem 1.2rem;
  box-shadow: var(--shadow-sm);
}
.card-attention { border-color: var(--watch); background: var(--watch-soft); }
.card-cancelled { opacity: 0.65; }

.card-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
}

.card-head-right {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.card-title {
  margin: 0 0 0.3rem;
  font-size: 1.02rem;
  color: var(--text-strong);
  font-weight: 600;
}

.card-meta {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 0.87rem;
}
.dot { color: var(--subtle); }

.card-notes {
  margin: 0.65rem 0 0;
  font-size: 0.88rem;
  color: var(--text);
}

.card-observer {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0.7rem 0 0;
  font-size: 0.88rem;
  flex-wrap: wrap;
}

.reference {
  font-variant-numeric: tabular-nums;
  font-size: 0.78rem;
  color: var(--subtle);
  letter-spacing: 0.03em;
}

.observer-line {
  display: flex;
  gap: 0.45rem;
  flex-wrap: wrap;
  margin-top: 0.75rem;
  padding-top: 0.7rem;
  border-top: 1px dashed var(--border);
}

.observer-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.83rem;
  color: var(--text);
}

.you-badge {
  font-size: 0.74rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--accent-strong);
  background: var(--accent-soft);
  padding: 0.16rem 0.45rem;
  border-radius: 999px;
}

.attention-line {
  margin: 0.7rem 0 0;
  font-size: 0.88rem;
  color: var(--watch);
  font-weight: 500;
}

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

.outcome-block {
  margin-top: 0.85rem;
  padding: 0.75rem 0.9rem;
  background: var(--surface-soft);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.outcome-row {
  display: flex;
  gap: 0.6rem;
  font-size: 0.88rem;
  padding: 0.12rem 0;
}

.outcome-label {
  color: var(--muted);
  min-width: 6.5rem;
  font-size: 0.83rem;
}

.outcome-flag { color: var(--intervention); font-weight: 600; }

.outcome-note {
  margin: 0.5rem 0 0;
  font-size: 0.87rem;
  color: var(--text);
  line-height: 1.5;
}

/* ------------------------------------------------------------------- pills */

.pill {
  display: inline-flex;
  align-items: center;
  font-size: 0.73rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 0.2rem 0.5rem;
  border-radius: 999px;
  white-space: nowrap;
}
.pill-confirmed { background: var(--normal-soft); color: var(--normal); }
.pill-needs_reconfirm { background: var(--watch-soft); color: var(--watch); }
.pill-awaiting_close { background: var(--accent-soft); color: var(--accent-strong); }
.pill-closed { background: var(--surface-strong); color: var(--muted); }
.pill-released { background: var(--intervention-soft); color: var(--intervention); }

/* ----------------------------------------------------------------- buttons */

.button {
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text-strong);
  border-radius: var(--radius-sm);
  padding: 0.5rem 0.9rem;
  font-size: 0.87rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.12s ease, border-color 0.12s ease;
}
.button:hover:not(:disabled) { background: var(--surface-strong); }
.button:disabled { opacity: 0.55; cursor: not-allowed; }

.button-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.button-primary:hover:not(:disabled) { background: var(--accent-strong); border-color: var(--accent-strong); }

.button-quiet { background: none; border-color: transparent; color: var(--muted); font-weight: 500; }
.button-quiet:hover:not(:disabled) { background: var(--surface-strong); color: var(--text-strong); }

.button-danger { background: var(--intervention); border-color: var(--intervention); color: #fff; }
.button-danger-quiet { background: none; border-color: transparent; color: var(--intervention); font-weight: 500; }
.button-danger-quiet:hover:not(:disabled) { background: var(--intervention-soft); }

.button-block { width: 100%; padding: 0.7rem; }

/* ------------------------------------------------------------------ panels */

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.35rem 1.5rem;
  box-shadow: var(--shadow-sm);
  margin-bottom: 1.1rem;
}
.panel-flush { padding: 0; overflow: hidden; }
.panel-centered { max-width: 460px; margin: 3rem auto; }

.panel-title { margin: 0 0 0.75rem; font-size: 1rem; color: var(--text-strong); }

.field { display: flex; flex-direction: column; gap: 0.3rem; margin-bottom: 0.85rem; }

.field label { font-size: 0.83rem; color: var(--muted); font-weight: 500; }

.field-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 0 0.9rem;
}

.field-row { margin-bottom: 0.85rem; }

.field-help {
  font-size: 0.84rem;
  color: var(--muted);
  line-height: 1.55;
  margin: 0 0 0.9rem;
  max-width: 70ch;
}

input[type="text"], input[type="date"], input[type="time"], input[type="email"],
input[type="password"], select, textarea {
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 0.55rem 0.7rem;
  background: var(--surface);
  color: var(--text-strong);
  font-size: 0.92rem;
  width: 100%;
}
textarea { resize: vertical; font-family: inherit; }

.csv-input {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.82rem;
  margin-bottom: 0.9rem;
}

.file-input { font-size: 0.86rem; }

.copy-row { display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; }
.copy-input {
  flex: 1;
  min-width: 240px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.8rem;
  color: var(--muted);
}

.credential {
  background: var(--surface-strong);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 0.8rem 1rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.95rem;
  color: var(--text-strong);
  user-select: all;
  margin: 0 0 0.9rem;
}

/* ------------------------------------------------------------------ tables */

.table { width: 100%; border-collapse: collapse; font-size: 0.89rem; }
.table th {
  text-align: left;
  padding: 0.7rem 1rem;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  border-bottom: 1px solid var(--border);
}
.table td { padding: 0.75rem 1rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: none; }
.person-name { color: var(--text-strong); font-weight: 500; }
.person-username { color: var(--subtle); font-size: 0.8rem; }
.row-actions { display: flex; gap: 0.3rem; justify-content: flex-end; }

/* ---------------------------------------------------------------- activity */

.activity-list {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.activity-row {
  display: grid;
  grid-template-columns: 3.75rem 5.5rem 1fr auto;
  gap: 0.85rem;
  align-items: baseline;
  padding: 0.6rem 1.1rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.88rem;
}
.activity-row:last-child { border-bottom: none; }

.activity-time {
  color: var(--subtle);
  font-variant-numeric: tabular-nums;
  font-size: 0.82rem;
}

.org-tag {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  padding: 0.14rem 0.4rem;
  border-radius: 999px;
  text-align: center;
  justify-self: start;
}
.org-tag-bcaa { background: var(--accent-soft); color: var(--accent-strong); }
.org-tag-bermudair { background: var(--surface-strong); color: var(--muted); }
.org-tag-system { background: var(--surface-strong); color: var(--subtle); }

.activity-body { display: flex; flex-direction: column; gap: 0.1rem; min-width: 0; }
.activity-action { color: var(--text-strong); }
.activity-detail { color: var(--muted); font-size: 0.82rem; }
.activity-actor { color: var(--subtle); font-size: 0.8rem; text-align: right; white-space: nowrap; }

@media (max-width: 720px) {
  .activity-row { grid-template-columns: 3.5rem 1fr; row-gap: 0.3rem; }
  .activity-actor { grid-column: 2; text-align: left; }
  .org-tag { grid-column: 2; }
}

/* ------------------------------------------------------------------ import */

.import-results { margin-top: 1.1rem; }

.plan-summary {
  display: flex;
  gap: 1.2rem;
  flex-wrap: wrap;
  padding: 0.85rem 1rem;
  background: var(--surface-soft);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  margin-bottom: 1rem;
}
.plan-stat { font-size: 0.87rem; color: var(--muted); }
.plan-stat strong { color: var(--text-strong); font-size: 1.05rem; margin-right: 0.25rem; }
.plan-stat-error strong { color: var(--intervention); }

.plan-block {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.9rem 1.1rem;
  margin-bottom: 0.85rem;
}
.plan-block h3 { margin: 0 0 0.5rem; font-size: 0.92rem; color: var(--text-strong); }
.plan-block ul { margin: 0; padding-left: 1.1rem; font-size: 0.86rem; color: var(--text); }
.plan-block li { padding: 0.12rem 0; }
.plan-block-error { border-color: var(--intervention); background: var(--intervention-soft); }
.plan-block-warn { border-color: var(--watch); background: var(--watch-soft); }
.plan-note { font-size: 0.85rem; color: var(--text); margin: 0 0 0.6rem; }
.plan-commit { margin-top: 1rem; }

/* ------------------------------------------------------------------ modals */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(12, 20, 24, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  z-index: 50;
}
.modal-backdrop[hidden] { display: none; }

.modal {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  width: min(560px, 100%);
  max-height: 86vh;
  display: flex;
  flex-direction: column;
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.1rem 1.4rem;
  border-bottom: 1px solid var(--border);
}
.modal-head h2 { margin: 0; font-size: 1.05rem; color: var(--text-strong); }

.modal-body { padding: 1.3rem 1.4rem; overflow-y: auto; }

.dialog-lead { margin: 0 0 0.9rem; font-size: 0.94rem; color: var(--text); line-height: 1.55; }

.dialog-warning {
  margin: 0 0 0.9rem;
  padding: 0.7rem 0.9rem;
  background: var(--watch-soft);
  border-left: 3px solid var(--watch);
  border-radius: var(--radius-sm);
  font-size: 0.87rem;
  color: var(--text);
  line-height: 1.5;
}

.history-item {
  border-left: 2px solid var(--border-strong);
  padding: 0.5rem 0 0.7rem 0.85rem;
  margin-bottom: 0.2rem;
}
.history-head { display: flex; justify-content: space-between; gap: 0.8rem; flex-wrap: wrap; font-size: 0.87rem; }
.history-when { color: var(--subtle); font-size: 0.8rem; }
.history-body { font-size: 0.85rem; color: var(--muted); margin-top: 0.2rem; line-height: 1.5; }
.history-note { font-size: 0.83rem; color: var(--subtle); margin-top: 0.2rem; font-style: italic; }

/* ------------------------------------------------------------------- empty */

.empty {
  text-align: center;
  padding: 3.5rem 1.5rem;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface-soft);
}
.empty-title { margin: 0 0 0.4rem; font-size: 1rem; font-weight: 600; color: var(--text-strong); }
.empty-body { margin: 0; color: var(--muted); font-size: 0.9rem; max-width: 46ch; margin-inline: auto; }

/* -------------------------------------------------------------------- auth */

.auth-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 1.5rem; }

.auth-shell { width: min(400px, 100%); }

.auth-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  padding: 2rem 1.9rem;
}
/* The operator wordmark leads, then a hairline, then EPHOR. */
.auth-brand {
  display: flex;
  justify-content: center;
  padding-bottom: 1.15rem;
  margin-bottom: 1.35rem;
  border-bottom: 1px solid var(--border);
}
.auth-brand .operator-wordmark { height: 19px; }
.auth-wordmark { text-align: center; }

.auth-card h1 {
  margin: 0.45rem 0 0.5rem;
  text-align: center;
  font-size: 1.4rem;
  line-height: 1.25;
  letter-spacing: -0.015em;
  color: var(--text-strong);
}
.auth-intro {
  margin: 0 0 1.5rem;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.55;
  text-align: center;
}
.auth-card label { display: block; font-size: 0.83rem; color: var(--muted); margin-bottom: 0.3rem; font-weight: 500; }
.auth-card input { margin-bottom: 0.9rem; }
.auth-footer {
  margin-top: 1.5rem;
  padding-top: 1.05rem;
  border-top: 1px solid var(--border);
}
.auth-footnote {
  margin: 0;
  text-align: center;
  font-size: 0.73rem;
  line-height: 1.5;
  color: var(--subtle);
}

.password-field { position: relative; }
.password-field input { padding-right: 4rem; }
.password-field button {
  position: absolute;
  right: 0.4rem;
  top: 0.35rem;
  background: none;
  border: none;
  color: var(--muted);
  font-size: 0.8rem;
  cursor: pointer;
  padding: 0.3rem 0.5rem;
  font-weight: 600;
}

.form-error {
  background: var(--intervention-soft);
  color: var(--intervention);
  border-radius: var(--radius-sm);
  padding: 0.6rem 0.8rem;
  font-size: 0.86rem;
  margin: 0 0 0.9rem;
}

/* ------------------------------------------------------------- responsive */

@media (max-width: 720px) {
  .topbar-inner { padding: 0.75rem 1rem; gap: 0.75rem; }
  .brand-subtitle, .brand-divider { display: none; }
  /* flex-basis 100%, not width: the base rule sets `flex: 1`, whose 0% basis
     wins over width and leaves the tab row sharing a line with the identity
     block, scrolled off the right edge. */
  .tabs { order: 3; flex: 1 0 100%; overflow-x: auto; }
  .identity { flex: 1; justify-content: flex-start; }
  .shell { padding: 1.5rem 1rem 3rem; }
  .card-head { flex-direction: column; gap: 0.5rem; }
  .card-head-right { justify-content: flex-start; }
  .row-actions { justify-content: flex-start; }
  .notice-rail { right: 1rem; left: 1rem; bottom: 1rem; max-width: none; }
  .table { display: block; overflow-x: auto; }
}

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