:root {
  --paper: #f7f3ea;
  --paper-soft: #fbf8f1;
  --ink: #201b16;
  --muted: #6f665d;
  --rule: #d7ccbd;
  --rule-strong: #b9ac9c;
  --clay: #c15f3c;
  --clay-dark: #8d3f27;
  --sage: #66785f;
  --ochre: #9c6f27;
  --rose: #9a3f35;
  --white: #fffdf8;
  --shadow: 0 18px 50px rgba(42, 35, 28, 0.08);
  --page-max-width: 1504px;
  --page-gutter: clamp(10px, 1.9vw, 34px);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(180deg, rgba(255, 253, 248, 0.9), rgba(247, 243, 234, 0.96)),
    var(--paper);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select {
  font: inherit;
}

h1,
h2,
p {
  margin-top: 0;
}

h1,
h2 {
  font-family: Georgia, "Times New Roman", serif;
  font-weight: 500;
  letter-spacing: 0;
}

h1 {
  margin-bottom: 10px;
  font-size: clamp(42px, 7vw, 86px);
  line-height: 0.94;
}

h2 {
  margin-bottom: 0;
  font-size: 30px;
  line-height: 1;
}

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

.site-header,
.app-shell,
.site-footer {
  width: min(var(--page-max-width), calc(100vw - (var(--page-gutter) * 2)));
  margin: 0 auto;
}

.site-header {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 28px;
  padding: 34px 0 28px;
  border-bottom: 1px solid var(--rule);
}

.brand-lockup p,
.auth-copy {
  max-width: 640px;
  margin-bottom: 0;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.55;
}

.brand-kicker,
.section-kicker {
  display: inline-flex;
  margin-bottom: 14px;
  color: var(--clay-dark);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.account-cluster {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding-top: 4px;
}

.identity-pill,
.status-tag {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border: 1px solid var(--rule);
  border-radius: 999px;
  background: rgba(255, 253, 248, 0.62);
  white-space: nowrap;
}

.identity-pill {
  padding: 6px 12px;
  color: var(--muted);
  font-size: 13px;
}

.app-shell {
  display: grid;
  gap: 24px;
  padding: 30px 0 44px;
}

.site-footer {
  display: flex;
  justify-content: flex-end;
  padding: 0 0 30px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

.workspace-grid {
  display: grid;
  grid-template-columns: minmax(220px, 280px) minmax(0, 1fr);
  gap: 24px;
  align-items: start;
}

.workspace-grid > * {
  min-width: 0;
}

.auth-panel,
.control-panel,
.jobs-console {
  border: 1px solid var(--rule);
  border-radius: 8px;
  background: rgba(255, 253, 248, 0.72);
  box-shadow: var(--shadow);
}

.control-panel,
.jobs-console {
  padding: 24px;
}

.section-heading {
  display: grid;
  gap: 8px;
  margin-bottom: 22px;
}

.upstream-status {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 18px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--rule);
}

.upstream-status-label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

.service-status-tag {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 4px 9px;
  border: 1px solid var(--rule);
  border-radius: 999px;
  background: rgba(255, 253, 248, 0.7);
  font-size: 12px;
  font-weight: 750;
  line-height: 1;
  white-space: nowrap;
}

.service-status-online {
  border-color: #b7c3a6;
  color: var(--sage);
  background: #edf2e7;
}

.service-status-degraded,
.service-status-checking {
  border-color: #cdbb9a;
  color: var(--ochre);
  background: #fbf0d8;
}

.service-status-offline,
.service-status-unknown {
  border-color: #d8aaa0;
  color: var(--rose);
  background: #f7e7e1;
}

.upload-panel form,
.auth-panel form {
  display: grid;
  gap: 16px;
}

label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

input,
select {
  width: 100%;
  min-height: 42px;
  padding: 10px 12px;
  border: 1px solid var(--rule-strong);
  border-radius: 6px;
  color: var(--ink);
  background: var(--white);
  outline: none;
}

input:focus,
select:focus {
  border-color: var(--clay);
  box-shadow: 0 0 0 3px rgba(193, 95, 60, 0.16);
}

.file-drop {
  padding: 18px;
  border: 1px dashed var(--rule-strong);
  border-radius: 8px;
  background: rgba(247, 243, 234, 0.58);
}

.file-drop-secondary {
  padding: 14px 16px;
  background: rgba(255, 253, 248, 0.52);
}

.file-drop-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
}

.file-drop-name {
  color: var(--ink);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 20px;
  font-weight: 500;
  line-height: 1.1;
}

.field-requirement {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  min-height: 22px;
  padding: 4px 8px;
  border: 1px solid var(--rule);
  border-radius: 999px;
  color: var(--muted);
  background: rgba(255, 253, 248, 0.7);
  font-size: 10px;
  font-weight: 750;
  letter-spacing: 0.06em;
  line-height: 1;
  text-transform: uppercase;
}

.field-required {
  border-color: #d8aaa0;
  color: var(--rose);
  background: #f7e7e1;
}

.field-optional {
  border-color: #cdbb9a;
  color: var(--ochre);
  background: #fbf0d8;
}

.admin-panel {
  overflow: hidden;
  border: 1px solid var(--rule);
  border-radius: 8px;
  background: rgba(255, 253, 248, 0.72);
  box-shadow: var(--shadow);
}

.admin-panel-summary {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: end;
  gap: 14px;
  padding: 20px 24px;
  cursor: pointer;
  list-style: none;
}

.admin-panel-summary::-webkit-details-marker {
  display: none;
}

.admin-panel-summary::before {
  width: 24px;
  height: 24px;
  border: 1px solid var(--rule-strong);
  border-radius: 999px;
  color: var(--muted);
  content: "+";
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  line-height: 1;
}

.admin-panel[open] .admin-panel-summary {
  border-bottom: 1px solid var(--rule);
}

.admin-panel[open] .admin-panel-summary::before {
  content: "-";
}

.admin-panel-title {
  color: var(--ink);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 30px;
  font-weight: 500;
  line-height: 1;
}

.admin-panel-count {
  min-height: 26px;
  padding: 5px 10px;
  border: 1px solid var(--rule);
  border-radius: 999px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
  line-height: 1;
}

.admin-panel-body {
  display: grid;
  gap: 18px;
  padding: 22px 24px 24px;
}

.admin-management-grid {
  display: grid;
  grid-template-columns: minmax(260px, 360px) minmax(0, 1fr);
  gap: 22px;
  align-items: start;
}

.admin-create-block {
  display: grid;
  gap: 12px;
  padding-right: 22px;
  border-right: 1px solid var(--rule);
}

.admin-create-block h3 {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
  letter-spacing: 0.08em;
  line-height: 1;
  text-transform: uppercase;
}

.admin-create-block form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.admin-create-block form label:nth-of-type(3),
.admin-create-block form label:nth-of-type(4),
.admin-create-block form button {
  grid-column: 1 / -1;
}

.admin-create-block form button {
  justify-self: start;
  min-width: 160px;
}

.flash-stack {
  display: grid;
  gap: 8px;
}

.flash-message {
  padding: 10px 12px;
  border: 1px solid var(--rule);
  border-radius: 6px;
  color: var(--muted);
  background: rgba(255, 253, 248, 0.7);
  font-size: 12px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.flash-success {
  border-color: #b7c3a6;
  color: var(--sage);
  background: #edf2e7;
}

.flash-error {
  border-color: #d8aaa0;
  color: var(--rose);
  background: #f7e7e1;
}

.admin-user-list {
  display: grid;
  gap: 0;
  border-top: 1px solid rgba(215, 204, 189, 0.72);
  color: var(--muted);
  font-size: 12px;
}

.admin-user-row {
  display: grid;
  grid-template-columns: minmax(170px, 0.8fr) minmax(0, 2.4fr) auto;
  gap: 14px;
  align-items: end;
  padding: 14px 0;
  border-bottom: 1px solid rgba(215, 204, 189, 0.72);
}

.admin-user-summary {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.admin-user-name,
.admin-user-meta,
.admin-user-chip {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.admin-user-name {
  color: var(--ink);
  font-size: 13px;
  font-weight: 750;
}

.admin-user-meta {
  grid-column: 1 / -1;
  color: var(--muted);
}

.admin-user-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 22px;
  padding: 4px 8px;
  border: 1px solid var(--rule);
  border-radius: 999px;
  color: var(--sage);
  background: #edf2e7;
  font-size: 11px;
  font-weight: 750;
  line-height: 1;
}

.source-chip {
  color: var(--muted);
  background: rgba(255, 253, 248, 0.68);
}

.admin-user-update-form {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr)) auto;
  gap: 10px;
  align-items: end;
  min-width: 0;
}

.admin-user-delete-form {
  display: flex;
  justify-content: flex-start;
  margin: 0;
}

.admin-user-update-form .secondary-button,
.admin-user-delete-form .danger-button {
  min-height: 34px;
  width: auto;
  white-space: nowrap;
}

.admin-user-readonly {
  align-self: center;
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.upload-progress {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--rule);
  border-radius: 6px;
  background: rgba(255, 253, 248, 0.62);
}

.upload-progress[hidden] {
  display: none;
}

.upload-progress-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.upload-progress-track {
  position: relative;
  height: 9px;
  overflow: hidden;
  border: 1px solid var(--rule);
  border-radius: 999px;
  background: #eee5d8;
}

.upload-progress-bar {
  display: block;
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: var(--clay);
  transition: width 180ms ease;
}

.upload-progress-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.upload-progress-stats strong {
  color: var(--ink);
  font-weight: 750;
}

.upload-row td {
  background: rgba(251, 248, 241, 0.72);
  vertical-align: middle;
}

.upload-status-stack {
  display: grid;
  gap: 7px;
  min-width: 0;
}

.job-upload-progress {
  display: grid;
  grid-template-columns: minmax(72px, 1fr) minmax(72px, 1fr);
  align-items: center;
  gap: 8px;
  width: 100%;
  min-width: 0;
  white-space: nowrap;
}

.job-upload-meter {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.job-upload-percent {
  color: var(--muted);
  font-size: 11px;
  font-weight: 750;
}

.job-upload-track {
  min-width: 0;
  height: 7px;
  width: 100%;
}

.job-upload-stats {
  display: grid;
  gap: 2px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.job-upload-stats strong {
  color: var(--ink);
  font-weight: 750;
}

.job-upload-stats span {
  overflow: hidden;
  text-overflow: ellipsis;
}

.upload-action-note,
.download-disabled {
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.status-stack {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  max-width: 100%;
  min-width: 0;
  white-space: nowrap;
}

.vis-action {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.vis-status-tag {
  min-height: 24px;
  padding: 4px 8px;
  font-size: 11px;
  text-transform: none;
}

.upload-actions {
  flex-wrap: nowrap;
  white-space: nowrap;
}

.primary-button,
.secondary-button,
button,
.actions a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 9px 13px;
  border: 1px solid var(--ink);
  border-radius: 6px;
  color: var(--white);
  background: var(--ink);
  line-height: 1;
  text-decoration: none;
  cursor: pointer;
}

.secondary-button,
.actions a {
  border-color: var(--rule-strong);
  color: var(--ink);
  background: transparent;
}

.danger-button {
  border-color: #d8aaa0;
  color: var(--rose);
  background: #f7e7e1;
}

button:hover,
.actions a:hover {
  border-color: var(--clay);
}

button:disabled {
  opacity: 0.62;
  cursor: wait;
}

.table-frame {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  border: 1px solid var(--rule);
  border-radius: 8px;
  background: rgba(255, 253, 248, 0.52);
}

table {
  width: 100%;
  min-width: 900px;
  border-collapse: collapse;
  table-layout: fixed;
}

th:nth-child(1),
td:nth-child(1) {
  width: 22%;
}

th:nth-child(2),
td:nth-child(2) {
  width: 18%;
}

th:nth-child(3),
td:nth-child(3) {
  width: 20%;
}

th:nth-child(4),
td:nth-child(4) {
  width: 18%;
}

th:nth-child(5),
td:nth-child(5) {
  width: 22%;
}

th,
td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--rule);
  text-align: left;
  vertical-align: middle;
}

tr:last-child td {
  border-bottom: 0;
}

th {
  color: var(--muted);
  font-size: 11px;
  font-weight: 750;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

td {
  font-size: 14px;
}

td:not(.empty) {
  white-space: nowrap;
}

.filename-cell {
  min-width: 0;
  overflow: hidden;
}

.filename-cell [data-role="job-file-name"] {
  display: inline-block;
  max-width: 100%;
  overflow: hidden;
  vertical-align: middle;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.actions {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  white-space: nowrap;
}

.actions > * {
  vertical-align: middle;
}

.actions form {
  display: inline-flex;
  flex: 0 0 auto;
  margin: 0;
}

.actions button,
.actions a {
  min-height: 32px;
  padding: 7px 10px;
  font-size: 13px;
}

.video-modal {
  width: min(960px, calc(100vw - 40px));
  max-height: min(760px, calc(100vh - 40px));
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--rule);
  border-radius: 8px;
  color: var(--ink);
  background: var(--paper-soft);
  box-shadow: 0 24px 80px rgba(32, 27, 22, 0.24);
}

.video-modal::backdrop {
  background: rgba(32, 27, 22, 0.44);
}

.video-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--rule);
}

.video-modal-header .section-kicker {
  margin-bottom: 8px;
}

.video-frame {
  padding: 16px;
  background: #17130f;
}

.video-frame video {
  display: block;
  width: 100%;
  max-height: min(68vh, 620px);
  aspect-ratio: 16 / 9;
  border-radius: 6px;
  background: #000;
  object-fit: contain;
}

.video-modal-error {
  margin: 0;
  padding: 0 20px 18px;
  color: var(--rose);
  font-size: 13px;
  font-weight: 650;
  line-height: 1.4;
}

.status-tag {
  min-height: 26px;
  padding: 4px 10px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
  line-height: 1;
}

.status-queued {
  border-color: #cdbb9a;
  color: var(--ochre);
  background: #fbf0d8;
}

.status-processing {
  border-color: #cdbb9a;
  color: var(--ochre);
  background: #fbf0d8;
}

.status-running {
  border-color: #b9ad7b;
  color: #695821;
  background: #f6edca;
}

.status-completed {
  border-color: #b7c3a6;
  color: var(--sage);
  background: #edf2e7;
}

.vis-status-tag.status-completed {
  border-color: #8bb9b2;
  color: #266a63;
  background: #e2f1ee;
}

.status-failed,
.status-upload-failed,
.status-missing-upstream {
  border-color: #d8aaa0;
  color: var(--rose);
  background: #f7e7e1;
}

.mono {
  color: #302922;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 12px;
  line-height: 1.45;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.empty,
.error {
  color: var(--rose);
}

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

.auth-card {
  width: min(440px, 100%);
  padding: 34px;
}

.auth-card h1 {
  margin-bottom: 12px;
  font-size: 56px;
}

.auth-copy {
  margin-bottom: 28px;
}

@media (max-width: 900px) {
  .site-header,
  .workspace-grid {
    grid-template-columns: 1fr;
  }

  .admin-management-grid {
    grid-template-columns: 1fr;
  }

  .admin-create-block {
    padding-right: 0;
    padding-bottom: 20px;
    border-right: 0;
    border-bottom: 1px solid var(--rule);
  }

  .admin-user-row {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .admin-user-update-form {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .admin-user-update-form .secondary-button,
  .admin-user-delete-form .danger-button {
    width: 100%;
  }

  .account-cluster {
    justify-content: space-between;
  }
}

@media (max-width: 720px) {
  .site-header,
  .app-shell {
    width: min(100vw - 20px, var(--page-max-width));
  }

  h1 {
    font-size: 48px;
  }

  .account-cluster {
    align-items: flex-start;
    flex-direction: column;
  }

  .control-panel,
  .jobs-console,
  .auth-card {
    padding: 20px;
  }

  .admin-panel-summary {
    grid-template-columns: auto minmax(0, 1fr);
    align-items: center;
    padding: 18px 20px;
  }

  .admin-panel-count {
    grid-column: 2;
    justify-self: start;
  }

  .admin-panel-body {
    padding: 20px;
  }

  .admin-create-block form,
  .admin-user-update-form {
    grid-template-columns: 1fr;
  }
}
