:root {
  --bg: #f4f7f9;
  --panel: #ffffff;
  --line: #dbe3ea;
  --text: #1f2937;
  --muted: #6b7280;
  --brand: #0f766e;
  --brand2: #1d4ed8;
  --ok: #166534;
  --err: #b91c1c;
  --warn: #92400e;
  --bg-glow-left: #dcf4ec;
  --bg-glow-right: #e7edff;
  --topbar-bg: rgba(255, 255, 255, 0.9);
  --soft-bg: #edf2f7;
  --soft-text: #0f172a;
}

:root[data-theme='dark'] {
  --bg: #0b1220;
  --panel: #0f172a;
  --line: #2b3b4f;
  --text: #e2e8f0;
  --muted: #94a3b8;
  --brand: #0f766e;
  --brand2: #3b82f6;
  --ok: #4ade80;
  --err: #f87171;
  --warn: #fbbf24;
  --bg-glow-left: rgba(13, 148, 136, 0.18);
  --bg-glow-right: rgba(37, 99, 235, 0.2);
  --topbar-bg: rgba(2, 6, 23, 0.84);
  --soft-bg: #1e293b;
  --soft-text: #e2e8f0;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  color: var(--text);
  font-family: "Segoe UI", Arial, sans-serif;
  background:
    radial-gradient(1000px 500px at -10% -10%, var(--bg-glow-left) 0, transparent 62%),
    radial-gradient(1000px 500px at 110% -10%, var(--bg-glow-right) 0, transparent 62%),
    var(--bg);
}

.hidden { display: none !important; }

/* Icaze bilgileri yuklenene qeder sehife menusu/content bir anliq gorunmesin. */
body.nav-pending .layout {
  visibility: hidden;
}

a.btn {
  display: block;
  text-decoration: none;
  color: inherit;
}

.btn {
  border: 0;
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.btn-primary {
  color: #fff;
  background: linear-gradient(135deg, var(--brand), var(--brand2));
}

.btn-soft {
  color: var(--soft-text);
  background: var(--soft-bg);
  border: 1px solid var(--line);
}

.btn-danger {
  color: var(--err);
  background: color-mix(in srgb, var(--err) 8%, var(--panel));
  border: 1px solid color-mix(in srgb, var(--err) 25%, var(--line));
}

.btn-mini {
  padding: 6px 9px;
  font-size: 12px;
}

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.07);
}

.notice {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
  font-size: 13px;
  background: var(--soft-bg);
  color: var(--text);
  white-space: pre-line;
}

.notice.ok {
  border-color: color-mix(in srgb, var(--ok) 30%, var(--line));
  background: color-mix(in srgb, var(--ok) 8%, var(--panel));
  color: var(--ok);
}

.notice.err {
  border-color: color-mix(in srgb, var(--err) 30%, var(--line));
  background: color-mix(in srgb, var(--err) 8%, var(--panel));
  color: var(--err);
}

.notice.warn {
  border-color: color-mix(in srgb, var(--warn) 30%, var(--line));
  background: color-mix(in srgb, var(--warn) 8%, var(--panel));
  color: var(--warn);
}

label {
  display: block;
  margin-bottom: 5px;
  font-size: 12px;
  color: var(--muted);
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
  font-size: 13px;
  font-family: inherit;
}

.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 22px;
}

.login-card {
  width: 100%;
  max-width: 430px;
  padding: 22px;
}

.login-card h1 {
  margin: 0 0 6px;
  font-size: 25px;
}

.muted {
  margin: 0 0 16px;
  color: var(--muted);
  font-size: 13px;
}

.app {
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr;
}
  background: var(--panel);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  backdrop-filter: blur(8px);
  background: var(--topbar-bg);
  border-bottom: 1px solid var(--line);
  padding: 10px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.top-left {
  font-weight: 800;
  font-size: 15px;
}

.brand-lockup {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
  line-height: 0;
}

.brand-logo {
  display: block;
  height: 40px;
  width: auto;
  border-radius: 10px;
  box-shadow: 0 6px 16px rgba(15, 76, 160, 0.28);
}

.brand-logo-lg {
  height: 72px;
  margin: 0 auto 4px;
  box-shadow: 0 10px 24px rgba(15, 76, 160, 0.32);
}

.login-brand {
  display: flex;
  justify-content: center;
  margin: 4px 0 10px;
}

.top-right {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  border-radius: 999px;
  border: 1px solid color-mix(in srgb, var(--ok) 30%, var(--line));
  background: color-mix(in srgb, var(--ok) 8%, var(--panel));
  color: var(--ok);
  padding: 6px 9px;
  font-size: 12px;
  font-weight: 600;
}

.layout {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 12px;
  padding: 12px;
  min-width: 0;
  transition: grid-template-columns .25s ease;
}

.sidebar {
  padding: 10px;
  height: calc(100vh - 88px);
  position: sticky;
  top: 74px;
}

.tab-btn {
  width: 100%;
  text-align: left;
  margin-bottom: 6px;
}

.tab-btn.active {
  background: var(--brand-soft, color-mix(in srgb, var(--brand) 10%, var(--panel)));
  border-color: color-mix(in srgb, var(--brand) 25%, var(--line));
}


.content {
  min-width: 0;
  padding: 14px;
}

.section {
  display: none;
}

.section.active {
  display: block;
}

.section h2 {
  margin: 0 0 6px;
  font-size: 21px;
}

.sub {
  margin: 0 0 12px;
  font-size: 13px;
  color: var(--muted);
}

.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin: 12px 0;
}

.stat {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
  background: var(--soft-bg);
}

.stat .k {
  font-size: 12px;
  color: var(--muted);
}

.stat .v {
  font-size: 21px;
  font-weight: 700;
  margin-top: 3px;
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 12px;
}

.block {
  border: 1px solid var(--line);
  border-radius: 11px;
  padding: 10px;
  background: var(--panel);
}

.block h3 {
  margin: 0 0 10px;
  font-size: 14px;
}

.collapsible-block {
  padding: 0;
  overflow: hidden;
}

.collapsible-toggle {
  width: 100%;
  border: 0;
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px;
  cursor: pointer;
  text-align: left;
  transition: background-color 0.18s ease, border-color 0.18s ease;
}

.collapsible-toggle:hover {
  background: var(--soft-bg);
}

.collapsible-toggle:focus-visible {
  outline: 2px solid #93c5fd;
  outline-offset: -2px;
}

.collapsible-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
}

.collapsible-icon {
  width: 9px;
  height: 9px;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  transform: rotate(45deg);
  transition: transform 0.2s ease;
  flex-shrink: 0;
}

.collapsible-block.is-open .collapsible-toggle {
  border-bottom: 1px solid var(--line);
}

.collapsible-block.is-open .collapsible-icon {
  transform: rotate(225deg);
}

.collapsible-content {
  display: none;
  padding: 8px 10px 10px;
}

.collapsible-block.is-open .collapsible-content {
  display: block;
}

.form-section-title {
  margin: 0 0 8px;
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
}

.collapsible-content > .inline-note:first-child {
  margin-top: 0;
}

.row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 8px;
}

.row-4 {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 8px;
}

.device-user-perm-grid {
  --device-user-panel-height: 270px;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1.2fr) minmax(0, 0.85fr);
  align-items: stretch;
}

.device-user-perm-grid.camera-hidden {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
}

.device-user-perm-grid.camera-hidden #deviceUserCameraPreviewBlock,
.device-user-perm-grid.camera-hidden #deviceUserCameraPermissionBlock {
  display: none;
}

.device-user-perm-grid > div {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.device-user-perm-grid > div > label {
  min-height: 22px;
  height: auto;
  display: flex;
  align-items: flex-start;
  flex-wrap: wrap;
  white-space: normal;
  gap: 3px;
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 6px;
  line-height: 1.4;
}

.lbl-hint {
  font-size: 10px;
  font-weight: 400;
  color: #94a3b8;
  line-height: 1.4;
}

.perm-grid {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--soft-bg);
  max-height: 250px;
  overflow: auto;
  padding: 8px;
}

.perm-item {
  display: flex;
  align-items: flex-start;
  gap: 7px;
  margin-bottom: 6px;
  color: var(--text);
  font-size: 12px;
  line-height: 1.35;
}

.perm-item input {
  width: auto;
  margin: 1px 0 0;
  padding: 0;
}

.folder-camera-item {
  align-items: center;
  margin-bottom: 6px;
  padding: 4px 6px;
  border-radius: 6px;
}

.folder-camera-item.is-assigned {
  background: rgba(16, 185, 129, 0.08);
}

.folder-camera-label {
  flex: 1;
  min-width: 0;
}

.folder-assigned-tick {
  flex: 0 0 auto;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #10b981;
  position: relative;
}

.folder-assigned-tick::after {
  content: '';
  position: absolute;
  left: 5px;
  top: 2px;
  width: 4px;
  height: 8px;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

.folder-assigned-nvr-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
  align-items: center;
}

.folder-assigned-nvr-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid #86efac;
  background: #ecfdf5;
  color: #065f46;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 12px;
  line-height: 1.2;
  cursor: pointer;
}

.folder-assigned-nvr-btn:hover {
  background: #d1fae5;
}

.folder-assigned-nvr-btn.is-active {
  border-color: #10b981;
  background: #10b981;
  color: #fff;
}

.folder-assigned-nvr-btn .tick {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: currentColor;
  position: relative;
  opacity: 0.9;
}

