/*
 * OPK Doors — Pencil Sketch / Millimeter Paper Theme
 * Enhanced version with visible hand-drawn aesthetic
 */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

:root {
  --paper: #f5f3ed;
  --ink: #2d2925;
  --ink-light: #8a8072;
  --ink-lighter: #b3aa9e;
  --border: #e8e2d8;
  --shadow: #d5cdc0;
  --accent: #b3aa9e;
  --accent-bg: #ede4d5;
  --success: #4a7a4a;
  --warning: #b08a40;
  --danger: #8a4040;
  --grid-light: #e5e0d5;
  --grid-dark: #d5cfc0;
  --card-bg: #faf8f5;
  --topbar-bg: #b3aa9e;
  --topbar-text: #2d2925;
  --nav-hover: #8a8072;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html { font-size: 15px; }

body {
  font-family: 'Inter', -apple-system, sans-serif;
  color: var(--ink);
  line-height: 1.7;
  min-height: 100vh;
  background-color: var(--paper);
  /* Millimeter paper grid */
  background-image:
    linear-gradient(var(--grid-light) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-light) 1px, transparent 1px);
  background-size: 20px 20px;
  background-position: -1px -1px;
}

/* ─── Typography ─── */

h1 {
  font-family: 'Inter', -apple-system, sans-serif;
  font-size: 2.25rem;
  font-weight: 600;
  letter-spacing: 0.5px;
  margin-bottom: 20px;
  padding-bottom: 10px;
  border-bottom: 3px double var(--ink);
  display: inline-block;
}

h2 {
  font-family: 'Inter', -apple-system, sans-serif;
  font-size: 1.4rem;
  font-weight: 600;
  margin-bottom: 16px;
  padding-bottom: 6px;
  border-bottom: 2px dashed var(--ink-lighter);
}

h3 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 12px;
}

/* ─── Layout ─── */

.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 20px 40px;
}

/* ─── Top Bar ─── */

.top-bar {
  background-color: #b3aa9e;
  background-image:
    linear-gradient(rgba(0,0,0,0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0,0,0,0.04) 1px, transparent 1px);
  background-size: 4px 4px;
  border-bottom: 3px double var(--ink);
  padding: 14px 28px;
  margin: 0 -20px 30px -20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 100;
}

.top-bar .brand {
  font-size: 0.9rem;
  font-weight: 700;
  text-decoration: none;
  color: var(--ink);
  letter-spacing: 1.5px;
  text-transform: uppercase;
}

.top-bar .brand span {
  font-weight: 400;
  color: #7a6b52;
}

.top-bar nav a {
  color: var(--ink);
  text-decoration: none;
  margin-left: 24px;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  font-weight: 600;
  padding-bottom: 4px;
  border-bottom: 1px solid transparent;
  transition: all 0.2s;
}

.top-bar nav a:hover {
  border-bottom: 3px double var(--ink);
}

.top-bar nav a.active {
  border-bottom: 2px solid var(--ink);
}

/* ─── Buttons ─── */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 22px;
  font-family: 'Inter', -apple-system, sans-serif;
  font-size: 0.85rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  border: 2px solid var(--ink);
  background: var(--card-bg);
  color: var(--ink);
  transition: all 0.12s;
  box-shadow: 3px 3px 0 var(--shadow);
  letter-spacing: 0.5px;
}

.btn:hover {
  transform: translate(-2px, -2px);
  box-shadow: 5px 5px 0 var(--shadow);
}

.btn:active {
  transform: translate(1px, 1px);
  box-shadow: 1px 1px 0 var(--shadow);
}

.btn-primary {
  background: #5f5f5f;
  color: var(--paper);
  border-color: var(--ink);
  box-shadow: 3px 3px 0 var(--ink);
}

.btn-primary:hover {
  background: #333;
}

/* Badge-style buttons — тёмный фон, uppercase, моноширинный */
.btn-badge {
  background: var(--ink);
  color: var(--paper);
  border-color: var(--ink);
  box-shadow: 3px 3px 0 var(--shadow);
  text-transform: uppercase;
  letter-spacing: 1.5px;
  font-size: 0.85rem;
  font-weight: 600;
  padding: 10px 22px;
}

