/*
 * base.css — Shared design tokens, reset, and background animations.
 * Imported by all pages to ensure visual consistency across the application.
 */
@import url('utilities.css');

/* ── Deploy version badge ── */
.app-version-badge {
  font-family: ui-monospace, 'Cascadia Code', 'Consolas', monospace;
  font-size: 0.68rem;
  letter-spacing: 0.04em;
  color: var(--muted2);
  pointer-events: none;
  user-select: none;
  text-align: center;
  white-space: nowrap;
}

#workspace-sidebar .app-version-badge.sidebar-version {
  display: block;
  width: 100%;
  margin-top: 10px;
  padding: 0 8px 4px;
  flex-shrink: 0;
  opacity: 0.85;
  line-height: 1.2;
  text-align: center;
  align-self: stretch;
}

.light-mode #workspace-sidebar .app-version-badge.sidebar-version {
  color: #64748b;
  opacity: 1;
}

/* ── Reset & Box Model ── */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* ── Design Tokens ── */
:root {
  /* Brand colors (Default: Orange/Amber) */
  --p-h: 38;
  --p-s: 92%;
  --p-l: 50%;

  --primary: hsl(var(--p-h), var(--p-s), var(--p-l));
  --primary-hover: hsl(var(--p-h), var(--p-s), calc(var(--p-l) - 8%));
  --primary-glow: hsla(var(--p-h), var(--p-s), var(--p-l), 0.3);
  --primary-gradient: linear-gradient(
    135deg,
    hsl(var(--p-h), var(--p-s), var(--p-l)),
    hsl(var(--p-h), var(--p-s), calc(var(--p-l) + 14%))
  );

  /* Surfaces */
  --bg: #06060f;
  --surface: #0d0d1a;
  --surface2: #12121b;
  --surface-hover: hsla(var(--p-h), var(--p-s), var(--p-l), 0.08);

  /* Borders */
  --border: hsla(var(--p-h), var(--p-s), var(--p-l), 0.15);
  --border2: hsla(var(--p-h), var(--p-s), var(--p-l), 0.25);
  --border-focus: hsla(var(--p-h), var(--p-s), var(--p-l), 0.70);

  /* Text */
  --text: #f1f5f9;
  --muted: #d6d3d1;
  --muted2: #a8a29e;

  /* Semantic */
  --error: #f87171;
  --success: #34d399;
  --warn: #fbbf24;
  --info: #60a5fa;

  /* Misc */
  --radius: 14px;
  --sidebar-width: 240px;
  --modal-bg: rgba(15, 15, 30, 0.95);
}

/* ── Light Mode Overrides ── */
.light-mode {
  --bg: #f8fafc;
  --surface: #ffffff;
  --surface2: #f1f5f9;
  --surface-hover: rgba(15, 23, 42, 0.05);

  --text: #0f172a;
  --muted: #475569;
  --muted2: #64748b;

  --border: hsla(var(--p-h), var(--p-s), var(--p-l), 0.12);
  --border2: hsla(var(--p-h), var(--p-s), var(--p-l), 0.20);

  --primary-glow: hsla(var(--p-h), var(--p-s), var(--p-l), 0.15);
  --modal-bg: #ffffff;
}

.light-mode .bg-orb {
  opacity: 0.15;
}