.folder-assigned-nvr-btn .tick::after {
  content: '';
  position: absolute;
  left: 4px;
  top: 2px;
  width: 3px;
  height: 7px;
  border: solid #ecfdf5;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

.folder-assigned-nvr-btn.is-active .tick::after {
  border-color: #10b981;
}

:root[data-theme='dark'] .folder-camera-item.is-assigned {
  background: rgba(16, 185, 129, 0.16);
}

:root[data-theme='dark'] .folder-assigned-nvr-btn {
  background: rgba(16, 185, 129, 0.16);
  border-color: rgba(16, 185, 129, 0.45);
  color: #a7f3d0;
}

:root[data-theme='dark'] .folder-assigned-nvr-btn.is-active {
  background: #059669;
  border-color: #34d399;
  color: #ecfdf5;
}

.perm-inline {
  margin-bottom: 8px;
}

#deviceUserCameraSelect {
  min-height: 200px;
  flex: 1;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

th,
td {
  text-align: left;
  padding: 8px 6px;
  border-bottom: 1px solid #edf1f5;
  vertical-align: top;
}

th {
  font-size: 12px;
  color: #475467;
}

.nvr-row-refreshing td {
  background: rgba(185, 28, 28, 0.12) !important;
}

.nvr-refreshing-tag {
  display: inline-block;
  margin-left: 8px;
  padding: 2px 8px;
  border-radius: 999px;
  background: #b91c1c;
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  vertical-align: middle;
}

.nvr-live-sync {
  margin: 10px 0 14px;
  padding: 14px 16px;
  border: 1px solid #fecaca;
  background: linear-gradient(180deg, #fef2f2 0%, #fff 100%);
  border-radius: 10px;
}

.nvr-live-sync-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.nvr-live-sync-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  background: #b91c1c;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
}

.nvr-live-sync-steps {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-bottom: 8px;
}

.nvr-live-step {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid #e5e7eb;
  background: #f9fafb;
  color: #6b7280;
  font-size: 12px;
  font-weight: 600;
}

.nvr-live-step.done {
  border-color: #86efac;
  background: #ecfdf5;
  color: #047857;
}

.nvr-live-step.active {
  border-color: #fca5a5;
  background: #fee2e2;
  color: #b91c1c;
  box-shadow: 0 0 0 2px rgba(185, 28, 28, 0.12);
}

.nvr-live-step-sep {
  color: #9ca3af;
  font-size: 12px;
}

.nvr-live-sync-detail {
  font-size: 13px;
  color: #7f1d1d;
  font-weight: 600;
}

:root[data-theme='dark'] .nvr-live-sync {
  border-color: rgba(248, 113, 113, 0.35);
  background: linear-gradient(180deg, rgba(127, 29, 29, 0.25) 0%, rgba(17, 24, 39, 0.9) 100%);
}

:root[data-theme='dark'] .nvr-live-step {
  border-color: #374151;
  background: #111827;
  color: #9ca3af;
}

:root[data-theme='dark'] .nvr-live-step.done {
  border-color: rgba(52, 211, 153, 0.4);
  background: rgba(6, 95, 70, 0.35);
  color: #6ee7b7;
}

:root[data-theme='dark'] .nvr-live-step.active {
  border-color: rgba(248, 113, 113, 0.5);
  background: rgba(127, 29, 29, 0.45);
  color: #fecaca;
}

:root[data-theme='dark'] .nvr-live-sync-detail {
  color: #fecaca;
}

.nvr-sync-phase {
  margin-top: 4px;
  font-size: 11px;
  color: #6b7280;
  max-width: 260px;
  line-height: 1.35;
  word-break: break-word;
}

.nvr-sync-phase.live {
  color: #b91c1c;
  font-weight: 600;
}

.status-pill.refreshing {
  background: rgba(185, 28, 28, 0.16);
  color: #b91c1c;
  font-weight: 600;
}

:root[data-theme='dark'] .nvr-sync-phase {
  color: #9ca3af;
}

:root[data-theme='dark'] .nvr-sync-phase.live {
  color: #fca5a5;
}

.table-row-selected td {
  background: #ecfeff;
}

.pill {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid #dbeafe;
  background: #eff6ff;
  color: #1d4ed8;
  font-size: 11px;
  font-weight: 600;
}

.status-pill {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid transparent;
  font-size: 11px;
  font-weight: 700;
}

.status-pill.active {
  color: #166534;
  background: #f0fdf4;
  border-color: #bbf7d0;
}

.status-pill.passive {
  color: #92400e;
  background: #fffbeb;
  border-color: #fde68a;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.mono {
  font-family: Consolas, "Courier New", monospace;
  font-size: 12px;
}

.inline-note {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.preview-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 8px;
}

.preview-slot {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel-2, var(--soft-bg));
  padding: 8px;
  max-width: 320px;
  position: relative;
}

.preview-slot.preview-compact {
  max-width: 280px;
}

body.preview-lock {
  overflow: hidden;
}

#singlePreviewSlot {
  cursor: zoom-in;
  user-select: none;
  -webkit-user-select: none;
}

#singlePreviewSlot.expanded {
  position: fixed;
  inset: 10px;
  z-index: 1200;
  max-width: none;
  width: auto;
  border-color: #1e293b;
  background: #020817;
  padding: 10px;
  cursor: zoom-out;
}


#singlePreviewSlot.expanded .slot-img {
  width: 100%;
  height: calc(100vh - 78px);
  max-height: calc(100vh - 78px);
  aspect-ratio: auto;
  object-fit: contain;
  border-color: #334155;
}


#singlePreviewSlot.expanded .slot-placeholder {
  width: 100%;
  height: calc(100vh - 78px);
  aspect-ratio: auto;
  background: #0f172a;
  color: #cbd5e1;
  border-color: #334155;
}

#singlePreviewSlot.expanded .slot-meta {
  color: #e2e8f0;
}

.nv-top-grid {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  gap: 12px;
  margin-top: 12px;
  align-items: start;
}

/* prog create form */
.prog-create-form {
  max-width: 560px;
}

/* NVR list scroll */
.nvr-list-scroll,
.nvr-table-scroll {
  max-height: min(380px, 42vh);
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
  /* Sticky basliq secimi butun sehifeye yayilmasin */
  -webkit-user-select: text;
  user-select: text;
}

.nvr-table-scroll table {
  min-width: 980px;
  /* border-collapse ile sticky basliqda setirler aradan gorunur; separate ile tam ortulur */
  border-collapse: separate;
  border-spacing: 0;
}

.nvr-table-scroll thead th {
  -webkit-user-select: none;
  user-select: none;
}

.nvr-table-scroll thead th input {
  -webkit-user-select: text;
  user-select: text;
}

.nvr-table-scroll tbody td {
  -webkit-user-select: text;
  user-select: text;
}

.nvr-table-scroll thead tr:first-child th {
  position: sticky;
  top: 0;
  z-index: 3;
  background: var(--panel);
  box-shadow: 0 1px 0 var(--line);
}

.nvr-table-scroll thead tr:nth-child(2) th {
  position: sticky;
  /* --nvr-head-h JS ile birinci basliq setrinin real hundurluyune gore yenilenir */
  top: var(--nvr-head-h, 41px);
  z-index: 3;
  background: var(--panel);
  box-shadow: 0 1px 0 var(--line);
}

/* Sehife-daxili tablar (nvrs.html) */
.page-tabs {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 14px;
  border-bottom: 2px solid var(--line);
}

.page-tab {
  border: 1px solid var(--line);
  border-bottom: none;
  border-radius: 10px 10px 0 0;
  background: transparent;
  color: var(--muted);
  padding: 9px 18px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  margin-bottom: -2px;
}

.page-tab:hover {
  color: var(--text);
  background: var(--soft-bg);
}

.page-tab.active {
  color: var(--text);
  background: var(--panel);
  border-color: var(--line);
  border-bottom: 2px solid var(--panel);
}

.tab-panel.tab-hidden {
  display: none !important;
}

/* table horizontal scroll */
.table-scroll-x {
  overflow-x: auto;
}

.folder-list-toolbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: end;
  margin-bottom: 10px;
}

.folder-list-toolbar > div {
  min-width: 0;
}

.folder-table-summary {
  margin: 0;
  white-space: nowrap;
}

.folder-table-scroll {
  max-height: 460px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
}

.folder-table-scroll table {
  min-width: 980px;
}

.folder-table-scroll thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--panel);
}

.folder-tree-cell {
  display: flex;
  align-items: center;
  min-width: 220px;
}

.folder-tree-indent {
  flex: 0 0 auto;
}

.folder-tree-toggle,
.folder-tree-spacer {
  width: 24px;
  height: 24px;
  flex: 0 0 24px;
}

.folder-tree-toggle {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow-xs, 0 1px 2px rgba(15, 23, 42, 0.08));
  padding: 0;
  cursor: pointer;
  position: relative;
  transition: background-color 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease, transform 0.18s ease;
}

.folder-tree-toggle:hover {
  background: var(--soft-bg);
  border-color: var(--line-strong, var(--line));
  box-shadow: var(--shadow-sm, 0 4px 10px rgba(15, 23, 42, 0.08));
}

.folder-tree-toggle:focus-visible {
  outline: 2px solid #93c5fd;
  outline-offset: 1px;
}

.folder-tree-toggle:active {
  transform: translateY(1px);
}

.folder-tree-toggle-bar {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 10px;
  height: 2px;
  border-radius: 999px;
  background: #334155;
  transform: translate(-50%, -50%);
  transition: opacity 0.18s ease, transform 0.18s ease, background-color 0.18s ease;
}

.folder-tree-toggle-bar.vertical {
  width: 2px;
  height: 10px;
}

.folder-tree-toggle.is-open .folder-tree-toggle-bar.vertical {
  opacity: 0;
  transform: translate(-50%, -50%) scaleY(0.35);
}

.folder-tree-spacer {
  display: inline-block;
}

.folder-tree-name {
  min-width: 0;
  white-space: normal;
  word-break: break-word;
  cursor: grab;
}

.folder-row-dragging {
  opacity: 0.55;
}

.folder-row-drop-target {
  outline: 2px solid var(--accent, #2f6fed);
  outline-offset: -2px;
  background: color-mix(in srgb, var(--accent, #2f6fed) 12%, transparent);
}

#createFolderParentFilter,
#createFolderGroupFilter,
#assignFolderFilter,
#assignNvrFilter,
#detailFolderFilter {
  margin-bottom: 6px;
}

.folder-tree-match {
  font-weight: 700;
  color: var(--brand2);
}

/* NVR create top fields: 3+3 düzülüş */
.nvr-create-top-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
  margin-bottom: 8px;
  align-items: end;
}

.form-2col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 8px;
}

.group-picker {
  position: relative;
}

.group-picker-toggle {
  width: 100%;
  text-align: left;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 40px;
}

.group-picker-toggle::after {
  content: "▾";
  color: #64748b;
  font-size: 12px;
  margin-left: 10px;
}

.group-picker-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 12px 24px rgba(15, 23, 42, 0.12);
  z-index: 1300;
  padding: 8px;
}

.group-picker-list {
  max-height: 220px;
  overflow-y: auto;
}

.group-picker-list .perm-item {
  margin-bottom: 8px;
}

