:root {
  --bg: #f7f4ec;
  --panel: #fffdf8;
  --panel-strong: #fff8ea;
  --text: #1f2937;
  --muted: #6b7280;
  --border: #e5dcc8;
  --accent: #0f766e;
  --accent-2: #c2410c;
  --shadow: 0 20px 45px rgba(62, 39, 17, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Segoe UI", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(194, 65, 12, 0.08), transparent 25%),
    radial-gradient(circle at top right, rgba(15, 118, 110, 0.1), transparent 30%),
    var(--bg);
}

.hidden {
  display: none !important;
}

.auth-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.auth-card {
  width: min(460px, 100%);
  padding: 28px;
  border-radius: 24px;
  background: var(--panel);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.auth-title {
  margin: 0 0 12px;
  font-size: clamp(28px, 4vw, 42px);
  line-height: 1.02;
}

.auth-form {
  display: grid;
  gap: 14px;
  margin-top: 24px;
}

.auth-form label {
  display: grid;
  gap: 8px;
}

.auth-form span {
  font-size: 14px;
  color: var(--muted);
}

.auth-form input,
.auth-form button {
  width: 100%;
  min-height: 46px;
  border-radius: 12px;
  border: 1px solid var(--border);
  padding: 0 14px;
  font: inherit;
}

.auth-form button {
  border: none;
  background: linear-gradient(135deg, var(--accent), #1d4ed8);
  color: white;
  font-weight: 700;
  cursor: pointer;
}

.auth-form button,
.controls button,
.panel-export-button,
.preset-button,
.sheet-tab,
.unit-scheme-action {
  position: relative;
  transition:
    transform 0.14s ease,
    box-shadow 0.18s ease,
    background-color 0.18s ease,
    background 0.18s ease,
    border-color 0.18s ease,
    color 0.18s ease,
    filter 0.18s ease;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.auth-form button:hover,
.controls button:hover {
  filter: brightness(1.04);
  box-shadow: 0 10px 24px rgba(29, 78, 216, 0.18);
}

.controls .ghost-button:hover,
.panel-export-button:hover,
.preset-button:hover,
.sheet-tab:hover,
.unit-scheme-action:hover {
  border-color: rgba(15, 118, 110, 0.28);
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 8px 20px rgba(62, 39, 17, 0.1);
}

.auth-form button:active,
.controls button:active,
.panel-export-button:active,
.preset-button:active,
.sheet-tab:active,
.unit-scheme-action:active {
  transform: translateY(1px) scale(0.985);
  box-shadow: inset 0 2px 6px rgba(15, 23, 42, 0.12);
}

.auth-form button:focus-visible,
.controls button:focus-visible,
.panel-export-button:focus-visible,
.preset-button:focus-visible,
.sheet-tab:focus-visible,
.unit-scheme-action:focus-visible {
  outline: 3px solid rgba(29, 78, 216, 0.22);
  outline-offset: 2px;
}

.auth-form button:disabled,
.controls button:disabled,
.panel-export-button:disabled,
.preset-button:disabled,
.sheet-tab:disabled,
.unit-scheme-action:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  box-shadow: none;
  transform: none;
  filter: none;
}

.controls button[data-busy="true"] {
  opacity: 1;
  cursor: progress;
  position: relative;
  padding-left: 40px;
}

.controls button[data-busy="true"]::before {
  content: "";
  position: absolute;
  left: 14px;
  top: 50%;
  width: 14px;
  height: 14px;
  margin-top: -7px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: rgba(255, 255, 255, 1);
  animation: dashboard-spin 0.7s linear infinite;
}

.auth-status {
  margin: 0;
  min-height: 20px;
  color: var(--muted);
  font-size: 14px;
}

.auth-status[data-mode="error"] {
  color: #991b1b;
}

.page {
  width: min(1280px, calc(100% - 32px));
  margin: 0 auto;
  padding: 32px 0 56px;
}

.hero {
  display: grid;
  gap: 20px;
  grid-template-columns: 1.6fr 1fr;
  align-items: end;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: 12px;
}

h1 {
  margin: 0 0 12px;
  font-size: clamp(32px, 5vw, 56px);
  line-height: 0.98;
}

.subtitle {
  margin: 0;
  max-width: 820px;
  color: var(--muted);
  line-height: 1.55;
}

.controls,
.panel,
.card,
.status,
.insight {
  background: var(--panel);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.controls {
  display: grid;
  gap: 14px;
  padding: 18px;
  border-radius: 20px;
}

.session-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.session-user {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 0 12px;
  border-radius: 999px;
  background: rgba(15, 118, 110, 0.08);
  color: var(--accent);
  font-size: 14px;
  font-weight: 600;
}

.control-grid {
  display: grid;
  gap: 14px;
}

.controls label {
  display: grid;
  gap: 8px;
}

.controls span {
  font-size: 14px;
  color: var(--muted);
}

.controls select,
.controls input,
.controls button {
  width: 100%;
  min-height: 44px;
  border-radius: 12px;
  border: 1px solid var(--border);
  padding: 0 14px;
  font: inherit;
}

.control-actions {
  display: grid;
  gap: 10px;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
}

.controls button {
  border: none;
  background: linear-gradient(135deg, var(--accent), #1d4ed8);
  color: white;
  font-weight: 700;
  cursor: pointer;
}

.controls .ghost-button {
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.85);
  color: var(--text);
}

.panel-export-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.85);
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  margin-bottom: 12px;
}

.preset-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.preset-button {
  width: auto;
  min-height: 36px;
  padding: 0 12px;
  border: 1px solid var(--border) !important;
  background: rgba(255, 255, 255, 0.78) !important;
  color: var(--text) !important;
  font-size: 14px;
  font-weight: 600;
}

.status {
  margin: 22px 0;
  padding: 14px 18px;
  border-radius: 16px;
  position: relative;
  transition: border-color 0.2s ease, background 0.2s ease, box-shadow 0.2s ease, color 0.2s ease;
}

.status[data-loading="true"] {
  padding-left: 48px;
  border-color: rgba(29, 78, 216, 0.22);
  background: linear-gradient(135deg, rgba(219, 234, 254, 0.9), rgba(239, 246, 255, 0.96));
  box-shadow: 0 18px 36px rgba(29, 78, 216, 0.08);
}

.status[data-loading="true"]::before {
  content: "";
  position: absolute;
  left: 18px;
  top: 50%;
  width: 16px;
  height: 16px;
  margin-top: -8px;
  border-radius: 50%;
  border: 2px solid rgba(29, 78, 216, 0.22);
  border-top-color: rgba(29, 78, 216, 0.95);
  animation: dashboard-spin 0.7s linear infinite;
}

.status[data-mode="loading"] {
  color: #1d4ed8;
}

.status[data-mode="ok"] {
  border-color: rgba(15, 118, 110, 0.22);
  color: #0f766e;
  background: #f0fdfa;
}

.status[data-mode="error"] {
  border-color: rgba(185, 28, 28, 0.25);
  color: #991b1b;
  background: #fff1f1;
}

.page-refresh-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    linear-gradient(135deg, rgba(247, 244, 238, 0.96), rgba(255, 255, 255, 0.98)),
    rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(10px);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.22s ease, visibility 0.22s ease;
}

.page-refresh-overlay.is-visible,
.page-refresh-pending .page-refresh-overlay {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.page-refresh-card {
  width: min(460px, 100%);
  padding: 28px 26px;
  border-radius: 28px;
  border: 1px solid rgba(194, 168, 120, 0.24);
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 28px 70px rgba(34, 38, 58, 0.14);
  text-align: center;
}

.page-refresh-spinner {
  width: 44px;
  height: 44px;
  margin: 0 auto 16px;
  border-radius: 50%;
  border: 3px solid rgba(29, 78, 216, 0.16);
  border-top-color: rgba(29, 78, 216, 0.95);
  animation: dashboard-spin 0.7s linear infinite;
}

.page-refresh-title {
  margin: 0;
  color: var(--text);
  font-size: 22px;
  font-weight: 700;
}

.page-refresh-message {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.5;
}

.page.page-loading .controls {
  box-shadow: 0 22px 48px rgba(29, 78, 216, 0.12);
}

@keyframes dashboard-spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  margin-bottom: 22px;
}

.card {
  padding: 18px;
  border-radius: 18px;
  position: relative;
}

.card-label {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

.card-label-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  margin: 0 0 10px;
}

.card-help {
  position: relative;
  flex: 0 0 auto;
  z-index: 2;
}

.card-help summary {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.82);
  cursor: pointer;
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
  list-style: none;
  transition: transform 0.15s ease, border-color 0.15s ease, color 0.15s ease, background 0.15s ease;
}

