/* System stack only, per #204 Phase 1 proposal. No remote or self-hosted font. */

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

/* Neutral defaults for a page with no entity stylesheet (the sign-in pages). Without them every var() below was
   undefined there, so the email box had no border and the button no background (Andrew, unit 2 review). The entity
   stylesheets (ibi.css, uma.css) load after this file and replace them. */
:root {
  --ink: #1f2933;
  --muted: #45525e;
  --page: #f4f6f8;
  --glow: #e9edf1;
  --accent-glow: rgba(31, 41, 51, 0.08);
  --surface: #ffffff;
  --soft: #e4e9ee;
  --brand: #1f4e79;
  --brand-hi: #2c6aa0;
  --on-brand: #ffffff;
  --accent: #1f4e79;
  --line: #c9d2db;
  --edge: #4a5a6a;
  --shadow: rgba(20, 30, 40, 0.12);
  --focus: #1f4e79;
  --error: #7a1f1f;
  --error-bg: #fdecec;
}

html { font: 400 1.0625rem/1.5 system-ui, sans-serif; }

body {
  margin: 0;
  color: var(--ink);
  background-color: var(--page);
  background-image: radial-gradient(ellipse 55% 32% at 0% 0%, var(--accent-glow), transparent 70%);
  background-repeat: no-repeat;
  background-attachment: fixed;
}

.skip {
  position: absolute;
  left: 1rem;
  top: 1rem;
  transform: translateY(-160%);
  background: var(--brand);
  color: var(--on-brand);
  padding: 0.6rem 0.9rem;
  border-radius: 999px;
  z-index: 4;
}
.skip:focus { transform: none; }

.brand-bar {
  background: linear-gradient(105deg, var(--surface), var(--soft));
  border-bottom: 4px solid var(--accent);
  box-shadow: 0 10px 28px var(--shadow);
}
.brand-inner,
.nav-wrap,
main { width: min(72rem, calc(100% - 1.5rem)); margin: 0 auto; }
.brand-inner {
  display: flex;
  align-items: center;
  gap: 1rem;
  min-height: 5.5rem;
  padding: 0.75rem 0;
}
.logo {
  height: 3.5rem;
  width: auto;
  max-width: 100%;
  object-fit: contain;
  object-position: left center;
  flex: 0 0 auto;
}
@media (min-width: 48rem) {
  .logo { height: 4.5rem; }
}

.wordmark {
  margin: 0;
  font-size: 1.75rem;
  line-height: 1.1;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--accent);
}
.entity { margin: 0.15rem 0 0; font-size: 1.1rem; line-height: 1.2; font-weight: 700; color: var(--ink); }
.note { margin: 0.25rem 0 0; color: var(--muted); }

