:root {
  color-scheme: light;
  --ink: #172026;
  --muted: #61717a;
  --line: #d6dde1;
  --surface: #ffffff;
  --page: #f4f6f7;
  --accent: #0b6b61;
  --accent-strong: #075149;
  --danger: #a53a2d;
  --warning: #9a6500;
  --ok: #176b3a;
  --shadow: 0 10px 30px rgba(23, 32, 38, 0.08);
  font-family: "Noto Sans SC", "Microsoft YaHei", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background:
    linear-gradient(90deg, rgba(11, 107, 97, 0.035) 1px, transparent 1px),
    linear-gradient(rgba(11, 107, 97, 0.035) 1px, transparent 1px),
    var(--page);
  background-size: 28px 28px;
  color: var(--ink);
}

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

button {
  border: 0;
  cursor: pointer;
}

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

[hidden] {
  display: none !important;
}

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

.login-panel {
  width: min(420px, 100%);
  display: grid;
  grid-template-columns: 56px 1fr;
  gap: 20px;
  padding: 32px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.login-panel label,
.login-panel button,
.login-panel .form-error {
  grid-column: 1 / -1;
}

.login-panel h1 {
  margin: 0;
  font-size: 24px;
}

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

.brand-mark {
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
  background: var(--accent);
  color: white;
  border-radius: 6px;
  font-weight: 800;
  letter-spacing: 0.04em;
}

.brand-mark.small {
  width: 38px;
  height: 38px;
  font-size: 13px;
}

.topbar {
  min-height: 68px;
  padding: 12px max(20px, calc((100vw - 1180px) / 2));
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(255, 255, 255, 0.94);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(10px);
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand strong,
.brand span {
  display: block;
}

.brand span {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

main {
  width: min(1180px, calc(100% - 32px));
  margin: 24px auto 56px;
}

.status-band,
.capture-panel,
.live-panel,
.history-section {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.status-band {
  padding: 20px 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  border-left: 4px solid var(--accent);
}

.status-band h2,
.section-heading h2 {
  margin: 2px 0 0;
  font-size: 20px;
  letter-spacing: 0;
}

.eyebrow {
  margin: 0;
  color: var(--accent);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.muted {
  color: var(--muted);
  line-height: 1.55;
}

.status-band .muted {
  margin: 7px 0 0;
}

.status-pill {
  flex: 0 0 auto;
  padding: 7px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}

.status-pill.online {
  color: var(--ok);
  background: #e9f6ee;
}

.status-pill.offline {
  color: var(--muted);
  background: #eef1f2;
}

.capture-layout {
  margin-top: 16px;
  display: grid;
  grid-template-columns: minmax(0, 1.65fr) minmax(280px, 0.75fr);
  gap: 16px;
}

.capture-panel,
.live-panel,
.history-section {
  padding: 22px;
}

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

.segmented {
  display: inline-grid;
  grid-template-columns: 1fr 1fr;
  padding: 3px;
  background: #e8edef;
  border-radius: 6px;
}

.segmented button {
  padding: 7px 14px;
  color: var(--muted);
  background: transparent;
  border-radius: 4px;
}

.segmented button.active {
  color: var(--ink);
  background: white;
  box-shadow: 0 1px 3px rgba(23, 32, 38, 0.12);
}

label {
  display: grid;
  gap: 7px;
  color: #33434c;
  font-size: 13px;
  font-weight: 600;
}

input,
select,
textarea {
  width: 100%;
  min-height: 42px;
  padding: 9px 11px;
  color: var(--ink);
  background: white;
  border: 1px solid #bcc8cd;
  border-radius: 5px;
  outline: none;
}

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(11, 107, 97, 0.12);
}

.field-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-top: 14px;
}

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

.wide-field {
  margin-top: 14px;
}

.capture-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 20px;
}

button.primary,
button.danger,
button.ghost {
  min-height: 42px;
  padding: 9px 16px;
  border-radius: 5px;
  font-weight: 700;
}

button.primary {
  color: white;
  background: var(--accent);
}

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

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

button.ghost {
  color: var(--ink);
  background: transparent;
  border: 1px solid var(--line);
}

.form-error {
  min-height: 18px;
  margin: 10px 0 0;
  color: var(--danger);
  font-size: 13px;
}

.metric-list {
  margin: 0;
}

.metric-list div {
  display: grid;
  grid-template-columns: 112px 1fr;
  gap: 12px;
  padding: 13px 0;
  border-bottom: 1px solid #e8ecee;
}

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

.metric-list dd {
  margin: 0;
  overflow-wrap: anywhere;
  font-size: 13px;
  font-weight: 650;
}

.history-section {
  margin-top: 16px;
}

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

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

th,
td {
  padding: 12px 10px;
  border-bottom: 1px solid #e8ecee;
  text-align: left;
  vertical-align: middle;
}

th {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

td {
  font-size: 13px;
}

.state-chip {
  display: inline-block;
  padding: 4px 8px;
  border-radius: 999px;
  background: #edf1f2;
  font-size: 12px;
}

.state-chip.active,
.state-chip.complete {
  color: var(--ok);
  background: #e9f6ee;
}

.state-chip.pending_start,
.state-chip.pending_stop,
.state-chip.finalizing {
  color: var(--warning);
  background: #fff4d8;
}

.state-chip.incomplete,
.state-chip.cancelled,
.state-chip.failed {
  color: var(--danger);
  background: #fbecea;
}

.row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.row-actions a,
.row-actions button {
  padding: 5px 8px;
  color: var(--accent);
  background: transparent;
  border: 1px solid #b7d3ce;
  border-radius: 4px;
  font-size: 12px;
  text-decoration: none;
}

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

.toast {
  position: fixed;
  left: 50%;
  bottom: 22px;
  max-width: min(520px, calc(100vw - 32px));
  padding: 11px 16px;
  color: white;
  background: #26343c;
  border-radius: 6px;
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 12px);
  transition: opacity 160ms ease, transform 160ms ease;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

@media (max-width: 820px) {
  main {
    width: min(100% - 20px, 1180px);
    margin-top: 12px;
  }

  .capture-layout {
    grid-template-columns: 1fr;
  }

  .status-band {
    align-items: flex-start;
  }
}

@media (max-width: 560px) {
  .topbar {
    padding-inline: 12px;
  }

  .capture-panel,
  .live-panel,
  .history-section {
    padding: 17px;
  }

  .section-heading {
    align-items: flex-start;
  }

  .field-grid,
  .field-grid.compact {
    grid-template-columns: 1fr;
  }

  .metric-list div {
    grid-template-columns: 96px 1fr;
  }

  th:nth-child(2),
  td:nth-child(2) {
    display: none;
  }
}
