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

  :root {
    --bg: #0f0d0b;
    --surface: #1a1714;
    --surface2: #221f1b;
    --border: #2e2a25;
    --accent: #c4944a;
    --accent-dim: rgba(196,148,74,0.12);
    --text: #f0ebe3;
    --text2: #a09880;
    --text3: #5a5448;
    --danger: #e05555;
    --success: #4caf7d;
    --radius: 8px;
    --admin-header-h: 144px;
    --admin-sidebar-w: 220px;
    --admin-logo-h: 128px;
  }

  html, body {
    height: 100%;
    margin: 0;
  }

  body {
    font-family: 'Montserrat', sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100%;
    -webkit-text-size-adjust: 100%;
  }

  /* Document never scrolls while admin is open — only .admin-main does */
  html.admin-open,
  body.admin-open {
    overflow: hidden;
    height: 100%;
  }

  /* ===== LOGIN ===== */
  #loginScreen {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg);
    position: relative;
    overflow: hidden;
  }
  #loginScreen::before {
    content: '';
    position: absolute;
    width: 600px; height: 600px;
    background: radial-gradient(circle, rgba(196,148,74,0.06) 0%, transparent 70%);
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    pointer-events: none;
  }

  .login-box {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 48px 40px;
    width: 100%;
    max-width: 400px;
    position: relative;
    z-index: 1;
  }
  .login-logo { text-align: center; margin-bottom: 36px; }
  .login-logo .name {
    font-family: 'Montserrat', sans-serif;
    font-size: 22px; font-weight: 800; letter-spacing: 5px; color: var(--text);
  }
  .login-logo .sub {
    font-size: 9px; letter-spacing: 3px; color: var(--accent);
    text-transform: uppercase; margin-top: 4px;
  }
  .login-title {
    font-size: 13px; font-weight: 600; letter-spacing: 2px;
    text-transform: uppercase; color: var(--text2); text-align: center; margin-bottom: 28px;
  }
  .login-field { margin-bottom: 16px; }
  .login-field label {
    display: block; font-size: 10px; font-weight: 600;
    letter-spacing: 2px; text-transform: uppercase; color: var(--text3); margin-bottom: 8px;
  }
  .login-field input {
    width: 100%; padding: 13px 16px;
    background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius);
    color: var(--text); font-family: 'Montserrat', sans-serif; font-size: 14px;
    outline: none; transition: border-color 0.2s;
  }
  .login-field input:focus { border-color: var(--accent); }
  .login-btn {
    width: 100%; padding: 14px; background: var(--accent); border: none;
    border-radius: var(--radius); color: #fff; font-family: 'Montserrat', sans-serif;
    font-size: 11px; font-weight: 700; letter-spacing: 2px; text-transform: uppercase;
    cursor: pointer; transition: opacity 0.2s; margin-top: 8px;
  }
  .login-btn:hover { opacity: 0.85; }
  .login-error { color: var(--danger); font-size: 12px; text-align: center; margin-top: 12px; display: none; }
  .login-ok { color: var(--success); font-size: 12px; text-align: center; margin-top: 12px; display: none; line-height: 1.45; }
  .login-hint {
    font-size: 12px; color: var(--text2); text-align: center; line-height: 1.5;
    margin: -8px 0 20px;
  }
  .login-forgot-link {
    display: block; width: 100%; margin-top: 16px; padding: 0;
    background: none; border: none; cursor: pointer;
    font-family: 'Montserrat', sans-serif; font-size: 12px;
    color: var(--text3); text-align: center; text-decoration: underline;
    text-underline-offset: 3px;
  }
  .login-forgot-link:hover { color: var(--accent); }

  /* ===== ADMIN PANEL — app shell: only .admin-main scrolls ===== */
  #adminPanel {
    display: none;
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    z-index: 100;
    flex-direction: column;
    overflow: hidden;
    background: var(--bg);
  }

  .admin-header {
    background: var(--surface); border-bottom: 1px solid var(--border);
    padding: 0 32px; display: flex; align-items: center; justify-content: space-between;
    height: var(--admin-header-h);
    flex: 0 0 var(--admin-header-h);
    flex-shrink: 0;
    position: relative;
    z-index: 1100;
    overflow: visible;
  }
  .admin-header-logo {
    display: flex;
    align-items: center;
    height: 100%;
    color: var(--text);
    min-width: 0;
    flex-shrink: 1;
    overflow: visible;
  }
  .admin-header-logo a {
    display: flex;
    align-items: center;
    height: 100%;
    min-width: 0;
    color: inherit;
    text-decoration: none;
  }
  .admin-header-logo img {
    height: var(--admin-logo-h) !important;
    width: auto !important;
    max-height: none !important;
    max-width: min(420px, 55vw);
    object-fit: contain;
    display: block;
  }
  .admin-header-right { display: flex; align-items: center; gap: 20px; flex-shrink: 0; }
  .admin-user { font-size: 12px; color: var(--text2); }
  .btn-logout {
    padding: 7px 16px; background: transparent; border: 1px solid var(--border);
    border-radius: var(--radius); color: var(--text2); font-family: 'Montserrat', sans-serif;
    font-size: 11px; cursor: pointer; transition: all 0.2s;
  }
  .btn-logout:hover { border-color: var(--danger); color: var(--danger); }

  /* Body row under header: sidebar + scrollable main */
  .admin-body {
    display: flex;
    flex: 1 1 auto;
    height: calc(100% - var(--admin-header-h));
    min-height: 0;
    overflow: hidden;
  }

  /* Sidebar — pinned in flex row (always visible on desktop) */
  .admin-sidebar {
    flex: 0 0 var(--admin-sidebar-w);
    width: var(--admin-sidebar-w);
    z-index: 1090;
    background: var(--surface);
    border-right: 1px solid var(--border);
    padding: 24px 0;
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
  .sidebar-section { padding: 0 16px; margin-bottom: 8px; }
  .sidebar-label {
    font-size: 9px; font-weight: 700; letter-spacing: 2px; text-transform: uppercase;
    color: var(--text3); padding: 0 12px; margin-bottom: 6px;
  }
  .sidebar-link {
    display: flex; align-items: center; gap: 10px; padding: 10px 12px;
    border-radius: var(--radius); font-size: 13px; color: var(--text2); cursor: pointer;
    transition: all 0.2s; border: none; background: none; width: 100%;
    text-align: left; font-family: 'Montserrat', sans-serif;
  }
  .sidebar-link:hover { background: var(--surface2); color: var(--text); }
  .sidebar-link.active { background: var(--accent-dim); color: var(--accent); }
  .sidebar-link svg { flex-shrink: 0; }

  /* Main content — the ONLY page scroll container */
  .admin-main {
    flex: 1 1 auto;
    min-width: 0;
    min-height: 0;
    height: 100%;
    max-height: calc(100vh - var(--admin-header-h));
    padding: 32px;
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
  .page-section { display: none; }
  .page-section.active { display: block; }
  .page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 28px; }
  .page-title { font-family: 'Cormorant Garamond', serif; font-size: 32px; font-weight: 500; color: var(--text); }
  .page-title em { font-style: italic; color: var(--accent); }

  /* Stats row */
  .stats-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 32px; }
  .stat-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; }
  .stat-label { font-size: 10px; letter-spacing: 2px; text-transform: uppercase; color: var(--text3); margin-bottom: 8px; }
  .stat-value { font-size: 28px; font-weight: 700; color: var(--text); }
  .stat-sub { font-size: 11px; color: var(--text3); margin-top: 4px; }
  .stat-accent { color: var(--accent); }

  /* Buttons */
  .btn-primary {
    padding: 10px 20px; background: var(--accent); border: none; border-radius: var(--radius);
    color: #fff; font-family: 'Montserrat', sans-serif; font-size: 11px; font-weight: 700;
    letter-spacing: 1px; text-transform: uppercase; cursor: pointer; transition: opacity 0.2s;
    display: inline-flex; align-items: center; gap: 8px;
  }
  .btn-primary:hover { opacity: 0.85; }
  .btn-secondary {
    padding: 10px 20px; background: transparent; border: 1px solid var(--border);
    border-radius: var(--radius); color: var(--text2); font-family: 'Montserrat', sans-serif;
    font-size: 11px; font-weight: 600; cursor: pointer; transition: all 0.2s;
  }
  .btn-secondary:hover { border-color: var(--text2); color: var(--text); }

  /* Toolbar */
  .toolbar { display: flex; gap: 12px; margin-bottom: 20px; align-items: center; }
  .search-input {
    flex: 1; padding: 10px 16px; background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); color: var(--text); font-family: 'Montserrat', sans-serif;
    font-size: 13px; outline: none; transition: border-color 0.2s;
  }
  .search-input:focus { border-color: var(--accent); }
  .search-input::placeholder { color: var(--text3); }

  /* Products table */
  .products-table { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
  .table-head {
    display: grid; grid-template-columns: 60px 1fr 120px 100px 100px 120px;
    padding: 12px 20px; border-bottom: 1px solid var(--border);
    font-size: 9px; font-weight: 700; letter-spacing: 2px; text-transform: uppercase; color: var(--text3);
  }
  .table-row {
    display: grid; grid-template-columns: 60px 1fr 120px 100px 100px 120px;
    padding: 14px 20px; border-bottom: 1px solid var(--border);
    align-items: center; transition: background 0.15s; font-size: 13px;
  }
  .table-row:last-child { border-bottom: none; }
  .table-row:hover { background: var(--surface2); }

  .product-thumb-mini {
    width: 44px; height: 44px; border-radius: 4px; object-fit: cover;
    background: var(--surface2); border: 1px solid var(--border);
  }
  .product-name-cell .name { font-weight: 600; color: var(--text); font-size: 13px; }
  .product-name-cell .variant { font-size: 11px; color: var(--text3); margin-top: 2px; }
  .price-cell { font-weight: 600; color: var(--accent); }
  .badge { display: inline-block; padding: 3px 8px; border-radius: 4px; font-size: 10px; font-weight: 600; letter-spacing: 1px; }
  .badge-stock { background: rgba(76,175,125,0.15); color: var(--success); }
  .badge-collection { background: rgba(201,169,110,0.15); color: var(--accent); margin-right: 4px; }
  .badge-order { background: rgba(196,148,74,0.15); color: var(--accent); }
  .badge-hidden { background: rgba(90,84,72,0.3); color: var(--text3); }

  .row-actions { display: flex; gap: 8px; }
  .btn-icon {
    width: 30px; height: 30px; background: var(--surface2); border: 1px solid var(--border);
    border-radius: 4px; display: flex; align-items: center; justify-content: center;
    cursor: pointer; transition: all 0.2s; color: var(--text2);
  }
  .btn-icon:hover { border-color: var(--accent); color: var(--accent); }
  .btn-icon.danger:hover { border-color: var(--danger); color: var(--danger); }

  /* Modal */
  .modal-bg {
    position: fixed; inset: 0; background: rgba(0,0,0,0.7); z-index: 1000;
    display: none; align-items: center; justify-content: center; padding: 20px;
  }
  .modal-bg.open { display: flex; }
  .modal-box {
    background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
    padding: 36px; width: 100%; max-width: 620px; max-height: 90vh; overflow-y: auto; position: relative;
  }
  .modal-title-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 28px; }
  .modal-title { font-family: 'Cormorant Garamond', serif; font-size: 26px; font-weight: 500; }
  .modal-title em { font-style: italic; color: var(--accent); }
  .modal-close-btn {
    width: 32px; height: 32px; background: var(--surface2); border: 1px solid var(--border);
    border-radius: 4px; cursor: pointer; color: var(--text2);
    display: flex; align-items: center; justify-content: center; font-size: 16px; transition: all 0.2s;
  }
  .modal-close-btn:hover { color: var(--danger); border-color: var(--danger); }

  .form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
  .form-full { grid-column: 1 / -1; }
  .form-group { display: flex; flex-direction: column; gap: 6px; }
  .form-group label { font-size: 10px; font-weight: 600; letter-spacing: 2px; text-transform: uppercase; color: var(--text3); }
  .form-group input, .form-group select, .form-group textarea {
    padding: 11px 14px; background: var(--bg); border: 1px solid var(--border);
    border-radius: var(--radius); color: var(--text); font-family: 'Montserrat', sans-serif;
    font-size: 13px; outline: none; transition: border-color 0.2s;
  }
  .form-group input:focus, .form-group select:focus, .form-group textarea:focus { border-color: var(--accent); }
  .form-group select option { background: var(--surface); }
  .form-group textarea { resize: vertical; min-height: 80px; }

  .admin-color-hint {
    font-size: 11px; color: var(--text3); margin: 0 0 4px; line-height: 1.4;
  }
  .admin-color-swatches {
    display: flex; flex-wrap: wrap; gap: 8px; margin: 2px 0 4px;
  }
  .admin-swatch {
    width: 36px; height: 36px; padding: 0; border-radius: 50%;
    border: 2px solid transparent; overflow: hidden; cursor: pointer;
    background: var(--surface2); transition: transform 0.15s, border-color 0.15s;
  }
  .admin-swatch img {
    width: 100%; height: 100%; object-fit: cover; display: block; pointer-events: none;
  }
  .admin-swatch:hover { transform: scale(1.1); border-color: var(--text3); }
  .admin-swatch.active {
    border-color: var(--accent); transform: scale(1.12);
    box-shadow: 0 0 0 2px rgba(196,148,74,0.25);
  }
  .admin-color-label {
    font-size: 12px; color: var(--text2); min-height: 16px; margin-bottom: 2px;
  }
  .badge-toggles { display: flex; flex-wrap: wrap; gap: 10px; }
  .badge-toggle {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 10px 14px; border: 1px solid var(--border, #3a342c);
    border-radius: 8px; background: var(--surface2, #1f1b17); cursor: pointer;
    font-size: 12px; font-weight: 600; color: var(--text2, #d6d0c4);
  }
  .badge-toggle input { accent-color: var(--accent); }
  .badge-toggle:has(input:checked) {
    border-color: var(--accent); color: var(--text, #fff);
    box-shadow: 0 0 0 1px rgba(196,148,74,0.25);
  }
  .image-upload-row {
    display: flex; flex-wrap: wrap; align-items: center; gap: 12px;
  }
  .image-upload-row input[type="file"] { display: none; }
  .image-upload-preview {
    max-width: 100%; max-height: 160px; margin-top: 10px;
    border-radius: var(--radius); border: 1px solid var(--border); object-fit: contain;
  }
  .product-gallery-slots {
    display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px;
  }
  @media (max-width: 720px) {
    .product-gallery-slots { grid-template-columns: 1fr; }
  }
  .gallery-slot {
    border: 1px solid var(--border); border-radius: var(--radius);
    padding: 10px; background: rgba(255,255,255,0.02);
  }
  .gallery-slot-label {
    font-size: 11px; font-weight: 600; color: var(--text3); margin-bottom: 8px;
  }
  .gallery-slot-preview {
    width: 100%; height: 120px; object-fit: contain;
    border-radius: 6px; border: 1px solid var(--border); background: #111;
  }
  .gallery-slot-empty {
    height: 120px; display: flex; align-items: center; justify-content: center;
    border-radius: 6px; border: 1px dashed var(--border); color: var(--text3);
    font-size: 12px; margin-bottom: 0;
  }
  .gallery-slot-actions {
    display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px;
  }
  .gallery-slot-actions .btn-sm {
    font-size: 11px; padding: 6px 10px;
  }

  .form-actions {
    display: flex; gap: 12px; justify-content: flex-end;
    margin-top: 24px; padding-top: 20px; border-top: 1px solid var(--border);
  }

  .toast {
    position: fixed; bottom: 24px; right: 24px; background: var(--success); color: #fff;
    padding: 12px 20px; border-radius: var(--radius); font-size: 13px; font-weight: 600;
    transform: translateY(80px); opacity: 0; transition: all 0.3s; z-index: 9999;
  }
  .toast.show { transform: translateY(0); opacity: 1; }
  .toast.error { background: var(--danger); }

  .empty-state { text-align: center; padding: 60px 20px; color: var(--text3); }
  .empty-state svg { opacity: 0.3; margin-bottom: 16px; }
  .empty-state p { font-size: 14px; }

  .admin-card {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 24px; margin-bottom: 24px;
  }
  .admin-card-label {
    font-size: 12px; color: var(--text3); letter-spacing: 1px;
    text-transform: uppercase; margin-bottom: 8px;
  }
  .admin-card-hint {
    font-size: 13px; color: var(--text2); margin-bottom: 16px; line-height: 1.5;
  }
  .featured-slots {
    display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px;
  }
  .featured-slot label {
    display: block; font-size: 11px; color: var(--text3); margin-bottom: 6px;
  }
  .featured-slot select {
    width: 100%; padding: 10px 12px; background: var(--bg); border: 1px solid var(--border);
    border-radius: var(--radius); color: var(--text); font-family: 'Montserrat', sans-serif; font-size: 13px;
  }
  .admin-btn-danger { border-color: var(--danger) !important; color: var(--danger) !important; }

  .brands-table {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); overflow: hidden;
  }
  .brands-head,
  .brands-row {
    display: grid;
    grid-template-columns: 72px 1.4fr 72px 72px 72px 96px;
    gap: 12px; align-items: center; padding: 14px 18px;
  }
  .brands-head {
    font-size: 11px; color: var(--text3); text-transform: uppercase;
    letter-spacing: 0.8px; border-bottom: 1px solid var(--border);
  }
  .brands-row { border-bottom: 1px solid var(--border); }
  .brands-row:last-child { border-bottom: none; }
  .brand-thumb {
    width: 56px; height: 40px; object-fit: contain;
    background: var(--bg); border: 1px solid var(--border); border-radius: 6px;
  }
  .brand-thumb--empty {
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 12px; color: var(--text3);
  }
  .brand-flag-cell, .brand-count-cell { text-align: center; color: var(--text2); }
  .brand-logo-preview { max-height: 80px; object-fit: contain; background: #fff; }

  .admin-pagination { display: flex; justify-content: center; gap: 6px; margin-top: 20px; }
  .admin-page-btn {
    min-width: 32px; height: 32px; padding: 0 10px; background: var(--surface);
    border: 1px solid var(--border); border-radius: 4px; color: var(--text2);
    font-family: 'Montserrat', sans-serif; font-size: 12px; cursor: pointer; transition: all 0.2s;
  }
  .admin-page-btn:hover { border-color: var(--accent); color: var(--accent); }
  .admin-page-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }

  /* Нижняя навигация — только на мобильных (см. @media) */
  .admin-bottom-nav { display: none; }

  /* ===== СОРТИРОВКА ===== */
  .sortable { cursor: pointer; user-select: none; transition: color 0.2s; }
  .sortable:hover { color: var(--accent); }
  .sortable.asc .sort-arrow::after { content: ' ↑'; }
  .sortable.desc .sort-arrow::after { content: ' ↓'; }
  .sort-arrow { font-size: 10px; opacity: 0.4; }
  .sortable.asc .sort-arrow, .sortable.desc .sort-arrow { opacity: 1; color: var(--accent); }

  /* ===== ЗАЯВКИ ===== */

  /* Колонки: дата | тип | имя | телефон | email | детали | статус | действия */
  .leads-head { grid-template-columns: 115px 120px 150px 140px 175px 100px 130px 60px; }
  .leads-row  { grid-template-columns: 115px 120px 150px 140px 175px 100px 130px 60px; }

  .leads-row:hover { background: var(--surface2); }
  .lead-new { border-left: 3px solid var(--accent); }
  .lead-phone { color: var(--accent); text-decoration: none; }
  .lead-phone:hover { text-decoration: underline; }
  .lead-date  { font-size: 12px; color: var(--text3); }
  .lead-type  { font-size: 12px; color: var(--text2); }
  .lead-extra { font-size: 12px; color: var(--text3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .lead-name { font-weight: 600; color: var(--text); }
  .lead-phone-cell { min-width: 0; }
  .lead-actions { display: flex; gap: 6px; align-items: center; justify-content: flex-end; }

  /* Email в строке */
  .lead-email {
    font-size: 12px; color: var(--text2);
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  }
  .lead-email a { color: var(--text2); text-decoration: none; }
  .lead-email a:hover { color: var(--accent); }

  .badge-new  { background: rgba(196,148,74,0.15); color: var(--accent); font-size: 10px; padding: 2px 8px; border-radius: 10px; }
  .badge-read { background: var(--surface2); color: var(--text3); font-size: 10px; padding: 2px 8px; border-radius: 10px; }

  /* Фильтры */
  .leads-filters-bar { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; }
  .leads-filter-btns { display: flex; gap: 6px; }
  .leads-filter-btn {
    padding: 7px 16px; border-radius: 6px; border: 1px solid var(--border);
    background: transparent; color: var(--text2); cursor: pointer;
    font-size: 12px; font-family: 'Montserrat', sans-serif; font-weight: 600; transition: all 0.2s;
  }
  .leads-filter-btn:hover { border-color: var(--accent); color: var(--accent); }
  .leads-filter-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }

  .leads-date-filter {
    padding: 7px 12px; background: var(--surface); border: 1px solid var(--border);
    border-radius: 6px; color: var(--text); font-family: 'Montserrat', sans-serif;
    font-size: 12px; outline: none; transition: border-color 0.2s; cursor: pointer;
  }
  .leads-date-filter:focus { border-color: var(--accent); }

  /* Статус */
  .lead-status-cell { display: flex; align-items: center; }
  .lead-status-select {
    padding: 5px 10px; border-radius: 6px; border: none; cursor: pointer;
    font-size: 11px; font-family: 'Montserrat', sans-serif; font-weight: 600;
    outline: none; transition: background 0.2s;
  }
  .lead-status-select.badge-new     { background: rgba(196,148,74,0.15); color: var(--accent); }
  .lead-status-select.badge-working { background: rgba(100,160,255,0.15); color: #64a0ff; }
  .lead-status-select.badge-closed  { background: rgba(76,175,125,0.15);  color: var(--success); }
  .lead-status-select option { background: var(--surface); color: var(--text); }

  /* ===== АНИМАЦИЯ КНОПКИ ОБНОВИТЬ ===== */
  @keyframes spin { to { transform: rotate(360deg); } }
  .spin { display: inline-block; animation: spin 0.8s linear infinite; }


/* ========================================
   АДАПТИВ АДМИН-ПАНЕЛИ
   ======================================== */

/* ---- 1024px — планшет ---- */
@media (max-width: 1024px) {
  .admin-main { padding: 24px; }
  .stats-row { grid-template-columns: repeat(2, 1fr); gap: 12px; }

  .products-table,
  .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .table-head, .table-row { min-width: 700px; }
  .leads-head, .leads-row { min-width: 900px; }
}

/* ---- 768px — телефон: карточки вместо таблиц ---- */
@media (max-width: 768px) {

  :root {
    --admin-header-h: 116px;
    --admin-logo-h: 100px;
  }

  .admin-header {
    padding: 0 12px;
    height: var(--admin-header-h);
    flex-basis: var(--admin-header-h);
    gap: 8px;
    overflow: visible;
  }
  .admin-header-logo {
    white-space: nowrap;
    max-width: 55vw;
    height: 100%;
    overflow: visible;
  }
  .admin-header-logo img {
    height: var(--admin-logo-h) !important;
    width: auto !important;
    max-height: none !important;
    max-width: 100%;
    object-fit: contain;
  }
  .admin-user { display: none; }
  .admin-header-right { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
  .admin-site-link { display: none; }
  .btn-logout { padding: 8px 14px; font-size: 11px; min-height: 36px; }

  .admin-body {
    flex: 1 1 auto;
    height: calc(100% - var(--admin-header-h));
    min-height: 0;
    overflow: hidden;
  }
  .admin-sidebar { display: none; }

  .featured-slots { grid-template-columns: 1fr; }

  .brands-table { background: transparent; border: none; }
  .brands-table .brands-head { display: none; }
  .brands-row {
    grid-template-columns: 1fr;
    gap: 8px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 10px;
  }
  .brand-flag-cell, .brand-count-cell { text-align: left; }

  .admin-bottom-nav {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--surface);
    border-top: 1px solid var(--border);
    z-index: 200;
    height: 64px;
    padding-bottom: env(safe-area-inset-bottom, 0);
  }
  .admin-bottom-nav .sidebar-link {
    flex: 1;
    flex-direction: column;
    gap: 4px;
    padding: 8px 4px;
    justify-content: center;
    align-items: center;
    font-size: 9px;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    border-radius: 0;
    min-height: 64px;
  }
  .admin-bottom-nav .sidebar-link svg { width: 22px; height: 22px; }

  .admin-main { padding: 16px 14px calc(80px + env(safe-area-inset-bottom, 0)); overflow-y: auto; }

  .stats-row { grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 20px; }
  .stat-card { padding: 14px; }
  .stat-value { font-size: 22px; }

  .page-header {
    margin-bottom: 16px;
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }
  .page-title { font-size: 24px; }
  .page-header .btn-primary,
  .page-header .btn-secondary,
  .page-header > div { width: 100%; }
  .page-header .btn-primary,
  .page-header .btn-secondary { justify-content: center; text-align: center; }

  .toolbar { flex-direction: column; align-items: stretch; }
  .toolbar .search-input { flex: 1 1 auto; width: 100%; font-size: 16px; }
  .toolbar select.search-input { flex: 1 1 auto !important; width: 100% !important; }

  /* --- Товары: карточки --- */
  .products-table {
    overflow: visible;
    background: transparent;
    border: none;
  }
  .products-table .table-head { display: none; }
  .products-table .table-row {
    display: grid;
    grid-template-columns: 56px 1fr auto;
    grid-template-areas:
      "thumb name name"
      "thumb price stock"
      "cat cat cat"
      "actions actions actions";
    gap: 6px 12px;
    min-width: 0;
    margin-bottom: 12px;
    padding: 14px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
  }
  .products-table .table-row > .product-thumb-mini {
    grid-area: thumb;
    width: 56px;
    height: 56px;
  }
  .products-table .table-row > .product-name-cell { grid-area: name; min-width: 0; }
  .products-table .table-row > .price-cell { grid-area: price; align-self: center; font-size: 15px; }
  .products-table .table-row > .product-stock-cell { grid-area: stock; align-self: center; justify-self: end; }
  .products-table .table-row > .product-cat-cell {
    grid-area: cat;
    font-size: 12px;
    color: var(--text3);
    padding-top: 4px;
    border-top: 1px solid var(--border);
  }
  .products-table .table-row > .row-actions {
    grid-area: actions;
    justify-content: flex-end;
    padding-top: 8px;
    gap: 10px;
  }

  /* --- Заявки: карточки --- */
  .table-wrap { overflow: visible; }
  .table-wrap .table-head { display: none; }
  .leads-row {
    display: grid;
    grid-template-columns: 1fr auto;
    grid-template-areas:
      "date type"
      "name name"
      "phone phone"
      "email email"
      "extra extra"
      "status status"
      "actions actions";
    gap: 8px 12px;
    min-width: 0 !important;
    margin-bottom: 12px;
    padding: 14px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
  }
  .leads-row .lead-date { grid-area: date; font-size: 11px; }
  .leads-row .lead-type {
    grid-area: type;
    justify-self: end;
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    color: var(--accent);
  }
  .leads-row .lead-name { grid-area: name; font-size: 15px; }
  .leads-row .lead-phone-cell { grid-area: phone; }
  .leads-row .lead-phone {
    display: block;
    font-size: 18px;
    font-weight: 700;
    padding: 10px 12px;
    background: var(--accent-dim);
    border-radius: var(--radius);
    text-align: center;
  }
  .leads-row .lead-email { grid-area: email; white-space: normal; word-break: break-all; }
  .leads-row .lead-extra {
    grid-area: extra;
    white-space: normal;
    font-size: 12px;
    color: var(--text2);
  }
  .leads-row .lead-status-cell { grid-area: status; }
  .leads-row .lead-status-select {
    width: 100%;
    padding: 12px 14px;
    font-size: 14px;
    min-height: 44px;
  }
  .leads-row .lead-actions {
    grid-area: actions;
    justify-content: flex-end;
    padding-top: 4px;
  }

  .leads-filters-bar { flex-direction: column; align-items: stretch; gap: 10px; }
  .leads-filter-btns { flex-wrap: wrap; }
  .leads-filter-btn { flex: 1 1 calc(50% - 4px); min-height: 40px; text-align: center; }
  .leads-date-filter { width: 100%; min-height: 44px; font-size: 16px; }

  /* Кнопки — удобнее для пальца */
  .btn-icon {
    width: 44px;
    height: 44px;
    border-radius: 8px;
  }
  .btn-primary,
  .btn-secondary {
    min-height: 44px;
    padding: 12px 18px;
  }

  /* Модалка на весь экран */
  .modal-bg { padding: 0; align-items: flex-end; }
  .modal-box {
    max-width: none;
    max-height: 92vh;
    border-radius: 12px 12px 0 0;
    padding: 20px 16px calc(20px + env(safe-area-inset-bottom, 0));
  }
  .form-grid { grid-template-columns: 1fr; }
  .form-group input,
  .form-group select,
  .form-group textarea,
  .login-field input { font-size: 16px; }
  .modal-title { font-size: 22px; }
  .form-actions {
    flex-direction: column-reverse;
    gap: 10px;
  }
  .form-actions .btn-primary,
  .form-actions .btn-secondary { width: 100%; justify-content: center; }

  .login-box { padding: 32px 24px; margin: 16px; width: calc(100% - 32px); }

  .toast {
    bottom: calc(72px + env(safe-area-inset-bottom, 0));
    right: 12px;
    left: 12px;
    text-align: center;
  }
}

/* ---- 480px — маленькие телефоны ---- */
@media (max-width: 480px) {
  :root {
    --admin-header-h: 104px;
    --admin-logo-h: 88px;
  }

  .admin-header {
    height: var(--admin-header-h);
    flex-basis: var(--admin-header-h);
    overflow: visible;
  }
  .admin-header-logo img {
    height: var(--admin-logo-h) !important;
    width: auto !important;
    max-height: none !important;
    object-fit: contain;
  }
  .admin-body {
    flex: 1 1 auto;
    height: calc(100% - var(--admin-header-h));
    min-height: 0;
    overflow: hidden;
  }
  .admin-main { padding: 14px 12px calc(76px + env(safe-area-inset-bottom, 0)); }

  .stats-row { gap: 8px; }
  .stat-card { padding: 12px; }
  .stat-label { font-size: 9px; }
  .stat-value { font-size: 20px; }

  .page-title { font-size: 22px; }
  .admin-bottom-nav .sidebar-link { font-size: 8px; }
}