.group-picker-list .perm-item:last-child {
  margin-bottom: 0;
}

:root[data-theme='dark'] .chip {
  border-color: #14532d;
  background: #052e16;
  color: #86efac;
}

:root[data-theme='dark'] .btn-danger {
  color: #fecaca;
  background: #3f1d1d;
  border-color: #7f1d1d;
}

:root[data-theme='dark'] .tab-btn.active {
  background: #1e293b;
  border-color: #334155;
}

:root[data-theme='dark'] .card {
  box-shadow: 0 10px 24px rgba(2, 6, 23, 0.45);
}

:root[data-theme='dark'] .notice {
  background: #111827;
  color: #cbd5e1;
}

:root[data-theme='dark'] .notice.ok {
  border-color: #14532d;
  background: #052e16;
  color: #86efac;
}

:root[data-theme='dark'] .notice.err {
  border-color: #7f1d1d;
  background: #3f1d1d;
  color: #fecaca;
}

:root[data-theme='dark'] .notice.warn {
  border-color: #854d0e;
  background: #422006;
  color: #fde68a;
}

:root[data-theme='dark'] input,
:root[data-theme='dark'] select {
  background: #0b1220;
  color: var(--text);
}

:root[data-theme='dark'] .stat,
:root[data-theme='dark'] .block,
:root[data-theme='dark'] .camera-list-box,
:root[data-theme='dark'] .camera-detail-box,
:root[data-theme='dark'] .preview-slot,
:root[data-theme='dark'] .perm-grid,
:root[data-theme='dark'] .group-picker-dropdown,
:root[data-theme='dark'] .device-camera-pane,
:root[data-theme='dark'] .device-user-preview-block,
:root[data-theme='dark'] .camera-empty,
:root[data-theme='dark'] .slot-placeholder,
:root[data-theme='dark'] .device-user-preview-block .camera-empty,
:root[data-theme='dark'] .group-picker-empty,
:root[data-theme='dark'] .device-camera-preview-list,
:root[data-theme='dark'] .device-camera-preview-item,
:root[data-theme='dark'] .camera-item {
  background: #111827;
}

:root[data-theme='dark'] .camera-item.active,
:root[data-theme='dark'] .table-row-selected td {
  background: #0f2a3a;
}

:root[data-theme='dark'] .nvr-row-refreshing td {
  background: rgba(248, 113, 113, 0.16) !important;
}

:root[data-theme='dark'] .status-pill.refreshing {
  background: rgba(248, 113, 113, 0.22);
  color: #fca5a5;
}

:root[data-theme='dark'] .camera-item .t,
:root[data-theme='dark'] .camera-detail-val,
:root[data-theme='dark'] .nvr-user-view-tag,
:root[data-theme='dark'] .nvr-user-view-line {
  color: var(--text);
}

:root[data-theme='dark'] .camera-item .m,
:root[data-theme='dark'] .camera-detail-key,
:root[data-theme='dark'] .slot-meta,
:root[data-theme='dark'] .perm-item,
:root[data-theme='dark'] th {
  color: #cbd5e1;
}

:root[data-theme='dark'] th,
:root[data-theme='dark'] td,
:root[data-theme='dark'] .camera-detail-row,
:root[data-theme='dark'] .collapsible-block.is-open .collapsible-toggle,
:root[data-theme='dark'] .nvr-user-view-line {
  border-color: var(--line);
}

:root[data-theme='dark'] .collapsible-toggle:hover {
  background: #0b1220;
}

:root[data-theme='dark'] .form-section-title,
:root[data-theme='dark'] .collapsible-title {
  color: var(--text);
}

:root[data-theme='dark'] .folder-tree-toggle:hover {
  background: linear-gradient(180deg, #233245, #1b2737);
  border-color: #475569;
  box-shadow: 0 4px 12px rgba(2, 6, 23, 0.3);
}

:root[data-theme='dark'] .folder-tree-toggle {
  background: linear-gradient(180deg, #1e293b, #162132);
  border-color: #334155;
  box-shadow: 0 1px 2px rgba(2, 6, 23, 0.28);
}

:root[data-theme='dark'] .folder-tree-toggle-bar {
  background: #e2e8f0;
}

.group-picker-empty {
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 10px;
  text-align: center;
  color: #64748b;
  font-size: 12px;
  background: var(--panel-2, var(--soft-bg));
}

.device-target-nvr-list {
  max-height: 170px;
}

.users-compact table {
  font-size: 12px;
}

.users-compact th,
.users-compact td {
  padding: 6px 5px;
  white-space: nowrap;
}


.device-user-preview-block {
  margin-top: 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel-2, var(--soft-bg));
  padding: 8px;
  min-height: var(--device-user-panel-height);
  flex: 1;
  display: flex;
  flex-direction: column;
}

.device-user-preview-block .device-camera-preview-list {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 0;
  gap: 0;
}

.device-user-preview-block .device-camera-preview-item {
  width: 100%;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  border: none;
  background: transparent;
  padding: 0;
}

.device-user-preview-block .device-camera-preview-item .slot-meta {
  flex-shrink: 0;
  margin-top: 0;
  margin-bottom: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
}

.device-user-preview-block .device-camera-preview-item .slot-img {
  flex: 1;
  width: 100%;
  height: 0;
  min-height: 0;
  aspect-ratio: auto;
  object-fit: contain;
  background: #0f172a;
  border-radius: 8px;
  border: 1px solid #dbe3ea;
  display: block;
}

.device-user-preview-block .camera-empty {
  flex: 1;
  display: grid;
  place-items: center;
  text-align: center;
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 12px;
  color: #64748b;
  font-size: 12px;
  background: var(--panel-2, var(--soft-bg));
}

.device-camera-pane {
  display: block;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel-2, var(--soft-bg));
  padding: 8px;
  min-height: var(--device-user-panel-height);
  flex: 1;
}

.device-user-perm-grid .perm-grid {
  min-height: var(--device-user-panel-height);
  flex: 1;
  max-height: none;
  overflow-y: auto;
}

.device-camera-left {
  min-width: 0;
  display: flex;
  flex-direction: column;
  height: 100%;
}

.device-camera-right {
  min-width: 0;
}

.device-camera-preview-list {
  background: var(--panel-2, var(--soft-bg));
  padding: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.device-camera-preview-item {
  border: 1px solid #dbe3ea;
  border-radius: 10px;
  background: var(--panel);
  padding: 8px;
  width: 240px;
  flex-shrink: 0;
}

.device-camera-preview-item .slot-img {
  width: 100%;
  aspect-ratio: 16 / 9;
  height: auto;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid #dbe3ea;
  background: #0f172a;
  display: block;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-box {
  background: var(--panel);
  border-radius: 14px;
  padding: 28px 32px;
  width: 380px;
  max-width: 95vw;
  box-shadow: 0 8px 40px rgba(0,0,0,0.18);
}

.modal-box h3 { margin: 0 0 4px; }
.modal-box label { display: block; font-size: 12px; font-weight: 600; margin-bottom: 4px; color: var(--muted); }
.modal-box input { width: 100%; margin-bottom: 0; }

.nvr-user-link {
  border: 0;
  background: transparent;
  color: #0f766e;
  font-size: inherit;
  font-family: inherit;
  cursor: pointer;
  padding: 0;
  text-align: left;
}

.nvr-user-link:hover {
  text-decoration: underline;
}

.nvr-user-view-modal {
  width: min(860px, 96vw);
  max-height: 90vh;
  overflow: auto;
}

.nvr-user-view-body {
  margin-top: 8px;
}

.nvr-user-view-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.nvr-user-view-card {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel-2, var(--soft-bg));
  padding: 10px;
}

.nvr-user-view-card.full {
  grid-column: 1 / -1;
}

.nvr-user-view-tag-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.nvr-user-view-tag {
  display: inline-flex;
  align-items: center;
  border: 1px solid #dbe3ea;
  border-radius: 999px;
  background: var(--panel);
  padding: 4px 10px;
  font-size: 12px;
  color: var(--text);
}

.nvr-user-view-empty {
  color: #64748b;
  font-size: 12px;
}

.nvr-user-view-list {
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: var(--panel);
  max-height: 220px;
  overflow: auto;
}

.nvr-user-view-line {
  padding: 8px 10px;
  font-size: 12px;
  border-bottom: 1px solid #e2e8f0;
}

.nvr-user-view-line:last-child {
  border-bottom: none;
}

@media (max-width: 900px) {
  .nvr-user-view-grid {
    grid-template-columns: 1fr;
  }

  .nvr-user-view-modal {
    padding: 18px 16px;
  }
}

.discover-bar {
  display: grid;
  grid-template-columns: minmax(0,1fr) auto;
  gap: 10px;
  align-items: end;
  margin-bottom: 10px;
}

.camera-dynamic-grid {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  gap: 12px;
  margin-top: 8px;
  align-items: start;
}

.camera-dynamic-grid.compact {
  grid-template-columns: 280px minmax(0, 1fr);
}

.camera-right-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 280px;
  gap: 10px;
  align-items: start;
}

.camera-list-box {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel-2, var(--soft-bg));
  max-height: 420px;
  overflow: auto;
  padding: 8px;
}

.camera-item {
  width: 100%;
  border: 1px solid #dbe3ea;
  border-radius: 10px;
  background: var(--panel);
  text-align: left;
  padding: 8px;
  margin-bottom: 8px;
  cursor: pointer;
}

.camera-item:last-child {
  margin-bottom: 0;
}

.camera-item.active {
  border-color: #0f766e;
  background: #ecfeff;
}

.camera-item .t {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

.camera-item .m {
  margin-top: 3px;
  font-size: 12px;
  color: #475467;
}

.camera-detail-box {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel-2, var(--soft-bg));
  padding: 10px;
}

.camera-detail-row {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 8px;
  font-size: 13px;
  padding: 4px 0;
  border-bottom: 1px dashed #e5e7eb;
}

.camera-detail-row:last-child {
  border-bottom: 0;
}

.camera-detail-key {
  color: #64748b;
}

.camera-detail-val {
  color: var(--text);
  font-weight: 600;
}

.camera-control-form {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed #dbe3ea;
}

.camera-control-form .row,
.camera-control-form .row-4 {
  margin-bottom: 6px;
}

.camera-control-form input,
.camera-control-form select {
  padding: 8px;
  font-size: 12px;
}

