/* ═══════════════════════════════════════════
   ساران — تم تیره مدرن
   ═══════════════════════════════════════════ */

html[data-theme="dark"] {
  color-scheme: dark;
  --ink: #E8EEF0;
  --brand: #2EC4B6;
  --brand-dark: #5EEAD4;
  --brand-soft: rgba(46, 196, 182, .14);
  --mark: #F0A46A;
  --mark-soft: rgba(240, 164, 106, .16);
  --bg: #0B1014;
  --bg-2: #11181E;
  --surface: #151C23;
  --surface-2: #1B242D;
  --line: #2A3540;
  --text: #DDE5E8;
  --muted: #8B9AA3;
  --danger: #F07178;
  --ok: #3DDC97;
  --shadow: 0 12px 36px rgba(0, 0, 0, .45);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, .35);
  --swatch: linear-gradient(90deg,
    #1A2229 0 12%, #3D4A55 12% 24%, #6B7884 24% 36%,
    #2EC4B6 36% 48%, #3DDC97 48% 60%, #F0A46A 60% 72%,
    #F07178 72% 84%, #E8EEF0 84% 100%);
}

html[data-theme="dark"] body,
html[data-theme="dark"] .app-body {
  background:
    radial-gradient(900px 420px at 12% -10%, rgba(46,196,182,.12), transparent 55%),
    radial-gradient(700px 380px at 100% 0%, rgba(240,164,106,.08), transparent 50%),
    linear-gradient(180deg, #0E151B 0%, var(--bg) 160px);
  color: var(--text);
}

html[data-theme="dark"] .app-body {
  background:
    radial-gradient(800px 360px at 85% 0%, rgba(46,196,182,.10), transparent 50%),
    linear-gradient(180deg, #101820 0%, var(--bg) 180px);
}

/* Surfaces */
html[data-theme="dark"] .panel,
html[data-theme="dark"] .dash-card,
html[data-theme="dark"] .dash-kpi,
html[data-theme="dark"] .dash-quick-item,
html[data-theme="dark"] .archive-filters,
html[data-theme="dark"] .archive-table-panel,
html[data-theme="dark"] .finance-filters,
html[data-theme="dark"] .finance-kpi,
html[data-theme="dark"] .finance-card,
html[data-theme="dark"] .record-card,
html[data-theme="dark"] .workspace-header,
html[data-theme="dark"] .canvas-panel,
html[data-theme="dark"] .form-panel,
html[data-theme="dark"] .action-panel,
html[data-theme="dark"] .mobile-workspace-tabs,
html[data-theme="dark"] .mobile-sticky-actions,
html[data-theme="dark"] .track-form-card,
html[data-theme="dark"] .card {
  background: var(--surface);
  border-color: var(--line);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}

html[data-theme="dark"] .dash-kpi.kpi-main,
html[data-theme="dark"] .finance-kpi-main {
  background: linear-gradient(135deg, #0F766E 0%, #134E4A 45%, #0B1220 100%);
  border: 1px solid rgba(46,196,182,.25);
  color: #fff;
}

html[data-theme="dark"] .dash-kpi-link:hover,
html[data-theme="dark"] .dash-quick-item:hover {
  border-color: rgba(46,196,182,.45);
  background: var(--surface-2);
  box-shadow: 0 8px 24px rgba(0,0,0,.35);
}

html[data-theme="dark"] .dash-card-head,
html[data-theme="dark"] .archive-table-toolbar,
html[data-theme="dark"] .archive-filters-head {
  background: var(--surface-2);
  border-color: var(--line);
}


/* Dashboard toolbar / header (premium actions) */
html[data-theme="dark"] .dash-header {
  background:
    radial-gradient(520px 180px at 100% 0%, rgba(46,196,182,.12), transparent 55%),
    linear-gradient(180deg, #151E28 0%, #101820 100%);
  border-color: var(--line);
  box-shadow: 0 8px 24px rgba(0,0,0,.28);
}
html[data-theme="dark"] .dash-eyebrow { color: var(--brand-dark); }
html[data-theme="dark"] .dash-toolbar-sep { background: var(--line); }
html[data-theme="dark"] .dash-action,
html[data-theme="dark"] .dash-icon-btn {
  background: var(--surface-2);
  border-color: var(--line);
  color: var(--ink);
  box-shadow: none;
}
html[data-theme="dark"] .dash-action:hover,
html[data-theme="dark"] .dash-icon-btn:hover {
  background: rgba(46,196,182,.12);
  border-color: rgba(46,196,182,.45);
  color: #9FE8DF;
  box-shadow: 0 8px 20px rgba(0,0,0,.3);
}
html[data-theme="dark"] .dash-action-icon {
  background: rgba(46,196,182,.14);
  color: #9FE8DF;
}
html[data-theme="dark"] .dash-action-icon.tone-ok {
  background: rgba(46,196,182,.18);
  color: #7DDEA8;
}
html[data-theme="dark"] .dash-action-icon.tone-mark {
  background: rgba(217,119,58,.18);
  color: #F0B27A;
}
html[data-theme="dark"] .dash-action-primary {
  background: linear-gradient(135deg, #0F8581 0%, #0A5C5A 100%);
  border: 0;
  color: #fff;
  box-shadow: 0 10px 24px rgba(15,133,129,.35);
}
html[data-theme="dark"] .dash-action-primary:hover {
  background: linear-gradient(135deg, #14A39E 0%, #0D7370 100%);
  color: #fff;
  border-color: transparent;
}
html[data-theme="dark"] .dash-action-primary .dash-action-icon {
  background: rgba(255,255,255,.16);
  color: #fff;
}
html[data-theme="dark"] .dash-icon-btn-label { color: var(--muted); }
html[data-theme="dark"] .dash-icon-btn:hover .dash-icon-btn-label { color: #9FE8DF; }
html[data-theme="dark"] .dash-quick-icon {
  background: rgba(46,196,182,.14);
  color: #9FE8DF;
}
html[data-theme="dark"] .dash-quick-icon.tone-ok {
  background: rgba(46,196,182,.18);
  color: #7DDEA8;
}
html[data-theme="dark"] .dash-quick-icon.tone-mark {
  background: rgba(217,119,58,.18);
  color: #F0B27A;
}
html[data-theme="dark"] .dash-kpi-icon {
  background: rgba(46,196,182,.14);
  color: #9FE8DF;
}
html[data-theme="dark"] .dash-kpi-icon.tone-mark {
  background: rgba(217,119,58,.18);
  color: #F0B27A;
}
html[data-theme="dark"] .dash-kpi-icon.tone-ok {
  background: rgba(46,196,182,.18);
  color: #7DDEA8;
}
html[data-theme="dark"] .dash-header h1,
html[data-theme="dark"] .archive-hero h1,
html[data-theme="dark"] .finance-hero h1,
html[data-theme="dark"] .workspace-header h5 {
  color: var(--ink);
}

html[data-theme="dark"] .archive-hero,
html[data-theme="dark"] .finance-hero {
  background: linear-gradient(120deg, #0B1220 0%, #0F766E 62%, #134E4A 100%);
  box-shadow: 0 10px 28px rgba(0,0,0,.35);
}

/* Forms */
html[data-theme="dark"] .form-control,
html[data-theme="dark"] .form-select,
html[data-theme="dark"] .login-input,
html[data-theme="dark"] textarea.form-control {
  background: var(--surface-2) !important;
  border-color: var(--line) !important;
  color: var(--ink) !important;
  box-shadow: none !important;
}
html[data-theme="dark"] .form-control:focus,
html[data-theme="dark"] .form-select:focus,
html[data-theme="dark"] .login-input:focus {
  border-color: var(--brand) !important;
  box-shadow: 0 0 0 3px rgba(46,196,182,.18) !important;
  background: #1E2832 !important;
}
html[data-theme="dark"] .form-control::placeholder,
html[data-theme="dark"] .form-select option {
  color: var(--muted);
}
html[data-theme="dark"] .form-select option {
  background: var(--surface);
  color: var(--ink);
}
html[data-theme="dark"] .form-label,
html[data-theme="dark"] .text-muted,
html[data-theme="dark"] .dash-kpi-label,
html[data-theme="dark"] .finance-kpi-label {
  color: var(--muted) !important;
}
html[data-theme="dark"] .form-check-input {
  background-color: var(--surface-2);
  border-color: var(--line);
}
html[data-theme="dark"] .form-check-input:checked {
  background-color: var(--brand);
  border-color: var(--brand);
}

/* Tables */
html[data-theme="dark"] .table {
  --bs-table-bg: transparent;
  --bs-table-color: var(--text);
  --bs-table-border-color: var(--line);
  --bs-table-striped-bg: rgba(255,255,255,.03);
  --bs-table-hover-bg: rgba(46,196,182,.08);
  --bs-table-hover-color: var(--ink);
  color: var(--text);
}
html[data-theme="dark"] .archive-table thead th,
html[data-theme="dark"] .finance-table thead th,
html[data-theme="dark"] .records-table thead {
  background: rgba(46,196,182,.12) !important;
  color: var(--brand-dark) !important;
  border-color: var(--line);
}
html[data-theme="dark"] .archive-table tbody td,
html[data-theme="dark"] .finance-table tbody td {
  border-color: var(--line);
}
html[data-theme="dark"] .archive-table tbody tr:hover {
  background: rgba(46,196,182,.07);
}

/* Buttons */
html[data-theme="dark"] .btn-outline-secondary {
  color: var(--text);
  border-color: var(--line);
  background: transparent;
}
html[data-theme="dark"] .btn-outline-secondary:hover {
  background: var(--surface-2);
  border-color: var(--brand);
  color: var(--brand-dark);
}
html[data-theme="dark"] .btn-outline-light {
  color: #fff;
  border-color: rgba(255,255,255,.35);
}
html[data-theme="dark"] .btn-light {
  background: #E8EEF0;
  border-color: #E8EEF0;
  color: #0B1014;
}
html[data-theme="dark"] .btn-warning {
  color: #1C2428;
}

/* Nav / chrome */
html[data-theme="dark"] .mobile-topbar {
  background: #0B1014;
  border-bottom-color: rgba(46,196,182,.25);
}
html[data-theme="dark"] .mobile-bottom-nav {
  background: #121920;
  border-top-color: var(--line);
  box-shadow: 0 -8px 28px rgba(0,0,0,.4);
}
html[data-theme="dark"] .mb-nav-item { color: var(--muted); }
html[data-theme="dark"] .mb-nav-item.active,
html[data-theme="dark"] .mb-nav-item:hover {
  color: var(--brand);
  background: var(--brand-soft);
}
html[data-theme="dark"] .status-bar {
  background: #080C10;
  color: rgba(232,238,240,.75);
}

/* Tabs */
html[data-theme="dark"] .nav-tabs {
  border-bottom-color: var(--line);
}
html[data-theme="dark"] .nav-tabs .nav-link {
  color: var(--muted);
  border: 0;
}
html[data-theme="dark"] .nav-tabs .nav-link.active {
  color: var(--brand-dark);
  background: var(--brand-soft);
  border-radius: 10px 10px 0 0;
}
html[data-theme="dark"] .mws-tab.active {
  background: var(--brand-soft);
  color: var(--brand-dark);
}
html[data-theme="dark"] .insp-tabs .nav-link.active {
  background: var(--brand-soft);
  color: var(--brand-dark);
}

/* Modals / alerts */
html[data-theme="dark"] .modal-content {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--line);
}
html[data-theme="dark"] .modal-header,
html[data-theme="dark"] .modal-footer {
  border-color: var(--line);
}
html[data-theme="dark"] .modal-header .btn-close {
  filter: invert(1) grayscale(1);
}
html[data-theme="dark"] .alert-success {
  background: rgba(61,220,151,.12);
  border-color: rgba(61,220,151,.35);
  color: #9AE6C5;
}
html[data-theme="dark"] .alert-danger,
html[data-theme="dark"] .alert-warning {
  background: rgba(240,113,120,.12);
  border-color: rgba(240,113,120,.35);
  color: #F5B0B4;
}
html[data-theme="dark"] .alert-warning {
  background: rgba(240,164,106,.12);
  border-color: rgba(240,164,106,.35);
  color: #F5C89A;
}

/* Chips / pills / badges */
html[data-theme="dark"] .archive-chip,
html[data-theme="dark"] .finance-preset {
  background: var(--surface-2);
  border-color: var(--line);
  color: var(--text);
}
html[data-theme="dark"] .archive-chip:hover,
html[data-theme="dark"] a.finance-preset:hover {
  background: var(--brand-soft);
  border-color: var(--brand);
  color: var(--brand-dark);
}
html[data-theme="dark"] .archive-chip.active,
html[data-theme="dark"] .finance-preset.active {
  background: var(--brand);
  border-color: var(--brand);
  color: #06201E;
}
html[data-theme="dark"] .status-draft { background: #2A3540; color: #B0BEC5; }
html[data-theme="dark"] .status-saved { background: rgba(46,196,182,.18); color: #5EEAD4; }
html[data-theme="dark"] .status-printed { background: rgba(240,164,106,.18); color: #F0A46A; }

/* Inspection canvas */
html[data-theme="dark"] .canvas-stage,
html[data-theme="dark"] .canvas-viewport {
  background:
    linear-gradient(rgba(46,196,182,.06) 1px, transparent 1px) 0 0 / 40px 40px,
    linear-gradient(90deg, rgba(46,196,182,.06) 1px, transparent 1px) 0 0 / 40px 40px,
    #0F161C;
  border-color: var(--line);
}
html[data-theme="dark"] .paint-toolbar,
html[data-theme="dark"] .tool-btn {
  background: var(--surface-2);
  border-color: var(--line);
  color: var(--text);
}
html[data-theme="dark"] .tool-btn.active,
html[data-theme="dark"] .tool-btn:hover {
  background: var(--brand-soft);
  color: var(--brand-dark);
  border-color: var(--brand);
}
html[data-theme="dark"] .form-section {
  background: var(--surface-2);
  border-color: var(--line);
}
html[data-theme="dark"] .form-section legend {
  color: var(--brand-dark);
}
html[data-theme="dark"] .action-btn {
  background: var(--surface-2);
  border-color: var(--line);
  color: var(--text);
}
html[data-theme="dark"] .qr-box {
  background: var(--surface-2);
  border-color: var(--line);
}

/* Login / track / auth */
html[data-theme="dark"] .login-card {
  background: linear-gradient(180deg, #151C23 0%, #121920 100%);
  color: var(--text);
}
html[data-theme="dark"] .login-card h2 { color: var(--ink); }
html[data-theme="dark"] .track-body {
  background:
    radial-gradient(700px 360px at 10% 0%, rgba(46,196,182,.12), transparent 55%),
    var(--bg);
}
html[data-theme="dark"] .jdp-popover {
  background: var(--surface);
  border-color: var(--line);
  color: var(--text);
  box-shadow: var(--shadow);
}
html[data-theme="dark"] .jdp-nav {
  background: var(--surface-2);
  border-color: var(--line);
  color: var(--ink);
}
html[data-theme="dark"] .jdp-day {
  color: var(--ink);
}
html[data-theme="dark"] .jdp-day:hover {
  background: var(--brand-soft);
  color: var(--brand-dark);
}

/* Settings / backup */
html[data-theme="dark"] .settings-hero-panel {
  background: rgba(46,196,182,.12) !important;
  border-color: transparent;
}
html[data-theme="dark"] .settings-hero-title { color: var(--brand-dark) !important; }
html[data-theme="dark"] .settings-switch-card {
  background: var(--surface-2);
  border-color: var(--line);
}
html[data-theme="dark"] .print-template-preview {
  background:
    linear-gradient(45deg, #1B242D 25%, transparent 25%) 0 0 / 16px 16px,
    linear-gradient(-45deg, #1B242D 25%, transparent 25%) 0 0 / 16px 16px,
    var(--surface-2);
  border-color: var(--line);
}
html[data-theme="dark"] .print-template-preview.has-image {
  background: #0B1014;
}
html[data-theme="dark"] code {
  color: #5EEAD4;
  background: rgba(46,196,182,.12);
}

html[data-theme="dark"] .dash-list-row,
html[data-theme="dark"] .dash-alert-item {
  border-color: var(--line);
}
html[data-theme="dark"] .dash-avatar {
  background: var(--brand-soft);
  color: var(--brand-dark);
}
html[data-theme="dark"] .fee-words {
  color: var(--muted);
}
html[data-theme="dark"] .fee-words.has-value {
  color: var(--brand-dark);
}
html[data-theme="dark"] .dash-sys-grid > div {
  background: var(--surface-2);
}
html[data-theme="dark"] .hr,
html[data-theme="dark"] hr {
  border-color: var(--line);
  opacity: .5;
}
html[data-theme="dark"] .card-header {
  background: var(--surface-2);
  border-color: var(--line);
  color: var(--ink);
}
html[data-theme="dark"] .border,
html[data-theme="dark"] .border-bottom,
html[data-theme="dark"] .border-top {
  border-color: var(--line) !important;
}

/* Theme toggle control */
.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 42px;
  height: 42px;
  padding: 0;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  transition: background .2s, border-color .2s, color .2s, transform .15s;
  flex: 0 0 auto;
}
.theme-toggle:hover {
  border-color: var(--brand);
  background: var(--brand-soft);
  color: var(--brand-dark);
}
.theme-toggle:active { transform: scale(.96); }
.theme-toggle i { font-size: 1.15rem; line-height: 1; }
.theme-toggle .theme-icon-sun { display: none; }
.theme-toggle .theme-icon-moon { display: inline-block; }
html[data-theme="dark"] .theme-toggle .theme-icon-sun { display: inline-block; }
html[data-theme="dark"] .theme-toggle .theme-icon-moon { display: none; }

.theme-toggle-lg {
  width: auto;
  min-height: 42px;
  padding: 0 14px;
  font-weight: 700;
  font-size: .85rem;
}
.theme-toggle-lg .theme-toggle-label { display: inline; }

.sidebar-theme-btn {
  margin: 8px 6px 0;
  width: calc(100% - 12px);
  height: auto;
  min-height: 44px;
  flex-direction: column;
  gap: 4px;
  background: rgba(255,255,255,.06);
  border-color: rgba(255,255,255,.1);
  color: rgba(255,255,255,.85);
  font-size: .62rem;
  font-weight: 600;
}
.sidebar-theme-btn:hover {
  background: rgba(46,196,182,.2);
  border-color: rgba(46,196,182,.45);
  color: #fff;
}
.sidebar-theme-btn i { font-size: 1.15rem; }

.mob-theme-btn {
  background: rgba(255,255,255,.08);
  border: 0;
  color: #fff;
  width: 42px;
  height: 42px;
  border-radius: 12px;
}

html[data-theme="dark"] .theme-toggle {
  background: var(--surface-2);
  border-color: var(--line);
  color: var(--brand-dark);
}
html[data-theme="dark"] .theme-toggle:hover {
  background: var(--brand-soft);
}

/* Print editor dark */
html[data-theme="dark"] .print-editor-page {
  background: #0B1014;
}
html[data-theme="dark"] .print-editor-sidebar {
  background: var(--surface);
  border-color: var(--line);
  color: var(--text);
}

@media (max-width: 575.98px) {
  .theme-toggle-lg .theme-toggle-label { display: none; }
  .theme-toggle-lg { width: 42px; padding: 0; }
}

/* Prefer dashboard icon-btn sizing over generic theme-toggle */
.dash-icon-btn.theme-toggle {
  width: 52px;
  height: auto;
  min-height: 52px;
  padding: 6px 4px;
  flex-direction: column;
  gap: 2px;
  border-radius: 14px;
}
html[data-theme="dark"] .dash-card:hover {
  border-color: rgba(46,196,182,.4);
  box-shadow: 0 10px 26px rgba(0,0,0,.35);
}
html[data-theme="dark"] .dash-card-head {
  background: linear-gradient(180deg, #1A2430 0%, var(--surface-2) 100%);
}
html[data-theme="dark"] .dash-rank-bar { background: #1E2832; }