:root {
  color: #16221c;
  background: #f2f5ef;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
  --ink: #16221c;
  --muted: #657168;
  --line: #d8ded8;
  --paper: #fffef9;
  --green: #174f38;
  --green-soft: #dcebe1;
  --amber: #c97724;
  --red: #a54032;
  --blue: #315d80;
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; min-height: 100vh; }
button, input, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: var(--green); }
[hidden] { display: none !important; }

.skip-link { position: fixed; left: 1rem; top: -4rem; z-index: 20; background: var(--ink); color: white; padding: .65rem 1rem; }
.skip-link:focus { top: 1rem; }
.centered-card { width: min(520px, calc(100% - 2rem)); margin: 12vh auto; padding: 3rem; text-align: center; background: var(--paper); border: 1px solid var(--line); border-radius: 22px; box-shadow: 0 18px 55px rgba(32, 50, 40, .09); }
.brand-mark { display: inline-grid; place-items: center; width: 62px; height: 62px; border-radius: 18px; color: white; background: var(--green); font: 700 1.75rem/1 Georgia, serif; }
.brand-mark.small { width: 34px; height: 34px; border-radius: 10px; font-size: 1rem; }
.eyebrow { margin: 1.5rem 0 .5rem; color: var(--green); font-size: .72rem; font-weight: 800; letter-spacing: .16em; }
h1, h2, h3 { font-family: Georgia, "Times New Roman", serif; color: var(--ink); }
h1 { margin: .25rem 0 .65rem; font-size: clamp(2rem, 5vw, 3.2rem); font-weight: 500; }
h2 { margin: 0; font-size: 1.35rem; font-weight: 600; }
h3 { margin: 0 0 .75rem; font-size: 1.05rem; }
p { color: var(--muted); line-height: 1.55; }
.lede { font-size: 1.05rem; }

