/* ═══════════════════════════════════════════════════════════
   ORBRT — Component Library
   Reusable UI components
   ═══════════════════════════════════════════════════════════ */

/* ── Page Header ───────────────────────────────────────── */

/* ── Checkbox — dark-themed ─────────────────────────────── */
input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  border: 1px solid var(--border-default);
  border-radius: 3px;
  background: var(--surface-2);
  cursor: pointer;
  position: relative;
  flex-shrink: 0;
  transition: background 0.15s, border-color 0.15s;
}
input[type="checkbox"]:hover {
  border-color: var(--text-tertiary);
  background: var(--surface-3);
}
input[type="checkbox"]:checked {
  background: var(--text-tertiary);
  border-color: var(--text-tertiary);
}
input[type="checkbox"]:checked::after {
  content: '';
  position: absolute;
  left: 4px;
  top: 1px;
  width: 5px;
  height: 9px;
  border: solid var(--surface-1, #111);
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}
input[type="checkbox"]:focus-visible {
  outline: 2px solid var(--accent-muted);
  outline-offset: 1px;
}

.page-header {
  margin-bottom: 24px;
}

.page-header h1 {
  font-size: 20px;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -0.3px;
  margin-bottom: 4px;
}

.page-header .page-subtitle {
  font-size: 13px;
  color: var(--text-secondary);
}

.page-header-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  padding-bottom: 10px;
  padding-top: 10px;
}

.page-header-actions h1 {
  margin-bottom: 0;
}

/* ── Cards ─────────────────────────────────────────────── */
.card {
  background: var(--surface-2);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  overflow: visible;
  margin-bottom: 16px;
}

.card:last-child {
  /* margin-bottom: 0; */
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border-subtle);
}

.card-header h2,
.card-header h3 {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -0.1px;
}

.card-header .card-actions {
  display: flex;
  gap: 6px;
}

.card-body {
  padding: 18px;
}

.card-footer {
  padding: 12px 18px;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* ── Stat Cards ────────────────────────────────────────── */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.dashboard-grid > .stat-card {
  margin-bottom: 0;
}

.stat-card {
  background: var(--surface-2);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  position: relative;
  overflow: visible;
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--accent-dim);
}

.stat-card.ok::before { background: var(--status-ok); }
.stat-card.warn::before { background: var(--status-warn); }
.stat-card.error::before { background: var(--status-error); }
.stat-card.info::before { background: var(--status-info); }