.card-help summary::-webkit-details-marker {
  display: none;
}

.card-help[open] summary,
.card-help summary:hover,
.card-help summary:focus-visible {
  border-color: #0f766e;
  color: #0f766e;
  background: #ecfdf5;
  transform: translateY(-1px);
  outline: none;
}

.card-help-popover {
  position: absolute;
  top: 28px;
  right: 0;
  z-index: 20;
  width: min(300px, calc(100vw - 48px));
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: #fffdf8;
  box-shadow: 0 18px 42px rgba(17, 24, 39, 0.16);
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  line-height: 1.45;
}

.card-value {
  margin: 0 0 10px;
  font-size: 28px;
  font-weight: 700;
}

.card-meta {
  margin: 0;
  font-size: 13px;
  line-height: 1.35;
  color: var(--muted);
}

.card-meta-line {
  display: block;
}

.card-meta.up {
  color: #0f766e;
}

.card-meta.down {
  color: #b91c1c;
}

.card-meta.flat {
  color: var(--muted);
}

.insights-panel {
  margin-bottom: 16px;
}

.funnel-metrics-panel {
  margin-bottom: 16px;
}

.sales-day-summary-section {
  margin: 0 0 18px;
}

.sales-day-summary-head {
  margin: 0 0 12px;
  padding: 0 2px;
}