#bulkCameraSelect {
  min-height: 120px;
}

#folderCameraSelect {
  min-height: 220px;
}

.camera-empty {
  border: 1px dashed var(--line);
  border-radius: 10px;
  padding: 12px;
  color: #64748b;
  font-size: 12px;
  text-align: center;
  background: var(--panel-2, var(--soft-bg));
}

.slot-head {
  font-size: 12px;
  color: #475467;
  margin-bottom: 6px;
  font-weight: 600;
}

.slot-meta {
  margin-top: 6px;
  font-size: 12px;
  color: var(--text);
}

.slot-placeholder {
  border: 1px dashed var(--line);
  border-radius: 8px;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
  padding: 6px;
  background: var(--panel-2, var(--soft-bg));
  width: 100%;
  aspect-ratio: 1 / 1;
}

.slot-img {
  width: 100%;
  aspect-ratio: 1 / 1;
  height: auto;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid #dbe3ea;
  background: #0f172a;
}


pre {
  margin: 0;
  border: 1px solid #1f2937;
  border-radius: 10px;
  background: #0f172a;
  color: #e2e8f0;
  padding: 12px;
  min-height: 220px;
  overflow: auto;
  font-size: 12px;
}

@media (max-width: 1100px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar {
    height: auto;
    position: static;
  }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-2 { grid-template-columns: 1fr; }
  .nvr-create-top-row { grid-template-columns: 1fr 1fr; }
  .form-2col { grid-template-columns: 1fr; }
  .nv-top-grid { grid-template-columns: 1fr; }
  .camera-dynamic-grid { grid-template-columns: 1fr; }
  .camera-right-grid { grid-template-columns: 1fr; }
  .preview-slot { max-width: 100%; }
  .row, .row-4 { grid-template-columns: 1fr; }
  .form-2col { grid-template-columns: 1fr; }
  .folder-list-toolbar { grid-template-columns: 1fr; }
  .folder-table-summary {
    white-space: normal;
  }
}

/* ── Şirkətlər (multi-tenant) ─────────────────────────────────────────────── */
.company-switch-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.company-current-row td {
  background: var(--panel-soft, rgba(14, 165, 233, 0.06));
}

/* ══════════════════════════════════════════════════════════════════════════
   MODERN UI LAYER
   Yalnız görünüş: yuxarıdakı qaydaları əvəz edir, heç bir element silinmir.
   Geri qaytarmaq üçün bu blokun hamısını silmək kifayətdir.
   ══════════════════════════════════════════════════════════════════════════ */

:root {
  --bg: #f4f6fa;
  --panel: #ffffff;
  --panel-2: #f8fafc;
  --panel-3: #f1f5f9;
  --line: #e4e8ef;
  --line-strong: #d3d9e3;
  --text: #0f172a;
  --muted: #64748b;
  --brand: #2563eb;
  --brand2: #2563eb;
  --brand-strong: #1d4ed8;
  --brand-soft: #eff4ff;
  --brand-ring: rgba(37, 99, 235, 0.18);
  --ok: #15803d;
  --err: #b91c1c;
  --warn: #a16207;
  --soft-bg: #ffffff;
  --soft-text: #1e293b;
  --topbar-bg: rgba(255, 255, 255, 0.86);
  --sidebar-bg: #ffffff;
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;
  --shadow-xs: 0 1px 2px rgba(15, 23, 42, 0.05);
  --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.06), 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-md: 0 6px 20px -6px rgba(15, 23, 42, 0.12), 0 2px 6px rgba(15, 23, 42, 0.04);
  --shadow-lg: 0 24px 48px -12px rgba(15, 23, 42, 0.22);
  --topbar-h: 60px;
  --font: "Inter", "Segoe UI Variable", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: "JetBrains Mono", "Cascadia Code", Consolas, "SFMono-Regular", Menlo, monospace;
}

:root[data-theme='dark'] {
  --bg: #0b1120;
  --panel: #111827;
  --panel-2: #0f172a;
  --panel-3: #1a2333;
  --line: #222d3d;
  --line-strong: #2f3b4f;
  --text: #e5e9f0;
  --muted: #94a3b8;
  --brand: #3b82f6;
  --brand2: #3b82f6;
  --brand-strong: #60a5fa;
  --brand-soft: rgba(59, 130, 246, 0.14);
  --brand-ring: rgba(59, 130, 246, 0.3);
  --ok: #4ade80;
  --err: #f87171;
  --warn: #fbbf24;
  --soft-bg: #161f2e;
  --soft-text: #e5e9f0;
  --topbar-bg: rgba(13, 19, 33, 0.86);
  --sidebar-bg: #0e1626;
  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.35);
  --shadow-md: 0 8px 24px -8px rgba(0, 0, 0, 0.55);
  --shadow-lg: 0 24px 48px -12px rgba(0, 0, 0, 0.7);
}

html { color-scheme: light; }
:root[data-theme='dark'] { color-scheme: dark; }

body {
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

::selection { background: var(--brand-ring); }

* { scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 999px; border: 2px solid transparent; background-clip: padding-box; }
*::-webkit-scrollbar-track { background: transparent; }

h2, h3 { letter-spacing: -0.01em; }

/* ── Buttons ─────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 36px;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.2;
  white-space: nowrap;
  transition: background-color .15s ease, border-color .15s ease, color .15s ease, box-shadow .15s ease, transform .05s ease;
}

.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--brand-ring); }
.btn:disabled { opacity: .55; cursor: not-allowed; }

.btn-primary {
  background: var(--brand);
  border: 1px solid var(--brand);
  color: #fff;
  box-shadow: var(--shadow-xs), inset 0 1px 0 rgba(255, 255, 255, 0.12);
}
.btn-primary:hover:not(:disabled) { background: var(--brand-strong); border-color: var(--brand-strong); }
:root[data-theme='dark'] .btn-primary:hover:not(:disabled) { background: #2563eb; border-color: #2563eb; }

.btn-soft {
  background: var(--soft-bg);
  color: var(--soft-text);
  border: 1px solid var(--line-strong);
  box-shadow: var(--shadow-xs);
}
.btn-soft:hover:not(:disabled) { background: var(--panel-3); border-color: var(--line-strong); }

.btn-danger {
  background: #fff5f5;
  color: #c81e1e;
  border: 1px solid #fbd0d0;
}
.btn-danger:hover:not(:disabled) { background: #fee2e2; border-color: #f8b4b4; }
:root[data-theme='dark'] .btn-danger { background: rgba(248, 113, 113, 0.1); color: #fca5a5; border-color: rgba(248, 113, 113, 0.3); }
:root[data-theme='dark'] .btn-danger:hover:not(:disabled) { background: rgba(248, 113, 113, 0.18); }

.btn-mini { min-height: 28px; padding: 4px 10px; font-size: 12px; border-radius: 7px; }
.actions .btn { min-height: 30px; padding: 5px 11px; font-size: 12px; }

/* ── Cards / blocks ──────────────────────────────────────────────────────── */
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}
:root[data-theme='dark'] .card { box-shadow: var(--shadow-sm); }

.block,
:root[data-theme='dark'] .block {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow-xs);
}
.block h3 { font-size: 15px; font-weight: 650; margin: 0 0 12px; color: var(--text); }
.collapsible-block { padding: 0; }
.collapsible-toggle { padding: 14px 16px; }
.collapsible-toggle:hover { background: var(--panel-2); }
:root[data-theme='dark'] .collapsible-toggle:hover { background: var(--panel-2); }
.collapsible-title, .form-section-title { color: var(--text); }
.collapsible-icon { border-color: var(--muted); }
.collapsible-block.is-open .collapsible-toggle { border-bottom-color: var(--line); }
.collapsible-content { padding: 14px 16px 16px; }

