html {
  color-scheme: light;
}

body {
  margin: 0;
  font-family: "Fira Sans", sans-serif;
  background:
    radial-gradient(circle at top left, rgba(34, 211, 238, 0.18), transparent 28%),
    linear-gradient(180deg, #f0fdff 0%, #ecfeff 32%, #f8fafc 100%);
  color: #164e63;
}

body.login-page {
  min-height: 100vh;
  background:
    radial-gradient(circle at 18% 18%, rgba(34, 211, 238, 0.18), transparent 22%),
    radial-gradient(circle at 82% 20%, rgba(8, 145, 178, 0.16), transparent 20%),
    linear-gradient(145deg, #ecfeff 0%, #eff6ff 35%, #f8fafc 100%);
}

a {
  color: inherit;
}

code {
  font-family: "Fira Code", monospace;
  font-size: 0.92em;
}

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

.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 1rem;
  padding: 1rem 1.5rem;
  background: rgba(255, 255, 255, 0.84);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid rgba(8, 145, 178, 0.18);
}

.brand {
  font-family: "Fira Code", monospace;
  font-weight: 600;
  text-decoration: none;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.header-logout-form {
  margin: 0;
}

.header-user-chip,
.header-logout-form .ghost-button {
  height: 2.4rem;
  box-sizing: border-box;
  padding: 0.5rem 0.9rem;
  font-size: 0.88rem;
  line-height: 1.2;
}

.header-logout-form .ghost-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.header-tabs {
  display: flex;
  gap: 0.5rem;
}

.header-tabs a,
.ghost-link,
.danger-link {
  text-decoration: none;
  padding: 0.55rem 0.8rem;
  border-radius: 0;
  transition: 180ms ease;
}

.header-tabs a.active,
.header-tabs a:hover,
.ghost-link:hover {
  background: rgba(8, 145, 178, 0.1);
}

.content-shell {
  width: 95vw;
  margin: 0 auto;
  padding: 1.5rem 0 2rem;
}

.hero-card,
.panel,
.metric-card {
  border: 1px solid rgba(8, 145, 178, 0.12);
  background: rgba(255, 255, 255, 0.86);
  box-shadow: 0 24px 80px rgba(21, 94, 117, 0.08);
}

.hero-card {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 1.5rem;
  border-radius: 0;
  padding: 2rem;
}

.hero-grid {
  display: grid;
  gap: 1rem;
}

.metric-card {
  border-radius: 0;
  padding: 1.2rem;
}

.metric-card span,
.eyebrow {
  display: inline-block;
  font-family: "Fira Code", monospace;
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #0f766e;
}

h1,
h2,
h3,
legend,
dt {
  margin: 0;
  font-weight: 600;
}

h1 {
  margin-top: 0.35rem;
  font-size: clamp(2rem, 3vw, 3rem);
}

h2 {
  margin-bottom: 1rem;
  font-size: 1.2rem;
}

h3 {
  margin-bottom: 0.75rem;
  font-size: 1rem;
}

.lead,
.muted,
.plain-list {
  line-height: 1.65;
}

.muted {
  color: #336d7f;
}

.plain-list,
.steps {
  margin: 0;
  padding-left: 1.2rem;
}

.panel-grid {
  display: grid;
  gap: 1rem;
  margin-top: 1rem;
}

.request-layout {
  grid-template-columns: minmax(280px, 0.9fr) minmax(0, 1.1fr);
}

.panel {
  border-radius: 0;
  padding: 1.5rem;
}

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

.detail-back-link {
  display: inline-flex;
  margin-bottom: 1rem;
  background: rgba(8, 145, 178, 0.16);
  color: #0f172a;
  border: 1px solid rgba(8, 145, 178, 0.22);
}

.status-pill,
.user-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.5rem 0.9rem;
  border-radius: 0;
  font-size: 0.88rem;
  font-weight: 600;
  background: rgba(8, 145, 178, 0.1);
}

.status-draft {
  background: rgba(251, 191, 36, 0.18);
  color: #92400e;
}

.status-submitted {
  background: rgba(6, 182, 212, 0.16);
  color: #0f766e;
}

.status-completed {
  background: rgba(34, 197, 94, 0.18);
  color: #166534;
}

.form-card,
.stack-form,
.stack-display,
.request-meta {
  display: grid;
  gap: 1rem;
}

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

.field {
  display: grid;
  gap: 0.45rem;
}

.field.compact {
  min-width: 180px;
}

.field span {
  font-weight: 600;
}

.date-range-inputs {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: 0.6rem;
}

.date-range-separator {
  font-family: "Fira Code", monospace;
  font-weight: 600;
  color: #0f766e;
}

.time-selects {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: 0.6rem;
}

.time-separator {
  font-family: "Fira Code", monospace;
  font-weight: 600;
  color: #0f766e;
}

input,
select,
textarea,
button {
  font: inherit;
}

input,
select,
textarea {
  width: 100%;
  box-sizing: border-box;
  padding: 0.85rem 0.95rem;
  border-radius: 0;
  border: 1px solid rgba(8, 145, 178, 0.18);
  background: rgba(255, 255, 255, 0.92);
  color: #164e63;
}

textarea {
  resize: none;
}

input:focus,
select:focus,
textarea:focus,
button:focus,
a:focus {
  outline: 3px solid rgba(34, 211, 238, 0.35);
  outline-offset: 2px;
}

.primary-button,
.ghost-button {
  border: 0;
  cursor: pointer;
  border-radius: 0;
  padding: 0.95rem 1.2rem;
  font-weight: 600;
  transition: 180ms ease;
}

.primary-button {
  color: white;
  background: linear-gradient(135deg, #0891b2, #22c55e);
}

.primary-button:hover,
.ghost-button:hover {
  transform: translateY(-1px);
  filter: brightness(1.02);
}

.ghost-button {
  color: #164e63;
  background: rgba(8, 145, 178, 0.1);
}

.alert {
  border-radius: 0;
  padding: 0.95rem 1rem;
}

.alert.error {
  background: rgba(239, 68, 68, 0.12);
  color: #991b1b;
}

.alert.success {
  background: rgba(34, 197, 94, 0.14);
  color: #166534;
}

.field-error {
  color: #b91c1c;
}

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

.meta-grid--single {
  grid-template-columns: 1fr;
}

.meta-grid div {
  padding: 1rem;
  border-radius: 0;
  background: rgba(8, 145, 178, 0.05);
}

.detail-section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.detail-change-flag {
  display: inline-flex;
  align-items: center;
  padding: 0.45rem 0.8rem;
  border: 1px solid rgba(220, 38, 38, 0.18);
  background: rgba(220, 38, 38, 0.08);
  color: #b91c1c;
  font-weight: 700;
}

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

.comparison-row {
  padding: 1rem;
  background: rgba(8, 145, 178, 0.05);
}

.comparison-row--changed {
  border: 1px solid rgba(220, 38, 38, 0.16);
  background: rgba(220, 38, 38, 0.06);
}

.comparison-values {
  display: grid;
  gap: 0.4rem;
}

.comparison-original {
  color: #475569;
}

.comparison-current {
  font-weight: 600;
  color: #0f172a;
}

.comparison-current--changed {
  color: #b91c1c;
}

.detail-summary-grid {
  margin-bottom: 1.25rem;
}

.meta-grid .detail-summary-item--revised {
  border: 1px solid rgba(220, 38, 38, 0.16);
  background: rgba(220, 38, 38, 0.06);
}

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

.detail-media-block {
  display: grid;
  gap: 0.9rem;
}

dt {
  margin-bottom: 0.35rem;
  color: #0f766e;
}

dd {
  margin: 0;
  line-height: 1.5;
}

.preview-grid {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(160px, 220px);
  justify-content: start;
  gap: 0.9rem;
  overflow-x: auto;
  padding-bottom: 0.25rem;
}

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

.preview-item,
.gallery-item {
  overflow: hidden;
  border-radius: 0;
  border: 1px solid rgba(8, 145, 178, 0.12);
  background: rgba(255, 255, 255, 0.9);
}

.preview-media {
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: zoom-in;
}

.preview-item img,
.gallery-item img {
  display: block;
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
}

.preview-lightbox {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  padding: 1.5rem;
  background: rgba(15, 23, 42, 0.82);
}

.preview-lightbox[hidden] {
  display: none !important;
}

.preview-lightbox__panel {
  position: relative;
  width: min(92vw, 1080px);
  max-height: calc(100vh - 3rem);
  padding: 1rem;
  border: 1px solid rgba(8, 145, 178, 0.18);
  background: rgba(255, 255, 255, 0.96);
  box-sizing: border-box;
}

.preview-lightbox__image {
  display: block;
  width: 100%;
  max-height: calc(100vh - 8rem);
  object-fit: contain;
}

.preview-lightbox__close {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  border: 0;
  padding: 0.65rem 0.9rem;
  background: rgba(8, 145, 178, 0.1);
  color: #164e63;
  cursor: pointer;
}

body.has-lightbox {
  overflow: hidden;
}

.preview-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.75rem;
}

.danger-link {
  color: #b91c1c;
  background: rgba(239, 68, 68, 0.1);
  border: 0;
  cursor: pointer;
}

.decision-switch {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  margin: 0;
  padding: 0;
  border: 0;
}

.decision-switch label {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.85rem 1rem;
  border-radius: 0;
  background: rgba(8, 145, 178, 0.06);
}

.is-dimmed {
  opacity: 0.45;
}

.filter-bar {
  display: flex;
  align-items: end;
  gap: 1rem;
  flex-wrap: wrap;
}

.table-wrap {
  overflow-x: auto;
}

.records-table {
  width: 100%;
  border-collapse: collapse;
}

.records-table th,
.records-table td {
  padding: 0.9rem 0.75rem;
  text-align: left;
  vertical-align: middle;
  border-bottom: 1px solid rgba(8, 145, 178, 0.12);
}

.records-table th {
  font-family: "Fira Code", monospace;
  font-size: 0.82rem;
  color: #0f766e;
}

.records-table .col-serial {
  white-space: nowrap;
}

.records-table .cell-center {
  text-align: center;
}

.records-cell {
  min-width: 14rem;
  line-height: 1.55;
  white-space: normal;
  word-break: break-word;
}

.records-cell--reason,
.records-cell--note {
  max-width: 24rem;
}

.records-detail-list {
  display: grid;
  gap: 0.45rem;
}

.review-approved {
  background: rgba(34, 197, 94, 0.18);
  color: #166534;
}

.review-revised {
  background: rgba(245, 158, 11, 0.2);
  color: #92400e;
}

.table-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.table-action-form {
  margin: 0;
}

.table-action-link,
.table-action-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 4.5rem;
  box-sizing: border-box;
}

