/* ================================================================
   1. ROOT VARIABLES
=============================================================== */
:root {
  --primary: #1a237e;
  --primary-light: #283593;
  --secondary: #3498db;
  --success: #27ae60;
  --danger: #e74c3c;
  --warning: #f39c12;
  --dark: #2c3e50;
  --light: #ecf0f1;
  --gray: #95a5a6;
  --radius: 12px;
  --transition: all 0.3s ease;
  --logo-scale: 1;

  --bg-body: #f0f2f5;
  --bg-card: #ffffff;
  --bg-header: #ffffff;
  --bg-input: #ffffff;
  --bg-hover: #f0f0f0;
  --bg-dropdown: #ffffff;
  --bg-modal: #ffffff;
  --bg-total: #f8f9fa;
  --text-primary: #1a1a2e;
  --text-secondary: #555;
  --text-muted: #888;
  --border-color: #e0e0e0;
  --shadow: 0 2px 12px rgba(0,0,0,0.08);
  --btn-primary: #3498db;
  --btn-primary-hover: #2980b9;
  --btn-success: #27ae60;
  --btn-success-hover: #219653;
  --btn-danger: #e74c3c;
  --btn-danger-hover: #c0392b;
  --btn-warning: #f39c12;
  --btn-warning-hover: #d68910;
  --btn-info: #00acc1;
  --btn-info-hover: #00838f;
  --btn-purple: #9b59b6;
  --global-btn-h: 40px;   /* высота всех кнопок в панели */
  --global-btn-w: 40px;   /* ширина квадратных кнопок */
}

/* ================================================================
   2. THEMES
=============================================================== */
[data-theme="light"] {
  --bg-body: #f0f2f5;
  --bg-card: #ffffff;
  --bg-header: #ffffff;
  --bg-input: #ffffff;
  --bg-hover: #f0f0f0;
  --bg-dropdown: #ffffff;
  --bg-modal: #ffffff;
  --bg-total: #f8f9fa;
  --text-primary: #1a1a2e;
  --text-secondary: #555;
  --text-muted: #888;
  --border-color: #e0e0e0;
  --shadow: 0 2px 12px rgba(0,0,0,0.08);
}

[data-theme="dark"] {
  --bg-body: #0d1117;
  --bg-card: #161b22;
  --bg-header: #161b22;
  --bg-input: #0d1117;
  --bg-hover: #1c2333;
  --bg-dropdown: #161b22;
  --bg-modal: #161b22;
  --bg-total: #1c2333;
  --text-primary: #e6edf3;
  --text-secondary: #8b949e;
  --text-muted: #6e7681;
  --border-color: #30363d;
  --shadow: 0 2px 12px rgba(0,0,0,0.4);
}

/* ================================================================
   3. COLORS
=============================================================== */
[data-color="blue"] { --btn-primary: #3498db; --btn-primary-hover: #2980b9; }
[data-color="green"] { --btn-primary: #27ae60; --btn-primary-hover: #219653; }
[data-color="red"] { --btn-primary: #e74c3c; --btn-primary-hover: #c0392b; }
[data-color="purple"] { --btn-primary: #9b59b6; --btn-primary-hover: #7d3c98; }
[data-color="orange"] { --btn-primary: #f39c12; --btn-primary-hover: #d68910; }
[data-color="teal"] { --btn-primary: #00acc1; --btn-primary-hover: #00838f; }

/* ================================================================
   4. GLOBAL
=============================================================== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg-body);
  padding-top: 30px;
  color: var(--text-primary);
  transition: var(--transition);
  min-height: 150vh;
}

/* ================================================================
   5. CONTAINER
=============================================================== */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 15px;
  padding-top: 40px; 
  transition: transform 0.2s ease, width 0.2s ease;
  overflow: visible;
  width: 100%;
  box-sizing: border-box;
  min-height: 150vh;
}


/* ================================================================
   6. HEADER
=============================================================== */
.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 20px;
  background: var(--bg-header);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 10px;
  gap: 10px;
  border: 1px solid var(--border-color);
  min-height: 60px;
  flex-wrap: nowrap;
  width: 100%; /* ← ДОБАВИТЬ */
  box-sizing: border-box; /* ← ДОБАВИТЬ */
  overflow: visible; /* ← ДОБАВИТЬ */
}

.logo {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
  padding: 0;
  margin: 0;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  
  /* ===== ДОБАВЬТЕ ЭТИ СТРОКИ ===== */
  transform: scale(var(--logo-scale, 1));
  transform-origin: left center;
  transition: transform 0.2s ease;
}

.logo .bolt {
  color: #f1c40f;
  flex-shrink: 0;
}

.logo .version {
  font-size: 14px;
  color: var(--text-secondary);
  margin-left: 2px;
  flex-shrink: 0;
}

.logo .logo-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
  flex-shrink: 1;
  font-size: 16px;  /* ← ДОБАВЬТЕ ЭТУ СТРОКУ И УМЕНЬШИТЕ ЗНАЧЕНИЕ */
}
.logo span {
  color: var(--btn-primary);
}
/* ================================================================
   7. USER BLOCK
=============================================================== */
.user-block {
  display: flex;
  align-items: center;
  gap: 12px;
}

.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--btn-primary);
  color: white;
  font-weight: 700;
  font-size: 16px;
}

.user-name {
  font-weight: 600;
  font-size: 0.95rem;
}

.user-role {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

/* ================================================================
   8. BUTTONS
=============================================================== */
.btn {
  padding: 10px 20px;
  border: none;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.95rem;
  text-decoration: none;
}

.btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 15px rgba(0,0,0,0.2);
}

.btn-primary { background: var(--btn-primary); color: white; }
.btn-primary:hover { background: var(--btn-primary-hover); }

.btn-success { background: var(--btn-success); color: white; }
.btn-success:hover { background: var(--btn-success-hover); }

.btn-danger { background: var(--btn-danger); color: white; }
.btn-danger:hover { background: var(--btn-danger-hover); }

.btn-warning { background: var(--btn-warning); color: white; }
.btn-warning:hover { background: var(--btn-warning-hover); }

.btn-info { background: var(--btn-info); color: white; }
.btn-info:hover { background: var(--btn-info-hover); }

.btn-outline {
  background: transparent;
  border: 2px solid var(--border-color);
  color: var(--text-primary);
}
.btn-outline:hover {
  background: var(--bg-hover);
}

.btn-sm {
  padding: 6px 12px;
  font-size: 0.85rem;
}

.btn-block {
  width: 100%;
  justify-content: center;
}
/* Скрываем баннер cookie по умолчанию, чтобы он не мигал при загрузке */
#cookie-banner {
    display: none;
}
/* ================================================================
   9. TABS
=============================================================== */
.tabs {
  display: flex;
  gap: 5px;
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 5px;
  margin-bottom: 10px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border-color);
  overflow-x: auto;
}

.tab-btn {
  padding: 10px 20px;
  border: none;
  background: transparent;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
  transition: var(--transition);
  color: var(--text-secondary);
  white-space: nowrap;
  font-size: 14px;
}

.tab-btn:hover {
  background: var(--bg-hover);
}

.tab-btn.active {
  background: var(--btn-primary);
  color: white;
  box-shadow: 0 2px 10px rgba(0,0,0,0.2);
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

/* ================================================================
   10. CARDS
=============================================================== */
.card {
  background: var(--bg-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 10px;
  border: 1px solid var(--border-color);
}

/* ================================================================
   11. TABLE
=============================================================== */
.table-wrapper {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin: 0 -5px;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.estimate-table {
    min-width: 700px;   /* Только для таблицы сметы */
}

thead {
  background: var(--primary);
  color: white;
}

th {
  padding: 12px 10px;
  text-align: left;
  font-weight: 600;
}

td {
  padding: 10px;
  border-bottom: 1px solid var(--border-color);
}

tr:hover td {
  background: rgba(52, 152, 219, 0.05);
}

/* ================================================================
   12. INPUTS
=============================================================== */
.form-control {
  width: 100%;
  padding: 10px 14px;
  border: 2px solid var(--border-color);
  border-radius: 8px;
  font-size: 1rem;
  transition: var(--transition);
  background: var(--bg-input);
  color: var(--text-primary);
}

.form-control:focus {
  border-color: var(--btn-primary);
  outline: none;
  box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.2);
}

/* ================================================================
   13. MODAL
=============================================================== */
.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,0.6);
  z-index: 10000;
  justify-content: center;
  align-items: center;
  padding: 20px;
  backdrop-filter: blur(5px);
}

.modal.open {
  display: flex;
}

.modal-content {
  background: var(--bg-modal);
  border-radius: var(--radius);
  padding: 25px;
  max-width: 550px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
  border: 1px solid var(--border-color);
  animation: modalIn 0.3s ease;
}

