/* ================================================================
   TwoX Control Center — Professional Design System v3.0
   ================================================================
   This file is the SOLE source of visual truth.
   It loads AFTER the legacy styles.css and overrides everything
   using high-specificity selectors with !important where needed.
   ================================================================ */

/* ---- 1. DESIGN TOKENS ---- */
:root {
  /* Typography */
  --twox-font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;

  /* Palette — WCAG AA compliant on white surfaces */
  --twox-text:       #111827;   /* primary text — 15.4:1 on white  */
  --twox-secondary:  #475569;   /* secondary text — 7.0:1 on white */
  --twox-muted:      #64748B;   /* auxiliary text — 4.6:1 on white */
  --twox-bg:         #F8FAFC;
  --twox-surface:    #FFFFFF;
  --twox-subtle:     #F1F5F9;
  --twox-inset:      #EEF2F6;
  --twox-border:     #E2E8F0;
  --twox-border-strong: #CBD5E1;

  /* Brand */
  --twox-brand:      #155E75;
  --twox-brand-hover:#0E4D5F;
  --twox-brand-soft: #E6F3F7;

  /* Semantic */
  --twox-success:    #16794C;
  --twox-success-soft:#E8F6EE;
  --twox-warning:    #92400E;
  --twox-warning-soft:#FEF3C7;
  --twox-danger:     #B42318;
  --twox-danger-soft: #FEE2E2;
  --twox-info:       #1D4ED8;
  --twox-info-soft:  #DBEAFE;

  /* Layout */
  --twox-radius:     10px;
  --twox-radius-sm:  6px;
  --twox-shadow:     0 1px 2px rgba(0,0,0,.05);
  --twox-shadow-md:  0 4px 12px rgba(0,0,0,.06);
  --twox-focus:      0 0 0 3px rgba(21,94,117,.22);
  --sidebar-width:   260px;
}


/* ---- 2. GLOBAL RESET / BASE ---- */
html {
  font-family: var(--twox-font-sans) !important;
  font-size: 16px !important;
  line-height: 1.5 !important;
  background: var(--twox-bg) !important;
  color: var(--twox-text) !important;
  overflow-x: hidden;
}

body, body.twox-system-scope {
  font-family: var(--twox-font-sans) !important;
  background: var(--twox-bg) !important;
  color: var(--twox-text) !important;
  background-image: none !important;
  overflow-x: hidden;
  max-width: 100%;
}

/* Kill all legacy dark-theme gradients */
body.twox-system-scope {
  background-color: var(--twox-bg) !important;
}

/* Skip link */
.twox-skip-link {
  position: fixed; left: 12px; top: -50px; z-index: 4000;
  padding: 8px 14px; background: var(--twox-brand); color: #fff;
  border-radius: var(--twox-radius-sm); font-weight: 650;
  text-decoration: none; transition: top .15s ease;
}
.twox-skip-link:focus { top: 12px; }


/* ---- 3. TYPOGRAPHY ---- */
body.twox-system-scope h1,
body.twox-system-scope h2,
body.twox-system-scope h3,
body.twox-system-scope h4 {
  color: var(--twox-text) !important;
  letter-spacing: -0.02em !important;
  line-height: 1.25 !important;
}

body.twox-system-scope p,
body.twox-system-scope span,
body.twox-system-scope div,
body.twox-system-scope li,
body.twox-system-scope label {
  color: var(--twox-text);
}

body.twox-system-scope .cell-subtext {
  color: var(--twox-secondary) !important;
}

body.twox-system-scope small,
body.twox-system-scope .text-muted {
  color: var(--twox-muted) !important;
}


/* ---- 4. SIDEBAR ---- */
body.twox-system-scope .app-sidebar {
  background: var(--twox-surface) !important;
  border-right: 1px solid var(--twox-border) !important;
  box-shadow: none !important;
  backdrop-filter: none !important;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--twox-border-strong) transparent;
}

body.twox-system-scope .brand {
  border-bottom: 1px solid var(--twox-border);
  padding: 20px 18px;
}

body.twox-system-scope .brand-icon,
body.twox-system-scope .login-brand-icon {
  background: var(--twox-brand) !important;
  box-shadow: none !important;
  border-radius: 9px !important;
}

body.twox-system-scope .brand-title {
  color: var(--twox-text) !important;
  font-weight: 750 !important;
  letter-spacing: -0.02em !important;
}

body.twox-system-scope .brand-badge {
  background: var(--twox-brand-soft) !important;
  color: var(--twox-brand) !important;
  text-transform: none !important;
  border-radius: 5px !important;
}

