:root {
  color-scheme: light dark;
  --bg: #f5f7fa;
  --panel: #ffffff;
  --text: #17202a;
  --muted: #657181;
  --line: #d9e0e8;
  --blue: #2563eb;
  --blue-dark: #1d4ed8;
  --green: #16835a;
  --amber: #a15c00;
  --red: #c22f2f;
  --shadow: 0 10px 30px rgba(22, 32, 42, 0.08);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111820;
    --panel: #17212b;
    --text: #eef3f8;
    --muted: #9aa8b7;
    --line: #2b3a49;
    --blue: #5b8dff;
    --blue-dark: #8bb0ff;
    --green: #60d394;
    --amber: #f0b35b;
    --red: #ff7070;
    --shadow: none;
  }
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

button,
input,
select {
  font: inherit;
  letter-spacing: 0;
}

.shell {
  width: min(1180px, calc(100vw - 28px));
  margin: 0 auto;
  padding: 18px 0 28px;
}

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

.eyebrow {
  margin: 0 0 2px;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  line-height: 1.15;
}

h1 {
  font-size: 28px;
}

h2 {
  font-size: 18px;
}

.top-actions,
.dialog-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.button {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px 12px;
  background: var(--panel);
  color: var(--text);
  cursor: pointer;
  white-space: nowrap;
}

.button:hover {
  border-color: #b8c3d0;
}

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

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

.button.secondary {
  background: #eef4ff;
  color: var(--blue-dark);
}

.button.ghost {
  background: transparent;
}

.button.danger {
  color: var(--red);
}

.button:disabled {
  cursor: wait;
  opacity: 0.55;
}

.status-pill,
.pill {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  border-radius: 999px;
  padding: 3px 9px;
  border: 1px solid var(--line);
  font-size: 12px;
  font-weight: 650;
}

.neutral {
  background: #eef1f5;
  color: #4b5563;
}

.ok {
  background: #e8f7ef;
  color: var(--green);
}

.warn {
  background: #fff3dc;
  color: var(--amber);
}

.bad {
  background: #fde9e9;
  color: var(--red);
}

.bad-text {
  color: var(--red);
}

.hidden {
  display: none !important;
}

.locked,
.metrics,
.guard,
.toolbar,
.table-wrap {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.locked {
  padding: 26px;
}

.locked p {
  margin: 10px 0 0;
  color: var(--muted);
}

.metrics {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0;
  overflow: hidden;
  margin-bottom: 12px;
}

.metric {
  min-height: 82px;
  padding: 14px 16px;
  border-right: 1px solid var(--line);
  border-top: 0;
  border-bottom: 0;
  border-left: 0;
  background: transparent;
  color: var(--text);
  text-align: left;
  cursor: pointer;
}

.metric:last-child {
  border-right: 0;
}

.metric span,
.label {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.metric strong {
  display: block;
  margin-top: 5px;
  font-size: 28px;
  line-height: 1;
}

.metric.danger strong {
  color: var(--red);
}

.metric:hover {
  background: rgba(37, 99, 235, 0.07);
}

.guard {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  padding: 12px 16px;
  margin-bottom: 12px;
}

.guard strong {
  display: block;
  margin-top: 2px;
}

.guard-actions,
.guard-form {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.guard-form .input {
  max-width: 96px;
}

.toolbar {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) 180px 160px 170px;
  gap: 10px;
  padding: 12px;
  margin-bottom: 12px;
}

.input {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  background: #fff;
  color: var(--text);
}

.input:focus {
  outline: 2px solid rgba(37, 99, 235, 0.22);
  border-color: var(--blue);
}

.table-wrap {
  overflow: auto;
}

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

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

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f9fbfd;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

tbody tr:hover {
  background: #f8fbff;
}

.task-name {
  font-weight: 700;
  word-break: break-word;
}

.task-title,
.task-source,
.meta {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
  word-break: break-word;
}

.actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  min-width: 170px;
}

.link {
  color: var(--blue-dark);
  text-decoration: none;
}

.link:hover {
  text-decoration: underline;
}

.empty {
  padding: 22px;
  color: var(--muted);
}

.pager,
.restore-panel {
  margin-top: 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 10px;
}

.page-info {
  color: var(--muted);
  min-width: 90px;
  text-align: center;
}

.restore-panel {
  padding: 14px 16px;
}

.restore-panel ul {
  margin: 10px 0 0;
  padding-left: 18px;
}

.restore-panel li {
  margin: 5px 0;
  color: var(--muted);
}

.dialog {
  width: min(720px, calc(100vw - 24px));
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0;
  box-shadow: var(--shadow);
}

.dialog::backdrop {
  background: rgba(17, 24, 39, 0.35);
}

.dialog form {
  padding: 18px;
}

.dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

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

.detail-grid dt {
  color: var(--muted);
}

.detail-grid dd {
  margin: 0;
  word-break: break-word;
}

.field {
  display: block;
  margin-bottom: 12px;
}

.field span {
  display: block;
  margin-bottom: 5px;
  color: var(--muted);
  font-weight: 650;
}

.check {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 10px 0 14px;
}

.check.disabled {
  color: var(--muted);
  opacity: 0.65;
}

.form-result {
  min-height: 22px;
  margin: 0 0 12px;
  color: var(--muted);
}

@media (prefers-color-scheme: dark) {
  .button {
    background: #1d2a36;
    color: var(--text);
  }

  .button.secondary {
    background: #20314a;
    color: #cfe0ff;
  }

  .input {
    background: #101923;
  }

  th {
    background: #17212b;
  }

  tbody tr:hover {
    background: #1a2733;
  }

  .neutral {
    background: #233140;
    color: #cad5df;
  }

  .ok {
    background: #123329;
  }

  .warn {
    background: #382a14;
  }

  .bad {
    background: #3a1d22;
  }
}

@media (max-width: 760px) {
  .shell {
    width: min(100vw - 18px, 1180px);
    padding-top: 10px;
  }

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

  .metrics,
  .guard,
  .toolbar {
    grid-template-columns: 1fr;
  }

  .metric {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .metric:last-child {
    border-bottom: 0;
  }

  .detail-grid {
    grid-template-columns: 1fr;
  }

  table {
    min-width: 760px;
  }
}