/* ── Notices ─────────────────────────────────────────────────────────────── */
.notice,
:root[data-theme='dark'] .notice {
  border: 1px solid var(--line);
  border-left: 3px solid var(--line-strong);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  background: var(--panel-2);
  color: var(--soft-text);
  font-size: 13px;
}
.notice.ok { border-color: #bbf7d0; border-left-color: #22c55e; background: #f0fdf4; color: #166534; }
.notice.err { border-color: #fecaca; border-left-color: #ef4444; background: #fef2f2; color: #991b1b; }
.notice.warn { border-color: #fde68a; border-left-color: #f59e0b; background: #fffbeb; color: #92400e; }
:root[data-theme='dark'] .notice.ok { border-color: rgba(34, 197, 94, 0.25); border-left-color: #22c55e; background: rgba(34, 197, 94, 0.08); color: #86efac; }
:root[data-theme='dark'] .notice.err { border-color: rgba(239, 68, 68, 0.25); border-left-color: #ef4444; background: rgba(239, 68, 68, 0.08); color: #fca5a5; }
:root[data-theme='dark'] .notice.warn { border-color: rgba(245, 158, 11, 0.25); border-left-color: #f59e0b; background: rgba(245, 158, 11, 0.08); color: #fcd34d; }

/* ── Forms ───────────────────────────────────────────────────────────────── */
label { font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 6px; }

input,
select,
textarea,
:root[data-theme='dark'] input,
:root[data-theme='dark'] select {
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  padding: 8px 11px;
  font-size: 13px;
  line-height: 1.4;
  transition: border-color .15s ease, box-shadow .15s ease, background-color .15s ease;
}
input:not([type=checkbox]):not([type=radio]):not([type=file]),
select { min-height: 38px; }
input::placeholder, textarea::placeholder { color: #9aa5b5; }
input:hover:not(:disabled):not(:focus),
select:hover:not(:disabled):not(:focus),
textarea:hover:not(:disabled):not(:focus) { border-color: #b8c1cf; }
:root[data-theme='dark'] input:hover:not(:disabled):not(:focus),
:root[data-theme='dark'] select:hover:not(:disabled):not(:focus),
:root[data-theme='dark'] textarea:hover:not(:disabled):not(:focus) { border-color: #3d4a60; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-ring); }
input:disabled, select:disabled, textarea:disabled { background: var(--panel-3); color: var(--muted); cursor: not-allowed; }
input[type=checkbox], input[type=radio] { accent-color: var(--brand); width: 15px; height: 15px; min-height: 0; cursor: pointer; }
select[multiple] { padding: 4px; }
select[multiple] option { padding: 5px 8px; border-radius: 6px; }
:root[data-theme='dark'] textarea { background: var(--panel); color: var(--text); }

.perm-grid,
:root[data-theme='dark'] .perm-grid { background: var(--panel-2); border-color: var(--line); border-radius: var(--radius-sm); }
.perm-item { color: var(--soft-text); }
:root[data-theme='dark'] .perm-item { color: var(--soft-text); }
.inline-note, .sub, .muted { color: var(--muted); }
.lbl-hint { color: var(--muted); }

.group-picker-dropdown,
:root[data-theme='dark'] .group-picker-dropdown { background: var(--panel); border-color: var(--line); border-radius: var(--radius); box-shadow: var(--shadow-lg); }
.group-picker-empty,
:root[data-theme='dark'] .group-picker-empty { background: var(--panel-2); border-color: var(--line-strong); color: var(--muted); }

/* ── Topbar ──────────────────────────────────────────────────────────────── */
.topbar {
  height: var(--topbar-h);
  padding: 0 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--topbar-bg);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--line);
  z-index: 50;
}
.brand-logo { height: 36px; border-radius: 9px; box-shadow: 0 2px 8px rgba(29, 78, 216, 0.25); }
.top-right { gap: 8px; flex-wrap: nowrap; }
.top-right .btn { min-height: 34px; }

.chip,
:root[data-theme='dark'] .chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: 42vw;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding: 6px 12px 6px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--soft-text);
  font-size: 12.5px;
  font-weight: 600;
}
.chip::before {
  content: '';
  flex: 0 0 8px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #22c55e;
  box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.18);
}

/* ── Layout + sidebar ────────────────────────────────────────────────────── */
.app {
  grid-template-rows: auto 1fr;
}

.layout {
  grid-template-columns: 248px minmax(0, 1fr);
  gap: 0;
  padding: 0;
  transition: grid-template-columns .25s ease;
}

.layout.sidebar-collapsed {
  grid-template-columns: 64px minmax(0, 1fr);
}

.sidebar,
.card.sidebar {
  position: sticky;
  top: var(--topbar-h);
  height: calc(100vh - var(--topbar-h));
  overflow-y: auto;
  overflow-x: hidden;
  padding: 14px 12px;
  background: var(--sidebar-bg);
  border: 0;
  border-right: 1px solid var(--line);
  border-radius: 0;
  box-shadow: none;
  transition: padding .25s ease, opacity .2s ease, border-right-color .25s ease;
  white-space: nowrap;
  display: flex;
  flex-direction: column;
}

.layout.sidebar-collapsed .sidebar,
.layout.sidebar-collapsed .card.sidebar {
  padding: 14px 8px;
}

.sidebar::before { display: none; }

.nav-text { overflow: hidden; text-overflow: ellipsis; }

.layout.sidebar-collapsed .sidebar-header { justify-content: center; padding: 0 0 10px; }
.layout.sidebar-collapsed .sidebar-label,
.layout.sidebar-collapsed .nav-text { display: none; }
.layout.sidebar-collapsed .sidebar .tab-btn,
.layout.sidebar-collapsed a.btn.tab-btn {
  justify-content: center;
  padding: 8px 0;
}
.layout.sidebar-collapsed .sidebar-footer { font-size: 0; padding: 10px 0 2px; }
.layout.sidebar-collapsed .sidebar-footer::before { content: '©'; font-size: 13px; }

.sidebar-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 4px 10px;
}
.sidebar-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--muted);
}
.sidebar-toggle {
  background: none;
  border: 1px solid var(--line);
  border-radius: 6px;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 14px;
  color: var(--muted);
  transition: .15s;
  flex-shrink: 0;
}
.sidebar-toggle:hover { color: var(--text); border-color: var(--brand); background: var(--brand-soft, rgba(37,99,235,.08)); }

.sidebar-footer {
  margin-top: auto;
  padding: 10px 4px 2px;
  font-size: 10px;
  color: var(--muted);
  text-align: center;
  border-top: 1px solid var(--line);
}


.sidebar .tab-btn,
a.btn.tab-btn {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
  width: 100%;
  min-height: 38px;
  margin: 0 0 2px;
  padding: 8px 12px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  box-shadow: none;
  color: var(--soft-text);
  font-weight: 550;
  font-size: 13.5px;
  position: relative;
}
.sidebar .tab-btn:hover { background: var(--panel-3); }
.sidebar .tab-btn.active,
:root[data-theme='dark'] .tab-btn.active {
  background: var(--brand-soft);
  color: var(--brand-strong);
  border: 0;
  font-weight: 650;
}
.sidebar .tab-btn.active::after {
  content: '';
  position: absolute;
  left: -12px;
  top: 8px;
  bottom: 8px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--brand);
}
.sidebar .tab-btn.hidden { display: none !important; }

/* Menyu ikonları (SVG mask, rəng mətndən gəlir) */
.sidebar .tab-btn::before {
  content: '';
  flex: 0 0 18px;
  width: 18px;
  height: 18px;
  background-color: currentColor;
  opacity: .85;
  -webkit-mask: var(--nav-icon) center / contain no-repeat;
  mask: var(--nav-icon) center / contain no-repeat;
}
.sidebar .tab-btn.active::before { opacity: 1; }
#navOverview { --nav-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3' y='3' width='7' height='9' rx='1.5'/%3E%3Crect x='14' y='3' width='7' height='5' rx='1.5'/%3E%3Crect x='14' y='12' width='7' height='9' rx='1.5'/%3E%3Crect x='3' y='16' width='7' height='5' rx='1.5'/%3E%3C/svg%3E"); }
#navAudit { --nav-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z'/%3E%3Cpath d='M14 2v6h6'/%3E%3Cpath d='M8 13h8M8 17h5'/%3E%3C/svg%3E"); }
#navNvrs { --nav-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m16 13 5.2 3.5a.5.5 0 0 0 .8-.4V7.9a.5.5 0 0 0-.8-.4L16 11'/%3E%3Crect x='2' y='6' width='14' height='12' rx='2'/%3E%3C/svg%3E"); }
#navUsers { --nav-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='8' r='4'/%3E%3Cpath d='M4 21a8 8 0 0 1 16 0'/%3E%3C/svg%3E"); }
#navGroups { --nav-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='7' r='3'/%3E%3Cpath d='M6.5 20a5.5 5.5 0 0 1 11 0'/%3E%3Ccircle cx='4.5' cy='10' r='2'/%3E%3Cpath d='M1.5 18.5a3.5 3.5 0 0 1 4-3.4'/%3E%3Ccircle cx='19.5' cy='10' r='2'/%3E%3Cpath d='M22.5 18.5a3.5 3.5 0 0 0-4-3.4'/%3E%3C/svg%3E"); }
#navFolders { --nav-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 20h16a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.93a2 2 0 0 1-1.66-.9l-.82-1.2A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13c0 1.1.9 2 2 2Z'/%3E%3C/svg%3E"); }
#navUpdates { --nav-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='2' y='3' width='20' height='14' rx='2'/%3E%3Cpath d='M8 21h8M12 17v4M12 7v6M9 10l3 3 3-3'/%3E%3C/svg%3E"); }
#navSettings { --nav-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z'/%3E%3Ccircle cx='12' cy='12' r='3'/%3E%3C/svg%3E"); }
#navCompanies { --nav-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 22V4a2 2 0 0 1 2-2h8a2 2 0 0 1 2 2v18Z'/%3E%3Cpath d='M6 12H4a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2h2M18 9h2a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2h-2'/%3E%3Cpath d='M10 6h4M10 10h4M10 14h4M10 18h4'/%3E%3C/svg%3E"); }
#navCompanies { margin-bottom: 10px; }
#navCompanies + * { margin-top: 0; }

/* ── Content area ────────────────────────────────────────────────────────── */
.content,
.card.content {
  margin: 20px 24px 28px;
  padding: 24px 26px;
  border-radius: var(--radius-lg);
  min-height: calc(100vh - var(--topbar-h) - 48px);
}
.content > h2,
.section h2 {
  margin: 0 0 4px;
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
}
.content > .sub,
.section > .sub { margin: 0 0 18px; font-size: 13.5px; }
.content > .notice { margin-bottom: 12px; }