.btn-badge:hover {
  background: var(--paper);
  color: var(--ink);
  box-shadow: 5px 5px 0 var(--shadow);
}

.btn-sm {
  padding: 8px 16px;
  font-size: 0.75rem;
  box-shadow: 2px 2px 0 var(--shadow);
}

.btn-outline {
  background: transparent;
  color: var(--ink);
  border-color: var(--ink);
  box-shadow: 3px 3px 0 var(--shadow);
}

.btn-outline:hover {
  background: var(--accent-bg);
}

/* ─── Tables ─── */

.table-wrap {
  background: var(--card-bg);
  border: 2px solid var(--ink);
  box-shadow: 4px 4px 0 var(--shadow);
  margin-bottom: 28px;
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

thead th {
  background: var(--accent-bg);
  border-bottom: 3px double var(--ink);
  padding: 12px 14px;
  text-align: left;
  font-weight: 700;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--ink);
}

tbody td {
  padding: 10px 14px;
  border-bottom: 1px dashed var(--grid-dark);
  vertical-align: middle;
}

tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: rgba(0,0,0,0.02); }

/* ─── Status ─── */

.status {
  display: inline-block;
  padding: 3px 10px;
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border: 1.5px solid;
  border-radius: 2px;
}
.status-new { border-color: var(--accent); color: var(--accent); }
.status-imported { border-color: var(--ink-lighter); color: var(--ink-lighter); }
.status-shipped { border-color: var(--success); color: var(--success); }

/* ─── Cards ─── */

.card {
  background: var(--card-bg);
  border: 2px solid var(--ink);
  box-shadow: 4px 4px 0 var(--shadow);
  padding: 24px;
  margin-bottom: 24px;
}

.card-title {
  font-weight: 600;
  margin-bottom: 16px;
  padding-bottom: 10px;
  border-bottom: 2px dashed var(--ink-lighter);
  font-size: 0.9rem;
  letter-spacing: 0.5px;
}

/* ─── Forms ─── */

.form-group {
  margin-bottom: 18px;
}

.form-group label {
  display: block;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 5px;
  color: var(--ink-light);
}

.form-control {
  width: 100%;
  padding: 10px 12px;
  font-family: 'Inter', -apple-system, sans-serif;
  font-size: 0.85rem;
  border: 2px solid var(--ink);
  background: white;
  border-radius: 0;
  transition: box-shadow 0.2s;
}

.form-control:focus {
  outline: none;
  box-shadow: 3px 3px 0 var(--shadow);
}

select.form-control {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M3 5l3 4 3-4' fill='none' stroke='%231a1a1a' stroke-width='2'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}

/* ─── Door Type Cards Grid ─── */

.type-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 8px;
}

.type-card {
  background: var(--card-bg);
  border: 2px solid var(--border);
  padding: 16px 12px;
  text-align: center;
  cursor: pointer;
  transition: all 0.12s;
  box-shadow: 3px 3px 0 var(--shadow);
}

.type-card:hover {
  border-color: var(--ink);
  transform: translate(-2px, -2px);
  box-shadow: 5px 5px 0 var(--shadow);
}

.type-card.selected {
  border-color: var(--ink);
  background: var(--accent-bg);
  box-shadow: inset 1px 1px 0 rgba(0,0,0,0.1);
}

.type-icon { font-size: 2rem; margin-bottom: 6px; }
.type-code { font-weight: 600; font-size: 1rem; }
.type-desc { font-size: 0.7rem; color: var(--ink-light); margin-top: 4px; }

/* ─── Calculation Result ─── */

.calc-result {
  background: var(--card-bg);
  border: 2px solid var(--ink);
  padding: 24px;
  margin-bottom: 24px;
  box-shadow: 4px 4px 0 var(--shadow);
}

.calc-result h3 {
  border-bottom: 2px dashed var(--ink-lighter);
  padding-bottom: 10px;
  margin-bottom: 18px;
}

