:root {
  --bg: #f5f6f8;
  --panel: #ffffff;
  --panel-2: #fafbfc;
  --text: #283548;
  --muted: #7b8797;
  --line: #cfd6e1;
  --line-strong: #b9c2d0;
  --brand: #b42318;
  --brand-dark: #8f1d15;
  --ok: #087443;
  --ok-bg: #e8f6ee;
  --warn: #9a5b00;
  --warn-bg: #fff4d7;
  --passive: #667085;
  --passive-bg: #edf0f4;
  --shadow: 0 1px 2px rgba(16, 24, 40, .04);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 13px/1.48 "Segoe UI", Roboto, Arial, Helvetica, sans-serif;
}

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

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

.auth-shell {
  width: min(100%, 420px);
}

.auth-card,
.panel,
.summary-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 4px;
  box-shadow: var(--shadow);
}

.auth-card {
  padding: 26px;
}

.brand-row,
.topbar,
.panel-heading,
.button-row,
.session-box {
  display: flex;
  align-items: center;
}

.brand-row {
  gap: 12px;
  margin-bottom: 30px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 4px;
  background: var(--brand);
  color: #fff;
  font-weight: 700;
  letter-spacing: 0;
}

.brand-name {
  font-weight: 500;
  font-size: 16px;
}

.brand-subtitle,
.eyebrow,
.summary-label,
.panel-heading p,
.upload-name,
.auth-status {
  color: var(--muted);
}

.auth-form h1,
.topbar h1,
.panel-heading h2 {
  margin: 0;
  letter-spacing: 0;
}

.auth-form h1 {
  font-size: 22px;
  margin-bottom: 18px;
}

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

.is-hidden {
  display: none;
}

.field {
  display: grid;
  gap: 7px;
}

.field span,
.upload-title {
  font-weight: 500;
  color: #5f6b7a;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  background: #fff;
  color: var(--text);
  padding: 11px 12px;
  outline: none;
}

.field textarea {
  resize: vertical;
  min-height: 132px;
}

.field input:focus,
.field select:focus,
.field textarea:focus,
.upload-box:focus-within {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(180, 35, 24, .12);
}

.button {
  border: 0;
  border-radius: 4px;
  padding: 11px 14px;
  font-weight: 700;
  cursor: pointer;
}

.button-primary {
  background: var(--brand);
  color: #fff;
}

.button-primary:hover {
  background: var(--brand-dark);
}

.button-secondary {
  background: #edf0f4;
  color: #243247;
}

.button-row {
  gap: 10px;
  justify-content: flex-end;
}

.button-row .button {
  min-width: 118px;
}

.auth-status {
  min-height: 21px;
  margin-top: 18px;
  font-size: 13px;
}

.page-shell {
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 42px;
}

.topbar {
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 18px;
}

.topbar h1 {
  font-size: 23px;
  font-weight: 500;
}

.eyebrow {
  margin-bottom: 4px;
  font-size: 12px;
  font-weight: 500;
  text-transform: uppercase;
}

.session-box {
  gap: 12px;
  padding: 10px 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 4px;
}

.session-box a {
  color: var(--brand);
  font-weight: 500;
  text-decoration: none;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 14px;
}

.summary-card {
  display: flex;
  min-height: 126px;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 15px 16px;
  text-align: center;
}

.summary-icon {
  display: inline-grid;
  place-items: center;
  width: 30px;
  height: 30px;
  margin-bottom: 9px;
  color: #7a8494;
}

.summary-icon svg {
  width: 24px;
  height: 24px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.summary-card strong {
  display: block;
  margin-top: 5px;
  font-size: 20px;
  font-weight: 500;
}

.action-toolbar {
  display: flex;
  justify-content: flex-end;
  margin: 0 0 14px;
  padding: 12px 16px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 4px;
  box-shadow: var(--shadow);
}

.toolbar-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0;
}

.text-action-link {
  border: 0;
  background: transparent;
  color: #697586;
  padding: 0 14px;
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
}

.text-action-link + .text-action-link {
  border-left: 1px solid var(--line);
}

.text-action-link:hover,
.text-action-link:focus-visible,
.session-box a:hover,
.session-box a:focus-visible {
  color: var(--brand);
}