.stat-label {
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-tertiary);
  font-family: var(--font-mono);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stat-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--text-primary);
  font-family: var(--font-mono);
  letter-spacing: -1px;
  line-height: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stat-detail {
  font-size: 12px;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stat-detail .trend-up {
  color: var(--status-ok);
}

.stat-detail .trend-down {
  color: var(--status-error);
}

.stat-color-accent { color: var(--text-accent); }
.stat-color-warn { color: var(--status-warn); }
.stat-color-ok { color: var(--status-ok); }
.stat-color-error { color: var(--status-error); }
.stat-color-info { color: var(--status-info); }

/* ── Tables ────────────────────────────────────────────── */
.data-table-wrapper,
.card-body:has(.data-table) {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.data-table {
  width: 100%;
  min-width: 600px;
  border-collapse: collapse;
  font-size: 13px;
}

.data-table thead th {
  text-align: left;
  padding: 10px 14px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-tertiary);
  font-family: var(--font-mono);
  border-bottom: 1px solid var(--border-default);
  background: var(--surface-2);
  white-space: nowrap;
  position: sticky;
  top: 0;
}

.data-table tbody tr {
  border-bottom: 1px solid var(--border-subtle);
  transition: background var(--transition-fast);
}

.data-table tbody tr:hover {
  background: var(--surface-3);
}

.data-table tbody td {
  padding: 10px 14px;
  color: var(--text-primary);
  vertical-align: middle;
}

.data-table .col-mono {
  font-family: var(--font-mono);
  font-size: 12px;
}

.data-table .col-secondary {
  color: var(--text-secondary);
}

.data-table .col-actions {
  text-align: right;
  white-space: nowrap;
}

/* ── Status Badges ─────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px;
  border-radius: 3px;
  font-size: 11px;
  font-weight: 500;
  font-family: var(--font-mono);
  letter-spacing: 0.3px;
}

.badge-ok {
  background: rgba(61, 220, 132, 0.1);
  color: var(--status-ok);
}

.badge-warn {
  background: rgba(230, 168, 23, 0.1);
  color: var(--status-warn);
}

.badge-error {
  background: rgba(224, 82, 82, 0.1);
  color: var(--status-error);
}

.badge-info {
  background: rgba(74, 158, 222, 0.1);
  color: var(--status-info);
}

.badge-neutral {
  background: rgba(107, 107, 107, 0.15);
  color: var(--text-secondary);
}

.badge-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}

.badge-ok .badge-dot { background: var(--status-ok); }
.badge-warn .badge-dot { background: var(--status-warn); }
.badge-error .badge-dot { background: var(--status-error); }
.badge-info .badge-dot { background: var(--status-info); }

/* ── Buttons ───────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all var(--transition-fast);
  font-family: var(--font-sans);
  white-space: nowrap;
}

.btn svg {
  width: 14px;
  height: 14px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.5;
}

.btn-primary {
  background: var(--accent-dim);
  color: var(--accent-primary);
  border-color: var(--accent-border);
}

.btn-primary:hover {
  background: var(--accent-muted);
  color: var(--surface-0);
}

.btn-secondary {
  background: var(--surface-3);
  color: var(--text-secondary);
  border-color: var(--border-default);
}

.btn-secondary:hover {
  background: var(--surface-4);
  color: var(--text-primary);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
}

.btn-ghost:hover {
  background: var(--surface-3);
  color: var(--text-primary);
}

.btn-danger {
  background: rgba(224, 82, 82, 0.1);
  color: var(--status-error);
  border-color: rgba(224, 82, 82, 0.2);
}

.btn-danger:hover {
  background: rgba(224, 82, 82, 0.2);
}

.btn-sm {
  padding: 4px 10px;
  font-size: 11.5px;
}

.btn-icon {
  width: 28px;
  height: 28px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ── Tabs ──────────────────────────────────────────────── */
.tabs {
  display: flex;
  border-bottom: 1px solid var(--border-default);
  margin-bottom: 20px;
  gap: 0;
}

.tab {
  background: none;
  border: none;
  outline: none;
  font-family: var(--font-sans);
  padding: 10px 16px;
  font-size: 13px;
  color: var(--text-secondary);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all var(--transition-fast);
  white-space: nowrap;
}

.tab:hover {
  color: var(--text-primary);
}

.tab.active {
  color: var(--text-accent);
  border-bottom-color: var(--accent-primary);
}

.tab .tab-count {
  font-size: 11px;
  font-family: var(--font-mono);
  color: var(--text-tertiary);
  margin-left: 6px;
}

/* ── Search & Filter Bar ───────────────────────────────── */
.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.search-input {
  display: flex;
  align-items: center;
  background: var(--surface-2);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  padding: 0 10px;
  flex: 1;
  min-width: 200px;
  max-width: 360px;
  transition: border-color var(--transition-fast);
}

.search-input:focus-within {
  border-color: var(--accent-muted);
}

.search-input svg {
  width: 15px;
  height: 15px;
  stroke: var(--text-tertiary);
  fill: none;
  stroke-width: 1.5;
  flex-shrink: 0;
}

.search-input input {
  background: none;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-size: 12.5px;
  padding: 7px 8px;
  width: 100%;
  font-family: var(--font-sans);
}

.search-input input::placeholder {
  color: var(--text-tertiary);
}

.filter-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 7px 12px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  color: var(--text-secondary);
  background: var(--surface-2);
  border: 1px solid var(--border-default);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.filter-btn:hover {
  border-color: var(--border-strong);
  color: var(--text-primary);
}

.filter-btn svg {
  width: 13px;
  height: 13px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.5;
}

/* ── Progress Bars ─────────────────────────────────────── */
.progress-bar {
  height: 4px;
  background: var(--surface-4);
  border-radius: 2px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  border-radius: 2px;
  background: var(--accent-muted);
  transition: width 0.8s ease-out;
}

.progress-fill.warn { background: var(--status-warn); }
.progress-fill.error { background: var(--status-error); }
.progress-fill.ok { background: var(--status-ok); }

/* ── Grid Layouts ──────────────────────────────────────── */
.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}
.grid-2 > .card {
  display: flex;
  flex-direction: column;
  margin-bottom: 0;
}
.grid-2 > .card > .card-body {
  flex: 1;
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}
.grid-3 > .card {
  display: flex;
  flex-direction: column;
  margin-bottom: 0;
}
.grid-3 > .card > .card-body {
  flex: 1;
}