@keyframes modalIn {
  from {
    opacity: 0;
    transform: scale(0.9) translateY(20px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  padding-bottom: 10px;
  border-bottom: 2px solid var(--border-color);
}
.modal-header h2,
.modal-header h3 {
  font-size: 1.3rem;
  color: var(--text-primary);
}

.modal-close {
  background: none;
  border: none;
  font-size: 1.8rem;
  cursor: pointer;
  color: var(--text-secondary);
  transition: var(--transition);

  /* ⭐ Для тач-устройств: большой размер и отзывчивость */
  min-width: 44px;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 8px;
  position: relative;
  z-index: 10;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.modal-close:hover {
  color: var(--btn-danger);
  transform: rotate(90deg);
}

.modal .form-group {
  margin-bottom: 12px;
}

.modal .form-group label {
  display: block;
  font-weight: 600;
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 3px;
}

.modal .form-group input,
.modal .form-group select,
.modal .form-group textarea {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  background: var(--bg-input);
  color: var(--text-primary);
  font-size: 14px;
}

.modal .form-group textarea {
  min-height: 80px;
  resize: vertical;
}

/* ================================================================
   14. NOTIFICATIONS
=============================================================== */
.notification {
  position: fixed;
  top: 20px;
  right: 20px;
  padding: 15px 25px;
  border-radius: var(--radius);
  color: white;
  font-weight: 500;
  z-index: 99999;
  box-shadow: 0 4px 20px rgba(0,0,0,0.2);
  animation: slideIn 0.3s ease;
  max-width: 400px;
  pointer-events: none;
}

.notification-success { background: var(--btn-success); }
.notification-error { background: var(--btn-danger); }
.notification-warning { background: var(--btn-warning); }
.notification-info { background: var(--btn-info); }

@keyframes slideIn {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

/* ================================================================
   15. GLOBAL MODIFIERS PANEL
=============================================================== */
.global-modifiers-panel {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding: 12px 16px;
  background: var(--bg-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 15px;
  align-items: center;
  border: 1px solid var(--border-color);
}

.global-modifier-item {
  display: flex;
  align-items: center;
  gap: 6px;
}

.global-modifier-item label {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-secondary);
}

.global-modifier-item input {
  width: 80px;
  padding: 6px 8px;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  background: var(--bg-input);
  color: var(--text-primary);
  font-size: 0.85rem;
}

.global-modifier-item input[type="text"] {
  width: 150px;
}

/* ================================================================
   16. ESTIMATE TABLE
=============================================================== */
.estimate-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  min-width: 800px;
}

.estimate-table th {
  background: var(--btn-primary);
  color: white;
  padding: 8px 6px;
  text-align: left;
  font-weight: 600;
  white-space: nowrap;
}

.estimate-table td {
  padding: 4px 6px;
  border-bottom: 1px solid var(--border-color);
  vertical-align: middle;
}

.estimate-table input {
  padding: 4px 6px;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  background: var(--bg-input);
  color: var(--text-primary);
  font-size: 13px;
  width: 100%;
}

.estimate-table .price-input {
  width: 80px;
  text-align: right;
}

.estimate-table .quantity-input {
  width: 60px;
  text-align: center;
}

.estimate-table .total-cell {
  font-weight: 700;
  color: var(--btn-success);
  text-align: right;
  cursor: pointer;
}

.estimate-table .delete-btn {
  background: none;
  border: none;
  color: var(--btn-danger);
  cursor: pointer;
  font-size: 16px;
}

.estimate-table .search-cell {
  position: relative;
}

.estimate-table .dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--bg-dropdown);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  max-height: 200px;
  overflow-y: auto;
  z-index: 100;
  display: none;
  box-shadow: var(--shadow);
}

.estimate-table .dropdown-item {
  padding: 6px 10px;
  cursor: pointer;
  border-bottom: 1px solid var(--border-color);
  font-size: 12px;
}

.estimate-table .dropdown-item:hover {
  background: var(--bg-hover);
}

.row-modifiers {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
  margin-top: 2px;
}

.modifier-badge {
  padding: 1px 8px;
  border-radius: 10px;
  font-size: 10px;
  font-weight: 600;
}

.modifier-badge.coeff {
  background: var(--btn-primary);
  color: white;
}

.modifier-badge.discount {
  background: var(--btn-danger);
  color: white;
}

.modifier-badge.comment {
  background: var(--btn-warning);
  color: white;
}

/* ================================================================
   17. TOTALS
=============================================================== */
.totals {
  padding: 15px;
  background: var(--bg-total);
  border-radius: 8px;
  border: 1px solid var(--border-color);
  margin-top: 15px;
}

.total-row {
  display: flex;
  justify-content: space-between;
  padding: 4px 0;
  font-size: 14px;
}

.total-row:last-child {
  font-size: 18px;
  font-weight: 700;
  padding-top: 10px;
  border-top: 2px solid var(--border-color);
  margin-top: 5px;
}

.total-value {
  font-weight: 600;
  color: var(--btn-success);
}

/* ================================================================
   18. PRICE LIST
=============================================================== */
.price-section {
  border: 1px solid var(--border-color);
  border-radius: 8px;
  margin-bottom: 10px;
  overflow: hidden;
}

.price-section .section-header {
  background: var(--btn-primary);
  color: white;
  padding: 10px 16px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  user-select: none;
}

.price-section .section-header .count {
  background: rgba(255,255,255,0.2);
  padding: 1px 10px;
  border-radius: 12px;
  font-size: 12px;
}

.price-section .section-body {
  display: none;
  padding: 8px 0;
}

.price-section .section-body.open {
  display: block;
}

        .price-item {
            display: grid;
            grid-template-columns: 50px 1fr 60px 80px;
            gap: 8px;
            padding: 8px 10px;
            border-bottom: 1px solid #eee;
            align-items: center;
            transition: background 0.2s;
            cursor: pointer;
            font-size: 0.85rem;
        }

.price-item:hover {
  background: var(--bg-hover);
}

.price-item .item-id {
  font-weight: 700;
  color: var(--btn-primary);
  font-size: 13px;
}

.price-item .item-name {
  font-size: 13px;
}

.price-item .item-unit {
  text-align: center;
  color: var(--text-secondary);
  font-size: 12px;
}

.price-item .item-price {
  text-align: right;
  font-weight: 600;
  color: var(--btn-success);
  font-size: 13px;
}

/* ================================================================
   19. STATUS
=============================================================== */
.status {
  padding: 10px 14px;
  border-radius: 8px;
  margin: 10px 0;
  font-size: 14px;
}

.status.success {
  background: #d4edda;
  color: #155724;
}

.status.error {
  background: #f8d7da;
  color: #721c24;
}

.status.info {
  background: #d1ecf1;
  color: #0c5460;
}

/* ================================================================
   20. MENU
=============================================================== */

.menu-container {
  position: relative;
  display: inline-block;
  flex-shrink: 0;
  margin-left: auto;
  overflow: visible; /* ← ДОБАВИТЬ */
}

.menu-dots {
  background: none;
  border: none;
  font-size: 28px;
  cursor: pointer;
  color: var(--text-secondary);
  padding: 8px 12px;
  line-height: 1;
  transition: var(--transition);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  min-height: 44px;
}

.menu-dots:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.menu-dropdown {
  display: none;
  position: absolute;
  right: 0;
  top: 40px;
  background: var(--bg-dropdown);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  box-shadow: 0 8px 30px rgba(0,0,0,0.2);
  min-width: 220px;
  padding: 8px 0;
  z-index: 1000;
}

.menu-dropdown.open {
  display: block;
}

.menu-dropdown .menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  color: var(--text-primary);
  background: none;
  border: none;
  width: 100%;
  text-align: left;
  cursor: pointer;
  font-size: 14px;
  transition: var(--transition);
  font-family: inherit;
}

.menu-dropdown .menu-item:hover {
  background: var(--bg-hover);
}

.menu-dropdown .menu-divider {
  height: 1px;
  background: var(--border-color);
  margin: 4px 12px;
}

.menu-dropdown .menu-item i {
  width: 20px;
  text-align: center;
  color: var(--btn-primary);
}

/* ================================================================
   21. THEME & COLOR SELECTORS
=============================================================== */
.theme-selector,
.color-selector {
  padding: 6px 16px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.theme-selector .label,
.color-selector .label {
  font-size: 12px;
  color: var(--text-secondary);
  font-weight: 600;
  width: 100%;
  margin-bottom: 2px;
}

.theme-dot,
.color-dot {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  cursor: pointer;
  border: 2px solid var(--border-color);
  transition: var(--transition);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.theme-dot:hover,
.color-dot:hover {
  transform: scale(1.1);
}

.theme-dot.active,
.color-dot.active {
  border-color: var(--btn-primary);
  box-shadow: 0 0 0 2px var(--btn-primary);
}

.theme-dot .check,
.color-dot .check {
  font-size: 14px;
  color: white;
  display: none;
}

.theme-dot.active .check,
.color-dot.active .check {
  display: block;
}

/* ================================================================
   22. PRINT / PDF
=============================================================== */
.print-section {
  padding: 10px 14px;
  border-radius: 6px;
  margin-bottom: 10px;
  border-left: 3px solid var(--btn-primary);
  background: var(--bg-card);
}

.print-section h4 {
  font-size: 14px;
  margin: 0 0 6px 0;
  color: var(--text-primary);
}

.print-section input,
.print-section textarea {
  width: 100%;
  padding: 6px 10px;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  background: var(--bg-input);
  color: var(--text-primary);
  font-size: 13px;
}

.print-section textarea {
  min-height: 50px;
  resize: vertical;
}

.print-section .logo-area {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 4px;
}

.print-section .logo-area img {
  max-height: 60px;
  max-width: 120px;
  object-fit: contain;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  padding: 4px;
  background: white;
}

.print-section .logo-area input[type="file"] {
  padding: 4px;
  font-size: 12px;
  width: auto;
}

.print-preview-container {
  background: var(--bg-body);
  border-radius: 8px;
  padding: 15px;
  margin-bottom: 15px;
  max-height: 500px;
  overflow-y: auto;
  border: 1px solid var(--border-color);
}

.print-preview-content {
  background: white;
  padding: 20px;
  border-radius: 4px;
  color: #333;
  font-family: Arial, sans-serif;
  font-size: 12px;
  max-width: 210mm;
  margin: 0 auto;
}

.print-preview-content .header-preview {
  text-align: center;
  padding: 10px 0;
  border-bottom: 2px solid #1a237e;
  margin-bottom: 15px;
}

.print-preview-content .header-preview h1 {
  color: #1a237e;
  margin: 0;
  font-size: 22px;
}

.print-preview-content .header-preview .date {
  color: #666;
  font-size: 14px;
}

.print-preview-content table {
  width: 100%;
  border-collapse: collapse;
  font-size: 11px;
  margin: 10px 0;
}

.print-preview-content table th {
  background: #1a237e;
  color: white;
  padding: 6px;
  text-align: left;
}

.print-preview-content table td {
  padding: 4px 6px;
  border-bottom: 1px solid #ddd;
}

/* ================================================================
   23. SCROLLBAR
=============================================================== */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: var(--bg-body);
}

::-webkit-scrollbar-thumb {
  background: var(--btn-primary);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--primary);
}

/* ================================================================
   24. BADGES
=============================================================== */
.badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
}

.badge-success {
  background: rgba(39, 174, 96, 0.2);
  color: var(--btn-success);
}

.badge-danger {
  background: rgba(231, 76, 60, 0.2);
  color: var(--btn-danger);
}

.badge-warning {
  background: rgba(243, 156, 18, 0.2);
  color: var(--btn-warning);
}

