:root {
  color-scheme: light;
  --ink: #17201d;
  --muted: #66716d;
  --paper: #f5f3ed;
  --surface: rgba(255, 255, 255, .88);
  --line: #deddd5;
  --brand: #176b55;
  --brand-deep: #0e4d3c;
  --soft: #e1f0e8;
  --warn: #e69024;
  --danger: #c64236;
  --shadow: 0 18px 50px rgba(31, 50, 43, .09);
  font-family: Inter, "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; color: var(--ink); background: var(--paper); min-height: 100vh; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 3px solid rgba(23, 107, 85, .25); outline-offset: 2px; }
.hidden { display: none !important; }
.app-shell { min-height: 100vh; }
.topbar { height: 72px; display: flex; align-items: center; gap: 28px; padding: 0 36px; background: rgba(245, 243, 237, .86); border-bottom: 1px solid var(--line); backdrop-filter: blur(18px); position: sticky; top: 0; z-index: 20; }
.brand { display: flex; align-items: center; gap: 12px; min-width: 210px; }
.brand-mark { width: 38px; height: 38px; display: grid; place-items: center; color: white; background: var(--brand); border-radius: 12px; font-weight: 800; box-shadow: 0 8px 20px rgba(23, 107, 85, .22); }
.brand strong { display: block; font-size: 16px; letter-spacing: .04em; }
.brand small { color: var(--muted); font-size: 11px; }
.top-stats { display: flex; gap: 10px; flex: 1; }
.stat-pill { background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 8px 13px; color: var(--muted); font-size: 13px; }
.stat-pill b { color: var(--ink); margin-right: 4px; }
.top-actions { display: flex; gap: 8px; }
.button { border: 0; border-radius: 10px; background: var(--brand); color: white; padding: 10px 15px; font-weight: 650; transition: transform .15s, background .15s; }
.button:hover { background: var(--brand-deep); transform: translateY(-1px); }
.button.secondary { background: white; color: var(--ink); border: 1px solid var(--line); }
.button.danger { background: var(--danger); }
.button.small { padding: 7px 10px; font-size: 12px; }
.dashboard { width: min(1440px, calc(100% - 48px)); margin: 30px auto 64px; display: grid; grid-template-columns: minmax(0, 1fr) 430px; gap: 24px; }
.panel { background: var(--surface); border: 1px solid rgba(222, 221, 213, .9); border-radius: 20px; box-shadow: var(--shadow); overflow: hidden; }
.panel-head { display: flex; align-items: center; justify-content: space-between; padding: 22px 24px 14px; }
.panel-head h2 { margin: 0; font-size: 18px; }
.panel-head p { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
.device-grid { padding: 8px 18px 22px; display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.device-card { border: 1px solid var(--line); border-radius: 16px; padding: 17px; background: rgba(255,255,255,.72); transition: border-color .15s, transform .15s; }
.device-card:hover { border-color: #b9c9c2; transform: translateY(-2px); }
.device-card-top { display: flex; justify-content: space-between; gap: 12px; }
.device-card h3 { margin: 0 0 5px; font-size: 16px; }
.meta { color: var(--muted); font-size: 12px; }
.status-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; background: #999; }
.status-dot.online { background: #27a568; box-shadow: 0 0 0 4px rgba(39,165,104,.12); }
.status-dot.monitoring { background: var(--warn); box-shadow: 0 0 0 4px rgba(230,144,36,.14); }
.meter-row { margin: 18px 0 14px; }
.meter-label { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.meter-track { height: 7px; border-radius: 99px; background: #e8e8e3; overflow: hidden; }
.meter-fill { height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--brand), var(--warn), var(--danger)); }
.card-actions { display: flex; gap: 8px; }
.switch { margin-left: auto; display: inline-flex; align-items: center; gap: 7px; font-size: 12px; color: var(--muted); }
.switch input { appearance: none; width: 38px; height: 22px; border-radius: 99px; background: #d4d7d2; position: relative; transition: .2s; }
.switch input::after { content: ""; position: absolute; width: 16px; height: 16px; top: 3px; left: 3px; border-radius: 50%; background: white; transition: .2s; box-shadow: 0 1px 4px rgba(0,0,0,.2); }
.switch input:checked { background: var(--brand); }
.switch input:checked::after { transform: translateX(16px); }
.events { padding: 6px 18px 22px; display: grid; gap: 10px; max-height: calc(100vh - 166px); overflow: auto; }
.event { padding: 14px; border: 1px solid var(--line); border-radius: 14px; background: rgba(255,255,255,.7); }
.event.critical { border-left: 4px solid var(--danger); }
.event.banner { border-left: 4px solid var(--warn); }
.event-top { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.event h3 { margin: 0; font-size: 14px; }
.badge { display: inline-flex; align-items: center; border-radius: 99px; padding: 4px 8px; font-size: 11px; font-weight: 700; background: #f6e5cf; color: #875210; }
.badge.critical { background: #fae0dd; color: #9e2e25; }
.event video { width: 100%; margin-top: 11px; border-radius: 10px; background: #111; max-height: 210px; }
.clip-tabs { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 11px; }
.clip-button { width: 28px; height: 25px; border: 1px solid var(--line); border-radius: 7px; background: white; color: var(--muted); font-size: 11px; }
.clip-button.active { background: var(--brand); color: white; border-color: var(--brand); }
.event-wait { margin-top: 10px; color: var(--muted); font-size: 12px; padding: 9px; background: #f1f1ec; border-radius: 8px; }
.empty { padding: 44px 24px; text-align: center; color: var(--muted); }
.modal { border: 0; border-radius: 20px; padding: 0; width: min(700px, calc(100% - 32px)); max-height: calc(100vh - 48px); box-shadow: 0 32px 90px rgba(16, 29, 24, .28); background: #fbfaf6; }
.modal::backdrop { background: rgba(17, 31, 26, .46); backdrop-filter: blur(4px); }
.modal-form { padding: 26px; overflow: auto; max-height: calc(100vh - 48px); }
.modal-head { display: flex; justify-content: space-between; align-items: start; gap: 20px; margin-bottom: 24px; }
.modal-head h2 { margin: 0; font-size: 22px; }
.modal-head p { color: var(--muted); margin: 6px 0 0; font-size: 13px; }
.icon-button { border: 1px solid var(--line); background: white; border-radius: 9px; width: 34px; height: 34px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.field { display: grid; gap: 7px; }
.field.full { grid-column: 1 / -1; }
.field label, fieldset legend { font-size: 12px; color: var(--muted); font-weight: 650; }
.field input, .field select, .field textarea { width: 100%; border: 1px solid var(--line); background: white; color: var(--ink); border-radius: 10px; padding: 10px 11px; }
.field small { color: var(--muted); }
.checkline { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.schedule-list { display: grid; gap: 9px; margin-top: 8px; }
.schedule-row { display: grid; grid-template-columns: 1fr auto 1fr 1.2fr auto; align-items: center; gap: 8px; }
.schedule-row input, .schedule-row select { min-width: 0; border: 1px solid var(--line); background: white; border-radius: 9px; padding: 9px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 9px; margin-top: 24px; }
.login-screen { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: radial-gradient(circle at 20% 0%, #dbece4, transparent 34%), var(--paper); }
.login-card { width: min(420px, 100%); background: var(--surface); border: 1px solid var(--line); border-radius: 24px; padding: 34px; box-shadow: var(--shadow); }
.login-card .brand-mark { width: 48px; height: 48px; margin-bottom: 24px; }
.login-card h1 { margin: 0; font-size: 28px; }
.login-card p { color: var(--muted); line-height: 1.6; }
.login-card form { display: grid; gap: 13px; margin-top: 26px; }
.login-card input { border: 1px solid var(--line); border-radius: 11px; padding: 12px; background: white; }
.error { color: var(--danger); font-size: 13px; min-height: 18px; }
.toast-stack { position: fixed; right: 22px; top: 88px; display: grid; gap: 10px; z-index: 100; }
.toast { width: min(360px, calc(100vw - 44px)); padding: 14px 16px; color: white; border-radius: 12px; background: #263b34; box-shadow: 0 14px 40px rgba(0,0,0,.2); animation: toast-in .25s ease-out; }
.toast.error { background: var(--danger); }
code.enrollment { display: block; padding: 14px; border-radius: 12px; background: #18231f; color: #d8eee4; overflow-wrap: anywhere; font-size: 12px; user-select: all; }
@keyframes toast-in { from { opacity: 0; transform: translateY(-8px); } }
@media (max-width: 980px) {
  .topbar { padding: 0 18px; } .top-stats { display: none; }
  .dashboard { width: min(100% - 24px, 760px); grid-template-columns: 1fr; }
  .events { max-height: none; }
}
@media (max-width: 620px) {
  .brand small, .top-actions .secondary { display: none; }
  .brand { min-width: 0; flex: 1; }
  .topbar { gap: 10px; height: 64px; }
  .dashboard { margin-top: 14px; }
  .form-grid { grid-template-columns: 1fr; }
  .field.full { grid-column: auto; }
  .schedule-row { grid-template-columns: 1fr auto 1fr; }
  .schedule-row select { grid-column: 1 / 3; }
  .schedule-row .remove-slot { grid-column: 3; grid-row: 2; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; } }