/* Nav section labels */
.nav-section-label {
  padding: 16px 14px 6px !important;
  color: var(--twox-muted) !important;
  font-size: 10px !important;
  font-weight: 700 !important;
  letter-spacing: 0.06em !important;
  text-transform: uppercase !important;
}
.nav-section-label:first-child { padding-top: 6px !important; }

body.twox-system-scope .nav-menu {
  padding: 10px 10px !important;
}

/* Nav items — OVERRIDE ALL inline styles */
body.twox-system-scope .nav-item,
body.twox-system-scope .nav-item[style] {
  color: var(--twox-secondary) !important;
  background: transparent !important;
  border: none !important;
  border-radius: 7px !important;
  padding: 9px 12px !important;
  margin: 1px 0 !important;
  min-height: 38px !important;
  font-size: 13.5px !important;
  font-weight: 500 !important;
  transition: background .15s ease, color .15s ease !important;
  display: flex !important;
  align-items: center !important;
  gap: 10px !important;
  cursor: pointer !important;
  text-decoration: none !important;
}

body.twox-system-scope .nav-item:hover,
body.twox-system-scope .nav-item[style]:hover {
  background: var(--twox-subtle) !important;
  color: var(--twox-text) !important;
}

body.twox-system-scope .nav-item.active,
body.twox-system-scope .nav-item.active[style] {
  background: var(--twox-brand-soft) !important;
  color: var(--twox-brand) !important;
  font-weight: 650 !important;
  box-shadow: inset 3px 0 0 var(--twox-brand) !important;
  border: none !important;
}

body.twox-system-scope .nav-item svg {
  width: 17px !important;
  height: 17px !important;
  opacity: 0.78 !important;
  flex-shrink: 0 !important;
}

/* Sidebar footer */
body.twox-system-scope .sidebar-footer {
  border-top: 1px solid var(--twox-border) !important;
}

body.twox-system-scope .api-status-card {
  background: var(--twox-subtle) !important;
  border: 1px solid var(--twox-border) !important;
}

body.twox-system-scope .status-label {
  color: var(--twox-muted) !important;
  font-size: 11px !important;
}

body.twox-system-scope .status-val {
  color: var(--twox-success) !important;
}

/* Sidebar pending badge — override inline background */
body.twox-system-scope #sidebar-pending-badge {
  background: var(--twox-danger) !important;
  color: #fff !important;
  font-size: 10px !important;
  font-weight: 700 !important;
  padding: 2px 7px !important;
  border-radius: 10px !important;
}


/* ---- 5. MAIN CONTENT AREA ---- */
body.twox-system-scope .app-main {
  background: var(--twox-bg) !important;
  padding: 28px 34px 48px !important;
  color: var(--twox-text) !important;
}

body.twox-system-scope .top-header {
  border-bottom: 1px solid var(--twox-border) !important;
  padding-bottom: 20px !important;
  margin-bottom: 24px !important;
}

body.twox-system-scope #page-title {
  color: var(--twox-text) !important;
  font-size: 26px !important;
  font-weight: 700 !important;
  letter-spacing: -0.025em !important;
}

body.twox-system-scope #page-subtitle {
  color: var(--twox-secondary) !important;
  font-size: 13px !important;
  margin-top: 4px !important;
}

/* Header profile button — override inline styles */
body.twox-system-scope #user-profile-btn,
body.twox-system-scope #user-profile-btn[style] {
  background: var(--twox-surface) !important;
  border: 1px solid var(--twox-border) !important;
  border-radius: 8px !important;
  color: var(--twox-text) !important;
}

body.twox-system-scope #header-user-avatar,
body.twox-system-scope #header-user-avatar[style] {
  background: var(--twox-brand-soft) !important;
  color: var(--twox-brand) !important;
  border: 1px solid #B9DCE5 !important;
}

body.twox-system-scope #header-user-name,
body.twox-system-scope #header-user-name[style] {
  color: var(--twox-text) !important;
  font-weight: 650 !important;
}

body.twox-system-scope #header-user-role-text,
body.twox-system-scope #header-user-role-text[style] {
  color: var(--twox-brand) !important;
}

/* Profile dropdown */
body.twox-system-scope .profile-dropdown-menu,
body.twox-system-scope #user-profile-dropdown,
body.twox-system-scope #user-profile-dropdown[style] {
  background: var(--twox-surface) !important;
  border: 1px solid var(--twox-border) !important;
  border-radius: 10px !important;
  box-shadow: var(--twox-shadow-md) !important;
  color: var(--twox-text) !important;
}

body.twox-system-scope .profile-dropdown-menu *,
body.twox-system-scope #user-profile-dropdown * {
  color: var(--twox-text) !important;
}