/* ================================================================
   25. LOADING
=============================================================== */
.loading {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 3px solid var(--border-color);
  border-top-color: var(--btn-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ================================================================
   26. THEME TOGGLE
=============================================================== */
.theme-toggle {
  background: none;
  border: none;
  font-size: 1.3rem;
  cursor: pointer;
  color: var(--text-secondary);
  transition: var(--transition);
}

.theme-toggle:hover {
  transform: rotate(30deg);
}

/* ================================================================
   27. ZOOM CONTROLS
=============================================================== */
.zoom-controls {
  display: flex;
  gap: 4px;
  align-items: center;
}

.zoom-controls .zoom-btn,
.zoom-controls .zoom-reset {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  padding: 4px 8px;
  cursor: pointer;
  color: var(--text-primary);
  transition: var(--transition);
  font-size: 14px;
}

.zoom-controls .zoom-btn:hover,
.zoom-controls .zoom-reset:hover {
  background: var(--bg-hover);
}

/* ================================================================
   28. SETTINGS MODAL (SLIDERS)
=============================================================== */
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  height: 6px;
  border-radius: 3px;
  background: var(--border-color);
  outline: none;
  transition: background 0.2s ease;
  width: 100%;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
  transition: all 0.2s ease;
}

input[type="range"]::-webkit-slider-thumb:hover {
  transform: scale(1.1);
}

input[type="range"]::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  cursor: pointer;
  border: none;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

/* Цвета для слайдеров */
#logoSizeSlider::-webkit-slider-thumb { background: var(--btn-primary); }
#tableSizeSlider::-webkit-slider-thumb { background: var(--btn-success); }
#priceSizeSlider::-webkit-slider-thumb { background: var(--btn-warning); }
#buttonSizeSlider::-webkit-slider-thumb { background: var(--btn-danger); }
#modalSizeSlider::-webkit-slider-thumb { background: var(--btn-info); }
#scaleSlider::-webkit-slider-thumb { background: var(--btn-purple); }

#logoSizeSlider::-moz-range-thumb { background: var(--btn-primary); }
#tableSizeSlider::-moz-range-thumb { background: var(--btn-success); }
#priceSizeSlider::-moz-range-thumb { background: var(--btn-warning); }
#buttonSizeSlider::-moz-range-thumb { background: var(--btn-danger); }
#modalSizeSlider::-moz-range-thumb { background: var(--btn-info); }
#scaleSlider::-moz-range-thumb { background: var(--btn-purple); }

/* ================================================================
   29. SHARE LINK BOX
=============================================================== */
.share-link-box {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

.share-link-box input {
  flex: 1;
  padding: 8px 12px;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  background: var(--bg-input);
  color: var(--text-primary);
  font-size: 13px;
}

.share-link-box input:focus {
  outline: none;
  border-color: var(--btn-primary);
}

/* ================================================================
   30. SETTINGS TABS
=============================================================== */
.settings-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 15px;
  border-bottom: 2px solid var(--border-color);
  padding-bottom: 10px;
}

.settings-tab {
  padding: 6px 14px;
  border: none;
  background: var(--bg-card);
  border-radius: 4px;
  cursor: pointer;
  font-weight: 600;
  font-size: 13px;
  transition: var(--transition);
  color: var(--text-secondary);
}

.settings-tab.active {
  background: var(--btn-primary);
  color: white;
}

.settings-content {
  display: none;
}

.settings-content.active {
  display: block;
}

/* ================================================================
   31. HIDDEN UTILITY
=============================================================== */
.hidden {
  display: none !important;
}


/* ================================================================
   33. PRINT STYLES
=============================================================== */
@media print {
  body {
    background: white !important;
    color: black !important;
  }

  .container {
    max-width: 100% !important;
    padding: 0 !important;
  }

  .header {
    box-shadow: none !important;
    border: 1px solid #ddd !important;
    background: white !important;
  }

  .menu-container,
  .menu-dots,
  .menu-dropdown,
  .tabs,
  .btn,
  .global-panel,
  #zoomIn,
  #zoomOut,
  #zoomReset,
  .zoomPercent,
  .controls {
    display: none !important;
  }

  .card {
    box-shadow: none !important;
    border: 1px solid #ddd !important;
    background: white !important;
    padding: 10px !important;
  }

  .estimate-table {
    font-size: 10px !important;
    min-width: auto !important;
  }

  .estimate-table th {
    background: #1a237e !important;
    color: white !important;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  .estimate-table td {
    border-bottom: 1px solid #ddd !important;
  }

  .estimate-table input {
    border: none !important;
    background: transparent !important;
    color: black !important;
  }

  .totals {
    background: #f8f9fa !important;
    border: 1px solid #ddd !important;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  .modal {
    display: none !important;
  }

  .modal.open {
    display: none !important;
  }

  .print-preview-container {
    max-height: none !important;
    overflow: visible !important;
  }

  .print-preview-content {
    background: white !important;
    color: black !important;
  }

  /* Разрывы страниц */
  .page-break {
    page-break-before: always;
  }

  .page-break-after {
    page-break-after: always;
  }

  /* Запрещаем разрыв внутри таблицы */
  table {
    page-break-inside: avoid;
  }

  /* Шапка таблицы на каждой странице */
  thead {
    display: table-header-group;
  }

  /* Запрещаем разрыв внутри строки */
  tr {
    page-break-inside: avoid;
  }
}
@media print {
  /* Отступ снизу первой страницы */
  .print-container > div:first-child {
    padding-bottom: 50px !important;
    margin-bottom: 30px !important;
    border-bottom: 2px dashed #ccc !important;
  }

  /* Отступ сверху второй страницы */
  .print-container > div:last-child {
    padding-top: 30px !important;
    margin-top: 10px !important;
  }

  /* Стиль для сообщения о продолжении */
  .print-container > div:first-child div:last-child {
    margin-top: 30px !important;
    padding-top: 15px !important;
    border-top: 2px dashed #999 !important;
    font-size: 11px !important;
    color: #666 !important;
    text-align: center !important;
    letter-spacing: 2px !important;
    font-weight: 600 !important;
  }
}
/* ================================================================
   32. АДАПТАЦИЯ ДЛЯ МОБИЛЬНЫХ
=============================================================== */
@media (max-width: 768px) {
  .container {
    padding: 8px;
    padding-top: 78px;   /* ← компенсация высоты градиент + топ-бар */
  }
  .header {
    padding: 6px 10px;
    min-height: 48px;
    gap: 4px;
    flex-wrap: nowrap;
  }

  .logo {
    font-size: 13px;
    gap: 3px;
    flex: 1;
    min-width: 0;
    max-width: 65%;
  }

  .logo .logo-text {
    font-size: 14px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 500px;
  }

  .logo .bolt {
    font-size: 12px;
  }

  .logo .version {
    font-size: 9px;
    margin-left: 2px;
  }

  .menu-dots {
    font-size: 20px;
    padding: 4px 8px;
    min-width: 36px;
    min-height: 36px;
  }

  /* ===== ВЫПАДАЮЩЕЕ МЕНЮ НА МОБИЛЬНЫХ ===== */
  .menu-dropdown {
    right: -5px;
    min-width: 200px;
    max-width: 90vw;
    max-height: 80vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .menu-dropdown .menu-item {
    padding: 10px 14px;
    font-size: 13px;
  }

  .menu-dropdown .menu-item i {
    width: 18px;
    font-size: 14px;
  }
              .price-item {
                grid-template-columns: 35px minmax(100px, 1fr) 45px 60px;
                gap: 6px;
                padding: 6px 8px;
                font-size: 0.8rem;
            }
            
            .item-number {
                font-size: 0.8rem;
            }
            
            .item-name {
                font-size: 0.8rem;
            }
            
            .item-unit {
                font-size: 0.75rem;
            }
            
            .item-price {
                font-size: 0.8rem;
            }
}
        @media (max-width: 480px) {
            .price-item {
                grid-template-columns: 35px 1fr 35px 60px;
                gap: 4px;
                padding: 5px 6px;
                font-size: 0.75rem;
            }
            
            .tab {
                padding: 8px 10px;
                font-size: 0.85rem;
            }
            
            .btn {
                padding: 6px 10px;
                font-size: 0.8rem;
            }
        }
@media (max-width: 480px) {
  .container {
    padding: 2px;
    padding-top: 78px;   /* ← компенсация */
  }

  .header {
    padding: 4px 6px;
    min-height: 36px;
    gap: 2px;
    width: 100%;
    box-sizing: border-box;
  }

  .logo {
    font-size: 9px;
    gap: 2px;
    max-width: 50%;
    flex: 0 1 auto;
  }

  .logo .logo-text {
    font-size: 12px;
    max-width: 280px;
    text-align: left !important;
  }

  .logo .bolt {
    font-size: 12px;
  }

  .logo .version {
    font-size: 12px;
  }

  .menu-container {
    flex-shrink: 0;
    margin-left: auto;
    overflow: visible;
  }

  .menu-dots {
    font-size: 14px;
    padding: 2px 4px;
    min-width: 28px;
    min-height: 28px;
  }

  .menu-dropdown {
    right: -5px;
    min-width: 150px;
  }

  .menu-dropdown .menu-item {
    padding: 6px 8px;
    font-size: 11px;
  }

  .menu-dropdown .menu-item i {
    width: 14px;
    font-size: 11px;
  }
}
@media (max-width: 380px) {
  .header {
    padding: 2px 4px;
    min-height: 32px;
    gap: 0px;
  }

  .logo {
    font-size: 8px;
    max-width: 40%;
  }

  .logo .logo-text {
    font-size: 8px;
    max-width: 220px;
  }

  .logo .bolt {
    font-size: 8px;
  }

  .logo .version {
    font-size: 6px;
  }

  .menu-dots {
    font-size: 12px;
    padding: 1px 3px;
    min-width: 24px;
    min-height: 24px;
  }

  .menu-dropdown {
    right: -2px;
    min-width: 130px;
  }

  .menu-dropdown .menu-item {
    padding: 4px 6px;
    font-size: 10px;
  }

  .menu-dropdown .menu-item i {
    width: 12px;
    font-size: 10px;
  }
}
/* ================================================================
   ДЛЯ БОЛЬШИХ ТЕЛЕФОНОВ (Samsung S26 Ultra и др.)
=============================================================== */
@media (min-width: 401px) and (max-width: 768px) {
  .logo {
    font-size: 14px !important;
    gap: 4px !important;
    max-width: 70% !important;
  }
  
  .logo .logo-text {
    font-size: 12px !important;
    max-width: 280px !important;
  }
  
  .logo .bolt {
    font-size: 12px !important;
  }
  
  .logo .version {
    font-size: 12px !important;
  }
}

/* ================================================================
   АДАПТАЦИЯ ЛОГОТИПА В ЗАВИСИМОСТИ ОТ ЭКРАНА (CSS переменные)
=============================================================== */

@media (min-width: 481px) and (max-width: 768px) {
  :root {
    --logo-scale: 0.75;
  }
}

@media (min-width: 769px) and (max-width: 1024px) {
  :root {
    --logo-scale: 0.85;
  }
}

@media (min-width: 1025px) {
  :root {
    --logo-scale: 1;
  }
}
/* ===== ФИКС ДЛЯ МЕНЮ НА ТЕЛЕФОНАХ ===== */
@media (max-width: 480px) {
  /* Фикс: делаем меню фиксированным, чтобы оно не обрезалось */
  .menu-dropdown {
    position: fixed !important;
    right: 10px !important;
    top: 50px !important;
    min-width: 180px !important;
    z-index: 99999 !important;
  }
  
  /* Убеждаемся, что контейнер не обрезает содержимое */
  .header {
    overflow: visible !important;
  }
  
  .menu-container {
    overflow: visible !important;
  }
}

/* ===== ФИКС ДЛЯ МЕНЮ НА ТЕЛЕФОНАХ ===== */
@media (max-width: 480px) {
  /* Фикс: делаем меню фиксированным, чтобы оно не обрезалось */
  .menu-dropdown {
    position: fixed !important;
    right: 10px !important;
    top: 50px !important;
    min-width: 180px !important;
    z-index: 99999 !important;
  }
  
  /* Убеждаемся, что контейнер не обрезает содержимое */
  .header {
    overflow: visible !important;
  }
  
  .menu-container {
    overflow: visible !important;
  }
}

/* Для всех мобильных */
@media (max-width: 768px) {
  .menu-dropdown {
    position: fixed !important;
    right: 10px !important;
    top: 55px !important;
    max-height: 80vh !important;
    overflow-y: auto !important;
  }
}
/* ================================================================
   ИСПРАВЛЕНИЕ ДЛЯ МЕНЮ НА МОБИЛЬНЫХ
=============================================================== */

/* Для всех экранов до 768px */
@media (max-width: 768px) {
  .header {
    padding: 1px 2px !important; /* Добавляем отступы справа и слева */
    gap: 1px !important;
  }
  
  .logo {
    flex: 1 1 auto !important;     /* Позволяем сжиматься */
    min-width: 0 !important;
    max-width: calc(100% - 60px) !important; /* Оставляем место для кнопки (≈60px) */
    font-size: 12px !important;
  }
  
  .logo .logo-text {
    max-width: 500px !important;   /* Ограничиваем ширину текста */
    font-size: 14px !important;
  }
  
  .menu-container {
    flex: 0 0 auto !important;    /* Кнопка не сжимается */
    margin-left: auto !important;
    overflow: visible !important;
  }
  
  .menu-dots {
    padding: 4px 8px !important;
    min-width: 36px !important;
    min-height: 36px !important;
    font-size: 22px !important;
  }
}

/* Для экранов уже 480px и меньше (самые маленькие) */
@media (max-width: 480px) {
  .header {
    padding: 1px 2px !important;
    gap: 2px !important;
  }
  
  .logo {
    max-width: calc(100% - 50px) !important;
    font-size: 9px !important;
  }
  
  .logo .logo-text {
    max-width: 280px !important;
    font-size: 12px !important;
  }
  
  .logo .bolt {
    font-size: 11px !important;
  }
  
  .menu-dots {
    padding: 2px 4px !important;
    min-width: 28px !important;
    min-height: 28px !important;
    font-size: 18px !important;
  }
  
  /* Меню-выпадашка – фиксированное положение, чтобы не зависеть от контейнера */
  .menu-dropdown {
    position: fixed !important;
    right: 8px !important;
    top: 40px !important;
    min-width: 160px !important;
    max-width: 90vw !important;
    z-index: 99999 !important;
  }
}

/* Дополнительно: убираем возможное обрезание */
.container,
.header,
.menu-container {
  overflow: visible !important;
}
/* ===== РАСТЯГИВАЕМ КАТЕГОРИИ ПРАЙС-ЛИСТА ===== */

/* Убираем внешние отступы у секций */
.price-section {
  margin-left: 0 !important;
  margin-right: 0 !important;
  border-radius: 0 !important;  /* убираем скругление, чтобы было от края до края */
}

/* Убираем отступы у заголовка секции */
.price-section .section-header {
  padding: 10px 12px !important;  /* уменьшаем отступы */
  margin: 0 !important;
}

/* Убираем отступы у тела секции */
.price-section .section-body {
  padding: 0 !important;
}

/* Растягиваем строки товаров на всю ширину */
.price-item {
  grid-template-columns: 40px 1fr 50px 80px !important;  /* меняем ширину колонок */
  gap: 6px !important;
  padding: 6px 10px !important;  /* уменьшаем отступы */
  margin: 0 !important;
  width: 100% !important;
}

/* Для мобильных - ещё меньше отступов */
@media (max-width: 768px) {
  .price-section .section-header {
    padding: 8px 8px !important;
    font-size: 13px !important;
  }
  
  .price-item {
    grid-template-columns: 30px 1fr 30px 60px !important;
    gap: 4px !important;
    padding: 5px 6px !important;
    font-size: 12px !important;
  }
  
  .price-item .item-id {
    font-size: 11px !important;
  }
  
  .price-item .item-name {
    font-size: 11px !important;
  /*   white-space: nowrap !important;  запрещаем перенос */
    overflow: hidden !important;
    text-overflow: ellipsis !important;  /* обрезаем с троеточием */
  }
  
  .price-item .item-unit {
    font-size: 11px !important;
  }
  
  .price-item .item-price {
    font-size: 11px !important;
  }
}

/* Для самых маленьких экранов */
@media (max-width: 480px) {
  .price-section .section-header {
    padding: 6px 4px !important;
    font-size: 11px !important;
  }
  
  .price-item {
    grid-template-columns: 20px 1fr 20px 50px !important;
    gap: 2px !important;
    font-size: 10px !important;
  }
  
  .price-item .item-id {
    font-size: 11px !important;
  }
  
  .price-item .item-name {
    font-size: 10px !important;
    max-width: 250px !important;
  }
  
  .price-item .item-unit {
    font-size: 10px !important;
  }
  
  .price-item .item-price {
    font-size: 10px !important;
  }
}
/* ===== УВЕЛИЧИВАЕМ ВЫСОТУ СТРОК В ПРАЙС-ЛИСТЕ ===== */

/* Основной размер */
.price-item {
  padding: 10px 12px !important;  /* увеличили отступы сверху/снизу */
  min-height: 52px !important;    /* минимальная высота строки */
}

/* Название - 2 строки */
.price-item .item-name {
  line-height: 1.4 !important;    /* увеличили межстрочный интервал */
  max-height: calc(1.4em * 2.2) !important;  /* место для 2 строк + запас */
}

/* Для планшетов */
@media (max-width: 768px) {
  .price-item {
    padding: 8px 10px !important;
    min-height: 46px !important;
  }
  .price-item .item-name {
    font-size: 12px !important;
    line-height: 1.4 !important;
    max-height: calc(1.4em * 2.2) !important;
  }
}

/* Для телефонов */
@media (max-width: 480px) {
  .price-item {
    padding: 8px 8px !important;
    min-height: 42px !important;
  }
  .price-item .item-name {
    font-size: 11px !important;
    line-height: 1.3 !important;
    max-height: calc(1.3em * 2.2) !important;
  }
}
/* ================================================================
   СМЕТА - УМЕНЬШЕННЫЕ ОТСТУПЫ И ШИРИНА
=============================================================== */

/* Основная таблица */
.estimate-table {
  font-size: 12px !important;
  min-width: auto !important;
}

/* Заголовки - УМЕНЬШИЛИ отступы */
.estimate-table th {
  padding: 6px 4px !important;   /* было 10px 8px → уменьшили */
  font-size: 12px !important;    /* было 14px → уменьшили */
  white-space: nowrap !important;
}

/* Ячейки - УМЕНЬШИЛИ отступы */
.estimate-table td {
  padding: 4px 3px !important;   /* было 8px 6px → уменьшили */
  vertical-align: middle !important;
}

/* Поля ввода - УМЕНЬШИЛИ */
.estimate-table input {
  padding: 3px 4px !important;   /* было 6px 8px → уменьшили */
  font-size: 12px !important;    /* было 14px → уменьшили */
  border-radius: 4px !important;
}

/* Цена - УМЕНЬШИЛИ ширину */
.estimate-table .price-input {
  width: 65px !important;        /* было 90px → уменьшили */
  text-align: right !important;
}

/* Количество - УМЕНЬШИЛИ ширину */
.estimate-table .quantity-input {
  width: 45px !important;        /* было 70px → уменьшили */
  text-align: center !important;
}

/* Итоговая сумма - УМЕНЬШИЛИ */
.estimate-table .total-cell {
  font-size: 13px !important;    /* было 15px → уменьшили */
  padding: 4px 6px !important;   /* было 8px 10px → уменьшили */
}

/* Кнопка удалить - УМЕНЬШИЛИ */
.estimate-table .delete-btn {
  font-size: 14px !important;    /* было 18px → уменьшили */
  padding: 2px 4px !important;
}

/* Высота строки - УМЕНЬШИЛИ */
.estimate-table tr {
  height: 32px !important;       /* было 48px → уменьшили */
}

/* ===== ДЛЯ КАЖДОЙ КОЛОНКИ ОТДЕЛЬНО ===== */

.estimate-table {
  table-layout: fixed !important;  /* ← ГЛАВНОЕ! Фиксирует ширину колонок */
  width: 100% !important;
  min-width: 500px !important;
}

/* Ширина каждой колонки */
.estimate-table th:nth-child(1),
.estimate-table td:nth-child(1) {
  width: 30px !important;
  min-width: 30px !important;
  max-width: 30px !important;
  text-align: center !important;
}

.estimate-table th:nth-child(2),
.estimate-table td:nth-child(2) {
  width: auto !important;  /* Наименование — занимает всё оставшееся место */
  min-width: 100px !important;
}

.estimate-table th:nth-child(3),
.estimate-table td:nth-child(3) {
  width: 60px !important;
  min-width: 60px !important;
  max-width: 60px !important;
  text-align: center !important;
}

.estimate-table th:nth-child(4),
.estimate-table td:nth-child(4) {
  width: 60px !important;
  min-width: 60px !important;
  max-width: 60px !important;
  text-align: right !important;
}

.estimate-table th:nth-child(5),
.estimate-table td:nth-child(5) {
  width: 60px !important;
  min-width: 60px !important;
  max-width: 60px !important;
  text-align: center !important;
}

.estimate-table th:nth-child(6),
.estimate-table td:nth-child(6) {
  width: 80px !important;
  min-width: 80px !important;
  max-width: 80px !important;
  text-align: right !important;
}

.estimate-table th:nth-child(7),
.estimate-table td:nth-child(7) {
  width: 30px !important;
  min-width: 30px !important;
  max-width: 30px !important;
  text-align: center !important;
}

/* Поля ввода — занимают всю ширину ячейки */
.estimate-table .price-input,
.estimate-table .quantity-input {
  width: 100% !important;
  box-sizing: border-box !important;
}

/* Убираем лишние отступы */
.estimate-table th,
.estimate-table td {
  padding: 4px 3px !important;
  overflow: hidden !important;      /* ← текст не вылезает */
  white-space: nowrap !important;   /* ← текст в одну строку */
  text-overflow: ellipsis !important; /* ← если не влазит, появляется ... */
}
@media (max-width: 768px) {
  .estimate-table td:nth-child(3),
  .estimate-table th:nth-child(3) {
    width: 40px !important;
    min-width: 40px !important;
    padding: 3px 1px !important;   /* ← убрали padding-right */
  }
  .estimate-table td:nth-child(4),
  .estimate-table th:nth-child(4) {
    width: 50px !important;
    min-width: 50px !important;
    padding: 3px 1px !important;   /* ← убрали padding-left */
  }
  .estimate-table td:nth-child(5),
  .estimate-table th:nth-child(5) {
    width: 40px !important;
    min-width: 40px !important;
    padding: 3px 1px !important;
}
}

@media (max-width: 480px) {
	.estimate-table {
  font-size: 9px !important;
  table-layout: fixed !important;  /* ← ГЛАВНОЕ! Фиксирует ширину колонок */
  width: 100% !important;
  min-width: 400px !important;
}
/* Ширина каждой колонки */
.estimate-table th:nth-child(1),
.estimate-table td:nth-child(1) {
  width: 30px !important;
  min-width: 30px !important;
  max-width: 30px !important;
  text-align: center !important;
}

.estimate-table th:nth-child(2),
.estimate-table td:nth-child(2) {
  width: auto !important;  /* Наименование — занимает всё оставшееся место */
  min-width: 100px !important;
}

.estimate-table th:nth-child(3),
.estimate-table td:nth-child(3) {
  width: 40px !important;
  min-width: 40px !important;
  max-width: 40px !important;
  text-align: center !important;
}

.estimate-table th:nth-child(4),
.estimate-table td:nth-child(4) {
  width: 40px !important;
  min-width: 40px !important;
  max-width: 40px !important;
  text-align: right !important;
}

.estimate-table th:nth-child(5),
.estimate-table td:nth-child(5) {
  width: 40px !important;
  min-width: 40px !important;
  max-width: 40px !important;
  text-align: center !important;
}

.estimate-table th:nth-child(6),
.estimate-table td:nth-child(6) {
  width: 60px !important;
  min-width: 60px !important;
  max-width: 60px !important;
  text-align: right !important;
}

.estimate-table th:nth-child(7),
.estimate-table td:nth-child(7) {
  width: 20px !important;
  min-width: 20px !important;
  max-width: 20px !important;
  text-align: center !important;
}
}

@media (max-width: 480px) {
  .estimate-table th {
    padding: 3px 1px !important;
    font-size: 8px !important;
  }
  .estimate-table td {
    padding: 2px 1px !important;
  }
  .estimate-table input {
    padding: 1px 2px !important;
    font-size: 8px !important;
  }
  .estimate-table .price-input {
    width: 35px !important;
  }
  .estimate-table .quantity-input {
    width: 30px !important;
  }
  .estimate-table .total-cell {
    font-size: 9px !important;
    padding: 2px 3px !important;
  }
  .estimate-table .delete-btn {
    font-size: 10px !important;
  }
  .estimate-table tr {
    height: 24px !important;
  }
  
  .table-wrapper {
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch !important;
}
}
/* ===== ФИКС ДЛЯ ВЫПАДАЮЩЕГО СПИСКА В СМЕТЕ ===== */
.search-cell {
  position: relative !important;
  overflow: visible !important;
  max-height: 60px !important;
  min-width: 40px !important;
}

.estimate-table .dropdown {
  position: absolute !important;
  top: 100% !important;
  left: 0 !important;
  right: 0 !important;
  z-index: 99999 !important;
  background: var(--bg-dropdown, #ffffff) !important;
  border: 1px solid var(--border-color, #ccc) !important;
  border-radius: 6px !important;
  box-shadow: 0 8px 30px rgba(0,0,0,0.2) !important;
  max-height: 250px !important;
  overflow-y: auto !important;
  min-width: 200px !important;
  padding: 4px 0 !important;
  margin: 0 !important;
  display: block !important;  /* ← ДОБАВЛЯЕМ, чтобы переопределить display: none */
}

.estimate-table .dropdown-item {
  padding: 8px 12px !important;
  cursor: pointer !important;
  border-bottom: 1px solid var(--border-color, #eee) !important;
  font-size: 13px !important;
  transition: background 0.15s !important;
  color: var(--text-primary, #333) !important;
}

.estimate-table .dropdown-item:hover {
  background: var(--bg-hover, #f0f0f0) !important;
}

.estimate-table .dropdown-item:last-child {
  border-bottom: none !important;
}

/* Для мобильных */
@media (max-width: 768px) {
  .estimate-table .dropdown {
    max-height: 180px !important;
    min-width: 150px !important;
  }
  .estimate-table .dropdown-item {
    font-size: 12px !important;
    padding: 6px 10px !important;
  }
}
/* ================================================================
   ГАРАНТИРОВАННЫЙ ФИКС ДЛЯ ВЫПАДАЮЩЕГО СПИСКА (ПОСЛЕДНИЙ)
=============================================================== */

.search-cell {
  position: relative !important;
  overflow: visible !important;
}

.estimate-table .dropdown {
  display: none !important;  /* по умолчанию скрыт */
  position: absolute !important;
  top: 100% !important;
  left: 0 !important;
  right: 0 !important;
  z-index: 999999 !important;
  background: #ffffff !important;
  border: 2px solid #3498db !important;
  border-radius: 6px !important;
  box-shadow: 0 8px 30px rgba(0,0,0,0.3) !important;
  max-height: 250px !important;
  overflow-y: auto !important;
  min-width: 200px !important;
  padding: 4px 0 !important;
  margin: 0 !important;
}

/* Когда дропдаун открыт — добавляем класс JS */
.estimate-table .dropdown.open {
  display: block !important;
}

.estimate-table .dropdown-item {
  padding: 8px 12px !important;
  cursor: pointer !important;
  border-bottom: 1px solid #eee !important;
  font-size: 13px !important;
  transition: background 0.15s !important;
  color: #333 !important;
  background: #ffffff !important;
}

.estimate-table .dropdown-item:hover {
  background: #f0f0f0 !important;
}

.estimate-table .dropdown-item:last-child {
  border-bottom: none !important;
}
/* ================================================================
   ОКОНЧАТЕЛЬНЫЙ ФИКС ДЛЯ ДРОПДАУНА В СМЕТЕ
=============================================================== */

/* Убираем обрезание у родителя */
.estimate-table .search-cell {
  position: relative !important;
  overflow: visible !important;  /* ← ГЛАВНОЕ! */
}

/* Дропдаун — всегда видим, когда открыт */
.estimate-table .dropdown {
  position: absolute !important;
  top: 100% !important;
  left: 0 !important;
  right: 0 !important;
  z-index: 999999 !important;
  background: #ffffff !important;
  border: 2px solid #3498db !important;
  border-radius: 6px !important;
  box-shadow: 0 8px 30px rgba(0,0,0,0.3) !important;
  max-height: 250px !important;
  overflow-y: auto !important;
  min-width: 200px !important;
  padding: 4px 0 !important;
  margin: 0 !important;
  display: none !important;  /* скрыт по умолчанию */
}

/* Когда открыт — показываем */
.estimate-table .dropdown.open {
  display: block !important;
}

.estimate-table .dropdown-item {
  padding: 8px 12px !important;
  cursor: pointer !important;
  border-bottom: 1px solid #eee !important;
  font-size: 13px !important;
  transition: background 0.15s !important;
  color: #333 !important;
  background: #ffffff !important;
}

.estimate-table .dropdown-item:hover {
  background: #f0f0f0 !important;
}

.estimate-table .dropdown-item:last-child {
  border-bottom: none !important;
}
/* ===== ФИКС ДЛЯ ДРОПДАУНА ===== */
.estimate-table .search-cell {
  position: relative !important;
  overflow: visible !important;
}

.estimate-table .dropdown {
  display: none !important;
}

.estimate-table .dropdown[style*="display: block"] {
  display: block !important;
}

.estimate-table .dropdown-item {
  padding: 8px 12px !important;
  cursor: pointer !important;
  border-bottom: 1px solid #eee !important;
  background: white !important;
}

.estimate-table .dropdown-item:hover {
  background: #f0f0f0 !important;
}
/* ===== РАСТЯГИВАНИЕ КАТЕГОРИЙ С ОТСТУПАМИ 5% ===== */
@media (max-width: 768px) {
  /* Отступы 5% с каждой стороны */
  .container {
    padding: 0 2% !important;   /* ← 5% отступы слева и справа */
	padding-top: 40px !important;   /* ← компенсация */
    max-width: 100% !important;
  }
  
  /* Убираем скругление и отступы у карточки */
  .card {
    padding: 10px 0 !important;
    border-radius: 0 !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
  }
  
  /* Убираем отступы у секций */
  .price-section {
    margin: 0 !important;
    border-radius: 0 !important;
    border-left: none !important;
    border-right: none !important;
  }
  
  /* Убираем отступы у заголовка */
  .price-section .section-header {
    padding: 10px 8px !important;
    margin: 0 !important;
  }
  
  /* Убираем отступы у строк товаров */
  .price-item {
    padding: 6px 8px !important;
    margin: 0 !important;
    width: 100% !important;
    gap: 6px !important;
  }
}

/* ================================================================
   ФИКС: МЕНЮ НЕ РАЗДВИГАЕТ КОНТЕЙНЕР
=============================================================== */


/* 3. ВЫПАДАЮЩЕЕ МЕНЮ — ПОЛНОСТЬЮ ВНЕ ПОТОКА */
.menu-dropdown {
    display: none !important;
    position: absolute !important;
    right: 0 !important;
    top: calc(100% + 2px) !important;  /* ← СРАЗУ ПОД КНОПКОЙ */
    background: var(--bg-dropdown, #ffffff) !important;
    border: 1px solid var(--border-color, #ddd) !important;
    border-radius: var(--radius, 12px) !important;
    box-shadow: 0 8px 30px rgba(0,0,0,0.3) !important;
    min-width: 200px !important;
    max-width: 90vw !important;
    padding: 8px 0 !important;
    z-index: 9999999 !important;
    /* ← НЕ ВЛИЯЕТ НА РОДИТЕЛЯ */
    pointer-events: auto !important;
}

/* 4. ОТКРЫТОЕ МЕНЮ */
.menu-dropdown.open,
.menu-dropdown.active {
    display: block !important;
}

/* 5. ХЕДЕР — ФИКСИРОВАННАЯ ВЫСОТА */
.header {
    display: flex !important;
    flex-wrap: nowrap !important;
    align-items: center !important;
    padding: 8px 16px !important;    /* ← ФИКСИРОВАННЫЙ ПАДДИНГ */
    min-height: 60px !important;     /* ← ФИКСИРОВАННАЯ ВЫСОТА */
    height: auto !important;         /* ← АВТО, НО НЕ МЕНЬШЕ min-height */
    overflow: visible !important;    /* ← НЕ ОБРЕЗАЕМ */
    position: relative !important;
    z-index: 99999 !important;
    box-sizing: border-box !important;
}

/* 6. КОНТЕЙНЕР — НЕ ОБРЕЗАЕТ */
.container {
    overflow: visible !important;
    position: relative !important;
    z-index: 1 !important;
}

/* ===== ДЛЯ МОБИЛЬНЫХ ===== */
@media (max-width: 768px) {
    .header {
        min-height: 48px !important;
        padding: 4px 10px !important;
    }
    
    .menu-dots,
    button.menu-dots {
        font-size: 22px !important;
        padding: 2px 8px !important;
        min-width: 36px !important;
        min-height: 36px !important;
        height: 36px !important;
    }
    
    .menu-dropdown {
        min-width: 160px !important;
        right: 0 !important;
        top: calc(100% + 2px) !important;
    }
}

@media (max-width: 480px) {
    .header {
        min-height: 36px !important;
        padding: 2px 6px !important;
    }
    
    .menu-dots,
    button.menu-dots {
        font-size: 18px !important;
        padding: 0px 4px !important;
        min-width: 28px !important;
        min-height: 28px !important;
        height: 28px !important;
    }
    
    .menu-dropdown {
        min-width: 140px !important;
        right: 0 !important;
        top: calc(100% + 2px) !important;
        max-width: 90vw !important;
    }
}

/* ===== НАДЁЖНЫЙ СПОСОБ: ИСПОЛЬЗОВАТЬ position: fixed ДЛЯ МЕНЮ ===== */
/* Раскомментируйте, если position: absolute всё ещё раздвигает */

/*
.menu-dropdown.open,
.menu-dropdown.active {
    position: fixed !important;
    top: 50px !important;
    right: 10px !important;
    z-index: 9999999 !important;
    min-width: 200px !important;
    max-width: 90vw !important;
}
*/
    .pwa-install-btn {
        position: fixed;
        bottom: 20px;
        right: 20px;
        z-index: 99999;
        display: flex;
        align-items: center;
        gap: 10px;
        animation: slideInUp 0.5s ease-out;
    }
    
    @keyframes slideInUp {
        from {
            transform: translateY(100px);
            opacity: 0;
        }
        to {
            transform: translateY(0);
            opacity: 1;
        }
    }
    
    .install-btn {
        background: linear-gradient(135deg, #00d2ff 0%, #004080 50%, #001f40 100%);
        color: white;
        border: none;
        padding: 12px 22px;
        border-radius: 22px;
        font-size: 14px;
        font-weight: bold;
        cursor: pointer;
        box-shadow: 0 4px 15px rgba(0, 64, 128, 0.35);
        display: flex;
        align-items: center;
        gap: 8px;
        transition: all 0.3s ease;
    }
    
    .install-btn:hover {
        transform: translateY(-2px);
        box-shadow: 0 6px 20px rgba(0,0,0,0.4);
    }
    
    .install-icon {
        font-size: 20px;
    }
    
    .close-install-btn {
        background: rgba(0, 64, 128, 0.6);
        color: white;
        border: none;
        width: 24px;
        height: 24px;
        border-radius: 50%;
        cursor: pointer;
        font-size: 14px;
        display: flex;
        align-items: center;
        justify-content: center;
        transition: all 0.3s ease;
    }
    
    .close-install-btn:hover {
        background: rgba(0, 64, 128, 0.9);
        transform: scale(1.1);
    }
	@media (max-width: 768px) {
  .container {
    min-height: 140vh !important;
  }
}

/* Для маленьких телефонов */
@media (max-width: 480px) {
  .container {
    min-height: 160vh !important;
  }
}
/* ============================================================
   КНОПКА АЗАН — оптимизировано для мобильных
   ============================================================ */
.azan-wrapper {
    width: 100%;
    text-align: center;
    margin-top: 16px;
    padding: 12px 10px 0;      /* добавлен боковой padding */
    border-top: 1px solid #334155;
    box-sizing: border-box;
}

.azan-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    flex-wrap: nowrap;          /* не переносить текст/иконки */
    white-space: nowrap;        /* не ломать текст по словам */
    background: linear-gradient(135deg, #10b981, #059669);
    color: #ffffff;
    padding: 10px 20px;
    border-radius: 30px;
    text-decoration: none;
    font-weight: 600;
    font-size: 14px;
    line-height: 1.2;
    transition: all 0.3s ease;
    box-shadow: 0 2px 12px rgba(16, 185, 129, 0.3);
    border: none;
    cursor: pointer;
    min-width: 150px;
    max-width: 100%;            /* ← не вылезать за экран */
    box-sizing: border-box;     /* ← padding не расширяет */
    -webkit-tap-highlight-color: transparent;  /* убрать серый квадрат на iOS */
    user-select: none;
}

.azan-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 20px rgba(16, 185, 129, 0.5);
    background: linear-gradient(135deg, #059669, #047857);
}

.azan-button:active {
    transform: translateY(0);
}

.azan-button .arrow {
    transition: transform 0.3s ease;
}

.azan-button:hover .arrow {
    transform: rotate(15deg);
}

.azan-subtitle {
    margin-top: 6px;
    font-size: 11px;
    color: #64748b;
    letter-spacing: 0.2px;
}

/* ============================================================
   МОБИЛЬНАЯ ОПТИМИЗАЦИЯ
   ============================================================ */

/* Планшеты и большие телефоны (≤600px) */
@media (max-width: 600px) {
    .azan-wrapper {
        margin-top: 12px;
        padding: 10px 8px 0;
    }
    
    .azan-button {
        padding: 9px 18px;
        font-size: 13px;
        min-width: 140px;
        gap: 6px;
    }
    
    .azan-subtitle {
        font-size: 10px;
    }
}

/* Маленькие телефоны (≤400px) */
@media (max-width: 400px) {
    .azan-wrapper {
        margin-top: 10px;
        padding: 8px 6px 0;
    }
    
    .azan-button {
        width: 100%;              /* ← растянуть на всю ширину */
        max-width: 280px;         /* но не больше 280px */
        padding: 10px 14px;
        font-size: 13px;
        min-width: 0;             /* ← сбросить min-width */
        border-radius: 24px;
        gap: 5px;
    }
    
    .azan-button span {
        font-size: 12px !important;  /* перебить инлайн-стили */
    }
    
    .azan-button .arrow {
        font-size: 12px !important;
    }
    
    .azan-subtitle {
        font-size: 9px;
        margin-top: 4px;
    }
}

/* Очень узкие (≤320px, iPhone SE 1st gen) */
@media (max-width: 320px) {
    .azan-button {
        padding: 9px 10px;
        font-size: 12px;
        max-width: 240px;
        gap: 4px;
    }
    
    .azan-button span {
        font-size: 11px !important;
    }
}

/* Градиентная полоса сверху */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 30px;
    background: linear-gradient(135deg, #00d2ff 0%, #004080 50%, #001f40 100%);
    z-index: 1000;
    pointer-events: none;
}
/* ================================================================
   ТОП-БАР СО ССЫЛКАМИ (под градиентом)
   ================================================================ */
.top-bar-links {
    position: fixed;
    top: 30px;
    left: 0;
    right: 0;
    width: 100%;
    height: auto;
    background: transparent;
    border: none;
    border-radius: 0;
    overflow-x: auto;
    overflow-y: hidden;
    touch-action: pan-x;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    display: flex;
    align-items: flex-start;
    padding: 0 20px;
    box-sizing: border-box;
    z-index: 2000;
}
/* ============================================================
   ТОП-БАР: скрытие при скролле вниз
   ============================================================ */
.top-bar-links {
    transition: transform 0.3s ease;
    will-change: transform;
}

.top-bar-links.hidden {
    transform: translateY(-100%);
}
.top-bar-links::-webkit-scrollbar {
    display: none;               /* Chrome/Safari — скрыть скроллбар */
}
.top-bar-links-track {
    display: flex;
    gap: 12px;
    align-items: center;
    padding: 0 12px;
    white-space: nowrap;
    touch-action: pan-x;
    min-width: 200%;   
}

.top-bar-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: 0 0 16px 16px;     /* ← все четыре угла */
    color: #fff;
    text-decoration: none;
    font-size: 14px;
    font-weight: 600;
    white-space: nowrap;
    transition: transform 0.15s, box-shadow 0.15s, background 0.15s;
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
    backdrop-filter: blur(4px);
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.top-bar-link:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.25);
}

.top-bar-link-icon {
    font-size: 16px;
    line-height: 1;
}

@media (max-width: 500px) {
    .top-bar-links { height: 42px; }
    .top-bar-link { font-size: 13px; padding: 6px 14px; }
    .top-bar-link-icon { font-size: 14px; }
}
.vtab-desc {
  position: absolute;
  bottom: 30px;
  left: 0; right: 0;
  padding: 6px 10px;
  background: linear-gradient(to top, rgba(0,0,0,.75), transparent);
  color: #fff;
  font-size: 11px;
  z-index: 3;
  pointer-events: none;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}
/* ============================================================
   ТАБЛИЦА ПОЛЬЗОВАТЕЛЕЙ (админка)
   ============================================================ */

.admin-users-td {
    padding: 4px 6px;
    text-align: center;
    font-size: 11px;
    border-bottom: 1px solid var(--border-color);
    vertical-align: middle;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 0; /* ← КРИТИЧНО */
}

.admin-users-th {
    padding: 4px 6px;
    text-align: center;
    font-size: 11px;
    font-weight: 500;
    border-bottom: 1px solid var(--border-color);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 0; /* ← КРИТИЧНО */
}

.admin-users-td button,
.admin-users-td a {
    display: inline-block;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    vertical-align: middle;
}

/* ===== Мобильная печать сметы ===== */
@media (max-width: 500px) {
    #printModal {
        padding: 4px !important;
    }
    #printModal .modal-content {
        max-width: 100% !important;
    }
    #printModal .modal-body {
        padding: 10px !important;
    }
}
/* ============================================================
   ДИАГНОСТИКА — стили модалки
   ============================================================ */

/* Контейнер вкладок — grid с автоколонками.
   Кнопки автоматически распределяются по ряду:
   - влезают 4 → 4 колонки
   - влезают 2 → 2 колонки
   - влезает 1 → 1 колонка (на всю ширину)
   Все кнопки в ряду — одинаковой ширины. */
#diagnosticsModal > .modal-content > div:nth-child(2) {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(72px, 1fr));
  gap: 6px;
  padding: 10px 12px;
  overflow: visible;
  height: auto;
  min-height: auto;
  max-height: none;
  flex-shrink: 0;
  background: var(--bg-body);
  border-bottom: 1px solid var(--border-color);
}

/* Вкладки диагностики — активная скроллится, остальные скрыты */
#diagnosticsModal .settings-content {
  display: none;
}
#diagnosticsModal .settings-content.active {
  display: block;
  overflow-y: auto;
  overflow-x: hidden;
  min-height: 0;
  flex: 1 1 auto;
  -webkit-overflow-scrolling: touch;
  padding: 12px;
}

/* Активная вкладка консоли — flex-колонка,
   чтобы вывод растягивался, а поле ввода было снизу */
#diagnosticsModal .settings-content.active#diagTab-console {
  display: flex;
  flex-direction: column;
  padding: 0;
  overflow: hidden;
}

/* Вкладки — кнопки-пилюли, растягиваются в grid-ячейке */
#diagnosticsModal .settings-tab {
  padding: 8px 10px;
  font-size: 13px;
  border-radius: 8px;
  border: 1px solid var(--border-color);
  background: var(--bg-card);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s;
  min-height: 34px;
  height: auto;
  line-height: 1.2;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin: 0;
  box-shadow: none;
  outline: none;
  white-space: nowrap;
  width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}
#diagnosticsModal .settings-tab:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}
#diagnosticsModal .settings-tab.active {
  background: var(--btn-primary);
  color: #fff;
  border-color: var(--btn-primary);
}