.grid-auto {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 16px;
}
.grid-auto > .card {
  display: flex;
  flex-direction: column;
  margin-bottom: 0;
}
.grid-auto > .card > .card-body {
  flex: 1;
}

@media (max-width: 900px) {
  .grid-2, .grid-3 {
    grid-template-columns: 1fr;
  }
}

/* ── Log / Activity Stream ─────────────────────────────── */
.activity-list {
  display: flex;
  flex-direction: column;
}

.activity-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border-subtle);
}

.activity-item:last-child {
  border-bottom: none;
}

.activity-icon {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 12px;
}

.activity-icon.ok {
  background: rgba(61, 220, 132, 0.1);
  color: var(--status-ok);
}

.activity-icon.warn {
  background: rgba(230, 168, 23, 0.1);
  color: var(--status-warn);
}

.activity-icon.error {
  background: rgba(224, 82, 82, 0.1);
  color: var(--status-error);
}

.activity-icon.info {
  background: rgba(74, 158, 222, 0.1);
  color: var(--status-info);
}

.activity-body {
  flex: 1;
  min-width: 0;
}

.activity-body .activity-text {
  font-size: 12.5px;
  color: var(--text-primary);
  line-height: 1.4;
}

.activity-body .activity-time {
  font-size: 11px;
  color: var(--text-tertiary);
  font-family: var(--font-mono);
  margin-top: 2px;
}

/* ── Gauge / Ring Charts (CSS only) ────────────────────── */
.gauge {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.gauge-inner {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: var(--surface-2);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
}

.gauge-value {
  font-size: 16px;
  font-weight: 700;
  font-family: var(--font-mono);
  color: var(--text-primary);
  line-height: 1;
}

.gauge-label {
  font-size: 9px;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* ── Chips / Tags ──────────────────────────────────────── */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 3px;
  font-size: 11px;
  font-family: var(--font-mono);
  background: var(--surface-3);
  color: var(--text-secondary);
  border: 1px solid var(--border-default);
}

.chip-green {
  background: var(--accent-subtle);
  color: var(--accent-primary);
  border-color: var(--accent-border);
}

.chip-info {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-tertiary);
  border-color: var(--border-subtle);
  font-family: var(--font-sans, inherit);
  font-size: 9px;
  letter-spacing: 0.02em;
}

/* ── Empty States ──────────────────────────────────────── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 24px;
  text-align: center;
}

.empty-state svg {
  width: 48px;
  height: 48px;
  stroke: var(--text-tertiary);
  fill: none;
  stroke-width: 1;
  margin-bottom: 16px;
  opacity: 0.5;
}

.empty-state h3 {
  font-size: 15px;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.empty-state p {
  font-size: 12.5px;
  color: var(--text-tertiary);
  max-width: 320px;
}

/* ── Toggle Switch ─────────────────────────────────────── */
.toggle {
  width: 36px;
  height: 20px;
  border-radius: 10px;
  background: var(--surface-4);
  cursor: pointer;
  position: relative;
  transition: background var(--transition-fast);
}

.toggle.on {
  background: var(--accent-dim);
}

.toggle::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--text-secondary);
  transition: all var(--transition-fast);
}

.toggle.on::after {
  left: 18px;
  background: var(--accent-primary);
}

/* Checkbox-based toggle (label > input + slider) */
label.toggle {
  display: inline-flex;
  align-items: center;
  width: auto;
  height: auto;
  background: none;
  border-radius: 0;
  position: static;
  cursor: pointer;
}

label.toggle::after {
  content: none;
}