.primary-button, .secondary-button, .text-button, .link-button { display: inline-flex; align-items: center; justify-content: center; min-height: 42px; border-radius: 999px; padding: .65rem 1.1rem; cursor: pointer; text-decoration: none; }
.primary-button { border: 1px solid var(--green); color: white; background: var(--green); font-weight: 700; }
.primary-button:disabled { cursor: not-allowed; opacity: .45; }
.secondary-button { border: 1px solid var(--line); color: var(--ink); background: var(--paper); font-weight: 700; }
.text-button { border: 0; color: var(--green); background: transparent; padding-inline: .45rem; }
.error-message { padding: .8rem 1rem; border: 1px solid #e2b7b0; border-radius: 10px; color: var(--red); background: #fff4f1; }

.app-header { position: sticky; top: 0; z-index: 10; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; min-height: 68px; padding: .75rem clamp(1rem, 4vw, 3.5rem); border-bottom: 1px solid var(--line); background: rgba(255, 254, 249, .96); backdrop-filter: blur(12px); }
.brand { display: inline-flex; gap: .7rem; align-items: center; color: var(--ink); font: 600 1.15rem Georgia, serif; text-decoration: none; }
nav { display: flex; gap: 1.5rem; }
nav a { padding: .55rem .25rem; color: var(--muted); font-size: .9rem; font-weight: 700; text-decoration: none; border-bottom: 2px solid transparent; }
nav a[aria-current="page"] { color: var(--green); border-bottom-color: var(--green); }
.account-area { display: flex; justify-content: flex-end; gap: .75rem; align-items: center; color: var(--muted); font-size: .82rem; }
.global-status { margin: 1rem auto 0; width: min(1400px, calc(100% - 2rem)); padding: .7rem 1rem; border-radius: 10px; color: var(--blue); background: #e9f1f6; }

.page { width: min(1400px, calc(100% - 2rem)); margin: 0 auto; padding: 3rem 0 5rem; }
.page.narrow { width: min(760px, calc(100% - 2rem)); }
.page-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 2rem; margin-bottom: 2rem; }
.page-heading.compact { margin-bottom: 1.25rem; }
.page-heading .eyebrow { margin-top: 0; }
.page-heading p { margin-bottom: 0; }
.breadcrumbs { display: flex; gap: .6rem; color: var(--muted); font-size: .85rem; margin-bottom: 1.5rem; }

.table-card, .detail-card, .form-card, .preview-card { background: var(--paper); border: 1px solid var(--line); border-radius: 16px; overflow: hidden; }
.table-card { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: .85rem 1rem; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
th { color: var(--muted); font-size: .72rem; letter-spacing: .06em; text-transform: uppercase; background: #f7f8f4; }
td { font-size: .88rem; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr[data-action] { cursor: pointer; }
tbody tr[data-action]:hover, tbody tr[data-selected="true"] { background: var(--green-soft); }
.run-link { font-weight: 700; text-decoration: none; }
.metric { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.empty-state { padding: 4rem 2rem; text-align: center; border: 1px dashed #b8c2b9; border-radius: 16px; }

.metric-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; margin-bottom: 1.25rem; }
.metric-card { padding: 1.25rem; background: var(--paper); border: 1px solid var(--line); border-radius: 14px; }
.metric-card span { display: block; color: var(--muted); font-size: .75rem; font-weight: 800; letter-spacing: .09em; }
.metric-card strong { display: block; margin-top: .45rem; font: 500 2rem Georgia, serif; font-variant-numeric: tabular-nums; }
.metric-card small { color: var(--muted); }
.report-layout { display: grid; grid-template-columns: minmax(480px, .9fr) minmax(480px, 1.1fr); gap: 1.25rem; align-items: start; }
.item-list-card { max-height: 72vh; }
.card-heading { padding: 1.1rem 1rem .65rem; }
.card-heading p { margin: .25rem 0 0; }
.pagination { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .75rem 1rem; border-top: 1px solid var(--line); }
.detail-card { min-height: 360px; padding: 1.4rem; }
.empty-detail { padding: 4rem 1rem; text-align: center; }
.detail-section { margin-top: 1.4rem; padding-top: 1.4rem; border-top: 1px solid var(--line); }
.transcript-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.transcript-panel { padding: 1rem; border-radius: 12px; background: #f7f8f4; }
.transcript-panel p { color: var(--ink); white-space: pre-wrap; overflow-wrap: anywhere; }
.transcript-panel small { display: block; color: var(--muted); white-space: pre-wrap; overflow-wrap: anywhere; }
.operation { display: grid; grid-template-columns: 110px 1fr 24px 1fr; gap: .5rem; padding: .55rem 0; border-bottom: 1px solid var(--line); font-size: .82rem; }
.operation:last-child { border-bottom: 0; }
.operation-kind { color: var(--amber); font-weight: 800; text-transform: capitalize; }
.timeline { display: grid; gap: .85rem; }
.timeline-row { display: grid; grid-template-columns: 90px 1fr; gap: .75rem; align-items: center; }
.timeline-track { position: relative; min-height: 38px; overflow: hidden; border-radius: 8px; background: #edf0ea; }
.timeline-segment { position: absolute; height: 26px; min-width: 2px; overflow: hidden; padding: .3rem .35rem; border-radius: 5px; color: white; background: var(--blue); font-size: .68rem; white-space: nowrap; }
.timeline-row.production .timeline-segment { background: var(--amber); }
.speaker-mapping { display: grid; gap: .5rem; }
.speaker-mapping-row { display: grid; grid-template-columns: minmax(0, 1fr) 24px minmax(0, 1fr); gap: .5rem; align-items: center; }
.speaker-mapping-row::before { content: "→"; grid-column: 2; grid-row: 1; color: var(--muted); text-align: center; }
.speaker-mapping-row dt { grid-column: 1; overflow-wrap: anywhere; }
.speaker-mapping-row dd { grid-column: 3; margin: 0; overflow-wrap: anywhere; }
.fact-grid, .preview-card dl { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .65rem 1rem; }
.fact { padding: .75rem; border-radius: 10px; background: #f7f8f4; }
.fact dt, .preview-card dt { color: var(--muted); font-size: .72rem; }
.fact dd, .preview-card dd { margin: .25rem 0 0; font-weight: 700; font-variant-numeric: tabular-nums; }

.form-card { display: grid; gap: 1.4rem; padding: 1.5rem; margin-bottom: 1rem; overflow: visible; }
.field { display: grid; gap: .45rem; }
.field > span { font-weight: 750; }
.field small { color: var(--muted); }
.field input, .field select { width: 100%; min-height: 46px; padding: .7rem .8rem; border: 1px solid #bfc8bf; border-radius: 10px; color: var(--ink); background: white; }
.field input:focus, .field select:focus, button:focus-visible, a:focus-visible { outline: 3px solid rgba(49, 93, 128, .28); outline-offset: 2px; }
.preview-card { padding: 1rem; background: #f7f8f4; }
.preview-card dl { margin-bottom: 0; }

@media (max-width: 980px) {
  .app-header { grid-template-columns: 1fr auto; }
  .app-header nav { grid-row: 2; grid-column: 1 / -1; justify-content: center; }
  .account-area { grid-column: 2; }
  .report-layout { grid-template-columns: 1fr; }
  .item-list-card { max-height: none; }
}

@media (max-width: 680px) {
  .centered-card { margin-top: 5vh; padding: 2rem 1.25rem; }
  .app-header { padding-inline: 1rem; }
  .account-area span { display: none; }
  .page { padding-top: 2rem; }
  .page-heading { align-items: flex-start; flex-direction: column; gap: 1rem; }
  .metric-grid { grid-template-columns: 1fr; }
  .transcript-grid, .fact-grid, .preview-card dl { grid-template-columns: 1fr; }
  .operation { grid-template-columns: 1fr 1fr; }
  .operation .arrow { display: none; }
}
