/* ColdStore Pro – application styles */
:root {
  --cs-sidebar-w: 256px;
  --cs-sidebar-bg: #0b2545;
  --cs-sidebar-bg2: #13315c;
  --cs-sidebar-fg: #c9d6ea;
  --cs-accent: #4cc9f0;
  --cs-body-bg: #f3f6fb;
  --cs-card-shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
}
[data-bs-theme="dark"] {
  --cs-body-bg: #0f1724;
  --cs-sidebar-bg: #08182e;
  --cs-sidebar-bg2: #0d223f;
  --cs-card-shadow: 0 1px 2px rgba(0, 0, 0, .4);
}

body { background: var(--cs-body-bg); font-size: .925rem; }
.app { display: flex; min-height: 100vh; }

/* Sidebar */
.sidebar {
  width: var(--cs-sidebar-w);
  background: linear-gradient(180deg, var(--cs-sidebar-bg), var(--cs-sidebar-bg2));
  color: var(--cs-sidebar-fg);
  flex-shrink: 0;
}
@media (min-width: 992px) {
  .sidebar { position: sticky; top: 0; height: 100vh; overflow-y: auto; }
}
@media (max-width: 991.98px) {
  .sidebar.offcanvas-lg { --bs-offcanvas-width: 270px; background: linear-gradient(180deg, var(--cs-sidebar-bg), var(--cs-sidebar-bg2)); }
}
.sidebar-brand { display: flex; align-items: center; gap: .75rem; padding: 1.1rem 1rem; border-bottom: 1px solid rgba(255,255,255,.08); width: 100%; }
.brand-icon { width: 38px; height: 38px; border-radius: 10px; background: rgba(76, 201, 240, .18); color: var(--cs-accent); display: grid; place-items: center; font-size: 1.3rem; flex-shrink: 0; }
.brand-text { min-width: 0; }
.brand-name { color: #fff; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 170px; }
.brand-text small { color: #8fa6c7; font-size: .72rem; }
.sidebar-nav { padding: .5rem .6rem 2rem; width: 100%; }
.sidebar .nav-header { font-size: .68rem; text-transform: uppercase; letter-spacing: .08em; color: #7d93b5; padding: 1rem .75rem .35rem; font-weight: 600; }
.sidebar .nav-link { display: flex; align-items: center; gap: .7rem; color: var(--cs-sidebar-fg); padding: .5rem .75rem; border-radius: 8px; font-size: .9rem; text-decoration: none; transition: background .15s, color .15s; }
.sidebar .nav-link i { font-size: 1.05rem; opacity: .85; width: 1.2rem; text-align: center; }
.sidebar .nav-link:hover { background: rgba(255,255,255,.07); color: #fff; }
.sidebar .nav-link.active { background: var(--cs-accent); color: #062033; font-weight: 600; }
.sidebar .nav-link.active i { opacity: 1; }

/* Main */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; gap: .75rem; padding: .7rem 1.5rem; background: var(--bs-body-bg); border-bottom: 1px solid var(--bs-border-color); position: sticky; top: 0; z-index: 1020; }
.page-title { font-size: 1.15rem; font-weight: 600; margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.content { padding: 1.5rem; flex: 1; }
.app-footer { padding: .75rem 1.5rem; font-size: .78rem; color: var(--bs-secondary-color); border-top: 1px solid var(--bs-border-color); }
.avatar { width: 26px; height: 26px; border-radius: 50%; background: var(--cs-sidebar-bg2); color: #fff; display: inline-grid; place-items: center; font-size: .78rem; font-weight: 600; }
@media (max-width: 575.98px) { .content { padding: 1rem; } .topbar { padding: .6rem 1rem; } }

/* Cards & tables */
.card { border: 1px solid var(--bs-border-color-translucent); box-shadow: var(--cs-card-shadow); border-radius: 12px; }
.card-header { background: transparent; border-bottom-color: var(--bs-border-color-translucent); }
.table > :not(caption) > * > * { padding: .6rem .75rem; }
.data-table thead th { font-size: .75rem; text-transform: uppercase; letter-spacing: .03em; color: var(--bs-secondary-color); background: var(--bs-tertiary-bg); white-space: nowrap; font-weight: 600; }
.detail-table th { width: 42%; font-weight: 500; color: var(--bs-secondary-color); padding-left: 1rem !important; }
.sticky-actions { position: sticky; bottom: 0; background: var(--cs-body-bg); padding: .75rem 0; z-index: 5; }

/* Stat tiles */
.stat { display: flex; gap: .9rem; align-items: center; padding: 1rem 1.1rem; }
.stat .icon { width: 46px; height: 46px; border-radius: 12px; display: grid; place-items: center; font-size: 1.35rem; flex-shrink: 0; }
.stat .label { font-size: .78rem; color: var(--bs-secondary-color); text-transform: uppercase; letter-spacing: .03em; }
.stat .value { font-size: 1.35rem; font-weight: 700; line-height: 1.2; }
.stat .sub { font-size: .75rem; color: var(--bs-secondary-color); }
.i-blue { background: #e0f2fe; color: #0369a1; }
.i-green { background: #dcfce7; color: #15803d; }
.i-amber { background: #fef3c7; color: #b45309; }
.i-red { background: #fee2e2; color: #b91c1c; }
.i-violet { background: #ede9fe; color: #6d28d9; }
.i-cyan { background: #cffafe; color: #0e7490; }
[data-bs-theme="dark"] .i-blue, [data-bs-theme="dark"] .i-green, [data-bs-theme="dark"] .i-amber,
[data-bs-theme="dark"] .i-red, [data-bs-theme="dark"] .i-violet, [data-bs-theme="dark"] .i-cyan { background: rgba(255,255,255,.08); }

.quick-actions .btn { display: flex; flex-direction: column; align-items: center; gap: .25rem; padding: .8rem .5rem; font-size: .82rem; }
.quick-actions .btn i { font-size: 1.4rem; }

.chamber-card .temp { font-size: 1.4rem; font-weight: 700; }
.lot-info { background: var(--bs-tertiary-bg); border-radius: 10px; padding: .9rem 1rem; }
.lot-info .k { font-size: .72rem; text-transform: uppercase; color: var(--bs-secondary-color); }
.lot-info .v { font-weight: 600; }

.empty-state { text-align: center; padding: 4rem 1rem; }
.empty-state > i { font-size: 3rem; color: var(--bs-secondary-color); display: block; margin-bottom: 1rem; }

/* Attendance */
.att-grid td, .att-grid th { padding: .3rem .25rem !important; text-align: center; font-size: .75rem; }
.att-grid td.name, .att-grid th.name { text-align: left; white-space: nowrap; }
.att-P { color: #15803d; font-weight: 700; }
.att-A { color: #b91c1c; font-weight: 700; }
.att-H { color: #b45309; font-weight: 700; }
.att-L { color: #0369a1; font-weight: 700; }
.btn-check + .btn.att-btn { min-width: 38px; }

/* Login */
.login-wrap { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.login-hero { background: linear-gradient(150deg, #0b2545 0%, #13315c 55%, #1b4d89 100%); color: #e6eef9; padding: 3rem; display: flex; flex-direction: column; justify-content: space-between; position: relative; overflow: hidden; }
.login-hero::after { content: "\2744"; position: absolute; right: -40px; bottom: -80px; font-size: 22rem; opacity: .06; line-height: 1; }
.login-hero h1 { font-weight: 700; font-size: 2.1rem; }
.login-hero ul { list-style: none; padding: 0; margin: 1.5rem 0 0; }
.login-hero li { padding: .35rem 0; }
.login-hero li i { color: var(--cs-accent); margin-right: .5rem; }
.login-form { display: flex; align-items: center; justify-content: center; padding: 2rem; background: var(--bs-body-bg); }
.login-form .inner { width: 100%; max-width: 380px; }
@media (max-width: 860px) { .login-wrap { grid-template-columns: 1fr; } .login-hero { display: none; } }

.ts-wrapper.form-select, .ts-wrapper.form-control { padding: 0; }
.ts-wrapper .ts-control { min-height: calc(1.5em + .75rem + 2px); }

@media print {
  .sidebar, .topbar, .no-print, .app-footer, .btn, form.filter-form, .pagination { display: none !important; }
  .content { padding: 0; }
  .card { box-shadow: none; border: 0; }
  body { background: #fff; font-size: 11px; }
  a { text-decoration: none; color: inherit; }
}

/* ---------- Demo mode ---------- */
.demo-strip { display: flex; align-items: center; gap: .5rem; padding: .4rem 1.5rem; font-size: .8rem; background: #fff7e0; color: #7a5300; border-bottom: 1px solid #f2dfa6; }
.demo-strip a { color: #7a5300; font-weight: 600; text-decoration: none; white-space: nowrap; }
[data-bs-theme="dark"] .demo-strip { background: #3a2f12; color: #f4d58d; border-color: #5a4a1d; }
[data-bs-theme="dark"] .demo-strip a { color: #f4d58d; }
.nav-badge { margin-left: auto; font-size: .62rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; padding: .12rem .4rem; border-radius: 6px; background: rgba(250, 204, 21, .2); color: #facc15; }
.sidebar .nav-link.active .nav-badge { background: rgba(6, 32, 51, .15); color: #062033; }
.demo-logins .demo-login-btn { width: 100%; display: flex; flex-direction: column; align-items: flex-start; gap: .1rem; padding: .6rem .75rem; border: 1px solid var(--bs-border-color); border-radius: 10px; background: var(--bs-tertiary-bg); text-align: left; transition: border-color .15s, transform .15s; }
.demo-login-btn:hover, .demo-login-btn:focus-visible { border-color: var(--bs-primary); transform: translateY(-1px); }
.demo-login-btn .role { font-weight: 600; font-size: .88rem; }
.demo-login-btn .role i { color: var(--bs-primary); margin-right: .3rem; }
.demo-login-btn .cred { font-family: ui-monospace, Consolas, monospace; font-size: .74rem; color: var(--bs-secondary-color); }

/* ---------- CCTV ---------- */
.cctv-tabs .nav-link { font-size: .88rem; }
.wall-wrap { background: #05080c; border-radius: 12px; padding: 4px; }
.wall-wrap:fullscreen { padding: 6px; display: flex; align-items: center; }
.wall-wrap:fullscreen .cctv-wall { width: 100%; }
.cctv-wall { display: grid; gap: 4px; }
.cctv-wall.g1 { grid-template-columns: 1fr; }
.cctv-wall.g4 { grid-template-columns: repeat(2, 1fr); }
.cctv-wall.g9 { grid-template-columns: repeat(3, 1fr); }
.cctv-wall.g16 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 767.98px) { .cctv-wall.g9, .cctv-wall.g16 { grid-template-columns: repeat(2, 1fr); } }
.cam-tile { position: relative; aspect-ratio: 16 / 9; background: #000; border-radius: 4px; overflow: hidden; cursor: pointer; }
.cam-tile canvas { width: 100%; height: 100%; display: block; }
.cam-tile .cam-actions { position: absolute; right: 6px; bottom: 26px; display: flex; gap: 4px; opacity: 0; transition: opacity .15s; }
.cam-tile:hover .cam-actions, .cam-tile:focus-within .cam-actions { opacity: 1; }
.cam-actions button { border: 0; background: rgba(0, 0, 0, .6); color: #fff; width: 30px; height: 30px; border-radius: 6px; }
.cam-actions button:hover { background: rgba(76, 201, 240, .85); color: #062033; }
.cam-tile.empty { cursor: default; display: grid; place-items: center; background: repeating-linear-gradient(45deg, #0b1016, #0b1016 10px, #0e141b 10px, #0e141b 20px); }
.empty-slot { display: flex; flex-direction: column; align-items: center; color: #5b6b7b; font-size: .8rem; }
.empty-slot i { font-size: 1.6rem; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; vertical-align: middle; }
.dot.online { background: #22c55e; box-shadow: 0 0 0 3px rgba(34, 197, 94, .18); }
.dot.offline { background: #ef4444; box-shadow: 0 0 0 3px rgba(239, 68, 68, .18); }
.cam-tree { max-height: 380px; overflow-y: auto; }
.cam-tree .tree-head, .cam-tree .tree-cam, .events .ev { display: flex; align-items: center; gap: .5rem; width: 100%; border: 0; background: transparent; text-align: left; color: inherit; min-width: 0; }
.cam-tree .tree-head { padding: .55rem 1rem; font-weight: 600; font-size: .85rem; background: var(--bs-tertiary-bg); border-top: 1px solid var(--bs-border-color-translucent); }
.cam-tree .tree-head.active { color: var(--bs-primary); }
.cam-tree .tree-cam { padding: .35rem 1rem .35rem 1.6rem; font-size: .82rem; }
.cam-tree .tree-cam:hover, .events .ev:hover { background: var(--bs-secondary-bg); }
.events { max-height: 340px; overflow-y: auto; }
.events .ev { align-items: flex-start; padding: .5rem 1rem; font-size: .82rem; border-bottom: 1px solid var(--bs-border-color-translucent); }
.events .ev > i { margin-top: .15rem; }
.store-card { border: 1px solid var(--bs-border-color); border-radius: 12px; padding: .9rem 1rem; background: var(--bs-body-bg); }
.store-card.is-alert { border-color: rgba(220, 38, 38, .6); box-shadow: 0 0 0 3px rgba(220, 38, 38, .12); }
.store-temp { font-size: 1.35rem; font-weight: 700; line-height: 1.1; }
.floor-row { display: grid; grid-template-columns: 26px 1fr 38px; align-items: center; gap: .4rem; font-size: .72rem; color: var(--bs-secondary-color); margin-bottom: 3px; }
.floor-track { height: 6px; background: var(--bs-secondary-bg); border-radius: 4px; overflow: hidden; }
.floor-track > div { height: 100%; background: #3b82f6; border-radius: 4px; }
.cam-modal { background: #0d1117; color: #e6edf3; }
.cam-modal .modal-header { border-bottom-color: #262d36; }
.focus-stage { position: relative; background: #000; cursor: grab; touch-action: none; }
.focus-stage:active { cursor: grabbing; }
.focus-stage canvas { width: 100%; display: block; aspect-ratio: 16 / 9; }
.zoom-ind { position: absolute; left: 10px; bottom: 10px; background: rgba(0, 0, 0, .6); color: #fff; font: 600 .75rem ui-monospace, Consolas, monospace; padding: .15rem .45rem; border-radius: 5px; }
.ptz { display: grid; grid-template-columns: repeat(3, 28px); gap: 2px; }
.ptz button { width: 28px; height: 24px; border: 1px solid #3a4450; background: #1a212a; color: #dbe4ee; border-radius: 4px; font-size: .7rem; padding: 0; }
.ptz button:hover { background: #2c3744; }
.timeline { position: relative; height: 22px; background: #2a2f36; border-radius: 5px; overflow: hidden; }
.timeline .tl-rec { position: absolute; top: 0; bottom: 0; background: #1f6feb; }
.timeline .tl-gap { position: absolute; top: 0; bottom: 0; background: #2a2f36; }
.timeline .tl-mot { position: absolute; top: 3px; bottom: 3px; width: 2px; background: #f59e0b; }
.timeline .tl-now { position: absolute; top: -2px; bottom: -2px; width: 2px; background: #fff; box-shadow: 0 0 6px #fff; }
.tl-key { display: inline-block; width: 10px; height: 10px; border-radius: 2px; vertical-align: middle; }
.tl-key.rec { background: #1f6feb; } .tl-key.mot { background: #f59e0b; } .tl-key.gap { background: #2a2f36; border: 1px solid #555; }
.features-hero { background: linear-gradient(120deg, rgba(76, 201, 240, .12), rgba(99, 102, 241, .08)); }
.i-gray { background: #e5e7eb; color: #374151; }
