:root{color-scheme:dark;font-family:Vazirmatn,Tahoma,Arial,sans-serif;background:#081321;color:#e9f1f8;font-synthesis:none}*{box-sizing:border-box}body{margin:0;min-height:100vh;background:radial-gradient(ellipse at 9% 0,rgba(30,111,115,.16),transparent 34rem),radial-gradient(ellipse at 90% 2%,rgba(83,65,142,.14),transparent 36rem),#081321}a{color:#88d9d2;text-decoration:none}a:hover{color:#b8fff2}.site-header{height:78px;padding:0 max(24px,calc((100vw - 1320px)/2));display:flex;align-items:center;gap:38px;background:rgba(8,18,31,.9);border-bottom:1px solid #20344a;position:sticky;top:0;z-index:10;backdrop-filter:blur(16px)}.brand{display:flex;align-items:center;gap:12px;color:#f3f8fc;white-space:nowrap}.brand-mark{width:42px;height:42px;border-radius:13px;background:#174448;color:#7fe9d6;display:grid;place-items:center;font-size:24px}.brand b{display:block;font-size:14px}.brand small{display:block;color:#6f9ca5;font:9px Arial;letter-spacing:1.6px;margin-top:3px}.site-header nav{display:flex;gap:22px;flex:1}.site-header nav a{font-size:12px;color:#9aafc2}.account{display:flex;align-items:center;gap:14px;font-size:12px;color:#adbdca}.account form{margin:0}.page-shell{max-width:1320px;margin:0 auto;padding:32px 24px 70px}.hero{display:flex;align-items:center;justify-content:space-between;gap:24px;padding:27px 30px;margin-bottom:20px;border:1px solid rgba(94,207,190,.2);border-radius:22px;background:linear-gradient(110deg,rgba(18,59,64,.9),rgba(17,34,53,.97) 64%,rgba(38,34,68,.8));box-shadow:0 18px 50px #0003}.hero.compact{padding:22px 26px}.eyebrow{color:#6ee0cb;font:700 9px Arial,sans-serif;letter-spacing:1.8px}.hero h1{font-size:clamp(23px,3vw,34px);margin:9px 0 7px}.hero p{color:#9eb2c3;font-size:13px;line-height:1.9;margin:0}.hero code,.breadcrumb code{direction:ltr;color:#91afc4;font-size:10px}.hero-actions,.inline-actions{display:flex;align-items:center;gap:12px;flex-wrap:wrap}.breadcrumb{color:#8aa1b4;font-size:11px;margin:0 0 13px}.muted{color:#8ea5b8;font-size:12px;line-height:1.9}.btn{border:1px solid transparent;border-radius:10px;padding:10px 15px;font:600 12px Vazirmatn,sans-serif;cursor:pointer;transition:.16s ease}.btn:hover{transform:translateY(-1px);filter:brightness(1.1)}.btn:disabled{opacity:.55;cursor:wait;transform:none}.btn.primary{background:#1e6d63;border-color:#368e80;color:#e9fff9}.btn.secondary{background:#172b40;border-color:#314a60;color:#c8d9e5}.btn.ghost{background:transparent;border-color:#35485c;color:#a9bece;padding:7px 11px}.stats-grid{display:grid;grid-template-columns:repeat(4,1fr);gap:13px;margin-bottom:36px}.stat-card{border:1px solid #23394e;border-radius:15px;padding:17px 18px;background:linear-gradient(145deg,#13243a,#101e30);min-height:120px}.stat-card small{display:block;color:#89a2b5;font-size:11px}.stat-card strong{display:block;font-size:26px;color:#eff9fc;margin:7px 0 2px}.stat-card span{font-size:10px;color:#6e899d}.section{margin-top:34px}.section-heading{display:flex;align-items:flex-end;justify-content:space-between;gap:12px;margin-bottom:14px}.section-heading h2{margin:5px 0 0;font-size:19px}.device-grid{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:14px}.device-card,.empty-card{border:1px solid #263d51;border-radius:16px;padding:18px;background:linear-gradient(150deg,#14263a,#101e2e);color:#eaf4fa;min-width:0}.device-card{display:block;transition:.16s ease}.device-card:hover{border-color:#4a938e;transform:translateY(-2px);color:#fff}.device-card-top{display:flex;justify-content:space-between;align-items:center}.camera-icon{width:40px;height:40px;border-radius:12px;background:#193c48;color:#81d8d0;display:grid;place-items:center;font-size:21px}.state{display:inline-flex;align-items:center;gap:7px;border-radius:30px;padding:6px 9px;font-size:10px;background:#173b38;color:#9ce9d6;border:1px solid #285d54;white-space:nowrap}.state i{width:7px;height:7px;border-radius:50%;background:#4ed49a;box-shadow:0 0 12px #4ed49a}.state.online{background:#163a35;color:#91e0c3;border-color:#286954}.state.offline{background:#382630;color:#efa7b1;border-color:#75434d}.state.offline i{background:#dc7583;box-shadow:0 0 9px #dc7583}.state.warning{background:#46351f;color:#f3cb88;border-color:#80602f}.device-card h3{margin:15px 0 4px;font-size:16px}.device-card code{display:block;color:#91afc4;font-size:10px;direction:ltr;text-align:left;overflow-wrap:anywhere}.device-meta{display:flex;justify-content:space-between;padding-top:11px;margin-top:11px;border-top:1px solid #26394c;font-size:11px;color:#8099ac;gap:10px}.device-meta b{color:#c9dce8;font-weight:600;text-align:left}.device-footer{display:flex;justify-content:space-between;align-items:center;gap:10px;border-top:1px solid #26394c;padding-top:14px;margin-top:14px;color:#7892a6;font-size:9px}.device-footer b{color:#7ddacb;font-size:10px}.empty-card{text-align:center;grid-column:1/-1;padding:42px 20px}.empty-card h3{margin:8px 0}.empty-card p{max-width:480px;margin:0 auto 17px}.table-wrap{border:1px solid #24394d;border-radius:14px;overflow:auto;background:#101e2e}table{width:100%;border-collapse:collapse;font-size:11px;min-width:680px}th,td{padding:13px 15px;text-align:right;border-bottom:1px solid #23384a;white-space:nowrap}th{color:#89a7bb;background:#14273b;font-weight:600}td{color:#c4d3df}tbody tr:last-child td{border-bottom:0}.empty{text-align:center;color:#7690a4;padding:27px}.event-type{color:#f5bd75}.retention-form{display:grid;grid-template-columns:repeat(4,1fr);gap:13px;align-items:end;padding:18px;border:1px solid #263a4e;background:#111f30;border-radius:15px}.retention-form label,.stack label{display:grid;gap:7px;color:#a4b7c7;font-size:11px}.retention-form input,.stack input{width:100%;border:1px solid #344a60;background:#091625;color:#e6f2fa;border-radius:9px;padding:10px 11px;outline:none}.retention-form input:focus,.stack input:focus{border-color:#59bcae}.modal{position:fixed;inset:0;background:rgba(1,7,14,.8);display:none;place-items:center;padding:18px;z-index:50;backdrop-filter:blur(12px)}.modal.open{display:grid}.modal-panel{width:min(500px,100%);position:relative;text-align:center;background:#122338;border:1px solid #35576b;border-radius:20px;padding:28px}.modal-panel h2{margin:8px 0;font-size:21px}.modal-panel p{max-width:380px;margin:0 auto 13px}.modal-close{position:absolute;left:14px;top:10px;border:0;background:none;color:#b7c9d7;font-size:27px;cursor:pointer}.qr-wrap{margin:17px auto;background:white;border-radius:14px;width:280px;height:280px;display:grid;place-items:center}.qr-wrap img{display:block;width:100%;height:100%!important;max-width:100%;object-fit:contain;padding:14px;image-rendering:pixelated}.pair-code-tools{display:grid;gap:9px;max-width:420px;margin:0 auto}.pair-code{display:block;color:#91afc4;font-size:10px;direction:ltr;text-align:left;overflow-wrap:anywhere;padding:10px;background:#0a1726;border-radius:8px}.pair-code-tools .btn{justify-self:center}.detail-grid{display:grid;grid-template-columns:1.4fr .8fr;gap:16px}.panel{padding:20px;border:1px solid #263b50;border-radius:16px;background:#111f30;min-width:0}.panel h2{font-size:17px;margin:6px 0 15px}.panel video{width:100%;min-height:250px;max-height:520px;object-fit:contain;background:#03080f;border-radius:11px}.health-list{display:grid;gap:0}.health-list div{display:flex;justify-content:space-between;gap:12px;padding:12px 0;border-bottom:1px solid #24384b;font-size:11px}.health-list div:last-child{border-bottom:0}.health-list span{color:#88a0b3}.health-list b{color:#d7e7f0;text-align:left}.alarm-grid{display:grid;grid-template-columns:repeat(3,1fr);gap:14px}.alarm-card{border:1px solid #2a3e51;border-radius:15px;background:#111f30;overflow:hidden}.alarm-card img{display:block;width:100%;height:180px;object-fit:cover;background:#050d17}.no-image{height:180px;display:grid;place-items:center;color:#7a92a5;background:#0a1725;font-size:11px}.alarm-body{padding:14px}.alarm-title{display:flex;justify-content:space-between;align-items:center;gap:8px;margin-bottom:8px}.alarm-title b{font-size:13px}.alarm-body .muted{font-size:10px}.alarm-meta{display:flex;justify-content:space-between;margin-top:10px;padding-top:10px;border-top:1px solid #293e51;font-size:11px;color:#8da5b8}.ack-form{margin-top:12px}.ack-form .btn{font-size:10px}.alarm-body details{color:#8fa5b7;font-size:10px}.alarm-body pre{white-space:pre-wrap;word-break:break-all;color:#b3c8d5;background:#0a1725;padding:10px;border-radius:8px}.messages{margin-bottom:16px}.message{padding:11px;border-radius:9px;background:#173b38;color:#a8ead6;font-size:11px}.auth-page{display:grid;place-items:center;padding:20px;min-height:100vh}.auth-card{width:min(440px,100%);padding:34px;border:1px solid #2a4659;border-radius:22px;background:linear-gradient(145deg,#14283b,#0e1a2a);box-shadow:0 25px 80px #0005}.auth-card h1{font-size:24px;margin:8px 0}.auth-card .muted{margin:0 0 22px}.auth-card .brand-mark{margin-bottom:18px}.stack{display:grid;gap:12px}.stack .btn{margin-top:6px}.btn.block{width:100%}.alert{padding:11px;border-radius:9px;font-size:11px;margin:10px 0}.alert.danger{background:#4a2933;color:#ffc0c8}.auth-note{font-size:10px;color:#7792a5;margin-top:20px}.site-footer{display:flex;justify-content:space-between;gap:15px;max-width:1320px;margin:0 auto;padding:18px 24px 24px;color:#5d768a;font-size:9px;border-top:1px solid #1e3042}@media(max-width:1000px){.device-grid{grid-template-columns:repeat(2,1fr)}.stats-grid{grid-template-columns:repeat(2,1fr)}.retention-form{grid-template-columns:repeat(2,1fr)}.alarm-grid{grid-template-columns:repeat(2,1fr)}}@media(max-width:700px){.site-header{height:auto;min-height:70px;padding:12px 15px;gap:13px;flex-wrap:wrap}.site-header nav{order:3;flex-basis:100%;gap:18px}.account{margin-right:auto}.page-shell{padding:18px 13px 44px}.hero{padding:20px;align-items:flex-start;flex-direction:column}.hero h1{font-size:25px}.hero-actions{width:100%;justify-content:space-between}.device-grid,.alarm-grid,.detail-grid{grid-template-columns:1fr}.stats-grid{gap:9px}.stat-card{min-height:105px;padding:13px}.stat-card strong{font-size:22px}.section-heading{align-items:flex-start;flex-direction:column}.retention-form{grid-template-columns:1fr}.panel{padding:15px}.site-footer{padding:15px;flex-direction:column}.modal-panel{padding:23px 17px}.qr-wrap{width:255px;height:255px}.event-item{align-items:flex-start;flex-direction:column}}

/* Incremental live alert UX: images are inserted once per new alert, never rebuilt by status polling. */
.alarm-image-cell{width:104px}.alarm-thumb{display:block;width:84px;height:58px;object-fit:cover;border:1px solid #345067;border-radius:8px;background:#071321}
[data-live-alerts] .section-heading{align-items:center}
[data-live-alerts] .inline-actions{justify-content:flex-end}
.live-new-alarm{animation:live-alarm-in .35s ease-out;border-color:#a77a3e;box-shadow:0 0 0 1px #a77a3e22,0 12px 30px #0003}
@keyframes live-alarm-in{from{opacity:.45;transform:translateY(-8px)}to{opacity:1;transform:translateY(0)}}
.alert-toast-region{position:fixed;z-index:100;top:92px;left:20px;width:min(390px,calc(100vw - 28px));display:grid;gap:9px;pointer-events:none}
.alert-toast{display:flex;align-items:flex-start;gap:12px;padding:14px 14px 13px 10px;border:1px solid #8c6a3e;border-radius:13px;background:rgba(19,33,49,.97);box-shadow:0 15px 40px #0008;backdrop-filter:blur(14px);pointer-events:auto;animation:live-alarm-in .25s ease-out}
.alert-toast-content{display:grid;gap:4px;min-width:0;flex:1}
.alert-toast-content b{font-size:12px;color:#ffd18d}
.alert-toast-content span{font-size:11px;color:#dbe7ed}
.alert-toast-content small{font-size:9px;color:#8fa6b7}
.alert-toast-content a{font-size:10px;font-weight:700}
.alert-toast-close{border:0;background:transparent;color:#9eb2c1;font-size:22px;line-height:1;cursor:pointer;padding:0 4px}
@media(max-width:700px){.alert-toast-region{top:80px;left:10px;width:calc(100vw - 20px)}[data-live-alerts] .inline-actions{width:100%;justify-content:flex-start;flex-wrap:wrap}.alarm-thumb{width:68px;height:50px}.alarm-image-cell{width:78px}}


/* Camera card pairing controls and live detection duration */
.device-card-link{display:block;color:inherit;text-decoration:none}
.device-card-link:hover{color:#fff}
.device-disconnect-btn{display:block;width:100%;margin-top:14px;padding:9px 12px;font-size:10px}
.device-disconnected-note{
  margin-top:14px;padding:10px 11px;border:1px solid #4d5362;border-radius:9px;
  background:#202b3a;color:#aabbd0;font-size:10px;line-height:1.8
}
.btn.danger{
  border:1px solid #794754;background:#3c2933;color:#f2c0c8
}
.btn.danger:hover:not(:disabled){background:#55323e;border-color:#9b5c6a}
.device-meta .tracking-duration{font-variant-numeric:tabular-nums;direction:ltr;unicode-bidi:isolate}
#tracking-duration{font-variant-numeric:tabular-nums;direction:ltr;unicode-bidi:isolate}


/* Bounded historical media, cleanup actions and compact log panes. */
.cleanup-toolbar{display:flex;align-items:center;gap:9px;flex-wrap:wrap;padding:15px;border:1px solid #293f54;border-radius:14px;background:#111f30}
.cleanup-toolbar .btn{font-size:10px}
.cleanup-status{min-height:22px;margin-top:8px}
.video-history-panel{display:grid;gap:12px;padding:15px;border:1px solid #263d52;border-radius:15px;background:linear-gradient(145deg,#0c1928,#101f30)}
.video-history-panel>video{display:block;width:100%;height:clamp(220px,42vw,520px);max-height:520px;min-height:200px;object-fit:contain;background:#02070d;border:1px solid #2b4155;border-radius:12px}
.video-history-controls{display:flex;align-items:center;gap:9px;flex-wrap:wrap}
.video-history-controls .muted{margin-inline-start:auto}
.video-segment-list{display:grid;grid-template-columns:repeat(auto-fit,minmax(min(100%,230px),1fr));gap:8px;max-height:218px;overflow:auto;padding:2px 3px 2px 0}
.video-segment-option{display:grid;gap:4px;min-width:0;text-align:right;padding:10px 12px;border:1px solid #2b4358;border-radius:10px;background:#101f30;color:#d9e7ef;cursor:pointer;font:inherit}
.video-segment-option span{font-size:11px;font-variant-numeric:tabular-nums}
.video-segment-option small{font-size:9px;color:#8ba4b7}
.video-segment-option:hover,.video-segment-option.active{border-color:#63cdbc;background:#14333b}
.table-link-button{border:0;background:transparent;color:#85dfd1;font:600 10px Vazirmatn,sans-serif;cursor:pointer;padding:4px}
.table-link-button:hover{text-decoration:underline}
.log-table-wrap{max-height:340px;overflow:auto;overscroll-behavior:contain}
.log-table-wrap table thead th{position:sticky;top:0;z-index:2}
.log-table-wrap td:last-child{white-space:normal;min-width:220px;max-width:620px;line-height:1.8;overflow-wrap:anywhere}
@media(max-width:700px){
  .cleanup-toolbar{display:grid;grid-template-columns:1fr}
  .cleanup-toolbar .btn{width:100%}
  .video-history-panel{padding:10px}
  .video-history-controls{display:grid;grid-template-columns:1fr 1fr}
  .video-history-controls .muted{grid-column:1/-1;margin:0}
  .video-segment-list{grid-template-columns:1fr;max-height:190px}
  .log-table-wrap{max-height:280px}
}


.camera-icon{display:grid;place-items:center;line-height:0;font-size:0}
.camera-icon svg{display:block;width:21px;height:21px;margin:0}


.video-history-panel .video-segment-list{max-height:300px;overflow-y:auto;overscroll-behavior:contain}
.log-table-wrap{height:auto;max-height:340px;overflow:auto;overscroll-behavior:contain}
.log-table-wrap table{min-width:680px}
.log-table-wrap thead th{position:sticky;top:0;z-index:2}
.log-table-wrap td:last-child{white-space:normal;overflow-wrap:anywhere;max-width:620px}


/* Raspberry Pi system telemetry cards mirrored in the Django device console. */
.edge-health-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:10px;margin:14px 0 17px}
.edge-health-card{display:grid;gap:8px;min-width:0;padding:13px 14px;border:1px solid rgba(135,165,190,.15);border-radius:13px;background:linear-gradient(145deg,rgba(22,42,62,.9),rgba(10,23,36,.92))}
.edge-health-card>div:first-child{display:flex;align-items:center;gap:9px}
.edge-health-card>div:first-child small{color:#a2b7c5;font-size:10px}
.edge-health-card>strong{font-size:22px;color:#edf8fb;direction:ltr;text-align:left;font-variant-numeric:tabular-nums}
.health-icon{display:grid;place-items:center;min-width:34px;height:30px;padding:0 6px;border-radius:9px;background:#193c4a;color:#8ce1d1;font:800 10px Arial,sans-serif}
.edge-health-track{height:5px;border-radius:99px;background:#27394a;overflow:hidden}
.edge-health-track span{display:block;width:0;height:100%;border-radius:inherit;background:linear-gradient(90deg,#60d7bb,#e7bd70);transition:width .35s ease}
.edge-health-card.is-warning{border-color:rgba(242,195,111,.62);background:linear-gradient(145deg,#392f27,#1d2630)}
.edge-health-card.is-hot{border-color:rgba(241,138,152,.7);background:linear-gradient(145deg,#442932,#202331)}
.edge-health-card.is-warning .health-icon{background:#4c3b2b;color:#f2c36f}
.edge-health-card.is-hot .health-icon{background:#4a2b35;color:#f18a98}
.edge-health-card small{color:#839bad;font-size:9px;line-height:1.7;overflow-wrap:anywhere}
.device-health-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:7px;margin-top:12px}
.device-health-item{display:grid;gap:3px;min-width:0;padding:9px 10px;border:1px solid rgba(135,165,190,.13);border-radius:10px;background:#0b1928}
.device-health-item span{font-size:9px;color:#8fa7b8}
.device-health-item b{font-size:13px;color:#e3f0f5;direction:ltr;text-align:left;font-variant-numeric:tabular-nums}
.device-health-item.is-warning{border-color:#8b7047;background:#302c25}
.device-health-item.is-hot{border-color:#8a4e5a;background:#35252e}

/* One continuous MSE archive player with a seekable recording timeline. */
.continuous-video-panel{gap:13px}
.continuous-video-panel>video{width:100%;height:clamp(230px,46vw,560px);min-height:210px;max-height:560px;object-fit:contain;background:#02070d;border:1px solid #2b4155;border-radius:13px}
.archive-player-toolbar,.archive-player-footer{display:flex;align-items:center;justify-content:space-between;gap:12px;flex-wrap:wrap}
.archive-player-toolbar .muted,.archive-player-footer .muted{font-size:10px}
.archive-timeline{display:grid;gap:8px;padding:13px 14px;border:1px solid rgba(135,165,190,.15);border-radius:13px;background:rgba(5,16,27,.72)}
.archive-timeline-heading{display:flex;align-items:center;justify-content:space-between;gap:10px;flex-wrap:wrap}
.archive-timeline-heading b{font-size:11px;color:#dcebf1}
.archive-timeline-heading strong{font-size:12px;color:#8fe4d2;direction:ltr;font-variant-numeric:tabular-nums}
.archive-timeline-heading small{font-size:9px;color:#9bb1c0}
.archive-timeline-track{position:relative;height:28px;display:flex;align-items:center;direction:ltr}
.archive-timeline-segments{position:absolute;inset:9px 0;height:9px;display:flex;overflow:hidden;border:1px solid #30475b;border-radius:99px;background:#1b2a3a;pointer-events:none}
.archive-timeline-segments span{display:block;min-width:1px;height:100%;background:#3caa98;border-right:1px solid #0b1a29}
.archive-timeline-segments span:nth-child(3n){background:#568caa}
.archive-timeline-segments span.is-gap{background:#775d42}
#archive-timeline{position:relative;z-index:2;width:100%;height:28px;margin:0;background:transparent;cursor:pointer;accent-color:#78dfcd}
#archive-timeline:disabled{cursor:not-allowed;opacity:.4}
#archive-timeline::-webkit-slider-runnable-track{height:4px;background:transparent}
#archive-timeline::-moz-range-track{height:4px;background:transparent}
#archive-timeline::-webkit-slider-thumb{width:15px;height:15px;border:2px solid #071622;border-radius:50%;background:#8be9d6;box-shadow:0 0 0 3px #8be9d644;appearance:none;margin-top:-5px}
#archive-timeline::-moz-range-thumb{width:15px;height:15px;border:2px solid #071622;border-radius:50%;background:#8be9d6;box-shadow:0 0 0 3px #8be9d644}
.archive-timeline-labels{display:flex;align-items:center;justify-content:space-between;gap:8px;color:#859cad;font-size:9px;direction:ltr;font-variant-numeric:tabular-nums}
.archive-timeline-labels span:nth-child(2){direction:rtl}
.archive-player-footer{border-top:1px solid #ffffff12;padding-top:10px}
#archive-empty[hidden]{display:none}
@media(max-width:700px){
  .edge-health-grid{gap:8px}
  .edge-health-card{padding:11px}
  .edge-health-card>strong{font-size:19px}
  .device-health-grid{gap:6px}
  .device-health-item{padding:8px}
  .archive-player-toolbar,.archive-player-footer{align-items:stretch;flex-direction:column}
  .archive-player-toolbar .btn{width:100%}
  .archive-timeline{padding:11px}
  .archive-timeline-heading{display:grid;grid-template-columns:1fr auto}
  .archive-timeline-heading small{grid-column:1/-1}
}


.remote-device-controls{margin:0 0 18px;border-color:rgba(96,190,181,.28);background:linear-gradient(125deg,rgba(19,54,62,.75),#111f30 62%)}
.remote-command-row{display:flex;align-items:center;justify-content:space-between;gap:16px;padding:14px 0;border-top:1px solid #2a4254;border-bottom:1px solid #2a4254}
.remote-command-row>div{display:grid;gap:6px}
.remote-command-row b{font-size:13px;color:#e0eef5}
.remote-command-row small{font-size:11px;color:#8ca7b8}
.remote-command-status{margin:10px 0 0;min-height:24px}
@media(max-width:680px){.remote-command-row{align-items:stretch;flex-direction:column}.remote-command-row .btn{width:100%}}