.light-mode body::before {
  background-image:
    linear-gradient(rgba(15, 23, 42, 0.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(15, 23, 42, 0.06) 1px, transparent 1px);
}

.light-mode .sidebar {
  background: rgba(255, 255, 255, 0.8);
}

.light-mode .topbar {
  background: rgba(255, 255, 255, 0.7);
}

/* ── Base Typography ── */
body {
  font-family: 'Inter', sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

/* ── Animated Background Orbs ── */
.bg-orb {
  position: fixed;
  border-radius: 50%;
  filter: blur(120px);
  opacity: 0.45;
  animation: orb-drift 14s ease-in-out infinite alternate;
  pointer-events: none;
  z-index: 0;
}

.bg-orb-1 {
  width: 560px;
  height: 560px;
  background: radial-gradient(circle, var(--primary), transparent);
  top: -160px;
  left: -160px;
  animation-delay: 0s;
}

.bg-orb-2 {
  width: 480px;
  height: 480px;
  background: radial-gradient(circle, hsla(var(--p-h), var(--p-s), var(--p-l), 0.5), transparent);
  bottom: -140px;
  right: -140px;
  animation-delay: -7s;
}

.bg-orb-3 {
  width: 300px;
  height: 300px;
  background: radial-gradient(circle, hsla(var(--p-h), var(--p-s), var(--p-l), 0.2), transparent);
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  animation-delay: -3s;
  opacity: 0.18;
}

@keyframes orb-drift {
  0% {
    transform: translate(0, 0) scale(1);
  }

  100% {
    transform: translate(40px, 30px) scale(1.08);
  }
}

/* ── Subtle Grid Overlay ── */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.06) 1px, transparent 1px);
  background-size: 48px 48px;
  pointer-events: none;
  z-index: 0;
}

/* ── Scrollbar Styling ── */
::-webkit-scrollbar {
  width: 5px;
  height: 5px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.12);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.22);
}

/* ── Utility: Visually Hidden (accessibility) ── */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}


/* ── Modern Tooltip System ── */
[data-tooltip] {
  position: relative;
  cursor: pointer;
}

[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 10px);
  left: 50%;
  transform: translateX(-50%) translateY(5px);
  background: rgba(15, 23, 42, 0.9);
  backdrop-filter: blur(8px);
  color: #fff;
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 0.72rem;
  font-weight: 500;
  white-space: nowrap;
  opacity: 0;
  visibility: hidden;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  z-index: 9999;
  border: 1px solid rgba(255, 255, 255, 0.1);
  pointer-events: none;
}

/* Arrow */
[data-tooltip]::before {
  content: "";
  position: absolute;
  bottom: calc(100% + 4px);
  left: 50%;
  transform: translateX(-50%) translateY(5px);
  border: 6px solid transparent;
  border-top-color: rgba(15, 23, 42, 0.9);
  opacity: 0;
  visibility: hidden;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 1000;
  pointer-events: none;
}

[data-tooltip]:hover::after,
[data-tooltip]:hover::before {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) translateY(0);
}

.light-mode [data-tooltip]::after {
  background: rgba(255, 255, 255, 0.95);
  color: #0f172a;
  border-color: #e2e8f0;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.light-mode [data-tooltip]::before {
  border-top-color: rgba(255, 255, 255, 0.95);
}

/* Tooltip Bottom Variant */
[data-tooltip].tooltip-bottom::after {
  bottom: auto;
  top: calc(100% + 10px);
}

[data-tooltip].tooltip-bottom::before {
  bottom: auto;
  top: calc(100% + 4px);
  border-top-color: transparent;
  border-bottom-color: rgba(15, 23, 42, 0.9);
}

.light-mode [data-tooltip].tooltip-bottom::before {
  border-bottom-color: rgba(255, 255, 255, 0.95);
}

/* Tooltip Bottom Left Variant (for right-aligned buttons) */
[data-tooltip].tooltip-bottom-left::after {
  bottom: auto;
  top: calc(100% + 10px);
  left: auto;
  right: 0;
  transform: translateY(5px);
}

[data-tooltip].tooltip-bottom-left::before {
  bottom: auto;
  top: calc(100% + 4px);
  left: auto;
  right: 15px;
  transform: translateY(5px);
  border-top-color: transparent;
  border-bottom-color: rgba(15, 23, 42, 0.9);
}

[data-tooltip].tooltip-bottom-left:hover::after,
[data-tooltip].tooltip-bottom-left:hover::before {
  transform: translateY(0);
}