.text-action-link:focus-visible {
  outline: 2px solid rgba(180, 35, 24, .35);
  outline-offset: 3px;
}

.panel {
  padding: 18px;
}

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

.panel-heading h2 {
  font-size: 16px;
  font-weight: 500;
}

.panel-heading p {
  margin: 4px 0 0;
  font-size: 13px;
}

.two-col,
.upload-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.upload-box {
  display: grid;
  gap: 8px;
  min-height: 96px;
  padding: 14px;
  border: 1px dashed var(--line-strong);
  border-radius: 4px;
  background: var(--panel-2);
  cursor: pointer;
}

.upload-box input {
  width: 100%;
  color: var(--muted);
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
}

.status-active,
.status-live {
  background: var(--ok-bg);
  color: var(--ok);
}

.status-passive {
  background: var(--passive-bg);
  color: var(--passive);
}

.status-draft {
  background: var(--warn-bg);
  color: var(--warn);
}

.slim-switch {
  position: relative;
  display: inline-block;
  width: 34px;
  height: 16px;
  vertical-align: middle;
}

.slim-switch input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.slim-switch span {
  position: absolute;
  inset: 0;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: #e9edf3;
  cursor: pointer;
  transition: background .16s ease, border-color .16s ease;
}

.slim-switch span::before {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 2px rgba(16, 24, 40, .18);
  transition: transform .16s ease;
}

.slim-switch input:checked + span {
  border-color: #98d4b6;
  background: #bfe8d1;
}

.slim-switch input:checked + span::before {
  transform: translateX(18px);
}

.slim-switch input:focus-visible + span {
  outline: 2px solid rgba(180, 35, 24, .28);
  outline-offset: 3px;
}

.versions-panel {
  margin-top: 14px;
}

.table-shell {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 4px;
}

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

th,
td {
  padding: 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  white-space: nowrap;
}

th {
  background: var(--panel-2);
  color: #667085;
  font-size: 12px;
  font-weight: 500;
  text-transform: uppercase;
}

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

.project-name {
  font-weight: 500;
}

.cell-action {
  text-align: right;
}

.table-toggle {
  display: inline-grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border: 1px solid transparent;
  border-radius: 4px;
  background: transparent;
  color: #697586;
  padding: 0;
  cursor: pointer;
}

.table-toggle:hover,
.table-toggle:focus-visible {
  border-color: var(--line-strong);
  color: var(--brand);
}

.chevron {
  width: 8px;
  height: 8px;
  border-right: 1.8px solid currentColor;
  border-bottom: 1.8px solid currentColor;
  transform: rotate(45deg) translateY(-1px);
  transition: transform .16s ease;
}

.table-toggle.is-expanded .chevron {
  transform: rotate(225deg) translate(-1px, -1px);
}

.project-row.is-open td {
  background: #fbfcfd;
  border-bottom-color: transparent;
}

.fw-detail-row td {
  padding: 0;
  background: #fbfcfd;
}

.version-stack {
  display: grid;
  gap: 0;
  padding: 0 12px 10px;
  border-bottom: 1px solid var(--line);
}

.version-item {
  display: grid;
  grid-template-columns: 95px minmax(190px, 1fr) minmax(170px, 1fr) auto 104px 86px;
  align-items: center;
  gap: 10px;
  min-height: 34px;
  padding: 6px 12px;
  border: 1px solid var(--line);
  border-bottom: 0;
  background: #fff;
}

.version-item:last-child {
  border-bottom: 1px solid var(--line);
}

.version-no {
  font-weight: 500;
  color: var(--text);
}

.version-date,
.version-file,
.version-device-count,
.version-device-inline {
  color: #667085;
}

.version-files-inline,
.version-device-inline {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: #667085;
  text-align: center;
}

.version-files-inline span + span::before,
.version-device-inline span + span::before {
  content: "|";
  margin-right: 8px;
  color: #98a2b3;
}

.version-delete-cell {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
}

.version-delete {
  border: 0;
  background: transparent;
  padding: 0;
  color: #697586;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
}

