/* ============================================================
   TGLE DMS Design System - Modern SaaS (Indigo)
   Compatible class names: tgle-*
   ============================================================ */

:root {
  /* Brand (indigo primary - mockup) */
  --tgle-primary: #4F46E5;
  --tgle-primary-hover: #4338CA;
  --tgle-primary-soft: rgba(79, 70, 229, 0.12);
  --tgle-secondary: #7C3AED;
  --tgle-navy: #0F172A;
  --tgle-navy-deep: #020617;
  --tgle-steel: #334155;
  --tgle-accent: var(--tgle-primary);
  --tgle-accent-hover: var(--tgle-primary-hover);
  --tgle-accent-soft: var(--tgle-primary-soft);

  /* Neutrals */
  --tgle-white: #FFFFFF;
  --tgle-off-white: #F8FAFC;
  --tgle-gray-50: #F8FAFC;
  --tgle-gray-100: #F1F5F9;
  --tgle-gray-200: #E2E8F0;
  --tgle-gray-300: #CBD5E1;
  --tgle-gray-400: #94A3B8;
  --tgle-gray-500: #64748B;
  --tgle-gray-600: #475569;
  --tgle-gray-700: #334155;
  --tgle-gray-800: #1E293B;
  --tgle-gray-900: #0F172A;

  /* Semantic */
  --tgle-success: #10B981;
  --tgle-success-bg: rgba(16, 185, 129, 0.12);
  --tgle-warning: #F59E0B;
  --tgle-warning-bg: rgba(245, 158, 11, 0.12);
  --tgle-danger: #EF4444;
  --tgle-danger-bg: rgba(239, 68, 68, 0.12);
  --tgle-info: #3B82F6;
  --tgle-info-bg: rgba(59, 130, 246, 0.12);

  /* Typography - Inter only */
  --font-display: "Inter", "Segoe UI", system-ui, sans-serif;
  --font-body: "Inter", "Segoe UI", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", Consolas, monospace;

  --fs-xs: 0.75rem;
  --fs-sm: 0.875rem;
  --fs-base: 0.9375rem;
  --fs-md: 1.0625rem;
  --fs-lg: 1.25rem;
  --fs-xl: 1.5rem;
  --fs-2xl: 1.875rem;
  --fs-3xl: 2.25rem;
  --fs-4xl: 2.75rem;
  --fs-5xl: 3.5rem;

  --fw-regular: 400;
  --fw-medium: 500;
  --fw-semibold: 600;
  --fw-bold: 700;

  --lh-tight: 1.25;
  --lh-normal: 1.6;
  --lh-relaxed: 1.7;
  --ls-tight: -0.02em;

  /* Spacing */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.25rem;
  --space-6: 1.5rem;
  --space-8: 2rem;
  --space-10: 2.5rem;
  --space-12: 3rem;
  --space-16: 4rem;
  --space-20: 5rem;
  --space-24: 6rem;
  --section-gap: 2rem;
  --card-gap: 1.5rem;

  /* Radius - SaaS */
  --radius-sm: 0.5rem;
  --radius-md: 0.75rem;
  --radius-lg: 0.875rem;
  --radius-xl: 1.125rem;
  --radius-2xl: 1.25rem;
  --radius-pill: 999px;
  --radius-btn: 0.75rem;
  --radius-card: 1.125rem;

  /* Shadows - soft layered */
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.04), 0 1px 1px rgba(15, 23, 42, 0.03);
  --shadow-md: 0 4px 12px rgba(15, 23, 42, 0.06), 0 1px 3px rgba(15, 23, 42, 0.04);
  --shadow-lg: 0 12px 32px rgba(15, 23, 42, 0.08), 0 4px 8px rgba(15, 23, 42, 0.04);
  --shadow-hover: 0 10px 28px rgba(15, 23, 42, 0.1), 0 2px 6px rgba(15, 23, 42, 0.05);

  /* Layout */
  --sidebar-width: 272px;
  --sidebar-collapsed: 80px;
  --navbar-height: 68px;
  --content-max: 100%;

  /* Motion */
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --duration-fast: 150ms;
  --duration-base: 250ms;
  --duration-slow: 400ms;

  /* Z-index */
  --z-dropdown: 1050;
  --z-sticky: 1020;
  --z-sidebar: 1030;
  --z-modal: 1060;
  --z-toast: 1080;
  --z-command: 1100;

  /* Surfaces */
  --bg-body: #F8FAFC;
  --bg-surface: #FFFFFF;
  --bg-sidebar: #0F172A;
  --bg-muted: #F1F5F9;
  --bg-input: #FFFFFF;
  --bg-dropdown: #FFFFFF;
  --bg-table-head: #F8FAFC;
  --bg-table-hover: #F8FAFC;
  --text-primary: #111827;
  --text-heading: #0F172A;
  --text-secondary: #64748B;
  --text-muted: #94A3B8;
  --text-table: #334155;
  --text-table-head: #64748B;
  --text-dropdown: #111827;
  --text-inverse: #FFFFFF;
  --border-color: #E2E8F0;
  --border-input: #E2E8F0;
  --border-subtle: #E8ECF3;
}

