/* Persisted application dark theme. Printed documents intentionally stay white. */
:root.theme-dark {
  --ink: #f4f1fb;
  --muted: #b7b0c9;
  --primary: #a994ff;
  --violet: #c4b5fd;
  --line: #39344b;
  --bg: #121019;
  color-scheme: dark;
}

.theme-dark body {
  background: radial-gradient(circle at 4% 0, #2d2650 0, transparent 35rem), radial-gradient(circle at 96% 20%, #172d3a 0, transparent 28rem), var(--bg);
}

.theme-toggle {
  position: fixed;
  top: 16px;
  right: 18px;
  z-index: 30;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 38px;
  padding: 0 12px;
  border: 1px solid #ded8ee;
  border-radius: 12px;
  background: #ffffffeb;
  color: var(--ink);
  box-shadow: 0 8px 22px #251e4430;
  cursor: pointer;
  font: 700 11px 'DM Sans', sans-serif;
}
.theme-toggle svg { width: 16px; height: 16px; color: var(--primary); }
.theme-toggle:hover { transform: translateY(-1px); }

.theme-dark .theme-toggle {
  border-color: #4a4263;
  background: #252130eb;
  color: #f6f3ff;
  box-shadow: 0 9px 24px #03020866;
}

.theme-dark .glass,
.theme-dark .module:not(.active),
.theme-dark .transaction,
.theme-dark .labour-card,
.theme-dark .labour-search,
.theme-dark .sales-card,
.theme-dark .sales-document-card,
.theme-dark .sales-form,
.theme-dark .sales-form-section,
.theme-dark .sales-type-panel,
.theme-dark .sales-notes,
.theme-dark .pricing-panel,
.theme-dark .settings-form section,
.theme-dark .company-hero,
.theme-dark .project-stats div,
.theme-dark .project-list > a,
.theme-dark .project-detail,
.theme-dark .attendance-table,
.theme-dark .accounting-panel,
.theme-dark .accounting-kpi,
.theme-dark .accounting-filter,
.theme-dark .payment-dialog,
.theme-dark .document-card,
.theme-dark .quotation-preview-frame,
.theme-dark .filter-card,
.theme-dark .entry-intro,
.theme-dark .form-hint,
.theme-dark .mode-control,
.theme-dark .attendance-context,
.theme-dark .sticky-save,
.theme-dark .sales-pagination {
  background: #201c2a !important;
  border-color: #3b354d !important;
  box-shadow: 0 12px 30px #06040b38;
}

.theme-dark .labour-card {
  color: var(--ink);
  border-color: #4a4260 !important;
  background: #201c2a !important;
}
.theme-dark .attendance-record {
  color: var(--ink);
  border-color: #4a4260 !important;
  background: #201c2a !important;
}
.theme-dark .attendance-record:hover {
  background: #282238 !important;
}
.theme-dark .attendance-filter {
  background: #201c2a !important;
  border-color: #4a4260 !important;
  box-shadow: 0 12px 30px #06040b38;
}
.theme-dark .attendance-pagination a { background: #322b50; color: #d9d1ff; }
.theme-dark .attendance-pagination a:hover { background: #7861dc; color: #fff; }
.theme-dark .attendance-pagination span { color: #c5bfd4; }
.theme-dark .labour-card:hover,
.theme-dark .labour-card:focus {
  background: #282238 !important;
  outline-color: #a994ff55;
}
.theme-dark .calendar-head a {
  background: #322b50 !important;
  border: 1px solid #51486a;
  color: #c8baff !important;
}
.theme-dark .calendar-head a:hover {
  background: #403665 !important;
  border-color: #a994ff;
}
.theme-dark .credit-sale-transaction b { color: #8ee7c5; }
.theme-dark .project-row,
.theme-dark .project-panel,
.theme-dark .project-kpi,
.theme-dark .project-filter { background: #201c2a; border-color: #4a4260; }
.theme-dark .project-open { color: #f5f2ff; }
.theme-dark .project-recent article { background: #29233a; }
.theme-dark .project-note { background: #29233a; color: #c5bfd4; }
.theme-dark .credit-row {
  background: #183d36;
  border: 1px solid #275a4e;
  color: #d8f6e9;
}
.theme-dark .credit-row b { color: #8ee7c5; }
.theme-dark .labour-search {
  background: #201c2a !important;
  border-color: #4a4260 !important;
}
.theme-dark .labour-search input {
  background: transparent !important;
  border-color: transparent !important;
  box-shadow: none !important;
}
.theme-dark .labour-search > i { color: #c5bfd4; }
.theme-dark .labour-search button {
  min-height: 36px;
  padding: 0 12px;
  border-radius: 9px;
  background: #322b50;
  color: #d9d1ff;
}
.theme-dark .labour-badge,
.theme-dark .profile-initial {
  background: #322b50;
  color: #c8baff;
}
.theme-dark .readonly,
.theme-dark .form-note,
.theme-dark .detail-grid > div {
  background: #2b2639;
  color: var(--muted);
}

.theme-dark .project-detail > div,
.theme-dark .pricing-summary,
.theme-dark .payment-summary,
.theme-dark .accounting-note,
.theme-dark .attendance-summary div,
.theme-dark .calendar-day:hover,
.theme-dark .calendar-day.today,
.theme-dark .settings-list a > i:first-child,
.theme-dark .transaction-icon,
.theme-dark .sales-pagination-link,
.theme-dark .payment-close,
.theme-dark .day-tab,
.theme-dark .category-track {
  background: #2b2639 !important;
}

.theme-dark input,
.theme-dark select,
.theme-dark textarea,
.theme-dark .line-row input,
.theme-dark .line-row select,
.theme-dark .mode-control .selected,
.theme-dark .day-tab.selected,
.theme-dark .sales-pagination-status {
  background: #181521 !important;
  border-color: #484158 !important;
  color: var(--ink) !important;
}
.theme-dark input::placeholder,
.theme-dark textarea::placeholder { color: #938ca8; }
.theme-dark input:focus,
.theme-dark select:focus,
.theme-dark textarea:focus { border-color: #a994ff !important; box-shadow: 0 0 0 3px #a994ff2e !important; }
.theme-dark option { background: #201c2a; color: #f4f1fb; }

/* Autocomplete menus sit above dark forms, so they need their own dark
   surface instead of retaining the light-mode white background. */
.theme-dark .item-suggestions,
.theme-dark .customer-suggestions {
  background: #201c2a !important;
  border-color: #4a4260 !important;
  box-shadow: 0 14px 30px #06040b80;
}
.theme-dark .item-suggestion,
.theme-dark .customer-suggestion {
  background: #201c2a !important;
  border-bottom-color: #3b354d !important;
  color: var(--ink) !important;
}
.theme-dark .item-suggestion:hover,
.theme-dark .item-suggestion:focus-visible,
.theme-dark .customer-suggestion:hover,
.theme-dark .customer-suggestion:focus-visible {
  background: #322b50 !important;
  color: #fff !important;
  outline: none;
}
.theme-dark .item-suggestion small,
.theme-dark .customer-suggestion small { color: var(--muted) !important; }

.theme-dark .bottom-nav,
.theme-dark .notifications > div {
  background: #201c2af2 !important;
  border-color: #3b354d !important;
  box-shadow: 0 -3px 22px #05030a66;
}
.theme-dark .bottom-nav a,
.theme-dark .bottom-nav button,
.theme-dark .notifications > div a { color: #c5bfd4; }
.theme-dark .bottom-nav .nav-add { border-color: #201c2a; }
.theme-dark .bottom-nav a:hover,
.theme-dark .bottom-nav button:hover { background: #322b44; color: #d8ceff; }

@media (hover: hover) and (pointer: fine) {
  .theme-dark .bottom-nav > a:not(.nav-add):hover,
  .theme-dark .bottom-nav > form > button:hover,
  .theme-dark .bottom-nav > .notifications > summary:hover {
    background: linear-gradient(135deg, #393150, #2b263d) !important;
    color: #eeeaff !important;
    box-shadow: 0 10px 22px #05030a80, inset 0 1px 0 #ffffff12;
  }

  .theme-dark .bottom-nav .nav-add:hover {
    box-shadow: 0 12px 28px #05030a9c, 0 0 0 4px #b9aaff30;
  }
}

.theme-dark .secondary-btn,
.theme-dark .tax-mode-button,
.theme-dark .discount-mode-button,
.theme-dark .danger-btn:not(:hover) {
  background: #2c2740 !important;
  border-color: #51486a !important;
  color: #d9d1ff !important;
}
.theme-dark .tax-mode-button.active,
.theme-dark .discount-mode-button.active { background: #7861dc !important; border-color: #a994ff !important; color: #fff !important; }
.theme-dark .remove-item { background: #321f29 !important; border-color: #77404b !important; color: #ff9aa9 !important; }
.theme-dark .billing-same-toggle { background: #29233b !important; border-color: #554a72 !important; }

.theme-dark .avatar,
.theme-dark .back,
.theme-dark .header-icon,
.theme-dark .brand-mark.brand-logo,
.theme-dark .company-hero img { background: #2a2536 !important; }
.theme-dark .brand-lockup span,
.theme-dark .settings-list a,
.theme-dark .project-list > a,
.theme-dark .sales-document-card { color: var(--ink); }

.theme-dark .sales-card-icon.draft,
.theme-dark .sales-empty > span,
.theme-dark .sales-status.draft { background: #322b50; color: #c2b4ff; }
.theme-dark .sales-card-icon.invoiced,
.theme-dark .sales-status.invoiced,
.theme-dark .accounting-kpi-icon.income,
.theme-dark .accounting-kpi-icon.positive,
.theme-dark .payment-btn { background: #183d36; color: #8ee7c5; }
.theme-dark .sales-card-icon.rejected,
.theme-dark .sales-status.rejected,
.theme-dark .accounting-kpi-icon.expense,
.theme-dark .accounting-kpi-icon.negative { background: #44242f; color: #ffacba; }
.theme-dark .accounting-kpi-icon.receivable,
.theme-dark .receivable-icon { background: #493919; color: #ffd77e; }

/* GST has nested report rows, so their light-mode gradients need their own
   dark surfaces instead of inheriting the white default. */
.theme-dark .gst-actions > div {
  background: linear-gradient(100deg, #29233a, #211d2d) !important;
  border-color: #4a4263;
}
.theme-dark .gst-actions > div > i {
  background: #342d50;
  color: #c9bcff;
}
.theme-dark .gst-ledger .section-head,
.theme-dark .gst-ledger article {
  border-color: #3b354d;
}
.theme-dark .gst-ledger .credit { color: #7ee8bd; }
.theme-dark .gst-ledger .payable { color: #ffadba; }

.theme-dark .line-heading,
.theme-dark .attendance-heading,
.theme-dark .ledger-heading,
.theme-dark .section-note,
.theme-dark .sales-card-detail,
.theme-dark .sales-card small,
.theme-dark .sales-document-card small,
.theme-dark .sales-document-card span,
.theme-dark .project-stats span,
.theme-dark .project-list small,
.theme-dark .project-list span,
.theme-dark .project-detail span { color: var(--muted); }
.theme-dark .attendance-heading {
  background: #2b2639 !important;
  color: #c5bfd4 !important;
  border-bottom: 1px solid #4a4260;
}
.theme-dark .attendance-row {
  background: #201c2a;
  color: var(--ink);
  border-top-color: #3b354d !important;
}
.theme-dark .attendance-row select {
  background: #181521 !important;
  border-color: #484158 !important;
  color: var(--ink) !important;
}
.theme-dark .line-row:hover { background: #272230; border-color: #4a4260; }
.theme-dark .revenue-row,
.theme-dark .ledger-row,
.theme-dark .settings-list a,
.theme-dark .attendance-row { border-color: var(--line); }

.theme-dark .toast { background: #193c34; color: #b8f4dc; }
.theme-dark .toast.error { background: #46242d; color: #ffc0c9; }
.theme-dark .status { background: #302c3a; color: #d8d1e8; }
.theme-dark .status.running,
.theme-dark .project-detail > .status.running {
  background: #1d3a5b !important;
  border: 1px solid #3f78ad;
  color: #b8dcff !important;
}
.theme-dark .status.completed { background: #193f34; color: #9be9c7; }
.theme-dark .status.cancelled { background: #4a2731; color: #ffb7c0; }
.theme-dark .status.on_hold,
.theme-dark .status.not_started { background: #4a391d; color: #ffdc88; }

@media (max-width: 620px) {
  .theme-toggle { top: 15px; right: 10px; justify-content:center; width:44px; min-height:44px; padding:0; border-radius:50%; }
  .theme-toggle span { display: none; }
  .theme-toggle svg { width: 17px; height: 17px; }
  /* Keep header actions clear of the fixed theme toggle. */
  .page-header > .header-icon { margin-right: 56px; }
}