body.twox-system-scope #user-profile-dropdown .user-role-option:hover {
  background: var(--twox-subtle) !important;
}


/* ---- 6. CARDS ---- */
body.twox-system-scope .content-card,
body.twox-system-scope .content-card[style],
body.twox-system-scope .metric-card,
body.twox-system-scope .metric-card[style],
body.twox-system-scope .card {
  background: var(--twox-surface) !important;
  color: var(--twox-text) !important;
  border: 1px solid var(--twox-border) !important;
  border-radius: var(--twox-radius) !important;
  box-shadow: var(--twox-shadow) !important;
  backdrop-filter: none !important;
}

body.twox-system-scope .content-card {
  padding: 22px !important;
  margin-bottom: 20px !important;
}

body.twox-system-scope .content-card h2 {
  font-size: 18px !important;
  font-weight: 650 !important;
  color: var(--twox-text) !important;
}

body.twox-system-scope .content-card h3 {
  font-size: 16px !important;
  font-weight: 600 !important;
  color: var(--twox-text) !important;
}

body.twox-system-scope .content-card p {
  color: var(--twox-secondary) !important;
  font-size: 13px !important;
  line-height: 1.5 !important;
}


/* ---- 7. METRIC CARDS ---- */
body.twox-system-scope .metric-card {
  padding: 18px 20px !important;
}

body.twox-system-scope .metric-card:hover {
  transform: none !important;
  border-color: var(--twox-border-strong) !important;
}

body.twox-system-scope .metric-title {
  color: var(--twox-secondary) !important;
  font-size: 12px !important;
  font-weight: 550 !important;
  letter-spacing: 0 !important;
  text-transform: none !important;
}

body.twox-system-scope .metric-value,
body.twox-system-scope .metric-value[style] {
  color: var(--twox-text) !important;
  font-size: 28px !important;
  font-weight: 700 !important;
  line-height: 1.2 !important;
  font-variant-numeric: tabular-nums !important;
  letter-spacing: -0.02em !important;
}

body.twox-system-scope .metric-footer {
  color: var(--twox-muted) !important;
  font-size: 12px !important;
}

body.twox-system-scope .metric-footer span {
  color: var(--twox-muted) !important;
}

body.twox-system-scope .metric-icon,
body.twox-system-scope .metric-icon[style] {
  width: 32px !important;
  height: 32px !important;
  border-radius: 8px !important;
}

/* Metrics grid */
body.twox-system-scope .metrics-grid {
  gap: 16px !important;
  margin-bottom: 24px !important;
}

/* Overview section label */
.overview-section-label {
  font-size: 11px !important;
  font-weight: 700 !important;
  color: var(--twox-muted) !important;
  text-transform: uppercase !important;
  letter-spacing: 0.06em !important;
  margin: 0 0 10px !important;
}


/* ---- 8. TABLES ---- */
body.twox-system-scope table {
  color: var(--twox-text) !important;
  border-collapse: collapse !important;
  width: 100% !important;
}

body.twox-system-scope th {
  background: var(--twox-subtle) !important;
  color: var(--twox-secondary) !important;
  border-bottom: 1px solid var(--twox-border) !important;
  text-transform: none !important;
  letter-spacing: 0 !important;
  font-size: 12px !important;
  font-weight: 650 !important;
  padding: 10px 14px !important;
  white-space: nowrap !important;
}

body.twox-system-scope td {
  color: var(--twox-text) !important;
  border-bottom: 1px solid #EDF1F4 !important;
  padding: 10px 14px !important;
  font-size: 13.5px !important;
  vertical-align: middle !important;
}

body.twox-system-scope tr:last-child td {
  border-bottom: none !important;
}

body.twox-system-scope tr:hover td {
  background: rgba(241,245,249,.5) !important;
}

body.twox-system-scope .cell-bold {
  font-weight: 600 !important;
  color: var(--twox-text) !important;
}

body.twox-system-scope .table-container {
  max-width: 100% !important;
  overflow-x: auto !important;
  scrollbar-color: #94A3B8 #F1F5F9;
}


/* ---- 9. BUTTONS ---- */
body.twox-system-scope .btn,
body.twox-system-scope button {
  border-radius: var(--twox-radius-sm) !important;
  box-shadow: none !important;
  min-height: 36px !important;
  font-weight: 600 !important;
  font-size: 13px !important;
  cursor: pointer !important;
  transition: background .15s ease, border-color .15s ease !important;
  font-family: var(--twox-font-sans) !important;
}