.table-action-link {
  background: rgba(8, 145, 178, 0.12);
}

.confirm-dialog {
  position: fixed;
  inset: 0;
  z-index: 1100;
  display: grid;
  place-items: center;
  padding: 1.5rem;
  background: rgba(15, 23, 42, 0.58);
}

.confirm-dialog[hidden] {
  display: none !important;
}

.confirm-dialog__card {
  width: min(92vw, 420px);
  padding: 1.5rem;
  border: 1px solid rgba(8, 145, 178, 0.18);
  background: rgba(255, 255, 255, 0.98);
  box-shadow: 0 24px 80px rgba(21, 94, 117, 0.14);
  box-sizing: border-box;
}

.confirm-dialog__card h2 {
  margin-bottom: 0.75rem;
}

.confirm-dialog__actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  margin-top: 1.25rem;
  flex-wrap: wrap;
}

.confirm-dialog__danger {
  min-width: 6.5rem;
}

body.has-dialog {
  overflow: hidden;
}

.empty-state {
  text-align: center;
  padding: 2rem;
  color: #336d7f;
}

.timeline {
  display: grid;
  gap: 0.75rem;
}

.timeline-item {
  display: grid;
  gap: 0.25rem;
  padding: 1rem;
  border-radius: 0;
  background: rgba(8, 145, 178, 0.05);
}

