:root {
  color-scheme: light;
  --bg: #f6f7f4;
  --surface: #ffffff;
  --surface-soft: #eef3ef;
  --ink: #18201d;
  --muted: #62706b;
  --line: #d8dfd9;
  --teal: #147b73;
  --teal-strong: #0c5f58;
  --amber: #bd741c;
  --red: #ba3f3f;
  --green: #28744a;
  --shadow: 0 18px 50px rgba(29, 39, 35, 0.12);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  min-width: 320px;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  letter-spacing: 0;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  min-height: 100vh;
}

.auth-gate {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.auth-card {
  width: min(420px, 100%);
  display: grid;
  gap: 12px;
  padding: 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.auth-card h1 {
  margin: 2px 0 8px;
  font-size: 1.5rem;
}

.auth-error {
  margin: 0;
  color: var(--red);
  font-size: 0.9rem;
  font-weight: 700;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 14px clamp(16px, 4vw, 44px);
  background: rgba(246, 247, 244, 0.92);
  border-bottom: 1px solid rgba(216, 223, 217, 0.82);
  backdrop-filter: blur(18px);
}

.brand,
.topbar-actions,
.hero-actions,
.table-actions,
.dialog-heading,
.panel-heading {
  display: flex;
  align-items: center;
}

.brand {
  gap: 12px;
  color: inherit;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 40px;
  height: 40px;
  place-items: center;
  color: white;
  background: var(--teal);
  border-radius: var(--radius);
  box-shadow: 0 10px 24px rgba(20, 123, 115, 0.22);
}

.brand-title,
.brand-subtitle,
.metric-label,
.metric-note,
.eyebrow,
.status-text,
.confidence-label,
.file-meta,
.review-field span,
label span {
  display: block;
}

.brand-title {
  font-size: 0.98rem;
  font-weight: 760;
}

.brand-subtitle {
  color: var(--muted);
  font-size: 0.78rem;
  margin-top: 2px;
}

.topbar-actions {
  gap: 8px;
}

.topbar-actions .icon-button {
  font-weight: 500;
}

.icon-button,
.primary-action,
.secondary-action,
.icon-only {
  border: 1px solid transparent;
  border-radius: var(--radius);
  min-height: 40px;
  transition:
    transform 160ms ease,
    box-shadow 160ms ease,
    border-color 160ms ease,
    background 160ms ease;
}

.icon-button,
.primary-action,
.secondary-action,
.sync-status {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  padding: 0 14px;
  font-size: 0.95rem;
  font-weight: 700;
  white-space: nowrap;
}

.icon-button {
  color: var(--ink);
  background: var(--surface);
  border-color: var(--line);
}

.sync-status {
  min-height: 40px;
  padding: 0 12px;
  color: var(--muted);
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-size: 0.95rem;
  font-weight: 700;
}

.sync-status.shared {
  color: var(--teal-strong);
  background: rgba(20, 123, 115, 0.1);
  border-color: rgba(20, 123, 115, 0.26);
}

.sync-status.error {
  color: var(--amber);
  background: rgba(189, 116, 28, 0.09);
  border-color: rgba(189, 116, 28, 0.28);
}

.primary-action {
  color: white;
  background: var(--teal);
  border-color: var(--teal);
}

.secondary-action {
  color: var(--ink);
  background: var(--surface);
  border-color: var(--line);
}

.icon-only {
  display: grid;
  width: 40px;
  height: 40px;
  place-items: center;
  padding: 0;
  color: var(--muted);
  background: transparent;
}

.icon-button:hover,
.primary-action:hover,
.secondary-action:hover,
.icon-only:hover {
  transform: translateY(-1px);
}

.primary-action:hover {
  background: var(--teal-strong);
  box-shadow: 0 12px 28px rgba(20, 123, 115, 0.22);
}

.secondary-action:hover,
.icon-button:hover {
  border-color: #bbc7c0;
  box-shadow: 0 10px 24px rgba(29, 39, 35, 0.08);
}

svg {
  width: 18px;
  height: 18px;
  stroke-width: 2;
}

main {
  padding: 0 clamp(16px, 4vw, 44px) 44px;
}

.hero-section {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 44vw);
  min-height: clamp(250px, 34vh, 360px);
  overflow: hidden;
  margin: 22px auto 18px;
  background: #17211e;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

/* Hero banner intentionally hidden per UI request. */
.hero-section {
  display: none;
}

.hero-copy {
  position: relative;
  z-index: 2;
  align-self: center;
  padding: clamp(24px, 5vw, 58px);
  color: white;
}

.hero-copy .eyebrow {
  color: #bde7de;
}

.hero-copy h1 {
  max-width: 720px;
  margin: 8px 0 20px;
  font-size: clamp(1.8rem, 4.2vw, 3.8rem);
  line-height: 0.98;
  letter-spacing: 0;
}

.hero-actions {
  gap: 10px;
  flex-wrap: wrap;
}

.hero-image {
  position: relative;
  min-height: 260px;
}

.hero-image::before {
  position: absolute;
  inset: 0;
  z-index: 1;
  content: "";
  background: linear-gradient(90deg, #17211e 0%, rgba(23, 33, 30, 0.62) 42%, rgba(23, 33, 30, 0.1) 100%);
}

.hero-image img {
  width: 100%;
  height: 100%;
  min-height: 100%;
  object-fit: cover;
}

.eyebrow {
  margin: 0;
  color: var(--teal-strong);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin: 0 auto 18px;
}

.metric-card {
  padding: 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.metric-card strong {
  display: block;
  margin-top: 8px;
  font-size: clamp(1.9rem, 4vw, 3rem);
  line-height: 1;
}

.metric-label {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 750;
  text-transform: uppercase;
}

.metric-note {
  margin-top: 9px;
  color: var(--muted);
  font-size: 0.86rem;
}

.metric-card.warning strong {
  color: var(--amber);
}

.metric-card.danger strong {
  color: var(--red);
}

.workspace-grid {
  display: grid;
  grid-template-columns: minmax(310px, 390px) minmax(0, 1fr);
  gap: 18px;
}

.upload-panel,
.records-panel,
.record-dialog form {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 12px 34px rgba(29, 39, 35, 0.08);
}

.upload-panel,
.records-panel {
  min-width: 0;
  padding: 18px;
}

.panel-heading {
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.panel-heading h2,
.dialog-heading h2 {
  margin: 4px 0 0;
  font-size: 1.25rem;
  line-height: 1.15;
}

.panel-count {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 720;
}

.drop-zone {
  display: grid;
  width: 100%;
  min-height: 174px;
  place-items: center;
  gap: 8px;
  padding: 24px;
  color: var(--ink);
  background:
    linear-gradient(180deg, rgba(20, 123, 115, 0.08), rgba(20, 123, 115, 0.02)),
    var(--surface-soft);
  border: 1px dashed #93aaa3;
  border-radius: var(--radius);
  text-align: center;
}

.drop-zone svg {
  width: 34px;
  height: 34px;
  color: var(--teal);
}

.drop-zone span {
  font-weight: 760;
}

.drop-zone small {
  color: var(--muted);
  font-size: 0.86rem;
}

.drop-zone.drag-over {
  background: rgba(20, 123, 115, 0.12);
  border-color: var(--teal);
}

.review-stack {
  display: grid;
  gap: 12px;
  margin-top: 16px;
}

.review-card {
  padding: 14px;
  background: #fbfcfa;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.review-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.file-meta {
  min-width: 0;
  color: var(--muted);
  font-size: 0.82rem;
  overflow-wrap: anywhere;
}

.confidence-badge {
  flex: 0 0 auto;
  padding: 5px 8px;
  color: var(--teal-strong);
  background: rgba(20, 123, 115, 0.1);
  border: 1px solid rgba(20, 123, 115, 0.22);
  border-radius: 999px;
  font-size: 0.74rem;
  font-weight: 780;
}

.review-fields {
  display: grid;
  gap: 10px;
}

.review-field,
.record-dialog label {
  display: grid;
  gap: 6px;
}

.review-field span,
label span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 750;
  text-transform: uppercase;
}

input,
select {
  width: 100%;
  min-height: 40px;
  padding: 0 11px;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

input:focus,
select:focus,
button:focus-visible {
  border-color: var(--teal);
  outline: 3px solid rgba(20, 123, 115, 0.18);
}

.review-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 12px;
}

.records-heading {
  align-items: flex-start;
}

.table-actions {
  flex: 1 1 540px;
  justify-content: flex-end;
  gap: 8px;
}

.search-field {
  position: relative;
  min-width: min(280px, 100%);
}

.search-field svg {
  position: absolute;
  top: 50%;
  left: 11px;
  color: var(--muted);
  transform: translateY(-50%);
  pointer-events: none;
}

.search-field input {
  padding-left: 38px;
}

.table-actions select {
  max-width: 150px;
}

.table-shell {
  position: relative;
  min-height: 280px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

table {
  width: 100%;
  min-width: 760px;
  border-collapse: collapse;
}

th,
td {
  padding: 13px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  color: var(--muted);
  background: #f8faf8;
  font-size: 0.74rem;
  font-weight: 800;
  text-transform: uppercase;
}

td {
  font-size: 0.92rem;
}

tbody tr:hover {
  background: #fbfcfa;
}

.person-row {
  cursor: pointer;
}

.person-row:focus-visible {
  outline: 3px solid rgba(20, 123, 115, 0.18);
  outline-offset: -3px;
}

.person-name,
.person-subline {
  display: block;
}

.person-name {
  font-weight: 760;
}

.person-subline {
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.82rem;
}

.count-badge {
  display: inline-flex;
  min-width: 32px;
  min-height: 28px;
  align-items: center;
  justify-content: center;
  padding: 0 9px;
  color: var(--ink);
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 999px;
  font-weight: 780;
}

.count-badge.current {
  color: var(--green);
  background: rgba(40, 116, 74, 0.08);
  border-color: rgba(40, 116, 74, 0.2);
}

.count-badge.due-soon {
  color: var(--amber);
  background: rgba(189, 116, 28, 0.08);
  border-color: rgba(189, 116, 28, 0.22);
}

.count-badge.overdue {
  color: var(--red);
  background: rgba(186, 63, 63, 0.08);
  border-color: rgba(186, 63, 63, 0.2);
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-width: 112px;
  font-weight: 750;
}

.status-pill.current {
  color: var(--green);
}

.status-pill.due-soon {
  color: var(--amber);
}

.status-pill.overdue,
.status-pill.review {
  color: var(--red);
}

.source-cell {
  max-width: 190px;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.source-link {
  padding: 0;
  color: var(--teal-strong);
  background: transparent;
  border: 0;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.source-link:hover {
  color: var(--teal);
}

.row-actions {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
}

.icon-button.compact {
  min-height: 40px;
  padding-inline: 14px;
  font-size: 0.95rem;
}

.empty-state {
  position: absolute;
  inset: 64px 0 0;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 9px;
  padding: 24px;
  color: var(--muted);
  text-align: center;
  pointer-events: none;
}

.empty-state[hidden] {
  display: none;
}

.empty-state svg {
  width: 34px;
  height: 34px;
  color: var(--teal);
}

.empty-state strong {
  color: var(--ink);
  font-size: 1rem;
}

.record-dialog,
.person-dialog,
.course-dialog,
.preview-dialog {
  width: min(520px, calc(100vw - 28px));
  padding: 0;
  background: transparent;
  border: 0;
}

.person-dialog {
  width: min(980px, calc(100vw - 28px));
}

.course-dialog {
  width: min(760px, calc(100vw - 28px));
}

.preview-dialog {
  width: min(1100px, calc(100vw - 28px));
}

.record-dialog::backdrop,
.person-dialog::backdrop,
.course-dialog::backdrop,
.preview-dialog::backdrop {
  background: rgba(24, 32, 29, 0.42);
  backdrop-filter: blur(4px);
}

.record-dialog form,
.person-dialog-surface,
.course-dialog-surface,
.preview-dialog-surface {
  display: grid;
  gap: 14px;
  padding: 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.dialog-heading {
  justify-content: space-between;
  gap: 16px;
}

.person-summary-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 10px;
}

.person-tabs {
  display: inline-flex;
  gap: 8px;
}

.person-tab {
  min-height: 34px;
  padding: 0 12px;
  color: var(--muted);
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 0.84rem;
  font-weight: 700;
}

.person-tab.is-active {
  color: var(--teal-strong);
  background: rgba(20, 123, 115, 0.1);
  border-color: rgba(20, 123, 115, 0.26);
}

.person-metric {
  min-width: 0;
  padding: 12px;
  background: #fbfcfa;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.person-metric span {
  display: block;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
}

.person-metric strong {
  display: block;
  margin-top: 8px;
  font-size: 1.05rem;
  overflow-wrap: anywhere;
}

.person-metric.current strong {
  color: var(--green);
}

.person-metric.due-soon strong {
  color: var(--amber);
}

.person-metric.overdue strong {
  color: var(--red);
}

.detail-table-shell {
  max-height: min(520px, 58vh);
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.person-history-heading h3 {
  margin: 4px 0 0;
  font-size: 1rem;
}

.history-empty {
  display: grid;
  place-items: center;
  min-height: 72px;
  padding: 12px;
  color: var(--muted);
  font-size: 0.9rem;
  border-top: 1px solid var(--line);
}

.course-form {
  display: grid;
  gap: 10px;
}

.course-table-shell table {
  min-width: 600px;
}

.validity-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 28px;
  padding: 0 10px;
  border: 1px solid transparent;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 760;
}

.validity-pill.one-year {
  color: var(--red);
  background: rgba(186, 63, 63, 0.08);
  border-color: rgba(186, 63, 63, 0.22);
}

.validity-pill.two-year {
  color: var(--amber);
  background: rgba(189, 116, 28, 0.08);
  border-color: rgba(189, 116, 28, 0.24);
}

.validity-pill.three-year {
  color: var(--teal-strong);
  background: rgba(20, 123, 115, 0.1);
  border-color: rgba(20, 123, 115, 0.26);
}

.validity-pill.no-expiry {
  color: var(--green);
  background: rgba(40, 116, 74, 0.1);
  border-color: rgba(40, 116, 74, 0.24);
}

.detail-table-shell table {
  min-width: 720px;
}

.preview-frame-shell {
  height: min(72vh, 760px);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}

.preview-frame-shell iframe {
  width: 100%;
  height: 100%;
  border: 0;
  background: #fff;
}

menu {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin: 4px 0 0;
  padding: 0;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 40;
  max-width: min(420px, calc(100vw - 36px));
  padding: 12px 14px;
  color: white;
  background: #18201d;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(12px);
  transition:
    opacity 180ms ease,
    transform 180ms ease;
  pointer-events: none;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 1120px) {
  .workspace-grid {
    grid-template-columns: 1fr;
  }

  .records-heading,
  .table-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .table-actions {
    flex-basis: auto;
  }

  .table-actions select,
  .search-field {
    max-width: none;
    width: 100%;
  }
}

@media (max-width: 860px) {
  .hero-section {
    grid-template-columns: 1fr;
  }

  .hero-image {
    min-height: 170px;
    order: -1;
  }

  .hero-image::before {
    background: linear-gradient(180deg, rgba(23, 33, 30, 0.08), #17211e 100%);
  }

  .hero-copy h1 {
    font-size: clamp(2rem, 12vw, 3.8rem);
  }

  .summary-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .person-summary-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 620px) {
  .topbar,
  main {
    padding-inline: 12px;
  }

  .brand-subtitle,
  .topbar-actions span,
  .source-cell {
    display: none;
  }

  .sync-status {
    display: none;
  }

  .hero-copy {
    padding: 24px;
  }

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

  .upload-panel,
  .records-panel {
    padding: 14px;
  }

  .review-actions,
  menu {
    flex-direction: column-reverse;
  }

  .review-actions button,
  menu button {
    width: 100%;
  }

  .person-summary-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
