/* =========================================================================
   UI Components
   ========================================================================= */

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: 8px var(--space-4);
  height: 38px;
  border-radius: var(--radius-md);
  font-size: var(--fs-label-md);
  font-weight: var(--fw-semibold);
  color: var(--text-primary);
  background: var(--surface-2);
  border: 1px solid var(--border);
  transition: background var(--dur-fast), border-color var(--dur-fast), transform var(--dur-fast), box-shadow var(--dur-fast);
  white-space: nowrap;
}
.btn:hover { background: var(--surface-3); border-color: var(--border-strong); }
.btn:active { transform: scale(0.98); }

.btn--primary {
  background: var(--accent);
  color: var(--text-on-accent);
  border-color: transparent;
  box-shadow: var(--shadow-sm);
}
.btn--primary:hover { background: var(--accent-hover); }
[data-theme="dark"] .btn--primary { box-shadow: var(--glow-primary); }

.btn--ghost {
  background: transparent;
  border-color: transparent;
  color: var(--text-secondary);
}
.btn--ghost:hover { background: var(--accent-soft); color: var(--text-primary); }

.btn--danger {
  background: var(--status-error);
  color: #fff;
  border-color: transparent;
}
[data-theme="dark"] .btn--danger { background: var(--status-error-bg); color: var(--status-error-fg); }

.btn--sm { height: 32px; padding: 6px var(--space-3); font-size: var(--fs-label-sm); }
.btn--lg { height: 44px; padding: 10px var(--space-5); font-size: var(--fs-body-md); }
.btn--icon { padding: 0; width: 38px; }
.btn--block { width: 100%; }

/* ---------- Card ---------- */
.card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  transition: background var(--dur-fast), border-color var(--dur-fast), box-shadow var(--dur-fast);
}
.card--interactive:hover {
  background: var(--card-hover-bg);
  box-shadow: var(--shadow-md);
}
[data-theme="dark"] .card { background: linear-gradient(135deg, rgba(39, 54, 71, 0.30), rgba(18, 33, 49, 0.85)); }
[data-theme="dark"] .card--glass {
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  border-inline-start: 1px solid rgba(255, 255, 255, 0.06);
}

.card__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-3);
}
.card__title {
  font-size: var(--fs-headline-sm);
  font-weight: var(--fw-semibold);
  color: var(--text-primary);
  margin: 0;
}
.card__subtitle { font-size: var(--fs-body-md); color: var(--text-secondary); }
.card__body { display: flex; flex-direction: column; gap: var(--space-3); }

/* ---------- KPI Bento grid ---------- */
.kpi-bento {
  display: grid;
  gap: var(--space-4);
  grid-template-columns: repeat(12, 1fr);
}
.kpi-bento .kpi { grid-column: span 3; }
.kpi-bento .kpi--hero {
  grid-column: span 6;
  grid-row: span 2;
}
.kpi-bento .kpi--hero .kpi__value { font-size: 64px; }
.kpi-bento .kpi--hero .kpi__sparkline { height: 80px; }
.kpi-bento .kpi--primary {
  background: linear-gradient(135deg, var(--accent-soft) 0%, var(--card-bg) 60%);
  border-color: var(--accent);
}
[data-theme="dark"] .kpi-bento .kpi--primary {
  background: linear-gradient(135deg, rgba(210, 187, 255, 0.10), rgba(18, 33, 49, 0.85));
  border-color: rgba(210, 187, 255, 0.32);
}
.kpi__value--pulse {
  animation: pulse 2.2s ease-in-out infinite;
}
@media (max-width: 1280px) {
  .kpi-bento { grid-template-columns: repeat(6, 1fr); }
  .kpi-bento .kpi { grid-column: span 2; }
  .kpi-bento .kpi--hero { grid-column: span 4; grid-row: span 2; }
}
@media (max-width: 768px) {
  .kpi-bento { grid-template-columns: repeat(2, 1fr); }
  .kpi-bento .kpi, .kpi-bento .kpi--hero { grid-column: span 1; grid-row: auto; }
}

/* ---------- KPI Card ---------- */
.kpi {
  position: relative;
  padding: var(--space-5);
  border-radius: var(--radius-lg);
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  overflow: hidden;
  transition: background var(--dur-fast), box-shadow var(--dur-fast);
}
.kpi::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at top right, var(--accent-soft) 0%, transparent 60%);
  pointer-events: none;
  opacity: 0.6;
}
.kpi:hover { background: var(--card-hover-bg); }
[data-theme="dark"] .kpi { background: linear-gradient(135deg, rgba(39, 54, 71, 0.30), rgba(18, 33, 49, 0.85)); }