.calc-dimensions {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.calc-dim {
  text-align: center;
  padding: 16px;
  border: 2px dashed var(--grid-dark);
  background: rgba(0,0,0,0.01);
}

.calc-dim .dim-label {
  font-size: 0.65rem;
  text-transform: uppercase;
  color: var(--ink-light);
  letter-spacing: 0.5px;
  margin-bottom: 6px;
}

.calc-dim .dim-value {
  font-size: 1.8rem;
  font-weight: 600;
  color: var(--ink);
}

/* ─── Photo cell with hover zoom ─── */

.photo-cell {
  display: flex;
  align-items: center;
  justify-content: center;
}

.photo-thumb {
  width: 36px;
  height: 36px;
  border: 1.5px solid var(--grid-heavy);
  border-radius: 2px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--card-bg);
  overflow: hidden;
  transition: all 0.2s ease;
  cursor: pointer;
  position: relative;
  z-index: 1;
}

.photo-thumb img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.photo-thumb svg {
  width: 24px;
  height: 24px;
}

.photo-thumb:hover .hover-enlarge {
  display: block;
}

/* ─── Hover enlarge ─── */
.hover-enlarge {
  display: none;
  position: fixed;
  z-index: 100000;
  width: 360px;
  height: 360px;
  border: 2px solid var(--ink);
  border-radius: 8px;
  box-shadow: 0 16px 48px rgba(0,0,0,0.3);
  background: var(--card-bg);
  padding: 6px;
  pointer-events: none;
  overflow: hidden;
}
.hover-enlarge img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: 4px;
}
/* ─── Category Header ─── */

.cat-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  padding-bottom: 10px;
  border-bottom: 2px dashed var(--ink-lighter);
  gap: 12px;
}

.cat-title {
  font-family: 'Inter', -apple-system, sans-serif;
  font-size: 1.4rem;
  font-weight: 600;
  letter-spacing: 0.5px;
  flex-shrink: 0;
}

.cat-actions {
  flex-shrink: 0;
}

@media (max-width: 480px) {
  .cat-header {
    flex-wrap: wrap;
    justify-content: center;
    text-align: center;
  }
  .cat-title {
    width: 100%;
    text-align: center;
    font-size: 1.2rem;
  }
  .cat-actions {
    width: 100%;
    display: flex;
    justify-content: center;
  }
}

/* ─── Responsive Table ─── */

.table-responsive {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

@media (max-width: 600px) {
  .table-responsive table,
  .table-responsive thead,
  .table-responsive tbody,
  .table-responsive tr,
  .table-responsive th,
  .table-responsive td {
    display: block;
  }
  .table-responsive thead {
    display: none; /* hide table headers, use data-label instead */
  }
  .table-responsive tr {
    margin-bottom: 16px;
    border: 2px solid var(--ink);
    box-shadow: 3px 3px 0 var(--shadow);
    padding: 12px;
    background: var(--card-bg);
  }
  .table-responsive td {
    border: none;
    border-bottom: 1px dashed var(--grid-dark);
    padding: 8px 4px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
  }
  .table-responsive td:last-child {
    border-bottom: none;
  }
  .table-responsive td::before {
    content: attr(data-label);
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--ink-light);
    flex-shrink: 0;
  }
  .table-responsive td.col-actions-cell::before {
    content: '';
    display: none;
  }
  .table-responsive td.col-actions-cell {
    justify-content: center;
    padding-top: 12px;
  }
  .photo-thumb:hover {
    border-color: var(--accent);
  }
  .col-photo { display: none; }
  thead .col-actions { display: none; }
}

/* ─── Component List ─── */

.comp-list { list-style: none; }
.comp-list li {
  padding: 8px 0;
  border-bottom: 1px dashed var(--grid-dark);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.85rem;
}
.comp-list li:last-child { border-bottom: none; }
.comp-code { font-weight: 600; }
.comp-qty { color: var(--ink-light); }

/* ─── Section dividers with sketch look ─── */

.sketch-divider {
  border: none;
  border-top: 3px double var(--ink);
  margin: 32px 0;
  opacity: 0.3;
}

/* ─── Footer ─── */

.footer {
  text-align: center;
  padding: 32px 0 10px;
  font-size: 0.7rem;
  color: var(--ink-lighter);
  border-top: 2px dashed var(--grid-dark);
  margin-top: 40px;
  letter-spacing: 0.5px;
}

/* ─── Action bar (flex row of buttons/actions) ─── */

.action-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 12px;
}

/* ─── Responsive ─── */

