/* ═══════════════════════════════════════════════════════════
   ПФК Производственный модуль — style.css
   Версия 3.0 | Фирстиль @pfk/design (navy + azure)
   Канон: C:\Users\user\Projects AG\pfk-design
═══════════════════════════════════════════════════════════ */

/* ─── Шрифт TT Norms Pro ──────────────────────────────────── */
@font-face {
  font-family: 'TT Norms Pro';
  src: url('/static/fonts/ttnormspro-regular.ttf') format('truetype');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'TT Norms Pro';
  src: url('/static/fonts/ttnormspro-medium.ttf') format('truetype');
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'TT Norms Pro';
  src: url('/static/fonts/ttnormspro-bold.ttf') format('truetype');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

/* ─── Переменные ──────────────────────────────────────────── */
:root {
  /* Акцент — единственный azure (@pfk/design) */
  --color-primary: #0082FF;
  --color-primary-hover: #0070DD;
  --color-primary-light: #E5F1FF;
  --color-primary-glow: rgba(0, 130, 255, 0.2);

  --color-surface: #F9FAFB;
  --color-bg: #F3F6F8;
  --color-panel: #FFFFFF;
  --color-header: #0A2A3F;

  --color-text: #0A2A3F;
  --color-text-muted: #5C6876;
  --color-text-on-dark: #FFFFFF;

  --color-border: #D7DCE0;
  --color-border-strong: #A6B1BE;
  --color-border-focus: #0082FF;

  /* Статусные — канон @pfk/design (success / warning / danger) */
  --color-yellow: #FBF1DC;
  --color-yellow-border: #C8901E;
  --color-green: #E3F2EA;
  --color-green-border: #2F8F5B;
  --color-red: #F7E3E1;
  --color-red-border: #C0392B;

  --color-step-done: #2F8F5B;
  --color-step-active: #0082FF;
  --color-step-idle: #A6B1BE;

  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .06);
  --shadow-md: 0 2px 8px rgba(0, 0, 0, .08);
  --shadow-lg: 0 4px 16px rgba(0, 0, 0, .10);

  --font: 'TT Norms Pro', 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
  --transition: 150ms ease;
}

/* ─── Reset / Base ────────────────────────────────────────── */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  font-feature-settings: "tnum";
}