.kpi__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: var(--fs-label-md);
  font-weight: var(--fw-semibold);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
  position: relative;
}
.kpi__icon { color: var(--accent); }
.kpi__value {
  position: relative;
  font-size: var(--fs-display-lg);
  font-weight: var(--fw-bold);
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
  color: var(--text-primary);
}
.kpi__delta {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  font-size: var(--fs-label-md);
  font-weight: var(--fw-medium);
}
.kpi__delta--up   { color: var(--status-success-fg); }
.kpi__delta--down { color: var(--status-error-fg); }
.kpi__sparkline { position: relative; height: 32px; margin-top: var(--space-2); }
.kpi__caption { position: relative; font-size: var(--fs-label-sm); color: var(--text-muted); }

/* ---------- KPI semantic tones (threshold-driven) ---------- */
.kpi--tone-success {
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.16) 0%, var(--card-bg) 70%);
  border-color: rgba(16, 185, 129, 0.55);
  border-inline-start: 3px solid var(--status-success);
}
[data-theme="dark"] .kpi--tone-success {
  background: linear-gradient(135deg, rgba(52, 211, 153, 0.20) 0%, rgba(13, 28, 45, 0.95) 70%);
  border-color: rgba(52, 211, 153, 0.45);
  border-inline-start: 3px solid var(--status-success);
}
.kpi--tone-success .kpi__value { color: var(--status-success-fg); }
.kpi--tone-success .kpi__icon  { color: var(--status-success-fg); }
.kpi--tone-success::before {
  background: radial-gradient(circle at top right, rgba(16, 185, 129, 0.22) 0%, transparent 65%);
}

.kpi--tone-warning {
  background: linear-gradient(135deg, rgba(188, 72, 0, 0.18) 0%, var(--card-bg) 70%);
  border-color: rgba(188, 72, 0, 0.55);
  border-inline-start: 3px solid var(--status-warning);
}
[data-theme="dark"] .kpi--tone-warning {
  background: linear-gradient(135deg, rgba(251, 191, 36, 0.22) 0%, rgba(13, 28, 45, 0.95) 70%);
  border-color: rgba(251, 191, 36, 0.50);
  border-inline-start: 3px solid var(--status-warning);
}
.kpi--tone-warning .kpi__value { color: var(--status-warning-fg); }
.kpi--tone-warning .kpi__icon  { color: var(--status-warning-fg); }
/* Dashboard SOC cards also use this tone via .dash-card */
.dash-card.kpi--tone-warning .dash-card__big-value .text-mono,
.dash-card.kpi--tone-warning .dash-card__icon .icon {
  color: var(--status-warning-fg);
}
.dash-card.kpi--tone-warning .dash-card__title-en,
.dash-card.kpi--tone-warning .dash-card__title-ar {
  color: var(--status-warning-fg);
}
.kpi--tone-warning::before {
  background: radial-gradient(circle at top right, rgba(188, 72, 0, 0.22) 0%, transparent 65%);
}

.kpi--tone-error {
  background: linear-gradient(135deg, rgba(186, 26, 26, 0.18) 0%, var(--card-bg) 70%);
  border-color: rgba(186, 26, 26, 0.60);
  border-inline-start: 3px solid var(--status-error);
  animation: kpi-error-pulse 2.2s ease-in-out infinite;
}
[data-theme="dark"] .kpi--tone-error {
  background: linear-gradient(135deg, rgba(255, 180, 171, 0.22) 0%, rgba(13, 28, 45, 0.95) 70%);
  border-color: rgba(255, 180, 171, 0.55);
  border-inline-start: 3px solid var(--status-error);
}
.kpi--tone-error .kpi__value { color: var(--status-error-fg); }
.kpi--tone-error .kpi__icon  { color: var(--status-error-fg); }
/* Dashboard SOC cards also use this tone via .dash-card */
.dash-card.kpi--tone-error .dash-card__big-value .text-mono,
.dash-card.kpi--tone-error .dash-card__icon .icon {
  color: var(--status-error-fg);
}
.dash-card.kpi--tone-error .dash-card__title-en,
.dash-card.kpi--tone-error .dash-card__title-ar {
  color: var(--status-error-fg);
}
.kpi--tone-error::before {
  background: radial-gradient(circle at top right, rgba(186, 26, 26, 0.22) 0%, transparent 65%);
}
@keyframes kpi-error-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(186, 26, 26, 0); }
  50%      { box-shadow: 0 0 0 6px rgba(186, 26, 26, 0.20); }
}