@media (max-width: 768px) {
  .form-row { grid-template-columns: 1fr; }
  .type-grid { grid-template-columns: repeat(2, 1fr); }
  .top-bar { flex-direction: column; gap: 12px; padding: 12px 16px; }
  .top-bar nav a { margin: 0 10px; }
  .calc-dimensions { grid-template-columns: 1fr 1fr; }
  .action-bar { flex-direction: column; align-items: stretch; }
}

/* ─── Lightbox ─── */

.lightbox {
  display: none;
  position: fixed;
  z-index: 9999;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,0.85);
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.lightbox.active {
  display: flex;
}

.lightbox-img {
  max-width: 90vw;
  max-height: 90vh;
  object-fit: contain;
  border: 3px solid var(--paper);
  box-shadow: 0 8px 40px rgba(0,0,0,0.5);
}

.lightbox-close {
  position: absolute;
  top: 20px;
  right: 30px;
  color: var(--paper);
  font-size: 2.5rem;
  font-weight: 300;
  cursor: pointer;
  line-height: 1;
  opacity: 0.8;
  transition: opacity 0.2s;
}

.lightbox-close:hover {
  opacity: 1;
}

/* ─── Modal Confirm ─── */

.modal-overlay {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(45, 41, 37, 0.5);
  z-index: 1000;
  align-items: center;
  justify-content: center;
}

.modal-overlay.active {
  display: flex;
}

.modal-dialog {
  background: var(--card-bg);
  border: 2px solid var(--ink);
  box-shadow: 6px 6px 0 var(--shadow);
  max-width: 420px;
  width: 90%;
  padding: 32px 28px 20px;
  text-align: center;
  animation: modalIn 0.15s ease-out;
}

@keyframes modalIn {
  from { transform: translateY(-20px); opacity: 0; }
  to   { transform: translateY(0); opacity: 1; }
}

.modal-icon {
  margin-bottom: 12px;
  color: var(--warning);
}

.modal-message {
  font-family: 'Inter', -apple-system, sans-serif;
  font-size: 1rem;
  line-height: 1.5;
  color: var(--ink);
  margin-bottom: 24px;
}

.modal-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
}

.modal-actions .btn {
  min-width: 100px;
  justify-content: center;
}

.modal-cancel {
  background: var(--paper) !important;
  color: var(--ink) !important;
}

.modal-confirm {
  background: var(--danger) !important;
  border-color: var(--danger) !important;
  color: var(--paper) !important;
}

/* ─── Collapsible Categories ─── */

.cat-header {
  cursor: pointer;
  user-select: none;
}

.cat-header .collapse-icon {
  display: inline-block;
  transition: transform 0.25s ease;
  font-size: 0.85rem;
  margin-right: 8px;
  color: var(--ink-lighter);
}

.cat-header .collapse-icon.expanded {
  transform: rotate(90deg);
}

.card.collapsed .table-responsive {
  display: none;
}

.card.collapsed .cat-header {
  margin-bottom: 0;
  padding-bottom: 0;
  border-bottom: none;
}

/* ─── Search & Toolbar ─── */

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.toolbar .search-wrap {
  position: relative;
  flex: 0 1 400px;
  min-width: 180px;
}

.toolbar .search-inner {
  display: flex;
  align-items: center;
  width: 100%;
  border: 2px solid var(--ink);
  background: var(--paper);
  box-shadow: 3px 3px 0 var(--shadow);
  transition: box-shadow 0.12s;
}

.toolbar .search-inner:focus-within {
  box-shadow: 3px 3px 0 var(--accent);
  border-color: var(--accent);
}

.toolbar .search-icon {
  flex-shrink: 0;
  width: 16px;
  height: 16px;
  color: var(--ink-lighter);
  pointer-events: none;
  margin: 0 8px;
}

.toolbar .search-wrap input {
  flex: 1;
  min-width: 0;
  padding: 10px 14px 10px 0;
  font-family: 'Inter', -apple-system, sans-serif;
  font-size: 0.8rem;
  border: none;
  background: transparent;
  color: var(--ink);
  outline: none;
}

.toolbar .search-wrap input::placeholder {
  color: var(--ink-lighter);
  font-style: italic;
}
/* highlight search match */
tr.search-highlight {
  background: #fff3cd !important;
  outline: 2px solid #f0c040;
  outline-offset: -2px;
}