/* Reset / Base */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

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

body {
  margin: 0;
  font-family: var(--font-body);
  font-size: var(--fs-base);
  font-weight: var(--fw-regular);
  line-height: var(--lh-normal);
  letter-spacing: var(--ls-tight);
  color: var(--text-primary);
  background: var(--bg-body);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-display);
  font-weight: var(--fw-bold);
  line-height: var(--lh-tight);
  letter-spacing: var(--ls-tight);
  color: var(--text-heading);
  margin-top: 0;
}

a {
  color: var(--tgle-primary);
  text-decoration: none;
  transition: color var(--duration-fast) var(--ease-out);
}

a:hover {
  color: var(--tgle-primary-hover);
}

img {
  max-width: 100%;
  height: auto;
}

:focus-visible {
  outline: 2px solid var(--tgle-primary);
  outline-offset: 2px;
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 9999;
  padding: 0.75rem 1rem;
  background: var(--tgle-primary);
  color: #fff;
  border-radius: var(--radius-md);
}

.skip-link:focus {
  left: var(--space-4);
  top: var(--space-4);
}

/* Buttons */
.btn-tgle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: 0.5rem 1rem;
  font-family: var(--font-body);
  font-size: var(--fs-sm);
  font-weight: var(--fw-semibold);
  line-height: 1.25;
  border: 1px solid transparent;
  border-radius: var(--radius-btn);
  cursor: pointer;
  box-sizing: border-box;
  white-space: nowrap;
  width: auto;
  max-width: 100%;
  min-height: 2.25rem;
  height: auto;
  flex: 0 0 auto;
  align-self: center;
  vertical-align: middle;
  text-decoration: none;
  transition: background var(--duration-fast) var(--ease-out),
              border-color var(--duration-fast) var(--ease-out),
              color var(--duration-fast) var(--ease-out),
              box-shadow var(--duration-fast) var(--ease-out),
              transform var(--duration-fast) var(--ease-out);
}

.btn-tgle:hover {
  transform: translateY(-1px);
  text-decoration: none;
}

.btn-tgle:active {
  transform: translateY(0);
}

/* Never stretch to sibling height in flex toolbars */
.d-flex > .btn-tgle,
.d-flex > a.btn-tgle,
[class*="d-flex"] > .btn-tgle,
[class*="d-flex"] > a.btn-tgle,
.d-flex > form:has(.btn-tgle),
.page-toolbar > a.btn-tgle,
.toolbar-actions > .btn-tgle,
.toolbar-actions > a.btn-tgle {
  align-self: center;
  flex: 0 0 auto;
  height: auto;
}

.btn-tgle.w-100,
.btn-tgle.btn-tgle-block {
  width: 100%;
  flex: 1 1 auto;
  align-self: stretch;
}