label.toggle input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  width: 36px;
  height: 20px;
  border-radius: 10px;
  background: var(--surface-4);
  cursor: pointer;
  position: relative;
  transition: background var(--transition-fast);
  display: inline-block;
  flex-shrink: 0;
}

.toggle-slider::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--text-secondary);
  transition: all var(--transition-fast);
}

label.toggle input:checked + .toggle-slider {
  background: var(--accent-dim);
}

label.toggle input:checked + .toggle-slider::after {
  left: 18px;
  background: var(--accent-primary);
}

/* ── Inline KV pairs ──────────────────────────────────── */
.kv-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.kv-item {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 13px;
}

.kv-item .kv-key {
  color: var(--text-tertiary);
  min-width: 120px;
  font-size: 12px;
}

.kv-item .kv-value {
  color: var(--text-primary);
}

.kv-item .kv-value.mono {
  font-family: var(--font-mono);
  font-size: 12px;
}

/* ── Donut Chart (pure CSS) ────────────────────────────── */
.donut-chart {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.donut-hole {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: var(--surface-2);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  z-index: 1;
}

.donut-value {
  font-size: 22px;
  font-weight: 700;
  font-family: var(--font-mono);
  color: var(--text-primary);
  line-height: 1;
}

.donut-label {
  font-size: 9px;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-top: 2px;
}

/* ── Section Divider ───────────────────────────────────── */
.section-divider {
  height: 1px;
  background: var(--border-default);
  margin: 24px 0;
}

/* ── Mini sparkline bars ───────────────────────────────── */
.sparkline {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  height: 24px;
}

.sparkline-bar {
  width: 4px;
  border-radius: 1px;
  background: var(--accent-dim);
  transition: height var(--transition-base);
}

/* ── Tooltip ───────────────────────────────────────────── */
[data-tooltip] {
  position: relative;
}

[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  padding: 4px 8px;
  background: var(--surface-5);
  color: var(--text-primary);
  font-size: 11px;
  border-radius: var(--radius-sm);
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-fast);
  z-index: 1000;
}

[data-tooltip]:hover::after {
  opacity: 1;
}

/* ═══════════════════════════════════════════════════════════
   Alpine.js — Dropdowns, Modals, Tenant Switcher
   ═══════════════════════════════════════════════════════════ */

/* ── Dropdown Menu ─────────────────────────────────────── */
.dropdown-menu {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  min-width: 220px;
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  box-shadow: 0 8px 24px rgba(0,0,0,0.4), 0 2px 8px rgba(0,0,0,0.2);
  z-index: 500;
  padding: 4px;
  overflow: hidden;
}

.dropdown-header {
  padding: 8px 12px 6px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-tertiary);
  font-family: var(--font-mono);
  display: flex;
  align-items: center;
  gap: 6px;
}

.dropdown-header-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
}

.dropdown-divider {
  height: 1px;
  background: var(--border-default);
  margin: 4px 0;
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
  background: none;
  border: none;
  width: 100%;
  text-align: left;
  font-family: var(--font-sans);
}

.dropdown-item:hover {
  background: var(--surface-3);
  color: var(--text-primary);
}

.dropdown-item.active {
  background: var(--accent-subtle);
  color: var(--text-accent);
}

.dropdown-item-icon {
  width: 16px;
  height: 16px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex-shrink: 0;
}

.dropdown-item-content {
  flex: 1;
  min-width: 0;
}

.dropdown-item-label {
  font-size: 13px;
  display: block;
}

.dropdown-item-desc {
  font-size: 11px;
  color: var(--text-tertiary);
  font-family: var(--font-mono);
  display: block;
  margin-top: 1px;
}

.dropdown-item-danger {
  color: var(--status-error);
}

.dropdown-item-danger:hover {
  background: rgba(224, 82, 82, 0.1);
  color: var(--status-error);
}

.dropdown-check {
  width: 16px;
  height: 16px;
  stroke: var(--accent-primary);
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex-shrink: 0;
}

/* ── Tenant Switcher ───────────────────────────────────── */
.tenant-switcher {
  position: relative;
}

.tenant-trigger {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  background: var(--surface-2);
  border: 1px solid var(--border-default);
  transition: all var(--transition-fast);
}