.sales-day-summary-cards {
  margin-bottom: 0;
}

.document-overall-section {
  margin-bottom: 18px;
}

.document-groups {
  display: grid;
  gap: 16px;
}

.document-month-panel {
  overflow: visible;
}

.document-month-cards {
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  margin: 14px 0;
}

.document-service-breakdown {
  margin: 14px 0 18px;
}

.document-service-cards {
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  margin: 10px 0 0;
}

.document-service-card span {
  min-height: 42px;
}

.document-service-card small {
  display: block;
  line-height: 1.45;
}

.document-month-comparison-table {
  max-height: 460px;
  overflow: auto;
}

.document-month-comparison-table th {
  white-space: nowrap;
}

.document-month-comparison-table thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: rgba(255, 252, 245, 0.97);
}

.document-month-comparison-table th small {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  white-space: normal;
}

.document-month-comparison-table .document-act-detail-column {
  background: rgba(20, 115, 94, 0.09);
  min-width: 220px;
  white-space: normal;
}

.document-month-comparison-table tbody th {
  position: sticky;
  left: 0;
  z-index: 1;
  background: rgba(255, 252, 245, 0.97);
  text-align: left;
}

.document-month-comparison-table td {
  min-width: 150px;
  vertical-align: top;
}

.document-month-comparison-table .document-act-detail-cell {
  background: rgba(20, 115, 94, 0.045);
  min-width: 220px;
}

.document-month-comparison-table td strong,
.document-month-comparison-table td small {
  display: block;
}

.document-month-comparison-table td small {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.document-group-warnings {
  margin: 0 0 12px;
}

.document-month-table {
  max-height: 320px;
  overflow: auto;
}

.document-unit-table {
  max-height: 520px;
  overflow: auto;
}

.document-unit-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: rgba(255, 252, 245, 0.96);
}

.insight-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
}

.insight {
  border-radius: 18px;
  padding: 16px;
}

.insight-label {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 13px;
}

.insight-value {
  margin: 0 0 8px;
  font-size: 22px;
  font-weight: 700;
}