/* auto-scroll margin */
.scroll-target {
  scroll-margin-top: 20px;
}

@media (max-width: 600px) {
  .toolbar {
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    flex-wrap: nowrap;
    gap: 6px;
  }
  .toolbar .search-wrap {
    max-width: 100%;
    min-width: 0;
    flex: 0 1 auto;
  }
  .toolbar .search-wrap input {
    padding: 7px 10px 7px 0 !important;
    font-size: 0.75rem !important;
  }
  .toolbar .search-icon {
    width: 14px !important;
    height: 14px !important;
    margin: 0 6px !important;
  }
  .toolbar .search-inner {
    padding: 0;
  }
  .toolbar > :first-child {
    order: 3;
  }
  .toolbar > :last-child {
    order: 2;
    margin-left: 0;
  }
  .toolbar .search-wrap {
    order: 1;
  }
  .toolbar .btn-badge {
    padding: 8px 16px !important;
    font-size: 0.75rem !important;
  }
  .toolbar .btn {
    padding: 8px 16px !important;
    font-size: 0.75rem !important;
  }
}

/* ─── Sticky Header (Components page) ─── */

.sticky-header {
  position: sticky;
  top: 50px;
  z-index: 50;
  background-color: var(--paper);
  background-image:
    linear-gradient(var(--grid-light) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-light) 1px, transparent 1px);
  background-size: 20px 20px;
  background-position: -1px -1px;
  margin: 0 -20px;
  padding: 0 20px 12px;
  border-bottom: 1px solid var(--border);
}

.sticky-header h1 {
  border-bottom: none;
}

/* ─── Door Types / Model Range ─── */

.door-group {
  margin-bottom: 32px;
}

.door-group-title {
  font-family: 'Inter', -apple-system, sans-serif;
  font-size: 1.35rem;
  font-weight: 500;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--ink-light);
  margin-bottom: 16px;
  padding-bottom: 8px;
  border-bottom: 2px dashed var(--grid-dark);
}

.door-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 20px;
}

.door-card {
  background: var(--card-bg);
  border: 2px solid var(--ink);
  box-shadow: 4px 4px 0 var(--shadow);
  transition: transform 0.15s, box-shadow 0.15s;
  cursor: pointer;
  text-decoration: none;
  color: var(--ink);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.door-card:hover {
  transform: translate(-2px, -2px);
  box-shadow: 6px 6px 0 var(--shadow);
}

.door-card:active {
  transform: translate(1px, 1px);
  box-shadow: 2px 2px 0 var(--shadow);
}

.door-card-img {
  width: 100%;
  height: 180px;
  background: var(--paper);
  display: flex;
  align-items: center;
  justify-content: center;
  border-bottom: 2px dashed var(--grid-dark);
  padding: 12px;
}

.door-card-img img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.door-card-body {
  padding: 14px 16px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.door-card-code {
  font-family: 'Inter', -apple-system, sans-serif;
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--ink-lighter);
  margin-top: 4px;
}

.door-card-desc {
  font-family: 'Inter', -apple-system, sans-serif;
  font-size: 1.125rem;
  font-weight: 500;
  line-height: 1.4;
  color: var(--ink);
}

.door-card-meta {
  font-size: 0.72rem;
  color: var(--ink-lighter);
  display: flex;
  gap: 16px;
  align-items: center;
  padding-top: 8px;
  border-top: 1px solid var(--grid-dark);
  margin-top: auto;
}

.door-card-meta .comp-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--accent-bg);
  padding: 2px 8px;
  font-weight: 500;
}

/* ─── Models Header ─── */
.models-header {
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  margin-bottom: 24px;
}
.models-header h1 {
  margin: 0 auto;
}
.models-header-btn {
  position: absolute;
  right: 0;
  flex-shrink: 0;
}

@media (max-width: 768px) {
  .models-header {
    flex-direction: column;
    gap: 12px;
  }
  .models-header h1 {
    font-size: 1.6rem !important;
  }
  .models-header-btn {
    position: static;
    width: 100%;
    text-align: center;
  }
  .models-header-btn .btn-badge {
    width: 100%;
    justify-content: center;
  }
}

