/* Предохранитель: у многих панелей есть собственный класс с display:grid/flex — авторское
   CSS-правило всегда перекрывает дефолтное браузерное [hidden]{display:none} (правило
   происхождения каскада важнее специфичности), из-за чего el.hidden=true молча ничего не
   делал для .salary-panel и подобных. !important здесь — намеренно и единственно правильно:
   "скрыто" обязано побеждать "как раскладывать содержимое", без исключений по всему сайту. */
[hidden] {
  display: none !important;
}

:root {
  --bg: #f6f7f4;
  --surface: #ffffff;
  --surface-strong: #eef5ef;
  --ink: #1f2623;
  --muted: #667069;
  --line: #d9dfd9;
  --green: #16855f;
  --green-dark: #0f6448;
  --teal: #157d8a;
  --red: #c4493d;
  --yellow: #f2b84b;
  --accent: #16855f;
  --accent-dark: #0f6448;
  --sidebar-bg: #24352e;
  --radius: 8px;
  --shadow: 0 12px 32px rgba(31, 38, 35, 0.08);
}

[data-theme="dark"] {
  --bg: #1a1d1b;
  --surface: #242725;
  --surface-strong: #2c3030;
  --ink: #e8ede9;
  --muted: #8fa393;
  --line: #363c38;
  --green: #34c98a;
  --green-dark: #27a871;
  --teal: #3ab8c8;
  --red: #e06b64;
  --yellow: #f5c96a;
  --accent: #34c98a;
  --accent-dark: #27a871;
  --sidebar-bg: #1a2420;
  --shadow: 0 12px 32px rgba(0, 0, 0, 0.35);
}

[data-theme="yellow"] {
  --bg: #fdf8ec;
  --surface: #fffdf4;
  --surface-strong: #fef3c7;
  --ink: #2c2510;
  --muted: #7a6a3a;
  --line: #e8d88a;
  --accent: #d4920a;
  --accent-dark: #b87c00;
  --sidebar-bg: #3d2e00;
  --shadow: 0 12px 32px rgba(180, 140, 0, 0.12);
}

[data-theme="blue"] {
  --bg: #f0f4fb;
  --surface: #ffffff;
  --surface-strong: #e4edf9;
  --ink: #0f1f3d;
  --muted: #5a72a0;
  --line: #c2d0ea;
  --accent: #2563eb;
  --accent-dark: #1d4ed8;
  --sidebar-bg: #0f2044;
  --shadow: 0 12px 32px rgba(37, 99, 235, 0.12);
}

[data-theme="purple"] {
  --bg: #f5f0fb;
  --surface: #ffffff;
  --surface-strong: #ede5f9;
  --ink: #1a0d33;
  --muted: #6b4f99;
  --line: #d0bff0;
  --accent: #7c3aed;
  --accent-dark: #6d28d9;
  --sidebar-bg: #1e0a40;
  --shadow: 0 12px 32px rgba(124, 58, 237, 0.12);
}

[data-theme="red"] {
  --bg: #fdf1f0;
  --surface: #ffffff;
  --surface-strong: #fce4e2;
  --ink: #2c0a08;
  --muted: #9a4040;
  --line: #f0c0bc;
  --accent: #dc2626;
  --accent-dark: #b91c1c;
  --sidebar-bg: #3b0a0a;
  --shadow: 0 12px 32px rgba(220, 38, 38, 0.12);
}

[data-theme="teal"] {
  --bg: #f0fafa;
  --surface: #ffffff;
  --surface-strong: #e0f5f5;
  --ink: #062020;
  --muted: #3a7070;
  --line: #b0dede;
  --accent: #0f7a8a;
  --accent-dark: #0a5f6e;
  --sidebar-bg: #062a30;
  --shadow: 0 12px 32px rgba(15, 122, 138, 0.12);
}

[data-theme="gray"] {
  --bg: #f2f2f2;
  --surface: #ffffff;
  --surface-strong: #e8e8e8;
  --ink: #1a1a1a;
  --muted: #666666;
  --line: #d0d0d0;
  --accent: #444444;
  --accent-dark: #222222;
  --sidebar-bg: #1a1a1a;
  --shadow: 0 12px 32px rgba(0, 0, 0, 0.10);
}

[data-theme="rose"] {
  --bg: #fff0f5;
  --surface: #ffffff;
  --surface-strong: #ffe4ef;
  --ink: #2d0a18;
  --muted: #9a4060;
  --line: #f0b8cc;
  --accent: #e11d6a;
  --accent-dark: #be185d;
  --sidebar-bg: #3b0a20;
  --shadow: 0 12px 32px rgba(225, 29, 106, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  color: var(--ink);
  background: var(--bg);
  font-family:
    Inter, "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, Arial, sans-serif;
}

button,
input,
select,
textarea {
  font: inherit;
}

.app-shell {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  min-height: 100vh;
}

.company-login-overlay {
  position: fixed;
  z-index: 1000;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at 20% 20%, rgba(22, 133, 95, 0.24), transparent 34%),
    rgba(20, 32, 27, 0.76);
}

.company-login-card {
  display: grid;
  width: min(420px, 100%);
  gap: 14px;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.24);
}

.company-login-card h2,
.company-login-card p {
  margin: 0;
}

.company-login-error {
  min-height: 18px;
  color: var(--red);
  font-size: 13px;
  font-weight: 800;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 28px;
  padding: 24px;
  color: #ffffff;
  background: var(--sidebar-bg);
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  order: 1;
}

.brand-mark {
  display: grid;
  width: 58px;
  height: 58px;
  place-items: center;
  border-radius: 10px;
  color: #1f2623;
  background: #8ce0ba;
  font-size: 18px;
  font-weight: 900;
  overflow: hidden;
}

.brand-mark img,
.topbar-brand-logo img,
.general-logo-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.brand strong,
.brand span {
  display: block;
}

.brand strong {
  font-size: 18px;
  line-height: 1.12;
}

.brand span {
  color: #bfd0c6;
  font-size: 15px;
  line-height: 1.25;
}

.main-nav {
  display: grid;
  gap: 8px;
  order: 3;
}

.main-nav a {
  padding: 12px 14px;
  border-radius: var(--radius);
  color: #dce8e1;
  text-decoration: none;
}

.main-nav .has-subnav {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.sub-nav[hidden] {
  display: none;
}

.main-nav a:hover,
.main-nav a.active {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.12);
}

.main-nav .sub-nav-link {
  display: block;
  margin-left: 16px;
  padding: 9px 12px;
  color: #bfd0c6;
  font-size: 14px;
}

.main-nav .sub-nav-link.active {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.08);
}

.support-box {
  order: 2;
  margin-top: 0;
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.04);
}

.support-box img {
  display: block;
  width: 100%;
  height: 120px;
  object-fit: cover;
  border-radius: 6px;
}

.support-box p {
  margin: 12px 0 4px;
  color: #bfd0c6;
}

.workspace {
  padding: 28px;
}

.topbar,
.topbar-actions,
.filters,
.stats-grid,
.detail-header,
.detail-row,
.work-item,
.timeline-item {
  display: flex;
}

.topbar {
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 22px;
  min-width: 0;
}

.topbar-brand {
  display: flex;
  min-width: 220px;
  align-items: center;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 10px 12px;
  background: linear-gradient(135deg, #ffffff 0%, #f0f7f3 100%);
  box-shadow: 0 10px 26px rgba(31, 38, 35, 0.07);
}

.topbar-brand-logo,
.general-logo-preview {
  display: grid;
  width: 48px;
  height: 48px;
  flex: 0 0 48px;
  place-items: center;
  overflow: hidden;
  border-radius: 12px;
  color: #123528;
  background: #8ce0ba;
  font-weight: 900;
}

.topbar-brand strong,
.topbar-brand span {
  display: block;
}

.topbar-brand strong {
  line-height: 1.1;
}

.topbar-brand div > span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 13px;
}

.topbar-title {
  min-width: 0;
}

.topbar[hidden],
.stats-grid[hidden],
.dashboard-grid[hidden],
.dashboard-insights[hidden],
.orders-layout[hidden] {
  display: none !important;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--green);
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
}

.required-hint {
  margin: -4px 0 14px;
  color: var(--muted);
  font-size: 12px;
}

.field-hint {
  color: var(--muted);
  font-weight: 400;
  font-size: 11px;
  margin-left: 4px;
}

#financeAvailableBreakdown {
  display: block;
  margin: 6px 0 0;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 34px;
}

.topbar-actions {
  gap: 10px;
  flex-wrap: wrap;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(280px, 0.9fr);
  gap: 18px;
  margin-bottom: 18px;
}