body.twox-system-scope .btn-primary,
body.twox-system-scope .btn-primary[style] {
  background: var(--twox-brand) !important;
  color: #fff !important;
  border: 1px solid var(--twox-brand) !important;
}

body.twox-system-scope .btn-primary:hover {
  background: var(--twox-brand-hover) !important;
}

body.twox-system-scope .btn-outline,
body.twox-system-scope .btn-outline[style] {
  background: var(--twox-surface) !important;
  border: 1px solid var(--twox-border-strong) !important;
  color: var(--twox-secondary) !important;
}

body.twox-system-scope .btn-outline:hover {
  background: var(--twox-subtle) !important;
  color: var(--twox-text) !important;
}


/* ---- 10. FORMS ---- */
body.twox-system-scope input,
body.twox-system-scope select,
body.twox-system-scope textarea {
  background: #fff !important;
  color: var(--twox-text) !important;
  border: 1px solid var(--twox-border-strong) !important;
  border-radius: var(--twox-radius-sm) !important;
  min-height: 38px !important;
  font-family: var(--twox-font-sans) !important;
  font-size: 14px !important;
}

body.twox-system-scope input::placeholder,
body.twox-system-scope textarea::placeholder {
  color: var(--twox-muted) !important;
  opacity: 1 !important;
}

body.twox-system-scope input:focus,
body.twox-system-scope select:focus,
body.twox-system-scope textarea:focus {
  border-color: var(--twox-brand) !important;
  box-shadow: var(--twox-focus) !important;
  outline: none !important;
}

body.twox-system-scope button:focus-visible,
body.twox-system-scope a:focus-visible,
body.twox-system-scope input:focus-visible,
body.twox-system-scope select:focus-visible,
body.twox-system-scope textarea:focus-visible {
  outline: none !important;
  box-shadow: var(--twox-focus) !important;
}


/* ---- 11. BADGES ---- */
body.twox-system-scope .badge {
  font-weight: 600 !important;
  font-size: 12px !important;
  border-radius: 5px !important;
  padding: 3px 8px !important;
}

body.twox-system-scope .badge-info,
body.twox-system-scope .badge[style*="59, 130, 246"],
body.twox-system-scope .badge[style*="139, 92, 246"],
body.twox-system-scope .badge[style*="139,92,246"] {
  background: var(--twox-brand-soft) !important;
  color: var(--twox-brand) !important;
}

body.twox-system-scope .badge-success {
  background: var(--twox-success-soft) !important;
  color: var(--twox-success) !important;
}

body.twox-system-scope .badge-danger,
body.twox-system-scope .badge[style*="239, 68, 68"],
body.twox-system-scope .badge[style*="239,68,68"] {
  background: var(--twox-danger-soft) !important;
  color: var(--twox-danger) !important;
}

body.twox-system-scope .badge-warning,
body.twox-system-scope .badge[style*="245, 158, 11"],
body.twox-system-scope .badge[style*="245,158,11"] {
  background: var(--twox-warning-soft) !important;
  color: var(--twox-warning) !important;
}

body.twox-system-scope .badge-primary {
  background: var(--twox-brand-soft) !important;
  color: var(--twox-brand) !important;
  border: 1px solid rgba(21, 94, 117, 0.2) !important;
}

body.twox-system-scope .badge-secondary {
  background: var(--twox-subtle) !important;
  color: var(--twox-secondary) !important;
  border: 1px solid var(--twox-border) !important;
}

body.twox-system-scope .badge-subtle {
  background: #F1F5F9 !important;
  color: #475569 !important;
  border: 1px solid #E2E8F0 !important;
  font-weight: 500 !important;
}

body.twox-system-scope .btn-sm {
  padding: 4px 10px !important;
  font-size: 12px !important;
  line-height: 1.4 !important;
  font-weight: 500 !important;
  border-radius: var(--twox-radius-sm) !important;
}

body.twox-system-scope .view-toggle-group {
  display: inline-flex !important;
  background: #F1F5F9 !important;
  border: 1px solid var(--twox-border) !important;
  border-radius: var(--twox-radius-sm) !important;
  padding: 2px !important;
  gap: 2px !important;
}

body.twox-system-scope .view-toggle-btn {
  background: transparent !important;
  border: none !important;
  border-radius: 4px !important;
  padding: 6px 14px !important;
  font-size: 13px !important;
  font-weight: 500 !important;
  color: var(--twox-secondary) !important;
  cursor: pointer !important;
  transition: all 0.15s ease !important;
}

body.twox-system-scope .view-toggle-btn.active {
  background: #FFFFFF !important;
  color: var(--twox-text) !important;
  font-weight: 600 !important;
  box-shadow: 0 1px 2px rgba(0,0,0,0.06) !important;
}