.btn-tgle-primary {
  background: linear-gradient(180deg, #6366F1 0%, var(--tgle-primary) 100%);
  color: #fff;
  border-color: var(--tgle-primary);
  box-shadow: 0 1px 2px rgba(79, 70, 229, 0.25), 0 4px 12px rgba(79, 70, 229, 0.2);
}

.btn-tgle-primary:hover {
  background: linear-gradient(180deg, var(--tgle-primary) 0%, var(--tgle-primary-hover) 100%);
  color: #fff;
}

.btn-tgle-secondary {
  background: var(--tgle-navy);
  color: var(--tgle-white);
  border-color: var(--tgle-navy);
}

.btn-tgle-secondary:hover {
  background: var(--tgle-steel);
  color: var(--tgle-white);
}

.btn-tgle-outline {
  background: var(--bg-surface);
  color: var(--text-primary);
  border-color: var(--border-color);
}

.btn-tgle-outline:hover {
  border-color: var(--tgle-primary);
  color: var(--tgle-primary);
  background: var(--tgle-primary-soft);
}

.btn-tgle-ghost {
  background: transparent;
  color: var(--text-secondary);
}

.btn-tgle-ghost:hover {
  background: var(--bg-muted);
  color: var(--text-primary);
}

.btn-tgle-danger {
  background: var(--tgle-danger);
  color: var(--tgle-white);
}

.btn-tgle-sm {
  padding: 0.35rem 0.8rem;
  font-size: 0.8125rem;
  border-radius: 0.625rem;
  min-height: 2.125rem;
  height: auto;
  line-height: 1.25;
}

.btn-tgle-sm:hover {
  transform: none;
}

.btn-tgle-sm.btn-tgle-primary {
  box-shadow: 0 1px 2px rgba(79, 70, 229, 0.22);
}

.btn-tgle-sm i {
  font-size: 0.75rem;
}

/* Compact page toolbars (filters + primary CTA) */
.page-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.page-toolbar .toolbar-filters {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  flex: 1 1 auto;
  min-width: 0;
}

.page-toolbar .toolbar-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  flex: 0 0 auto;
}

.page-toolbar .form-control-tgle,
.page-toolbar .form-control,
.page-toolbar .form-select,
.page-toolbar .toolbar-filters .form-control-tgle,
.d-flex.flex-wrap > .form-control-tgle,
.d-flex.gap-2 > .form-control-tgle,
.d-flex.gap-2 .form-control-tgle[style*="max-width"],
form.d-flex > .form-control-tgle,
form.d-flex > .form-select {
  width: auto;
  min-width: 0;
  min-height: 2.125rem;
  padding-top: 0.375rem;
  padding-bottom: 0.375rem;
}

/* Default list toolbars - center items so CTAs don't stretch */
.d-flex.justify-content-between {
  align-items: center;
}

.btn-tgle-lg {
  padding: 0.875rem 1.75rem;
  font-size: var(--fs-base);
}

.btn-tgle-block {
  width: 100%;
}

.btn-tgle.is-loading {
  pointer-events: none;
  opacity: 0.72;
}

/* Cards */
.tgle-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--duration-base) var(--ease-out),
              transform var(--duration-base) var(--ease-out);
}

.tgle-card-hover:hover,
.tgle-card.stat-card:hover {
  box-shadow: var(--shadow-hover);
  transform: translateY(-2px);
}

.tgle-card-header {
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
}

.tgle-card-header strong,
.tgle-card-title {
  font-size: var(--fs-sm);
  font-weight: var(--fw-semibold);
  color: var(--text-heading);
}

.tgle-card-body {
  padding: var(--space-5);
}

.tgle-card-footer {
  padding: var(--space-4) var(--space-5);
  border-top: 1px solid var(--border-subtle);
  background: var(--bg-muted);
  border-radius: 0 0 var(--radius-card) var(--radius-card);
}

/* Stat / KPI cards */
.stat-card .stat-label {
  font-size: var(--fs-xs);
  font-weight: var(--fw-medium);
  color: var(--text-secondary);
  margin-bottom: var(--space-2);
}

.stat-card .stat-value {
  font-size: 1.75rem;
  font-weight: var(--fw-bold);
  letter-spacing: var(--ls-tight);
  color: var(--text-primary);
  line-height: 1.1;
}

.stat-card .stat-value.is-alert,
.kpi-value.is-alert {
  color: #B42318;
}