.insight-note {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 16px;
}

.panel {
  border-radius: 22px;
  padding: 18px;
  overflow: hidden;
}

.panel.wide {
  grid-column: 1 / -1;
}

.unit-panel {
  margin-bottom: 18px;
  overflow: visible;
}

.unit-toolbar {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

.unit-input-layout {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.unit-input-group {
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: rgba(255, 248, 234, 0.36);
}

.unit-input-group h3 {
  margin: 0 0 12px;
  font-size: 18px;
}

.unit-form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.unit-form-grid label {
  display: grid;
  gap: 8px;
}

.unit-form-grid span,
.unit-note,
.unit-inline-toggle small {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

.unit-form-grid input,
.unit-form-grid select {
  width: 100%;
  min-height: 42px;
  border-radius: 12px;
  border: 1px solid var(--border);
  padding: 0 12px;
  font: inherit;
  background: white;
}

.unit-form-grid input[readonly] {
  background: rgba(148, 163, 184, 0.08);
  color: var(--muted);
}

.unit-span-2 {
  grid-column: span 2;
}

.unit-inline-toggle small {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.unit-note {
  margin: 12px 0 0;
}

.unit-note[data-mode="error"] {
  color: #b91c1c;
}

.infographics-intro-panel {
  background:
    radial-gradient(circle at 12% 12%, rgba(15, 118, 110, 0.12), transparent 28%),
    radial-gradient(circle at 92% 0%, rgba(29, 78, 216, 0.12), transparent 32%),
    var(--panel);
}

.infographics-editor-panel {
  overflow: visible;
}

.infographics-form-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(180px, 1fr));
  gap: 14px;
}

.infographics-form-grid label {
  display: grid;
  gap: 8px;
}

.infographics-form-grid span {
  color: var(--muted);
  font-size: 13px;
}

.infographics-form-grid input,
.infographics-form-grid select,
.infographics-form-grid textarea {
  width: 100%;
  min-height: 42px;
  border-radius: 12px;
  border: 1px solid var(--border);
  padding: 0 12px;
  font: inherit;
  background: white;
}

.infographics-form-grid input[type="color"] {
  padding: 4px;
}

.infographics-form-grid textarea {
  min-height: 118px;
  padding: 12px;
  resize: vertical;
}

.infographics-product-label,
.infographics-wide {
  grid-column: span 3;
}

.infographics-preview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 18px;
}

.infographics-card {
  display: grid;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.72);
  box-shadow: 0 14px 30px rgba(62, 39, 17, 0.08);
}

.infographics-card img {
  width: 100%;
  aspect-ratio: 3 / 4;
  object-fit: cover;
  border-radius: 16px;
  background: #f8fafc;
}

.infographics-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.infographics-card-footer strong {
  font-size: 14px;
}

.unit-buyout-auto {
  display: grid;
  gap: 10px;
  padding: 14px 16px;
  border: 1px dashed rgba(15, 118, 110, 0.26);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.76);
}

.unit-buyout-auto-head {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
}

.unit-buyout-auto-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px 14px;
}

.unit-buyout-auto-item {
  display: grid;
  gap: 4px;
  padding: 10px 12px;
  border: 1px solid rgba(15, 118, 110, 0.14);
  border-radius: 12px;
  background: rgba(248, 250, 252, 0.82);
}

.unit-buyout-auto-item strong {
  font-size: 13px;
}

.unit-buyout-auto-item span {
  font-size: 16px;
  font-weight: 700;
  color: var(--accent);
}