body.twox-system-scope .login-screen-backdrop {
  background: var(--twox-bg) !important;
  backdrop-filter: none !important;
  min-height: 100dvh !important;
  height: auto !important;
  padding: 24px !important;
  overflow-y: auto !important;
}

body.twox-system-scope .login-card-box {
  background: #fff !important;
  border: 1px solid var(--twox-border) !important;
  border-radius: 12px !important;
  box-shadow: 0 12px 30px rgba(23,33,43,.10) !important;
  max-width: 460px !important;
  padding: 28px !important;
  gap: 18px !important;
  margin: auto !important;
}

body.twox-system-scope .login-title {
  color: var(--twox-text) !important;
  font-size: 20px !important;
  font-weight: 700 !important;
}

body.twox-system-scope .login-subtitle {
  color: var(--twox-secondary) !important;
  font-size: 13px !important;
}

body.twox-system-scope .login-field-label {
  color: var(--twox-secondary) !important;
  font-size: 13px !important;
  font-weight: 550 !important;
  margin-bottom: 7px !important;
}

body.twox-system-scope .login-input-field {
  background: #fff !important;
  color: var(--twox-text) !important;
  border: 1px solid var(--twox-border-strong) !important;
  border-radius: var(--twox-radius-sm) !important;
  font-size: 14px !important;
  min-height: 42px !important;
  padding: 10px 12px !important;
}

body.twox-system-scope .login-input-field option {
  color: var(--twox-text) !important;
  background: #fff !important;
}

body.twox-system-scope .login-input-field:focus {
  border-color: var(--twox-brand) !important;
  box-shadow: var(--twox-focus) !important;
}

body.twox-system-scope .login-submit-btn {
  margin-top: 12px !important;
  min-height: 42px !important;
}

body.twox-system-scope .login-credentials-hint {
  display: none !important;
}


/* ---- 13. MODALS ---- */
body.twox-system-scope .modal-backdrop {
  background: rgba(15,23,42,.4) !important;
  backdrop-filter: blur(4px) !important;
}

body.twox-system-scope .modal-card {
  background: var(--twox-surface) !important;
  border: 1px solid var(--twox-border) !important;
  border-radius: 12px !important;
  box-shadow: 0 20px 40px rgba(0,0,0,.15) !important;
  color: var(--twox-text) !important;
}

body.twox-system-scope .modal-header {
  border-bottom: 1px solid var(--twox-border) !important;
}

body.twox-system-scope .modal-title {
  color: var(--twox-text) !important;
}

body.twox-system-scope .close-btn {
  color: var(--twox-muted) !important;
}

body.twox-system-scope .close-btn:hover {
  color: var(--twox-text) !important;
}

body.twox-system-scope .detail-row {
  border-bottom: 1px solid var(--twox-border) !important;
}

body.twox-system-scope .detail-label {
  color: var(--twox-secondary) !important;
}

body.twox-system-scope .detail-val {
  color: var(--twox-text) !important;
}


/* ---- 14. CRM KANBAN ---- */
body.twox-system-scope .crm-kanban-board {
  gap: 14px !important;
}

body.twox-system-scope .kanban-column {
  background: var(--twox-subtle) !important;
  border: 1px solid var(--twox-border) !important;
  border-radius: 10px !important;
}

body.twox-system-scope .kanban-column.drag-over {
  background: var(--twox-success-soft) !important;
  border-color: var(--twox-success) !important;
}

body.twox-system-scope .kanban-column-header {
  border-bottom: 1px solid var(--twox-border) !important;
}

body.twox-system-scope .kanban-column-title {
  color: var(--twox-text) !important;
}

body.twox-system-scope .kanban-count-badge {
  background: var(--twox-brand-soft) !important;
  color: var(--twox-brand) !important;
}

body.twox-system-scope .kanban-lead-card {
  background: var(--twox-surface) !important;
  border: 1px solid var(--twox-border) !important;
  box-shadow: var(--twox-shadow) !important;
}

body.twox-system-scope .kanban-lead-card:hover {
  border-color: var(--twox-border-strong) !important;
  transform: translateY(-1px) !important;
  box-shadow: var(--twox-shadow-md) !important;
}

body.twox-system-scope .kanban-lead-name {
  color: var(--twox-text) !important;
}

body.twox-system-scope .kanban-lead-sub {
  color: var(--twox-secondary) !important;
}

body.twox-system-scope .kanban-chk-pill.ok {
  background: var(--twox-success-soft) !important;
  color: var(--twox-success) !important;
}

body.twox-system-scope .kanban-chk-pill.missing {
  background: var(--twox-danger-soft) !important;
  color: var(--twox-danger) !important;
}


