:root {
  color-scheme: dark;
  --page: #10151c;
  --surface: #171e27;
  --surface-raised: #1d2631;
  --border: #293442;
  --muted: #8d9bad;
  --text: #edf2f8;
  --accent: #7669f5;
  --accent-strong: #8a7fff;
  --green: #39c995;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--page); color: var(--text); font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; font-size: .94rem; }
a { color: inherit; text-decoration: none; }
.app-shell { min-height: 100vh; }
.sidebar { width: 252px; position: fixed; inset: 0 auto 0 0; z-index: 20; display: flex; flex-direction: column; padding: 27px 17px 16px; background: #141a22; border-right: 1px solid #252f3b; }
.brand, .login-brand { display: flex; gap: 11px; align-items: center; color: var(--text); }
.brand { padding: 0 9px 31px; }
.brand-mark { width: 39px; height: 39px; display: grid; place-items: center; color: white; font-size: .8rem; font-weight: 800; border-radius: 12px; background: linear-gradient(140deg, #8274ff, #5143c8); box-shadow: 0 6px 20px #6555e544; }
.brand strong, .login-brand strong { display: block; font-size: .92rem; letter-spacing: -.025em; }
.brand small, .login-brand small { display: block; color: #788698; font-size: .58rem; font-weight: 700; letter-spacing: .16em; margin-top: 2px; }
.sidebar-label { padding: 2px 11px 9px; color: #687687; font-size: .62rem; font-weight: 750; letter-spacing: .15em; }
.app-nav { gap: 4px; }
.app-nav .nav-link, .disabled-link { min-height: 42px; display: flex; align-items: center; gap: 12px; border-radius: 8px; padding: 0 11px; color: #a4b0bf; font-size: .84rem; transition: background .15s, color .15s; }
.app-nav .nav-link:hover { color: #fff; background: #222c38; }
.app-nav .nav-link.active { color: #fff; background: #282745; box-shadow: inset 2px 0 #8e82ff; }
.nav-icon { width: 18px; color: #8895a6; font-size: 1rem; text-align: center; }
.active .nav-icon { color: #a399ff; }
.disabled-link { color: #697586; font-size: .82rem; }
.nav-soon { margin-left: auto; font-size: .52rem; letter-spacing: .06em; color: #697586; border: 1px solid #364251; border-radius: 4px; padding: 2px 4px; }
.sidebar-bottom { margin-top: auto; }
.privacy-note { display: flex; align-items: flex-start; gap: 10px; padding: 12px 10px; margin-bottom: 14px; border: 1px solid #28352f; border-radius: 8px; background: #17231f; }
.privacy-note strong, .privacy-note small { display: block; }
.privacy-note strong { font-size: .73rem; font-weight: 650; }
.privacy-note small { color: #88998f; font-size: .65rem; margin-top: 3px; }
.privacy-dot, .status-dot { flex: 0 0 auto; display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--green); box-shadow: 0 0 9px #39c99544; }
.user-menu { display: flex; align-items: center; gap: 9px; padding: 14px 5px 1px; border-top: 1px solid #29323d; }
.avatar { width: 31px; height: 31px; display: grid; place-items: center; border-radius: 50%; background: #34304f; color: #c3bbff; font-weight: 700; }
.user-label { min-width: 0; flex: 1; }
.user-label strong, .user-label small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-label strong { font-size: .69rem; font-weight: 600; }
.user-label small { color: #788698; font-size: .63rem; margin-top: 2px; }
.icon-button { padding: 4px 7px; border: 0; background: none; color: #8592a3; }
.main-content { min-height: 100vh; margin-left: 252px; padding: 0 40px 20px; }
.topbar { min-height: 91px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid #252f3b; margin-bottom: 29px; }
.breadcrumb-label, .section-kicker, .welcome-kicker { color: #7c8a9c; font-size: .62rem; font-weight: 750; letter-spacing: .13em; }
.breadcrumb-label span, .breadcrumb-label a { color: #a397ff; }
.topbar h1 { margin: 5px 0 0; font-size: 1.28rem; font-weight: 660; letter-spacing: -.035em; }
.topbar-right { display: flex; align-items: center; gap: 17px; color: #9aa8b8; font-size: .74rem; }
.system-status { display: flex; align-items: center; gap: 8px; }
.topbar-divider { width: 1px; height: 19px; background: #303b48; }
.topbar-date { color: #8391a1; }
.flash-stack { margin: -7px 0 20px; }
.alert { font-size: .84rem; border-radius: 9px; }
.welcome-row, .page-intro-row { display: flex; justify-content: space-between; align-items: flex-end; gap: 20px; margin-bottom: 25px; }
.welcome-kicker { margin: 0 0 7px; color: #9a8fff; }
.welcome-row h2 { margin: 0; font-size: 1.45rem; font-weight: 640; letter-spacing: -.04em; }
.welcome-copy { color: #91a0b0; margin: 6px 0 0; font-size: .84rem; }
.btn { border-radius: 7px; font-size: .82rem; font-weight: 600; }
.btn-primary { background: #7164ed; border-color: #7164ed; box-shadow: 0 4px 13px #6255df30; }
.btn-primary:hover, .btn-primary:focus { background: #8074ff; border-color: #8074ff; }
.btn-primary span { padding-left: 5px; }
.btn-outline-light { color: #ced7e1; border-color: #3a4653; }
.btn-outline-light:hover { color: white; background: #293440; border-color: #536171; }
.stats-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; margin-bottom: 22px; }
.stat-card, .panel { border: 1px solid var(--border); background: var(--surface); border-radius: 11px; }
.stat-card { min-height: 145px; padding: 18px 19px 16px; }
.stat-top { display: flex; align-items: center; gap: 10px; }
.stat-icon { width: 29px; height: 29px; display: grid; place-items: center; border-radius: 8px; font-size: .9rem; }
.icon-violet { color: #b7adff; background: #332f55; }
.icon-green { color: #7adab5; background: #203d35; }
.icon-blue { color: #81b9ff; background: #223b54; }
.stat-label { color: #9ba8b7; font-size: .61rem; font-weight: 700; letter-spacing: .1em; }
.stat-value { margin-top: 12px; font-size: 1.8rem; line-height: 1; font-weight: 690; letter-spacing: -.05em; }
.stat-value-label { font-size: 1.15rem; letter-spacing: -.02em; }
.stat-foot { margin-top: 8px; color: #8290a1; font-size: .7rem; }
.panel { overflow: hidden; }
.branch-panel { margin-bottom: 20px; }
.panel-header { display: flex; align-items: center; justify-content: space-between; padding: 20px 22px 15px; }
.section-kicker { margin: 0 0 5px; font-size: .59rem; }
.panel-header h2 { display: flex; align-items: center; gap: 9px; margin: 0; font-size: 1rem; font-weight: 620; }
.text-link { color: #aaa1ff; font-size: .76rem; font-weight: 600; }
.text-link span { padding-left: 4px; }
.branch-row { display: flex; align-items: center; gap: 12px; min-height: 66px; padding: 10px 22px; border-top: 1px solid #27313d; }
.branch-row:hover { background: #1c2530; }
.branch-avatar { width: 34px; height: 34px; display: grid; flex: 0 0 auto; place-items: center; border-radius: 9px; color: #b9b1ff; background: #302d4d; font-size: .65rem; font-weight: 750; }
.branch-main { flex: 1; min-width: 0; }
.branch-main strong, .branch-main small, .table-branch strong, .table-branch small { display: block; }
.branch-main strong, .table-branch strong { font-size: .8rem; font-weight: 620; }
.branch-main small, .table-branch small { margin-top: 3px; color: #8492a2; font-size: .68rem; }
.branch-state { display: flex; align-items: center; gap: 7px; color: #a8b4c1; font-size: .7rem; }
.branch-chevron { color: #7b8998; font-size: 1.35rem; padding-left: 11px; }
.status-green { background: #39c995; }
.status-gray { background: #778393; box-shadow: none; }
.empty-state { padding: 36px 22px 41px; text-align: center; }
.empty-icon { width: 42px; height: 42px; display: grid; place-items: center; margin: 0 auto 13px; border: 1px solid #37344f; border-radius: 12px; color: #aaa0ff; background: #272540; font-size: 1.15rem; }
.empty-state h3 { margin: 0; font-size: .95rem; font-weight: 630; }
.empty-state p { max-width: 410px; margin: 8px auto 16px; color: #93a0af; font-size: .78rem; line-height: 1.6; }
.phase-note { display: flex; align-items: flex-start; gap: 12px; padding: 14px 16px; border: 1px solid #30364e; border-radius: 9px; background: #1a1d2b; }
.phase-note-icon { width: 20px; height: 20px; display: grid; flex: 0 0 auto; place-items: center; border-radius: 50%; color: #b5adff; background: #393559; font-size: .72rem; font-weight: 700; }
.phase-note strong { font-size: .75rem; }
.phase-note p { margin: 4px 0 0; color: #939fb1; font-size: .72rem; line-height: 1.55; }
.app-footer { display: flex; justify-content: space-between; padding: 28px 1px 5px; color: #667486; font-size: .58rem; letter-spacing: .11em; }
.app-footer span:last-child { letter-spacing: 0; }
.count-pill { padding: 3px 7px; color: #b7adff; border-radius: 20px; background: #302d4d; font-size: .62rem; }
.page-intro-row { align-items: center; margin: -7px 0 21px; }
.page-intro-row .welcome-copy { margin: 0; }
.branch-table { --bs-table-bg: transparent; --bs-table-color: #dce3eb; --bs-table-border-color: #28323e; }
.branch-table thead th { padding: 12px 17px; color: #778698; font-size: .58rem; font-weight: 700; letter-spacing: .1em; border-bottom-width: 1px; }
.branch-table tbody td { padding: 13px 17px; font-size: .77rem; }
.branch-table tbody tr:last-child td { border-bottom: 0; }
.table-branch { display: flex; align-items: center; gap: 10px; }
.table-branch .branch-avatar { width: 31px; height: 31px; }
.table-secondary { display: block; margin-top: 3px; color: #8391a1; font-size: .67rem; }
.status-pill { display: inline-flex; align-items: center; gap: 7px; padding: 5px 8px; border-radius: 20px; font-size: .68rem; }
.status-pill-green { color: #83dcb9; background: #203a32; }
.status-pill-gray { color: #a8b2bf; background: #2a333e; }
.status-pill-red { color: #ffaaa8; background: #492d34; }
.evidence-video { display: block; width: min(100%, 960px); margin-top: 12px; background: #070a0e; }
.action-cell { white-space: nowrap; }
.action-cell .btn { margin-left: 4px; font-size: .68rem; }
.form-layout { display: grid; grid-template-columns: minmax(0, 1fr) 260px; gap: 19px; align-items: start; }
.form-panel { padding-bottom: 21px; }
.form-panel .panel-header { padding-bottom: 21px; }
.form-panel .panel-header h2 { font-size: .98rem; }
.form-panel form { padding: 0 22px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 17px 15px; }
.form-span { grid-column: span 2; }
.form-label { color: #c7d0da; font-size: .75rem; font-weight: 600; }
.form-control { min-height: 41px; padding: 9px 11px; color: #e7edf4; background: #111821; border-color: #35414e; border-radius: 7px; font-size: .78rem; }
.form-control::placeholder { color: #687789; }
.form-control:focus { color: #fff; background: #111821; border-color: #8276ff; box-shadow: 0 0 0 .2rem #7669f522; }
.form-control.multi-select { min-height: 110px; height: auto; padding: 5px; }
.form-control.multi-select option { padding: 5px 7px; border-radius: 4px; }
.role-chip { display: inline-block; margin: 2px 3px 2px 0; padding: 4px 7px; border: 1px solid #393650; border-radius: 15px; background: #2a2840; color: #c1baff; font-size: .64rem; }
.token-field { color: #a9e8ca; overflow-wrap: anywhere; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.live-intro { align-items: center; }
.live-intro > div { display: grid; gap: 7px; }
.live-privacy { display: inline-flex; align-items: center; gap: 7px; color: #84d9b7; font-size: .68rem; }
.layout-picker { display: flex; align-items: center; gap: 9px; color: #9eabba; font-size: .73rem; }
.layout-picker select { width: auto; min-width: 135px; min-height: 36px; }
.camera-grid { display: grid; gap: 13px; }
.camera-grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.camera-grid-9 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.camera-grid-16 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.live-camera { min-width: 0; overflow: hidden; border: 1px solid #2c3744; border-radius: 9px; background: #171e27; }
.live-camera-header, .live-camera-footer { display: flex; align-items: center; gap: 8px; padding: 9px 11px; }
.live-camera-header { justify-content: space-between; min-height: 48px; }
.live-camera-header strong, .live-camera-header small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.live-camera-header strong { font-size: .73rem; font-weight: 620; }
.live-camera-header small { margin-top: 2px; color: #8391a1; font-size: .59rem; }
.privacy-chip { display: flex; align-items: center; gap: 5px; flex: 0 0 auto; color: #83dcb9; font-size: .49rem; font-weight: 750; letter-spacing: .08em; }
.privacy-chip .privacy-dot { width: 5px; height: 5px; }
.live-video-wrap { position: relative; display: grid; place-items: center; aspect-ratio: 16 / 9; overflow: hidden; background: #0a0e13; }
.live-video { width: 100%; height: 100%; object-fit: contain; background: #0a0e13; }
.live-state { position: absolute; inset: auto auto 10px 10px; padding: 5px 8px; border: 1px solid #394451; border-radius: 5px; background: #0d131be8; color: #cbd4df; font-size: .61rem; }
.live-camera-footer { min-height: 48px; border-top: 1px solid #28323e; }
.live-state-detail { flex: 1; min-width: 0; overflow: hidden; color: #8694a4; font-size: .59rem; text-overflow: ellipsis; white-space: nowrap; }
.live-camera-footer .btn { flex: 0 0 auto; font-size: .62rem; }
.live-caption { display: block; max-width: 930px; margin-top: 12px; line-height: 1.6; }
.camera-grid-9 .live-camera-header, .camera-grid-16 .live-camera-header { padding: 7px 8px; }
.camera-grid-9 .live-camera-footer, .camera-grid-16 .live-camera-footer { padding: 7px 8px; }
.camera-grid-16 .live-state-detail { display: none; }
.camera-grid-16 .live-state { left: 6px; bottom: 6px; font-size: .54rem; }
.form-hint { color: #778698; font-size: .66rem; margin-top: 5px; }
.field-error { color: #ff9a9a; font-size: .69rem; margin-top: 5px; }
.remember-row { display: flex; align-items: center; gap: 8px; color: #aab5c2; font-size: .74rem; }
.remember-row input { accent-color: #786cff; }
.branch-active { margin-top: 18px; }
.form-actions { display: flex; justify-content: flex-end; gap: 9px; padding-top: 21px; margin-top: 20px; border-top: 1px solid #2a3440; }
.form-aside { padding: 20px; border: 1px solid #2a3440; border-radius: 10px; background: #161d26; }
.aside-icon { width: 34px; height: 34px; display: grid; place-items: center; margin-bottom: 20px; border-radius: 9px; color: #b9b1ff; background: #302d4d; }
.form-aside h3 { margin: 0 0 8px; font-size: .94rem; font-weight: 620; }
.form-aside p:last-child { margin: 0; color: #8f9dad; font-size: .73rem; line-height: 1.65; }
.public-shell { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 36px 20px 20px; background: radial-gradient(ellipse at 50% 44%, #1c2034 0%, #11161e 48%, #10151c 76%); }
.public-shell > .login-brand { position: absolute; top: 35px; left: max(36px, calc((100vw - 1060px) / 2)); }
.public-shell > .login-brand:hover { color: white; }
.login-card, .landing-card { width: min(100%, 410px); padding: 31px; border: 1px solid #303a47; border-radius: 13px; background: #171e27; box-shadow: 0 24px 80px #05080e70; }
.login-card h1, .landing-card h1 { margin: 8px 0 6px; font-size: 1.7rem; letter-spacing: -.05em; font-weight: 670; }
.eyebrow { color: #a99fff; font-size: .62rem; font-weight: 750; letter-spacing: .14em; }
.login-subtitle, .landing-card > p { margin: 0 0 22px; color: #95a2b1; font-size: .82rem; }
.login-card .form-label { display: block; }
.login-card .form-control { min-height: 45px; }
.login-security { display: flex; justify-content: center; align-items: center; gap: 8px; margin-top: 21px; color: #83918f; font-size: .65rem; text-align: center; }
.public-footer { margin-top: 30px; color: #667486; font-size: .57rem; font-weight: 650; letter-spacing: .12em; }
.public-footer span { margin: 0 7px; color: #9388ff; }
.landing-card { width: min(100%, 530px); padding: 44px; }
.landing-card h1 { margin-top: 16px; font-size: 2.45rem; line-height: 1.1; }
.landing-card > p { max-width: 390px; margin: 13px 0 24px; line-height: 1.65; }
.landing-card .btn { font-size: .83rem; }
.landing-foot { display: flex; justify-content: space-between; margin-top: 34px; padding-top: 17px; border-top: 1px solid #2a3440; color: #7d8a9a; font-size: .55rem; font-weight: 700; letter-spacing: .09em; }
.locale-form { width: 88px; }
.locale-form .form-select { min-height: 31px; padding-top: 4px; padding-bottom: 4px; background: #171e27; border-color: #34414e; color: #b6c1cd; font-size: .68rem; }
.filter-form { display: flex; align-items: end; gap: 12px; flex-wrap: wrap; padding: 0 22px 22px; }
.filter-form label { color: #aab5c2; font-size: .72rem; }
.filter-form .form-control, .filter-form .form-select { min-width: 150px; margin-top: 6px; }
html[dir="rtl"] .sidebar { right: 0; left: auto; border-right: 0; border-left: 1px solid #252f3b; }
html[dir="rtl"] .main-content { margin-right: 252px; margin-left: 0; }
html[dir="rtl"] .app-nav .nav-link.active { box-shadow: inset -2px 0 #8e82ff; }
@media (max-width: 1050px) {
  html[dir="rtl"] .main-content { margin-right: 218px; }
}
@media (max-width: 760px) {
  html[dir="rtl"] .sidebar { border-left: 0; }
  html[dir="rtl"] .main-content { margin-right: 0; }
}

@media (max-width: 1050px) {
  .sidebar { width: 218px; }
  .main-content { margin-left: 218px; padding: 0 25px 20px; }
  .stats-grid { gap: 10px; }
  .stat-card { padding: 15px; }
  .stat-label { font-size: .54rem; }
}
@media (max-width: 760px) {
  .sidebar { position: static; width: auto; height: auto; display: block; padding: 13px 16px; border-right: 0; border-bottom: 1px solid #29323d; }
  .brand { padding: 0; }
  .sidebar-label, .sidebar > .nav-link, .sidebar > .nav, .sidebar-bottom { display: none; }
  .main-content { margin: 0; padding: 0 17px 15px; }
  .topbar { min-height: 77px; margin-bottom: 22px; }
  .topbar-right { gap: 9px; }
  .system-status { font-size: 0; gap: 0; }
  .topbar-date { font-size: .65rem; }
  .stats-grid { grid-template-columns: 1fr; gap: 9px; }
  .stat-card { min-height: 125px; }
  .form-layout { grid-template-columns: 1fr; }
  .form-aside { display: none; }
  .branch-table { min-width: 850px; }
  .welcome-row { align-items: flex-start; }
  .welcome-row h2 { font-size: 1.3rem; }
  .welcome-row > .btn { white-space: nowrap; }
  .camera-grid-9, .camera-grid-16 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 480px) {
  .topbar-date, .topbar-divider { display: none; }
  .welcome-row { flex-direction: column; gap: 13px; }
  .page-intro-row { align-items: flex-start; }
  .page-intro-row .welcome-copy { max-width: 230px; line-height: 1.5; }
  .panel-header { padding: 17px 15px 13px; }
  .branch-row { padding: 10px 14px; }
  .branch-state { font-size: .64rem; }
  .form-grid { grid-template-columns: 1fr; }
  .form-span { grid-column: auto; }
  .form-panel form { padding: 0 15px; }
  .public-shell > .login-brand { top: 19px; left: 20px; }
  .login-card, .landing-card { padding: 25px 20px; }
  .landing-card h1 { font-size: 2rem; }
  .public-footer { text-align: center; font-size: .5rem; }
  .camera-grid-4, .camera-grid-9, .camera-grid-16 { grid-template-columns: 1fr; }
  .live-intro { align-items: flex-start; }
  .layout-picker { width: 100%; justify-content: space-between; }
}