.light-mode [data-tooltip].tooltip-bottom-left::before {
  border-bottom-color: rgba(255, 255, 255, 0.95);
}

/* Tooltip Right Variant (sidebar nav — avoids clipping at viewport top) */
[data-tooltip].tooltip-right::after {
  bottom: auto;
  top: 50%;
  left: calc(100% + 10px);
  right: auto;
  transform: translateY(-50%) translateX(-5px);
  white-space: normal;
  max-width: 220px;
  text-align: left;
}

[data-tooltip].tooltip-right::before {
  bottom: auto;
  top: 50%;
  left: calc(100% + 4px);
  right: auto;
  transform: translateY(-50%) translateX(-5px);
  border-top-color: transparent;
  border-right-color: rgba(15, 23, 42, 0.9);
  border-left: none;
  border-bottom-color: transparent;
}

[data-tooltip].tooltip-right:hover::after,
[data-tooltip].tooltip-right:hover::before {
  transform: translateY(-50%) translateX(0);
}

.light-mode [data-tooltip].tooltip-right::before {
  border-right-color: rgba(255, 255, 255, 0.95);
}

@media (max-width: 768px) {
  #workspace-sidebar [data-tooltip]::after,
  #workspace-sidebar [data-tooltip]::before {
    display: none !important;
  }
}

/* Resizable textareas: fixed width, vertical height only */
.modal textarea.styled-textarea,
.sm-section textarea,
.sm-layout .form-group textarea {
  resize: vertical;
  max-width: 100%;
  min-width: 0;
  max-height: min(280px, 40vh);
}

body.workspace-access-blocked #btn-add-widget,
body.workspace-access-blocked #btn-add-widget-empty,
body.workspace-access-blocked #dash-board-create-btn,
body.workspace-access-blocked .dash-board-create-btn,
body.workspace-access-blocked .dash-report-item-add,
body.workspace-access-blocked .history-new-btn,
body.workspace-access-blocked .suggestion,
body.workspace-access-blocked .btn-save-report,
body.workspace-access-blocked .btn-rerun-question,
body.workspace-access-blocked .widget-drag-handle,
body.workspace-access-blocked .widget-btn.danger,
body.workspace-access-blocked #question,
body.workspace-access-blocked #send-btn {
  opacity: 0.5 !important;
  pointer-events: none !important;
  cursor: not-allowed !important;
}

body.workspace-access-blocked .btn-rerun-question,
body.workspace-access-blocked .widget-footer-rerun,
body.workspace-access-blocked #btn-refresh-all,
body.workspace-access-blocked .widget-resize-handle,
body.workspace-access-blocked [data-requires-write-access] {
  opacity: 0.5 !important;
  pointer-events: none !important;
  cursor: not-allowed !important;
}

body.workspace-view-only .input-bar {
  position: relative;
}

body.workspace-view-only .input-bar--blocked,
body.workspace-access-blocked .input-bar--blocked {
  pointer-events: none;
}

body.workspace-view-only .input-bar--blocked::after,
body.workspace-access-blocked .input-bar--blocked::after {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 2;
  cursor: not-allowed;
}

body.workspace-view-only #question,
body.workspace-view-only #send-btn {
  pointer-events: none !important;
  opacity: 0.55;
}

.chat-access-block-notice,
.dashboard-access-block-notice {
  width: 100%;
  margin-bottom: 10px;
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 0.78rem;
  line-height: 1.45;
  background: rgba(248, 113, 113, 0.12);
  border: 1px solid rgba(248, 113, 113, 0.28);
  color: #fecaca;
}

.dashboard-access-block-notice {
  margin: 0 0 12px;
}

.light-mode .chat-access-block-notice,
.light-mode .dashboard-access-block-notice {
  background: rgba(254, 226, 226, 0.95);
  border-color: #fecaca;
  color: #991b1b;
}