/* ---- 15. MARKETING CALENDAR ---- */
body.twox-system-scope .mkt-calendar-day-header {
  background: var(--twox-subtle) !important;
  border: 1px solid var(--twox-border) !important;
  color: var(--twox-brand) !important;
}

body.twox-system-scope .mkt-calendar-cell {
  background: var(--twox-surface) !important;
  border: 1px solid var(--twox-border) !important;
}

body.twox-system-scope .mkt-calendar-cell:hover {
  border-color: var(--twox-border-strong) !important;
}

body.twox-system-scope .mkt-calendar-cell.empty-cell {
  background: var(--twox-bg) !important;
  border-color: transparent !important;
}

body.twox-system-scope .mkt-calendar-date-badge {
  background: var(--twox-subtle) !important;
  color: var(--twox-text) !important;
}

body.twox-system-scope .mkt-calendar-date-badge.has-event {
  background: var(--twox-brand-soft) !important;
  color: var(--twox-brand) !important;
  border: 1px solid #B9DCE5 !important;
}

body.twox-system-scope .mkt-event-card {
  background: var(--twox-surface) !important;
  border-left: 3px solid var(--twox-brand) !important;
  box-shadow: var(--twox-shadow) !important;
}

body.twox-system-scope .mkt-event-title {
  color: var(--twox-text) !important;
}


/* ---- 16. VIEW TOGGLE ---- */
body.twox-system-scope .view-toggle-group {
  background: var(--twox-subtle) !important;
  border: 1px solid var(--twox-border) !important;
}

body.twox-system-scope .view-toggle-btn {
  color: var(--twox-secondary) !important;
  background: transparent !important;
  border: none !important;
}

body.twox-system-scope .view-toggle-btn.active {
  background: var(--twox-brand) !important;
  color: #fff !important;
  box-shadow: none !important;
}


/* ---- 17. SEARCH & FILTERS ---- */
body.twox-system-scope .search-box {
  background: var(--twox-surface) !important;
  border: 1px solid var(--twox-border-strong) !important;
  border-radius: 8px !important;
}

body.twox-system-scope .search-box input {
  background: transparent !important;
  border: none !important;
  min-height: auto !important;
}

body.twox-system-scope .search-box svg {
  color: var(--twox-muted) !important;
}

body.twox-system-scope .filter-select {
  background: var(--twox-surface) !important;
  border: 1px solid var(--twox-border-strong) !important;
  color: var(--twox-text) !important;
}


/* ---- 18. DAY TAGS ---- */
body.twox-system-scope .day-tag {
  background: var(--twox-subtle) !important;
  color: var(--twox-secondary) !important;
  font-size: 11px !important;
  border-radius: 4px !important;
}


/* ---- 19. SPINNER ---- */
body.twox-system-scope .spinner {
  border-color: rgba(21,94,117,.15) !important;
  border-top-color: var(--twox-brand) !important;
}

/* Non-blocking spinner — sits in bottom-right corner */
body.twox-system-scope #global-spinner {
  position: fixed !important;
  inset: auto 24px 24px auto !important;
  width: auto !important;
  height: auto !important;
  padding: 0 !important;
  background: transparent !important;
  pointer-events: none !important;
  z-index: 80 !important;
}

body.twox-system-scope #global-spinner .spinner {
  width: 22px !important;
  height: 22px !important;
  border-width: 2px !important;
}


/* ---- 20. TOAST NOTIFICATIONS ---- */
body.twox-system-scope #toast-notification {
  position: fixed !important;
  top: 78px !important;
  right: 24px !important;
  bottom: auto !important;
  max-width: 360px !important;
  min-width: 260px !important;
  padding: 12px 16px !important;
  background: #DCFCE7 !important;
  color: #166534 !important;
  border: 1px solid #86EFAC !important;
  border-radius: 8px !important;
  box-shadow: 0 8px 20px rgba(22,101,52,.14) !important;
  font-weight: 600 !important;
  white-space: normal !important;
  line-height: 1.4 !important;
  z-index: 5000 !important;
}


/* ---- 21. DESPESAS MODULE ---- */
body.twox-system-scope #view-despesas .metrics-grid {
  display: grid !important;
  grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
  gap: 16px !important;
  margin-bottom: 24px !important;
}

@media (max-width: 1100px) {
  body.twox-system-scope #view-despesas .metrics-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }
}

@media (max-width: 640px) {
  body.twox-system-scope #view-despesas .metrics-grid {
    grid-template-columns: 1fr !important;
  }
}