/* ─── Model Hero Mobile ─── */
@media (max-width: 768px) {
  .model-hero {
    flex-direction: column;
    padding: 16px;
    gap: 16px;
  }
  .model-hero-img {
    width: 100% !important;
    max-width: 100%;
  }
  .model-hero-img img {
    max-height: 200px;
  }
  .model-hero-title {
    font-size: 1.5rem;
  }
}

@media (max-width: 600px) {
  .door-grid {
    grid-template-columns: 1fr;
  }
  .door-card-img {
    height: 140px;
  }
}

/* ─── Global Mobile Fixes ─── */
@media (max-width: 600px) {
  /* Order index: stats grid */
  .container > div[style*="grid-template-columns: repeat(auto-fit, minmax(220px, 1fr))"] {
    grid-template-columns: 1fr !important;
  }
  /* Order view: data grid */
  .card > div[style*="grid-template-columns: repeat(auto-fit, minmax(200px, 1fr))"] {
    grid-template-columns: 1fr !important;
  }
  /* Order new: select-type grid */
  .type-grid {
    grid-template-columns: repeat(2, 1fr) !important;
  }
  /* Order new: form rows and buttons */
  .form-row {
    grid-template-columns: 1fr !important;
  }
  form > .btn, form > a.btn {
    width: 100%;
    justify-content: center;
    margin-left: 0 !important;
    margin-bottom: 8px;
  }
  /* Component form: storage row */
  .form-group > div[style*="display:flex"][style*="gap"] {
    flex-direction: column;
  }
  /* Component form: buttons row */
  .card form > div[style*="margin-top"] {
    flex-wrap: wrap;
  }
  .card form > div[style*="margin-top"] .btn {
    flex: 1;
    justify-content: center;
    text-align: center;
  }
  /* Reduce h1 spacing on mobile */
  h1 {
    margin-bottom: 14px !important;
    padding-bottom: 6px !important;
  }
  .card {
    padding: 16px !important;
    margin-bottom: 16px !important;
  }

  /* ─── Orders page: flex header (h1 + button) ─── */
  .orders-header > div[style*="justify-content:space-between"] {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 12px !important;
  }
  .orders-header > div[style*="justify-content:space-between"] h1 {
    width: 100% !important;
  }
  .orders-header > div[style*="justify-content:space-between"] a.btn {
    width: 100%;
    justify-content: center;
  }

  /* ─── Stats row: 3 cards wrap on mobile ─── */
  .stats-row {
    flex-direction: column !important;
    gap: 10px !important;
  }
  .stats-row .stat-card {
    width: 100% !important;
    min-width: 0 !important;
  }

  /* ─── Order view page: header ─── */
  .order-view-header {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 10px !important;
  }
  .order-view-header > div:first-child {
    flex-wrap: wrap !important;
    gap: 8px !important;
  }
  .order-view-header > div:first-child h1 {
    font-size: 1.3rem !important;
  }
  .order-view-header > div:last-child {
    justify-content: flex-start !important;
  }

  /* ─── Order info row (создан, срок, дверей) ─── */
  .order-info-row {
    flex-direction: column !important;
    gap: 6px !important;
  }

  /* ─── Door view header ─── */
  .door-view-header {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 10px !important;
  }
  .door-view-header > div:first-child {
    flex-wrap: wrap !important;
    gap: 8px !important;
  }
  .door-view-header > div:first-child h1 {
    font-size: 1.15rem !important;
  }
  .door-view-header > div:last-child {
    justify-content: flex-start !important;
  }

  /* ─── Door detail: PDF buttons row ─── */
  .pdf-buttons {
    flex-direction: column !important;
    gap: 8px !important;
  }
  .pdf-buttons .btn {
    width: 100%;
    justify-content: center;
  }

  /* ─── Order card details on mobile ─── */
  .order-card-meta {
    flex-direction: column !important;
    gap: 4px !important;
  }

  /* ─── Door form: flex form-row (высота/ширина) ─── */
  form .flex-form-row {
    flex-direction: column !important;
    gap: 12px !important;
  }
  form .flex-form-row .form-group {
    flex: none !important;
    width: 100% !important;
  }

  /* ─── Door detail: component table card view ─── */
  .comp-full-table,
  .comp-full-table thead,
  .comp-full-table tbody,
  .comp-full-table tr,
  .comp-full-table th,
  .comp-full-table td {
    display: block;
  }
  .comp-full-table thead {
    display: none !important;
  }
  .comp-full-table tr {
    margin-bottom: 12px;
    border: 2px solid var(--ink);
    box-shadow: 3px 3px 0 var(--shadow);
    padding: 10px;
    background: var(--card-bg);
  }
  .comp-full-table td {
    border: none;
    border-bottom: 1px dashed var(--grid-dark);
    padding: 6px 4px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 6px;
    font-size: 0.75rem;
  }
  .comp-full-table td:last-child {
    border-bottom: none;
  }
  .comp-full-table td::before {
    content: attr(data-label);
    font-size: 0.6rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--ink-light);
    flex-shrink: 0;
  }
  .comp-full-table td.row-num::before {
    content: "№";
  }
  .comp-full-table td.cat-name::before {
    content: "Категория";
  }
  .comp-full-table td.num {
    justify-content: space-between;
  }

  /* ─── Order form buttons row ─── */
  .order-form-buttons {
    flex-direction: column !important;
    gap: 8px !important;
  }
  .order-form-buttons .btn {
    width: 100%;
    justify-content: center;
  }

  /* ─── Door form buttons row ─── */
  .door-form-buttons {
    flex-direction: column !important;
    gap: 8px !important;
  }
  .door-form-buttons .btn {
    width: 100%;
    justify-content: center;
  }

  /* ─── Empty state ─── */
  .empty-state {
    padding: 30px 16px !important;
  }

  /* ─── General h1 on mobile ─── */
  h1 {
    font-size: 1.5rem !important;
  }

  /* ─── Status select on mobile ─── */
  .status-select {
    font-size: 0.6rem !important;
    padding: 2px 18px 2px 6px !important;
  }

  /* ─── Order card: improve spacing on mobile ─── */
  .order-card {
    padding: 12px 14px !important;
  }

  /* ─── Door view: info table ─── */
  .info-table td {
    padding: 5px 8px !important;
  }
  .info-table td:first-child {
    width: auto !important;
    min-width: 80px !important;
  }
}