.chat-access-block-notice.hidden,
.dashboard-access-block-notice.hidden {
  display: none;
}

.access-block-notice-link {
  color: inherit;
  font-weight: 700;
  text-decoration: underline;
  margin-left: 4px;
}

body.smart-tooltips-enabled [data-tooltip]::after,
body.smart-tooltips-enabled [data-tooltip]::before {
  display: none !important;
}

.smart-tooltip {
  position: fixed;
  z-index: 10050;
  max-width: min(260px, calc(100vw - 20px));
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 0.72rem;
  font-weight: 500;
  line-height: 1.35;
  color: #fff;
  background: rgba(15, 23, 42, 0.94);
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  pointer-events: none;
  animation: smart-tooltip-in 0.15s ease-out both;
}

.light-mode .smart-tooltip {
  color: #0f172a;
  background: rgba(255, 255, 255, 0.98);
  border-color: #e2e8f0;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
}

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

.locale-date-picker {
  position: relative;
  display: inline-flex;
}

.locale-date-input-native {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
}

.locale-date-trigger {
  cursor: pointer;
  text-align: left;
  min-width: 9.5rem;
}

.locale-date-trigger--empty {
  color: var(--muted);
}

.locale-date-popover {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  z-index: 1200;
  min-width: 260px;
  padding: 12px;
  border-radius: 12px;
  background: var(--surface2);
  border: 1px solid var(--border2);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.35);
}

.light-mode .locale-date-popover {
  background: #fff;
  border-color: #e2e8f0;
}

.locale-date-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}

.locale-date-month {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text);
  text-transform: capitalize;
}

.locale-date-nav {
  width: 28px;
  height: 28px;
  border-radius: 7px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
}

.locale-date-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
  margin-bottom: 6px;
}

.locale-date-weekdays span {
  font-size: 0.62rem;
  font-weight: 600;
  color: var(--muted);
  text-align: center;
  text-transform: capitalize;
}

.locale-date-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
}

.locale-date-spacer {
  aspect-ratio: 1;
}

.locale-date-day {
  aspect-ratio: 1;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  font-size: 0.75rem;
  cursor: pointer;
}

.locale-date-day:hover {
  background: rgba(245, 158, 11, 0.15);
}

.locale-date-day.selected {
  background: var(--primary);
  color: #fff;
  font-weight: 600;
}

.locale-date-day.today:not(.selected) {
  border: 1px solid rgba(245, 158, 11, 0.45);
}

.locale-date-footer {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}

.locale-date-action {
  border: none;
  background: none;
  color: var(--primary);
  font-size: 0.72rem;
  font-weight: 600;
  cursor: pointer;
  padding: 4px 6px;
}

.sm-rls-form-grid {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.sm-rls-form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  align-items: stretch;
}

.sm-rls-form-row .form-group {
  margin-bottom: 0;
  display: flex;
  flex-direction: column;
}

.sm-rls-form-row .form-group label {
  flex: 1 1 auto;
  min-height: 3.6rem;
}

.sm-rls-form-row select,
.sm-rls-form-row input[type="text"] {
  margin-top: auto;
  min-height: 42px;
}

.sm-rls-col-full {
  grid-column: 1 / -1;
}

@media (max-width: 640px) {
  .sm-rls-form-row {
    grid-template-columns: 1fr;
  }

  .sm-rls-form-row .form-group label {
    min-height: auto;
  }
}


/* Access-blocked controls (trial expired / payment pending) */
.access-blocked,
button.access-blocked:disabled,
textarea.access-blocked:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.trial-status-banner--payment {
  background: rgba(248, 113, 113, 0.12);
  border-color: rgba(248, 113, 113, 0.35);
  color: #fecaca;
}

.light-mode .trial-status-banner--payment {
  background: rgba(254, 226, 226, 0.95);
  border-color: #fecaca;
  color: #991b1b;
}

