:root {
  color-scheme: light;
  --background: #eef3f1;
  --background-strong: #dde7e5;
  --surface: #ffffff;
  --surface-soft: #f6f9f8;
  --surface-raised: #ffffff;
  --border: #d7e1df;
  --border-strong: #aebfbc;
  --ink: #122024;
  --muted: #586a72;
  --muted-strong: #35484f;
  --brand: #0d766f;
  --brand-strong: #095f59;
  --brand-soft: rgba(13, 118, 111, 0.1);
  --info: #1d5fd8;
  --success: #14733a;
  --warning: #8a5a00;
  --danger: #b42318;
  --shadow: 0 16px 44px rgba(18, 32, 36, 0.09);
  --shadow-soft: 0 8px 20px rgba(18, 32, 36, 0.06);
  --radius: 8px;
  --radius-sm: 6px;
  --focus: 0 0 0 3px rgba(13, 118, 111, 0.2);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  min-width: 320px;
  background: var(--background);
}

body {
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(180deg, var(--background) 0%, var(--background-strong) 100%);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  text-rendering: optimizeLegibility;
}

button,
input,
select {
  font: inherit;
}

button,
a,
input,
select,
summary {
  -webkit-tap-highlight-color: transparent;
}

button,
summary {
  touch-action: manipulation;
}

.skip-link {
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 10;
  transform: translateY(-140%);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  color: #ffffff;
  background: var(--brand);
  font-weight: 750;
  text-decoration: none;
  transition: transform 160ms ease;
}

.skip-link:focus {
  transform: translateY(0);
  outline: 0;
  box-shadow: var(--focus);
}

.shell {
  width: min(1240px, 100%);
  margin: 0 auto;
  padding: 28px 20px 56px;
}

.shell:focus {
  outline: 0;
}

.masthead {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 20px;
  margin-bottom: 20px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--brand);
  font-size: 12px;
  font-weight: 800;
  line-height: 1.3;
  text-transform: uppercase;
}

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

h1 {
  margin-bottom: 6px;
  font-size: clamp(24px, 3vw, 34px);
  line-height: 1.12;
}

h2 {
  margin-bottom: 0;
  font-size: 18px;
  line-height: 1.25;
}

.masthead-copy,
.section-copy,
.muted,
.field-hint,
.metric-hint {
  color: var(--muted);
}

.masthead-copy {
  max-width: 720px;
  margin-bottom: 0;
}

.section-copy,
.field-hint,
.metric-hint {
  margin-bottom: 0;
  font-size: 13px;
}

.app-stack {
  display: grid;
  gap: 16px;
}

.auth-panel,
.panel,
.metric-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-soft);
}

.auth-panel {
  max-width: 520px;
  padding: 22px;
}

.auth-form,
.settings-form,
.stack-form {
  display: grid;
  gap: 12px;
}

.auth-form {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
}

.panel {
  padding: 18px;
}

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

.section-heading--with-tools {
  align-items: end;
}

.overview-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(220px, 0.72fr) minmax(300px, 1fr);
  gap: 12px;
}

.metric-card {
  display: grid;
  gap: 10px;
  min-height: 118px;
  padding: 16px;
}

.metric-card--primary {
  border-color: rgba(13, 118, 111, 0.22);
  background:
    linear-gradient(135deg, rgba(13, 118, 111, 0.12), rgba(29, 95, 216, 0.06)),
    var(--surface-raised);
}

.metric-label {
  color: var(--muted-strong);
  font-size: 13px;
  font-weight: 750;
}

.metric-split {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-top: 10px;
}

.metric-split > div {
  min-width: 0;
}