.nav-wrap { padding: 0.75rem 0 0; }
.nav { display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 0 0 0.6rem; }
.nav a {
  min-height: 2.75rem;
  display: inline-flex;
  align-items: center;
  text-decoration: none;
  color: var(--accent);
  background: var(--surface);
  border: 1px solid var(--edge);
  border-radius: 999px;
  padding: 0.35rem 0.85rem;
  font-weight: 700;
}
.nav a[aria-current="page"] {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.mobile-only { display: block; margin: 0 0 0.5rem; }
.mobile-only summary {
  min-height: 2.75rem;
  display: inline-flex;
  align-items: center;
  font-weight: 700;
  color: var(--accent);
  cursor: pointer;
}
.desk-only { display: none; }

.band {
  display: grid;
  gap: 0.35rem;
  margin: 0 0 1rem;
  padding: 1.25rem 1.35rem;
  border-radius: 1.25rem;
  color: #fff;
  background:
    radial-gradient(circle at 90% 20%, var(--accent-glow), transparent 40%),
    linear-gradient(120deg, var(--accent), var(--brand));
  box-shadow: 0 16px 36px var(--shadow);
}
.band .kicker { margin: 0; font-size: 0.8rem; letter-spacing: 0.08em; text-transform: uppercase; font-weight: 700; }
.band .figure { margin: 0; font-size: clamp(1.8rem, 3vw, 2.6rem); line-height: 1.1; font-weight: 700; }
.band p { margin: 0; }

.layout { display: grid; gap: 1rem; }
.stage-main h1 { margin: 0 0 0.75rem; color: var(--accent); }
h1 { font-size: clamp(1.7rem, 2vw, 2.15rem); line-height: 1.15; }
h2 { font-size: 1.2rem; margin: 0 0 0.6rem; color: var(--accent); }

.card, .hero {
  background: var(--surface);
  border: 1px solid var(--edge);
  border-radius: 1rem;
  padding: 1.15rem;
  margin: 0 0 1rem;
  box-shadow: 0 1px 0 #fff, 0 14px 32px var(--shadow);
}
.reading, form.card, .lock-card { max-width: 40rem; }
.hero { display: grid; gap: 1rem; }
.hero p.pill-row { margin: 0 0 0.9rem; }
.lock-card, .lock-card p:first-child { margin-top: 0; }

.rail {
  background: var(--surface);
  border-radius: 1rem;
  padding: 1rem;
  border: 1px solid var(--edge);
  box-shadow: 0 14px 32px var(--shadow);
}
.rail a { display: block; min-height: 2.75rem; font-weight: 700; }

label { display: block; font-weight: 700; margin: 0 0 0.35rem; }
input, select, textarea, button { width: 100%; max-width: 100%; margin: 0 0 0.8rem; font: inherit; color: inherit; }
input, select, textarea {
  min-height: 2.75rem;
  padding: 0.55rem 0.8rem;
  border: 2px solid var(--edge);
  border-radius: 0.8rem;
  background: #fff;
}
button, .actions a { font-weight: 700; }
button {
  min-height: 2.75rem;
  border: 0;
  border-radius: 0.8rem;
  background: linear-gradient(180deg, var(--brand-hi), var(--brand));
  color: var(--on-brand);
  box-shadow: 0 8px 18px var(--shadow);
}
button.is-inert, button:disabled {
  opacity: 1;
  background: var(--surface);
  color: var(--muted);
  border: 2px dashed var(--edge);
  box-shadow: none;
}
.actions { display: flex; flex-wrap: wrap; gap: 0.75rem; margin-top: 1rem; }
.actions a {
  min-height: 2.75rem;
  display: inline-flex;
  align-items: center;
  text-decoration: none;
  background: var(--soft);
  color: var(--accent);
  border: 1px solid var(--edge);
  border-radius: 0.8rem;
  padding: 0.4rem 0.9rem;
}
a { color: var(--accent); }
a:focus, button:focus, input:focus, select:focus, textarea:focus, summary:focus {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}
#error[role="alert"] {
  color: var(--error);
  background: var(--error-bg);
  border: 1px solid var(--error);
  border-radius: 0.8rem;
  padding: 0.75rem 0.9rem;
}
#error[role="alert"]:empty { display: none; }
.state, .state-ok {
  display: inline-flex;
  min-height: 1.75rem;
  align-items: center;
  border-radius: 999px;
  padding: 0.1rem 0.7rem;
  font-weight: 700;
  font-size: 0.875rem;
}
.state { background: var(--soft); color: var(--accent); }
.state-locked { background: #f4e7c8; color: #6a4b00; }
.state-ok { background: #e5f6ea; color: #146c36; }
dl { margin: 0; display: grid; gap: 0.7rem; }
dt { font-size: 0.8125rem; font-weight: 700; letter-spacing: 0.03em; text-transform: uppercase; color: var(--muted); }
dd { margin: 0.1rem 0 0; }

@media (min-width: 800px) {
  .mobile-only { display: none; }
  .desk-only { display: flex; }
  .layout { grid-template-columns: minmax(0, 42rem) minmax(16rem, 22rem); align-items: start; }
  .band { grid-template-columns: auto 1fr auto; align-items: end; gap: 1.5rem; }
  .hero { grid-template-columns: 1.3fr 0.9fr; }
}
@media (prefers-reduced-motion: reduce) {
  .nav a, button { transition: none; }
}

.mobile-only:not([open]) .nav { display: none; }

@media (max-width: 799px) { .band { padding: 0.85rem 1rem; } .band .figure { font-size: 1.6rem; } }

/* Round 6 */
.nav-label.desk-only { display: none; }
.rail a {
  display: inline-flex;
  align-items: center;
  min-height: 2.75rem;
  margin: 0.4rem 0.4rem 0 0;
  padding: 0.35rem 0.85rem;
  text-decoration: none;
  color: var(--accent);
  background: var(--soft);
  border: 1px solid var(--edge);
  border-radius: 999px;
}
@media (max-width: 799px) {
  .brand-inner { flex-direction: column; align-items: flex-start; min-height: 0; }
}
@media (min-width: 800px) {
  .nav-label.desk-only {
    display: block;
    margin: 0.35rem 0 0.4rem;
    color: var(--accent);
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
  }
}

/* Round 6 phone menu */
.menu-button {
  width: 100%;
  min-height: 2.75rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-radius: 0.9rem;
  list-style: none;
}
.menu-button::-webkit-details-marker { display: none; }
.here { font-weight: 700; color: var(--accent); }
.phone-panel, #phone-panel { padding: 0.5rem 0 0.25rem; }
#phone-panel .nav a { min-height: 2.75rem; }
@media (max-width: 799px) {
  .note.desk-only { display: none; }
}

.phone-menu:not([open]) #phone-panel { display: none; }

/* Final touch */
.menu-button {
  justify-content: flex-start;
  gap: 0.6rem;
  text-align: left;
  font-weight: 700;
}
.menu-button::before { content: none; }
.menu-button::after {
  content: "\25BE";
  font-size: 1.15rem;
  line-height: 1;
}
.phone-menu[open] > .menu-button::before { content: none; }
.phone-menu[open] > .menu-button::after { content: "\25B4"; }

/* Payroll test view (#226) */
.table-wrap { overflow-x: auto; max-width: 100%; }
table { border-collapse: collapse; width: 100%; font-size: 0.875rem; }
th, td { border: 1px solid var(--line); padding: 0.4rem 0.6rem; text-align: left; overflow-wrap: anywhere; }
th { background: var(--soft); font-weight: 700; }

/* Readable tables (#654). Inside .table-wrap, cells break only between words, so a table keeps the width its words
   need and the wrapper scrolls it, instead of the shared th/td rule above splitting words letter by letter. The
   wrapper's own width ignores its table (inline-size containment), so a wide table never widens the page: it fills
   its column and scrolls. Page overflow is not hidden anywhere. */
.table-wrap { contain: inline-size; }
.table-wrap th, .table-wrap td { overflow-wrap: normal; }

/* Responsive tables: sticky first column on narrow viewports (#278) */
@media (max-width: 47.99rem) {
  .table-wrap table {
    border-collapse: separate;
    border-spacing: 0;
    min-width: 100%;
  }
  .table-wrap th:first-child,
  .table-wrap td:first-child {
    position: sticky;
    left: 0;
    background: var(--surface);
    z-index: 1;
    box-shadow: 2px 0 4px var(--shadow);
  }
  .table-wrap th:first-child {
    background: var(--soft);
  }
  /* #654: in the review summary list the value column is narrow on phones; slimmer side padding lets a long status
     such as "Returned for correction" fit its column whole, instead of pushing the page 4px wide at 320px. */
  .review-context .state { padding-inline: 0.45rem; }
}

/* #538 phone bottom nav (worker). Phone only; the desktop nav is unchanged. */
.bottom-nav { display: none; }
@media (max-width: 799px) {
  .bottom-nav:not([hidden]) {
    position: sticky; bottom: 0; z-index: 10;
    display: grid; grid-auto-flow: column; grid-auto-columns: 1fr;
    background: var(--surface); border-top: 1px solid var(--edge);
  }
  .bottom-nav a, .bottom-nav summary {
    min-height: 3rem; display: flex; align-items: center; justify-content: center;
    padding: 0.25rem; text-decoration: none; color: var(--accent);
    font-weight: 700; cursor: pointer; list-style: none;
  }
  .bottom-nav summary::-webkit-details-marker { display: none; }
  .bottom-nav [aria-current="page"] { background: var(--accent); color: #fff; }
  .more-sheet { position: relative; }
  .more-items {
    position: absolute; right: 0; bottom: 100%; min-width: 12rem;
    background: var(--surface); border: 1px solid var(--edge); border-radius: 0.75rem 0.75rem 0 0;
  }
  .more-items a { justify-content: flex-start; padding: 0.5rem 1rem; }
}

/* #558 review queue. Information panel has no decision controls. */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr)); gap: 0.5rem; margin: 0.75rem 0; }
.tile { display: block; padding: 0.6rem 0.75rem; border: 1px solid var(--line); border-radius: 0.5rem; text-decoration: none; background: var(--surface); color: var(--ink); }
.tile[aria-current="true"] { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.tile-count { display: block; font-size: 1.5rem; font-weight: 700; }
.filters { display: flex; flex-wrap: wrap; gap: 0.75rem; align-items: end; margin: 0.75rem 0; }
.filters label { display: grid; gap: 0.2rem; font-weight: 700; font-size: 0.875rem; }
.queue-body { display: grid; gap: 1rem; }
.info-panel { border: 1px solid var(--line); border-radius: 0.5rem; padding: 0.75rem 1rem; background: var(--surface); }
.info-panel h3 { margin-top: 0; }
.queue tr.is-selected th, .queue tr.is-selected td { background: var(--soft); }
.sev-block { background: #f8d7d7; color: #7a1010; }
.sev-review { background: #f4e7c8; color: #6a4b00; }
.sev-info { background: #e3edf8; color: #1b4a7a; }
.phone-note { display: none; }
@media (max-width: 799px) { .phone-note { display: block; } }
@media (min-width: 800px) { .queue-body.has-panel { grid-template-columns: minmax(0, 1fr) 18rem; align-items: start; } }

/* #582 full review. Action bar stays inside the main review area. */
.review-context { display: grid; grid-template-columns: max-content 1fr; gap: 0.25rem 1rem; margin: 0.75rem 0; }
.review-context dt { font-weight: 700; }
.review-context dd { margin: 0; }
.issue-list { padding-left: 1.25rem; }
.issue-list li { margin-bottom: 0.75rem; }
.action-bar { margin-top: 1rem; padding: 0.75rem 1rem; border: 1px solid var(--line); border-radius: 0.5rem; background: var(--surface); }

/* #558 Return for correction preview (non-live). Whole row tappable. */
.return-preview { margin: 0.75rem 0; }
.return-preview .radio-row { display: flex; align-items: center; gap: 0.5rem; min-height: 2.5rem; }
.return-preview textarea { width: 100%; box-sizing: border-box; }

/* #659 light desktop shell (visual only). At 800px and up the brand bar and grouped navigation sit in an anchored,
   independently scrolling sidebar, with a breadcrumb top bar above the workspace. Below 800px nothing here applies:
   the phone shell, menu and bottom nav are unchanged. The links, their filtering and their order come from the frame. */
.topbar { display: none; }
.nav-label { margin: 0.35rem 0 0.4rem; color: var(--muted); font-size: 0.75rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; }
.crumbs { display: flex; flex-wrap: wrap; gap: 0.25rem 0.5rem; margin: 0; padding: 0; list-style: none; }
.crumbs li + li::before { content: "/"; margin-right: 0.5rem; color: var(--muted); }
.crumb-here { font-weight: 700; color: var(--ink); }

@media (min-width: 800px) {
  body:has(.shell-side) {
    display: grid;
    grid-template-columns: 16rem minmax(0, 1fr);
    grid-template-rows: auto 1fr;
    align-items: start;
    min-height: 100vh;
  }
  .shell-side {
    grid-column: 1;
    grid-row: 1 / span 2;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    overscroll-behavior: contain;
    background: var(--surface);
    border-right: 1px solid var(--edge);
  }
  .shell-side .brand-bar { background: transparent; border-bottom: 1px solid var(--edge); box-shadow: none; }
  .shell-side .brand-inner { width: auto; margin: 0; padding: 1rem; min-height: 0; flex-direction: column; align-items: flex-start; gap: 0.5rem; }
  .shell-side .logo { height: 3.25rem; }
  .shell-side .nav-wrap { width: auto; margin: 0; padding: 0.75rem 0.75rem 1.5rem; }
  .shell-side .nav { flex-direction: column; flex-wrap: nowrap; gap: 0.15rem; margin: 0; }
  .shell-side .nav-group { display: grid; gap: 0.15rem; margin: 0 0 0.9rem; }
  .shell-side .nav a {
    width: 100%;
    border-radius: 0.6rem;
    border-color: transparent;
    background: transparent;
    padding: 0.35rem 0.75rem;
  }
  .shell-side .nav a:hover { background: var(--soft); }
  .shell-side .nav a[aria-current="page"] { background: var(--accent); color: #fff; border-color: var(--accent); }
  .topbar {
    display: block;
    grid-column: 2;
    grid-row: 1;
    min-width: 0;
    padding: 0.9rem 1.5rem;
    background: var(--surface);
    border-bottom: 1px solid var(--edge);
  }
  body:has(.shell-side) main { grid-column: 2; grid-row: 2; width: auto; min-width: 0; margin: 0; padding: 1.25rem 1.5rem 2rem; }
  /* The sidebar takes 16rem, so the page rail drops below the content until the workspace is wide enough for both. */
  body:has(.shell-side) .layout { grid-template-columns: minmax(0, 1fr); }
}
@media (min-width: 1100px) {
  body:has(.shell-side) .layout { grid-template-columns: minmax(0, 42rem) minmax(14rem, 22rem); }
}

/* #930 review queue on phones and tablets. Layout only: the markup, copy, requests, DOM order and filtering are the
   page's own. The table stays in its own scrolling .table-wrap, so nothing here widens the page. */
.queue caption { text-align: left; }
.queue .queue-period { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.25rem 0.6rem; margin: 0 0 0.5rem; }
.queue .queue-period dd { margin: 0; }
@media (max-width: 47.99rem) {
  /* Two summary tiles per row instead of four stacked ones, and a compact filter block, so the table is reached
     with less scrolling. */
  .queue .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.4rem; margin: 0.5rem 0; }
  .queue .tile { padding: 0.45rem 0.55rem; overflow-wrap: anywhere; }
  .queue .tile-count { font-size: 1.25rem; }
  .queue .filters { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.5rem; align-items: end; }
  .queue .filters label { grid-column: 1 / -1; min-width: 0; margin: 0; }
  .queue .filters input, .queue .filters select, .queue .filters button { margin: 0; min-width: 0; }
}

/* The hours page (unit 2): status lines and the worker's own entries as cards, one per row on a phone. */
.notice, .alert { max-width: 40rem; padding: 0.7rem 0.9rem; border-radius: 0.5rem; border-left: 4px solid; }
.notice { border-color: var(--accent); background: var(--soft); }
.alert { border-color: var(--error); background: var(--error-bg); color: var(--error); }
.entries { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.75rem; max-width: 40rem; }
.entries p { margin: 0 0 0.35rem; }
.entries form button { width: auto; margin: 0.25rem 0; }
label { display: block; font-weight: 600; margin-bottom: 0.25rem; }
.students { border: 1px solid var(--soft); border-radius: 0.5rem; padding: 0.5rem 0.75rem; margin: 0 0 0.75rem; }
.students legend { font-weight: 600; }
.students .check { font-weight: 400; display: flex; gap: 0.5rem; align-items: center; min-height: 2.5rem; }
.students .check input { width: auto; margin: 0; }

/* Sign-in (unit 2 review): a bordered, high-contrast email box and one obvious primary button. */
.signin { max-width: 28rem; padding: 1.1rem 1.2rem; background: var(--surface); border: 1px solid var(--line);
  border-radius: 1rem; box-shadow: 0 8px 22px var(--shadow); }
.signin input[type="email"] { background: #fff; color: #111; border: 2px solid var(--edge); font-size: 1.1rem; }
.signin .primary { font-size: 1.05rem; }