.auth-shell {
  display: grid;
  place-items: center;
  min-height: calc(100vh - 180px);
}

.narrow {
  max-width: 520px;
  margin: 0 auto;
}

.login-stage {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1.5rem;
}

.login-card {
  width: min(88vw, 560px);
  aspect-ratio: 1 / 1;
  border: 1px solid rgba(8, 145, 178, 0.14);
  border-radius: 0;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(247, 252, 255, 0.94)),
    rgba(255, 255, 255, 0.94);
  box-shadow:
    0 30px 100px rgba(21, 94, 117, 0.12),
    inset 0 1px 0 rgba(255, 255, 255, 0.8);
  padding: 1.5rem;
  box-sizing: border-box;
}

.login-card__content {
  height: 100%;
  display: grid;
  align-content: center;
  gap: 1rem;
}

.login-card__content h1 {
  margin: 0 0 0.5rem;
  text-align: center;
  font-size: clamp(2rem, 4vw, 2.8rem);
  letter-spacing: 0.02em;
}

.login-card .primary-button {
  margin-top: 0.5rem;
}

.completion-card {
  text-align: center;
}

.completion-card h1 {
  margin-bottom: 1rem;
}

@media (max-width: 960px) {
  .hero-card,
  .request-layout {
    grid-template-columns: 1fr;
  }
}

