:root {
  color-scheme: light;
  --bg: #eef1f4;
  --panel: #ffffff;
  --panel-soft: #f7f9fb;
  --line: #d7dde4;
  --text: #17202a;
  --muted: #637083;
  --ok: #177245;
  --ok-bg: #e6f6ed;
  --warn: #9a5b00;
  --warn-bg: #fff3d4;
  --critical: #b42318;
  --critical-bg: #fde8e7;
  --accent: #245f9f;
  --accent-dark: #174c82;
  --focus: #1a73e8;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  min-width: 320px;
}

button,
input,
select {
  font: inherit;
}

button {
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  border-radius: 6px;
  min-height: 38px;
  padding: 0 14px;
  cursor: pointer;
}

button:hover {
  border-color: #aeb9c5;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

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

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

button.danger {
  color: var(--critical);
  border-color: #f1b8b4;
}

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

input:focus,
select:focus,
button:focus {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

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

.login-panel {
  width: min(420px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 24px;
  box-shadow: 0 18px 50px rgba(17, 24, 39, 0.08);
}

.login-panel h1 {
  margin: 0 0 6px;
  font-size: 1.45rem;
}

.login-panel p {
  margin: 0 0 22px;
  color: var(--muted);
}

.field {
  display: grid;
  gap: 7px;
  margin-bottom: 14px;
}

.field label {
  color: var(--muted);
  font-size: 0.9rem;
}

.login-error,
.inline-error {
  color: var(--critical);
  background: var(--critical-bg);
  border: 1px solid #fac5c1;
  border-radius: 6px;
  padding: 10px 12px;
  margin-bottom: 14px;
}

.shell {
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr;
  min-width: 0;
}

.topbar {
  background: #111827;
  color: #fff;
  border-bottom: 1px solid #0b1220;
}

.topbar-inner {
  width: min(1480px, 100%);
  margin: 0 auto;
  min-height: 64px;
  padding: 0 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-width: 0;
}

.brand {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.brand strong {
  font-size: 1.02rem;
}

.brand span {
  color: #b8c2d1;
  font-size: 0.85rem;
  overflow-wrap: anywhere;
}

.top-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.top-actions button {
  background: #1f2937;
  border-color: #344256;
  color: #fff;
}

.content {
  width: min(1480px, 100%);
  margin: 0 auto;
  padding: 22px;
  min-width: 0;
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
  min-width: 0;
}

.toolbar h1 {
  margin: 0;
  font-size: 1.3rem;
}

.toolbar p {
  margin: 4px 0 0;
  color: var(--muted);
}

.tabs {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: 7px;
  overflow: hidden;
  background: var(--panel);
}

.tab {
  border: 0;
  border-radius: 0;
  min-height: 36px;
  background: transparent;
}

.tab.active {
  background: #dde9f6;
  color: #123d68;
  font-weight: 700;
}

.alert-strip {
  display: grid;
  gap: 8px;
  margin-bottom: 18px;
}

.alert-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid var(--line);
  background: var(--panel);
  border-left-width: 5px;
  border-radius: 6px;
  padding: 11px 12px;
}

.alert-item.critical {
  border-left-color: var(--critical);
}

.alert-item.warning {
  border-left-color: var(--warn);
}

.alert-item.ok {
  border-left-color: var(--ok);
}

.grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  min-width: 0;
}

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  min-height: 116px;
  min-width: 0;
}

.card-title {
  color: var(--muted);
  font-size: 0.86rem;
}

.card-value {
  margin-top: 8px;
  font-size: 1.42rem;
  font-weight: 800;
  line-height: 1.15;
}

.card-detail {
  margin-top: 8px;
  color: var(--muted);
  font-size: 0.88rem;
  overflow-wrap: anywhere;
}

.card-status-row {
  margin-top: 10px;
}

.status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 26px;
  border-radius: 999px;
  padding: 0 9px;
  font-size: 0.78rem;
  font-weight: 700;
}

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

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

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

.section {
  margin-top: 18px;
  display: grid;
  gap: 12px;
  min-width: 0;
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 16px;
}

.section-header h2 {
  margin: 0;
  font-size: 1.05rem;
}

.section-header p {
  margin: 3px 0 0;
  color: var(--muted);
}

.table-wrap {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  overflow-x: auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

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

th,
td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
  font-size: 0.9rem;
  overflow-wrap: anywhere;
}

th {
  color: var(--muted);
  font-weight: 700;
  background: var(--panel-soft);
}

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

.backup-panels {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  min-width: 0;
}

.section-header.compact {
  margin-top: 4px;
}

.manifest-details {
  max-width: 520px;
}

.manifest-details summary {
  cursor: pointer;
  color: var(--accent);
  font-weight: 700;
  overflow-wrap: anywhere;
}

.manifest-details div {
  margin-top: 8px;
  color: var(--muted);
}

.manifest-details ul {
  margin: 8px 0 0;
  padding-left: 18px;
}

.manifest-details li {
  margin-top: 7px;
  overflow-wrap: anywhere;
}

.manifest-details code {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.78rem;
  white-space: normal;
  word-break: break-all;
}

.actions-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  min-width: 0;
}

.action-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  display: grid;
  gap: 10px;
  min-width: 0;
}

.action-card h3 {
  margin: 0;
  font-size: 1rem;
}

.action-card p {
  margin: 0;
  color: var(--muted);
  min-height: 42px;
}

.action-footer {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.preflight {
  background: var(--panel-soft);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  display: grid;
  gap: 8px;
}

.preflight ul {
  margin: 0;
  padding-left: 18px;
}

.confirm-row {
  display: grid;
  grid-template-columns: minmax(160px, 1fr) auto;
  gap: 8px;
}

.logs {
  background: #101820;
  color: #e8eef7;
  border-radius: 8px;
  border: 1px solid #1f2937;
  padding: 12px;
  white-space: pre-wrap;
  overflow: auto;
  max-height: 520px;
  font-family: "Cascadia Mono", "Fira Code", Consolas, monospace;
  font-size: 0.82rem;
}

.empty {
  color: var(--muted);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
}

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

@media (max-width: 720px) {
  .topbar-inner,
  .toolbar,
  .section-header {
    align-items: stretch;
    flex-direction: column;
  }

  .content {
    padding: 16px;
  }

  table {
    min-width: 0;
    table-layout: fixed;
  }

  .grid,
  .actions-grid,
  .backup-panels {
    grid-template-columns: 1fr;
  }

  .tabs {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
  }

  .confirm-row {
    grid-template-columns: 1fr;
  }
}