.unit-buyout-auto-note {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.unit-catalog-controls {
  display: grid;
  grid-template-columns: minmax(220px, 360px) minmax(0, 1fr);
  gap: 16px;
  align-items: end;
  margin-bottom: 16px;
}

.unit-catalog-controls label {
  display: grid;
  gap: 8px;
}

.unit-catalog-controls select {
  width: 100%;
  min-height: 42px;
  border-radius: 12px;
  border: 1px solid var(--border);
  padding: 0 12px;
  font: inherit;
  background: white;
}

.unit-purchase-import-controls,
.unit-product-import-controls {
  display: grid;
  grid-template-columns: minmax(260px, 420px) minmax(0, 1fr);
  gap: 16px;
  align-items: end;
  margin-bottom: 16px;
}

.unit-purchase-import-controls label,
.unit-product-import-controls label {
  display: grid;
  gap: 8px;
}

.unit-purchase-import-controls input[type="file"],
.unit-product-import-controls input[type="file"] {
  width: 100%;
  min-height: 42px;
  border-radius: 12px;
  border: 1px solid var(--border);
  padding: 10px 12px;
  font: inherit;
  background: white;
}

.unit-purchase-import-controls .unit-note,
.unit-product-import-controls .unit-note {
  margin: 0;
}

.unit-batch-expense-controls {
  display: grid;
  grid-template-columns: repeat(4, minmax(200px, 1fr));
  gap: 16px;
  align-items: end;
  margin-bottom: 16px;
}

.unit-batch-expense-controls label {
  display: grid;
  gap: 8px;
}

.unit-batch-expense-controls input {
  width: 100%;
  min-height: 42px;
  border-radius: 12px;
  border: 1px solid var(--border);
  padding: 0 12px;
  font: inherit;
  background: white;
}

.unit-batch-expense-controls .unit-note {
  grid-column: 1 / -1;
  margin: 0;
}

.unit-batch-table th:nth-child(6),
.unit-batch-table th:nth-child(7),
.unit-batch-table th:nth-child(8),
.unit-batch-table th:nth-child(9),
.unit-batch-table th:nth-child(10),
.unit-batch-table th:nth-child(11),
.unit-batch-table th:nth-child(12),
.unit-batch-table td:nth-child(6),
.unit-batch-table td:nth-child(7),
.unit-batch-table td:nth-child(8),
.unit-batch-table td:nth-child(9),
.unit-batch-table td:nth-child(10),
.unit-batch-table td:nth-child(11),
.unit-batch-table td:nth-child(12) {
  text-align: right;
}

.unit-batch-table th.num,
.unit-batch-table td.num {
  text-align: right;
  white-space: nowrap;
}

.unit-batch-table thead th {
  position: sticky;
  top: 54px;
  z-index: 5;
  background: rgba(255, 253, 248, 0.98);
  box-shadow: inset 0 -1px 0 rgba(194, 168, 120, 0.24);
}

#unit-batch-wrap {
  scrollbar-width: thin;
  scrollbar-color: rgba(100, 116, 139, 0.55) rgba(226, 232, 240, 0.5);
}

#unit-batch-wrap::-webkit-scrollbar {
  height: 8px;
}

#unit-batch-wrap::-webkit-scrollbar-track {
  background: rgba(226, 232, 240, 0.48);
  border-radius: 999px;
}

#unit-batch-wrap::-webkit-scrollbar-thumb {
  background: rgba(100, 116, 139, 0.55);
  border-radius: 999px;
}

#unit-batch-wrap::-webkit-scrollbar-thumb:hover {
  background: rgba(71, 85, 105, 0.7);
}

.unit-batch-header-text {
  display: grid;
  gap: 4px;
  min-width: 140px;
}

.unit-batch-header-label {
  display: block;
  font-weight: 700;
}

.unit-batch-header-hint {
  display: block;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
  font-weight: 500;
  white-space: normal;
}

.unit-scheme-header {
  display: grid;
  gap: 8px;
  min-width: 180px;
}

.unit-scheme-header-controls {
  display: grid;
  gap: 8px;
}

.unit-scheme-header-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.unit-scheme-select {
  width: 100%;
  min-height: 36px;
  border-radius: 10px;
  border: 1px solid var(--border);
  padding: 0 10px;
  font: inherit;
  background: white;
}

.unit-override-input {
  text-align: right;
}

.unit-scheme-action {
  min-height: 32px;
  padding: 6px 10px;
}

.unit-breakdown-table th:nth-child(2),
.unit-breakdown-table td:nth-child(2) {
  text-align: right;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: baseline;
  margin-bottom: 16px;
}