.kpi--tone-info {
  border-color: rgba(37, 99, 235, 0.32);
}
.kpi--tone-info .kpi__value { color: var(--status-info-fg); }

@media (prefers-reduced-motion: reduce) {
  .kpi--tone-error { animation: none !important; }
}

/* ---------- Status Badge ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  font-size: var(--fs-label-sm);
  font-weight: var(--fw-semibold);
  background: var(--status-neutral-bg);
  color: var(--status-neutral-fg);
  white-space: nowrap;
}
.badge__dot {
  width: 8px;
  height: 8px;
  border-radius: var(--radius-full);
  background: currentColor;
  flex: 0 0 auto;
}
.badge--success { background: var(--status-success-bg); color: var(--status-success-fg); }
.badge--warning { background: var(--status-warning-bg); color: var(--status-warning-fg); }
.badge--error   { background: var(--status-error-bg);   color: var(--status-error-fg); }
.badge--info    { background: var(--status-info-bg);    color: var(--status-info-fg); }
.badge--accent  { background: var(--accent-soft); color: var(--accent); }
.badge--solid   { background: var(--accent); color: var(--text-on-accent); }

/* ---------- Tabs ---------- */
.tabs {
  display: flex;
  gap: var(--space-1);
  border-block-end: 1px solid var(--border);
  margin-block-end: var(--space-4);
}
.tab {
  position: relative;
  padding: 10px var(--space-4);
  font-size: var(--fs-label-md);
  font-weight: var(--fw-medium);
  color: var(--text-secondary);
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  transition: color var(--dur-fast), background var(--dur-fast);
}
.tab:hover { color: var(--text-primary); background: var(--surface-2); }
.tab.is-active { color: var(--accent); font-weight: var(--fw-semibold); }
.tab.is-active::after {
  content: "";
  position: absolute;
  inset-inline: var(--space-4);
  bottom: -1px;
  height: 2px;
  background: var(--accent);
  border-radius: var(--radius-full);
}

/* ---------- Data Table ---------- */
.table-wrapper {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  overflow-x: auto;
  background: var(--card-bg);
}
.table {
  width: max-content;
  min-width: 100%;
  border-collapse: collapse;
  font-size: var(--fs-body-md);
}
.table thead th,
.table tbody td.text-mono,
.table tbody td .text-mono,
.table tbody td .badge,
.table__row-actions { white-space: nowrap; }
.table tbody td { vertical-align: middle; max-width: 280px; }
.table tbody tr { height: 52px; }
[data-theme="light"] .table tbody tr:nth-child(even) { background: rgba(234, 237, 255, 0.35); }
[data-theme="dark"]  .table tbody tr:nth-child(even) { background: rgba(255, 255, 255, 0.02); }
.table tbody tr:hover { background: var(--accent-soft) !important; }
.table thead th {
  position: sticky;
  top: 0;
  background: var(--surface-2);
  color: var(--text-muted);
  text-align: start;
  font-size: var(--fs-label-sm);
  font-weight: var(--fw-semibold);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 10px var(--space-4);
  border-block-end: 1px solid var(--border);
  white-space: nowrap;
}
[data-theme="dark"] .table thead th { background: var(--surface-3); }
.table tbody td {
  padding: 12px var(--space-4);
  border-block-end: 1px solid var(--divider);
  color: var(--text-primary);
  vertical-align: middle;
}
.table tbody tr:last-child td { border-block-end: 0; }
.table tbody tr:hover { background: var(--surface-2); }
.table__row-actions { display: flex; gap: var(--space-1); justify-content: flex-end; }