body.twox-system-scope #view-despesas .metric-card {
  border-left: 1px solid var(--twox-border) !important;
  background: var(--twox-surface) !important;
}


/* ---- 22. IFRAME (ASAAS) ---- */
body.twox-system-scope #iframe-lancamento-asaas {
  background: #fff !important;
  border-radius: var(--twox-radius) !important;
  border: 1px solid var(--twox-border) !important;
}


/* ---- 23. OVERVIEW HIERARCHY ---- */
/* Override inline backgrounds on content-cards in Visão Geral */
body.twox-system-scope #view-visao-geral > .content-card[style],
body.twox-system-scope #view-visao-geral > .content-card {
  background: var(--twox-surface) !important;
  border: 1px solid var(--twox-border) !important;
}

/* Properly style alert cards without inline color overrides */
body.twox-system-scope #view-visao-geral .content-card h2[style],
body.twox-system-scope #view-visao-geral .content-card h3[style] {
  color: var(--twox-text) !important;
}

/* Overview split grid */
.overview-split-grid {
  display: grid !important;
  grid-template-columns: 1fr 1fr !important;
  gap: 20px !important;
  margin-bottom: 20px !important;
  align-items: start !important;
}

body.twox-system-scope .overview-split-grid > * {
  min-width: 0 !important;
}


/* ---- 24. THUMB LOGOS ---- */
body.twox-system-scope .thumb-logo {
  background: var(--twox-subtle) !important;
  border: 1px solid var(--twox-border) !important;
}


/* ---- 25. TAB VIEWS ---- */
.tab-view { display: none !important; }
.tab-view.active { display: block !important; }

body.twox-system-scope .tab-view {
  max-width: 1280px !important;
  color: var(--twox-text) !important;
}

body.twox-system-scope .tab-view p {
  line-height: 1.5 !important;
  max-width: 78ch !important;
}


/* ---- 26. CARD HEADER BAR ---- */
body.twox-system-scope .card-header-bar {
  border-bottom: 1px solid var(--twox-border) !important;
  padding-bottom: 14px !important;
  margin-bottom: 16px !important;
}


/* ---- 27. MOBILE RESPONSIVE ---- */
.mobile-menu-toggle {
  display: none !important;
  position: fixed !important;
  right: 14px !important;
  top: 14px !important;
  z-index: 2600 !important;
  background: var(--twox-brand) !important;
  color: #fff !important;
  border: 0 !important;
  border-radius: 7px !important;
  padding: 9px 14px !important;
  font-weight: 700 !important;
  font-size: 13px !important;
}

@media (max-width: 900px) {
  body.twox-system-scope .app-main {
    padding: 22px 18px 40px !important;
  }
  .overview-split-grid {
    grid-template-columns: 1fr !important;
    gap: 16px !important;
  }
  body.twox-system-scope #view-despesas > .metrics-grid {
    grid-template-columns: 1fr !important;
  }
}

@media (max-width: 640px) {
  .mobile-menu-toggle {
    display: block !important;
  }

  body.twox-system-scope .app-sidebar {
    position: fixed !important;
    left: 0 !important;
    top: 0 !important;
    bottom: 0 !important;
    width: 280px !important;
    max-width: calc(100vw - 48px) !important;
    margin: 0 !important;
    transform: translateX(-105%) !important;
    z-index: 2500 !important;
    transition: transform .2s ease !important;
  }

  body.twox-system-scope.mobile-sidebar-open .app-sidebar {
    transform: translateX(0) !important;
    box-shadow: 8px 0 24px rgba(23,33,43,.15) !important;
  }

  body.twox-system-scope.mobile-sidebar-open::after {
    content: "" !important;
    position: fixed !important;
    inset: 0 !important;
    background: rgba(15,23,42,.28) !important;
    z-index: 2400 !important;
    pointer-events: auto !important;
  }

  body.twox-system-scope.mobile-sidebar-open {
    overflow: hidden !important;
  }

  body.twox-system-scope .app-main {
    display: block !important;
    position: relative !important;
    left: 0 !important;
    margin: 0 !important;
    padding: 72px 14px 32px !important;
    width: 100vw !important;
    max-width: 100vw !important;
    min-width: 0 !important;
  }

  body.twox-system-scope #page-title {
    font-size: 22px !important;
    overflow-wrap: anywhere !important;
  }

  body.twox-system-scope .header-actions {
    width: 100% !important;
    max-width: 100% !important;
    flex-wrap: wrap !important;
  }

  body.twox-system-scope .metrics-grid {
    grid-template-columns: 1fr !important;
    width: 100% !important;
  }

  .overview-split-grid {
    grid-template-columns: 1fr !important;
    width: 100% !important;
  }

  body.twox-system-scope .content-card {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
  }

  body.twox-system-scope .table-container {
    overflow-x: auto !important;
    max-width: 100% !important;
  }

  body.twox-system-scope #toast-notification {
    top: 62px !important;
    right: 12px !important;
    left: 12px !important;
    min-width: 0 !important;
    max-width: none !important;
    width: auto !important;
  }

  body.twox-system-scope .nav-item {
    white-space: normal !important;
    overflow-wrap: anywhere !important;
  }

  body.twox-system-scope #view-despesas form {
    grid-template-columns: 1fr !important;
  }

  body.twox-system-scope .crm-kanban-board {
    grid-template-columns: 1fr !important;
  }
}