.panel-head h2,
.panel-head p {
  margin: 0;
}

.panel-head p {
  color: var(--muted);
}

.chart-shell {
  position: relative;
  height: clamp(260px, 32vh, 360px);
}

.chart-shell-wide {
  height: clamp(280px, 36vh, 400px);
}

canvas {
  display: block;
  width: 100% !important;
  height: 100% !important;
  min-height: 0;
}

.table-wrap {
  overflow-x: auto;
}

.table-scroll-shell {
  position: relative;
}

.table-scrollbar-top {
  position: sticky;
  top: 8px;
  z-index: 6;
  overflow-x: auto;
  overflow-y: hidden;
  margin: 0 0 10px;
  padding: 0 0 4px;
  background: linear-gradient(180deg, rgba(255, 253, 248, 0.96), rgba(255, 253, 248, 0.88));
  border-radius: 10px;
}

.table-scrollbar-top.is-hidden {
  display: none;
}

.table-scrollbar-inner {
  height: 1px;
}

.funnel-table th:nth-child(2),
.funnel-table th:nth-child(3),
.funnel-table th:nth-child(4),
.funnel-table td:nth-child(2),
.funnel-table td:nth-child(3),
.funnel-table td:nth-child(4) {
  text-align: right;
}

.funnel-row-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.funnel-row-label.conversion {
  color: #374151;
}

.funnel-branch {
  color: #94a3b8;
  font-weight: 700;
}

.trend-chip {
  display: inline-block;
  min-width: 56px;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.12);
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  text-align: center;
}

.trend-chip.up {
  background: rgba(16, 185, 129, 0.12);
  color: #059669;
}

.trend-chip.down {
  background: rgba(239, 68, 68, 0.12);
  color: #dc2626;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 12px 10px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  white-space: nowrap;
}

thead th {
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

tbody tr:hover {
  background: var(--panel-strong);
}

.sales-day-table .sales-total-expense-header {
  background: rgba(15, 118, 110, 0.08);
  color: #0f766e;
}

.sales-day-table .sales-expense-group-header,
.sales-day-table .sales-expense-detail-group-header {
  text-align: center;
  background: rgba(15, 118, 110, 0.08);
  color: #0f766e;
}

.sales-day-table .sales-expense-detail-group-header {
  background: rgba(59, 130, 246, 0.08);
  color: #2563eb;
}

.sales-day-table .sales-expense-detail-header {
  min-width: 170px;
  max-width: 230px;
  white-space: normal;
  line-height: 1.25;
  vertical-align: bottom;
}

.sales-day-table .sales-expense-detail-value {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

code {
  background: rgba(15, 118, 110, 0.08);
  border-radius: 6px;
  padding: 2px 6px;
}

.sheet-tabs {
  display: inline-flex;
  gap: 8px;
  margin: 0 0 18px;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: rgba(255, 253, 248, 0.92);
  box-shadow: var(--shadow);
}

.sheet-tab {
  min-height: 42px;
  padding: 0 18px;
  border: 1px solid transparent;
  border-radius: 12px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.sheet-tab.active {
  border-color: rgba(15, 118, 110, 0.16);
  background: linear-gradient(135deg, rgba(15, 118, 110, 0.14), rgba(29, 78, 216, 0.08));
  color: var(--text);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.65), 0 8px 18px rgba(62, 39, 17, 0.1);
}

.sheet-view.hidden {
  display: none;
}

.scheme-status-panel {
  margin-bottom: 16px;
}

.scheme-status-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
}

.scheme-status-card {
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(255, 248, 234, 0.72), rgba(255, 255, 255, 0.94));
}

.scheme-status-title {
  margin: 0 0 12px;
  font-size: 14px;
  font-weight: 700;
  color: var(--muted);
}

.scheme-status-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 0;
  border-top: 1px solid rgba(229, 220, 200, 0.7);
}

.scheme-status-row:first-of-type {
  border-top: 0;
  padding-top: 0;
}

.scheme-status-row.empty {
  color: var(--muted);
}

.scheme-status-name {
  overflow: hidden;
  text-overflow: ellipsis;
}