body {
  font-family: var(--font);
  background: var(--color-bg);
  color: var(--color-text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

@media (prefers-reduced-motion: reduce) {

  *,
  *::before,
  *::after {
    animation-duration: .01ms !important;
    transition-duration: .01ms !important;
  }
}

/* ─── Skip link ───────────────────────────────────────────── */
.skip-link {
  position: absolute;
  top: -100%;
  left: 8px;
  background: var(--color-primary);
  color: #fff;
  padding: 8px 16px;
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
  font-weight: 600;
  text-decoration: none;
  z-index: 9999;
  transition: top var(--transition);
}

.skip-link:focus {
  top: 0;
}

/* ─── Visually hidden ─────────────────────────────────────── */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ─── Header ──────────────────────────────────────────────── */
.app-header {
  background: var(--color-header);
  color: var(--color-text-on-dark);
  box-shadow: var(--shadow-sm);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-inner {
  max-width: 1400px;
  margin: 0 auto;
  padding: 10px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.header-logo {
  display: flex;
  align-items: center;
  gap: 14px;
}

.logo-img {
  height: 40px;
  width: auto;
  border-radius: var(--radius-sm);
  object-fit: contain;
}

.header-title {
  font-size: 1rem;
  font-weight: 600;
}

.header-subtitle {
  font-size: .82rem;
  opacity: .65;
}

/* Step indicators */
.header-steps {
  display: flex;
  align-items: center;
  gap: 0;
}

.step-indicator {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: .8rem;
  font-weight: 500;
  opacity: .55;
  transition: opacity var(--transition);
}

.step-indicator[aria-current="step"],
.step-indicator.done {
  opacity: 1;
}

.step-num {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: rgba(255, 255, 255, .2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .75rem;
  font-weight: 700;
  transition: background var(--transition);
}

.step-indicator[aria-current="step"] .step-num {
  background: #fff;
  color: var(--color-primary);
}

.step-indicator.done .step-num {
  background: var(--color-step-done);
}

.step-connector {
  width: 32px;
  height: 2px;
  background: rgba(255, 255, 255, .25);
  margin: 0 6px;
}

/* ─── Screens ─────────────────────────────────────────────── */
.screen {
  display: none;
  flex: 1;
}

.screen-active {
  display: flex;
  flex-direction: column;
}

/* ─── PIN-экран ─────────────────────────────────────────── */
.pin-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  max-width: 340px;
  margin: auto;
  padding: 2.5rem 2rem;
  background: var(--card-bg, #fff);
  border-radius: 1rem;
  box-shadow: 0 4px 24px rgba(0,0,0,.08);
}
.pin-logo { margin-bottom: .5rem; }
.pin-title { font-size: 1.5rem; font-weight: 600; color: var(--text-primary, #0A2A3F); margin: 0; }
.pin-subtitle { font-size: .875rem; color: var(--text-secondary, #5C6876); margin: 0; }
.pin-input {
  width: 100%;
  padding: .75rem 1rem;
  font-size: 1.5rem;
  text-align: center;
  letter-spacing: .3em;
  border: 2px solid var(--border-color, #D7DCE0);
  border-radius: .5rem;
  outline: none;
  transition: border-color .2s;
}
.pin-input:focus { border-color: var(--primary, #0082FF); }
.pin-btn { width: 100%; }
.pin-error { color: #C0392B; font-size: .875rem; min-height: 1.25rem; margin: 0; }

main {
  display: flex;
  flex-direction: column;
  flex: 1;
}

/* ─── SCREEN 1: Upload ────────────────────────────────────── */
.upload-container {
  max-width: 680px;
  margin: 0 auto;
  padding: 48px 24px;
  display: flex;
  flex-direction: column;
  gap: 32px;
  width: 100%;
}

.upload-hero {
  text-align: center;
}

.upload-title {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: 8px;
  text-wrap: balance;
}

.upload-desc {
  color: var(--color-text-muted);
  font-size: .875rem;
}

/* Drop Zone */
.drop-zone {
  border: 2px dashed var(--color-border);
  border-radius: var(--radius-lg);
  background: var(--color-panel);
  padding: 40px 32px;
  text-align: center;
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition);
}

.drop-zone:hover,
.drop-zone:focus {
  border-color: var(--color-primary);
  background: var(--color-primary-light);
  outline: none;
}

.drop-zone.drag-over {
  border-color: var(--color-primary);
  background: var(--color-primary-light);
}

.drop-zone-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.drop-icon {
  filter: drop-shadow(0 2px 8px rgba(0, 130, 255, .2));
}

.drop-primary {
  font-size: 1rem;
  font-weight: 600;
  color: var(--color-text);
}

.drop-secondary {
  color: var(--color-text-muted);
  font-size: .875rem;
}

.drop-limits {
  font-size: .8125rem;
  color: var(--color-text-muted);
  margin-top: 4px;
}

/* File list */
.file-list-container {
  background: var(--color-panel);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 16px;
}

.file-list-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.file-list-title {
  font-size: .875rem;
  font-weight: 600;
}

.badge {
  background: var(--color-primary);
  color: #fff;
  border-radius: 12px;
  font-size: .8125rem;
  font-weight: 600;
  padding: 2px 8px;
  margin-left: 6px;
}

.file-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.file-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  font-size: .875rem;
  animation: fadeIn 150ms ease;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

.file-item-icon {
  font-size: 1rem;
  flex-shrink: 0;
}

.file-item-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-item-size {
  color: var(--color-text-muted);
  font-size: .8125rem;
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
}

.file-item-remove {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--color-text-muted);
  font-size: 1rem;
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  transition: color var(--transition), background var(--transition);
}

.file-item-remove:hover {
  color: var(--color-red-border);
  background: var(--color-red);
}

.file-item-remove:focus-visible {
  outline: 2px solid var(--color-border-focus);
}

.upload-actions {
  display: flex;
  justify-content: center;
}

/* ─── SCREEN 2: Loading ───────────────────────────────────── */
.loading-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  flex: 1;
  padding: 48px 24px;
  max-width: 480px;
  margin: 0 auto;
  text-align: center;
}

.loading-animation {
  position: relative;
  width: 80px;
  height: 80px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.loading-ring {
  position: absolute;
  inset: 0;
  border: 3px solid var(--color-primary-light);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.loading-logo {
  font-size: 1rem;
  font-weight: 800;
  color: var(--color-primary);
  letter-spacing: .5px;
}

.loading-title {
  font-size: 1.25rem;
  font-weight: 600;
}

.loading-subtitle {
  color: var(--color-text-muted);
  font-size: .875rem;
}

.progress-bar-wrap {
  width: 100%;
  height: 6px;
  background: var(--color-border);
  border-radius: 99px;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  width: 0%;
  border-radius: 99px;
  background: linear-gradient(90deg, var(--color-primary-hover), var(--color-primary));
  transition: width 400ms ease;
}

.loading-file-list {
  list-style: none;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.loading-file-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  background: var(--color-panel);
  font-size: .875rem;
}

.loading-file-status {
  font-size: .8125rem;
  font-weight: 600;
}

.status-done {
  color: var(--color-step-done);
}

.status-processing {
  color: var(--color-primary);
}

.status-pending {
  color: var(--color-text-muted);
}

.status-error {
  color: var(--color-red-border);
}

/* ─── SCREEN 3: Preview ───────────────────────────────────── */
.preview-layout {
  display: grid;
  grid-template-columns: 1fr 4px 1fr;
  min-height: calc(100vh - 70px);
}

.panel {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.panel-left {
  background: var(--color-panel);
  border-right: 1px solid var(--color-border);
}

.panel-right {
  background: var(--color-surface);
}

.panel-divider {
  background: var(--color-border);
  cursor: col-resize;
}

.panel-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-shrink: 0;
  background: var(--color-panel);
}

.panel-title {
  font-size: 1rem;
  font-weight: 700;
}

.file-selector {
  font-family: var(--font);
  font-size: .82rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  color: var(--color-text);
  padding: 4px 8px;
  max-width: 220px;
  cursor: pointer;
}

.file-selector:focus-visible {
  outline: 2px solid var(--color-border-focus);
}

/* Document viewer */
.document-viewer {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.viewer-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 200px;
  color: var(--color-text-muted);
  font-size: .9rem;
}

.viewer-excel-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .8125rem;
}

.viewer-excel-table th,
.viewer-excel-table td {
  border: 1px solid var(--color-border);
  padding: 5px 8px;
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  max-width: 180px;
  text-overflow: ellipsis;
}

.viewer-excel-table th {
  background: var(--color-header);
  color: var(--color-text-on-dark);
  font-weight: 600;
  font-size: .8125rem;
}

.viewer-excel-table tr:nth-child(even) {
  background: var(--color-surface);
}

.viewer-sheet-tabs {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  padding-bottom: 8px;
}

.viewer-sheet-tab {
  padding: 4px 12px;
  border-radius: var(--radius-sm);
  font-size: .8125rem;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid var(--color-border);
  background: var(--color-panel);
  color: var(--color-text-muted);
  transition: all var(--transition);
}

.viewer-sheet-tab.active,
.viewer-sheet-tab:hover {
  background: var(--color-primary);
  color: #fff;
  border-color: var(--color-primary);
}

.viewer-sheet-tab:focus-visible {
  outline: 2px solid var(--color-border-focus);
}

canvas.pdf-page {
  max-width: 100%;
  box-shadow: var(--shadow-sm);
  margin-bottom: 8px;
}

.viewer-text {
  font-size: .875rem;
  white-space: pre-wrap;
  font-family: var(--font-mono);
  line-height: 1.6;
}

.viewer-image {
  max-width: 100%;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm);
}

/* Right panel content */
.panel-right {
  padding-bottom: 0;
  overflow-y: auto;
}

.panel-right .panel-header {
  position: sticky;
  top: 0;
  z-index: 10;
}

.panel-header-actions {
  display: flex;
  gap: 8px;
}

/* Meta-block */
.meta-block {
  background: var(--color-panel);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  margin: 16px 20px 0;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.meta-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.meta-label {
  font-size: .875rem;
  font-weight: 600;
  color: var(--color-text-muted);
  min-width: 140px;
}

.meta-ctrl {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.meta-detected {
  display: flex;
  align-items: center;
  gap: 8px;
}

.meta-value-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--color-primary-light);
  color: var(--color-primary);
  border-radius: var(--radius-sm);
  padding: 3px 10px;
  font-weight: 600;
  font-size: .875rem;
}

.meta-choice-group {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.meta-choice-btn {
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--color-border);
  background: var(--color-surface);
  cursor: pointer;
  font-size: .875rem;
  font-weight: 500;
  color: var(--color-text-muted);
  transition: border-color var(--transition), color var(--transition);
}

.meta-choice-btn:hover {
  border-color: var(--color-primary);
  color: var(--color-primary);
}

.meta-choice-btn.selected,
.meta-choice-btn[aria-pressed="true"] {
  background: var(--color-primary);
  color: #fff;
  border-color: var(--color-primary);
}

.meta-choice-btn:focus-visible {
  outline: 2px solid var(--color-border-focus);
}

.meta-confirmed {
  color: var(--color-step-done);
  font-weight: 600;
  font-size: .875rem;
  display: flex;
  align-items: center;
  gap: 4px;
}

/* Sort bar */
.sort-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 12px 20px 0;
  padding: 0;
  flex-wrap: wrap;
}

.sort-bar-label {
  font-size: .8125rem;
  color: var(--color-text-muted);
  font-weight: 500;
}

.sort-btn {
  padding: 4px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-text-muted);
  font-family: var(--font);
  font-size: .8125rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
}

.sort-btn:hover {
  border-color: var(--color-primary);
  color: var(--color-primary);
}

.sort-btn:focus-visible {
  outline: 2px solid var(--color-border-focus);
}

.sort-btn-active {
  background: var(--color-primary);
  color: #fff;
  border-color: var(--color-primary);
}

/* Table */
.table-wrapper {
  margin: 16px 20px 0;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  overflow-x: auto;
  background: var(--color-panel);
}

.positions-table {
  width: 100%;
  border-collapse: collapse;
}

.positions-table th {
  background: var(--color-header);
  color: var(--color-text-on-dark);
  padding: 10px 10px;
  font-size: .8125rem;
  font-weight: 600;
  text-align: left;
  white-space: nowrap;
  position: sticky;
  top: 0;
  z-index: 5;
}

.positions-table td {
  padding: 0;
  border-bottom: 1px solid var(--color-border);
  vertical-align: middle;
}

.positions-table tr:last-child td {
  border-bottom: none;
}

.positions-table tr:hover td {
  background: var(--color-primary-light);
}

.col-type {
  width: 110px;
}

.col-color {
  width: 120px;
}

.col-num {
  width: 80px;
}

.col-actions {
  width: 36px;
}

/* Editable cells */
.cell-editable {
  display: block;
  width: 100%;
  height: 100%;
  padding: 9px 10px;
  font-size: .875rem;
  font-family: var(--font);
  border: none;
  outline: none;
  background: transparent;
  color: var(--color-text);
  cursor: text;
  font-variant-numeric: tabular-nums;
  transition: background var(--transition);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cell-editable:focus {
  background: var(--color-primary-light);
  outline: 2px solid var(--color-primary) inset;
}

/* Cell states */
.cell-low {
  background: var(--color-yellow) !important;
  border-left: 3px solid var(--color-yellow-border) !important;
}

.cell-confirmed {
  background: var(--color-green) !important;
  border-left: 3px solid var(--color-green-border) !important;
}

.cell-normal {
  background: transparent;
}

/* Type dropdown */
.type-select {
  width: 100%;
  height: 100%;
  padding: 9px 8px;
  font-size: .875rem;
  font-family: var(--font);
  border: none;
  background: transparent;
  cursor: pointer;
  color: var(--color-text);
}

.type-select:focus-visible {
  outline: 2px solid var(--color-border-focus);
}

/* Row delete button */
.btn-row-delete {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--color-text-muted);
  font-size: .9rem;
  padding: 4px 6px;
  border-radius: var(--radius-sm);
  width: 100%;
  transition: color var(--transition), background var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-row-delete:hover {
  color: var(--color-red-border);
  background: var(--color-red);
}

.btn-row-delete:focus-visible {
  outline: 2px solid var(--color-border-focus);
}

.table-empty {
  padding: 32px;
  text-align: center;
  color: var(--color-text-muted);
  font-size: .9rem;
}

/* Table stats */
.table-stats {
  margin: 8px 20px 0;
  font-size: .8125rem;
  color: var(--color-text-muted);
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}

.stats-item {
  display: flex;
  gap: 4px;
  align-items: center;
}

.stats-val {
  font-weight: 700;
  color: var(--color-text);
  font-variant-numeric: tabular-nums;
}

.stats-warn {
  color: var(--color-yellow-border);
  font-weight: 600;
}

/* Actions bar (bottom) */
.actions-bar {
  padding: 20px 20px 24px;
  border-top: 1px solid var(--color-border);
  background: var(--color-panel);
  display: flex;
  flex-direction: column;
  gap: 16px;
  flex-shrink: 0;
  position: sticky;
  bottom: 0;
}

.actions-buttons {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

.hint-text {
  font-size: .75rem;
  color: var(--color-text-muted);
}

/* Checkbox */
.checkbox-label {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  font-size: .88rem;
  font-weight: 500;
  user-select: none;
}

.checkbox-label input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.checkbox-custom {
  width: 20px;
  height: 20px;
  border: 2px solid var(--color-border);
  border-radius: 4px;
  flex-shrink: 0;
  background: var(--color-panel);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
}

.checkbox-label input:checked+.checkbox-custom {
  background: var(--color-primary);
  border-color: var(--color-primary);
}

.checkbox-label input:checked+.checkbox-custom::after {
  content: '✓';
  color: #fff;
  font-size: .85rem;
  font-weight: 700;
  margin-top: -1px;
}

.checkbox-label input:focus-visible+.checkbox-custom {
  box-shadow: 0 0 0 3px var(--color-primary-glow);
}

/* ─── Buttons ─────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: .875rem;
  font-weight: 500;
  border: none;
  cursor: pointer;
  text-decoration: none;
  transition: background var(--transition), opacity var(--transition);
  white-space: nowrap;
}

.btn:focus-visible {
  outline: 2px solid var(--color-border-focus);
  outline-offset: 2px;
}

.btn-primary {
  background: var(--color-primary);
  color: #fff;
}

.btn-primary:hover:not(:disabled) {
  background: var(--color-primary-hover);
}

.btn-primary:disabled,
.btn-primary[aria-disabled="true"] {
  background: var(--color-border);
  color: #9CA3AF;
  cursor: not-allowed;
}

.btn-secondary {
  background: #F3F4F6;
  color: var(--color-text);
  border: 1px solid var(--color-border);
}

.btn-secondary:hover {
  background: var(--color-border);
}

.btn-ghost {
  background: none;
  color: var(--color-primary);
  border: none;
  padding: 6px 10px;
  font-size: .875rem;
}

.btn-ghost:hover {
  background: var(--color-primary-light);
}

.btn-sm {
  padding: 6px 12px;
  font-size: .8125rem;
}

.btn-lg {
  padding: 12px 28px;
  font-size: .875rem;
  font-weight: 600;
}

.btn-icon {
  font-size: 1rem;
}

/* ─── Toast notifications ─────────────────────────────────── */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 9000;
  max-width: 360px;
}

.toast {
  background: var(--color-panel);
  color: var(--color-text);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  box-shadow: var(--shadow-md);
  display: flex;
  align-items: flex-start;
  gap: 10px;
  border-left: 3px solid var(--color-primary);
  animation: toastIn 150ms ease forwards;
  font-size: .875rem;
}

.toast.toast-error {
  border-left-color: var(--color-red-border);
}

.toast.toast-success {
  border-left-color: var(--color-step-done);
}

.toast.toast-warning {
  border-left-color: var(--color-yellow-border);
}

.toast-icon {
  font-size: 1.1rem;
  flex-shrink: 0;
}

.toast-msg {
  flex: 1;
  line-height: 1.4;
}

.toast-close {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--color-text-muted);
  padding: 0 2px;
  font-size: 1rem;
  line-height: 1;
  transition: color var(--transition);
}

.toast-close:hover {
  color: var(--color-text);
}

.toast-close:focus-visible {
  outline: 2px solid var(--color-border-focus);
}

@keyframes toastIn {
  from {
    opacity: 0;
    transform: translateX(20px);
  }

  to {
    opacity: 1;
    transform: translateX(0);
  }
}

.toast-out {
  animation: toastOut 250ms ease forwards;
}

@keyframes toastOut {
  from {
    opacity: 1;
    transform: translateX(0);
  }

  to {
    opacity: 0;
    transform: translateX(20px);
  }
}

/* ─── Zoom Controls ──────────────────────────────────────── */
.zoom-controls {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: 12px;
}

.btn-zoom {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  color: var(--color-text);
  transition: background var(--transition);
}

.btn-zoom:hover {
  background: var(--color-border);
}

.zoom-level {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--color-muted);
  min-width: 36px;
  text-align: center;
}

/* ─── Panel Scrolling ────────────────────────────────────── */
.document-viewer {
  overflow: auto;
  max-height: calc(100vh - 200px);
}

.document-viewer>* {
  transform-origin: top left;
}

.table-wrapper {
  overflow: auto;
  max-height: calc(100vh - 320px);
}

.table-wrapper>* {
  transform-origin: top left;
}

/* ─── New Calc Button ────────────────────────────────────── */
.btn-success {
  background: var(--color-green-border);
  color: #fff;
  border: none;
  font-weight: 600;
}

.btn-success:hover {
  background: #267449;
}

/* ─── Feedback button ───────────────────────────────────── */
.btn-feedback {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: .82rem;
  white-space: nowrap;
  flex-shrink: 0;
}

/* ─── Modal overlay ────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal-overlay[hidden] {
  display: none;
}

.modal-dialog {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  box-shadow: 0 12px 40px rgba(0,0,0,.25);
  width: min(520px, 90vw);
  max-height: 80vh;
  display: flex;
  flex-direction: column;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px 12px;
  border-bottom: 1px solid var(--color-border);
}

.modal-title {
  font-size: 1.05rem;
  font-weight: 600;
}

.modal-close {
  background: none;
  border: none;
  font-size: 1.6rem;
  cursor: pointer;
  color: var(--color-text);
  line-height: 1;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  opacity: .7;
}

.modal-close:hover { opacity: 1; background: rgba(0,0,0,.06); }

.modal-body {
  padding: 16px 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.feedback-field-label {
  font-size: .85rem;
  font-weight: 500;
  color: var(--color-text-muted);
}

.feedback-textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  font-family: inherit;
  font-size: .9rem;
  resize: vertical;
  background: var(--color-bg);
  color: var(--color-text);
}

.feedback-textarea:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(0, 130, 255, .15);
}

.feedback-file-input {
  font-size: .85rem;
}

.feedback-file-list {
  font-size: .82rem;
  color: var(--color-text-muted);
}

.modal-footer {
  padding: 12px 20px 16px;
  border-top: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
}

.feedback-status {
  font-size: .82rem;
  color: var(--color-text-muted);
}

.feedback-status.success { color: var(--color-green-border); }
.feedback-status.error { color: var(--color-red-border); }

/* ─── Mobile responsive ──────────────────────────────────── */
@media (max-width: 1024px) {
  .preview-layout {
    grid-template-columns: 1fr 4px 1fr;
  }

  .header-steps .step-label {
    display: none;
  }

  .feedback-label {
    display: none;
  }

  .meta-block {
    margin: 12px 16px 0;
  }
}

@media (max-width: 768px) {
  .preview-layout {
    grid-template-columns: 1fr;
  }

  .panel-divider {
    display: none;
  }

  .panel-left {
    border-right: none;
    border-bottom: 1px solid var(--color-border);
    max-height: 40vh;
  }

  .header-steps {
    display: none;
  }

  .header-inner {
    padding: 10px 12px;
  }

  .meta-block {
    margin: 12px 12px 0;
  }

  .table-wrapper {
    margin: 12px 12px 0;
  }

  .actions-bar {
    padding: 16px 12px;
  }
}