:root {
  color-scheme: light;
  --ink: #172126;
  --muted: #667177;
  --paper: #f3f2ed;
  --panel: #fffefa;
  --line: #c9cec9;
  --blue: #2455d6;
  --teal: #007d72;
  --red: #b5222c;
  --amber: #b86b00;
  --shadow: 0 14px 36px rgb(20 34 38 / .09);
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--paper); color: var(--ink); font: 15px/1.5 ui-sans-serif, system-ui, -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif; }
button, input { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .42; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.error { min-height: 1.5em; color: var(--red); font-weight: 700; }
.eyebrow { margin: 0 0 5px; color: var(--blue); font: 750 11px/1.2 ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .16em; }

.masthead { min-height: 92px; padding: 17px clamp(18px, 4vw, 56px); display: flex; align-items: center; justify-content: space-between; gap: 24px; color: white; background: #172126; border-bottom: 5px solid var(--blue); }
.masthead h1 { margin: 0; font-size: clamp(22px, 3vw, 36px); letter-spacing: -.035em; }
.masthead .eyebrow { color: #80a3ff; }
.header-state { display: flex; align-items: center; gap: 12px; }
.signal::before { content: ""; display: inline-block; width: 9px; height: 9px; margin-right: 7px; border-radius: 50%; background: #6c777c; }
.signal.live::before { background: #2bc7a9; box-shadow: 0 0 0 4px rgb(43 199 169 / .15); }

main { padding: clamp(18px, 3vw, 42px) clamp(16px, 4vw, 56px) 60px; }
.login-panel { min-height: 65vh; display: grid; place-items: center; }
.login-panel form { width: min(440px, 100%); padding: 34px; background: var(--panel); border: 1px solid var(--line); box-shadow: var(--shadow); }
.login-panel h2 { margin: 0 0 6px; font-size: 28px; }
label { display: grid; gap: 6px; margin-top: 18px; color: var(--muted); font-size: 13px; font-weight: 700; }
input { width: 100%; padding: 10px 11px; color: var(--ink); background: white; border: 1px solid #aeb6b3; border-radius: 3px; outline: none; }
input:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgb(36 85 214 / .14); }
input[type="checkbox"] { width: auto; accent-color: var(--blue); }
button { padding: 10px 15px; color: white; background: var(--blue); border: 1px solid var(--blue); border-radius: 3px; font-weight: 760; }
.login-panel button { width: 100%; margin-top: 24px; }
button.secondary { color: white; background: transparent; border-color: #7c898f; }
button.secondary.light { color: var(--ink); background: transparent; border-color: #9ba5a4; }
button.stop { color: var(--red); background: #fff8f7; border-color: var(--red); }
button.start { background: var(--teal); border-color: var(--teal); }

.summary-strip { display: grid; grid-template-columns: repeat(4, 1fr); margin-bottom: 34px; color: white; background: #233038; border-top: 4px solid var(--blue); box-shadow: var(--shadow); }
.summary-strip div { padding: 15px 22px; border-right: 1px solid #465158; }
.summary-strip div:last-child { border-right: 0; }
.summary-strip span { display: block; color: #aab4b8; font-size: 12px; }
.summary-strip strong { font: 800 28px/1.1 ui-monospace, SFMono-Regular, Menlo, monospace; }
.section-heading { display: flex; align-items: end; justify-content: space-between; gap: 20px; margin-bottom: 16px; }
.section-heading h2 { margin: 0; font-size: 25px; }
.section-heading > p { max-width: 520px; margin: 0; color: var(--muted); text-align: right; }
.section-heading.compact { margin-top: 34px; }

.rig-grid { display: grid; grid-template-columns: repeat(3, minmax(270px, 1fr)); gap: 16px; }
.rig-card { min-width: 0; padding: 19px; background: var(--panel); border: 1px solid var(--line); border-top: 5px solid #8c9695; box-shadow: 0 7px 20px rgb(20 34 38 / .055); }
.rig-card.online { border-top-color: var(--teal); }
.rig-card.fault { border-top-color: var(--red); }
.rig-card.stale { border-top-color: var(--amber); }
.rig-title { display: flex; justify-content: space-between; gap: 12px; }
.rig-number { display: grid; place-items: center; width: 42px; height: 42px; flex: 0 0 auto; color: white; background: #223038; font: 800 20px/1 ui-monospace, monospace; }
.rig-name { flex: 1; min-width: 0; }
.rig-name h3 { margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rig-name p { margin: 2px 0 0; color: var(--muted); font: 12px ui-monospace, monospace; overflow: hidden; text-overflow: ellipsis; }
.badge { align-self: start; padding: 4px 8px; color: #5d6668; background: #ecefeb; border-radius: 999px; font-size: 11px; font-weight: 800; }
.badge.online { color: #00675d; background: #d8f2eb; }
.badge.fault { color: #9c131d; background: #fde2df; }
.metrics { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1px; margin: 17px 0; background: var(--line); border: 1px solid var(--line); }
.metric { min-width: 0; padding: 10px; background: var(--panel); }
.metric span { display: block; color: var(--muted); font-size: 11px; }
.metric strong { display: block; margin-top: 2px; font: 760 17px/1.2 ui-monospace, SFMono-Regular, Menlo, monospace; overflow: hidden; text-overflow: ellipsis; }
.freshness { min-height: 40px; padding: 8px 10px; color: var(--muted); background: #f1f2ee; font-size: 12px; }
.capability-note { min-height: 36px; margin: 9px 0 0; color: var(--muted); font-size: 12px; line-height: 1.5; }
.controls { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 12px; }
.controls input { padding: 8px; }
.controls button { padding: 8px; font-size: 12px; }
.controls .wide { grid-column: 1 / -1; }
.placeholder { color: var(--muted); border-style: dashed; box-shadow: none; }
.placeholder .metrics, .placeholder .controls { display: none; }

.notification-panel { margin-top: 34px; }
.settings-card { padding: 22px; background: var(--panel); border: 1px solid var(--line); border-left: 5px solid var(--blue); box-shadow: 0 7px 20px rgb(20 34 38 / .055); }
.notification-state { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding-bottom: 16px; border-bottom: 1px solid #e2e4df; }
.notification-state > div { display: flex; align-items: center; gap: 10px; }
.notification-state p { margin: 0; font-size: 12px; }
.credential-grid { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(240px, 1fr); gap: 16px; }
.credential-hint { margin: 10px 0 0; color: var(--muted); font-size: 12px; }
.switch-row { display: flex; flex-wrap: wrap; gap: 12px 28px; margin-top: 18px; padding: 13px 0; border-top: 1px solid #e2e4df; border-bottom: 1px solid #e2e4df; }
label.check-control { display: flex; align-items: center; gap: 9px; margin: 0; color: var(--ink); font-size: 13px; }
.settings-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; margin-top: 16px; }
.form-message { min-height: 1.5em; margin-left: 6px; color: var(--muted); font-size: 12px; font-weight: 700; }

.audit-panel { margin-top: 34px; }
.audit-list { background: var(--panel); border: 1px solid var(--line); }
.audit-row { display: grid; grid-template-columns: 180px minmax(190px, 240px) 1fr; gap: 14px; padding: 9px 13px; border-bottom: 1px solid #e2e4df; font-size: 12px; }
.audit-row:last-child { border-bottom: 0; }
.audit-row code { color: var(--blue); overflow-wrap: anywhere; }

@media (max-width: 1050px) { .rig-grid { grid-template-columns: repeat(2, minmax(260px, 1fr)); } }
@media (max-width: 680px) {
  .masthead, .section-heading { align-items: flex-start; flex-direction: column; }
  .section-heading > p { text-align: left; }
  .summary-strip { grid-template-columns: repeat(2, 1fr); }
  .rig-grid { grid-template-columns: 1fr; }
  .notification-state { align-items: flex-start; flex-direction: column; }
  .credential-grid { grid-template-columns: 1fr; }
  .settings-actions button { width: 100%; }
  .form-message { margin-left: 0; }
  .audit-row { grid-template-columns: 1fr; gap: 2px; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; } }