.scheme-status-value {
  font-weight: 700;
  white-space: nowrap;
}

.scheme-table th:nth-child(n + 2),
.scheme-table td:nth-child(n + 2) {
  text-align: right;
}

.cluster-table th:nth-child(n + 2),
.cluster-table td:nth-child(n + 2),
.cluster-day-table th:nth-child(n + 2),
.cluster-day-table td:nth-child(n + 2),
.supply-table th:nth-child(n + 2),
.supply-table td:nth-child(n + 2),
.supply-plan-table th:nth-child(5),
.supply-plan-table td:nth-child(5),
.supply-plan-table th:nth-child(6),
.supply-plan-table td:nth-child(6),
.supply-plan-table th:nth-child(7),
.supply-plan-table td:nth-child(7),
.supply-plan-table th:nth-child(8),
.supply-plan-table td:nth-child(8),
.supply-plan-table th:nth-child(9),
.supply-plan-table td:nth-child(9),
.supply-plan-table th:nth-child(10),
.supply-plan-table td:nth-child(10),
.supply-plan-table th:nth-child(12),
.supply-plan-table td:nth-child(12),
.supply-plan-table th:nth-child(15),
.supply-plan-table td:nth-child(15),
.supply-plan-table th:nth-child(16),
.supply-plan-table td:nth-child(16),
.supply-plan-table th:nth-child(17),
.supply-plan-table td:nth-child(17),
.supply-plan-table th:nth-child(18),
.supply-plan-table td:nth-child(18),
.supply-day-table th:nth-child(n + 2),
.supply-day-table td:nth-child(n + 2) {
  text-align: right;
}

.supply-plan-controls {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.supply-plan-controls label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

.supply-plan-controls input,
.supply-plan-controls select {
  width: 100%;
}

.supply-plan-table th:nth-child(4) {
  min-width: 240px;
}

.supply-plan-table th:nth-child(11),
.supply-plan-table th:nth-child(14) {
  min-width: 180px;
}

.table-empty {
  padding: 18px 12px;
  color: var(--muted);
  text-align: center;
}

.expense-overview-panel {
  margin-bottom: 16px;
}

.metric-label-cell {
  display: grid;
  gap: 4px;
  min-width: 280px;
  white-space: normal;
}

.metric-label-title {
  font-weight: 600;
  color: var(--text);
}

.metric-label-note {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.expense-overview-table th:nth-child(n + 2),
.expense-overview-table td:nth-child(n + 2),
.article-expense-table th:nth-child(n + 6),
.article-expense-table td:nth-child(n + 6),
.inventory-day-table th:nth-child(n + 2),
.inventory-day-table td:nth-child(n + 2),
.inventory-sku-table th:nth-child(6),
.inventory-sku-table th:nth-child(7),
.inventory-sku-table th:nth-child(8),
.inventory-sku-table th:nth-child(11),
.inventory-sku-table th:nth-child(12),
.inventory-sku-table th:nth-child(13),
.inventory-sku-table th:nth-child(14),
.inventory-sku-table th:nth-child(15),
.inventory-sku-table th:nth-child(16),
.inventory-sku-table th:nth-child(17),
.inventory-sku-table th:nth-child(18),
.inventory-sku-table td:nth-child(6),
.inventory-sku-table td:nth-child(7),
.inventory-sku-table td:nth-child(8),
.inventory-sku-table td:nth-child(11),
.inventory-sku-table td:nth-child(12),
.inventory-sku-table td:nth-child(13),
.inventory-sku-table td:nth-child(14),
.inventory-sku-table td:nth-child(15),
.inventory-sku-table td:nth-child(16),
.inventory-sku-table td:nth-child(17),
.inventory-sku-table td:nth-child(18) {
  text-align: right;
}

.expense-note-block {
  display: grid;
  gap: 10px;
  color: var(--muted);
  line-height: 1.55;
}

.expense-note-block p {
  margin: 0;
}

.expense-article-methodology {
  margin: 0 0 16px;
  padding: 14px 16px;
  border: 1px solid rgba(191, 165, 120, 0.28);
  border-radius: 16px;
  background: rgba(255, 252, 245, 0.85);
}

.inventory-note-panel {
  margin-bottom: 16px;
}

.returns-received-panel {
  margin-bottom: 16px;
}

.returns-received-panel .cards {
  margin-bottom: 16px;
}

.article-name-cell {
  min-width: 280px;
  white-space: normal;
}

.article-meta-cell {
  min-width: 220px;
  white-space: normal;
  vertical-align: top;
}

.article-meta-list {
  display: grid;
  gap: 4px;
}

.article-meta-item {
  display: block;
  font-variant-numeric: tabular-nums;
  word-break: break-word;
}

.inventory-meta-cell {
  min-width: 180px;
  white-space: normal;
}

.filter-row th {
  background: rgba(247, 244, 236, 0.8);
  vertical-align: top;
}

.filter-select-cell {
  min-width: 170px;
}

.column-filter {
  width: 100%;
  min-height: 34px;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.92);
  font: inherit;
}

.column-filter-number {
  min-width: 84px;
}

.column-filter-select {
  cursor: pointer;
}

.column-filter-select.expanded {
  min-height: 240px;
  white-space: normal;
}

.competitor-import-controls {
  align-items: end;
}

.competitor-own-products-grid {
  display: grid;
  gap: 12px;
}

.competitor-own-products-grid label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 0.92rem;
}