/* Консоль — вывод */
#diagConsoleOutput {
  scrollbar-width: thin;
  scrollbar-color: #555 #1e1e1e;
  line-height: 1.5;
  word-break: break-word;
  white-space: pre-wrap;
    flex: 1 1 auto;
  min-height: 0;
}
#diagConsoleOutput::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
#diagConsoleOutput::-webkit-scrollbar-track {
  background: #1e1e1e;
}
#diagConsoleOutput::-webkit-scrollbar-thumb {
  background: #555;
  border-radius: 4px;
}
#diagConsoleOutput::-webkit-scrollbar-thumb:hover {
  background: #777;
}

/* Строки вывода консоли */
.diag-line {
  margin-bottom: 6px;
  padding: 4px 0;
}
.diag-line-input {
  color: #569cd6;
  font-weight: 600;
}
.diag-line-input::before {
  content: '> ';
  color: #27ae60;
  font-weight: 700;
}
.diag-line-output {
  color: #d4d4d4;
  padding-left: 12px;
  border-left: 2px solid #333;
}
.diag-line-error {
  color: #f48771;
  padding-left: 12px;
  border-left: 2px solid #e74c3c;
}
.diag-line-meta {
  color: #6a9955;
  font-size: 11px;
  padding-left: 12px;
  font-style: italic;
}