@media (min-width: 1024px) {
  .records-table--desktop-balanced {
    table-layout: fixed;
  }

  .records-table--desktop-balanced .records-col--balanced {
    width: calc(80% / 9);
  }

  .records-table--desktop-balanced .records-col--note {
    width: 12%;
  }

  .records-table--desktop-balanced .records-col--actions {
    width: 8%;
  }

  .records-table--desktop-balanced th,
  .records-table--desktop-balanced td {
    overflow-wrap: anywhere;
  }

  .records-table--desktop-balanced .col-serial,
  .records-table--desktop-balanced .col-status,
  .records-table--desktop-balanced .records-cell,
  .records-table--desktop-balanced .records-cell--reason,
  .records-table--desktop-balanced .records-cell--note {
    width: auto;
    min-width: 0;
    max-width: none;
    white-space: normal;
  }

  .records-table--desktop-balanced code {
    white-space: normal;
    word-break: break-word;
    overflow-wrap: anywhere;
  }
}

@media (max-width: 720px) {
  .content-shell {
    width: min(100vw - 1rem, 1200px);
    padding: 1rem 0 1.5rem;
  }

  .site-header,
  .page-heading,
  .header-actions {
    align-items: stretch;
  }

  .site-header,
  .page-heading {
    flex-direction: column;
  }

  .site-header {
    position: static;
    padding: 0.85rem 0.75rem;
  }

  .header-actions {
    width: 100%;
    gap: 0.75rem;
  }

  .header-actions--auth {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
      "user logout"
      "tabs tabs";
    align-items: center;
    column-gap: 0.75rem;
    row-gap: 0.75rem;
  }

  .header-user-chip {
    grid-area: user;
    min-width: 0;
  }

  .header-tabs {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    flex-wrap: nowrap;
    grid-area: tabs;
  }

  .header-tabs a {
    text-align: center;
  }

  .header-logout-form {
    grid-area: logout;
    justify-self: end;
  }

  .header-logout-form .ghost-button {
    width: auto;
    min-width: 0;
    padding-inline: 1rem;
  }

  .form-grid,
  .meta-grid,
  .comparison-grid,
  .detail-media-grid,
  .date-range-inputs,
  .filter-bar {
    grid-template-columns: 1fr;
  }

  .filter-bar {
    display: grid;
    align-items: stretch;
  }

  .panel,
  .hero-card,
  .metric-card,
  .login-card {
    padding: 1rem;
  }

  .detail-back-link {
    width: 100%;
    justify-content: center;
    box-sizing: border-box;
  }

  .field.compact {
    min-width: 0;
  }

  .decision-switch {
    display: grid;
    grid-template-columns: 1fr;
  }

  .decision-switch label,
  .primary-button,
  .ghost-button {
    width: 100%;
    box-sizing: border-box;
    justify-content: center;
  }

  .header-logout-form .ghost-button {
    width: auto;
  }

  .preview-grid {
    grid-auto-columns: minmax(140px, 180px);
  }

  .preview-footer,
  .confirm-dialog__actions {
    flex-direction: column;
    align-items: stretch;
  }

  .preview-footer .danger-link,
  .confirm-dialog__actions .ghost-button,
  .confirm-dialog__actions .confirm-dialog__danger {
    width: 100%;
    box-sizing: border-box;
    justify-content: center;
  }

  .preview-lightbox {
    padding: 0.75rem;
  }

  .preview-lightbox__panel {
    width: 100%;
    max-height: calc(100vh - 1.5rem);
    padding: 0.75rem;
  }

  .preview-lightbox__close {
    position: static;
    display: inline-flex;
    margin: 0 0 0.75rem auto;
  }

  .table-wrap {
    overflow: visible;
  }

  .records-table,
  .records-table tbody {
    display: block;
  }

  .records-table thead {
    display: none;
  }

  .records-table tr {
    display: grid;
    gap: 0.85rem;
    padding: 1rem;
    margin-bottom: 1rem;
    border: 1px solid rgba(8, 145, 178, 0.12);
    background: rgba(255, 255, 255, 0.9);
  }

  .records-table th,
  .records-table td {
    border-bottom: 0;
  }

  .records-table td {
    display: grid;
    grid-template-columns: minmax(5.8rem, 7rem) minmax(0, 1fr);
    gap: 0.75rem;
    align-items: start;
    padding: 0;
  }

  .records-table td::before {
    content: attr(data-label);
    font-family: "Fira Code", monospace;
    font-size: 0.78rem;
    color: #0f766e;
  }

  .records-table td.cell-center {
    text-align: left;
  }

  .records-table .col-serial,
  .records-table .col-status,
  .records-cell,
  .records-cell--reason,
  .records-cell--note {
    width: auto;
    min-width: 0;
    max-width: none;
    white-space: normal;
  }

  .records-table .status-pill {
    justify-self: start;
  }

  .records-table td:last-child {
    grid-template-columns: 1fr;
  }

  .records-table td:last-child::before,
  .records-table .empty-state::before {
    content: none;
  }

  .records-table .empty-state {
    display: block;
    padding: 1rem 0;
  }

  .table-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    justify-content: stretch;
  }

  .table-action-form,
  .table-action-link,
  .table-action-button {
    width: 100%;
  }

  .login-card {
    width: min(100%, 420px);
    aspect-ratio: auto;
    min-height: 0;
  }

  .auth-shell {
    min-height: auto;
    padding: 0.5rem 0;
  }
}

@media (max-width: 480px) {
  .content-shell {
    width: calc(100vw - 0.75rem);
  }

  .site-header {
    padding: 0.75rem 0.5rem;
  }

  .header-actions--auth {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .header-user-chip {
    font-size: 0.82rem;
  }

  h1 {
    font-size: clamp(1.6rem, 9vw, 2rem);
  }

  .page-heading,
  .detail-section-heading {
    gap: 0.75rem;
  }

  .meta-grid div,
  .comparison-row,
  .timeline-item,
  .panel {
    padding: 0.9rem;
  }

  .preview-grid {
    grid-auto-columns: minmax(120px, 150px);
  }

  .time-selects {
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
    gap: 0.45rem;
  }

  .records-table tr {
    padding: 0.9rem;
  }

  .records-table td {
    grid-template-columns: 1fr;
    gap: 0.35rem;
  }

  .records-table td::before {
    margin-bottom: 0.05rem;
  }

  .table-actions {
    grid-template-columns: 1fr;
  }
}

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