.competitor-own-products-grid textarea {
  width: 100%;
  min-height: 112px;
  resize: vertical;
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 12px 14px;
  background: rgba(255, 255, 255, 0.95);
  color: var(--text);
  font: inherit;
  line-height: 1.45;
}

.competitor-filter-grid {
  display: grid;
  grid-template-columns: 1.3fr 1fr 1fr 0.8fr;
  gap: 14px;
  margin-bottom: 16px;
}

.competitor-filter-grid label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.92rem;
}

.competitor-filter-grid input,
.competitor-filter-grid select {
  min-height: 38px;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 8px 10px;
  background: rgba(255, 255, 255, 0.94);
  color: var(--text);
  font: inherit;
}

.competitor-table th,
.competitor-table td,
.competitor-matrix-table th,
.competitor-matrix-table td {
  vertical-align: top;
}

.competitor-table td:nth-child(3) {
  min-width: 320px;
  white-space: normal;
}

.competitor-table a {
  color: var(--accent);
  text-decoration: none;
}

.competitor-table a:hover {
  text-decoration: underline;
}

.competitor-row-check {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}

.competitor-matrix-table th:first-child {
  min-width: 230px;
  position: sticky;
  left: 0;
  z-index: 2;
  background: rgba(255, 252, 245, 0.96);
}

.competitor-matrix-table thead th {
  min-width: 220px;
}

.competitor-matrix-table thead span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 500;
  max-width: 260px;
  white-space: normal;
}

.competitor-metric-label {
  display: grid;
  gap: 4px;
  min-width: 230px;
  white-space: normal;
}

.competitor-metric-label small {
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 500;
  line-height: 1.35;
}

@media (max-width: 960px) {
  .hero,
  .grid,
  .control-actions,
  .unit-input-layout,
  .unit-form-grid,
  .unit-catalog-controls,
  .unit-product-import-controls,
  .unit-purchase-import-controls,
  .infographics-form-grid,
  .competitor-filter-grid {
    grid-template-columns: 1fr;
  }

  .unit-batch-expense-controls {
    grid-template-columns: 1fr;
  }

  .unit-buyout-auto-grid {
    grid-template-columns: 1fr;
  }

  .panel.wide {
    grid-column: auto;
  }

  .chart-shell,
  .chart-shell-wide {
    height: 280px;
  }

  .sheet-tabs {
    display: flex;
    width: 100%;
  }

  .sheet-tab {
    flex: 1 1 0;
  }

  .unit-span-2 {
    grid-column: auto;
  }

  .infographics-product-label,
  .infographics-wide {
    grid-column: auto;
  }

  .unit-toolbar {
    justify-content: flex-start;
  }
}