/* --- Compact composite table cells --- */
.cell-stacked {
  display: flex; flex-direction: column;
  gap: 2px;
  line-height: 1.3;
}
.cell-stacked__primary {
  font-weight: var(--fw-medium);
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cell-stacked__sub {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cell-device {
  display: inline-flex; align-items: center; gap: 8px;
}
.cell-device__dot {
  width: 8px; height: 8px;
  border-radius: 999px;
  flex-shrink: 0;
  box-shadow: 0 0 0 3px color-mix(in oklab, currentColor 8%, transparent);
}
.cell-device__name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cell-apps {
  display: inline-flex; align-items: center; gap: 4px;
}
.cell-apps__pill {
  display: inline-flex; align-items: center; justify-content: center;
  width: 26px; height: 26px;
  border-radius: 8px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-muted);
  opacity: 0.55;
  transition: all var(--dur-fast) var(--ease-out);
}
.cell-apps__pill .icon {
  font-size: 14px !important;
}
.cell-apps__pill.is-on {
  opacity: 1;
  background: color-mix(in oklab, var(--status-success) 16%, transparent);
  border-color: color-mix(in oklab, var(--status-success) 35%, var(--border));
  color: var(--status-success);
}

/* Slightly tighter padding for high-column tables */
.table--compact tbody td { padding: 10px var(--space-3); }
.table--compact thead th { padding: 8px var(--space-3); }

/* Empty / loading / error states inside table */
.table-empty {
  padding: var(--space-9) var(--space-6);
  text-align: center;
  color: var(--text-muted);
}

/* ---------- Filters bar ---------- */
.filters {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-wrap: wrap;
  padding: var(--space-3) var(--space-4);
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
}
.filters__search {
  position: relative;
  flex: 1;
  min-width: 240px;
}
.filters__chip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: 6px 10px;
  border-radius: var(--radius-full);
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-size: var(--fs-label-md);
  font-weight: var(--fw-medium);
  color: var(--text-secondary);
  transition: background var(--dur-fast);
}
.filters__chip:hover { background: var(--surface-3); color: var(--text-primary); }
.filters__chip.is-active { background: var(--accent-soft); color: var(--accent); border-color: transparent; }

/* ---------- Field ---------- */
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.field__label {
  font-size: var(--fs-label-md);
  font-weight: var(--fw-medium);
  color: var(--text-secondary);
}
.field__control {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  height: 40px;
  padding: 0 var(--space-3);
  background: var(--field-bg);
  border: 1px solid var(--field-border);
  border-radius: var(--radius-md);
  transition: border-color var(--dur-fast), box-shadow var(--dur-fast);
}
.field__control:hover { border-color: var(--field-border-hover); }
.field__control:focus-within {
  border-color: var(--field-focus);
  box-shadow: var(--shadow-focus);
}
.field__input {
  flex: 1;
  border: 0;
  background: transparent;
  outline: none;
  font-size: var(--fs-body-md);
  color: var(--text-primary);
  min-width: 0;
}
.field__input::placeholder { color: var(--field-placeholder); }
.field__hint { font-size: var(--fs-label-sm); color: var(--text-muted); }
.field__error { font-size: var(--fs-label-sm); color: var(--status-error-fg); }
.field--has-error .field__control { border-color: var(--status-error); }

textarea.field__input { min-height: 96px; padding: var(--space-3) 0; resize: vertical; }

/* ---------- Modal ---------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: var(--modal-backdrop);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-5);
  z-index: var(--z-modal);
  animation: fade-in var(--dur-fast) var(--ease-out);
}
.modal {
  background: var(--modal-bg);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  border: 1px solid var(--border);
  max-width: 560px;
  width: 100%;
  max-height: calc(100vh - var(--space-9));
  display: flex;
  flex-direction: column;
  animation: slide-up var(--dur-normal) var(--ease-out);
}
.modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-5) var(--space-6);
  border-block-end: 1px solid var(--border);
}
.modal__title { font-size: var(--fs-headline-sm); font-weight: var(--fw-semibold); }
.modal__body { padding: var(--space-6); overflow-y: auto; }
.modal__footer {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-2);
  padding: var(--space-4) var(--space-6);
  border-block-start: 1px solid var(--border);
}

/* ---------- Drawer ---------- */
.drawer-backdrop {
  position: fixed;
  inset: 0;
  background: var(--overlay-scrim);
  z-index: var(--z-drawer);
  animation: fade-in var(--dur-fast) var(--ease-out);
}
.drawer {
  position: fixed;
  top: 0;
  bottom: 0;
  width: min(480px, 100vw);
  background: var(--drawer-bg);
  border-inline-start: 1px solid var(--border);
  box-shadow: var(--shadow-xl);
  z-index: calc(var(--z-drawer) + 1);
  display: flex;
  flex-direction: column;
  transition: transform var(--dur-normal) var(--ease-out);
}
.drawer__header {
  padding: var(--space-5) var(--space-6);
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-block-end: 1px solid var(--border);
}
.drawer__title { font-size: var(--fs-headline-sm); font-weight: var(--fw-semibold); }
.drawer__body { padding: var(--space-6); overflow-y: auto; flex: 1; }
.drawer__footer {
  padding: var(--space-4) var(--space-6);
  border-block-start: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: var(--space-2);
}