/* ── Stats ───────────────────────────────────────────────────────────────── */
.stats { gap: 14px; margin: 16px 0; }
.stat,
:root[data-theme='dark'] .stat {
  position: relative;
  overflow: hidden;
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow-xs);
}
.stat::before {
  content: '';
  position: absolute;
  inset: 0 auto 0 0;
  width: 3px;
  background: var(--brand);
  opacity: .75;
}
.stats .stat:nth-child(4n+2)::before { background: #10b981; }
.stats .stat:nth-child(4n+3)::before { background: #f59e0b; }
.stats .stat:nth-child(4n+4)::before { background: #8b5cf6; }
.stat .k { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.stat .v { font-size: 26px; font-weight: 700; margin-top: 6px; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }

/* ── Tables ──────────────────────────────────────────────────────────────── */
table { font-size: 13px; font-variant-numeric: tabular-nums; }
th, td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th,
:root[data-theme='dark'] th {
  font-size: 11.5px;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--muted);
  background: var(--panel-2);
  white-space: nowrap;
}
thead th:first-child { border-top-left-radius: var(--radius-sm); }
thead th:last-child { border-top-right-radius: var(--radius-sm); }
tbody tr:last-child > td { border-bottom: 0; }
tbody tr:not(.table-row-selected):not(.nvr-row-refreshing):not(.company-current-row):hover > td { background: var(--panel-2); }
.table-row-selected td { background: var(--brand-soft); }
:root[data-theme='dark'] .table-row-selected td { background: var(--brand-soft); }
.users-compact th, .users-compact td { padding: 7px 8px; }
.nvr-table-scroll thead tr:first-child th,
.nvr-table-scroll thead tr:nth-child(2) th,
.folder-table-scroll thead th { background: var(--panel-2); }
.nvr-table-scroll thead tr:nth-child(2) th { text-transform: none; letter-spacing: 0; }

.table-scroll-x,
.nvr-list-scroll,
.nvr-table-scroll,
.folder-table-scroll {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
}
.block > .table-scroll-x:only-child,
.block > h3 + .table-scroll-x { margin-top: 4px; }

/* ── Pills ───────────────────────────────────────────────────────────────── */
.pill {
  padding: 2px 9px;
  border-radius: 999px;
  border: 1px solid transparent;
  background: var(--brand-soft);
  color: var(--brand-strong);
  font-size: 11.5px;
  font-weight: 600;
}
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 9px 2px 8px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 650;
  border: 1px solid transparent;
}
.status-pill::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.status-pill.active { color: #15803d; background: #ecfdf3; border-color: #c6f1d6; }
.status-pill.passive { color: #b45309; background: #fff8eb; border-color: #fde7b0; }
:root[data-theme='dark'] .status-pill.active { color: #4ade80; background: rgba(34, 197, 94, 0.12); border-color: rgba(34, 197, 94, 0.25); }
:root[data-theme='dark'] .status-pill.passive { color: #fbbf24; background: rgba(245, 158, 11, 0.12); border-color: rgba(245, 158, 11, 0.25); }

/* ── In-page tabs (segmented) ────────────────────────────────────────────── */
.page-tabs {
  display: inline-flex;
  gap: 4px;
  margin-top: 6px;
  margin-bottom: 14px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--panel-3);
  border-bottom: 1px solid var(--line);
  max-width: 100%;
  overflow-x: auto;
}
.page-tab {
  margin: 0;
  padding: 7px 16px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-weight: 600;
  white-space: nowrap;
  transition: background-color .15s ease, color .15s ease, box-shadow .15s ease;
}
.page-tab:hover { background: transparent; color: var(--text); }
.page-tab.active {
  background: var(--panel);
  color: var(--text);
  border: 0;
  box-shadow: var(--shadow-sm);
}

/* ── Misc surfaces ───────────────────────────────────────────────────────── */
.camera-list-box, .camera-detail-box, .preview-slot, .device-camera-pane,
.device-user-preview-block, .device-camera-preview-list, .nvr-user-view-card,
:root[data-theme='dark'] .camera-list-box,
:root[data-theme='dark'] .camera-detail-box,
:root[data-theme='dark'] .preview-slot,
:root[data-theme='dark'] .device-camera-pane,
:root[data-theme='dark'] .device-user-preview-block,
:root[data-theme='dark'] .device-camera-preview-list {
  background: var(--panel-2);
  border-color: var(--line);
  border-radius: var(--radius);
}
.camera-item,
:root[data-theme='dark'] .camera-item {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  transition: border-color .15s ease, background-color .15s ease, box-shadow .15s ease;
}
.camera-item:hover { border-color: var(--line-strong); box-shadow: var(--shadow-xs); }
.camera-item.active,
:root[data-theme='dark'] .camera-item.active { border-color: var(--brand); background: var(--brand-soft); }
.camera-item .t, .camera-detail-val { color: var(--text); }
.camera-item .m, .camera-detail-key { color: var(--muted); }
.camera-detail-row { border-bottom-color: var(--line); }
.camera-empty, .slot-placeholder,
:root[data-theme='dark'] .camera-empty,
:root[data-theme='dark'] .slot-placeholder { background: var(--panel-2); border-color: var(--line-strong); color: var(--muted); }
.device-camera-preview-item,
:root[data-theme='dark'] .device-camera-preview-item { background: var(--panel); border-color: var(--line); }
.nvr-user-view-tag { background: var(--panel); border-color: var(--line); color: var(--text); }
.nvr-user-view-list { background: var(--panel); border-color: var(--line-strong); }
.nvr-user-view-line { border-bottom-color: var(--line); }
.nvr-user-link { color: var(--brand); font-weight: 600; }
.mono { font-family: var(--font-mono); font-size: 12px; }
pre { border-radius: var(--radius); font-family: var(--font-mono); }

/* ── Modal ───────────────────────────────────────────────────────────────── */
.modal-backdrop { background: rgba(15, 23, 42, 0.5); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); }
.modal-box { border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); }

/* ── Login ───────────────────────────────────────────────────────────────── */
.login-wrap {
  background:
    radial-gradient(800px 420px at 15% 0%, rgba(37, 99, 235, 0.12), transparent 65%),
    radial-gradient(700px 420px at 90% 100%, rgba(16, 185, 129, 0.10), transparent 65%),
    var(--bg);
}
.login-card {
  max-width: 400px;
  padding: 28px 30px 30px;
  border-radius: 20px;
  box-shadow: var(--shadow-lg);
}
.login-card .muted { text-align: center; margin: 2px 0 22px; font-size: 13.5px; }
.login-card label { margin-top: 2px; }
.login-card input { min-height: 42px; }
.login-card #loginBtn { min-height: 42px; font-size: 14px; }
.brand-logo-lg { height: 68px; }

/* ── Super admin company switch banner ───────────────────────────────────── */
.company-switch-banner { border-radius: var(--radius); padding: 10px 14px; }
.company-current-row td { background: var(--brand-soft); }

/* ── Responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 1100px) {
  .layout { grid-template-columns: 1fr; align-content: start; }
  .sidebar,
  .card.sidebar {
    align-items: center;
    position: sticky;
    top: var(--topbar-h);
    z-index: 40;
    height: auto;
    display: flex;
    gap: 4px;
    overflow-x: auto;
    padding: 8px 12px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
  .sidebar::before { display: none; }
  .sidebar .tab-btn,
  a.btn.tab-btn { width: auto; flex: 0 0 auto; margin: 0; white-space: nowrap; }
  .sidebar .tab-btn.active::after { display: none; }
  #navCompanies { margin-bottom: 0; }
  .content,
  .card.content { margin: 14px; padding: 18px 16px; min-height: 0; }
}

@media (max-width: 640px) {
  .topbar { padding: 0 12px; }
  .top-right { gap: 6px; }
  .top-right .btn { padding: 6px 10px; font-size: 12px; }
  .chip { display: none; }
}

/* ══════════════════════════════════════════════════════════════════════════
   ACCESS UI (qovluq giriş icazələri, effektiv yetki)
   ══════════════════════════════════════════════════════════════════════════ */

.level-chips { display: inline-flex; flex-wrap: wrap; gap: 4px; }
.level-chip {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 11.5px; font-weight: 500; line-height: 20px; padding: 0 9px;
  border-radius: 999px; border: 1px solid var(--line); background: var(--panel-2); color: var(--muted);
}
.level-chip.on { background: var(--brand-soft); border-color: transparent; color: var(--brand-strong); font-weight: 600; }
.level-chip.off { opacity: 0.6; }
.level-chip.off::before { content: ""; width: 6px; height: 1.5px; background: currentColor; opacity: 0.7; }

.ax-layout { display: grid; grid-template-columns: 320px minmax(0, 1fr); gap: 16px; align-items: start; }
.ax-panel {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xs);
}

/* tree */
.ax-tree { position: sticky; top: calc(var(--topbar-h) + 16px); display: flex; flex-direction: column; max-height: calc(100vh - var(--topbar-h) - 48px); }
.ax-tree-head { padding: 14px 14px 10px; border-bottom: 1px solid var(--line); }
.ax-tree-head h4 { margin: 0 0 8px; font-size: 13px; font-weight: 600; }
.ax-tree-head input { margin: 0; }
.ax-tree-list { overflow: auto; padding: 6px; }
.ax-node {
  display: flex; align-items: center; gap: 6px; width: 100%;
  padding: 6px 8px 6px calc(8px + var(--depth, 0) * 16px);
  border: 0; border-radius: var(--radius-sm); background: transparent; color: var(--text);
  font: inherit; font-size: 13px; text-align: left; cursor: pointer;
}
.ax-node:hover { background: var(--panel-3); }
.ax-node.is-selected { background: var(--brand-soft); color: var(--brand-strong); font-weight: 600; }
.ax-node.is-passive .ax-node-name { opacity: 0.55; }
.ax-caret {
  flex: 0 0 18px; height: 18px; display: inline-flex; align-items: center; justify-content: center;
  border-radius: 4px; color: var(--muted); transition: transform .15s ease;
}
.ax-caret:hover { background: var(--line); }
.ax-caret.is-open { transform: rotate(90deg); }
.ax-caret.is-leaf { visibility: hidden; }
.ax-folder-ico { flex: 0 0 16px; height: 16px; color: var(--muted); }
.ax-node.is-selected .ax-folder-ico { color: var(--brand); }
.ax-node-name { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ax-node-meta { flex: 0 0 auto; font-size: 11px; color: var(--muted); font-weight: 500; }
.ax-node mark { background: rgba(250, 204, 21, 0.35); color: inherit; border-radius: 2px; }
.ax-tree-empty { padding: 18px; text-align: center; color: var(--muted); font-size: 13px; }

/* detail */
.ax-detail { min-width: 0; }
.ax-head { padding: 18px 20px 16px; border-bottom: 1px solid var(--line); display: flex; gap: 12px; align-items: flex-start; justify-content: space-between; flex-wrap: wrap; }
.ax-crumbs { font-size: 12.5px; color: var(--muted); display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.ax-crumbs .sep { opacity: .5; }
.ax-title { margin: 2px 0 0; font-size: 18px; font-weight: 650; letter-spacing: -0.01em; }
.ax-head-meta { display: flex; gap: 6px; flex-wrap: wrap; }
.ax-badge {
  display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 500;
  padding: 3px 10px; border-radius: 999px; background: var(--panel-3); color: var(--muted); white-space: nowrap;
}
.ax-badge.ok { background: rgba(21, 128, 61, 0.1); color: var(--ok); }
.ax-badge.warn { background: rgba(161, 98, 7, 0.12); color: var(--warn); }
.ax-badge.err { background: rgba(185, 28, 28, 0.1); color: var(--err); }
.ax-badge.brand { background: var(--brand-soft); color: var(--brand-strong); }
.ax-section { padding: 16px 20px; border-bottom: 1px solid var(--line); }
.ax-section:last-child { border-bottom: 0; }
.ax-section-title { display: flex; align-items: center; gap: 8px; margin: 0 0 4px; font-size: 13.5px; font-weight: 600; }
.ax-count { font-size: 11.5px; font-weight: 600; color: var(--muted); background: var(--panel-3); border-radius: 999px; padding: 0 8px; line-height: 20px; }
.ax-section-desc { margin: 0 0 12px; font-size: 12.5px; color: var(--muted); }

/* switch */
.ax-switch-row { display: flex; gap: 12px; align-items: flex-start; }
.ax-switch { position: relative; flex: 0 0 38px; width: 38px; height: 22px; margin-top: 1px; }
.ax-switch input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; z-index: 1; }
.ax-switch span { position: absolute; inset: 0; border-radius: 999px; background: var(--line-strong); transition: background .15s ease; }
.ax-switch span::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%;
  background: var(--panel); box-shadow: 0 1px 2px rgba(0,0,0,.25); transition: transform .15s ease;
}
.ax-switch input:checked + span { background: var(--brand); }
.ax-switch input:checked + span::after { transform: translateX(16px); }
.ax-switch input:focus-visible + span { box-shadow: 0 0 0 3px var(--brand-ring); }
.ax-switch input:disabled + span { opacity: .5; }
.ax-switch-text b { display: block; font-size: 13.5px; font-weight: 600; }
.ax-switch-text p { margin: 2px 0 0; font-size: 12.5px; color: var(--muted); }

.ax-inherited { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.ax-inherited-item {
  display: inline-flex; align-items: center; gap: 8px; padding: 5px 10px 5px 6px;
  border: 1px dashed var(--line-strong); border-radius: 999px; font-size: 12.5px; background: var(--panel-2);
}

/* rule rows */
.ax-rules { display: flex; flex-direction: column; gap: 8px; }
.ax-rule {
  display: grid; grid-template-columns: 34px minmax(120px, 1fr) auto minmax(150px, 200px) 30px;
  grid-template-areas: "av name seg tpl rm" ". lv lv lv lv";
  gap: 10px 12px; align-items: center; padding: 10px 12px;
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel);
  transition: border-color .15s ease, box-shadow .15s ease;
}
.ax-rule:hover { border-color: var(--line-strong); box-shadow: var(--shadow-xs); }
.ax-rule.is-deny { background: linear-gradient(0deg, rgba(185, 28, 28, 0.04), rgba(185, 28, 28, 0.04)), var(--panel); border-color: rgba(185, 28, 28, 0.25); }
.ax-rule select { margin: 0; height: 32px; padding-top: 0; padding-bottom: 0; font-size: 12.5px; }
.ax-avatar {
  width: 34px; height: 34px; border-radius: 10px; display: inline-flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; letter-spacing: .02em; color: #fff; background: var(--av, #64748b); flex: 0 0 auto;
}
.ax-avatar.sm { width: 24px; height: 24px; border-radius: 7px; font-size: 10px; }
.ax-rule-name { font-weight: 600; font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ax-rule-sub { font-size: 12px; color: var(--muted); }
.ax-seg { display: inline-flex; padding: 2px; border-radius: 9px; background: var(--panel-3); border: 1px solid var(--line); }
.ax-seg button {
  border: 0; background: transparent; color: var(--muted); font: inherit; font-size: 12.5px; font-weight: 600;
  padding: 4px 12px; border-radius: 7px; cursor: pointer;
}
.ax-seg button.on { background: var(--panel); color: var(--text); box-shadow: var(--shadow-xs); }
.ax-seg button.on[data-effect='deny'] { color: var(--err); }
.ax-seg button.on[data-effect='allow'] { color: var(--ok); }
.ax-levels { display: flex; flex-wrap: wrap; gap: 4px; grid-area: lv; }
.ax-r-av { grid-area: av; } .ax-r-name { grid-area: name; min-width: 0; } .ax-r-seg { grid-area: seg; justify-self: start; }
.ax-r-tpl { grid-area: tpl; } .ax-r-rm { grid-area: rm; }
.ax-inherited-item b { font-weight: 600; }
.ax-inherited-level { font-size: 11.5px; color: var(--muted); line-height: 1; margin: 0; }
.ax-level {
  border: 1px solid var(--line); background: var(--panel); color: var(--muted);
  font: inherit; font-size: 12px; font-weight: 500; padding: 3px 10px; border-radius: 999px; cursor: pointer;
  display: inline-flex; align-items: center; gap: 5px; transition: all .12s ease;
}
.ax-level::before { content: ""; width: 7px; height: 7px; border-radius: 50%; border: 1.5px solid currentColor; opacity: .7; }
.ax-level.on { background: var(--brand-soft); border-color: transparent; color: var(--brand-strong); font-weight: 600; }
.ax-level.on::before { background: currentColor; opacity: 1; }
.ax-level:hover:not(:disabled) { border-color: var(--brand); }
.ax-level:disabled { cursor: not-allowed; opacity: .45; }
.ax-icon-btn {
  width: 30px; height: 30px; border-radius: 8px; border: 1px solid transparent; background: transparent;
  color: var(--muted); cursor: pointer; display: inline-flex; align-items: center; justify-content: center; font-size: 18px; line-height: 1;
}
.ax-icon-btn:hover { background: rgba(185, 28, 28, 0.08); color: var(--err); }
.ax-add { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 10px; padding: 10px 12px; border: 1px dashed var(--line-strong); border-radius: var(--radius); }
.ax-add select { margin: 0; width: auto; min-width: 180px; height: 34px; padding-top: 0; padding-bottom: 0; }
.ax-add .ax-add-label { font-size: 12.5px; font-weight: 600; color: var(--muted); margin-right: 4px; }

/* effective list */
.ax-eff { display: flex; flex-direction: column; }
.ax-eff-row { display: grid; grid-template-columns: 24px minmax(120px, 1fr) auto minmax(110px, auto); gap: 12px; align-items: center; padding: 9px 4px; border-bottom: 1px solid var(--line); font-size: 13px; }
.ax-eff-row:last-child { border-bottom: 0; }
.ax-eff-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ax-eff-name .muted { font-weight: 400; }
.ax-source { justify-self: end; }

.ax-empty { padding: 48px 24px; text-align: center; color: var(--muted); }
.ax-empty svg { width: 44px; height: 44px; opacity: .45; margin-bottom: 10px; }
.ax-empty b { display: block; color: var(--text); font-size: 15px; margin-bottom: 4px; }

/* sticky save bar */
.ax-savebar {
  position: sticky; bottom: 12px; z-index: 5; margin: 0 12px 12px;
  display: none; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: 10px 12px 10px 16px; border-radius: var(--radius); background: var(--text); color: var(--panel); box-shadow: var(--shadow-lg);
}
.ax-savebar.is-visible { display: flex; }
.ax-savebar span { font-size: 13px; font-weight: 500; display: inline-flex; align-items: center; gap: 8px; }
.ax-savebar span::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: #f59e0b; }
.ax-savebar .btn-soft { background: transparent; color: inherit; border-color: rgba(255,255,255,.25); }
:root[data-theme='dark'] .ax-savebar { background: #e5e9f0; color: #0f172a; }
:root[data-theme='dark'] .ax-savebar .btn-soft { border-color: rgba(15,23,42,.25); }

/* all-folders card */
.ax-group-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 8px; }
.ax-group-card {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px;
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel);
}
.ax-group-card.is-on { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-ring); }
.ax-group-card .ax-group-text { flex: 1 1 auto; min-width: 0; }
.ax-group-card .ax-group-text b { display: block; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ax-group-card .ax-group-text small { color: var(--muted); font-size: 11.5px; }

/* effective access modal */
.ea-modal { width: min(1000px, 96vw); max-height: 92vh; padding: 0; display: flex; flex-direction: column; overflow: hidden; }
.ea-head { display: flex; gap: 14px; align-items: center; padding: 20px 24px 16px; border-bottom: 1px solid var(--line); }
.ea-head .ax-avatar { width: 46px; height: 46px; border-radius: 14px; font-size: 16px; }
.ea-head h3 { margin: 0; font-size: 18px; font-weight: 650; }
.ea-head .ax-head-meta { margin-top: 4px; }
.ea-close { margin-left: auto; }
.ea-body { overflow: auto; padding: 16px 24px 24px; }
.ea-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin-bottom: 14px; }
.ea-stat { padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel-2); }
.ea-stat small { display: block; font-size: 11.5px; color: var(--muted); font-weight: 500; text-transform: uppercase; letter-spacing: .04em; }
.ea-stat b { display: block; font-size: 22px; font-weight: 700; margin-top: 2px; letter-spacing: -0.02em; }
.ea-stat b span { font-size: 13px; font-weight: 500; color: var(--muted); }
.ea-note { display: flex; gap: 8px; align-items: flex-start; padding: 10px 12px; margin-bottom: 8px; border-radius: var(--radius); background: rgba(161, 98, 7, 0.08); color: var(--warn); font-size: 13px; font-weight: 500; }
.ea-tabs { margin: 6px 0 12px; }
.ea-toolbar { display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; margin-bottom: 10px; }
.ea-toolbar input[type='search'] { margin: 0; max-width: 280px; }
.ea-cat td { background: var(--panel-2) !important; font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); padding-top: 8px; padding-bottom: 8px; }
.ea-yes, .ea-no { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 600; }
.ea-yes { color: var(--ok); }
.ea-no { color: var(--muted); opacity: .8; }
.ea-yes::before, .ea-no::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.ea-no::before { background: transparent; border: 1.5px solid currentColor; }
.ea-reason { font-size: 12px; color: var(--muted); }
.ea-reason.is-group { color: var(--err); }
.ea-key { font-family: var(--font-mono); font-size: 11px; color: var(--muted); }
.ea-page-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 8px; }
.ea-page { display: flex; align-items: center; justify-content: space-between; padding: 9px 12px; border: 1px solid var(--line); border-radius: var(--radius); font-size: 13px; }

