/* Ulinzi AI — enterprise security dashboard theme (dark default, light optional) */
:root {
  --u-accent: #14b8a6;
  --u-accent-2: #06b6d4;
  --u-accent-strong: #0f766e;
  --u-danger: #ef4444;
  --u-warning: #f59e0b;
  --u-radius: 12px;
  --u-sidebar-w: 256px;
  --bs-primary: #0d9488;
  --bs-primary-rgb: 13, 148, 136;
  --bs-link-color: #0d9488;
  --bs-link-color-rgb: 13, 148, 136;
  --bs-link-hover-color: #0f766e;
  --bs-font-sans-serif: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
[data-bs-theme="light"] {
  --u-bg: #f3f6f8;
  --u-surface: #ffffff;
  --u-surface-2: #f8fafc;
  --u-border: #e2e8f0;
  --u-text-dim: #64748b;
  --u-sidebar: #0b1f24;
  --u-sidebar-text: #cbd5e1;
  --bs-body-bg: var(--u-bg);
}
[data-bs-theme="dark"] {
  --u-bg: #0b1215;
  --u-surface: #111b1f;
  --u-surface-2: #16232a;
  --u-border: #22333a;
  --u-text-dim: #94a3b8;
  --u-sidebar: #081013;
  --u-sidebar-text: #cbd5e1;
  --bs-body-bg: var(--u-bg);
  --bs-body-color: #e2e8f0;
  --bs-border-color: var(--u-border);
  --bs-primary: #14b8a6;
  --bs-primary-rgb: 20, 184, 166;
  --bs-link-color: #2dd4bf;
  --bs-link-color-rgb: 45, 212, 191;
  --bs-link-hover-color: #5eead4;
  --bs-secondary-bg: var(--u-surface-2);
  --bs-tertiary-bg: var(--u-surface-2);
}
html, body { height: 100%; }
body { background: var(--u-bg); font-size: .925rem; }
.btn-primary { --bs-btn-bg: var(--bs-primary); --bs-btn-border-color: var(--bs-primary); --bs-btn-hover-bg: var(--u-accent-strong); --bs-btn-hover-border-color: var(--u-accent-strong); --bs-btn-active-bg: var(--u-accent-strong); --bs-btn-disabled-bg: var(--bs-primary); --bs-btn-disabled-border-color: var(--bs-primary); }
.btn-outline-primary { --bs-btn-color: var(--bs-primary); --bs-btn-border-color: var(--bs-primary); --bs-btn-hover-bg: var(--bs-primary); --bs-btn-hover-border-color: var(--bs-primary); --bs-btn-active-bg: var(--u-accent-strong); }
.text-primary { color: var(--bs-primary) !important; }
.bg-primary { background-color: var(--bs-primary) !important; }
.form-check-input:checked { background-color: var(--bs-primary); border-color: var(--bs-primary); }
.form-control:focus, .form-select:focus { border-color: var(--u-accent); box-shadow: 0 0 0 .2rem rgba(20,184,166,.2); }
.page-link.active, .active > .page-link { background-color: var(--bs-primary); border-color: var(--bs-primary); }

/* shell */
.app-shell { display: flex; min-height: 100vh; }
.sidebar { width: var(--u-sidebar-w); background: var(--u-sidebar); color: var(--u-sidebar-text); flex-shrink: 0; display: flex; flex-direction: column; }
@media (min-width: 992px) { .sidebar { position: sticky; top: 0; height: 100vh; overflow-y: auto; } }
.sidebar.offcanvas-lg { --bs-offcanvas-bg: var(--u-sidebar); --bs-offcanvas-width: 280px; }
.sidebar-brand { display: flex; align-items: center; gap: .65rem; padding: 1.1rem 1rem; border-bottom: 1px solid rgba(255,255,255,.06); }
.brand-name { font-weight: 700; letter-spacing: .02em; color: #f1f5f9; }
.guest .brand-name { color: inherit; }
.brand-sub { font-size: .72rem; color: #5eead4; }
.sidebar-nav { padding: .5rem .5rem 1rem; flex: 1; }
.nav-section { font-size: .68rem; text-transform: uppercase; letter-spacing: .08em; color: #64748b; margin: 1rem .75rem .35rem; }
.nav-item { display: flex; align-items: center; gap: .7rem; padding: .5rem .75rem; border-radius: 8px; color: var(--u-sidebar-text); text-decoration: none; font-size: .88rem; }
.nav-item:hover { background: rgba(20,184,166,.10); color: #fff; }
.nav-item.active { background: linear-gradient(90deg, rgba(20,184,166,.25), rgba(6,182,212,.08)); color: #fff; box-shadow: inset 3px 0 0 var(--u-accent); }
.nav-item i { font-size: 1.05rem; width: 1.2rem; text-align: center; color: #5eead4; }
.sidebar-foot { padding: .75rem 1rem; color: #64748b; border-top: 1px solid rgba(255,255,255,.06); }
.sidebar-foot a { color: #94a3b8; }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 1020; display: flex; align-items: center; gap: .5rem; padding: .55rem 1rem; background: color-mix(in srgb, var(--u-surface) 92%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--u-border); }
.page-title { font-size: 1.1rem; font-weight: 600; margin: 0; }
.content { padding: 1.25rem; }
@media (max-width: 575px) { .content { padding: .75rem; } }
.btn-icon { border: 0; background: transparent; color: inherit; padding: .35rem .55rem; border-radius: 8px; }
.btn-icon:hover { background: var(--u-surface-2); }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: linear-gradient(135deg, var(--u-accent), var(--u-accent-2)); color: #032; display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: .85rem; }
.alert-count { position: absolute; top: 0; right: 0; font-size: .62rem; }

/* surfaces */
.card { background: var(--u-surface); border: 1px solid var(--u-border); border-radius: var(--u-radius); }
.card-header { background: transparent; border-bottom: 1px solid var(--u-border); font-weight: 600; }
.table { --bs-table-bg: transparent; }
.table > :not(caption) > * > * { border-color: var(--u-border); }
.table thead th { font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; color: var(--u-text-dim); font-weight: 600; }
.stat { padding: 1rem; border-radius: var(--u-radius); background: var(--u-surface); border: 1px solid var(--u-border); height: 100%; position: relative; overflow: hidden; }
.stat .v { font-size: 1.7rem; font-weight: 700; line-height: 1.1; }
.stat .l { font-size: .78rem; color: var(--u-text-dim); }
.stat i.icon { position: absolute; right: .8rem; top: .8rem; font-size: 1.4rem; color: var(--u-accent); opacity: .7; }
.stat.ok .v { color: #22c55e; } .stat.bad .v { color: var(--u-danger); } .stat.warn .v { color: var(--u-warning); }
.muted { color: var(--u-text-dim); }
.kv { display: grid; grid-template-columns: minmax(120px, 40%) 1fr; gap: .35rem .75rem; font-size: .88rem; }
.kv dt { color: var(--u-text-dim); font-weight: 500; }
.kv dd { margin: 0; word-break: break-word; }
.filters .form-control, .filters .form-select { min-width: 140px; }
.chip { display: inline-flex; align-items: center; gap: .3rem; padding: .15rem .55rem; border-radius: 999px; background: var(--u-surface-2); border: 1px solid var(--u-border); font-size: .75rem; }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; background: #64748b; }
.dot.online { background: #22c55e; box-shadow: 0 0 0 3px rgba(34,197,94,.18); }
.dot.offline, .dot.error { background: var(--u-danger); }
.dot.pending_test { background: #38bdf8; }
.dot.integration_required { background: var(--u-warning); }
.cap-available, .cap-available_via_agent, .cap-available_on_recorder { color: #22c55e; }
.cap-unavailable { color: var(--u-danger); }
.cap-manual_import_only, .cap-vendor_cloud, .cap-unknown { color: var(--u-warning); }

/* wizard */
.method-card { cursor: pointer; border: 2px solid var(--u-border); border-radius: var(--u-radius); padding: 1rem; height: 100%; background: var(--u-surface); transition: border-color .15s, transform .15s; }
.method-card:hover { border-color: var(--u-accent); transform: translateY(-1px); }
.method-card i { font-size: 1.8rem; color: var(--u-accent); }
.btn-check:checked + .method-card { border-color: var(--u-accent); background: color-mix(in srgb, var(--u-accent) 10%, var(--u-surface)); }
.step-badge { width: 26px; height: 26px; border-radius: 50%; background: var(--bs-primary); color: #fff; display: inline-flex; align-items: center; justify-content: center; font-size: .8rem; font-weight: 700; margin-right: .4rem; }

/* channel grid */
.channel-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: .75rem; }
.channel { border: 1px solid var(--u-border); border-radius: 10px; padding: .7rem; background: var(--u-surface); position: relative; }
.channel .no { font-weight: 700; font-size: 1.1rem; }
.channel.unassigned { border-style: dashed; }
.channel.connected { border-color: rgba(34,197,94,.5); }
.channel.offline, .channel.faulty { border-color: rgba(239,68,68,.5); }

/* live grid */
.live-grid { display: grid; gap: .6rem; }
.live-grid.g1 { grid-template-columns: 1fr; }
.live-grid.g4 { grid-template-columns: repeat(2, 1fr); }
.live-grid.g9 { grid-template-columns: repeat(3, 1fr); }
.live-grid.g16 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 767px) { .live-grid.g9, .live-grid.g16 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 480px) { .live-grid.g4, .live-grid.g9, .live-grid.g16 { grid-template-columns: 1fr; } }
.tile { position: relative; background: #000; border-radius: 10px; overflow: hidden; aspect-ratio: 16 / 9; border: 1px solid var(--u-border); }
.tile img, .tile iframe { width: 100%; height: 100%; object-fit: cover; border: 0; display: block; }
.tile .overlay-top, .tile .overlay-bottom { position: absolute; left: 0; right: 0; padding: .35rem .55rem; color: #fff; font-size: .78rem; display: flex; align-items: center; gap: .4rem; background: linear-gradient(rgba(0,0,0,.65), transparent); }
.tile .overlay-bottom { bottom: 0; background: linear-gradient(transparent, rgba(0,0,0,.7)); justify-content: space-between; }
.tile .overlay-top { top: 0; }
.tile .placeholder-msg { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; text-align: center; color: #94a3b8; padding: 1rem; font-size: .85rem; }
.tile .tools { display: flex; gap: .25rem; }
.tile .tools button { background: rgba(0,0,0,.45); color: #fff; border: 0; border-radius: 6px; padding: .15rem .4rem; }
.tile:fullscreen { aspect-ratio: auto; }

/* zones editor */
.zone-editor { position: relative; background: #000; border-radius: 10px; overflow: hidden; aspect-ratio: 16 / 9; user-select: none; }
.zone-editor img { width: 100%; height: 100%; object-fit: cover; opacity: .9; }
.zone-editor canvas { position: absolute; inset: 0; width: 100%; height: 100%; cursor: crosshair; }

/* chat */
.chat-wrap { display: grid; grid-template-columns: 260px 1fr; gap: 1rem; min-height: 70vh; }
@media (max-width: 991px) { .chat-wrap { grid-template-columns: 1fr; } .chat-list { max-height: 180px; overflow: auto; } }
.chat-log { display: flex; flex-direction: column; gap: .8rem; overflow-y: auto; max-height: 62vh; padding: .25rem; }
.msg { max-width: 92%; padding: .7rem .9rem; border-radius: 12px; white-space: pre-wrap; line-height: 1.45; }
.msg.user { align-self: flex-end; background: var(--bs-primary); color: #fff; border-bottom-right-radius: 4px; }
.msg.assistant { align-self: flex-start; background: var(--u-surface-2); border: 1px solid var(--u-border); border-bottom-left-radius: 4px; }
.evidence { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .5rem; margin-top: .6rem; white-space: normal; }
.evidence a { text-decoration: none; color: inherit; }
.ev-card { border: 1px solid var(--u-border); border-radius: 8px; overflow: hidden; background: var(--u-surface); font-size: .74rem; }
.ev-card img { width: 100%; aspect-ratio: 16/9; object-fit: cover; background: #000; display: block; }
.ev-card .noimg { aspect-ratio: 16/9; display: flex; align-items: center; justify-content: center; background: var(--u-surface-2); color: var(--u-text-dim); }
.ev-card .b { padding: .35rem .45rem; }
.suggest .btn { font-size: .78rem; }

/* misc */
.thumb { width: 84px; aspect-ratio: 16/9; object-fit: cover; border-radius: 6px; background: #000; }
.snapshot-lg { width: 100%; border-radius: 10px; background: #000; }
.steps li { list-style: none; padding: .3rem 0; }
.steps li i { margin-right: .35rem; }
.guest-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 1rem; background: radial-gradient(1000px 600px at 10% 10%, rgba(20,184,166,.18), transparent), radial-gradient(800px 500px at 90% 90%, rgba(6,182,212,.12), transparent), var(--u-bg); }
.guest-card { width: 100%; max-width: 420px; background: var(--u-surface); border: 1px solid var(--u-border); border-radius: 16px; padding: 2rem; box-shadow: 0 20px 60px rgba(0,0,0,.35); }
.code-box { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 1.5rem; letter-spacing: .12em; text-align: center; padding: .8rem; border: 1px dashed var(--u-accent); border-radius: 10px; background: var(--u-surface-2); user-select: all; }
pre.cmd { background: #0a0f12; color: #a7f3d0; padding: .75rem; border-radius: 8px; font-size: .8rem; white-space: pre-wrap; word-break: break-all; }
.chart-box { position: relative; height: 260px; }
.sim-banner { background: repeating-linear-gradient(45deg, rgba(245,158,11,.12), rgba(245,158,11,.12) 10px, transparent 10px, transparent 20px); border: 1px solid rgba(245,158,11,.4); }
@media print {
  .sidebar, .topbar, .no-print, .toast-container { display: none !important; }
  body, .content { background: #fff !important; color: #000 !important; padding: 0 !important; }
  .card { border: 1px solid #ccc !important; break-inside: avoid; }
}