/* ---------- Stepper Wizard ---------- */
.stepper {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-4);
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
  overflow-x: auto;
}
.stepper__step {
  display: inline-flex;
  align-items: center;
  gap: var(--space-3);
  padding: 6px 12px;
  border-radius: var(--radius-full);
  color: var(--text-muted);
  font-size: var(--fs-label-md);
  font-weight: var(--fw-medium);
  white-space: nowrap;
}
.stepper__step.is-active { background: var(--accent-soft); color: var(--accent); font-weight: var(--fw-semibold); }
.stepper__step.is-done   { color: var(--status-success-fg); }
.stepper__step-index {
  width: 22px;
  height: 22px;
  border-radius: var(--radius-full);
  background: var(--surface-3);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: var(--fw-semibold);
}
.stepper__step.is-active .stepper__step-index { background: var(--accent); color: var(--text-on-accent); }
.stepper__step.is-done .stepper__step-index { background: var(--status-success); color: #fff; }
.stepper__connector {
  height: 2px;
  flex: 1;
  background: var(--border);
  min-width: 24px;
}

/* ---------- Audio Player ---------- */
.audio-player {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-full);
}
.audio-player__btn {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  background: var(--accent);
  color: var(--text-on-accent);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.audio-player__progress {
  flex: 1;
  height: 4px;
  border-radius: var(--radius-full);
  background: var(--surface-3);
  position: relative;
  overflow: hidden;
}
.audio-player__progress-fill {
  position: absolute;
  inset-inline-start: 0;
  top: 0;
  bottom: 0;
  width: 35%;
  background: var(--accent);
  border-radius: inherit;
}
.audio-player__time {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-muted);
}

/* ---------- Timeline ---------- */
.timeline { display: flex; flex-direction: column; gap: var(--space-4); position: relative; }
.timeline::before {
  content: "";
  position: absolute;
  inset-block: 8px;
  inset-inline-start: 11px;
  width: 2px;
  background: var(--border);
  border-radius: var(--radius-full);
}
.timeline__item { display: flex; gap: var(--space-4); position: relative; }
.timeline__dot {
  width: 24px;
  height: 24px;
  border-radius: var(--radius-full);
  background: var(--surface-3);
  border: 2px solid var(--card-bg);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  flex: 0 0 auto;
  z-index: 1;
}
.timeline__dot--accent  { background: var(--accent); color: var(--text-on-accent); }
.timeline__dot--success { background: var(--status-success); color: #fff; }
.timeline__dot--error   { background: var(--status-error); color: #fff; }
.timeline__content { flex: 1; padding-block: 2px; }
.timeline__title { font-weight: var(--fw-semibold); color: var(--text-primary); }
.timeline__meta { font-size: var(--fs-label-sm); color: var(--text-muted); }

/* ---------- Empty / Loading / Error states ---------- */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-3);
  padding: var(--space-10) var(--space-5);
  text-align: center;
}
.empty-state__icon {
  width: 64px;
  height: 64px;
  border-radius: var(--radius-full);
  background: var(--accent-soft);
  color: var(--accent);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.empty-state__title { font-size: var(--fs-headline-sm); font-weight: var(--fw-semibold); }
.empty-state__description { color: var(--text-secondary); max-width: 360px; }

.skeleton {
  background: linear-gradient(
    90deg,
    var(--surface-2) 0%,
    var(--surface-3) 50%,
    var(--surface-2) 100%
  );
  background-size: 400px 100%;
  animation: shimmer 1.4s linear infinite;
  border-radius: var(--radius-sm);
  min-height: 12px;
}
.skeleton--line { height: 12px; }
.skeleton--block { height: 80px; border-radius: var(--radius-md); }

.error-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-10) var(--space-5);
  text-align: center;
}
.error-state__icon {
  width: 64px;
  height: 64px;
  border-radius: var(--radius-full);
  background: var(--status-error-bg);
  color: var(--status-error-fg);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* ---------- Toast ---------- */
.toast-stack {
  position: fixed;
  bottom: var(--space-5);
  inset-inline-end: var(--space-5);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  z-index: var(--z-toast);
  pointer-events: none;
}
.toast {
  pointer-events: auto;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-4);
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-width: 280px;
  max-width: 420px;
  animation: slide-up var(--dur-normal) var(--ease-out);
}
.toast__icon { flex: 0 0 auto; }
.toast__body { flex: 1; }
.toast__title { font-weight: var(--fw-semibold); }
.toast__description { color: var(--text-secondary); font-size: var(--fs-label-md); }
.toast--success .toast__icon { color: var(--status-success); }
.toast--warning .toast__icon { color: var(--status-warning); }
.toast--error   .toast__icon { color: var(--status-error); }
.toast--info    .toast__icon { color: var(--status-info); }