@media (prefers-reduced-motion: reduce) {
  body.twox-system-scope *,
  body.twox-system-scope *::before,
  body.twox-system-scope *::after {
    animation-duration: 0.001ms !important;
    transition-duration: 0.001ms !important;
  }
}


/* ---- 28. OVERRIDES FOR INLINE STYLES IN VISÃO GERAL ---- */
/* These kill the legacy dark-theme colors leaking through inline styles */

/* Alert cards that have inline background colors */
body.twox-system-scope .content-card[style*="linear-gradient"],
body.twox-system-scope .content-card[style*="rgba(239"],
body.twox-system-scope .content-card[style*="rgba(245"],
body.twox-system-scope .content-card[style*="rgba(139"],
body.twox-system-scope .content-card[style*="rgba(16"] {
  background: var(--twox-surface) !important;
}

/* Fix white text set inline on h3/h2 elements */
body.twox-system-scope h3[style*="color: #fff"],
body.twox-system-scope h3[style*="color:#fff"],
body.twox-system-scope h3[style*="color: #fbbf24"],
body.twox-system-scope h3[style*="color:#fbbf24"],
body.twox-system-scope h3[style*="color: #ef4444"],
body.twox-system-scope h3[style*="color:#ef4444"],
body.twox-system-scope h2[style*="color: #fff"],
body.twox-system-scope h2[style*="color:#fff"],
body.twox-system-scope h2[style*="color: #ef4444"],
body.twox-system-scope h2[style*="color:#ef4444"],
body.twox-system-scope h2[style*="color:#fbbf24"],
body.twox-system-scope h2[style*="color: #fbbf24"] {
  color: var(--twox-text) !important;
}

/* Fix inline border-left colors — keep them but neutralize the card background */
body.twox-system-scope .metric-card[style*="border-left"] {
  background: var(--twox-surface) !important;
}

/* Fix button with inline styles showing wrong bg */
body.twox-system-scope button[style*="background: #ffffff"],
body.twox-system-scope button[style*="background:#ffffff"] {
  background: var(--twox-brand) !important;
  color: #fff !important;
}

/* Fix inline color overrides on secondary text */
body.twox-system-scope p[style*="color: var(--text-secondary)"],
body.twox-system-scope p[style*="color:var(--text-secondary)"] {
  color: var(--twox-secondary) !important;
}

/* Fix inline border-color on export buttons */
body.twox-system-scope .btn-outline[style*="border-color"] {
  border-color: var(--twox-border-strong) !important;
  color: var(--twox-secondary) !important;
}

body.twox-system-scope .btn-outline[style*="border-color"]:hover {
  background: var(--twox-subtle) !important;
  color: var(--twox-text) !important;
}

/* ============================================================
   FINANCIAL / EXPENSES MODULE STYLES
   ============================================================ */
.form-label {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--twox-secondary);
  margin-bottom: 6px;
}

body.twox-system-scope .filter-select {
  background: var(--twox-surface) !important;
  border: 1px solid var(--twox-border-strong) !important;
  color: var(--twox-text) !important;
  border-radius: var(--twox-radius-sm) !important;
  padding: 6px 12px !important;
  font-size: 13px !important;
  min-height: 36px !important;
  outline: none !important;
  cursor: pointer;
}

body.twox-system-scope .filter-select:focus {
  border-color: var(--twox-brand) !important;
  box-shadow: var(--twox-focus) !important;
}

body.twox-system-scope .login-input-field {
  width: 100%;
  box-sizing: border-box;
  padding: 8px 12px;
  background: #fff;
  border: 1px solid var(--twox-border-strong);
  border-radius: var(--twox-radius-sm);
  color: var(--twox-text);
  font-size: 13.5px;
  min-height: 38px;
}

body.twox-system-scope .login-input-field:focus {
  border-color: var(--twox-brand);
  box-shadow: var(--twox-focus);
  outline: none;
}