.tenant-trigger:hover {
  border-color: var(--border-strong);
  background: var(--surface-3);
}

.tenant-indicator {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--status-ok);
  flex-shrink: 0;
}

.tenant-info {
  text-align: left;
}

.tenant-name {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-primary);
  font-family: var(--font-mono);
  line-height: 1.2;
}

.tenant-label {
  display: block;
  font-size: 9px;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.tenant-chevron {
  width: 14px;
  height: 14px;
  stroke: var(--text-tertiary);
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: transform var(--transition-fast);
  flex-shrink: 0;
}

.tenant-chevron.rotated {
  transform: rotate(180deg);
}

.user-chevron {
  width: 12px;
  height: 12px;
  stroke: var(--text-tertiary);
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: transform var(--transition-fast);
  flex-shrink: 0;
}

.user-chevron.rotated {
  transform: rotate(180deg);
}

.tenant-menu {
  min-width: 260px;
}

.tenant-option-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.tenant-option-dot.ok { background: var(--status-ok); }
.tenant-option-dot.warn { background: var(--status-warn); }
.tenant-option-dot.info { background: var(--status-info); }
.tenant-option-dot.neutral { background: var(--status-neutral); }

/* ── Notification Dropdown ─────────────────────────────── */
.noti-menu {
  min-width: 340px;
  max-height: 420px;
  overflow-y: auto;
}

@media (max-width: 768px) {
  .dropdown-menu.noti-menu {
    position: fixed;
    top: 48px;
    left: 8px;
    right: 8px;
    min-width: 0;
    width: auto;
    max-height: 70vh;
  }
}

.noti-count {
  background: var(--status-error);
  color: var(--surface-0);
  font-size: 10px;
  padding: 0 5px;
  border-radius: 8px;
  min-width: 16px;
  text-align: center;
  font-weight: 700;
}

.noti-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 8px 12px;
  transition: background var(--transition-fast);
  cursor: pointer;
}

.noti-item + .noti-item {
  margin-top: 6px;
  padding-top: 10px;
  border-top: 1px solid var(--border-default);
  border-radius: 0;
}

.noti-item:hover {
  background: var(--surface-3);
}

.noti-item.ack {
  border-left: 2px solid var(--accent-primary);
}
.noti-item.unread-error {
  border-left: 2px solid var(--status-error);
}
.noti-item.unread-warn {
  border-left: 2px solid var(--status-warn);
}
.noti-item.unread-info {
  border-left: 2px solid var(--status-info);
}

.noti-icon {
  width: 24px;
  height: 24px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 11px;
  font-weight: 700;
}

.noti-icon.ok { background: rgba(61, 220, 132, 0.1); color: var(--status-ok); }
.noti-icon.warn { background: rgba(230, 168, 23, 0.1); color: var(--status-warn); }
.noti-icon.error { background: rgba(224, 82, 82, 0.1); color: var(--status-error); }
.noti-icon.info { background: rgba(74, 158, 222, 0.1); color: var(--status-info); }

.noti-body { flex: 1; min-width: 0; }
.noti-text { font-size: 12.5px; color: var(--text-primary); line-height: 1.4; }
.noti-time { font-size: 11px; color: var(--text-tertiary); font-family: var(--font-mono); margin-top: 2px; }

/* ── User Dropdown ─────────────────────────────────────── */
.user-menu {
  min-width: 220px;
}

/* ── Modal ─────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 10vh;
  z-index: 1000;
  /* CSS-driven enter/leave — no Alpine x-transition needed */
  animation: modal-fade-in 0.15s ease-out;
}

@keyframes modal-fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.modal-overlay .modal {
  animation: modal-scale-in 0.15s ease-out;
}