/* create-user preview */
.ax-preview { margin-top: 8px; padding: 10px 12px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--panel-2); font-size: 12.5px; }
.ax-preview b { font-weight: 600; }
.ax-preview .level-chips { margin-top: 6px; }

@media (max-width: 1100px) {
  .ax-layout { grid-template-columns: 1fr; }
  .ax-tree { position: static; max-height: 340px; }
  .ax-rule { grid-template-columns: 34px minmax(0, 1fr) 30px; grid-template-areas: "av name rm" ". seg seg" ". tpl tpl" ". lv lv"; }
  .ea-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* ── Səhifə bələdçisi ────────────────────────────────────────────────────── */
.guide-card { margin: 0 0 16px; border: 1px solid var(--line); border-radius: var(--radius-lg); background: linear-gradient(135deg, var(--brand-soft), transparent 60%), var(--panel); overflow: hidden; }
.guide-head { display: flex; align-items: center; gap: 10px; width: 100%; padding: 12px 16px; border: 0; background: transparent; color: var(--text); font: inherit; cursor: pointer; text-align: left; }
.guide-ico { width: 24px; height: 24px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; background: var(--brand); color: #fff; font-weight: 700; font-size: 13px; flex: 0 0 auto; }
.guide-title { font-weight: 600; font-size: 14px; flex: 1 1 auto; }
.guide-toggle { font-size: 12.5px; color: var(--brand-strong); font-weight: 600; }
.guide-body { padding: 0 16px 16px 50px; }
.guide-card.is-collapsed .guide-body { display: none; }
.guide-steps { margin: 0; padding-left: 18px; display: grid; gap: 6px; font-size: 13px; color: var(--text); }
.guide-steps li::marker { color: var(--brand); font-weight: 700; }
.guide-steps b { font-weight: 600; }
.guide-steps a { color: var(--brand-strong); font-weight: 600; text-decoration: none; }
.guide-steps a:hover { text-decoration: underline; }
.guide-flow { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 0 0 8px; }
.guide-flow-step { display: inline-flex; flex-direction: column; padding: 6px 12px; border-radius: var(--radius); background: var(--panel); border: 1px solid var(--line); box-shadow: var(--shadow-xs); }
.guide-flow-step b { font-size: 13px; font-weight: 650; }
.guide-flow-step small { font-size: 11.5px; color: var(--muted); }
.guide-flow-arrow { color: var(--muted); font-weight: 700; }
.guide-flow-note { margin: 0 0 10px; font-size: 12.5px; color: var(--muted); }

/* ── Başlanğıc bələdçisi (checklist) ─────────────────────────────────────── */
.setup-card { margin: 0 0 16px; padding: 18px 20px; border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--panel); box-shadow: var(--shadow-xs); }
.setup-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.setup-head .btn { width: auto; flex: 0 0 auto; }
.setup-head h3 { margin: 0; font-size: 16px; font-weight: 650; }
.setup-head p { margin: 2px 0 0; font-size: 12.5px; color: var(--muted); }
.setup-progress { margin: 0 0 14px; height: 6px; border-radius: 999px; background: var(--panel-3); overflow: hidden; }
.setup-progress span { display: block; height: 100%; background: var(--brand); border-radius: inherit; transition: width .3s ease; }
.setup-steps { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 10px; }
.setup-step { position: relative; display: flex; flex-direction: column; gap: 4px; padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel-2); color: inherit; text-decoration: none; transition: border-color .15s ease, box-shadow .15s ease; }
.setup-step:hover { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-ring); }
.setup-step .n { width: 24px; height: 24px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; background: var(--panel); border: 1.5px solid var(--line-strong); color: var(--muted); }
.setup-step.is-done .n { background: var(--ok); border-color: var(--ok); color: #fff; }
.setup-step.is-next { border-color: var(--brand); background: var(--brand-soft); }
.setup-step.is-next .n { border-color: var(--brand); color: var(--brand-strong); }
.setup-step b { font-size: 13.5px; font-weight: 600; }
.setup-step small { font-size: 12px; color: var(--muted); }
.setup-step .cta { margin-top: 4px; font-size: 12px; font-weight: 600; color: var(--brand-strong); }

/* ── Qruplar səhifəsi ────────────────────────────────────────────────────── */
.gp-titlebar { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.gp-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border: 0; border-radius: var(--radius); background: transparent; color: var(--text); font: inherit; text-align: left; cursor: pointer; }
.gp-item:hover { background: var(--panel-3); }
.gp-item.is-selected { background: var(--brand-soft); }
.gp-item.is-selected b { color: var(--brand-strong); }
.gp-item.is-passive .ax-avatar { opacity: .5; }
.gp-item-text { flex: 1 1 auto; min-width: 0; }
.gp-item-text b { display: block; font-size: 13.5px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gp-item-text small { color: var(--muted); font-size: 12px; }
.gp-tabs { margin: 0; }
.gp-row { display: grid; grid-template-columns: 24px minmax(0, 1fr) auto auto; gap: 12px; align-items: center; padding: 9px 4px; border-bottom: 1px solid var(--line); font-size: 13px; }
.gp-row:last-child { border-bottom: 0; }
.gp-frow { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; grid-template-areas: "name src act" "lv lv lv"; gap: 8px 12px; align-items: center; padding: 10px 4px; border-bottom: 1px solid var(--line); font-size: 13px; }
.gp-frow > :nth-child(1) { grid-area: name; min-width: 0; }
.gp-frow > :nth-child(2) { grid-area: lv; padding-left: 22px; }
.gp-frow > :nth-child(3) { grid-area: src; justify-self: end; }
.gp-frow > :nth-child(4) { grid-area: act; }
.gp-frow:last-child { border-bottom: 0; }
.gp-factions { display: flex; gap: 6px; align-items: center; justify-content: flex-end; }
.gp-factions select { margin: 0; width: 200px; max-width: 100%; height: 32px; padding-top: 0; padding-bottom: 0; font-size: 12.5px; }
.gp-wizard { width: min(720px, 96vw); }
.gp-wiz-steps { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.gp-wiz-step { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--muted); padding: 3px 10px 3px 4px; border-radius: 999px; background: var(--panel-3); }
.gp-wiz-step i { font-style: normal; width: 20px; height: 20px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; background: var(--panel); font-size: 11px; font-weight: 700; }
.gp-wiz-step.is-active { background: var(--brand-soft); color: var(--brand-strong); font-weight: 600; }
.gp-wiz-step.is-active i { background: var(--brand); color: #fff; }
.gp-wiz-step.is-done i { background: var(--ok); color: #fff; }
.gp-wiz-foot { display: flex; gap: 8px; padding: 14px 24px; border-top: 1px solid var(--line); background: var(--panel-2); }
.gp-pick { max-height: 320px; overflow: auto; border: 1px solid var(--line); border-radius: var(--radius); padding: 4px; }
.gp-pick-item, .modal-box .gp-pick-item { margin: 0; font-weight: 400; color: var(--text); display: flex; align-items: center; gap: 10px; padding: 7px 8px; border-radius: var(--radius-sm); cursor: pointer; font-size: 13px; }
.gp-pick-item:hover { background: var(--panel-3); }
.gp-pick-item input { flex: 0 0 16px; width: 16px; height: 16px; min-height: 0; margin: 0; padding: 0; accent-color: var(--brand); }
@media (max-width: 1100px) {
  .gp-frow { grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "name src" "lv lv" "act act"; }
  .gp-factions { justify-content: flex-start; padding-left: 22px; }
}

.gp-titlebar h2 { margin-bottom: 2px; }
.gp-titlebar .sub { margin-top: 0; }

/* ── Müasir sol menyu ───────────────────────────────────────────────────── */
.sidebar, .card.sidebar { padding: 16px 12px; gap: 2px; }
.sidebar-header { padding: 0 2px 14px; margin-bottom: 6px; border-bottom: 1px solid var(--line); gap: 10px; }
.sidebar-label { font-size: 11px; letter-spacing: .1em; }
.sidebar-toggle {
  width: 34px; height: 34px; border-radius: 11px;
  background: var(--panel-3); border: 1px solid transparent; color: var(--muted);
  transition: background .18s ease, color .18s ease, box-shadow .18s ease;
}
.sidebar-toggle svg { width: 18px; height: 18px; }
.sidebar-toggle:hover { background: var(--brand-soft); color: var(--brand-strong); border-color: transparent; box-shadow: 0 0 0 3px var(--brand-ring); }

.sidebar .tab-btn, a.btn.tab-btn {
  min-height: 42px; gap: 12px; padding: 9px 12px; margin: 0 0 3px;
  border-radius: 12px; color: var(--muted); font-size: 13.5px; font-weight: 600;
  transition: background .18s ease, color .18s ease, transform .18s ease, box-shadow .18s ease;
}
.sidebar .tab-btn::before { flex: 0 0 20px; width: 20px; height: 20px; opacity: .9; transition: transform .18s ease; }
.sidebar .tab-btn:hover { background: var(--panel-3); color: var(--text); transform: translateX(2px); }
.sidebar .tab-btn:hover::before { transform: scale(1.08); }
.sidebar .tab-btn.active, :root[data-theme='dark'] .tab-btn.active {
  background: linear-gradient(135deg, var(--brand-soft), transparent 140%);
  color: var(--brand-strong); font-weight: 700; transform: none;
  box-shadow: inset 0 0 0 1px var(--brand-ring);
}
.sidebar .tab-btn.active::before { color: var(--brand); }
.sidebar .tab-btn.active::after { left: -12px; top: 10px; bottom: 10px; width: 4px; border-radius: 0 4px 4px 0; }

a[href="guide.html"].tab-btn { --nav-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='9.5'/%3E%3Cpath d='M9.5 9.2a2.6 2.6 0 1 1 3.6 2.4c-.8.4-1.1 1-1.1 1.8'/%3E%3Cpath d='M12 17h.01'/%3E%3C/svg%3E"); }

.sidebar-footer {
  margin-top: auto; padding: 12px 8px; font-size: 11px; font-weight: 600; letter-spacing: .02em;
  border: 0; border-radius: 12px; background: var(--panel-3); color: var(--muted);
}

.layout.sidebar-collapsed .sidebar, .layout.sidebar-collapsed .card.sidebar { padding: 16px 10px; }
.layout.sidebar-collapsed .sidebar-header { border-bottom-color: transparent; }
.layout.sidebar-collapsed .sidebar .tab-btn, .layout.sidebar-collapsed a.btn.tab-btn {
  width: 44px; height: 44px; min-height: 44px; margin: 0 auto 4px; padding: 0; border-radius: 13px;
}
.layout.sidebar-collapsed .sidebar .tab-btn:hover { transform: none; }
.layout.sidebar-collapsed .sidebar .tab-btn.active {
  background: linear-gradient(135deg, var(--brand), var(--brand2)); color: #fff;
  box-shadow: 0 6px 16px -6px var(--brand-ring);
}
.layout.sidebar-collapsed .sidebar .tab-btn.active::before { color: #fff; opacity: 1; }
.layout.sidebar-collapsed .sidebar .tab-btn.active::after { left: -10px; }
.layout.sidebar-collapsed .sidebar-footer { padding: 10px 0; }

.brand-text { font-size: 18px; font-weight: 700; letter-spacing: 0.2px; line-height: 1.2; color: inherit; }