/* ─── Door form inline flex-row fix for mobile (768px) ─── */
@media (max-width: 768px) {
  form .flex-form-row {
    flex-direction: column !important;
    gap: 12px !important;
  }
  form .flex-form-row .form-group {
    flex: none !important;
    width: 100% !important;
  }
}

/* ─── Edit/New Form Mobile ─── */
@media (max-width: 768px) {
  .form-grid {
    grid-template-columns: 1fr !important;
  }
  .form-grid .form-group[style*="grid-column"] {
    grid-column: 1 !important;
  }
  .form-section {
    padding: 16px !important;
  }
  .form-section-title {
    margin: -16px -16px 12px -16px !important;
    padding: 10px 16px !important;
    font-size: 1.3rem !important;
  }
  /* section 2 — image upload */
  .form-section > div[style*="display:flex"] {
    flex-direction: column !important;
    align-items: stretch !important;
  }
  .form-section > div[style*="display:flex"] > div:first-child {
    width: 100% !important;
    max-width: 100%;
  }
  /* button row at bottom */
  .form-section + div[style*="display:flex"] {
    flex-direction: column !important;
    gap: 8px !important;
  }
  .form-section + div[style*="display:flex"] > div {
    width: 100%;
    display: flex;
    gap: 8px;
  }
  .form-section + div[style*="display:flex"] > div:first-child {
    order: 2;
  }
  .form-section + div[style*="display:flex"] > div:last-child {
    order: 1;
  }
  .form-section + div[style*="display:flex"] .btn {
    flex: 1;
    justify-content: center;
    text-align: center;
  }
}

/* ─── Status Select ─── */
.status-select {
  font-family: 'Inter', -apple-system, sans-serif;
  font-size: 0.7rem;
  font-weight: 600;
  padding: 3px 22px 3px 8px;
  border: 1px solid var(--ink);
  background: var(--paper);
  color: var(--ink);
  cursor: pointer;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='8' height='6'%3E%3Cpath d='M0 0l4 6 4-6' fill='%238a8072'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 6px center;
}
.status-select:hover {
  background-color: var(--accent-bg);
}