.kpi-value {
  color: var(--text-primary);
  font-weight: var(--fw-bold);
  line-height: 1.1;
}

.stat-card .stat-trend {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  margin-top: var(--space-2);
  font-size: 0.75rem;
  font-weight: var(--fw-semibold);
}

.stat-trend.up { color: var(--text-secondary); }
.stat-trend.down { color: #B42318; }
.stat-trend.flat { color: var(--text-muted); }

.stat-icon {
  width: 2.5rem;
  height: 2.5rem;
  border-radius: var(--radius-md);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  background: var(--bg-muted);
  color: var(--text-secondary);
}

.stat-icon.info,
.stat-icon.success,
.stat-icon.warning,
.stat-icon.danger,
.stat-icon.primary,
.stat-icon.neutral {
  background: var(--bg-muted);
  color: var(--text-secondary);
}

.sparkline {
  width: 72px;
  height: 28px;
  display: block;
}

/* Forms */
.form-label-tgle {
  display: block;
  font-size: var(--fs-sm);
  font-weight: var(--fw-semibold);
  color: var(--text-secondary);
  margin-bottom: var(--space-2);
}

.form-control-tgle,
.form-control,
.form-select {
  display: block;
  width: 100%;
  padding: 0.625rem 0.875rem;
  font-family: var(--font-body);
  font-size: var(--fs-sm);
  color: var(--text-primary);
  background: var(--bg-input);
  border: 1px solid var(--border-input);
  border-radius: var(--radius-md);
  transition: border-color var(--duration-fast) var(--ease-out),
              box-shadow var(--duration-fast) var(--ease-out);
}

.form-control-tgle:focus,
.form-control:focus,
.form-select:focus {
  outline: none;
  border-color: var(--tgle-primary);
  box-shadow: 0 0 0 3px var(--tgle-primary-soft);
}

.form-control-tgle.is-invalid,
.form-control.is-invalid {
  border-color: var(--tgle-danger);
}

.form-error {
  font-size: var(--fs-xs);
  color: var(--tgle-danger);
  margin-top: var(--space-1);
}

.form-hint {
  font-size: var(--fs-xs);
  color: var(--text-muted);
  margin-top: var(--space-1);
}

/* Badges */
.badge-tgle {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.55rem;
  font-size: 0.7rem;
  font-weight: var(--fw-semibold);
  border-radius: var(--radius-pill);
  line-height: 1.4;
}

.badge-tgle-success { background: var(--tgle-success-bg); color: #047857; }
.badge-tgle-warning { background: var(--tgle-warning-bg); color: #B45309; }
.badge-tgle-danger  { background: var(--tgle-danger-bg); color: #B91C1C; }
.badge-tgle-info    { background: var(--tgle-info-bg); color: #1D4ED8; }
.badge-tgle-neutral { background: var(--tgle-gray-100); color: var(--tgle-gray-600); }
.badge-tgle-primary { background: var(--tgle-primary-soft); color: var(--tgle-primary); }

/* Table row action icons */
.btn-icon-tgle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  background: var(--bg-surface);
  color: var(--text-secondary);
  text-decoration: none;
  transition: background var(--duration-fast) var(--ease-out),
              color var(--duration-fast) var(--ease-out),
              border-color var(--duration-fast) var(--ease-out),
              transform var(--duration-fast) var(--ease-out);
}

.btn-icon-tgle:hover {
  background: var(--tgle-primary-soft);
  color: var(--tgle-primary);
  border-color: rgba(79, 70, 229, 0.25);
  transform: translateY(-1px);
}

.btn-icon-tgle.edit:hover {
  background: var(--tgle-info-bg);
  color: var(--tgle-info);
  border-color: rgba(59, 130, 246, 0.25);
}

.btn-icon-tgle.delete:hover {
  background: var(--tgle-danger-bg);
  color: var(--tgle-danger);
  border-color: rgba(239, 68, 68, 0.25);
}

.table-actions {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.35rem;
  white-space: nowrap;
}

/* Invoice detail premium blocks */
.invoice-hero {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: var(--space-4);
  margin-bottom: var(--section-gap);
  padding: var(--space-5);
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-sm);
}

.invoice-hero .inv-number {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0 0 0.35rem;
}

.invoice-totals .tot-row {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.45rem 0;
  font-size: 0.875rem;
  border-bottom: 1px solid var(--border-subtle);
}

.invoice-totals .tot-row:last-child {
  border-bottom: none;
}

.invoice-totals .tot-row.emphasis {
  font-size: 1rem;
  font-weight: 700;
  padding-top: 0.75rem;
  margin-top: 0.25rem;
  border-top: 1px solid var(--border-color);
  border-bottom: none;
}

.invoice-totals .tot-row.outstanding strong {
  color: var(--tgle-danger);
}

.invoice-totals .tot-row.paid strong {
  color: var(--tgle-success);
}

.party-block .label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  font-weight: 600;
  margin-bottom: 0.35rem;
}

.party-block .name {
  font-weight: 700;
  font-size: 1rem;
  color: var(--text-heading);
}

.party-block .meta {
  color: var(--text-secondary);
  font-size: 0.85rem;
}

/* Alerts */
.alert-tgle {
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-lg);
  border: 1px solid transparent;
  font-size: var(--fs-sm);
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
}

.alert-tgle-success { background: var(--tgle-success-bg); border-color: rgba(16,185,129,0.25); color: #047857; }
.alert-tgle-warning { background: var(--tgle-warning-bg); border-color: rgba(245,158,11,0.25); color: #B45309; }
.alert-tgle-danger  { background: var(--tgle-danger-bg); border-color: rgba(239,68,68,0.25); color: #B91C1C; }
.alert-tgle-info    { background: var(--tgle-info-bg); border-color: rgba(59,130,246,0.25); color: #1D4ED8; }

/* Tables */
.table-tgle {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--fs-sm);
}

.table-tgle thead th {
  text-align: left;
  padding: var(--space-3) var(--space-4);
  font-weight: var(--fw-semibold);
  color: var(--text-table-head);
  background: var(--bg-table-head);
  border-bottom: 1px solid var(--border-color);
  white-space: nowrap;
  position: sticky;
  top: 0;
  z-index: 1;
}

.table-tgle tbody td {
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-table);
  vertical-align: middle;
}

.table-tgle tbody tr:hover td {
  background: var(--bg-table-hover);
}

.table-tgle tbody tr:last-child td {
  border-bottom: none;
}

/* Breadcrumb */
.breadcrumb-tgle {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  list-style: none;
  padding: 0;
  margin: 0 0 var(--space-4);
  font-size: var(--fs-sm);
  color: var(--text-muted);
}

.breadcrumb-tgle li:not(:last-child)::after {
  content: "/";
  margin-left: var(--space-2);
  color: var(--tgle-gray-300);
}

.breadcrumb-tgle a {
  color: var(--text-secondary);
}

.breadcrumb-tgle .active {
  color: var(--text-primary);
  font-weight: var(--fw-medium);
}

/* Pagination */
.pagination-bar-tgle {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  width: 100%;
}

.pagination-meta-tgle {
  font-size: var(--fs-sm);
  color: var(--text-secondary);
}

.pagination-tgle {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1);
  list-style: none;
  padding: 0;
  margin: 0;
}

.pagination-tgle a,
.pagination-tgle span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2rem;
  height: 2rem;
  padding: 0 var(--space-2);
  font-size: var(--fs-sm);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  background: var(--bg-surface);
  text-decoration: none;
}

.pagination-tgle a:hover {
  border-color: var(--tgle-primary);
  color: var(--tgle-primary);
}

.pagination-tgle .active span {
  background: var(--tgle-primary);
  color: #fff;
  border-color: var(--tgle-primary);
}

.pagination-tgle .disabled span,
.pagination-tgle .ellipsis span {
  opacity: 0.45;
  cursor: default;
}

/* Loader + skeleton */
.loader-tgle {
  width: 2rem;
  height: 2rem;
  border: 3px solid var(--tgle-gray-200);
  border-top-color: var(--tgle-primary);
  border-radius: 50%;
  animation: tgle-spin 0.7s linear infinite;
}

.loader-tgle-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

.skeleton {
  background: linear-gradient(90deg, var(--bg-muted) 25%, var(--tgle-gray-100) 50%, var(--bg-muted) 75%);
  background-size: 200% 100%;
  animation: tgle-skeleton 1.2s ease-in-out infinite;
  border-radius: var(--radius-md);
}

@keyframes tgle-spin {
  to { transform: rotate(360deg); }
}

@keyframes tgle-skeleton {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

@keyframes tgle-fade-in {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Toast */
.toast-container-tgle {
  position: fixed;
  top: var(--space-4);
  right: var(--space-4);
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  max-width: 360px;
}

.toast-tgle {
  background: var(--tgle-navy);
  color: var(--tgle-white);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  font-size: var(--fs-sm);
  animation: tgle-slide-in var(--duration-base) var(--ease-out);
}

.toast-tgle.success { border-left: 3px solid var(--tgle-success); }
.toast-tgle.error { border-left: 3px solid var(--tgle-danger); }

@keyframes tgle-slide-in {
  from { opacity: 0; transform: translateX(1rem); }
  to { opacity: 1; transform: translateX(0); }
}

/* Switch */
.tgle-switch {
  position: relative;
  width: 42px;
  height: 24px;
  display: inline-block;
}

.tgle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.tgle-switch .slider {
  position: absolute;
  inset: 0;
  background: var(--tgle-gray-300);
  border-radius: var(--radius-pill);
  cursor: pointer;
  transition: background var(--duration-fast) var(--ease-out);
}

.tgle-switch .slider::before {
  content: "";
  position: absolute;
  width: 18px;
  height: 18px;
  left: 3px;
  top: 3px;
  background: #fff;
  border-radius: 50%;
  transition: transform var(--duration-fast) var(--ease-out);
  box-shadow: var(--shadow-sm);
}

.tgle-switch input:checked + .slider {
  background: var(--tgle-primary);
}

.tgle-switch input:checked + .slider::before {
  transform: translateX(18px);
}

/* Empty state */
.empty-state {
  text-align: center;
  padding: var(--space-12) var(--space-8);
}

.empty-state i {
  font-size: 2.5rem;
  color: var(--tgle-primary);
  margin-bottom: var(--space-4);
  opacity: 0.85;
}

.empty-state h2 {
  margin-bottom: var(--space-2);
  font-size: var(--fs-lg);
}

.empty-state p {
  color: var(--text-secondary);
  max-width: 28rem;
  margin: 0 auto var(--space-6);
}

/* Utilities */
.text-muted-tgle { color: var(--text-muted); }
.text-accent { color: var(--tgle-primary); }
.bg-surface { background: var(--bg-surface); }
.fw-semibold { font-weight: var(--fw-semibold); }
.font-display { font-family: var(--font-display); font-weight: var(--fw-bold); }

.fade-in {
  animation: tgle-fade-in var(--duration-slow) var(--ease-out);
}

.user-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.user-chip .avatar-sm {
  width: 1.75rem;
  height: 1.75rem;
  border-radius: 50%;
  background: var(--tgle-primary-soft);
  color: var(--tgle-primary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.65rem;
  font-weight: var(--fw-bold);
  flex-shrink: 0;
}

/* Dark theme */
[data-theme="dark"] {
  color-scheme: dark;

  --bg-body: #0B1220;
  --bg-surface: #111827;
  --bg-sidebar: #020617;
  --bg-muted: #0F172A;
  --bg-input: #0F172A;
  --bg-dropdown: #1E293B;
  --bg-table-head: #0F172A;
  --bg-table-hover: #1E293B;

  --text-primary: #F1F5F9;
  --text-heading: #F8FAFC;
  --text-secondary: #94A3B8;
  --text-muted: #64748B;
  --text-table: #CBD5E1;
  --text-table-head: #94A3B8;
  --text-dropdown: #F1F5F9;

  --border-color: #1E293B;
  --border-input: #334155;
  --border-subtle: #1E293B;

  --tgle-gray-50: #0F172A;
  --tgle-gray-100: #1E293B;
  --tgle-gray-200: #334155;
  --tgle-gray-300: #475569;
  --tgle-gray-500: #94A3B8;
  --tgle-gray-600: #CBD5E1;
  --tgle-gray-700: #E2E8F0;

  --tgle-primary-soft: rgba(99, 102, 241, 0.2);

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.35);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.5);
  --shadow-hover: 0 10px 28px rgba(0, 0, 0, 0.45);

  --tgle-success-bg: rgba(16, 185, 129, 0.18);
  --tgle-warning-bg: rgba(245, 158, 11, 0.18);
  --tgle-danger-bg: rgba(239, 68, 68, 0.18);
  --tgle-info-bg: rgba(59, 130, 246, 0.18);
}

[data-theme="dark"] a { color: #A5B4FC; }
[data-theme="dark"] a:hover { color: #C7D2FE; }

[data-theme="dark"] .btn-tgle-outline {
  color: var(--text-primary);
  border-color: var(--border-input);
  background: transparent;
}

[data-theme="dark"] .btn-tgle-ghost { color: var(--text-secondary); }
[data-theme="dark"] .btn-tgle-ghost:hover {
  background: var(--bg-table-hover);
  color: var(--text-primary);
}

[data-theme="dark"] .badge-tgle-success { color: #34D399; }
[data-theme="dark"] .badge-tgle-warning { color: #FBBF24; }
[data-theme="dark"] .badge-tgle-danger { color: #F87171; }
[data-theme="dark"] .badge-tgle-info { color: #60A5FA; }
[data-theme="dark"] .badge-tgle-neutral { color: var(--text-secondary); }

/* Bootstrap / DataTables dark overrides */
[data-theme="dark"] .form-control,
[data-theme="dark"] .form-select {
  background-color: var(--bg-input);
  border-color: var(--border-input);
  color: var(--text-primary);
}

[data-theme="dark"] .form-control:focus,
[data-theme="dark"] .form-select:focus {
  background-color: var(--bg-input);
  border-color: var(--tgle-primary);
  color: var(--text-primary);
  box-shadow: 0 0 0 0.2rem var(--tgle-primary-soft);
}

[data-theme="dark"] .form-control::placeholder { color: var(--text-muted); }

[data-theme="dark"] .card {
  background-color: var(--bg-surface);
  border-color: var(--border-color);
  color: var(--text-primary);
}

[data-theme="dark"] .modal-content {
  background-color: var(--bg-surface);
  border-color: var(--border-color);
  color: var(--text-primary);
}

[data-theme="dark"] .dropdown-menu {
  background-color: var(--bg-dropdown);
  border-color: var(--border-color);
}

[data-theme="dark"] .dropdown-item { color: var(--text-primary); }
[data-theme="dark"] .dropdown-item:hover,
[data-theme="dark"] .dropdown-item:focus {
  background-color: var(--bg-table-hover);
  color: var(--text-primary);
}

[data-theme="dark"] .bg-light {
  background-color: var(--bg-muted) !important;
  color: var(--text-primary);
}

[data-theme="dark"] .text-muted { color: var(--text-muted) !important; }
[data-theme="dark"] .text-dark { color: var(--text-primary) !important; }

[data-theme="dark"] pre,
[data-theme="dark"] code {
  background-color: var(--bg-muted) !important;
  color: var(--text-primary);
  border: 1px solid var(--border-color);
}

[data-theme="dark"] .page-link {
  background-color: var(--bg-surface);
  border-color: var(--border-color);
  color: var(--text-primary);
}

[data-theme="dark"] .page-item.active .page-link {
  background-color: var(--tgle-primary);
  border-color: var(--tgle-primary);
  color: #fff;
}

[data-theme="dark"] .btn-close {
  filter: invert(1) grayscale(100%) brightness(200%);
}

[data-theme="dark"] table.dataTable {
  color: var(--text-primary);
}

[data-theme="dark"] .dataTables_wrapper .dataTables_length,
[data-theme="dark"] .dataTables_wrapper .dataTables_filter,
[data-theme="dark"] .dataTables_wrapper .dataTables_info {
  color: var(--text-secondary);
}