/* ============================================================
   ДИАГНОСТИКА — секции состояния
   ============================================================ */
.diag-section {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 12px 16px;
  margin-bottom: 12px;
}
.diag-section h4 {
  margin: 0 0 8px 0;
  font-size: 14px;
  color: var(--text-primary);
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border-color);
}
.diag-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  padding: 4px 0;
  font-size: 13px;
  line-height: 1.4;
}
.diag-row > span {
  color: var(--text-secondary);
  flex-shrink: 0;
}
.diag-row > b {
  color: var(--text-primary);
  text-align: right;
  word-break: break-word;
}

/* ============================================================
   ДИАГНОСТИКА — планшет (768px)
   ============================================================ */
@media (max-width: 768px) {
  #diagnosticsModal .modal-content {
    max-width: 100%;
    max-height: 100vh;
    border-radius: 0;
  }
  #diagnosticsModal > .modal-content > div:nth-child(2) {
    padding: 8px 10px;
    gap: 4px;
    grid-template-columns: repeat(auto-fit, minmax(64px, 1fr));
  }
  #diagnosticsModal .settings-tab {
    padding: 6px 8px;
    font-size: 12px;
    min-height: 30px;
  }
  #diagnosticsModal .settings-content.active {
    padding: 10px;
  }
  #diagAdminBlock > div:last-child {
    grid-template-columns: 1fr 1fr;
  }
  /* Вкладка консоли — на всю высоту экрана */
  #diagnosticsModal .settings-content.active#diagTab-console {
    height: 90vh !important;
    max-height: 90vh !important;
  }
  /* САМ ТЕРМИНАЛ — забирает всё свободное место */
  #diagTab-console #diagConsoleOutput {
    flex: 1 1 auto !important;
    min-height: 0 !important;
    max-height: none !important;
  }
  /* Ввод и галочки — компактные, не растягиваются */
  #diagTab-console > div:not(#diagConsoleOutput):not(#diagConsoleWarning) {
    flex-shrink: 0 !important;
    padding: 4px 8px !important;
  }
}