.sm-rls-example {
  font-size: 0.75rem;
  color: var(--muted);
  background: rgba(99, 102, 241, 0.08);
  border: 1px solid rgba(99, 102, 241, 0.2);
  border-radius: 8px;
  padding: 10px 14px;
  margin: 0 0 14px;
  line-height: 1.5;
}

.sm-rls-summary {
  font-size: 0.78rem;
  color: var(--text);
  line-height: 1.4;
}

.sm-rls-field-hint {
  display: block;
  font-size: 0.68rem;
  font-weight: 400;
  color: var(--muted);
  text-transform: none;
  letter-spacing: normal;
  margin-top: 4px;
  line-height: 1.4;
}


/* Native <select> dropdown list — dark mode uses app surfaces (not OS light popup) */
select option,
select optgroup {
  background-color: var(--surface2);
  color: var(--text);
}

select optgroup {
  color: var(--muted);
  font-style: normal;
  font-weight: 600;
}

#save-report-folder option,
#theme-mode-select option,
#edit-report-folder option,
.dashboard-date-select option,
.dashboard-board-select option {
  background-color: var(--surface2);
  color: var(--text);
}

.light-mode select option,
.light-mode select optgroup {
  background-color: #ffffff;
  color: #0f172a;
}

.light-mode select optgroup {
  color: #64748b;
}

.light-mode select {
  background-color: rgba(15, 23, 42, 0.05);
  color: #0f172a;
  border-color: rgba(15, 23, 42, 0.1);
}

/* ── Light Mode Core UI Overrides ── */
.light-mode .sidebar {
  background: #f1f5f9;
  border-color: #e2e8f0;
}

.light-mode .topbar {
  background: rgba(255, 255, 255, 0.8);
  border-color: #e2e8f0;
  backdrop-filter: blur(20px);
}

.light-mode .nav-btn:hover {
  background: rgba(15, 23, 42, 0.05);
}

.light-mode .nav-btn.active {
  background: hsla(var(--p-h), var(--p-s), var(--p-l), 0.1);
  border-color: hsla(var(--p-h), var(--p-s), var(--p-l), 0.2);
}

.light-mode .user-card {
  background: rgba(15, 23, 42, 0.04);
  border-color: #e2e8f0;
}

/* ── Light Mode Chat & Reports Overrides (Consolidated) ── */
.light-mode .input-bar,
.light-mode .folders-sidebar,
.light-mode .viewer-header {
  background: rgba(241, 245, 249, 0.72);
  backdrop-filter: blur(10px);
  border-color: #e2e8f0;
  color: #0f172a;
}

.light-mode .reports-main {
  background: transparent;
  border-color: #e2e8f0;
  color: #0f172a;
}

.light-mode .msg-row.ai-row .msg-bubble,
.light-mode .report-card,
.light-mode .data-card,
.light-mode .chart-card,
.light-mode .kpi-card,
.light-mode .modal,
.light-mode .input-wrap {
  background: white;
  border-color: #e2e8f0;
  color: #0f172a;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
}

.light-mode .msg-bubble.ai-text strong,
.light-mode .msg-bubble.ai-text h3,
.light-mode .msg-bubble.ai-text h4,
.light-mode .msg-bubble.ai-text h5,
.light-mode .kpi-value,
.light-mode .report-title,
.light-mode .topbar-title {
  color: #0f172a;
}

.light-mode .msg-bubble.ai-text em,
.light-mode .kpi-label,
.light-mode .topbar-sub,
.light-mode .report-question {
  color: #64748b;
}

.light-mode th {
  background: #f8fafc;
  color: #475569;
}

.light-mode td {
  color: #1e293b;
}

/* ── Toast Notifications ── */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 18px;
  border-radius: 10px;
  font-size: .82rem;
  font-weight: 500;
  backdrop-filter: blur(12px);
  box-shadow: 0 8px 32px rgba(0, 0, 0, .4);
  animation: toast-in .35s cubic-bezier(.34, 1.56, .64, 1) both;
  max-width: 320px;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateX(20px)
  }

  to {
    opacity: 1;
    transform: translateX(0)
  }
}

