:root {
  color-scheme: light;
  --bg: #f3f6f7;
  --panel: #fff;
  --text: #172329;
  --muted: #68777d;
  --line: #dce4e6;
  --accent: #168162;
  --accent-dark: #0c654c;
  --accent-soft: #e7f4ef;
  --nav: #13292f;
  --danger: #bd3e44;
  --shadow: 0 6px 22px rgba(23, 42, 48, .07);
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body { background: var(--bg); color: var(--text); font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
button, input, select { font: inherit; }
button { border: 0; border-radius: 6px; background: var(--accent); color: #fff; padding: 10px 15px; cursor: pointer; }
button:hover { background: var(--accent-dark); }
button:disabled { cursor: not-allowed; opacity: .45; }
button.secondary { background: #e7edef; color: var(--text); }
button.secondary:hover { background: #d9e3e5; }
button.danger-soft { background: #f8e9e9; color: var(--danger); }
a { color: inherit; text-decoration: none; }
[hidden] { display: none !important; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 232px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; background: var(--nav); color: #eef7f5; padding: 22px 16px 16px; }
.brand { display: flex; align-items: center; gap: 12px; padding: 0 6px 24px; border-bottom: 1px solid rgba(255,255,255,.1); }
.brand-mark { width: 38px; height: 38px; flex: 0 0 38px; display: grid; place-items: center; border-radius: 7px; background: var(--accent); color: #fff; font-weight: 800; }
.brand-mark.large { width: 56px; height: 56px; font-size: 20px; }
.brand strong, .brand small { display: block; }
.brand strong { font-size: 15px; }
.brand small { margin-top: 3px; color: #9fb2b6; font-size: 12px; }
.nav { margin-top: 22px; }
.nav a { display: flex; align-items: center; gap: 11px; padding: 11px 12px; border-radius: 6px; color: #b9c9cc; font-size: 14px; }
.nav a + a { margin-top: 4px; }
.nav a.active, .nav a:hover { color: #fff; background: rgba(255,255,255,.09); }
.nav-icon { font-size: 17px; }
.sidebar-foot { margin-top: auto; padding-top: 16px; border-top: 1px solid rgba(255,255,255,.1); display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.operator { min-width: 0; display: flex; align-items: center; gap: 9px; }
.operator strong, .operator small { display: block; }
.operator strong { font-size: 13px; }
.operator small { color: #9fb2b6; font-size: 11px; margin-top: 2px; }
.avatar { width: 32px; height: 32px; display: grid; place-items: center; border-radius: 50%; background: #28444b; font-size: 13px; }
.icon-button { width: 34px; height: 34px; padding: 0; background: transparent; color: #aebfc2; font-size: 20px; }

.main { min-width: 0; padding: 28px 32px 40px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 24px; }
.page-head h1, .page-head p, .section-head h2, .section-head p { margin: 0; }
.page-head h1 { font-size: 25px; line-height: 1.25; letter-spacing: 0; }
.page-head > div > p:last-child, .section-head p { margin-top: 5px; color: var(--muted); font-size: 13px; }
.eyebrow { margin-bottom: 5px !important; color: var(--accent) !important; font-size: 11px !important; font-weight: 700; text-transform: uppercase; }
.stats { display: grid; grid-template-columns: repeat(3, minmax(150px, 220px)); gap: 12px; margin-bottom: 30px; }
.stats div { background: var(--panel); border: 1px solid var(--line); border-radius: 7px; padding: 16px 18px; }
.stats span, .stats strong { display: block; }
.stats span { color: var(--muted); font-size: 12px; }
.stats strong { margin-top: 5px; font-size: 25px; }
.section-head { display: flex; justify-content: space-between; align-items: end; margin-bottom: 14px; }
.section-head h2 { font-size: 17px; letter-spacing: 0; }
.device-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.device-card { min-width: 0; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 18px; transition: border-color .15s, box-shadow .15s, transform .15s; }
.device-card:hover { border-color: #a9c8bd; box-shadow: var(--shadow); transform: translateY(-1px); }
.device-card-top { display: flex; justify-content: space-between; align-items: center; }
.device-card-actions { display: flex; align-items: center; gap: 8px; }
.device-card-edit { width: 30px; height: 30px; display: grid; place-items: center; padding: 0; border: 1px solid var(--line); background: #f5f8f7; color: #4b635b; }
.device-card-edit:hover { border-color: #a9c8bd; background: var(--accent-soft); color: var(--accent-dark); }
.device-card-edit svg { width: 14px; height: 14px; }
.device-card-body { display: block; }
.camera-icon { width: 36px; height: 36px; display: grid; place-items: center; border-radius: 6px; background: var(--accent-soft); color: var(--accent); font-size: 11px; }
.state-pill { display: inline-flex; align-items: center; gap: 5px; border-radius: 999px; padding: 4px 8px; font-size: 11px; font-weight: 700; }
.state-pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.state-pill.online { color: #08724f; background: #e4f5ee; }
.state-pill.offline { color: #758287; background: #edf1f2; }
.device-card h3 { margin: 14px 0 3px; font-size: 16px; letter-spacing: 0; }
.device-card-body > p { display: flex; flex-wrap: wrap; align-items: baseline; gap: 5px; margin: 0; color: var(--muted); font-size: 10px; }
.device-card-body > p code { color: var(--muted); font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 12px; }
.device-card dl { margin: 16px 0; padding: 12px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.device-card dl div { display: flex; justify-content: space-between; gap: 12px; margin: 5px 0; font-size: 12px; }
.device-card dt { color: var(--muted); }
.device-card dd { margin: 0; text-align: right; }
.enter-device { display: flex; justify-content: space-between; color: var(--accent-dark); font-size: 13px; font-weight: 700; }
.empty-state { padding: 60px 20px; text-align: center; color: var(--muted); background: var(--panel); border: 1px dashed var(--line); }
.head-actions { display: flex; gap: 8px; }
.button-link { display: inline-flex; align-items: center; justify-content: center; min-height: 40px; padding: 9px 14px; border-radius: 6px; background: var(--accent); color: #fff; font-size: 13px; font-weight: 700; }
.button-link:hover { background: var(--accent-dark); }
.table-panel { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.table-panel .section-head { padding: 16px 18px; margin: 0; border-bottom: 1px solid var(--line); }
.table-scroll { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table th, .data-table td { padding: 13px 18px; border-bottom: 1px solid #e8edef; text-align: left; vertical-align: middle; }
.data-table th { background: #f7f9f9; color: var(--muted); font-size: 11px; font-weight: 700; white-space: nowrap; }
.data-table td { min-width: 110px; }
.data-table td:first-child { min-width: 190px; }
.data-table td:nth-child(4) { min-width: 260px; color: var(--muted); }
.data-table strong, .data-table small { display: block; }
.data-table small { margin-top: 3px; color: var(--muted); }
.data-table tr:last-child td { border-bottom: 0; }
.task-state { display: inline-flex; border-radius: 999px; padding: 4px 8px; font-size: 11px; font-weight: 700; white-space: nowrap; }
.task-state.running { color: #356674; background: #e8f1f4; }
.task-state.pending { color: #7b6320; background: #f5efd9; }
.task-state.success { color: #08724f; background: var(--accent-soft); }
.task-state.failed { color: #9c3238; background: #f8e7e8; }
.row-link, .text-link { color: var(--accent-dark); font-size: 12px; font-weight: 700; }

.form-main, .detail-main { max-width: 1180px; width: 100%; margin: 0 auto; }
.setup-form { display: grid; gap: 14px; }
.form-section { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.form-section > header { display: flex; align-items: center; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.form-section > header > span { width: 30px; height: 30px; display: grid; place-items: center; border-radius: 6px; background: var(--accent-soft); color: var(--accent-dark); font-size: 11px; font-weight: 800; }
.form-section h2, .form-section p { margin: 0; }
.form-section h2 { font-size: 15px; letter-spacing: 0; }
.form-section p { margin-top: 3px; color: var(--muted); font-size: 11px; }
.form-grid { display: grid; gap: 15px; padding: 18px; }
.form-grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.form-grid label { min-width: 0; display: grid; align-content: start; gap: 7px; color: #40545a; font-size: 12px; font-weight: 700; }
.form-grid input:not([type="checkbox"]), .form-grid select, .form-grid textarea { width: 100%; min-width: 0; border: 1px solid #ccd8da; border-radius: 6px; background: #fff; padding: 10px 11px; color: var(--text); outline: none; font-weight: 400; }
.form-grid textarea { resize: vertical; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 11px; line-height: 1.5; }
.form-grid input:focus, .form-grid select:focus, .form-grid textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(22,129,98,.1); }
.span-two { grid-column: span 2; }
.span-three { grid-column: span 3; }
.security-note { display: flex; gap: 12px; padding: 13px 16px; border-left: 3px solid #397184; background: #eaf2f4; color: #36545c; font-size: 12px; line-height: 1.5; }
.security-note strong { flex: 0 0 auto; }
.form-actions { display: flex; justify-content: flex-end; align-items: center; gap: 16px; padding: 5px 0; }

.onboarding-layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 14px; align-items: start; }
.progress-panel, .connection-panel, .confirmation-panel { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 18px; }
.connection-panel h2 { margin: 0 0 14px; font-size: 16px; letter-spacing: 0; }
.connection-panel dl, .discovery-grid dl { margin: 0; }
.connection-panel dl div, .discovery-grid dl div { display: grid; grid-template-columns: 92px minmax(0, 1fr); gap: 10px; padding: 8px 0; border-bottom: 1px solid #e9eeee; font-size: 11px; }
.connection-panel dl div:last-child, .discovery-grid dl div:last-child { border-bottom: 0; }
.connection-panel dt, .discovery-grid dt { color: var(--muted); }
.connection-panel dd, .discovery-grid dd { min-width: 0; margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: right; }
.progress-timeline { margin: 0; padding: 0; list-style: none; }
.progress-timeline li { position: relative; display: grid; grid-template-columns: 20px minmax(0, 1fr); gap: 10px; min-height: 50px; }
.progress-timeline li::after { content: ""; position: absolute; left: 6px; top: 14px; bottom: -2px; width: 1px; background: var(--line); }
.progress-timeline li:last-child::after { display: none; }
.progress-timeline li > span { position: relative; z-index: 1; width: 13px; height: 13px; margin-top: 2px; border: 3px solid #d6e0e2; border-radius: 50%; background: #fff; }
.progress-timeline li.completed > span { border-color: var(--accent); background: var(--accent); }
.progress-timeline li.running > span { border-color: #397184; box-shadow: 0 0 0 4px #e8f1f4; }
.progress-timeline li.failed > span { border-color: var(--danger); background: var(--danger); }
.progress-timeline strong, .progress-timeline small { display: block; }
.progress-timeline strong { font-size: 12px; font-weight: 600; }
.progress-timeline small { margin-top: 4px; color: var(--muted); font-size: 10px; }
.deployment-log-panel { margin-top: 22px; overflow: hidden; border: 1px solid #263b40; border-radius: 8px; background: #142328; }
.deployment-log-panel .section-head { margin: 0; padding: 14px 16px; border-bottom: 1px solid #2d444a; color: #f1f6f5; }
.deployment-log-panel .section-head h2 { color: #f1f6f5; }
.deployment-log-panel .section-head p { color: #9eb2b5; }
.live-log-state { display: inline-flex; align-items: center; gap: 7px; color: #a9bbbe; font-size: 11px; }
.live-log-state::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: #70858a; }
.live-log-state.active::before { background: #52d19a; box-shadow: 0 0 0 4px rgba(82,209,154,.12); }
.deployment-log { height: 280px; overflow: auto; padding: 12px 0; color: #d8e4e3; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 11px; line-height: 1.65; scrollbar-color: #496066 #142328; }
.log-line { display: grid; grid-template-columns: 72px 42px minmax(0, 1fr); gap: 8px; padding: 2px 16px; }
.log-line:hover { background: rgba(255,255,255,.035); }
.log-line time { color: #789096; }
.log-level { color: #85a2a7; }
.log-line.success .log-level { color: #52d19a; }
.log-line.warning .log-level { color: #f0c66b; }
.log-line.error .log-level { color: #ff8b92; }
.log-message { min-width: 0; overflow-wrap: anywhere; white-space: pre-wrap; }
.log-empty { padding: 20px 16px; color: #789096; }
.discovery-section { margin-top: 22px; }
.discovery-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.discovery-grid article { min-width: 0; padding: 15px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); }
.discovery-grid h3 { margin: 0 0 10px; font-size: 14px; letter-spacing: 0; }
.confirmation-panel { margin-top: 22px; }
.confirmation-panel .section-head { margin-bottom: 0; }
.confirmation-panel .form-grid { padding: 14px 0; }
.check-line { display: flex !important; grid-column: span 2; grid-template-columns: auto 1fr; align-items: center !important; justify-content: start; }
.check-line input { width: 16px; height: 16px; accent-color: var(--accent); }
.failure-panel { margin-top: 22px; padding: 18px; border: 1px solid #eccbcd; border-radius: 8px; background: #fff7f7; }
.failure-panel strong { color: var(--danger); }
.failure-panel p { color: #73575a; font-size: 12px; }

.device-main { max-width: 1680px; width: 100%; margin: 0 auto; padding-top: 20px; }
.device-head { align-items: center; margin-bottom: 16px; }
.back-link { display: inline-block; margin-bottom: 8px; color: var(--accent-dark); font-size: 12px; }
.title-line { display: flex; align-items: center; gap: 10px; }
.stream-switch { display: flex; gap: 8px; }
.stream-switch button.active-stream { box-shadow: 0 0 0 3px rgba(22,129,98,.18); }
.control-layout { display: grid; grid-template-columns: minmax(520px, 1fr) 310px; gap: 14px; align-items: stretch; }
.video-panel, .ptz-panel { min-width: 0; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow); overflow: hidden; }
.video-panel { display: flex; flex-direction: column; }
.video-toolbar { height: 58px; flex: 0 0 58px; display: flex; align-items: center; justify-content: space-between; padding: 0 16px; border-bottom: 1px solid var(--line); }
.video-toolbar span, .video-toolbar small { display: block; }
.video-toolbar span { font-weight: 700; font-size: 14px; }
.video-toolbar small { max-width: 520px; margin-top: 3px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 11px; }
.playback-badges { display: flex; align-items: center; gap: 6px; }
.latency-badge { padding: 4px 7px; border-radius: 4px; background: #e8f1f4; color: #376775; font-size: 10px !important; white-space: nowrap; }
.latency-badge.webrtc { background: var(--accent-soft); color: #08724f; }
.latency-badge.hls { background: #f3eee2; color: #766331; }
.live-badge { display: inline-flex !important; padding: 4px 7px; border-radius: 4px; background: #d94348; color: #fff; font-size: 10px !important; }
.live-badge[hidden] { display: none !important; }
.video-wrap { position: relative; min-height: 0; aspect-ratio: 16 / 8.55; background: #071114; overflow: hidden; }
video { display: block; width: 100%; height: 100%; object-fit: contain; background: #071114; }
.empty-video { position: absolute; inset: 0; display: grid; align-content: center; justify-items: center; gap: 7px; color: #d4e0e2; pointer-events: none; }
.empty-video strong { font-size: 14px; }
.empty-video span { color: #82969b; font-size: 12px; }
.ptz-panel { display: flex; flex-direction: column; padding: 16px; }
.panel-title { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.panel-title h2, .panel-title p { margin: 0; }
.panel-title h2 { font-size: 16px; letter-spacing: 0; }
.panel-title p { max-width: 180px; margin-top: 4px; color: var(--muted); font-size: 11px; line-height: 1.4; }
.speed-control { display: grid; gap: 3px; color: var(--muted); font-size: 10px; }
.speed-control select { border: 1px solid var(--line); border-radius: 5px; background: #fff; padding: 4px 22px 4px 7px; color: var(--text); }
.ptz-pad { width: 210px; height: 210px; margin: auto; display: grid; grid-template-columns: repeat(3, 62px); grid-template-rows: repeat(3, 62px); grid-template-areas: ". up ." "left stop right" ". down ."; gap: 9px; justify-content: center; align-content: center; border-radius: 50%; background: #edf3f2; }
.ptz-pad button, .zoom-control button { padding: 0; border: 1px solid #d2dfdc; background: #fff; color: #315159; font-size: 25px; box-shadow: 0 2px 5px rgba(25,49,55,.06); touch-action: none; user-select: none; }
.ptz-pad button:hover, .ptz-pad button.pressed, .zoom-control button:hover, .zoom-control button.pressed { background: var(--accent); border-color: var(--accent); color: #fff; }
.ptz-pad [data-ptz-hold="up"] { grid-area: up; }
.ptz-pad [data-ptz-hold="left"] { grid-area: left; }
.ptz-pad [data-ptz-stop] { grid-area: stop; color: var(--danger); font-size: 14px; }
.ptz-pad [data-ptz-hold="right"] { grid-area: right; }
.ptz-pad [data-ptz-hold="down"] { grid-area: down; }
.zoom-control { display: flex; align-items: center; justify-content: space-between; margin-top: auto; padding-top: 12px; border-top: 1px solid var(--line); color: var(--muted); font-size: 12px; }
.zoom-control div { display: flex; gap: 7px; }
.zoom-control button { width: 45px; height: 35px; font-size: 21px; }
.hold-status { display: flex; justify-content: center; align-items: center; gap: 7px; margin-top: 10px; color: var(--muted); font-size: 11px; }
.hold-status span { width: 7px; height: 7px; border-radius: 50%; background: #b8c4c6; }
.hold-status span.active { background: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }

.addresses-section { margin-top: 22px; }
.gate-section { margin-top: 24px; padding-top: 4px; }
.gate-controller-list { display: grid; gap: 22px; }
.gate-controller > header { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 10px; }
.gate-controller > header > div { display: flex; align-items: center; gap: 10px; min-width: 0; }
.gate-controller > header h3, .gate-controller > header p { margin: 0; }
.gate-controller > header h3 { font-size: 15px; }
.gate-controller > header p { margin-top: 2px; color: var(--muted); font-size: 11px; }
.gate-controller-icon { width: 38px; height: 38px; flex: 0 0 38px; display: grid; place-items: center; border-radius: 7px; color: var(--accent); background: var(--accent-soft); }
.gate-controller-icon svg { width: 20px; height: 20px; }
.gate-door-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.gate-door { min-width: 0; padding: 16px; border: 1px solid #d6dfdb; border-radius: 8px; background: #fff; box-shadow: 0 10px 26px rgba(23,41,35,.07); }
.gate-door > header { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding-bottom: 12px; border-bottom: 1px solid #e6ebe8; }
.gate-door h4 { margin: 0 0 4px; font-size: 16px; }
.gate-door header code { display: block; max-width: 100%; overflow-wrap: anywhere; color: var(--muted); font-size: 10px; }
.gate-command-state { flex: 0 0 auto; min-height: 24px; padding: 4px 8px; border-radius: 999px; color: #586963; background: #edf1ef; font-size: 10px; font-weight: 700; }
.gate-command-state.dropped { color: #8d3434; background: #f8e7e7; }
.gate-command-state.prepared { color: #176446; background: #e3f3ea; }
.gate-status-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 16px; margin: 14px 0; }
.gate-status-grid div { min-width: 0; }
.gate-status-grid dt { color: var(--muted); font-size: 10px; }
.gate-status-grid dd { margin: 3px 0 0; overflow-wrap: anywhere; color: #253a34; font-size: 12px; font-weight: 650; }
.gate-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.gate-actions button { min-height: 42px; justify-content: center; }
.gate-actions .danger { background: #a83d42; color: #fff; }
.gate-actions .danger:hover { background: #913238; }
.gate-mode-control { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 12px; }
.gate-mode-control > span { flex: 0 0 auto; color: var(--muted); font-size: 11px; font-weight: 650; }
.gate-mode-control .segmented-control { flex: 1; }
.gate-mode-control button { min-height: 34px; padding: 6px 8px; font-size: 11px; }
.gate-safety-note { display: flex; align-items: flex-start; gap: 7px; margin: 12px 0 0; padding-top: 11px; border-top: 1px solid #ecefec; color: #7d5a36; font-size: 10px; line-height: 1.5; }
.gate-safety-note svg { width: 14px; height: 14px; flex: 0 0 14px; margin-top: 1px; }
.address-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.address-card { min-width: 0; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 14px; }
.address-card header { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 10px; }
.address-card header > div { display: flex; align-items: center; gap: 8px; }
.address-card h3 { margin: 0; font-size: 14px; letter-spacing: 0; }
.address-kind { border-radius: 4px; padding: 3px 6px; font-size: 10px; font-weight: 700; }
.address-kind.local { color: #2e6574; background: #e8f1f4; }
.address-kind.cloud { color: #08724f; background: var(--accent-soft); }
.link-button { padding: 4px 7px; background: transparent; color: var(--accent-dark); font-size: 11px; }
.link-button:hover { background: var(--accent-soft); }
.url-line, .protocol-url { min-width: 0; display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 8px; }
.url-line code, .protocol-url code { min-width: 0; display: block; padding: 8px 9px; border-radius: 5px; background: #f1f5f5; color: #344d54; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 11px; }
.url-line button, .protocol-url button { padding: 6px 8px; background: #e7edef; color: #345159; font-size: 11px; }
.url-stack { display: grid; gap: 6px; color: var(--muted); font-size: 11px; }
.protocol-url { grid-template-columns: 54px minmax(0, 1fr) auto; }
.protocol-url b { font-size: 10px; }
.close-session { justify-self: end; padding: 3px 0; background: transparent; color: var(--danger); font-size: 10px; }
.close-session:hover { background: transparent; text-decoration: underline; }

.toast { position: fixed; right: 24px; bottom: 24px; z-index: 20; max-width: min(420px, calc(100vw - 32px)); padding: 11px 14px; border-radius: 6px; background: #173138; color: #fff; box-shadow: 0 8px 24px rgba(0,0,0,.16); opacity: 0; transform: translateY(8px); pointer-events: none; transition: .18s; font-size: 13px; }
.toast.show { opacity: 1; transform: translateY(0); }
.toast.error { background: #8e3035; }

.login-page { overflow: hidden; }
.login-shell { min-height: 100vh; display: grid; grid-template-columns: minmax(340px, 42%) 1fr; }
.login-brand { position: relative; display: grid; align-items: center; padding: 70px; overflow: hidden; background: #153139; color: #fff; }
.login-brand::after { content: ""; position: absolute; right: -100px; bottom: -140px; width: 360px; height: 360px; border: 80px solid rgba(40,163,128,.15); border-radius: 50%; }
.login-brand-inner { position: relative; z-index: 1; max-width: 430px; }
.login-brand-inner > p { margin: 22px 0 4px; color: #7fd1b6; font-size: 12px; font-weight: 800; }
.login-brand h1 { margin: 0; font-size: 36px; letter-spacing: 0; }
.login-brand-inner > span:last-child { display: block; margin-top: 18px; color: #b9cbce; line-height: 1.8; font-size: 14px; }
.login-panel { display: grid; place-items: center; padding: 40px; background: #f7f9f9; }
.login-form { width: min(380px, 100%); display: grid; gap: 18px; }
.login-form header { margin-bottom: 10px; }
.login-form h2 { margin: 0; font-size: 27px; letter-spacing: 0; }
.login-form header > span { display: block; margin-top: 7px; color: var(--muted); font-size: 13px; }
.login-form label { display: grid; gap: 7px; color: #3d5056; font-size: 13px; font-weight: 600; }
.login-form input { width: 100%; border: 1px solid #ccd8da; border-radius: 6px; background: #fff; padding: 12px 13px; outline: none; }
.login-form input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(22,129,98,.12); }
.login-form > button { min-height: 44px; margin-top: 2px; }
.form-error { min-height: 18px; margin: -7px 0 -6px; color: var(--danger); font-size: 12px; }
.form-error.form-success { color: var(--accent); }

@media (max-width: 1050px) {
  .control-layout { grid-template-columns: minmax(420px, 1fr) 270px; }
  .ptz-pad { width: 190px; height: 190px; grid-template-columns: repeat(3, 56px); grid-template-rows: repeat(3, 56px); }
}

@media (max-width: 820px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: static; width: 100%; height: auto; flex-direction: row; align-items: center; padding: 10px 14px; }
  .brand { padding: 0; border: 0; }
  .brand small, .operator, .nav-icon { display: none; }
  .nav { margin: 0 0 0 auto; }
  .nav a { padding: 8px 10px; }
  .sidebar-foot { margin: 0 0 0 5px; padding: 0; border: 0; }
  .main { padding: 20px 16px 32px; }
  .control-layout { grid-template-columns: 1fr; }
  .ptz-panel { min-height: 350px; }
  .address-grid { grid-template-columns: 1fr; }
  .onboarding-layout, .discovery-grid { grid-template-columns: 1fr; }
  .form-grid.three { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .span-three { grid-column: span 2; }
  .login-shell { grid-template-columns: 1fr; }
  .login-brand { min-height: 220px; padding: 34px; }
  .login-brand::after { width: 230px; height: 230px; border-width: 50px; }
  .login-brand h1 { font-size: 28px; }
  .login-brand-inner > span:last-child { margin-top: 10px; }
}

@media (max-width: 560px) {
  .page-head { align-items: flex-start; }
  .stats { grid-template-columns: repeat(3, 1fr); }
  .stats div { padding: 12px 10px; }
  .stats strong { font-size: 21px; }
  .device-head { display: block; }
  .stream-switch { margin-top: 14px; display: grid; grid-template-columns: repeat(3, 1fr); }
  .stream-switch button { padding: 9px 6px; font-size: 12px; }
  .video-toolbar small { max-width: 260px; }
  .login-panel { padding: 34px 24px; align-items: start; }
  .login-brand { min-height: 190px; }
  .login-brand-inner > span:last-child { display: none; }
  .url-line { grid-template-columns: minmax(0, 1fr) auto; }
  .form-grid.two, .form-grid.three { grid-template-columns: 1fr; }
  .span-two, .span-three, .check-line { grid-column: span 1; }
  .head-actions { flex-wrap: wrap; justify-content: flex-end; }
}

/* 云瞰智巡 visual system */
:root {
  --bg: #f4f6f3;
  --panel: #ffffff;
  --text: #17211e;
  --muted: #697672;
  --line: #dfe5e1;
  --accent: #17775b;
  --accent-dark: #0e5d46;
  --accent-soft: #e7f2ed;
  --nav: #142722;
  --danger: #b9454c;
  --amber: #c4872f;
  --amber-soft: #f8eedc;
  --blue: #426c78;
  --shadow: 0 10px 28px rgba(27, 45, 39, .08);
}

body { background: var(--bg); }
svg { display: block; }
button svg, .button-link svg, .back-link svg, .nav-icon svg { width: 17px; height: 17px; flex: 0 0 auto; }
button { min-height: 40px; font-weight: 650; transition: background-color .16s, border-color .16s, color .16s, transform .16s, box-shadow .16s; }
button:active:not(:disabled), .button-link:active { transform: translateY(1px); }
.icon-text-button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; }

.app-shell { grid-template-columns: 248px minmax(0, 1fr); }
.sidebar { padding: 20px 16px 16px; background: var(--nav); box-shadow: 8px 0 28px rgba(13, 32, 26, .07); }
.brand { gap: 11px; padding: 0 7px 20px; }
.brand-mark { width: 40px; height: 40px; flex-basis: 40px; border-radius: 8px; background: #1b8869; box-shadow: inset 0 0 0 1px rgba(255,255,255,.13); }
.brand-mark svg { width: 22px; height: 22px; }
.brand strong { font-size: 16px; font-weight: 750; }
.brand small { color: #98aaa4; font-size: 10px; }
.nav { margin-top: 18px; }
.nav a { min-height: 43px; border-radius: 7px; padding: 11px 12px; color: #aebdb8; font-weight: 600; }
.nav a.active { position: relative; background: #224038; box-shadow: inset 0 0 0 1px rgba(255,255,255,.045); }
.nav a.active::before { content: ""; position: absolute; left: 0; top: 11px; bottom: 11px; width: 3px; border-radius: 0 3px 3px 0; background: #5ac49d; }
.nav a:hover { background: #1d3730; }
.nav-icon { width: 20px; display: grid; place-items: center; }
.nav-icon svg { width: 18px; height: 18px; }
.sidebar-foot { padding: 16px 4px 0; }
.avatar { background: #29463e; color: #dce8e4; font-weight: 750; }
.icon-button { display: grid; place-items: center; border-radius: 6px; }
.icon-button:hover { background: #263f38; color: #fff; }
.icon-button svg { width: 17px; height: 17px; }

.main { padding: 30px 36px 44px; }
.page-head { margin-bottom: 26px; }
.page-head h1 { font-size: 26px; font-weight: 720; }
.page-head > div > p:last-child { color: #74807c; }
.eyebrow { color: var(--accent) !important; letter-spacing: 0 !important; }
.back-link { display: inline-flex; align-items: center; gap: 6px; margin-bottom: 10px; color: #48645b; font-weight: 650; }

.stats { grid-template-columns: repeat(3, minmax(180px, 1fr)); max-width: 780px; gap: 14px; }
.stats div { position: relative; overflow: hidden; min-height: 104px; border-radius: 8px; padding: 17px 19px; box-shadow: 0 2px 10px rgba(29, 45, 40, .035); }
.stats div::after { content: ""; position: absolute; right: 0; top: 0; bottom: 0; width: 3px; background: #91aaa2; }
.stats .stat-online::after { background: var(--accent); }
.stats .stat-offline::after { background: var(--danger); }
.stats .stat-pending::after { background: var(--amber); }
.stats span { display: flex; align-items: center; gap: 7px; font-weight: 650; }
.stats span svg { width: 15px; height: 15px; }
.stats strong { margin-top: 11px; font-size: 30px; font-variant-numeric: tabular-nums; }
.stat-online strong { color: var(--accent-dark); }
.stat-offline strong { color: #9c3b41; }
.stat-pending strong { color: #93641f; }

.device-grid { grid-template-columns: repeat(auto-fill, minmax(285px, 1fr)); gap: 16px; }
.device-card { position: relative; border-radius: 8px; padding: 19px; }
.device-card:hover { border-color: #91b8a9; box-shadow: var(--shadow); transform: translateY(-2px); }
.camera-icon { width: 40px; height: 40px; border-radius: 7px; }
.camera-icon svg { width: 20px; height: 20px; }
.device-card h3 { margin-top: 16px; font-size: 17px; }
.device-card dl { margin-top: 18px; }
.device-card dl div { align-items: center; }
.device-card dd { max-width: 62%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.enter-device { align-items: center; }
.enter-device svg { width: 15px; height: 15px; transition: transform .16s; }
.device-card:hover .enter-device svg { transform: translate(2px, -2px); }
.empty-state { border-radius: 8px; }

.table-panel, .form-section, .progress-panel, .connection-panel, .confirmation-panel, .discovery-grid article, .address-card { box-shadow: 0 2px 12px rgba(28, 45, 39, .035); }
.data-table tbody tr { transition: background-color .14s; }
.data-table tbody tr:hover { background: #f8faf8; }
.data-table th { background: #f5f7f5; }
.data-table td:nth-child(4) { max-width: 360px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-link { display: inline-flex; padding: 5px 8px; border-radius: 5px; background: var(--accent-soft); }
.row-link:hover { color: #fff; background: var(--accent); }
.row-actions { display: flex; gap: 6px; white-space: nowrap; }
.row-link.retry { color: #9c3238; background: #f8e7e8; }
.row-link.retry:hover { color: #fff; background: #9c3238; }
.button-link { gap: 8px; }
.task-state.pending { color: #855e22; background: var(--amber-soft); }

.form-main, .detail-main { max-width: 1240px; }
.form-section > header { padding: 16px 19px; }
.form-section > header > span { background: #ecf2ef; }
.form-grid { padding: 20px; }
.form-grid input:not([type="checkbox"]), .form-grid select, .form-grid textarea { min-height: 42px; border-color: #cfd8d3; }
.security-note { align-items: flex-start; border-left-color: var(--blue); background: #edf3f4; }
.security-note > svg { width: 18px; height: 18px; flex: 0 0 auto; color: var(--blue); margin-top: 1px; }

.video-panel, .ptz-panel { border-color: #d6dfdb; box-shadow: 0 12px 30px rgba(23, 41, 35, .09); }
.video-toolbar { background: #fbfcfb; }
.video-wrap, video { background: #09120f; }
.empty-video { color: #dbe6e2; }
.empty-video > svg { width: 38px; height: 38px; margin-bottom: 5px; color: #6f8b81; }
.ptz-panel { background: #fbfcfb; }
.ptz-pad { background: #e9efec; box-shadow: inset 0 0 0 1px #dfe7e3; }
.ptz-pad button, .zoom-control button { display: grid; place-items: center; }
.ptz-pad button svg { width: 25px; height: 25px; }
.ptz-pad [data-ptz-stop] svg { width: 13px; height: 13px; }
.zoom-control button svg { width: 19px; height: 19px; }
.address-card { transition: border-color .16s, box-shadow .16s; }
.address-card:hover { border-color: #aec4bb; box-shadow: 0 8px 22px rgba(28, 45, 39, .06); }

.camera-context { min-width: 0; display: flex; align-items: center; gap: 12px; margin: -5px 0 16px; padding: 11px 13px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); box-shadow: 0 2px 12px rgba(28,45,39,.035); }
.camera-context > label { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 11px; font-weight: 650; }
.camera-context select { min-width: 220px; height: 36px; border: 1px solid #cfd8d3; border-radius: 6px; padding: 0 32px 0 10px; background: #fff; color: var(--text); font-weight: 650; }
.identity-pair { min-width: 0; display: flex; align-items: center; gap: 7px; padding-left: 12px; border-left: 1px solid var(--line); }
.identity-pair span, .camera-identities span { color: var(--muted); font-size: 10px; }
.identity-pair code { max-width: 230px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #284a40; font-size: 11px; }
.camera-context > .state-pill { margin-left: auto; }
.stream-profile-control { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 11px; font-weight: 650; }
.segmented-control { display: grid; grid-template-columns: repeat(3, minmax(68px, 1fr)); padding: 3px; border: 1px solid #cfd8d3; border-radius: 7px; background: #edf2ef; }
.segmented-control button { min-height: 28px; padding: 4px 9px; border-radius: 5px; color: #53655f; background: transparent; font-size: 11px; }
.segmented-control button.active { color: #fff; background: var(--accent); box-shadow: 0 1px 3px rgba(16, 61, 47, .18); }
.segmented-control button:disabled { color: #9aa6a2; background: transparent; }
.profile-url + .profile-url { margin-top: 10px; }
.profile-url > b, .cloud-profile-label { display: block; margin-bottom: 5px; color: var(--muted); font-size: 10px; }

@media (min-width: 821px) and (max-width: 1400px) {
  .camera-context { flex-wrap: wrap; }
  .camera-context > label { flex: 1 1 300px; }
  .camera-context select { flex: 1; min-width: 0; }
  .stream-profile-control { margin-left: auto; }
  .identity-pair { order: 2; flex: 1 1 calc(50% - 6px); padding-left: 0; border-left: 0; }
  .camera-context > .state-pill { margin-left: 0; }
}

.cameras-section { margin-top: 24px; }
.cameras-section > .section-head { align-items: center; }
.section-actions { display: flex; justify-content: flex-end; gap: 8px; }
.camera-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); gap: 12px; }
.camera-management-card { min-width: 0; padding: 16px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); box-shadow: 0 2px 12px rgba(28,45,39,.035); }
.camera-management-card.selected { border-color: #8cb8a8; box-shadow: inset 3px 0 0 var(--accent), 0 7px 20px rgba(28,45,39,.06); }
.camera-management-card > header, .camera-card-title { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.camera-card-title { justify-content: flex-start; }
.camera-card-title .camera-icon { width: 36px; height: 36px; }
.camera-card-title h3 { margin: 0; font-size: 15px; letter-spacing: 0; }
.camera-card-title div > span { color: var(--muted); font-size: 10px; }
.camera-identities { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin: 14px 0; }
.camera-identities > div { min-width: 0; padding: 9px; border-radius: 6px; background: #f2f6f4; }
.camera-identities span, .camera-identities code { display: block; }
.camera-identities code { margin-top: 3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #294a40; font-size: 11px; }
.camera-management-card dl { display: grid; gap: 7px; margin: 0; padding: 12px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.camera-management-card dl div { min-width: 0; display: grid; grid-template-columns: 58px minmax(0, 1fr); gap: 8px; }
.camera-management-card dt { color: var(--muted); font-size: 10px; }
.camera-management-card dd { margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #435b54; font-family: monospace; font-size: 10px; }
.camera-management-card dd small { display: block; margin-top: 3px; overflow: hidden; color: #7a8d87; font-family: inherit; text-overflow: ellipsis; }
.camera-management-card footer { display: flex; justify-content: flex-end; gap: 7px; padding-top: 12px; }
.camera-management-card footer button { min-height: 32px; padding: 6px 9px; font-size: 11px; }

.modal-backdrop { position: fixed; inset: 0; z-index: 40; display: grid; place-items: center; padding: 20px; background: rgba(10,25,20,.55); }
.modal-backdrop[hidden] { display: none; }
.camera-modal { width: min(680px, 100%); max-height: calc(100vh - 40px); overflow: auto; border-radius: 8px; background: #fff; box-shadow: 0 24px 70px rgba(5,20,15,.28); }
.device-info-modal { width: min(560px, 100%); }
.camera-modal > header { display: flex; align-items: center; justify-content: space-between; padding: 18px 20px; border-bottom: 1px solid var(--line); }
.camera-modal > header p { margin: 0 0 3px; color: var(--accent); font-size: 10px; font-weight: 750; }
.camera-modal > header h2 { margin: 0; font-size: 19px; letter-spacing: 0; }
.modal-close { width: 36px; min-height: 36px; padding: 0; display: grid; place-items: center; background: #eef3f1; color: #40564f; }
.camera-form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 15px; padding: 20px; }
.camera-form-grid label { min-width: 0; display: grid; gap: 6px; color: #354b44; font-size: 12px; font-weight: 650; }
.camera-form-grid input:not([type="checkbox"]) { width: 100%; min-height: 42px; border: 1px solid #cfd8d3; border-radius: 6px; padding: 9px 11px; outline: none; }
.camera-form-grid input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(23,119,91,.11); }
.camera-form-grid input[readonly] { color: #62736d; background: #f1f5f3; cursor: default; }
.camera-form-grid small { color: var(--muted); font-size: 9px; font-weight: 400; }
.camera-form-grid .span-two { grid-column: span 2; }
.toggle-line { display: flex !important; grid-template-columns: auto 1fr; align-items: center; justify-content: flex-start; }
.toggle-line input { width: 16px; height: 16px; accent-color: var(--accent); }
.camera-modal .form-error { margin: -7px 20px 8px; }
.camera-modal form > footer { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px 18px; border-top: 1px solid var(--line); }
.integration-table-panel .data-table td:last-child { min-width: 190px; }
.integration-actions { display: flex; gap: 7px; }
.integration-actions button { min-height: 32px; padding: 6px 9px; font-size: 11px; white-space: nowrap; }
.integration-status { display: inline-flex; align-items: center; min-height: 24px; padding: 3px 8px; border-radius: 999px; font-size: 11px; font-weight: 750; }
.integration-status.enabled { color: #176446; background: #e1f3e9; }
.integration-status.disabled { color: #8a3d3d; background: #f8e8e8; }
.integration-status.neutral { color: #566962; background: #e9efec; }
.integration-modal { width: min(760px, 100%); }
.integration-scopes, .integration-resources { min-width: 0; margin: 0; padding: 14px; border: 1px solid #d6dfdb; border-radius: 6px; }
.integration-scopes legend, .integration-resources legend { padding: 0 6px; color: #354b44; font-size: 12px; font-weight: 700; }
.integration-scopes { display: flex; flex-wrap: wrap; gap: 12px 22px; }
.integration-scopes label { display: flex; grid-template-columns: none; align-items: center; gap: 8px; }
.integration-scopes input, .resource-permission-list input { width: 16px; height: 16px; accent-color: var(--accent); }
.resource-permission-list { display: grid; gap: 12px; max-height: 270px; overflow: auto; }
.resource-permission-list section { border-bottom: 1px solid #e5ebe8; padding-bottom: 10px; }
.resource-permission-list section:last-child { border-bottom: 0; padding-bottom: 0; }
.resource-permission-list section > header { display: flex; justify-content: space-between; gap: 12px; margin-bottom: 8px; }
.resource-permission-list section > header code { color: var(--muted); font-size: 10px; }
.resource-permission-list label { display: grid; grid-template-columns: 18px minmax(0, 1fr) auto; align-items: center; gap: 8px; padding: 6px 4px; font-weight: 500; }
.resource-permission-list label code { color: var(--muted); font-size: 10px; }
.resource-empty { margin: 0; color: var(--muted); font-size: 12px; }
.secret-modal { width: min(620px, 100%); }
.secret-modal > footer { display: flex; justify-content: flex-end; padding: 14px 20px 18px; border-top: 1px solid var(--line); }
.secret-content { display: grid; gap: 15px; padding: 20px; }
.secret-content > p { margin: 0; color: #7b4d16; background: #fff7df; border: 1px solid #ead59c; border-radius: 6px; padding: 11px 12px; font-size: 12px; }
.secret-content label { display: grid; gap: 6px; color: #40544d; font-size: 12px; font-weight: 700; }
.secret-content label > div { display: grid; grid-template-columns: minmax(0, 1fr) 36px; align-items: center; border: 1px solid #d3ddd9; border-radius: 6px; background: #f5f8f6; }
.secret-content code { min-width: 0; padding: 11px 12px; overflow-wrap: anywhere; color: #183b30; }
.secret-content .icon-button { color: #46645b; }

.deployment-log-panel { border-color: #243b34; background: #10221d; box-shadow: 0 12px 30px rgba(13, 31, 26, .13); }
.deployment-log-panel .section-head { border-color: #2a433b; }
.deployment-log { scrollbar-color: #47645b #10221d; }

.login-shell { grid-template-columns: minmax(560px, 1.45fr) minmax(420px, .75fr); }
.login-brand { align-items: end; padding: 64px 70px; background-color: #142722; background-image: url("./assets/reserve-monitoring-login.png"); background-size: cover; background-position: center; }
.login-brand::before { content: ""; position: absolute; inset: 0; background: rgba(9, 25, 20, .38); }
.login-brand::after { content: none; }
.login-brand-inner { max-width: 590px; padding: 28px 0; }
.brand-mark.large { width: 52px; height: 52px; margin-bottom: 28px; background: rgba(20, 119, 89, .88); backdrop-filter: blur(8px); }
.brand-mark.large svg { width: 29px; height: 29px; }
.login-brand-inner > p { margin: 0 0 8px; color: #a9dbca; letter-spacing: 0 !important; }
.login-brand h1 { font-size: 43px; font-weight: 760; text-shadow: 0 2px 16px rgba(0,0,0,.18); }
.login-brand-inner > span:not(.brand-mark) { max-width: 520px; margin-top: 13px; color: #d9e4e0; font-size: 15px; line-height: 1.7; }
.login-signal { display: flex; align-items: center; gap: 8px; margin-top: 26px; color: #c9d8d3; font-size: 12px; }
.login-signal > span { width: 7px; height: 7px; margin: 0; border-radius: 50%; background: #62d6a9; box-shadow: 0 0 0 5px rgba(98, 214, 169, .14); }
.login-panel { background: #f5f7f4; }
.login-form { width: min(390px, 100%); gap: 17px; }
.login-form header { position: relative; margin-bottom: 12px; }
.login-form-icon { width: 40px; height: 40px; display: grid !important; place-items: center; margin: 0 0 20px !important; border-radius: 8px; color: var(--accent); background: var(--accent-soft); }
.login-form-icon svg { width: 21px; height: 21px; }
.login-form h2 { font-size: 28px; font-weight: 730; }
.input-with-icon { position: relative; }
.input-with-icon > svg { position: absolute; left: 13px; top: 50%; z-index: 1; width: 17px; height: 17px; color: #84918d; transform: translateY(-50%); pointer-events: none; }
.login-form .input-with-icon input { min-height: 46px; padding-left: 41px; }
.login-form > button { display: flex; align-items: center; justify-content: center; gap: 8px; min-height: 46px; margin-top: 3px; }

/* Corporate identity */
.brand-logo {
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  object-fit: contain;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 0 0 1px rgba(255,255,255,.16), 0 4px 14px rgba(0,0,0,.14);
}
.brand > span:last-child { min-width: 0; }
.brand small { max-width: 158px; font-size: 9px; white-space: nowrap; }
.login-logo {
  display: block;
  width: 76px;
  height: 76px;
  margin-bottom: 26px;
  object-fit: contain;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 8px 28px rgba(0,0,0,.2);
}
.login-brand-inner > .login-company {
  display: block;
  margin-top: 12px;
  color: #d6e1dd;
  font-size: 13px;
  line-height: 1.5;
}
.login-brand-inner > .login-tagline {
  display: block;
  margin-top: 7px;
  color: #fff;
  font-size: 17px;
  font-weight: 650;
  line-height: 1.55;
}
.page-tagline { color: #3f5550 !important; font-weight: 550; }

.permission-fieldset { border: 1px solid #dce5e1; padding: 14px; border-radius: 6px; }
.permission-fieldset legend { padding: 0 6px; color: #263d36; font-weight: 700; }
.permission-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.permission-grid label { display: flex; align-items: center; gap: 8px; min-height: 42px; padding: 9px 10px; background: #f5f8f6; border: 1px solid #e0e8e4; border-radius: 5px; }
.permission-grid label span { min-width: 0; }
.permission-grid label small { display: block; margin-top: 2px; color: #71817c; }
.device-permission-grid { max-height: 220px; overflow-y: auto; }
.user-modal { width: min(820px, calc(100vw - 32px)); }
.settings-layout { display: grid; grid-template-columns: minmax(340px, .8fr) minmax(500px, 1.2fr); gap: 18px; align-items: start; }
.settings-panel, .trend-panel { background: #fff; border: 1px solid #dce5e1; border-radius: 7px; padding: 20px; }
.settings-panel > label { display: grid; gap: 7px; margin-bottom: 16px; color: #344b44; font-weight: 650; }
.settings-panel input, .settings-panel textarea, .filter-bar input, .filter-bar select { width: 100%; border: 1px solid #cbd8d3; border-radius: 5px; padding: 10px 11px; background: #fff; color: #182a25; }
.form-grid-two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-grid-two label { display: grid; gap: 7px; margin-bottom: 16px; font-weight: 650; }
.switch-control { display: flex !important; grid-template-columns: none !important; align-items: center; gap: 8px; margin: 0 !important; }
.switch-control input { width: auto; }
.input-suffix { display: flex; align-items: center; gap: 8px; }
.input-suffix input { max-width: 120px; }
.schedule-strip { display: flex; align-items: center; gap: 12px; padding: 12px; margin: 4px 0 18px; background: #f2f7f4; border-left: 3px solid #347957; }
.schedule-strip span { display: flex; align-items: center; gap: 5px; font-weight: 750; }
.schedule-strip svg { width: 16px; }
.schedule-strip p { margin-left: auto; color: #667871; font-size: 12px; }
.status-good { color: #287149 !important; }.status-warn { color: #a05b20 !important; }
.filter-bar { display: grid; grid-template-columns: repeat(3, minmax(150px, 1fr)) auto auto; gap: 10px; align-items: end; padding: 15px; margin-bottom: 16px; background: #fff; border: 1px solid #dce5e1; border-radius: 7px; }
.traffic-filter-bar { grid-template-columns: repeat(4, minmax(135px, 1fr)) auto auto; }
.filter-bar label { display: grid; gap: 6px; color: #455b54; font-size: 12px; font-weight: 700; }
.traffic-stats { grid-template-columns: repeat(4, minmax(0, 1fr)); max-width: none; }
.traffic-stats strong { font-size: 25px; }
.traffic-layout { display: grid; grid-template-columns: minmax(520px, 1.25fr) minmax(300px, .75fr); gap: 18px; align-items: start; }
.traffic-trend { display: grid; gap: 11px; }
.traffic-trend > div { display: grid; grid-template-columns: 42px minmax(80px, 1fr) 76px; align-items: center; gap: 8px; font-size: 12px; }
.traffic-trend > div > div { height: 8px; background: #e8efeb; border-radius: 4px; overflow: hidden; }
.traffic-trend i { display: block; height: 100%; background: #347957; border-radius: inherit; }
.traffic-trend strong { text-align: right; font-size: 11px; }
.traffic-detail-panel { margin-top: 18px; }
.traffic-detail-panel > .section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.traffic-detail-table { min-width: 1160px; }
.traffic-detail-table td { min-width: 130px; }
.traffic-detail-table td:first-child { min-width: 230px; }
.traffic-detail-table td:nth-child(3) { min-width: 210px; }
.traffic-detail-table td:nth-child(4) { min-width: 155px; max-width: none; overflow: visible; white-space: normal; }
.traffic-detail-table td:nth-child(7) { min-width: 150px; }
.table-pagination { display: flex; align-items: center; justify-content: flex-end; gap: 12px; padding: 12px 16px; border-top: 1px solid var(--line); background: #fafcfb; }
.table-pagination > span { min-width: 90px; text-align: center; color: var(--muted); font-size: 12px; }
.table-pagination button { min-height: 36px; }
.login-apply { display: flex; align-items: center; justify-content: center; gap: 8px; color: #6b7d77; font-size: 13px; }
.login-apply a { display: inline-flex; align-items: center; gap: 5px; color: var(--accent); font-weight: 750; }
.login-apply svg { width: 16px; height: 16px; }
.application-page-panel { overflow-y: auto; align-items: start; padding-top: 34px; padding-bottom: 34px; }
.application-form { gap: 14px; }
.application-form header { margin-bottom: 2px; }
.application-form header .back-link { margin-bottom: 18px; }
.application-fields { display: grid; gap: 13px; }
.application-password-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.application-password-grid label { min-width: 0; }
.application-form textarea { width: 100%; resize: vertical; border: 1px solid #ccd8da; border-radius: 6px; padding: 11px 13px; }
.application-honeypot { position: absolute !important; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
.application-success { padding: 24px 0; text-align: center; }
.application-success > svg { width: 48px; height: 48px; color: var(--accent); }
.application-success h3 { margin: 13px 0 7px; font-size: 23px; }
.application-success p { color: var(--muted); line-height: 1.7; }
.application-success code { display: block; margin: 18px 0; padding: 10px; background: #edf4f0; color: #245e47; }
.primary-link { display: inline-flex; min-height: 42px; align-items: center; justify-content: center; padding: 0 18px; border-radius: 5px; color: #fff; background: var(--accent); font-weight: 750; }
.application-panel { margin-bottom: 18px; }
.count-badge { display: grid; min-width: 30px; height: 30px; place-items: center; border-radius: 15px; color: #fff; background: var(--accent); font-weight: 800; }
.application-summary { margin: 0 20px 14px; padding: 13px 15px; background: #f1f6f3; border-left: 3px solid var(--accent); }
.application-summary dl { display: grid; gap: 8px; margin: 0; }
.application-summary dl div { display: grid; grid-template-columns: 82px 1fr; gap: 10px; }
.application-summary dt { color: #6b7d77; font-size: 12px; }.application-summary dd { margin: 0; overflow-wrap: anywhere; }
.account-layout { display: grid; grid-template-columns: minmax(250px, .65fr) minmax(380px, 1fr); gap: 18px; align-items: start; max-width: 920px; }
.account-profile { display: flex; align-items: center; gap: 16px; padding: 22px; background: #17332a; color: #fff; border-radius: 7px; }
.account-avatar { display: grid; width: 58px; height: 58px; flex: 0 0 58px; place-items: center; border: 1px solid rgba(255,255,255,.35); border-radius: 50%; background: #347957; font-size: 22px; font-weight: 800; }
.account-profile small { color: #a8c3b8; }.account-profile h2 { margin: 4px 0; font-size: 20px; }.account-profile p { color: #d4e3dc; }
.password-panel .section-head { margin-bottom: 18px; }.password-panel .section-head svg { width: 30px; height: 30px; color: var(--accent); }
.password-panel label small { color: var(--muted); font-size: 12px; font-weight: 500; }
.password-panel button { justify-self: start; }

@media (max-width: 1050px) {
  .app-shell { grid-template-columns: 210px minmax(0, 1fr); }
  .login-shell { grid-template-columns: minmax(380px, 1fr) minmax(390px, .85fr); }
  .login-brand { padding: 45px; }
  .settings-layout, .traffic-layout { grid-template-columns: 1fr; }
  .account-layout { grid-template-columns: 1fr; }
  .traffic-filter-bar { grid-template-columns: repeat(2, minmax(150px, 1fr)) auto auto; }
}

@media (max-width: 820px) {
  .app-shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar {
    position: sticky;
    top: 0;
    z-index: 12;
    width: 100%;
    height: auto;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    padding: 10px 12px;
  }
  .brand { padding: 0; border: 0; }
  .brand-mark { width: 34px; height: 34px; flex-basis: 34px; }
  .brand-mark svg { width: 19px; height: 19px; }
  .brand-logo { width: 34px; height: 34px; flex-basis: 34px; }
  .brand small, .operator, .nav-icon { display: none; }
  .brand strong { font-size: 14px; white-space: nowrap; }
  .nav { display: flex; justify-content: flex-start; gap: 3px; margin: 0; overflow-x: auto; scrollbar-width: none; }
  .nav a { min-height: 36px; padding: 8px 9px; font-size: 12px; white-space: nowrap; }
  .nav a.active::before { inset: auto 9px 0; width: auto; height: 2px; border-radius: 2px 2px 0 0; }
  .sidebar-foot { margin: 0 0 0 5px; padding: 0; border: 0; }
  .sidebar-foot .avatar { display: none; }
  .icon-button { width: 34px; height: 34px; }
  .main { padding: 22px 18px 36px; }
  .device-head { min-width: 0; }
  .device-head > div:first-child { min-width: 0; }
  .device-head h1 { overflow-wrap: anywhere; }
  .stream-switch { max-width: 100%; }
  .control-layout { grid-template-columns: minmax(0, 1fr); }
  .gate-door-grid { grid-template-columns: minmax(0, 1fr); }
  .video-panel, .ptz-panel, .address-card { max-width: 100%; }
  .camera-context { flex-wrap: wrap; }
  .camera-context > label { width: 100%; }
  .camera-context select { flex: 1; min-width: 0; }
  .identity-pair { flex: 1 1 220px; padding-left: 0; border-left: 0; }
  .camera-context > .state-pill { margin-left: 0; }
  .login-page { overflow: auto; }
  .login-shell { display: block; background: #f5f7f4; }
  .login-brand { min-height: 310px; padding: 30px 24px; align-items: end; background-position: 47% center; }
  .login-brand-inner { padding: 0; }
  .login-brand h1 { font-size: 34px; }
  .login-logo { width: 62px; height: 62px; margin-bottom: 18px; }
  .login-brand-inner > .login-company { margin-top: 8px; font-size: 12px; }
  .login-brand-inner > .login-tagline { margin-top: 5px; font-size: 14px; }
  .login-panel { padding: 34px 24px 48px; }
  .permission-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .filter-bar { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .traffic-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 560px) {
  .sidebar { grid-template-columns: auto minmax(0, 1fr) auto; padding: 8px 10px; }
  .brand { gap: 7px; }
  .brand strong { font-size: 13px; }
  .nav a { padding: 7px 8px; font-size: 11px; }
  .main { padding: 18px 14px 30px; }
  .stats { grid-template-columns: repeat(3, minmax(0, 1fr)); max-width: none; gap: 8px; }
  .stats div { min-height: 88px; padding: 13px 12px; }
  .stats span { font-size: 10px; gap: 4px; }
  .stats span svg { width: 13px; height: 13px; }
  .stats strong { font-size: 24px; }
  .page-head h1 { font-size: 23px; }
  #refreshDevices { width: 42px; min-width: 42px; padding: 0; }
  #refreshDevices span { display: none; }
  .device-head h1 { font-size: 21px; }
  .stream-switch { width: 100%; }
  .stream-switch button { min-width: 0; }
  .ptz-panel { min-height: 0; }
  .gate-actions { grid-template-columns: minmax(0, 1fr); }
  .gate-mode-control { align-items: stretch; flex-direction: column; }
  .camera-list { grid-template-columns: minmax(0, 1fr); }
  .camera-identities, .camera-form-grid { grid-template-columns: 1fr; }
  .camera-form-grid .span-two { grid-column: span 1; }
  .camera-context select { width: 100%; }
  .identity-pair { flex-basis: 100%; }
  .login-brand { min-height: 280px; }
  .permission-grid, .form-grid-two, .filter-bar { grid-template-columns: 1fr; }
  .application-password-grid { grid-template-columns: 1fr; }
  .schedule-strip { align-items: flex-start; flex-wrap: wrap; }
  .schedule-strip p { width: 100%; margin-left: 0; }
  .traffic-detail-panel > .section-head { align-items: flex-start; }
  .traffic-detail-panel > .section-head button span { display: none; }
  .table-pagination { justify-content: space-between; }
}
/* Portal configuration follows the console's compact form layout. */
.portal-page { max-width: 960px; margin: 0 auto; padding: 32px 24px; }
.portal-page section { padding: 24px 0; border-top: 1px solid #dbe4e1; }
.portal-page form { max-width: 640px; display: grid; gap: 16px; }
.portal-page label { display: grid; gap: 8px; }
.portal-page input, .portal-page select { width: 100%; max-width: 100%; min-width: 0; min-height: 42px; padding: 9px 12px; border: 1px solid #c6d5ce; border-radius: 5px; background: #fff; font: inherit; }
.portal-status { display: grid; grid-template-columns: 120px minmax(0, 1fr); gap: 12px; }
.portal-status dd { margin: 0; overflow-wrap: anywhere; }
.portal-checks { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; }
.portal-checks label { display: flex; align-items: center; }
.portal-checks input { width: auto; min-height: auto; }
.portal-error { max-width: 600px; padding: 32px 20px; margin: 40px auto; }
.portal-login { display: flex; align-items: center; justify-content: center; gap: 10px; padding: 12px; border: 1px solid #357559; border-radius: 6px; }
.portal-login svg { width: 20px; height: 20px; }