.version-delete:hover,
.version-delete:focus-visible {
  color: var(--brand);
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  max-width: 360px;
  padding: 12px 14px;
  border-radius: 8px;
  background: #142033;
  color: #fff;
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
  transition: opacity .18s ease, transform .18s ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(15, 23, 42, .52);
}

.modal-backdrop.is-open {
  display: flex;
}

.modal-card {
  width: min(100%, 520px);
  max-height: calc(100vh - 48px);
  overflow: auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 4px;
  box-shadow: 0 26px 70px rgba(15, 23, 42, .28);
  padding: 20px;
}

.modal-card-wide {
  width: min(100%, 760px);
}

.modal-card-log {
  width: min(100%, 1040px);
}

.modal-card-small {
  width: min(100%, 390px);
}

.log-filter-grid {
  display: grid;
  grid-template-columns: minmax(150px, 1fr) minmax(170px, 1.15fr) minmax(130px, .85fr) minmax(150px, .95fr) auto;
  gap: 12px;
  align-items: end;
  margin-bottom: 14px;
}

.log-filter-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.log-filter-actions .button {
  min-width: 88px;
}

.log-table {
  min-width: 960px;
}

.log-table td {
  vertical-align: top;
}

.log-message {
  max-width: 260px;
  white-space: normal;
  color: #5f6b7a;
}

.log-version {
  color: #667085;
  font-size: 12px;
}

.log-detail-toggle {
  border: 0;
  background: transparent;
  padding: 0;
  color: #697586;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
}

.log-detail-toggle:hover,
.log-detail-toggle:focus-visible {
  color: var(--brand);
}

.log-detail-row td {
  padding: 0;
  background: #fbfcfd;
  border-bottom: 1px solid var(--line);
}

.log-detail-panel {
  display: grid;
  gap: 10px;
  padding: 12px;
  color: #5f6b7a;
}

.log-detail-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px 14px;
}

.log-detail-grid span {
  display: grid;
  gap: 2px;
  min-width: 0;
  word-break: break-word;
}

.log-detail-grid strong {
  color: #475467;
  font-weight: 500;
}

.log-payload {
  max-height: 180px;
  overflow: auto;
  margin: 0;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #fff;
  color: #344054;
  font: 12px/1.45 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  white-space: pre-wrap;
  word-break: break-word;
}

.empty-state {
  color: var(--muted);
  text-align: center;
}

.log-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-top: 12px;
  color: var(--muted);
}

.log-pager {
  display: flex;
  align-items: center;
  gap: 10px;
}

.log-pager .button {
  min-width: 82px;
  padding: 8px 10px;
}

.log-pager .button:disabled {
  opacity: .52;
  cursor: not-allowed;
}

.delete-modal-copy {
  margin: 0 0 18px;
  color: var(--muted);
}

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

.modal-heading h2 {
  margin: 0;
  font-size: 18px;
  font-weight: 500;
  letter-spacing: 0;
}

.modal-heading p {
  margin: 5px 0 0;
  color: var(--muted);
}

.icon-button {
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #fff;
  color: #475467;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}

.icon-button:hover {
  border-color: var(--brand);
  color: var(--brand);
}

body.modal-open {
  overflow: hidden;
}

@media (max-width: 860px) {
  .topbar,
  .action-toolbar,
  .summary-grid,
  .two-col,
  .upload-grid,
  .log-filter-grid,
  .log-detail-grid {
    grid-template-columns: 1fr;
  }

  .topbar {
    display: grid;
  }

  .session-box {
    justify-content: space-between;
  }

  .toolbar-actions {
    justify-content: stretch;
  }

  .toolbar-actions .text-action-link {
    flex: 1;
    text-align: left;
  }

  .version-item {
    grid-template-columns: 1fr;
    min-height: auto;
  }

  .log-filter-actions,
  .log-footer,
  .log-pager {
    align-items: stretch;
  }

  .log-filter-actions,
  .log-footer {
    flex-direction: column;
  }
}

@media (max-width: 520px) {
  .page-shell {
    width: min(100% - 20px, 1180px);
    padding-top: 16px;
  }

  .auth-card,
  .panel,
  .summary-card {
    border-radius: 4px;
  }

  .button-row {
    display: grid;
  }

  .button-row .button {
    width: 100%;
  }
}