@keyframes modal-scale-in {
  from { opacity: 0; transform: scale(0.96) translateY(-8px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

.modal {
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  box-shadow: 0 16px 48px rgba(0,0,0,0.5), 0 4px 16px rgba(0,0,0,0.3);
  width: 100%;
  max-width: 520px;
  max-height: 80vh;
  overflow-y: auto;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-default);
}

.modal-header h2 {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
}

.modal-close {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  color: var(--text-tertiary);
  cursor: pointer;
  transition: all var(--transition-fast);
  background: none;
  border: none;
}

.modal-close:hover {
  color: var(--text-primary);
  background: var(--surface-4);
}

.modal-close svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.modal-body {
  padding: 20px;
}

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  padding: 14px 20px;
  border-top: 1px solid var(--border-default);
}

/* Modal form elements */

/* ── Table Actions & Action Menu ───────────────────────── */
.table-actions {
  position: relative;
  display: inline-flex;
}

.action-menu {
  position: absolute;
  top: 100%;
  right: 0;
  z-index: 200;
  min-width: 180px;
  padding: 4px 0;
  background: var(--surface-3);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  box-shadow: 0 8px 24px rgba(0,0,0,0.4), 0 2px 8px rgba(0,0,0,0.2);
  margin-top: 4px;
}

.action-menu button {
  display: block;
  width: 100%;
  padding: 7px 14px;
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 12px;
  text-align: left;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.action-menu button:hover {
  background: var(--surface-4);
  color: var(--text-primary);
}

.action-menu button.danger {
  color: var(--status-error);
}

.action-menu button.danger:hover {
  background: rgba(239,68,68,0.08);
  color: var(--status-error);
}

/* Modal form elements */
.form-group {
  margin-bottom: 16px;
}

.form-group:last-child {
  margin-bottom: 0;
}

.form-label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 6px;
  letter-spacing: 0.2px;
}

.form-label .required {
  color: var(--status-error);
  margin-left: 2px;
}

.form-input-full {
  background: var(--surface-3);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 13px;
  padding: 8px 12px;
  font-family: var(--font-sans);
  outline: none;
  transition: border-color var(--transition-fast);
  width: 100%;
}

.form-input-full:focus {
  border-color: var(--accent-muted);
}

.form-input-full.mono {
  font-family: var(--font-mono);
  font-size: 12px;
}

textarea.form-input-full {
  resize: vertical;
  min-height: 72px;
  line-height: 1.5;
}

.form-select,
.form-select-full {
  background: var(--surface-3);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 13px;
  padding: 8px 12px;
  font-family: var(--font-sans);
  outline: none;
  cursor: pointer;
  appearance: none;
  padding-right: 32px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23666' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  transition: border-color var(--transition-fast);
}

.form-select-full {
  width: 100%;
}

.form-select:focus,
.form-select-full:focus {
  border-color: var(--accent-muted);
}

.form-hint {
  font-size: 11px;
  color: var(--text-tertiary);
  margin-top: 4px;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

/* ── Search Modal ──────────────────────────────────────── */
.modal-search {
  max-width: 580px;
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.search-modal-input {
  display: flex;
  align-items: center;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border-default);
  gap: 10px;
}

.search-modal-input svg {
  width: 20px;
  height: 20px;
  stroke: var(--text-tertiary);
  fill: none;
  stroke-width: 1.5;
  flex-shrink: 0;
}

.search-modal-input input {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  font-size: 15px;
  color: var(--text-primary);
  font-family: var(--font-sans);
}

.search-modal-input input::placeholder {
  color: var(--text-tertiary);
}

.kbd {
  font-size: 10px;
  font-family: var(--font-mono);
  padding: 2px 6px;
  border-radius: 3px;
  background: var(--surface-4);
  color: var(--text-tertiary);
  border: 1px solid var(--border-default);
}

.search-modal-body {
  padding: 8px;
  max-height: 340px;
  overflow-y: auto;
}

.search-section-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-tertiary);
  font-family: var(--font-mono);
  padding: 8px 12px 4px;
}

.search-result-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.search-result-item:hover,
.search-result-item.selected {
  background: var(--surface-3);
  color: var(--text-primary);
}

.search-result-item svg {
  width: 16px;
  height: 16px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.5;
  flex-shrink: 0;
}

.search-result-path {
  margin-left: auto;
  font-size: 11px;
  color: var(--text-tertiary);
  font-family: var(--font-mono);
}

/* ── Context Menu (row actions) ────────────────────────── */
.row-actions {
  position: relative;
}

.row-actions .dropdown-menu {
  position: fixed;
  min-width: 180px;
  z-index: 600;
}