.metric-value {
  display: block;
  overflow: hidden;
  color: var(--ink);
  font-size: 32px;
  line-height: 1.05;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.metric-value--status {
  font-size: 26px;
}

.metric-value--code {
  display: block;
  overflow: hidden;
  color: var(--ink);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
  font-weight: 750;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.metric-caption {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

.pointer-list {
  display: grid;
  gap: 8px;
  margin-bottom: 0;
}

.pointer-list > div {
  display: grid;
  grid-template-columns: minmax(112px, 0.6fr) minmax(0, 1fr);
  gap: 10px;
  align-items: baseline;
}

.pointer-list dt {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.pointer-list dd {
  margin-bottom: 0;
}

.activity-grid,
.tool-grid {
  display: grid;
  gap: 16px;
}

.tool-grid {
  align-items: stretch;
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.activity-grid {
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 0.95fr);
}

.disclosure-panel {
  padding: 0;
}

.tool-grid > .disclosure-panel {
  min-width: 0;
}

.tool-grid > .disclosure-panel:not([open]) {
  min-height: 156px;
}

.tool-grid > .disclosure-panel:not([open]) .disclosure-summary {
  height: 100%;
  min-height: 156px;
}

.disclosure-summary {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto 14px;
  gap: 14px;
  align-items: center;
  min-height: 86px;
  padding: 18px;
  cursor: pointer;
  list-style: none;
}

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

.disclosure-summary::after {
  content: "";
  grid-column: 3;
  grid-row: 1;
  width: 8px;
  height: 8px;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  transform: rotate(45deg);
  transition: transform 160ms ease;
}

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

.disclosure-panel[open] .disclosure-summary::after {
  transform: rotate(-135deg);
}

.disclosure-summary:focus-visible {
  outline: 0;
  box-shadow: inset var(--focus);
}

.tool-grid .disclosure-summary {
  grid-template-columns: minmax(0, 1fr) 14px;
}

.tool-grid .disclosure-summary::after {
  grid-column: 2;
  justify-self: end;
}

.tool-grid .summary-chip {
  grid-column: 1 / -1;
  grid-row: 2;
  justify-self: start;
}

.summary-chip {
  display: inline-flex;
  grid-column: 2;
  grid-row: 1;
  align-items: center;
  justify-content: center;
  min-height: 30px;
  max-width: 280px;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px 10px;
  color: var(--muted-strong);
  background: var(--surface-soft);
  font-size: 12px;
  font-weight: 750;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.summary-chip--warning {
  border-color: rgba(138, 90, 0, 0.26);
  color: var(--warning);
  background: rgba(138, 90, 0, 0.1);
}

.settings-form,
.disclosure-panel .stack-form {
  padding: 18px;
}

.settings-form {
  grid-template-columns: minmax(160px, 220px) minmax(220px, 320px) auto;
  align-items: start;
}

.disclosure-panel .settings-form {
  grid-template-columns: 1fr;
}

.field-group {
  display: grid;
  gap: 6px;
}

.field,
.search-field {
  display: grid;
  gap: 6px;
  color: var(--muted-strong);
  font-size: 13px;
  font-weight: 700;
}

.field input,
.field select,
.search-field input {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 9px 11px;
  color: var(--ink);
  background: var(--surface-raised);
}

.field input::placeholder,
.search-field input::placeholder {
  color: color-mix(in srgb, var(--muted) 72%, transparent);
}

.field input[type="file"] {
  padding: 8px 11px;
}

.field input:focus,
.field select:focus,
.search-field input:focus,
.copy-url:focus {
  border-color: var(--brand);
  outline: 0;
  box-shadow: var(--focus);
}

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

.check-field {
  display: flex;
  align-items: center;
  gap: 9px;
  width: fit-content;
  min-height: 44px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 11px;
  color: var(--ink);
  background: var(--surface-soft);
  font-weight: 700;
}

.check-field input {
  width: 18px;
  height: 18px;
  accent-color: var(--brand);
}

.button-row,
.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.button {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 0 15px;
  font-weight: 750;
  text-decoration: none;
  cursor: pointer;
  transition: background 160ms ease, border-color 160ms ease, color 160ms ease, box-shadow 160ms ease, transform 160ms ease;
  white-space: nowrap;
}

.button:hover {
  transform: translateY(-1px);
}

.button:active {
  transform: translateY(0);
}

.button:focus-visible {
  outline: 0;
  box-shadow: var(--focus);
}

.button:disabled {
  cursor: wait;
  opacity: 0.68;
  transform: none;
}

.button[aria-busy="true"]::after {
  content: "";
  width: 12px;
  height: 12px;
  margin-left: 8px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 999px;
  animation: spin 700ms linear infinite;
}

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

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

.button--secondary {
  border-color: var(--border);
  color: var(--ink);
  background: var(--surface-soft);
}

.button--secondary:hover {
  border-color: var(--border-strong);
  background: var(--background);
}

.button--ghost {
  border-color: var(--border);
  color: var(--brand);
  background: transparent;
}

.button--ghost:hover {
  background: var(--brand-soft);
}

.button--danger {
  color: #ffffff;
  background: var(--danger);
}

.button--danger:hover {
  background: #8f1d15;
}

.button--small {
  min-height: 34px;
  padding: 0 10px;
  font-size: 12px;
}

.sources-table th:last-child,
.sources-table td:last-child {
  width: 430px;
}

.source-actions {
  display: grid;
  grid-template-columns: repeat(5, minmax(68px, 1fr));
  min-width: 420px;
  align-items: start;
}

.source-actions .button,
.action-spacer {
  width: 100%;
}

.action-spacer {
  display: block;
  min-height: 34px;
}

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

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

.data-table th,
.data-table td {
  border-bottom: 1px solid var(--border);
  padding: 10px 9px;
  text-align: left;
  vertical-align: top;
}

.data-table th {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.data-table tbody tr {
  transition: background 150ms ease;
}

.data-table tbody tr:hover {
  background: var(--brand-soft);
}

.data-table tbody tr.is-disabled {
  color: var(--muted);
  background: var(--surface-soft);
}

.primary-cell {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.primary-cell strong,
.primary-cell span {
  overflow-wrap: anywhere;
}

.primary-cell span,
.status-detail {
  color: var(--muted);
  font-size: 12px;
}

.number-cell {
  font-variant-numeric: tabular-nums;
}

.status-cell {
  display: grid;
  gap: 5px;
  min-width: 0;
}

.status-detail {
  max-width: 280px;
  overflow-wrap: anywhere;
}

.badge {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  min-height: 24px;
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 3px 9px;
  font-size: 12px;
  font-weight: 800;
  line-height: 1.2;
  text-transform: capitalize;
}

.badge--success {
  border-color: rgba(20, 115, 58, 0.24);
  color: var(--success);
  background: rgba(20, 115, 58, 0.1);
}

.badge--danger {
  border-color: rgba(180, 35, 24, 0.24);
  color: var(--danger);
  background: rgba(180, 35, 24, 0.1);
}

.badge--warning {
  border-color: rgba(138, 90, 0, 0.26);
  color: var(--warning);
  background: rgba(138, 90, 0, 0.11);
}

.badge--info {
  border-color: rgba(29, 95, 216, 0.22);
  color: var(--info);
  background: rgba(29, 95, 216, 0.1);
}

.badge--neutral {
  border-color: var(--border);
  color: var(--muted-strong);
  background: var(--surface-soft);
}

.code-pill,
.copy-url {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.code-pill {
  display: inline-block;
  max-width: 260px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 3px 7px;
  color: var(--muted-strong);
  background: var(--surface-soft);
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  vertical-align: middle;
  white-space: nowrap;
}

.copy-url {
  width: min(620px, 44vw);
  min-width: 300px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 9px;
  color: var(--muted-strong);
  background: var(--surface-soft);
}

.empty-row td {
  padding: 22px 12px;
  color: var(--muted);
  text-align: center;
}

.notice {
  position: sticky;
  bottom: 14px;
  z-index: 5;
  width: fit-content;
  max-width: min(680px, 100%);
  margin: 4px 0 0 auto;
  border: 1px solid rgba(20, 115, 58, 0.24);
  border-radius: var(--radius);
  padding: 10px 12px;
  color: #14532d;
  background: #ecfdf3;
  box-shadow: var(--shadow);
}

.notice--error,
.form-error {
  color: var(--danger);
}

.notice--error {
  border-color: rgba(180, 35, 24, 0.24);
  background: #fef3f2;
}

.form-error {
  margin: 10px 0 0;
  min-height: 20px;
}

.copy-helper {
  position: fixed;
  inset: auto auto 0 0;
  opacity: 0;
  pointer-events: none;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

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

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --background: #111817;
    --background-strong: #0b1110;
    --surface: #16201f;
    --surface-soft: #1b2826;
    --surface-raised: #1d2927;
    --border: #2d403d;
    --border-strong: #49615d;
    --ink: #eef6f4;
    --muted: #a5b8b5;
    --muted-strong: #c3d2cf;
    --brand: #63d6c9;
    --brand-strong: #8ce4db;
    --brand-soft: rgba(99, 214, 201, 0.12);
    --info: #8db6ff;
    --success: #7edb9b;
    --warning: #f0c36a;
    --danger: #ff9a8f;
    --shadow: 0 18px 48px rgba(0, 0, 0, 0.34);
    --shadow-soft: 0 10px 24px rgba(0, 0, 0, 0.24);
    --focus: 0 0 0 3px rgba(99, 214, 201, 0.28);
  }

  .button--primary,
  .button--danger,
  .skip-link {
    color: #071211;
  }

  .button--danger {
    color: #210402;
  }

  .button--danger:hover {
    background: #ffb3aa;
  }

  .notice {
    color: #d9fbe5;
    background: #173623;
  }

  .notice--error {
    background: #3c1714;
  }
}

@media (max-width: 1060px) {
  .overview-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .metric-card--deployment {
    grid-column: 1 / -1;
  }

  .activity-grid,
  .tool-grid {
    grid-template-columns: 1fr;
  }

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

@media (max-width: 760px) {
  .shell {
    padding: 20px 12px 44px;
  }

  .masthead,
  .section-heading,
  .section-heading--with-tools {
    align-items: stretch;
    grid-template-columns: 1fr;
    flex-direction: column;
  }

  .overview-grid,
  .auth-form,
  .settings-form {
    grid-template-columns: 1fr;
  }

  .metric-split {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .disclosure-summary {
    grid-template-columns: minmax(0, 1fr) 14px;
  }

  .disclosure-summary::after {
    grid-column: 2;
    grid-row: 1;
    justify-self: end;
  }

  .summary-chip {
    grid-column: 1 / -1;
    grid-row: 2;
    justify-self: start;
    max-width: 100%;
  }

  .search-field {
    width: 100%;
  }

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

  .actions .button {
    width: auto;
    min-height: 40px;
  }

  .data-table,
  .data-table thead,
  .data-table tbody,
  .data-table tr,
  .data-table td {
    display: block;
  }

  .data-table thead {
    display: none;
  }

  .data-table tbody tr {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 10px;
    padding: 8px;
    background: var(--surface);
  }

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

  .data-table td {
    display: grid;
    grid-template-columns: minmax(92px, 34%) minmax(0, 1fr);
    gap: 10px;
    padding: 7px;
  }

  .data-table td::before {
    content: attr(data-label);
    color: var(--muted);
    font-weight: 800;
  }

  .data-table td.actions {
    display: flex;
  }

  .data-table td.actions::before {
    flex: 0 0 100%;
  }

  .sources-table th:last-child,
  .sources-table td:last-child {
    width: auto;
  }

  .source-actions {
    min-width: 0;
  }

  .action-spacer {
    display: none;
  }

  .copy-url {
    width: 100%;
    min-width: 0;
  }

  .empty-row td {
    display: block;
  }

  .empty-row td::before {
    content: "";
  }
}

@media (max-width: 520px) {
  .panel,
  .auth-panel,
  .metric-card,
  .settings-form,
  .disclosure-panel .stack-form,
  .disclosure-summary {
    padding: 14px;
  }

  .metric-card {
    min-height: 100px;
  }

  .metric-value {
    font-size: 28px;
  }

  .metric-value--status {
    font-size: 24px;
  }

  .pointer-list > div {
    grid-template-columns: 1fr;
    gap: 2px;
  }
}