.toast.success {
  background: rgba(52, 211, 153, .15);
  border: 1px solid rgba(52, 211, 153, .3);
  color: var(--success);
}

.toast.error {
  background: rgba(248, 113, 113, .15);
  border: 1px solid rgba(248, 113, 113, .3);
  color: var(--error);
}

.toast.info {
  background: rgba(245, 158, 11, .15);
  border: 1px solid rgba(245, 158, 11, .3);
  color: #fbbf24;
}

/* ── Modal Overlay & Dialog (Shared) ── */
.modal-overlay {
  display: none;
  position: fixed; inset: 0; z-index: 3000;
  background: rgba(0,0,0,.65);
  backdrop-filter: blur(6px);
  align-items: center; justify-content: center;
  animation: fade-in .2s ease;
}
.modal-overlay.open { display: flex; }
@keyframes fade-in { from{opacity:0} to{opacity:1} }

.modal {
  display: flex;
  flex-direction: column;
  background: var(--modal-bg); border: 1px solid var(--border2);
  border-radius: 18px; padding: 32px;
  width: 100%; max-width: 440px; margin: 20px;
  box-shadow: 0 24px 80px rgba(0,0,0,.7), inset 0 1px 0 rgba(255,255,255,.06);
  animation: modal-in .3s cubic-bezier(.34,1.56,.64,1) both;
  position: relative;
  z-index: 3001;
  max-height: calc(100vh - 40px);
}
@keyframes modal-in { from{opacity:0;transform:scale(.95) translateY(12px)} to{opacity:1;transform:scale(1) translateY(0)} }

.modal-body {
  overflow-y: auto;
  flex: 1;
  padding-right: 6px;
  margin-right: -6px;
  margin-bottom: 8px;
  
  /* Scroll shadows */
  background:
    /* Shadow covers */
    linear-gradient(var(--modal-bg) 30%, rgba(255,255,255,0)),
    linear-gradient(rgba(255,255,255,0), var(--modal-bg) 70%) 0 100%,
    
    /* Shadows */
    radial-gradient(farthest-side at 50% 0, rgba(0,0,0,.35), rgba(0,0,0,0)),
    radial-gradient(farthest-side at 50% 100%, rgba(0,0,0,.35), rgba(0,0,0,0)) 0 100%;
  background-repeat: no-repeat;
  background-size: 100% 20px, 100% 20px, 100% 10px, 100% 10px;
  background-attachment: local, local, scroll, scroll;
}

.modal-body::-webkit-scrollbar {
  width: 6px;
}
.modal-body::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.03);
  border-radius: 3px;
}
.light-mode .modal-body::-webkit-scrollbar-track {
  background: rgba(15, 23, 42, 0.03);
}
.modal-body::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.2);
  border-radius: 3px;
}
.light-mode .modal-body::-webkit-scrollbar-thumb {
  background: rgba(15, 23, 42, 0.2);
}
.modal-body::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.35);
}
.light-mode .modal-body::-webkit-scrollbar-thumb:hover {
  background: rgba(15, 23, 42, 0.35);
}

.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 24px;
}
.modal-header h3 { font-size: 1rem; font-weight: 700; color: var(--text); }
.modal-close {
  width: 28px; height: 28px; border-radius: 7px;
  background: rgba(255,255,255,.07); border: 1px solid var(--border);
  color: var(--muted); font-size: 16px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all .2s;
}
.modal-close:hover { background: rgba(255,255,255,.12); color: var(--text); }