/* ── Confirmation Modal ────────────────────────────────── */
.modal-confirm {
  max-width: 420px;
}

.confirm-icon {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 16px;
}

.confirm-icon.warn {
  background: rgba(230, 168, 23, 0.1);
}

.confirm-icon.danger {
  background: rgba(224, 82, 82, 0.1);
}

.confirm-icon svg {
  width: 24px;
  height: 24px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.5;
}

.confirm-icon.warn svg { color: var(--status-warn); }
.confirm-icon.danger svg { color: var(--status-error); }

.confirm-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  text-align: center;
  margin-bottom: 8px;
}

.confirm-message {
  font-size: 13px;
  color: var(--text-secondary);
  text-align: center;
  line-height: 1.5;
  margin-bottom: 4px;
}

/* ── Sidebar Collapse Button ───────────────────────────── */
.sidebar-collapse-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 6px;
  background: none;
  border: none;
  color: var(--text-tertiary);
  cursor: pointer;
  transition: all var(--transition-fast);
  border-radius: var(--radius-sm);
  margin-bottom: 4px;
}

.sidebar-collapse-btn:hover {
  color: var(--text-primary);
  background: var(--surface-3);
}

.sidebar-collapse-btn svg {
  width: 16px;
  height: 16px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: transform var(--transition-base);
}

/* ── User Modal ────────────────────────────────────────── */
.modal-user {
  max-width: 420px;
}

.user-modal-section {
  padding: 8px 0;
  border-bottom: 1px solid var(--border-subtle);
}

.user-modal-section:last-child {
  border-bottom: none;
}

.user-modal-section-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-tertiary);
  font-family: var(--font-mono);
  padding: 6px 24px 4px;
}

.user-modal-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 24px;
  width: 100%;
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
  text-align: left;
  font-family: var(--font-sans);
}

.user-modal-item:hover {
  background: var(--surface-3);
  color: var(--text-primary);
}

.user-modal-item > svg:first-child {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex-shrink: 0;
  opacity: 0.6;
}

.user-modal-item:hover > svg:first-child {
  opacity: 1;
}

.user-modal-item-content {
  flex: 1;
  min-width: 0;
}

.user-modal-item-label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
}

.user-modal-item-desc {
  display: block;
  font-size: 11px;
  color: var(--text-tertiary);
  margin-top: 1px;
}

.user-modal-arrow {
  width: 14px;
  height: 14px;
  stroke: var(--text-tertiary);
  fill: none;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex-shrink: 0;
  opacity: 0;
  transition: opacity var(--transition-fast);
}

.user-modal-item:hover .user-modal-arrow {
  opacity: 1;
}

/* ── Feature Gate Banner ────────────────────────────────── */
.feature-gate-banner {
  padding: 16px 20px;
  border-radius: var(--radius-md);
  font-size: 13px;
  margin-bottom: 16px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
}
.feature-gate-banner.pro {
  background: rgba(255, 200, 50, 0.06);
  border: 1px solid rgba(255, 200, 50, 0.15);
  color: var(--text-secondary);
}
.feature-gate-banner.enterprise {
  background: rgba(160, 120, 255, 0.06);
  border: 1px solid rgba(160, 120, 255, 0.15);
  color: var(--text-secondary);
}

/* ── Sidebar Tier Badge ─────────────────────────────────── */
.nav-tier-badge {
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.5px;
  padding: 1px 5px;
  border-radius: 3px;
  margin-left: auto;
  flex-shrink: 0;
  text-transform: uppercase;
}
.nav-tier-badge.pro {
  background: rgba(255, 200, 50, 0.12);
  color: rgba(255, 200, 50, 0.7);
}
.nav-tier-badge.enterprise {
  background: rgba(160, 120, 255, 0.12);
  color: rgba(160, 120, 255, 0.7);
}

/* RBAC disabled state */
.btn.rbac-disabled {
  opacity: 0.45;
  cursor: not-allowed;
  pointer-events: none;
}

/* Feature override banner */
.feature-gate-banner.override {
  background: rgba(100, 160, 255, 0.06);
  border: 1px solid rgba(100, 160, 255, 0.15);
  color: var(--text-secondary);
}