/* ============================================================
   ДИАГНОСТИКА — телефон (480px)
   ============================================================ */
@media (max-width: 480px) {
  #diagnosticsModal > .modal-content > div:nth-child(2) {
    grid-template-columns: repeat(auto-fit, minmax(58px, 1fr));
  }
  #diagnosticsModal .settings-tab {
    padding: 6px 6px;
    font-size: 11px;
    min-height: 28px;
  }
  #diagConsoleOutput {
    font-size: 11px;
  }
  #diagConsoleInput {
    font-size: 12px;
  }
  /* Вкладка консоли — на всю высоту экрана */
  #diagnosticsModal .settings-content.active#diagTab-console {
    height: 90vh !important;
    max-height: 90vh !important;
  }
  /* САМ ТЕРМИНАЛ — забирает всё свободное место */
  #diagTab-console #diagConsoleOutput {
    flex: 1 1 auto !important;
    min-height: 0 !important;
    max-height: none !important;
  }
  /* Ввод и галочки — компактные, не растягиваются */
  #diagTab-console > div:not(#diagConsoleOutput):not(#diagConsoleWarning) {
    flex-shrink: 0 !important;
    padding: 4px 8px !important;
  }
}

/* ============================================================
   ДИАГНОСТИКА — очень узкий телефон (360px)
   ============================================================ */