.modal .form-group { margin-bottom: 16px; }
.modal label {
  display: block; font-size: .75rem; font-weight: 600;
  color: var(--muted); letter-spacing: .06em;
  text-transform: uppercase; margin-bottom: 6px;
}
.modal input,
.modal select,
.modal textarea.styled-textarea {
  width: 100%; padding: 10px 14px;
  background: rgba(255,255,255,.05); border: 1.5px solid var(--border);
  border-radius: 9px; color: var(--text);
  font-family: 'Inter', sans-serif; font-size: .88rem; outline: none;
  transition: border-color .2s, box-shadow .2s;
  appearance: none;
  box-sizing: border-box;
}
.modal input:focus,
.modal select:focus,
.modal textarea.styled-textarea:focus {
  border-color: rgba(245,158,11,.6);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

.modal-footer { display: flex; gap: 10px; margin-top: 24px; }
.modal-footer .btn-primary { flex: 1; justify-content: center; }

.modal-footer-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 0;
  flex-shrink: 0;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.modal-footer-actions .btn-primary,
.modal-footer-actions .btn-secondary {
  flex: 0 0 auto;
}

.modal-wide {
  max-width: 520px;
}

.modal-xl {
  max-width: 800px;
  padding: 24px;
}

.modal-xl .modal-body {
  text-align: center;
}

.modal-xl .modal-body img {
  max-width: 100%;
  border-radius: 8px;
  border: 1px solid var(--border2);
}

.modal-demo .modal-body {
  text-align: center;
}

.modal-demo h3 {
  font-size: 1.2rem;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--text);
}

.modal-demo-icon {
  font-size: 2.5rem;
  margin-bottom: 12px;
}

.modal-demo-lead {
  font-size: 0.9rem;
  color: var(--muted);
  line-height: 1.5;
  margin-bottom: 20px;
}

.modal-message {
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.5;
  margin-bottom: 16px;
}

.modal-actions-stack {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.btn-danger-outline {
  color: var(--error) !important;
  border-color: var(--error) !important;
}

.btn-danger-outline:hover {
  background: rgba(248, 113, 113, 0.1) !important;
}

.modal-alert {
  display: none;
  align-items: center;
  gap: 8px;
  padding: 10px 13px;
  border-radius: 8px;
  font-size: 0.8rem;
  font-weight: 500;
  margin-bottom: 14px;
}

.modal-alert.error {
  background: rgba(248, 113, 113, 0.12);
  border: 1px solid rgba(248, 113, 113, 0.3);
  color: var(--error);
  display: flex;
}

.modal-alert[hidden],
.modal-alert.hidden {
  display: none !important;
}

.modal-history-section {
  margin-top: 8px;
  border-top: 1px solid var(--border);
  padding-top: 12px;
}

.modal-history-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 8px 4px;
  border: none;
  background: none;
  color: var(--muted);
  font-family: 'Inter', sans-serif;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  cursor: pointer;
  transition: color 0.15s;
}

.modal-history-toggle:hover {
  color: var(--text);
}

.modal-history-chevron {
  flex-shrink: 0;
  color: var(--muted2);
  transition: transform 0.18s;
}

.modal-history-toggle[aria-expanded="true"] .modal-history-chevron {
  transform: rotate(90deg);
}

.modal-history-body {
  padding: 8px 4px 4px;
}

.modal-history-list {
  max-height: 160px;
  overflow-y: auto;
  font-size: 0.82rem;
  color: var(--muted);
  line-height: 1.45;
}

.modal-history-entry {
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
}

.modal-history-entry:last-child {
  border-bottom: none;
}

.modal-history-entry strong {
  color: var(--text);
  font-weight: 500;
}

/* ── Standard Buttons ── */
.btn-primary {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 20px;
  background: var(--primary-gradient);
  background-color: var(--primary);
  color: #fff !important; border: none; border-radius: 10px;
  font-family: 'Inter', sans-serif; font-size: .85rem; font-weight: 600;
  cursor: pointer; transition: all .2s;
  box-shadow: 0 4px 16px var(--primary-glow);
  white-space: nowrap;
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 6px 22px var(--primary-glow); }
.btn-primary:active { transform: translateY(0); }