.dashboard-hero-card,
.dashboard-day-card,
.dashboard-panel {
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.dashboard-hero-card {
  position: relative;
  overflow: hidden;
  padding: 24px;
  background:
    radial-gradient(circle at top right, rgba(22, 133, 95, 0.18), transparent 32%),
    linear-gradient(135deg, #ffffff 0%, #f2f7f3 55%, #ebf5ef 100%);
}

.dashboard-hero-card::after {
  position: absolute;
  inset: auto -40px -60px auto;
  width: 220px;
  height: 220px;
  border-radius: 50%;
  background: rgba(21, 125, 138, 0.08);
  content: "";
}

.dashboard-hero-copy {
  position: relative;
  z-index: 1;
  max-width: 640px;
}

.dashboard-hero-copy h2 {
  margin-bottom: 10px;
  font-size: 34px;
  line-height: 1.05;
}

.dashboard-hero-copy p:last-child {
  margin-bottom: 0;
  max-width: 620px;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.6;
}

.dashboard-hero-actions,
.dashboard-module-strip,
.dashboard-day-stats,
.dashboard-insights,
.dashboard-panel-head {
  display: flex;
}

.dashboard-hero-actions {
  position: relative;
  z-index: 1;
  gap: 10px;
  margin-top: 18px;
  flex-wrap: wrap;
}

.dashboard-module-strip {
  position: relative;
  z-index: 1;
  gap: 10px;
  margin-top: 20px;
  flex-wrap: wrap;
}

.dashboard-module-strip span,
.dashboard-badge {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  border-radius: 999px;
  padding: 0 14px;
  font-size: 13px;
  font-weight: 700;
}

.dashboard-module-strip span {
  color: #184536;
  background: rgba(22, 133, 95, 0.12);
}

.dashboard-day-card {
  padding: 22px;
  background: linear-gradient(180deg, #24352e 0%, #1a2823 100%);
  color: #ffffff;
}

.dashboard-panel-head {
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.dashboard-panel-label {
  display: block;
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.dashboard-day-card .dashboard-panel-label,
.dashboard-day-card span {
  color: #bfd0c6;
}

.dashboard-day-card strong {
  font-size: 28px;
}

.dashboard-badge {
  color: #143528;
  background: #8ce0ba;
}

.dashboard-day-stats {
  display: grid;
  gap: 12px;
  margin-top: 18px;
}

.dashboard-day-stats div {
  padding: 14px 16px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.04);
}

.dashboard-day-stats span {
  display: block;
  margin-bottom: 6px;
}

.dashboard-insights {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  margin-bottom: 18px;
}

.dashboard-panel {
  padding: 20px;
}

.dashboard-panel h3 {
  margin: 0;
  font-size: 20px;
}

.dashboard-status-list,
.dashboard-master-list,
.dashboard-attention-list,
.dashboard-activity-list {
  display: grid;
  gap: 10px;
  margin-top: 16px;
}

.dashboard-status-row,
.dashboard-master-row,
.dashboard-activity-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fbfcfa;
}

.dashboard-status-row span,
.dashboard-master-row span,
.dashboard-activity-row span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

.dashboard-attention-card {
  display: flex;
  width: 100%;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  border: 1px solid #e6d4ae;
  border-radius: 14px;
  padding: 14px 16px;
  color: var(--ink);
  background: linear-gradient(180deg, #fff9ec 0%, #fffdf8 100%);
  cursor: pointer;
  text-align: left;
}

.dashboard-attention-card strong,
.dashboard-activity-row strong,
.dashboard-master-row strong {
  display: block;
}

.dashboard-attention-card span {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: 13px;
}

.dashboard-empty {
  padding: 18px;
  border: 1px dashed var(--line);
  border-radius: 14px;
  color: var(--muted);
  background: #fbfcfa;
  text-align: center;
}

.dashboard-chart {
  position: relative;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(56px, 1fr));
  align-items: end;
  gap: 10px;
  min-height: 230px;
  margin-top: 16px;
  padding: 30px 0 4px;
  background:
    linear-gradient(to top, rgba(125, 139, 151, 0.18) 1px, transparent 1px) 0 30px / 100% 37.5px repeat-y;
  border-bottom: 1px solid var(--line);
}

.dashboard-chart-toolbar,
.dashboard-chart-metrics {
  display: grid;
  gap: 10px;
}

.dashboard-chart-toolbar {
  grid-template-columns: 170px 140px repeat(2, minmax(0, 1fr)) 110px;
  margin-top: 16px;
}

.dashboard-chart-metrics {
  grid-template-columns: repeat(auto-fit, minmax(135px, 1fr));
  margin-top: 12px;
}

.dashboard-chart-metrics article {
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fbfcfa;
}

.dashboard-chart-metrics span {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 12px;
}

.dashboard-chart-metrics strong {
  font-size: 20px;
}

.dashboard-chart-col {
  display: grid;
  gap: 8px;
  justify-items: center;
}

.dashboard-chart-bars {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: end;
  justify-content: center;
  gap: 6px;
  width: 100%;
  height: 150px;
}

.dashboard-chart-bar {
  position: relative;
  display: block;
  width: 16px;
  min-height: 6px;
  border-radius: 999px 999px 6px 6px;
}

.dashboard-chart-bar b {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 4px);
  transform: translateX(-50%);
  color: var(--ink);
  font-size: 10px;
  font-weight: 800;
  line-height: 1;
  white-space: nowrap;
}

.dashboard-chart-levels {
  position: absolute;
  inset: 30px 0 28px;
  pointer-events: none;
}

.dashboard-chart-levels span {
  position: absolute;
  left: 0;
  transform: translateY(50%);
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
}

.dashboard-chart[data-mode="combined"] .dashboard-chart-bar b {
  display: none;
}

.dashboard-chart[data-mode="combined"] .dashboard-chart-bar:hover b {
  display: block;
  z-index: 4;
  padding: 3px 5px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #ffffff;
  box-shadow: var(--shadow);
}

.dashboard-chart-bar.orders {
  background: linear-gradient(180deg, #8ce0ba 0%, #16855f 100%);
}

.dashboard-chart-bar.revenue {
  background: linear-gradient(180deg, #8cc8ff 0%, #2f78e5 100%);
}

.dashboard-chart-bar.expenses {
  background: linear-gradient(180deg, #ffc4a9 0%, #d85d3f 100%);
}

.dashboard-chart-bar.profit {
  background: linear-gradient(180deg, #9de7b8 0%, #1f9b63 100%);
}

.dashboard-chart-bar.net-profit {
  background: linear-gradient(180deg, #94f0dc 0%, #14a38b 100%);
}

.dashboard-chart-bar.tax {
  background: linear-gradient(180deg, #d7c2ff 0%, #7659c7 100%);
}

.dashboard-chart-bar.loss {
  background: linear-gradient(180deg, #ffb3b3 0%, #c4493d 100%);
}

.dashboard-chart-bar.average {
  background: linear-gradient(180deg, #ffcc95 0%, #f08a24 100%);
}

.dashboard-chart-col small {
  color: var(--muted);
  font-size: 11px;
  text-align: center;
}

.dashboard-chart-legend {
  display: flex;
  gap: 16px;
  margin-top: 12px;
  color: var(--muted);
  font-size: 13px;
  flex-wrap: wrap;
}

.dashboard-chart-legend span {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.chart-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.chart-dot.orders {
  background: #16855f;
}

.chart-dot.revenue {
  background: #2f78e5;
}

.chart-dot.expenses {
  background: #d85d3f;
}

.chart-dot.profit {
  background: #1f9b63;
}

.chart-dot.net-profit {
  background: #14a38b;
}

.chart-dot.tax {
  background: #7659c7;
}

.chart-dot.average {
  background: #f08a24;
}

.primary-button,
.ghost-button,
.status-select {
  min-height: 42px;
  border-radius: var(--radius);
  cursor: pointer;
}

.primary-button {
  border: 0;
  padding: 0 18px;
  color: #ffffff;
  background: var(--accent);
  font-weight: 700;
}

.primary-button:hover {
  background: var(--green-dark);
}

.ghost-button {
  border: 1px solid var(--line);
  padding: 0 16px;
  color: var(--ink);
  background: var(--surface);
}

.primary-button:disabled,
.ghost-button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
  background: var(--line);
  color: var(--muted);
  border-color: var(--line);
  box-shadow: none;
}

.primary-button:disabled:hover,
.ghost-button:disabled:hover {
  background: var(--line);
}

.link-button {
  border: none;
  padding: 0;
  background: none;
  color: var(--green);
  cursor: pointer;
  font-size: inherit;
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.link-button:hover {
  color: var(--green-dark);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.stats-grid article,
.orders-panel,
.details-panel,
.contractors-panel,
.finance-panel,
.finance-summary article {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.stats-grid article {
  padding: 18px;
}

.stats-grid span {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
}

.stats-grid strong {
  font-size: 26px;
}

.orders-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 380px;
  gap: 18px;
  align-items: start;
}

.orders-panel {
  min-width: 0;
}

.filters {
  align-items: end;
  gap: 12px;
  padding: 16px;
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}

label,
.field-group {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.search-field {
  flex: 1 1 300px;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0 12px;
  color: var(--ink);
  background: #ffffff;
}

input,
select {
  min-height: 42px;
}

textarea {
  min-height: 90px;
  padding-top: 10px;
  resize: vertical;
}

.table-wrap {
  position: relative;
  overflow-x: auto;
}

.table-settings-button {
  position: absolute;
  z-index: 3;
  top: 8px;
  right: 8px;
  width: 36px;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #ffffff;
  cursor: pointer;
}

table {
  width: 100%;
  min-width: 760px;
  border-collapse: collapse;
}

th,
td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

th {
  color: var(--muted);
  background: #fbfcfa;
  font-size: 13px;
}

th[data-column-key] {
  position: relative;
  user-select: none;
}

th[data-column-key].dragging {
  opacity: 0.45;
}

th[data-column-key].drag-over {
  box-shadow: inset 3px 0 0 #2f78e5;
}

th.sorted,
th.filtered {
  color: #1d5ec9;
  background: #f2f6ff;
}

.column-header-button {
  display: inline-flex;
  width: 100%;
  min-height: 28px;
  align-items: center;
  justify-content: flex-start;
  gap: 6px;
  border: 0;
  padding: 0;
  color: inherit;
  background: transparent;
  cursor: grab;
  text-align: left;
}

.column-header-button span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.column-header-button b {
  color: #1d5ec9;
  font-size: 12px;
}

.column-header-button i {
  margin-left: auto;
  color: #9aa5b1;
  font-style: normal;
  font-size: 12px;
}

.column-menu {
  position: fixed;
  z-index: 40;
  display: grid;
  width: 270px;
  gap: 8px;
  border: 1px solid #2f78e5;
  border-radius: 6px;
  padding: 12px;
  background: #ffffff;
  box-shadow: 0 18px 40px rgba(31, 38, 35, 0.16);
}

.column-menu[hidden] {
  display: none !important;
}

.column-menu-title {
  padding-bottom: 6px;
  border-bottom: 1px solid var(--line);
  color: var(--ink);
  font-weight: 800;
}

.column-menu-move {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.column-menu button {
  min-height: 34px;
  border: 0;
  border-radius: 5px;
  padding: 0 8px;
  color: var(--ink);
  background: transparent;
  cursor: pointer;
  text-align: left;
}

.column-menu button:hover {
  background: #dfeaff;
}

.column-menu label {
  gap: 5px;
}

.column-menu select {
  min-height: 36px;
}

tbody tr {
  cursor: pointer;
}

tbody tr:hover,
tbody tr.selected {
  background: var(--surface-strong);
}

.client-name {
  display: block;
  font-weight: 800;
}

.client-phone {
  color: var(--muted);
  font-size: 13px;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  color: #ffffff;
  font-size: 13px;
  font-weight: 800;
}

.badge.new {
  background: var(--teal);
}

.badge.progress {
  background: var(--green);
}

.badge.waiting {
  color: #3c2a00;
  background: var(--yellow);
}

.badge.ready {
  background: #5e6ad2;
}

.badge.done {
  background: #606a63;
}

.badge.cancelled {
  background: #a34f46;
}

.badge.custom {
  color: #233247;
  background: #d9e6f7;
}

.statuses-dialog .price-table td:first-child {
  text-align: center;
  vertical-align: middle;
}

.statuses-dialog .price-table td {
  vertical-align: middle;
}

.status-preview-badge {
  display: inline-block;
  min-width: 90px;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 130px;
}

.status-color-cell {
  padding: 6px 8px !important;
}

.status-palette {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  align-items: center;
  max-width: 230px;
}

.swatch-btn {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.35);
  cursor: pointer;
  padding: 0;
  flex-shrink: 0;
  transition: transform 0.12s, box-shadow 0.12s;
}

.swatch-btn:hover {
  transform: scale(1.18);
}

.swatch-btn.selected {
  border-color: #fff;
  box-shadow: 0 0 0 2.5px #333;
  transform: scale(1.12);
}

.swatch-custom-label {
  display: flex;
  align-items: center;
  cursor: pointer;
  position: relative;
}

.swatch-custom-input {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 2px dashed rgba(0,0,0,0.25);
  padding: 0;
  cursor: pointer;
  overflow: hidden;
  background: none;
}

.deadline.urgent {
  color: var(--red);
  font-weight: 800;
}

.details-panel {
  position: sticky;
  top: 18px;
  min-height: 560px;
  max-height: calc(100vh - 36px);
  overflow-y: auto;
  padding: 20px;
}

.finance-view[hidden] {
  display: none;
}

.warehouse-view[hidden] {
  display: none;
}

.reports-view[hidden] {
  display: none;
}

.contractors-view[hidden] {
  display: none;
}

.finance-view {
  display: grid;
  gap: 18px;
}

.warehouse-view {
  display: grid;
  gap: 18px;
}

.reports-view {
  display: grid;
  gap: 18px;
}

.warehouse-header,
.warehouse-actions,
.warehouse-toolbar,
.reports-header {
  display: flex;
  align-items: center;
}

.warehouse-header,
.reports-header {
  justify-content: space-between;
  gap: 16px;
}

.warehouse-actions,
.warehouse-toolbar {
  gap: 10px;
  flex-wrap: wrap;
}

.warehouse-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.warehouse-summary article,
.warehouse-groups,
.warehouse-table-panel,
.warehouse-section-panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.warehouse-summary article {
  padding: 16px;
}

.warehouse-summary span {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.warehouse-summary strong {
  font-size: 24px;
}

.reports-tabs {
  display: flex;
  max-width: 760px;
  border-bottom: 1px solid var(--line);
  gap: 18px;
  overflow-x: auto;
}

.reports-tabs button {
  border: 0;
  border-bottom: 2px solid transparent;
  padding: 0 0 10px;
  color: var(--ink);
  background: transparent;
  cursor: pointer;
  white-space: nowrap;
}

.reports-tabs button.active {
  border-color: var(--blue);
  color: var(--blue);
  font-weight: 800;
}

.reports-note {
  max-width: 820px;
  margin: -4px 0 0;
  color: var(--muted);
}

.schedule-view[hidden] {
  display: none;
}

.schedule-view {
  display: grid;
  gap: 18px;
}

.schedule-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.schedule-legend {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  font-size: 13px;
  color: var(--muted);
}

.schedule-legend-item {
  padding: 2px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
}

.schedule-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.schedule-table {
  border-collapse: collapse;
  width: 100%;
}

.schedule-table th,
.schedule-table td {
  border: 1px solid var(--line);
  text-align: center;
  padding: 4px 6px;
  font-size: 12px;
  white-space: nowrap;
}

.schedule-name-col {
  text-align: left !important;
  min-width: 180px;
  position: sticky;
  left: 0;
  background: var(--surface);
  z-index: 1;
}

.schedule-role {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 400;
}

.schedule-company-group td {
  text-align: left !important;
  background: var(--surface-strong);
  font-weight: 700;
  color: var(--muted);
  padding: 6px 10px;
}

.schedule-weekend {
  background: var(--surface-strong);
}

.schedule-cell {
  cursor: pointer;
  min-width: 28px;
  font-weight: 700;
}

.schedule-cell:hover {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

.schedule-cell-work {
  background: color-mix(in srgb, var(--green) 22%, var(--surface));
  color: var(--green-dark, var(--green));
}

.schedule-cell-off {
  background: color-mix(in srgb, var(--muted) 18%, var(--surface));
  color: var(--muted);
}

.schedule-cell-vacation {
  background: color-mix(in srgb, var(--teal) 22%, var(--surface));
  color: var(--teal);
}

.schedule-cell-sick {
  background: color-mix(in srgb, var(--red) 22%, var(--surface));
  color: var(--red);
}

.schedule-legend-item.schedule-cell-work { background: color-mix(in srgb, var(--green) 22%, var(--surface)); color: var(--green-dark, var(--green)); }
.schedule-legend-item.schedule-cell-off { background: color-mix(in srgb, var(--muted) 18%, var(--surface)); color: var(--muted); }
.schedule-legend-item.schedule-cell-vacation { background: color-mix(in srgb, var(--teal) 22%, var(--surface)); color: var(--teal); }
.schedule-legend-item.schedule-cell-sick { background: color-mix(in srgb, var(--red) 22%, var(--surface)); color: var(--red); }

.schedule-shift-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(160px, 1fr));
  gap: 12px;
  padding: 4px 0 16px;
}

.schedule-shift-fields label {
  display: grid;
  gap: 6px;
  color: var(--ink);
  font-size: 14px;
}

.schedule-shift-comment {
  grid-column: 1 / -1;
}

.report-filter-grid {
  display: grid;
  max-width: 980px;
  grid-template-columns: repeat(3, minmax(190px, 1fr));
  gap: 12px;
  align-items: end;
}

.report-filter-grid label {
  display: grid;
  gap: 6px;
  color: var(--ink);
  font-size: 14px;
}

.report-filter-grid label span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.date-range-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.report-filter-grid input,
.report-filter-grid select {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 12px;
  background: #fff;
}

.report-summary {
  display: grid;
  grid-template-columns: repeat(5, minmax(130px, 1fr));
  gap: 12px;
}

.report-summary article {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: var(--surface);
}

.report-summary span {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 13px;
}

.report-summary strong {
  font-size: 22px;
}

.reports-result {
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: var(--surface);
}

.reports-result .table-wrap {
  max-height: 560px;
}

.report-empty {
  display: grid;
  gap: 6px;
  padding: 28px;
  text-align: center;
}

.report-empty span {
  color: var(--muted);
}

.warehouse-layout {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  gap: 14px;
  align-items: start;
}

.warehouse-groups {
  display: grid;
  gap: 12px;
  padding: 14px;
}

.stock-group-list {
  display: grid;
  gap: 4px;
}

.stock-group-list button {
  display: flex;
  min-height: 34px;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border: 0;
  border-radius: 6px;
  padding: 0 10px;
  color: var(--ink);
  background: transparent;
  cursor: pointer;
  text-align: left;
}

.stock-group-list button:hover,
.stock-group-list button.active {
  background: #e8f1ff;
}

.stock-group-list b {
  color: var(--muted);
}

.warehouse-toolbar {
  padding: 14px;
  border-bottom: 1px solid var(--line);
}

.stock-sort-note {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.warehouse-table-panel {
  min-width: 0;
  overflow: hidden;
}

.warehouse-table-panel .table-wrap {
  overflow-x: auto;
}

.warehouse-table th,
.warehouse-table td {
  white-space: nowrap;
}

.warehouse-table th:last-child,
.warehouse-table td:last-child {
  position: sticky;
  right: 0;
  background: var(--surface);
  box-shadow: -2px 0 4px rgba(0,0,0,0.06);
  z-index: 1;
}

.stock-serials {
  display: inline-block;
  max-width: 260px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.stock-row-button {
  min-height: 32px;
  padding: 0 10px;
  font-size: 12px;
}

.warehouse-table .stock-status {
  display: inline-flex;
  min-width: 34px;
  min-height: 26px;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  color: #ffffff;
  font-weight: 800;
}

.stock-status.ok {
  background: var(--green);
}

.stock-status.low {
  color: #3c2a00;
  background: var(--yellow);
}

.stock-status.empty {
  background: var(--red);
}

.stock-row-low td {
  background: rgba(242, 184, 75, 0.12);
}

.stock-actions-cell {
  display: flex;
  gap: 6px;
  align-items: center;
  white-space: nowrap;
}

.stock-margin-pos { color: var(--green); }
.stock-margin-neg { color: var(--red); }

.receipt-add-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 20px;
}

.receipt-basket-title {
  margin: 0;
  padding: 16px 20px 8px;
  font-size: 14px;
  color: var(--muted);
}

.receipt-basket-table tfoot td {
  border-top: 2px solid var(--line);
  padding-top: 6px;
}

.receipt-journal {
  padding: 0 0 20px;
}

.receipt-journal-title {
  margin: 0;
  padding: 20px 20px 10px;
  font-size: 16px;
}

.receipt-journal-empty {
  padding: 16px 20px;
  color: var(--muted);
}

.receipt-journal-items {
  max-width: 240px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.warehouse-section-panel {
  display: grid;
  gap: 12px;
  padding: 20px;
}

.warehouse-section-panel[hidden] {
  display: none;
}

.warehouse-layout[hidden] {
  display: none;
}

.warehouse-summary[hidden] {
  display: none;
}

.warehouse-operation-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.stock-qty-popup {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(0,0,0,0.35);
  display: flex;
  align-items: center;
  justify-content: center;
}

.stock-qty-popup-inner {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  min-width: 260px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.stock-item-popup-inner {
  min-width: 320px;
  max-width: 420px;
  width: 100%;
}

.stock-item-popup-inner label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
}

.stock-item-popup-inner input {
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-size: inherit;
  color: var(--ink);
}

.stock-qty-actions {
  display: flex;
  gap: 8px;
}

.stock-qty-input {
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-size: 16px;
  width: 100%;
  box-sizing: border-box;
}

.inline-group-form {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
}

.inline-group-form input {
  flex: 1 1 100%;
  min-width: 0;
  padding: 5px 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-size: 13px;
}

.inline-group-error {
  flex: 1 1 100%;
  font-size: 12px;
}

.ws-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 12px 0;
}

.ws-tabs .ghost-button.active {
  background: var(--primary, #2f78e5);
  color: #fff;
  border-color: var(--primary, #2f78e5);
}

.ws-content {
  margin-top: 8px;
}

.ws-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 12px;
}

.ws-list-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  flex-wrap: wrap;
}

.ws-list-item span {
  flex: 1;
  min-width: 0;
}

.ws-item-fields {
  display: flex;
  flex: 1;
  min-width: 0;
  gap: 6px;
  flex-wrap: wrap;
}

.ws-item-fields input,
.ws-item-fields select {
  flex: 1;
  min-width: 100px;
  padding: 4px 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-size: inherit;
  box-sizing: border-box;
}

.ws-add-location-form {
  flex-wrap: wrap;
}

.ws-add-location-form select,
.ws-add-location-form input {
  flex: 1;
  min-width: 100px;
}

.ws-group-input {
  flex: 1;
  min-width: 0;
  padding: 4px 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-size: inherit;
}

.ws-add-form {
  display: flex;
  gap: 8px;
}

.ws-add-form input {
  flex: 1;
  min-width: 0;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-size: inherit;
}

.ws-minqty-table {
  display: grid;
  gap: 4px;
}

.ws-minqty-header,
.ws-minqty-row {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(0, 1fr) 80px 80px;
  gap: 8px;
  align-items: center;
  padding: 6px 10px;
}

.ws-minqty-header {
  font-weight: 700;
  font-size: 13px;
  color: var(--muted);
  border-bottom: 1px solid var(--line);
}

.ws-minqty-row {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.ws-minqty-input {
  width: 100%;
  min-width: 0;
  padding: 4px 6px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-size: inherit;
  box-sizing: border-box;
}

.warehouse-operation-grid article {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  background: #fbfcfa;
  font-weight: 800;
}

.receipt-panel {
  padding: 0;
  overflow: hidden;
}

.receipt-form,
.receipt-items,
.receipt-result {
  display: grid;
  gap: 12px;
  padding: 16px;
}

.receipt-form {
  grid-template-columns: minmax(220px, 1.4fr) repeat(3, minmax(140px, 1fr));
  border-bottom: 1px solid var(--line);
}

.receipt-items {
  grid-template-columns: minmax(260px, 1.6fr) repeat(5, minmax(120px, 1fr));
  border-bottom: 1px solid var(--line);
}

.receipt-items .wide-field {
  grid-column: 1 / -1;
}

.stock-shipment-panel {
  margin: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbfcfa;
}

.stock-shipment-panel .receipt-items {
  padding: 0;
  border-bottom: 0;
}

.receipt-result {
  grid-template-columns: repeat(2, minmax(160px, 1fr)) auto;
  align-items: end;
  background: #fbfcfa;
}

.receipt-result article {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
  background: #ffffff;
}

.receipt-result span {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.contractors-view {
  display: grid;
  gap: 18px;
}

.contractors-header,
.contractor-actions,
.contractors-toolbar,
.contractor-tabs {
  display: flex;
  align-items: center;
}

.contractors-header {
  justify-content: space-between;
  gap: 16px;
}

.contractor-actions,
.contractors-toolbar {
  gap: 10px;
  flex-wrap: wrap;
}

.contractors-toolbar {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.compact-search {
  flex: 0 1 320px;
}

.contractor-tabs {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #ffffff;
}

.contractor-tabs button {
  min-height: 42px;
  border: 0;
  border-right: 1px solid var(--line);
  padding: 0 16px;
  color: var(--ink);
  background: transparent;
  cursor: pointer;
}

.contractor-tabs button:last-child {
  border-right: 0;
}

.contractor-tabs button.active {
  color: #ffffff;
  background: #2f78e5;
  font-weight: 700;
}

.contractors-panel {
  min-width: 0;
}

.contractor-check {
  width: 18px;
  height: 18px;
  min-height: 18px;
  padding: 0;
}

.finance-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.finance-header h2 {
  margin: 0;
  font-size: 30px;
}

.finance-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
}

.expense-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.settings-tables-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 0.95fr);
  gap: 14px;
  align-items: start;
}

.settings-table-panel {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #ffffff;
}

.settings-table-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}

.settings-table-head h3 {
  margin: 0;
  font-size: 18px;
}

.settings-table-head span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.workers-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  background: #fbfcfa;
}

.workers-summary article {
  display: grid;
  gap: 4px;
}

.workers-summary span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.workers-summary strong {
  font-size: 16px;
}

.expense-summary article {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
  background: #fbfcfa;
}

.expense-summary span {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
}

.expense-summary strong {
  font-size: 22px;
}

.finance-summary article,
.finance-panel {
  padding: 18px;
}

.finance-summary span {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
}

.finance-summary strong {
  font-size: 24px;
}

.finance-panel h3 {
  margin-bottom: 14px;
}

.salary-panel {
  display: grid;
  gap: 14px;
}

.salary-panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.salary-panel-head h3 {
  margin: 0;
}

.salary-panel-head > span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.salary-scenario-tabs {
  margin-bottom: 2px;
}

.salary-scenario-panel {
  display: grid;
  gap: 14px;
}

.salary-form {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
  align-items: end;
}

.quick-shift-panel {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.quick-shift-panel > div {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.quick-shift-hint {
  color: var(--muted);
  font-size: 13px;
}

.cashbox-balance-preview {
  margin: 0;
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
}

.cashbox-scenario-tabs {
  margin-bottom: 2px;
}

.expense-from-cash-panel,
.owner-withdrawal-panel {
  display: grid;
  gap: 14px;
}

.expense-from-cash-form,
.owner-withdrawal-form {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
  align-items: end;
}

.salary-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.order-settlement-panel,
.shift-settlement-panel {
  display: grid;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  background: #ffffff;
}

.order-settlement-form,
.order-settlement-summary,
.shift-settlement-form,
.shift-settlement-summary {
  display: grid;
  gap: 10px;
  padding: 14px;
}

.order-settlement-form,
.shift-settlement-form {
  grid-template-columns: minmax(220px, 1.3fr) repeat(3, minmax(140px, 1fr));
  border-bottom: 1px solid var(--line);
}

.order-settlement-summary,
.shift-settlement-summary {
  grid-template-columns: repeat(4, minmax(130px, 1fr));
  background: #fbfcfa;
}

.order-settlement-summary article,
.shift-settlement-summary article {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #ffffff;
}

.order-settlement-summary span,
.shift-settlement-summary span {
  display: block;
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.order-settlement-summary strong,
.shift-settlement-summary strong {
  font-size: 18px;
}

.order-settlement-panel > .primary-button,
.shift-settlement-panel > .primary-button {
  justify-self: start;
  margin: 0 14px 14px;
}

.salary-summary article {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
  background: #fbfcfa;
}

.salary-summary span {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.finance-placeholder {
  color: var(--muted);
}

.finance-placeholder p {
  max-width: 720px;
  margin-bottom: 0;
  line-height: 1.6;
}

.accounts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 12px;
}

.account-card {
  display: grid;
  gap: 7px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  color: var(--ink);
  background: #fbfcfa;
}

.account-card.closed {
  opacity: 0.62;
}

.account-card span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.account-card strong,
.account-name-input {
  font-size: 18px;
}

.account-name-input {
  min-height: 36px;
  padding: 0 10px;
  font-weight: 800;
}

.account-card b {
  font-size: 24px;
}

.account-card-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.account-card-actions .ghost-button {
  min-height: 34px;
  padding: 0 10px;
}

.transfer-panel {
  display: grid;
  gap: 12px;
  margin-top: 16px;
}

.transfer-panel h4,
.account-editor-panel h4 {
  margin: 0;
  font-size: 18px;
}

.account-editor-panel {
  display: grid;
  gap: 12px;
  margin-top: 16px;
}

.transfer-form,
.account-form {
  display: grid;
  gap: 10px;
  align-items: end;
}

.transfer-form {
  grid-template-columns: repeat(2, minmax(150px, 1fr)) minmax(140px, 0.8fr) minmax(220px, 1.4fr) auto;
}

.account-form {
  grid-template-columns: minmax(180px, 1.4fr) minmax(140px, 0.8fr) minmax(150px, 0.8fr) auto;
  gap: 10px;
  align-items: end;
}

.empty-state {
  display: grid;
  min-height: 510px;
  place-content: center;
  color: var(--muted);
  text-align: center;
}

.detail-header {
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}

.detail-header h2 {
  margin-bottom: 4px;
}

.detail-header p {
  color: var(--muted);
}

.status-select {
  max-width: 150px;
}

.detail-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  margin-bottom: 16px;
  border: 1px solid var(--line);
  border-radius: 6px;
  overflow: hidden;
}

.detail-tabs button {
  min-height: 42px;
  border: 0;
  border-right: 1px solid var(--line);
  color: var(--ink);
  background: #f7f8fa;
  cursor: pointer;
  font-weight: 700;
}

.detail-tabs button:last-child {
  border-right: 0;
}

.detail-tabs button.active {
  color: #ffffff;
  background: var(--green);
}

.detail-row {
  justify-content: space-between;
  gap: 16px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}

.order-info-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.order-info-form .wide-field {
  grid-column: 1 / -1;
}

.detail-row span {
  color: var(--muted);
}

.detail-section {
  margin-top: 22px;
}

.detail-section h3 {
  margin-bottom: 10px;
  font-size: 16px;
}

.work-list,
.timeline {
  display: grid;
  gap: 10px;
}

.service-adder {
  position: relative;
  margin-bottom: 12px;
}

.comment-adder {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 12px;
}

.comment-input {
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
  resize: vertical;
  font-family: inherit;
  font-size: inherit;
  padding: 8px;
  border: 1px solid #ccc;
  border-radius: 4px;
}

.comment-adder .add-comment-button {
  align-self: flex-end;
}

.service-search-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 170px;
  gap: 8px;
}

.service-search-input {
  border-color: #2f78e5;
}

.price-dropdown {
  position: absolute;
  z-index: 8;
  top: calc(100% + 4px);
  left: 0;
  width: min(520px, 100%);
  max-height: 280px;
  overflow-y: auto;
  border: 1px solid #2f78e5;
  border-radius: 6px;
  background: #ffffff;
  box-shadow: 0 18px 40px rgba(31, 38, 35, 0.16);
}

.price-dropdown[hidden] {
  display: none !important;
}

.price-option {
  display: flex;
  width: 100%;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 0;
  border-bottom: 1px solid var(--line);
  padding: 10px 12px;
  color: var(--ink);
  background: #ffffff;
  cursor: pointer;
  text-align: left;
}

.price-option:hover,
.price-option:first-child {
  background: #dfeaff;
}

.price-option span,
.price-option small {
  display: block;
}

.price-option small {
  margin-top: 3px;
  color: var(--muted);
}

.price-option b {
  white-space: nowrap;
}

.create-price-option {
  color: #1d5ec9;
}

.work-item,
.timeline-item {
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbfcfa;
}

.work-item {
  align-items: center;
}

.remove-work-from-order,
.edit-work-in-order {
  display: grid;
  width: 30px;
  height: 30px;
  flex: 0 0 30px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #ffffff;
  cursor: pointer;
  font-size: 18px;
}

.remove-work-from-order {
  color: var(--red);
}

.edit-work-in-order {
  color: var(--muted);
}

.edit-work-in-order:hover {
  color: var(--green);
  border-color: var(--green);
}

.work-item-editing {
  flex-direction: column;
  align-items: stretch !important;
  gap: 10px;
  background: #f4faf7;
  border-color: var(--green);
}

.work-edit-fields {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.work-edit-fields .we-title {
  font-weight: 600;
  font-size: 15px;
}

.work-edit-row2 {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.work-edit-row2 label {
  display: flex;
  flex-direction: column;
  gap: 3px;
  flex: 1;
  min-width: 80px;
}

.work-edit-row2 label span {
  font-size: 11px;
  color: var(--muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.work-edit-actions {
  display: flex;
  gap: 8px;
}

.work-item small,
.timeline-item small {
  display: block;
  margin-top: 3px;
  color: var(--muted);
}

.note {
  margin-bottom: 0;
  padding: 12px;
  border-left: 4px solid var(--green);
  border-radius: 0 var(--radius) var(--radius) 0;
  background: var(--surface-strong);
}

.order-payments-list {
  display: grid;
  gap: 10px;
}

.order-payment-row {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbfcfa;
}

.order-payment-main {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 14px;
}

.order-payment-main strong {
  font-size: 15px;
}

.order-payment-main span {
  color: var(--muted);
  font-size: 13px;
}

.order-payment-status-badge {
  margin-left: auto;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  background: color-mix(in srgb, var(--green) 16%, var(--surface));
  color: var(--green);
}

.order-payment-row.order-payment-reversed .order-payment-status-badge,
.order-payment-status-badge.status-reversed {
  background: color-mix(in srgb, var(--red) 14%, var(--surface));
  color: var(--red);
}

.order-payment-row.order-payment-compensating {
  background: var(--surface-strong);
  border-style: dashed;
}

.order-payment-reason,
.order-payment-links {
  margin-top: 6px;
  font-size: 13px;
  color: var(--muted);
}

.order-payment-actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.order-payment-payroll-warning {
  margin-bottom: 10px;
  padding: 10px 12px;
  border: 1px solid var(--warning, #b8860b);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--warning, #b8860b) 12%, var(--surface));
  color: var(--warning, #b8860b);
  font-size: 13px;
}

.order-payment-ambiguous-note {
  margin-top: 6px;
  font-size: 12px;
  color: var(--red);
}

.order-payment-preview {
  margin: 0;
  padding: 10px;
  border-radius: 6px;
  background: var(--surface-strong);
  font-size: 13px;
  line-height: 1.5;
}

.profit-row {
  display: flex;
  justify-content: flex-end;
  gap: 18px;
  margin-top: 12px;
  color: var(--muted);
  flex-wrap: wrap;
}

.profit-row strong {
  color: var(--green);
}

.order-dialog,
.template-dialog,
.payment-dialog,
.contractor-dialog,
.table-settings-dialog,
.price-dialog,
.print-preview-dialog {
  width: min(980px, calc(100vw - 20px));
  height: min(900px, calc(100vh - 20px));
  border: 0;
  border-radius: 6px;
  padding: 0;
  color: var(--ink);
  background: #f7f8fa;
  box-shadow: 0 24px 80px rgba(31, 38, 35, 0.24);
}

.order-dialog::backdrop,
.template-dialog::backdrop,
.payment-dialog::backdrop,
.contractor-dialog::backdrop,
.table-settings-dialog::backdrop,
.price-dialog::backdrop,
.print-preview-dialog::backdrop {
  background: rgba(31, 38, 35, 0.46);
}

.order-form,
.payment-form,
.contractor-form,
.table-settings-form,
.price-form {
  display: grid;
  grid-template-rows: auto;
  gap: 20px;
  min-height: 100%;
  padding: 0 24px 84px;
  overflow-y: auto;
}

.template-form {
  gap: 0;
  padding: 0;
  overflow: hidden;
}

.payment-dialog {
  width: min(520px, calc(100vw - 20px));
  height: auto;
}

.contractor-dialog {
  width: min(760px, calc(100vw - 20px));
  height: auto;
}

.table-settings-dialog {
  width: min(560px, calc(100vw - 20px));
  height: min(760px, calc(100vh - 20px));
}

.numbering-dialog,
.general-dialog {
  width: min(640px, calc(100vw - 20px));
  height: auto;
}

.price-dialog {
  width: min(1280px, calc(100vw - 20px));
  height: min(860px, calc(100vh - 20px));
}

.expenses-dialog {
  width: min(1480px, calc(100vw - 20px));
}

.contractors-browser-dialog {
  width: min(1280px, calc(100vw - 20px));
  height: min(860px, calc(100vh - 20px));
}

.payment-form {
  min-height: auto;
  padding-bottom: 22px;
}

.contractor-form {
  min-height: auto;
  padding-bottom: 22px;
}

.table-settings-form {
  min-height: 100%;
  padding-bottom: 22px;
}

.numbering-form,
.general-form {
  min-height: auto;
}

.price-form {
  min-height: 100%;
  padding-bottom: 22px;
}

.contractors-browser-shell {
  min-height: 100%;
  padding-bottom: 22px;
}

.template-editor-view {
  display: flex;
  flex-direction: column;
  height: calc(100vh);
  overflow: hidden;
  background: #f7f8fa;
}

.template-editor-view[hidden] {
  display: none;
}

.template-form {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.template-editor-header {
  flex-shrink: 0;
  padding: 16px 24px 12px;
  border-bottom: 1px solid var(--line);
  background: #fff;
}

.template-editor-header h1 {
  margin: 0;
  font-size: 22px;
  font-weight: 700;
  color: var(--ink);
}

.template-editor-settings {
  flex-shrink: 0;
  padding: 10px 24px !important;
  border-bottom: 1px solid var(--line) !important;
  background: #fff !important;
  gap: 20px !important;
}

.template-form .format-toolbar {
  flex-shrink: 0;
  border: none;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  background: #fff;
}

.template-form .format-toolbar .toolbar-row {
  padding: 5px 24px;
}

#variablePopupAnchor {
  flex-shrink: 0;
  padding: 6px 24px;
  border-bottom: 1px solid var(--line);
  background: #fff;
}

.template-form .variable-popup {
  margin: 0 24px;
}

.template-form .document-editor {
  flex: 1;
  min-height: 0;
  border: none;
  border-radius: 0;
  overflow: hidden;
}

.template-form .editor-page-wrap {
  border: none;
  border-radius: 0;
  height: 100%;
  padding: 24px;
  overflow-y: auto;
  background: #e2e5e9;
}

.template-form .editor-page {
  box-shadow: 0 2px 16px rgba(0,0,0,.13);
}

.template-form .editor-preview-wrap {
  display: flex;
  flex-direction: column;
  border: none;
  border-left: 1px solid var(--line);
  border-radius: 0;
  height: 100%;
}

.template-form .editor-preview-wrap[hidden] {
  display: none;
}

.template-editor-footer {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 24px;
  border-top: 1px solid var(--line);
  background: #fff;
}

.dialog-header,
.section-title,
.dialog-actions,
.form-total {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.dialog-header {
  position: sticky;
  z-index: 3;
  top: 0;
  margin: 0 -24px;
  padding: 12px 24px 8px;
  border-bottom: 1px solid var(--line);
  background: #f7f8fa;
}

.dialog-header h2,
.section-title h3 {
  margin-bottom: 0;
}

.dialog-header h2 {
  font-size: 30px;
  font-weight: 500;
}

.icon-button {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--ink);
  background: #ffffff;
  cursor: pointer;
  font-size: 24px;
  line-height: 1;
}

.gear-button {
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--muted);
  background: #ffffff;
  cursor: pointer;
}

.compact-title {
  justify-content: flex-start;
}

.short-field {
  max-width: 320px;
}

.form-grid {
  display: grid;
  gap: 14px;
}

.form-grid .wide-field {
  grid-column: 1 / -1;
}

.two-columns {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  column-gap: 42px;
}

.form-section {
  display: grid;
  gap: 10px;
}

.form-section h3 {
  margin: 0;
  color: #2f78e5;
  font-size: 16px;
  text-transform: uppercase;
}

.stacked-fields {
  display: grid;
  gap: 10px;
  align-content: start;
}

.field-with-action {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 40px;
}

.field-with-action input {
  border-radius: 6px 0 0 6px;
}

.field-with-action button {
  min-height: 42px;
  border: 1px solid #4e8df7;
  border-left: 0;
  border-radius: 0 6px 6px 0;
  color: #1d5ec9;
  background: #ffffff;
  cursor: pointer;
  font-size: 20px;
}

.client-lookup-section {
  position: relative;
}

.client-lookup-dropdown {
  position: absolute;
  z-index: 12;
  top: calc(100% + 4px);
  right: 0;
  left: 0;
  max-height: 300px;
  overflow-y: auto;
  border: 1px solid #2f78e5;
  border-radius: 6px;
  background: #ffffff;
  box-shadow: 0 18px 40px rgba(31, 38, 35, 0.18);
}

.client-lookup-dropdown[hidden] {
  display: none !important;
}

.client-lookup-title {
  position: sticky;
  z-index: 1;
  top: 0;
  padding: 10px 14px 6px;
  color: var(--ink);
  background: #ffffff;
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
}

.client-lookup-dropdown button {
  display: grid;
  width: 100%;
  grid-template-columns: minmax(140px, 0.7fr) minmax(160px, 1fr) auto;
  align-items: center;
  gap: 12px;
  border: 0;
  border-top: 1px solid #edf1f5;
  padding: 8px 14px;
  color: var(--ink);
  background: #ffffff;
  cursor: pointer;
  text-align: left;
}

.client-lookup-dropdown button:hover,
.client-lookup-dropdown button.active {
  background: #dfeaff;
}

.client-lookup-name {
  font-weight: 700;
}

.client-lookup-phone {
  color: #39465a;
  white-space: nowrap;
}

.client-lookup-dropdown small {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.client-lookup-dropdown mark {
  border-radius: 3px;
  padding: 0 2px;
  color: #5b3f00;
  background: #ffe28c;
}

label b {
  color: var(--red);
}

.tag-input {
  display: grid;
  grid-template-columns: auto minmax(120px, 1fr);
  min-height: 42px;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 5px 7px;
  background: #ffffff;
}

.tag-list {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.tag-chip {
  display: inline-flex;
  min-height: 28px;
  align-items: center;
  border: 1px solid #9fc3ff;
  border-radius: 4px;
  padding: 0 6px;
  color: #233247;
  background: #eef5ff;
  cursor: pointer;
  font-weight: 500;
}

.tag-input input[type="text"] {
  min-width: 120px;
  min-height: 30px;
  border: 0;
  padding: 0 4px;
  outline: 0;
}

.small-button {
  min-height: 36px;
  padding: 0 12px;
}

.work-editor {
  display: grid;
  gap: 10px;
}

.work-editor-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 140px 150px 42px;
  gap: 10px;
}

.remove-work-button {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--red);
  background: #ffffff;
  cursor: pointer;
  font-size: 22px;
}

.form-total {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-strong);
}

.form-total strong {
  font-size: 24px;
}

.payment-grid {
  display: grid;
  grid-template-columns: 170px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
}

.payment-grid > span {
  color: var(--muted);
  text-align: right;
}

.payment-grid strong {
  font-size: 16px;
}

.payment-methods {
  display: grid;
  gap: 6px;
}

.payment-method {
  min-height: 58px;
  border: 0;
  border-radius: 6px;
  color: var(--ink);
  background: #f0f1f2;
  cursor: pointer;
  font-weight: 800;
}

.payment-method.active {
  color: #ffffff;
  background: var(--green);
}

.payment-method.muted {
  color: var(--muted);
}

.table-settings-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.table-settings-top span {
  font-size: 22px;
  font-weight: 700;
}

.column-settings-list {
  display: grid;
  gap: 6px;
}

.column-setting-row {
  display: flex;
  min-height: 42px;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid var(--line);
  color: var(--ink);
  font-size: 16px;
  font-weight: 500;
}

.column-setting-row input {
  width: 18px;
  min-height: 18px;
}

.numbering-preview-card {
  display: grid;
  gap: 6px;
  border: 1px solid #b9dec8;
  border-radius: 14px;
  padding: 18px;
  color: #123528;
  background:
    radial-gradient(circle at top right, rgba(140, 224, 186, 0.38), transparent 36%),
    #eef8f1;
}

.numbering-preview-card span {
  color: var(--green);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.numbering-preview-card strong {
  font-size: 34px;
  line-height: 1;
}

.numbering-preview-card small {
  color: var(--muted);
}

.general-preview-card {
  border-color: #cbd9ec;
  color: #17233a;
  background:
    radial-gradient(circle at top right, rgba(47, 120, 229, 0.16), transparent 36%),
    #f1f6ff;
}

.general-preview-card span {
  color: #2f78e5;
}

.general-preview-head {
  display: flex;
  align-items: center;
  gap: 14px;
}

.general-logo-preview {
  width: 64px;
  height: 64px;
  flex-basis: 64px;
  border: 1px solid rgba(47, 120, 229, 0.18);
  color: #ffffff;
  background: #1179bf;
}

.settings-hint {
  border: 1px dashed #9fc3ff;
  border-radius: 6px;
  padding: 12px;
  color: var(--muted);
  background: #eef5ff;
  line-height: 1.5;
}

.price-toolbar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.price-filters {
  display: grid;
  grid-template-columns: minmax(220px, 1.5fr) repeat(4, minmax(140px, 1fr));
  gap: 10px;
}

.price-counter {
  color: var(--muted);
  font-weight: 700;
}

.price-table {
  font-size: 13px;
}

.price-table thead th {
  position: sticky;
  z-index: 2;
  top: 0;
}

.file-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.import-hint {
  border: 1px dashed #9fc3ff;
  border-radius: 6px;
  padding: 10px 12px;
  color: var(--muted);
  background: #eef5ff;
}

/* Строка заказа с номером (order.id), который исторически дублируется у нескольких разных
   заказов (см. R1142/R1143) — важно визуально отличать, что "один и тот же номер" здесь на
   самом деле несколько разных записей (открываются раздельно по orderUid). */
tr.duplicate-order-number td:first-child {
  position: relative;
  padding-left: 22px;
}
tr.duplicate-order-number td:first-child::before {
  content: "⧉";
  position: absolute;
  left: 4px;
  color: var(--warning, #b8860b);
  font-weight: 700;
}

.legacy-contractor-link-panel {
  display: grid;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
  margin: 6px 0 14px;
  background: var(--surface);
}

.legacy-contractor-search-results {
  display: grid;
  gap: 6px;
  max-height: 220px;
  overflow-y: auto;
}

.legacy-contractor-result {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 2px 10px;
  text-align: left;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 6px 10px;
  background: var(--surface-strong);
  cursor: pointer;
}
.legacy-contractor-result:hover { border-color: var(--green); }
.legacy-contractor-result small { grid-column: 1 / -1; color: var(--muted); }

.legacy-contractor-confirm-card {
  border: 1px solid var(--green);
  border-radius: 6px;
  padding: 10px 12px;
  background: color-mix(in srgb, var(--green) 8%, var(--surface));
}
.legacy-contractor-confirm-actions { display: flex; gap: 10px; margin-top: 8px; }

.legacy-contractor-panel-actions { display: flex; gap: 10px; justify-content: flex-end; }

.legacy-contractors-list { display: grid; gap: 10px; padding: 4px 2px; }
.legacy-contractor-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
  background: var(--surface);
}
.legacy-contractor-card-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.table-pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 4px 2px;
  color: var(--muted);
  font-size: 13px;
  flex-wrap: wrap;
}
.table-pagination-controls { display: flex; gap: 8px; }
.table-pagination-controls button:disabled { opacity: 0.5; cursor: not-allowed; }

.needs-company-badge {
  display: inline-block;
  margin-top: 3px;
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  color: #8a5a00;
  background: #fff3cd;
}

.contractor-link-badge {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border: 1px solid var(--green);
  border-radius: 6px;
  padding: 8px 12px;
  margin: -8px 0 14px;
  background: color-mix(in srgb, var(--green) 10%, var(--surface));
  font-size: 13px;
}

.import-hint.hint-danger {
  border: 1px solid var(--red);
  color: var(--red);
  background: color-mix(in srgb, var(--red) 12%, var(--surface));
  font-weight: 700;
}

.value-negative {
  color: var(--red) !important;
}

.import-result {
  border: 1px solid #b9dec8;
  border-radius: 6px;
  padding: 10px 12px;
  color: #0f6448;
  background: #eef8f1;
}

.import-result[hidden] {
  display: none;
}

.price-table input {
  min-width: 96px;
  min-height: 36px;
}

.price-table input[name="title"] {
  min-width: 260px;
}

.expenses-table input,
.expenses-table select,
.workers-table input,
.workers-table select {
  min-width: 150px;
  min-height: 36px;
}

.expenses-table input[name="description"] {
  min-width: 260px;
}

.workers-table input[name="workerNote"] {
  min-width: 220px;
}

.workers-table input[name="workerIncome"],
.workers-table input[name="workerPaid"] {
  min-width: 120px;
}

.worker-balance-due {
  color: var(--green);
}

.price-table input[name="category"],
.price-table input[name="deviceCategory"],
.price-table input[name="brand"],
.price-table input[name="model"],
.price-table input[name="pcType"],
.price-table input[name="service"] {
  min-width: 140px;
}

.price-table input[name="detailType"] {
  min-width: 110px;
}

.price-table .remove-price-row,
.price-table .remove-expense-row,
.price-table .remove-worker-row {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--red);
  background: #ffffff;
  cursor: pointer;
}

.dialog-actions {
  position: sticky;
  z-index: 3;
  bottom: 0;
  margin: 0 -24px -84px;
  padding: 16px 24px;
  border-top: 1px solid var(--line);
  justify-content: flex-end;
  background: #f7f8fa;
  box-shadow: 0 -8px 18px rgba(31, 38, 35, 0.06);
}

.dialog-actions .primary-button,
.dialog-actions .ghost-button {
  min-width: 92px;
}

.footer-spacer {
  flex: 1;
}

.dots-button {
  min-width: 44px;
  padding: 0;
  font-size: 22px;
}

.print-menu {
  position: relative;
}

.print-panel {
  position: absolute;
  right: 0;
  bottom: 54px;
  display: grid;
  width: 280px;
  gap: 12px;
  border: 1px solid #2f78e5;
  border-radius: 6px;
  padding: 16px;
  background: #ffffff;
  box-shadow: 0 18px 40px rgba(31, 38, 35, 0.16);
}

.print-panel[hidden] {
  display: none !important;
}

.print-panel label {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  font-weight: 500;
}

.print-panel input {
  width: 18px;
  min-height: 18px;
}

.print-panel p {
  margin: 0;
  color: var(--muted);
  font-style: italic;
}

.template-hint {
  border: 1px dashed #9fc3ff;
  border-radius: 6px;
  padding: 12px;
  color: var(--muted);
  background: #eef5ff;
  line-height: 1.45;
}

.editor-toolbar {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) 150px 170px 120px;
  gap: 12px;
}

.format-toolbar {
  display: flex;
  flex-direction: column;
  gap: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #ffffff;
  overflow: hidden;
}

.toolbar-row {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
  padding: 6px 8px;
}

.toolbar-row + .toolbar-row {
  border-top: 1px solid var(--line);
  background: #fafbfc;
}

.format-toolbar button,
.format-toolbar select,
.color-picker {
  min-height: 32px;
  border: 1px solid #d5dbe2;
  border-radius: 4px;
  color: var(--ink);
  background: #f9fafb;
}

.format-toolbar button {
  min-width: 32px;
  padding: 0 8px;
  cursor: pointer;
  font-size: 13px;
  white-space: nowrap;
}

.format-toolbar button:hover,
.format-toolbar select:hover {
  border-color: #2f78e5;
  background: #eef5ff;
}

.format-toolbar select {
  width: auto;
  padding: 0 24px 0 7px;
  font-size: 13px;
}

.toolbar-separator {
  width: 1px;
  height: 24px;
  margin: 0 3px;
  background: var(--line);
  flex-shrink: 0;
}

.toolbar-spacer {
  flex: 1;
}

.toolbar-var-btn {
  padding: 0 10px !important;
  background: #eef5ff !important;
  border-color: #b8d0f8 !important;
  color: #1d5ec9 !important;
  font-weight: 600 !important;
}

.toolbar-var-btn:hover {
  background: #dceafd !important;
}

.toolbar-preview-btn {
  padding: 0 12px !important;
  background: #f0faf5 !important;
  border-color: #a8d8bc !important;
  color: #166b44 !important;
  font-weight: 600 !important;
}

.toolbar-preview-btn.active,
.toolbar-preview-btn:hover {
  background: #d4f0e2 !important;
}

.color-picker {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 0 6px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
}

.color-picker input {
  width: 20px;
  min-height: 20px;
  border: 1px solid #ccc;
  border-radius: 3px;
  padding: 1px;
  background: transparent;
  cursor: pointer;
}

.variable-popup {
  position: relative;
  z-index: 100;
}

.variable-popup > div {
  position: absolute;
  top: 0;
  left: 0;
  display: flex;
  gap: 0;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 6px 24px rgba(0,0,0,.14);
  overflow: hidden;
}

.variable-popup-group {
  display: flex;
  flex-direction: column;
  min-width: 160px;
}

.variable-popup-group + .variable-popup-group {
  border-left: 1px solid var(--line);
}

.variable-popup-title {
  padding: 8px 14px 6px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  color: #2f78e5;
  background: #f5f8ff;
  letter-spacing: .04em;
}

.variable-popup-group button {
  padding: 7px 14px;
  border: none;
  border-radius: 0;
  background: none;
  color: var(--ink);
  font-size: 13px;
  text-align: left;
  cursor: pointer;
  border-top: 1px solid var(--line);
  white-space: nowrap;
}

.variable-popup-group button:hover {
  background: #eef5ff;
  color: #1d5ec9;
}

.document-editor {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 0;
  min-height: 480px;
}

.document-editor.with-preview {
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.editor-preview-wrap {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line);
  border-radius: 6px;
  overflow: hidden;
  background: #dfe4e8;
}

.editor-preview-wrap[hidden] {
  display: none;
}

.preview-bar {
  padding: 8px 14px;
  background: #fff;
  border-bottom: 1px solid var(--line);
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .04em;
}

.editor-preview-wrap iframe {
  flex: 1;
  border: none;
  width: 100%;
}

.editor-jodit-wrap {
  min-height: 0;
  overflow: hidden;
}

.editor-jodit-wrap .jodit-container {
  border-radius: 4px;
  border-color: var(--line);
}

.img-resize-popup {
  position: absolute;
  display: flex;
  align-items: center;
  gap: 5px;
  background: #fff;
  border: 1px solid #ccc;
  border-radius: 6px;
  padding: 5px 8px;
  box-shadow: 0 2px 8px rgba(0,0,0,.18);
  font-size: 12px;
  z-index: 9999;
  pointer-events: all;
}
.img-resize-popup[hidden] { display: none; }
.img-resize-popup input { padding: 2px 4px; border: 1px solid #ccc; border-radius: 4px; }
.img-resize-popup button { padding: 2px 7px; border: 1px solid #ccc; border-radius: 4px; cursor: pointer; background: #f5f5f5; }
.editor-page img.img-selected { outline: 2px solid #1179bf; }

.editor-page-wrap {
  position: relative;
  min-width: 0;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 24px;
  background: #dfe4e8;
}

.editor-page {
  width: 210mm;
  min-height: 297mm;
  margin: 0 auto;
  padding: 12mm;
  outline: 0;
  background: #ffffff;
  box-shadow: 0 12px 36px rgba(31, 38, 35, 0.18);
  line-height: 1.45;
}

.editor-page[data-size="A5"] {
  width: 148mm;
  min-height: 210mm;
}

.editor-page[data-size="receipt"] {
  width: 80mm;
  min-height: 180mm;
}

.editor-page[data-orientation="landscape"][data-size="A4"] {
  width: 297mm;
  min-height: 210mm;
}

.editor-page[data-orientation="landscape"][data-size="A5"] {
  width: 210mm;
  min-height: 148mm;
}

.editor-page table {
  width: 100%;
  border-collapse: collapse;
}

.editor-page th,
.editor-page td {
  border: 1px solid #9aa3a0;
  padding: 6px 8px;
}

.editor-page .template-token {
  display: inline-block;
  border-radius: 4px;
  padding: 1px 5px;
  color: #1d5ec9;
  background: #eef5ff;
  font-weight: 700;
}

.inline-actions {
  position: static;
  margin: 0;
  padding: 0;
  border-top: 0;
  box-shadow: none;
}

.print-preview-dialog {
  width: min(1100px, calc(100vw - 20px));
  height: min(920px, calc(100vh - 20px));
  padding: 0;
  background: #eef1f3;
}

.print-preview-shell {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  height: 100%;
}

.print-preview-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--line);
  padding: 12px 16px;
  background: #ffffff;
}

.print-preview-header h2 {
  margin: 0;
}

.print-preview-header div {
  display: flex;
  gap: 10px;
}

#printPreviewFrame {
  width: 100%;
  height: 100%;
  border: 0;
  background: #eef1f3;
}

.detail-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin: 16px 0 18px;
}

.detail-print-menu {
  position: relative;
}

.detail-print-menu .print-panel {
  left: 0;
  right: auto;
  bottom: auto;
  top: 48px;
  z-index: 5;
}

.order-action-bar {
  position: sticky;
  z-index: 4;
  right: 0;
  bottom: -20px;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin: 22px -20px -20px;
  border-top: 1px solid var(--line);
  padding: 12px 20px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.94), #ffffff);
}

.order-action-bar .detail-print-menu,
.order-settings-menu {
  position: relative;
}

.order-action-bar .detail-print-menu .print-panel {
  right: 0;
  left: auto;
  top: auto;
  bottom: 48px;
}

.order-settings-panel {
  position: absolute;
  right: 0;
  bottom: 48px;
  display: grid;
  width: 250px;
  border: 1px solid #2f78e5;
  border-radius: 4px;
  padding: 10px 0;
  background: #ffffff;
  box-shadow: 0 18px 40px rgba(31, 38, 35, 0.16);
}

.order-settings-panel[hidden] {
  display: none !important;
}

.order-settings-panel button {
  min-height: 36px;
  border: 0;
  padding: 0 16px;
  color: var(--ink);
  background: transparent;
  cursor: pointer;
  text-align: left;
}

.order-settings-panel button:hover {
  background: #dfeaff;
}

.toggle-row {
  display: grid;
  grid-template-columns: auto 46px auto;
  align-items: center;
  justify-content: start;
  column-gap: 8px;
  min-height: 42px;
}

.toggle-row input {
  position: relative;
  width: 46px;
  min-height: 24px;
  appearance: none;
  border: 0;
  border-radius: 999px;
  background: #dde1e7;
  cursor: pointer;
}

.toggle-row input::before {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #ffffff;
  content: "";
  transition: transform 0.16s ease;
}

.toggle-row input:checked {
  background: #2f78e5;
}

.toggle-row input:checked::before {
  transform: translateX(22px);
}

.toggle-row em {
  min-width: 26px;
  color: var(--ink);
  font-style: normal;
  font-weight: 700;
}

@media (max-width: 1120px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    display: grid;
    grid-template-columns: 1fr;
  }

  .main-nav {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .orders-layout {
    grid-template-columns: 1fr;
  }

  .dashboard-grid,
  .dashboard-insights {
    grid-template-columns: 1fr;
  }

  .dashboard-chart-toolbar,
  .dashboard-chart-metrics {
    grid-template-columns: 1fr;
  }

  .report-filter-grid,
  .report-summary,
  .expense-from-cash-form,
  .owner-withdrawal-form,
  .order-settlement-form,
  .order-settlement-summary,
  .shift-settlement-form,
  .shift-settlement-summary {
    grid-template-columns: 1fr;
  }

  .date-range-fields {
    grid-template-columns: 1fr;
  }

  .details-panel {
    position: static;
  }
}

@media (max-width: 720px) {
  .workspace,
  .sidebar {
    padding: 18px;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .topbar-left {
    width: 100%;
    align-items: flex-start;
    flex-direction: column;
  }

  .topbar-brand {
    width: 100%;
    min-width: 0;
  }

  .stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .dashboard-hero-copy h2 {
    font-size: 28px;
  }

  .main-nav {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  h1 {
    font-size: 28px;
  }

  .form-grid,
  .two-columns,
  .work-editor-row {
    grid-template-columns: 1fr;
  }

  .dialog-actions {
    align-items: stretch;
    flex-wrap: wrap;
  }

  .editor-toolbar,
  .document-editor {
    grid-template-columns: 1fr;
  }

  .dashboard-hero-actions,
  .dashboard-module-strip {
    flex-direction: column;
  }

  .dashboard-hero-actions .primary-button,
  .dashboard-hero-actions .ghost-button {
    width: 100%;
  }

  .client-lookup-dropdown button {
    grid-template-columns: 1fr;
    gap: 4px;
  }

  .format-toolbar select {
    flex: 1 1 120px;
  }

  .footer-spacer {
    display: none;
  }
}

@media (max-width: 460px) {
  .stats-grid,
  .main-nav {
    grid-template-columns: 1fr;
  }

  .topbar-actions,
  .primary-button,
  .ghost-button {
    width: 100%;
  }
}

.status-multi-wrap {
  position: relative;
}

.status-multi-btn {
  width: 100%;
  min-height: 42px;
  padding: 0 32px 0 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #ffffff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23888' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E") no-repeat right 10px center;
  color: var(--ink);
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
  font-size: 14px;
}

.status-multi-btn:hover {
  border-color: #aaa;
}

.status-multi-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  min-width: max(100%, 220px);
  max-height: 320px;
  overflow-y: auto;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 4px 16px rgba(0,0,0,.12);
  z-index: 200;
  padding: 6px 0;
}

.status-multi-dropdown label {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 14px;
  cursor: pointer;
  color: var(--ink);
  font-size: 14px;
  font-weight: 400;
  white-space: nowrap;
}

.status-multi-dropdown label:hover {
  background: var(--hover, #f5f5f5);
}

.status-multi-dropdown input[type="checkbox"] {
  width: 15px;
  min-height: 15px;
  margin: 0;
  cursor: pointer;
  accent-color: var(--accent, #2563eb);
}

.status-multi-dropdown .multi-reset {
  display: block;
  padding: 7px 14px;
  background: none;
  border: none;
  color: var(--muted);
  font-size: 13px;
  text-align: left;
  cursor: pointer;
}

.status-multi-dropdown .multi-reset:hover {
  color: var(--ink);
}

/* Preset chips */
.status-presets-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px 10px 6px;
}

.preset-sep {
  margin: 0 10px 2px;
  border: none;
  border-top: 1px solid var(--line);
}

.status-preset-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 6px 3px 9px;
  background: var(--accent, #16855f);
  color: #fff;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  cursor: default;
  user-select: none;
}

.status-preset-chip > span:first-child {
  cursor: pointer;
}

.status-preset-chip > span:first-child:hover {
  text-decoration: underline;
}

.preset-chip-del {
  background: none;
  border: none;
  color: rgba(255,255,255,0.75);
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  padding: 0 2px;
  border-radius: 50%;
}

.preset-chip-del:hover {
  color: #fff;
  background: rgba(0,0,0,0.2);
}

/* Footer row */
.preset-footer {
  display: flex;
  align-items: center;
  border-top: 1px solid var(--line);
  margin-top: 4px;
}

.preset-save-btn {
  color: var(--green) !important;
  font-weight: 600 !important;
}


.preset-name-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px 12px 10px;
  width: 100%;
  box-sizing: border-box;
}

.preset-name-input {
  width: 100%;
  box-sizing: border-box;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 14px;
  color: var(--ink);
  background: #ffffff;
}

.preset-name-row .preset-name-btns {
  display: flex;
  gap: 6px;
}

/* ── Dark mode overrides ── */

/* Sidebar */
[data-theme="dark"] .sidebar { background: #1a2420; }
[data-theme="dark"] .main-nav a { color: #c8d8cc; }
[data-theme="dark"] .main-nav a.active,
[data-theme="dark"] .main-nav a:hover { color: #fff; background: rgba(255,255,255,.08); }
[data-theme="dark"] .sub-nav a { color: #8fa393; }
[data-theme="dark"] .support-box { background: rgba(255,255,255,.05); border-color: rgba(255,255,255,.1); }
[data-theme="dark"] .support-box p,
[data-theme="dark"] .support-box strong { color: #c8d8cc; }

/* Topbar */
[data-theme="dark"] .topbar-brand { background: linear-gradient(135deg, #2c3530 0%, #242f2a 100%); }

/* Global: inputs, selects, textareas */
[data-theme="dark"] input,
[data-theme="dark"] select,
[data-theme="dark"] textarea { color: var(--ink); background: #2a2e2c; border-color: var(--line); }
[data-theme="dark"] input::placeholder,
[data-theme="dark"] textarea::placeholder { color: var(--muted); }
[data-theme="dark"] input[type="date"]::-webkit-calendar-picker-indicator { filter: invert(1) opacity(.5); }

/* Dialogs */
[data-theme="dark"] dialog { background: var(--surface); color: var(--ink); }
[data-theme="dark"] dialog::backdrop { background: rgba(0,0,0,.7); }
[data-theme="dark"] .dialog-header { border-color: var(--line); }
[data-theme="dark"] .dialog-actions { border-color: var(--line); background: var(--surface); }

/* Buttons */
[data-theme="dark"] .ghost-button { color: var(--ink); background: #2a2e2c; border-color: var(--line); }
[data-theme="dark"] .ghost-button:hover { background: var(--line); }
[data-theme="dark"] .icon-button { color: var(--muted); }
[data-theme="dark"] .icon-button:hover { color: var(--ink); background: var(--surface-strong); }

/* Tables */
[data-theme="dark"] th { background: #2a2e2c; color: var(--muted); border-color: var(--line); }
[data-theme="dark"] td { border-color: var(--line); }
[data-theme="dark"] .table-wrap { background: var(--surface); }
[data-theme="dark"] tr:hover td { background: rgba(255,255,255,.03); }
[data-theme="dark"] .order-row td { background: var(--surface); }
[data-theme="dark"] .order-row.selected td { background: #1e3a2e; }
[data-theme="dark"] .price-table td,
[data-theme="dark"] .price-table th,
[data-theme="dark"] .warehouse-table td,
[data-theme="dark"] .warehouse-table th { border-color: var(--line); }

/* Stats & summary cards */
[data-theme="dark"] .stats-grid article,
[data-theme="dark"] .finance-summary article,
[data-theme="dark"] .warehouse-summary article,
[data-theme="dark"] .report-summary article,
[data-theme="dark"] .salary-summary article,
[data-theme="dark"] .workers-summary article,
[data-theme="dark"] .order-settlement-summary article,
[data-theme="dark"] .shift-settlement-summary article,
[data-theme="dark"] .expense-summary article { background: var(--surface); border-color: var(--line); }

/* Dashboard */
[data-theme="dark"] .dashboard-panel,
[data-theme="dark"] .dashboard-day-card { background: var(--surface); border-color: var(--line); }
[data-theme="dark"] .dashboard-hero-card { background: linear-gradient(135deg, #1a3028 0%, #162620 100%); border-color: var(--line); }
[data-theme="dark"] .dashboard-hero-copy h2,
[data-theme="dark"] .dashboard-hero-copy p { color: #d4e8dc; }
[data-theme="dark"] .dashboard-module-strip span { background: rgba(255,255,255,.08); color: #9ab5a3; }
[data-theme="dark"] .dashboard-badge { background: rgba(52,201,138,.15); color: #34c98a; }
[data-theme="dark"] .dashboard-status-row,
[data-theme="dark"] .dashboard-master-row,
[data-theme="dark"] .dashboard-activity-row { border-color: var(--line); }
[data-theme="dark"] .dashboard-attention-card { background: #2c2820; border-color: var(--line); }
[data-theme="dark"] .dashboard-panel-label { color: var(--muted); }
[data-theme="dark"] .dashboard-empty { color: var(--muted); }

/* Order details panel */
[data-theme="dark"] .details-panel,
[data-theme="dark"] #orderDetails { background: var(--surface); border-color: var(--line); }
[data-theme="dark"] .detail-header { background: var(--surface); border-color: var(--line); }
[data-theme="dark"] .detail-tabs button { background: transparent; color: var(--muted); border-color: var(--line); }
[data-theme="dark"] .detail-tabs button.active { background: var(--accent); color: #fff; border-color: var(--accent); }
[data-theme="dark"] .detail-row { background: var(--surface); border-color: var(--line); }
[data-theme="dark"] .detail-row:hover { background: var(--surface-strong); }
[data-theme="dark"] .work-row,
[data-theme="dark"] .work-editor-row { background: var(--surface); border-color: var(--line); }
[data-theme="dark"] .timeline-item::before { background: var(--line); }
[data-theme="dark"] .timeline-dot { border-color: var(--surface); }
[data-theme="dark"] .order-payment-row { background: var(--surface); border-color: var(--line); }
[data-theme="dark"] .order-payment-row.order-payment-compensating { background: var(--surface-strong); }
[data-theme="dark"] .order-payment-preview { background: var(--surface-strong); }
[data-theme="dark"] .money-grid div { background: var(--surface-strong); border-color: var(--line); }
[data-theme="dark"] .terms { background: var(--surface-strong); border-color: var(--line); }

/* Filters */
[data-theme="dark"] .filters,
[data-theme="dark"] .warehouse-toolbar,
[data-theme="dark"] .reports-tabs { background: var(--surface); border-color: var(--line); }
[data-theme="dark"] .reports-tabs button { color: var(--muted); }
[data-theme="dark"] .reports-tabs button.active { color: var(--accent); border-color: var(--accent); }
[data-theme="dark"] .search-field { background: transparent; }

/* Dropdowns */
[data-theme="dark"] .status-multi-dropdown { background: var(--surface); border-color: var(--line); }
[data-theme="dark"] .status-multi-dropdown label:hover { background: var(--surface-strong); }
[data-theme="dark"] .client-lookup-dropdown { background: var(--surface); border-color: var(--line); box-shadow: 0 8px 24px rgba(0,0,0,.4); }
[data-theme="dark"] .client-lookup-dropdown button:hover { background: var(--surface-strong); }

/* Finance panels */
[data-theme="dark"] .finance-panel,
[data-theme="dark"] .salary-panel,
[data-theme="dark"] .warehouse-section-panel,
[data-theme="dark"] .settings-table-panel,
[data-theme="dark"] .account-editor-panel,
[data-theme="dark"] .transfer-panel { background: var(--surface); border-color: var(--line); }
[data-theme="dark"] .accounts-grid article { background: var(--surface-strong); border-color: var(--line); }
[data-theme="dark"] .salary-panel-head { border-color: var(--line); }
[data-theme="dark"] .settings-table-head { border-color: var(--line); }

/* Price & expenses editor */
[data-theme="dark"] .price-dialog,
[data-theme="dark"] .expenses-dialog { background: var(--surface); }
[data-theme="dark"] .import-hint { background: var(--surface-strong); border-color: var(--line); color: var(--muted); }
[data-theme="dark"] .contractor-link-badge { background: color-mix(in srgb, var(--green) 16%, var(--surface-strong)); }
[data-theme="dark"] .needs-company-badge { color: #ffcf66; background: color-mix(in srgb, #8a5a00 35%, var(--surface-strong)); }
[data-theme="dark"] .import-hint.hint-danger { background: color-mix(in srgb, var(--red) 20%, var(--surface)); border-color: var(--red); color: var(--red); }
[data-theme="dark"] .expense-summary { border-color: var(--line); }

/* Warehouse */
[data-theme="dark"] .warehouse-groups { background: var(--surface); border-color: var(--line); }
[data-theme="dark"] .stock-group-list button { color: var(--ink); }
[data-theme="dark"] .stock-group-list button:hover,
[data-theme="dark"] .stock-group-list button.active { background: var(--surface-strong); }

/* Reports */
[data-theme="dark"] .reports-header { background: transparent; }
[data-theme="dark"] .report-filter-grid { background: var(--surface); border-color: var(--line); }

/* Settings dialogs */
[data-theme="dark"] .general-preview-card,
[data-theme="dark"] .numbering-preview-card { background: var(--surface-strong); border-color: var(--line); }
[data-theme="dark"] .settings-hint { background: var(--surface-strong); border-color: var(--line); color: var(--muted); }

/* Template editor */
[data-theme="dark"] .template-editor-header,
[data-theme="dark"] .template-editor-settings,
[data-theme="dark"] #variablePopupAnchor,
[data-theme="dark"] .template-editor-footer { background: var(--surface); border-color: var(--line); }
[data-theme="dark"] .variable-popup { background: var(--surface); border-color: var(--line); box-shadow: 0 8px 24px rgba(0,0,0,.4); }
[data-theme="dark"] .variable-popup-title { background: var(--surface-strong); color: #6ab0ff; }
[data-theme="dark"] .variable-popup-group button { color: var(--ink); }
[data-theme="dark"] .variable-popup-group button:hover { background: var(--surface-strong); }

/* Print preview */
[data-theme="dark"] .print-preview-dialog { background: #141714; }
[data-theme="dark"] .print-preview-shell { background: #141714; }
[data-theme="dark"] .print-preview-header { background: var(--surface); border-color: var(--line); }

/* Badges & chips */
[data-theme="dark"] .status-badge { filter: brightness(.8) saturate(.85); }
[data-theme="dark"] .tag-chip { background: var(--surface-strong); border-color: var(--line); color: var(--ink); }
[data-theme="dark"] .eyebrow { color: var(--muted); }
[data-theme="dark"] .form-section { border-color: var(--line); }
[data-theme="dark"] .form-section h3 { color: var(--ink); }
[data-theme="dark"] .section-title { border-color: var(--line); }
[data-theme="dark"] .form-total { background: var(--surface-strong); border-color: var(--line); }

/* Empty state */
[data-theme="dark"] .empty-state { color: var(--muted); }
[data-theme="dark"] .empty-state h2 { color: var(--ink); }
/* ── Yellow theme overrides ── */
[data-theme="yellow"] .sidebar {
  background: #3d2e00;
  color: #fff8dc;
}
[data-theme="yellow"] .main-nav a {
  color: #ffe9a0;
}
[data-theme="yellow"] .main-nav a.active,
[data-theme="yellow"] .main-nav a:hover {
  color: #ffffff;
  background: rgba(255,220,80,.18);
}
[data-theme="yellow"] .sub-nav a {
  color: #f5d88a;
}
[data-theme="yellow"] .brand-mark {
  background: #f5c30a;
  color: #2c2510;
}
[data-theme="yellow"] .primary-button {
  background: #d4920a;
  border-color: #b87c00;
}
[data-theme="yellow"] .primary-button:hover {
  background: #b87c00;
}
[data-theme="yellow"] .topbar-brand {
  background: linear-gradient(135deg, #fffdf4 0%, #fef3c7 100%);
}
[data-theme="yellow"] .dashboard-hero-card {
  background: linear-gradient(135deg, #3d2e00 0%, #5a4500 100%);
  color: #fff8dc;
}
[data-theme="yellow"] .dashboard-hero-card h2,
[data-theme="yellow"] .dashboard-hero-card p {
  color: #fff8dc;
}
[data-theme="yellow"] th {
  background: #fef3c7;
}
[data-theme="yellow"] .variable-popup-title {
  background: #fef3c7;
  color: #7a4f00;
}

/* ── Theme palette picker ── */
.theme-picker-field {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.theme-palette-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.theme-swatch {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  padding: 6px 8px;
  border: 2px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  cursor: pointer;
  font-size: 11px;
  color: var(--ink);
  transition: border-color .15s, box-shadow .15s;
  min-width: 70px;
}

.theme-swatch span {
  display: block;
  width: 52px;
  height: 34px;
  border-radius: 6px;
  overflow: hidden;
  position: relative;
  border: 1px solid rgba(0,0,0,.08);
  background: var(--sw-bg);
}

.theme-swatch span::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 16px;
  background: var(--sw-sidebar);
}

.theme-swatch span::after {
  content: '';
  position: absolute;
  right: 6px; bottom: 6px;
  width: 22px; height: 8px;
  border-radius: 3px;
  background: var(--sw-accent);
}

.theme-swatch:hover {
  border-color: var(--accent);
}

.theme-swatch.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent);
}