@media (max-width: 360px) {
  #diagnosticsModal > .modal-content > div:nth-child(2) {
    grid-template-columns: repeat(auto-fit, minmax(52px, 1fr));
  }
  #diagnosticsModal .settings-tab {
    padding: 5px 4px;
    font-size: 10px;
    min-height: 26px;
  }
  #diagnosticsModal .settings-content.active#diagTab-console {
    height: 94vh !important;
    max-height: 94vh !important;
  }
  #diagTab-console #diagConsoleOutput {
    flex: 1 1 auto !important;
    min-height: 78vh !important;
    max-height: none !important;
  }
  #diagTab-console > div:not(#diagConsoleOutput):not(#diagConsoleWarning) {
    flex-shrink: 0 !important;
    padding: 3px 6px !important;
  }
}
#diagnosticsModal .settings-content:not(.active) {
  display: none !important;
}
/* ================================================================
   КНОПКИ В ТАБАХ — компактные, один цвет, меняются с темой
   ================================================================ */

/* Все три кнопки (Прайс-лист, Смета, Скачать прайс) */
.tabs .tab-btn {
    padding: 8px 14px;
    font-size: 13px;
    border-radius: 6px;
    gap: 6px;
    min-height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.tabs .tab-btn i {
    font-size: 13px;
}

/* Активная вкладка — цвет из темы */
.tabs .tab-btn.active {
    background: var(--btn-primary);
    color: #ffffff;
}

/* Кнопка "Скачать прайс" в табах — открывает модалку */
.tabs .tab-btn[onclick*="openPriceDownloadModal"] {
    background: var(--btn-primary) !important;
    color: #ffffff !important;
    margin-left: 4px;
    border: none;
    transition: background 0.2s, transform 0.15s;
}

.tabs .tab-btn[onclick*="openPriceDownloadModal"]:hover {
    background: var(--btn-primary-hover) !important;
    transform: translateY(-1px);
}

/* Мобильные — 3 кнопки в одну строку */
@media (max-width: 500px) {
    .tabs {
        display: flex;
        flex-wrap: nowrap;
        gap: 3px;
        padding: 3px;
        overflow: hidden;
    }

    .tabs .tab-btn {
        padding: 6px 6px;
        font-size: 11px;
        min-height: 30px;
        border-radius: 5px;
        flex: 1 1 0;
        min-width: 0;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        gap: 4px;
    }

    .tabs .tab-btn i {
        font-size: 11px;
    }

    .tabs .tab-btn[onclick*="openPriceDownloadModal"] {
        margin-left: 0;
    }

    #estimateCounter {
        font-size: 9px !important;
        padding: 0 4px !important;
        margin-left: 2px !important;
    }
}

/* Модалка на мобильных — компактнее */
@media (max-width: 480px) {
    #priceDownloadModal .modal-content {
        max-width: 95% !important;
        margin: 10px auto !important;
    }

    #priceDownloadModal .modal-body {
        padding: 15px !important;
    }

    #priceDownloadModal .btn-block {
        padding: 14px !important;
        font-size: 14px !important;
    }

    #priceDownloadModal .btn-block i {
        font-size: 22px !important;
    }
}

/* ================================================================
   МОБИЛЬНЫЕ — кнопки остаются компактными, идут в строку
   ================================================================ */
@media (max-width: 768px) {
    .tabs {
        gap: 4px;
        padding: 4px;
    }

    .tabs .tab-btn {
        padding: 7px 12px;
        font-size: 12px;
        min-height: 34px;
    }

    .tabs .tab-btn i {
        font-size: 12px;
    }

    /* Кнопка "Скачать прайс" — не переносится на новую строку */
    .tabs .tab-btn[onclick*="downloadPriceXlsx"] {
        margin-left: 4px;
    }
}