/* ---------- Confirmation Dialog (variant of modal) ---------- */
.confirm-dialog { max-width: 440px; }
.confirm-dialog .modal__body { padding: var(--space-6); }
.confirm-dialog__icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-full);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--status-warning-bg);
  color: var(--status-warning-fg);
}
.confirm-dialog__icon--danger { background: var(--status-error-bg); color: var(--status-error-fg); }

/* ---------- Command Palette ---------- */
.palette-backdrop {
  position: fixed;
  inset: 0;
  background: var(--overlay-scrim);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 12vh;
  padding-inline: var(--space-5);
  z-index: var(--z-palette);
  animation: fade-in var(--dur-fast) var(--ease-out);
}
.palette {
  width: 100%;
  max-width: 620px;
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  overflow: hidden;
  animation: slide-up var(--dur-normal) var(--ease-out);
}
.palette__search {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-4);
  border-block-end: 1px solid var(--border);
}
.palette__input {
  flex: 1;
  border: 0;
  outline: none;
  background: transparent;
  font-size: var(--fs-body-lg);
  color: var(--text-primary);
}
.palette__list { max-height: 360px; overflow-y: auto; padding: var(--space-2); }
.palette__item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 10px var(--space-3);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  cursor: pointer;
  font-size: var(--fs-body-md);
}
.palette__item:hover,
.palette__item.is-active { background: var(--accent-soft); color: var(--text-primary); }
.palette__item-group {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-inline-start: auto;
}
.palette__section-label {
  padding: var(--space-3) var(--space-3) var(--space-1);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  font-weight: var(--fw-semibold);
}

/* ---------- Chart Card (placeholder canvas) ---------- */
.chart-card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  min-height: 280px;
}
.chart-card__plot {
  flex: 1;
  min-height: 200px;
  border-radius: var(--radius-md);
  background:
    linear-gradient(180deg, transparent 0%, var(--accent-soft) 100%),
    repeating-linear-gradient(0deg, var(--chart-grid) 0 1px, transparent 1px 32px),
    repeating-linear-gradient(90deg, var(--chart-grid) 0 1px, transparent 1px 48px);
}

/* ---------- Wallboard cell ---------- */
.wallboard {
  display: grid;
  gap: var(--space-4);
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}
.wallboard__tile {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-xl);
  padding: var(--space-6);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  position: relative;
  overflow: hidden;
}
.wallboard__tile::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at top right, var(--accent-soft) 0%, transparent 70%);
  pointer-events: none;
}
.wallboard__value {
  font-size: 56px;
  font-weight: var(--fw-bold);
  line-height: 1;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
  color: var(--text-primary);
}
.wallboard__label {
  font-size: var(--fs-label-md);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}

/* ---------- Permission Matrix table ---------- */
.matrix th, .matrix td { text-align: center; }
.matrix tbody td:first-child { text-align: start; font-weight: var(--fw-medium); }
.matrix__check {
  width: 18px;
  height: 18px;
  border-radius: var(--radius-xs);
  border: 1.5px solid var(--border-strong);
  display: inline-block;
}
.matrix__check.is-on {
  background: var(--accent);
  border-color: var(--accent);
}

/* ---------- Switchboard grid ---------- */
.switchboard {
  display: grid;
  gap: var(--space-3);
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
}
.switchboard__line {
  padding: var(--space-3);
  border-radius: var(--radius-md);
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  font-size: var(--fs-label-md);
}
.switchboard__line .badge { align-self: flex-start; }

/* ---------- Function keys ---------- */
.fn-keys {
  display: grid;
  gap: var(--space-2);
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
}
.fn-key {
  padding: var(--space-3);
  border-radius: var(--radius-md);
  background: var(--surface-2);
  border: 1px solid var(--border);
  text-align: center;
  font-weight: var(--fw-medium);
  font-size: var(--fs-label-md);
  color: var(--text-secondary);
  transition: background var(--dur-fast);
}
.fn-key:hover { background: var(--surface-3); color: var(--text-primary); }
.fn-key--active { background: var(--accent-soft); color: var(--accent); border-color: transparent; }