.btn-secondary {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 10px 20px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--muted);
  border: 1.5px solid rgba(148, 163, 184, 0.22);
  border-radius: 10px;
  font-family: 'Inter', sans-serif; font-size: .85rem; font-weight: 500;
  cursor: pointer; transition: all .2s;
}
.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  border-color: rgba(148, 163, 184, 0.35);
}

.light-mode .btn-secondary {
  background: var(--surface);
  border-color: #e2e8f0;
  color: var(--muted);
}
.light-mode .btn-secondary:hover {
  background: var(--surface2);
  color: var(--text);
  border-color: #cbd5e1;
}

/* ── Icon Button (shared across admin, superuser, reports) ── */
.btn-icon {
  width: 30px;
  height: 30px;
  border-radius: 7px;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 13px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  flex-shrink: 0;
}

/* ── Custom Confirm Modal Specifics ── */
.confirm-modal {
  max-width: 380px !important;
  text-align: center;
  padding: 40px 32px !important;
}
.confirm-modal-icon {
  font-size: 48px;
  margin-bottom: 20px;
}
.confirm-modal h3 {
  font-size: 1.25rem;
  margin-bottom: 12px;
}
.confirm-modal p {
  font-size: 0.9rem;
  color: var(--muted);
  line-height: 1.5;
  margin-bottom: 30px;
}
.confirm-modal .modal-footer {
  margin-top: 0;
}

/* ── Trial status banner (in-flow, below page topbar) ── */
.trial-status-banner {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
  width: 100%;
  margin: 0;
  padding: 8px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 0.8125rem;
  line-height: 1.4;
  z-index: 4;
}
.trial-status-banner.hidden {
  display: none;
}
.trial-status-banner--active {
  background: rgba(245, 158, 11, 0.08);
  color: var(--text);
  border-bottom-color: rgba(245, 158, 11, 0.25);
}
.light-mode .trial-status-banner--active {
  background: rgba(245, 158, 11, 0.1);
}
.trial-status-banner--expired {
  background: rgba(225, 29, 72, 0.1);
  color: var(--text);
  border-bottom-color: rgba(225, 29, 72, 0.35);
}
.light-mode .trial-status-banner--expired {
  background: rgba(225, 29, 72, 0.08);
}
.trial-status-banner__inner {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  width: 100%;
  max-width: 1200px;
}
.trial-status-banner__icon {
  flex-shrink: 0;
}
.trial-status-banner__text {
  flex: 1;
  min-width: 160px;
}
.trial-status-banner__btn {
  margin-left: auto;
  text-decoration: none;
  white-space: nowrap;
}
.trial-status-banner__hint {
  color: var(--muted);
  font-size: 0.8rem;
  margin-left: auto;
}
body.dashboard-presentation-mode .trial-status-banner,
body.dashboard-embed-mode .trial-status-banner {
  display: none !important;
}
@media (max-width: 768px) {
  .trial-status-banner {
    padding: 8px 12px;
  }
  .trial-status-banner__inner {
    gap: 8px;
  }
  .trial-status-banner__btn {
    width: 100%;
    text-align: center;
    margin-left: 0;
  }
}
.pricing-trial-hint {
  text-align: center;
  color: var(--muted);
  font-size: 0.875rem;
  margin: 0 0 24px;
  padding: 10px 14px;
  border-radius: 8px;
  background: rgba(245, 158, 11, 0.08);
  border: 1px solid rgba(245, 158, 11, 0.2);
}
.pricing-trial-hint--expired {
  background: rgba(225, 29, 72, 0.08);
  border-color: rgba(225, 29, 72, 0.25);
  color: var(--text);
}
.chat-notice-hint {
  color: var(--muted);
  font-size: 0.875rem;
}

.light-mode .modal {
  background: white;
  border-color: #e2e8f0;
}