/* ================================================================
   ТАБЫ НА УЗКИХ ЭКРАНАХ — все 3 кнопки в одну строку БЕЗ свайпа
   ================================================================ */
@media (max-width: 500px) {
    .tabs {
        display: flex;
        flex-wrap: nowrap;
        gap: 3px;
        padding: 3px;
        overflow: hidden;        /* ← никакого свайпа */
        justify-content: space-between;
    }

    .tabs .tab-btn {
        padding: 6px 6px;
        font-size: 11px;
        min-height: 30px;
        border-radius: 5px;
        flex: 1 1 0;             /* ← все три растягиваются ПОРОВНУ */
        min-width: 0;            /* ← позволяем сжиматься */
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        gap: 3px;
    }

    .tabs .tab-btn i {
        font-size: 11px;
    }

    /* Кнопка "Скачать прайс" — без отступа */
    .tabs .tab-btn[onclick*="downloadPriceXlsx"] {
        margin-left: 0;
    }

    /* Счётчик у "Сметы" — компактный */
    #estimateCounter {
        font-size: 9px !important;
        padding: 0 4px !important;
        margin-left: 2px !important;
    }
}

/* Совсем маленькие экраны (< 380px, iPhone SE 1st gen) */
@media (max-width: 380px) {
    .tabs .tab-btn {
        padding: 5px 4px;
        font-size: 10px;
        min-height: 28px;
        gap: 2px;
    }

    .tabs .tab-btn i {
        font-size: 10px;
    }

    /* Убираем иконки совсем, чтобы текст влез */
    .tabs .tab-btn i.fa-list,
    .tabs .tab-btn i.fa-file-excel {
        display: none;
    }
}
/* ============================================================
   ГЛОБАЛЬНАЯ ПАНЕЛЬ — [⚙️] [💾] .......... [12 500 ₽]
   ------------------------------------------------------------
   • Всегда 36px высота строки
   • Кнопки: 34×34 (иконки), текст — только на широких экранах
   • Сумма: справа, приклеена через margin-left: auto
   ============================================================ */

.global-panel {
    position: sticky;
    top: 30px;
    z-index: 100;

    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    gap: 6px;

    height: 36px;
    min-height: 36px;
    max-height: 36px;

    padding: 0 6px;
    margin-bottom: 12px;

    background: var(--bg-total);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.06);

    box-sizing: border-box;
}

/* ---------- КНОПКИ (⚙️ и 💾) — 34×34 ---------- */
.global-panel-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    flex: 0 0 auto;

    height: 34px;
    min-height: 34px;
    max-height: 34px;

    min-width: 34px;
    padding: 0;

    /* ⭐ По умолчанию — только иконка */
    width: 34px;

    box-sizing: border-box;
    white-space: nowrap;
    overflow: hidden;

    font-size: 14px;
    font-weight: 600;
    line-height: 1;

    border-radius: 6px;
    border: 1px solid var(--border-color);
    background: var(--bg-card);
    color: var(--text-primary);

    cursor: pointer;
    transition: all 0.15s ease;
}

.global-panel-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.1);
    border-color: var(--btn-primary);
}

.global-panel-btn:active {
    transform: translateY(0);
}

/* ⭐ На широких экранах — показываем текст и растягиваем кнопку */
/* ⭐ На широких экранах — показываем текст, все кнопки фиксированной ширины */
@media (min-width: 500px) {
    .global-panel-btn {
        width: 130px;
        min-width: 130px;
        max-width: 130px;
        flex: 0 0 130px;
        padding: 0;
        justify-content: center;
    }
    .global-panel-btn span {
        display: inline;
    }
}

/* На узких экранах (по умолчанию) — скрываем текст */
@media (max-width: 499px) {
    .global-panel-btn span {
        display: none;
    }
}
.global-panel-btn-new {
    background: var(--btn-primary);
    color: #ffffff;
    border-color: var(--btn-primary);
}
.global-panel-btn-new:hover {
    box-shadow: 0 4px 12px rgba(52, 152, 219, 0.35);
    border-color: var(--btn-primary);
}
/* Кнопка "Сохранить" — зелёная */
.global-panel-btn-save {
    background: var(--btn-success);
    color: #ffffff;
    border-color: var(--btn-success);
}

.global-panel-btn-save:hover {
    box-shadow: 0 4px 12px rgba(39, 174, 96, 0.35);
    border-color: var(--btn-success);
}

.global-panel-btn-save:disabled {
    opacity: 0.7;
    cursor: wait;
}

/* ---------- СУММА — приклеена вправо ---------- */
.global-panel-total {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;

    /* ⭐ Прижимаем вправо */
    margin-left: auto;

    /* ⭐ Высота = высота кнопок */
    height: 34px;
    min-height: 34px;
    max-height: 34px;

    /* ⭐ ШИРИНА: под ~8 цифр («9 999 999,99 ₽») */
    min-width: 145px;
    width: auto;

    padding: 0 10px;
    box-sizing: border-box;
    white-space: nowrap;

    font-size: 15px;
    font-weight: 700;
    line-height: 1;

    color: var(--btn-success);
    background: var(--bg-total);
    border-left: 3px solid var(--btn-success);
    border-radius: 6px;

    flex: 0 0 auto;
}

/* Иконка "калькулятор" в сумме — того же размера */
.global-panel-total i {
    font-size: 14px;
}

/* Анимация "пульс" при сохранении */
@keyframes savePulse {
    0%   { transform: scale(1);    box-shadow: 0 0 0 0 rgba(39, 174, 96, 0.6); }
    50%  { transform: scale(1.05); box-shadow: 0 0 0 8px rgba(39, 174, 96, 0); }
    100% { transform: scale(1);    box-shadow: 0 0 0 0 rgba(39, 174, 96, 0); }
}

.quick-save-flash {
    animation: savePulse 0.5s ease;
}

/* ============================================================
   МОДАЛКА «НАСТРОЙКИ СМЕТЫ»
   ============================================================ */

.global-section {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 12px 0;
    border-bottom: 1px solid var(--border-color);
}

.global-section:last-of-type {
    border-bottom: none;
}

.global-section-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 6px;
}

.global-section input {
    width: 100%;
    padding: 10px 14px;
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-sizing: border-box;
    outline: none;
    transition: border-color 0.2s;
}

.global-section input:focus {
    border-color: var(--btn-primary);
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.15);
}

.global-section .global-zoom {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 6px 8px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-sizing: border-box;
}

.global-section .global-zoom .btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    min-width: 36px;
    max-width: 36px;
    height: 36px;
    min-height: 36px;
    max-height: 36px;
    padding: 0;
    font-size: 14px;
    line-height: 1;
    background: transparent;
    border: none;
    color: var(--text-primary);
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.2s;
    box-sizing: border-box;
    flex: 0 0 36px;
}

.global-section .global-zoom .btn:hover {
    background: var(--bg-hover);
}

.global-section .global-zoom #zoomPercent {
    flex: 1;
    text-align: center;
    font-size: 14px;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1;
}
/* ⭐ Скрываем колонку "Ед.Из" в таблице сметы */
#estimateTable th:nth-child(3),
#estimateTable td:nth-child(3) {
    display: none !important;
}
.admin-search-row {
    transition: background 0.15s ease;
}

.admin-search-row:hover {
    background: var(--bg-hover);
}
/* ============================================================
   Бригады: кнопка с кодом приглашения
============================================================ */
.brigade-code-btn {
    flex: 1;
    min-width: 140px;
    padding: 10px;
    background: #fff;
    border: 2px dashed #9c27b0;
    border-radius: 6px;
    font-family: monospace;
    font-size: 16px;
    font-weight: 700;
    letter-spacing: 1px;
    color: #9c27b0;
    cursor: pointer;
    transition: all .2s;
}
.brigade-code-btn:hover {
    background: #f3e5f5;
}
/* ============================================================
   Меню действий пользователя — hover вместо inline onmouse*
============================================================ */
.user-action-btn:hover {
    background: #f8f9fa;
}
.user-action-btn-account:hover {
    background: #eff6ff;
}
/* ============================================================
   Админ: карточки статистики — hover вместо inline onmouse*
============================================================ */
.stat-card:hover {
    transform: scale(1.03);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.15);
}
/* ============================================================
   Прайс-режим: карточки в дропдауне «Обновить»
============================================================ */
.price-mode-item:hover {
    background: var(--bg-hover);
}
.price-refresh-item:hover {
    background: var(--bg-hover);
}
/* ============================================================ */
/*  Кнопка "Печать" на панели сметы                              */
/* ============================================================ */
.global-panel-btn-print {
    background: var(--btn-info);
    color: #ffffff;
    border-color: var(--btn-info);
}

.global-panel-btn-print:hover {
    box-shadow: 0 4px 12px rgba(0, 172, 193, 0.35); /* Цвет info */
    border-color: var(--btn-info);
}
  /* для QR кода*/
  .qr-page {
    max-width: 520px;
    margin: 40px auto;
    padding: 15px;
  }
  .qr-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 24px;
    transition: var(--transition);
  }
  .qr-title {
    margin: 0 0 6px 0;
    font-size: 20px;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 10px;
  }
  .qr-subtitle {
    font-size: 13px;
    color: var(--text-secondary);
    margin: 0 0 20px 0;
  }
  .qr-input {
    width: 100%;
    padding: 12px 14px;
    font-size: 15px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    background: var(--bg-input);
    color: var(--text-primary);
    box-sizing: border-box;
    outline: none;
    transition: var(--transition);
  }
  .qr-input:focus {
    border-color: var(--btn-primary);
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.2);
  }
  .qr-buttons {
    display: flex;
    gap: 10px;
    margin-top: 12px;
    flex-wrap: wrap;
  }
  .qr-result {
    margin-top: 20px;
    padding: 20px;
    border-radius: 12px;
    background: #fff;
    border: 1px dashed var(--border-color);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    min-height: 240px;
    justify-content: center;
  }
  .qr-result:empty::before {
    content: 'Здесь появится QR-код';
    color: var(--text-muted);
    font-size: 13px;
  }
  .qr-result img,
  .qr-result canvas {
    border-radius: 8px;
    max-width: 100%;
  }
  .qr-hint {
    font-size: 12px;
    color: var(--text-secondary);
    text-align: center;
    margin-top: 12px;
  }
  .qr-back {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: var(--btn-primary);
    text-decoration: none;
    margin-bottom: 16px;
  }
  .qr-back:hover { text-decoration: underline; }
    /* конец QR кода*/