/* ── C16: Network FQDN (customer admin) ─────────────────────────────── */
.nfqdn-wrap { max-width: 900px; margin: 0 auto; display: flex; flex-direction: column; gap: 16px; }
.nfqdn-card { padding: 20px; }
.nfqdn-card .card__header { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 16px; }
.nfqdn-icon { color: var(--c-accent); font-size: 24px; margin-top: 2px; }
.nfqdn-fqdn-row { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.nfqdn-fqdn-value { font-size: 20px; font-weight: 700; color: var(--c-text); letter-spacing: -.3px; }
.nfqdn-flags { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.nfqdn-flag { display: flex; align-items: center; gap: 4px; font-size: 12px; padding: 3px 10px; border-radius: 20px; }
.nfqdn-flag .material-symbols-outlined { font-size: 14px; }
.nfqdn-flag--ok { background: rgba(34,197,94,.12); color: #16a34a; }
.nfqdn-flag--pending { background: rgba(251,191,36,.12); color: #b45309; }
.nfqdn-meta { font-size: 12px; margin-top: 4px; }
.nfqdn-no-domain { display: flex; align-items: center; gap: 8px; color: var(--c-text-muted); padding: 12px 0; }
.nfqdn-table { width: 100%; border-collapse: collapse; }
.nfqdn-table tr + tr td { border-top: 1px solid var(--c-border); }
.nfqdn-url-icon { width: 28px; padding: 8px 4px; }
.nfqdn-url-label { padding: 8px 12px; color: var(--c-text-muted); font-size: 13px; white-space: nowrap; }
.nfqdn-url-val { padding: 8px; word-break: break-all; font-size: 13px; }
.nfqdn-link { color: var(--c-accent); text-decoration: none; }
.nfqdn-link:hover { text-decoration: underline; }
.nfqdn-sip-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px,1fr)); gap: 12px; padding: 4px 0; }
.nfqdn-sip-field { background: var(--c-surface); border: 1px solid var(--c-border); border-radius: 8px; padding: 10px 14px; }
.nfqdn-sip-label { font-size: 11px; text-transform: uppercase; letter-spacing: .5px; margin-bottom: 4px; }
.nfqdn-sip-value { font-size: 15px; font-weight: 600; }
.nfqdn-sip-note { font-size: 12px; margin-top: 12px; }
.nfqdn-notes { border-left: 3px solid var(--c-info); }
.nfqdn-note { display: flex; align-items: center; gap: 6px; color: var(--c-text-muted); font-size: 13px; }

/* ── C16: Sysadmin Domains Panel ─────────────────────────────────────── */
.domains-panel { }
.domains-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.domains-title { display: flex; align-items: center; gap: 8px; font-size: 16px; font-weight: 600; }
.domain-card { border: 1px solid var(--c-border); border-radius: 10px; padding: 16px; margin-bottom: 12px; background: var(--c-surface); }
.domain-card--success { border-color: rgba(34,197,94,.3); }
.domain-card--info    { border-color: rgba(59,130,246,.3); }
.domain-card--warning { border-color: rgba(251,191,36,.3); }
.domain-card--error   { border-color: rgba(239,68,68,.3); }
.domain-card--muted   { opacity: .6; }
.domain-card__head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; flex-wrap: wrap; gap: 8px; }
.domain-card__fqdn { display: flex; align-items: center; gap: 8px; font-size: 15px; }
.domain-card__urls { display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 10px; font-size: 12px; }
.domain-url-line { display: flex; align-items: center; gap: 4px; }
.domain-card__meta { font-size: 11px; margin-bottom: 8px; }
.domain-card__error { font-size: 12px; margin-bottom: 8px; display: flex; align-items: center; gap: 4px; }
.domain-card__actions { display: flex; flex-wrap: wrap; gap: 6px; }


/* ════════════════════════════════════════════════════════════════════════════
   Sprint 16 Phase 2 — RTL / Mobile / Accessibility enhancements
   ════════════════════════════════════════════════════════════════════════════ */

/* ── Coming Soon page ──────────────────────────────────────────────────────── */
.coming-soon-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 60vh;
  text-align: center;
  padding: 40px 20px;
}

/* ── RTL — logical properties for icon buttons ─────────────────────────────── */
[dir="rtl"] .icon-btn,
[dir="rtl"] .btn--icon {
  transform: scaleX(-1);
}
[dir="rtl"] .icon-btn.icon-no-flip,
[dir="rtl"] .btn--icon.icon-no-flip {
  transform: none;
}

/* ── RTL — table column alignment ──────────────────────────────────────────── */
[dir="rtl"] .table th,
[dir="rtl"] .table td {
  text-align: right;
}
[dir="rtl"] .table .actions-col {
  text-align: left;
}

/* ── RTL — badge / tag layout ──────────────────────────────────────────────── */
[dir="rtl"] .badge,
[dir="rtl"] .tag {
  direction: rtl;
}

/* ── RTL — breadcrumb separator ────────────────────────────────────────────── */
[dir="rtl"] .breadcrumb__separator {
  transform: scaleX(-1);
}

/* ── RTL — form labels ──────────────────────────────────────────────────────── */
[dir="rtl"] .form-label,
[dir="rtl"] .form-hint {
  text-align: right;
}
[dir="rtl"] .form-label .required-star {
  margin-inline-start: 2px;
  margin-inline-end: 0;
}

/* ── RTL — SIP/phone numbers (always LTR data) ──────────────────────────────── */
.sip-number,
.phone-number,
.extension-number,
.sip-username {
  direction: ltr;
  unicode-bidi: isolate;
  font-family: var(--font-mono, monospace);
}

/* ── Mobile — sidebar overlay ───────────────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    inset-inline-start: -280px;
    top: 0;
    bottom: 0;
    width: 280px;
    z-index: 200;
    transition: inset-inline-start 0.25s ease;
    box-shadow: 4px 0 20px rgba(0,0,0,0.15);
  }
  .sidebar.sidebar--open {
    inset-inline-start: 0;
  }
  .main-layout {
    margin-inline-start: 0 !important;
  }
  .page {
    padding: 12px;
  }
  .table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .form__grid {
    grid-template-columns: 1fr !important;
  }
  .page-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }
  .page-header__actions {
    width: 100%;
    flex-wrap: wrap;
  }
  /* Touch targets — minimum 44px */
  .btn,
  .tab-btn,
  .tabs__item,
  .sidebar__item a {
    min-height: 44px;
    display: flex;
    align-items: center;
  }
}

/* ── Accessibility — focus ring ─────────────────────────────────────────────── */
:focus-visible {
  outline: 2px solid var(--color-primary, #2563eb);
  outline-offset: 2px;
  border-radius: 4px;
}
/* Skip default outline when focus-visible is supported */
:focus:not(:focus-visible) {
  outline: none;
}

/* ── Accessibility — aria-label for icon-only buttons ───────────────────────── */
.btn[aria-label] .btn-text,
.btn[title] .btn-text {
  /* allow text to be visually hidden but accessible */
}

/* ── Accessibility — reduced motion ─────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ── Tab bar consistency ─────────────────────────────────────────────────────── */
.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 2px solid var(--color-border, #e5e7eb);
  padding-bottom: 0;
  overflow-x: auto;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tabs__item {
  padding: 10px 18px;
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  color: var(--color-muted, #6b7280);
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  white-space: nowrap;
  border-radius: 4px 4px 0 0;
  transition: color 0.15s, border-color 0.15s;
}
.tabs__item:hover {
  color: var(--color-primary, #2563eb);
  background: var(--color-surface-2, #f8fafc);
}
.tabs__item.is-active {
  color: var(--color-primary, #2563eb);
  border-bottom-color: var(--color-primary, #2563eb);
}
.tabs__item--planned {
  opacity: 0.45;
  cursor: not-allowed;
}

/* ── Status badge colors ─────────────────────────────────────────────────────── */
.badge--registered  { background: #dcfce7; color: #15803d; border: 1px solid #86efac; }
.badge--unregistered{ background: #f1f5f9; color: #64748b; border: 1px solid #cbd5e1; }
.badge--dnd         { background: #fef3c7; color: #92400e; border: 1px solid #fcd34d; }
.badge--busy        { background: #fee2e2; color: #991b1b; border: 1px solid #fca5a5; }
.badge--available   { background: #dcfce7; color: #15803d; border: 1px solid #86efac; }

/* ── IVR no-prompt warning ───────────────────────────────────────────────────── */
#ivr-no-prompt-warn {
  animation: fadeIn 0.2s ease;
}
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}
