/* Склад Grigor — простой крупный интерфейс для строительного магазина.
   Дизайн: большие кнопки, крупный шрифт, понятные цвета.
   Цвета: зелёный — хорошо, жёлтый — внимание, красный — проблема, серый — архив. */

:root {
  --bg: #f3f4f6;
  --surface: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --border: #d1d5db;

  --brand: #1d4ed8;        /* основной синий */
  --brand-dark: #1e40af;
  --green: #16a34a;
  --green-bg: #dcfce7;
  --yellow: #d97706;
  --yellow-bg: #fef3c7;
  --red: #dc2626;
  --red-bg: #fee2e2;
  --gray: #9ca3af;
  --gray-bg: #f1f5f9;

  --radius: 14px;
  --shadow: 0 1px 3px rgba(0,0,0,.1), 0 1px 2px rgba(0,0,0,.06);
  --shadow-lg: 0 10px 25px rgba(0,0,0,.12);

  --fs-base: 18px;
  --fs-lg: 22px;
  --fs-xl: 30px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: var(--fs-base);
  line-height: 1.4;
}

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

/* --- Шапка --- */
.topbar {
  background: var(--brand);
  color: #fff;
  padding: 14px 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: var(--shadow);
  position: sticky;
  top: 0;
  z-index: 100;
}
.topbar .brand {
  font-size: var(--fs-xl);
  font-weight: 800;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 10px;
}
.topbar .brand:hover { text-decoration: none; }
.topbar .nav { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.topbar .nav a {
  color: #fff;
  padding: 8px 14px;
  border-radius: 10px;
  font-size: 17px;
  font-weight: 600;
}
.topbar .nav a:hover { background: rgba(255,255,255,.18); text-decoration: none; }
.topbar .nav a.active { background: rgba(255,255,255,.28); box-shadow: inset 0 -3px 0 #fff; }

.container { max-width: 1280px; margin: 0 auto; padding: 22px; }
.mobile-tabbar,
.mobile-home { display: none; }

h1 { font-size: var(--fs-xl); margin: 0 0 18px; }
h2 { font-size: var(--fs-lg); margin: 0 0 14px; }
.muted { color: var(--muted); }
.small { font-size: 15px; }

/* --- Главный экран: огромные кнопки --- */
.menu-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 18px;
  margin-top: 10px;
}
.menu-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 34px 18px;
  min-height: 160px;
  text-align: center;
  font-size: 24px;
  font-weight: 700;
  color: var(--text);
  box-shadow: var(--shadow);
  transition: transform .08s ease, box-shadow .15s ease, border-color .15s ease;
}
.menu-btn:hover {
  text-decoration: none;
  transform: translateY(-3px);
  box-shadow: var(--shadow-lg);
  border-color: var(--brand);
}
.menu-btn .icon { font-size: 52px; line-height: 1; }
.menu-btn small { font-size: 14px; font-weight: 600; color: var(--muted); line-height: 1.25; margin-top: 2px; }
.menu-btn.accent { background: var(--brand); color: #fff; border-color: var(--brand); }
.menu-btn.accent .icon { filter: none; }
.menu-btn.green { border-color: var(--green); }
.menu-btn.yellow { border-color: var(--yellow); }
.menu-btn.folder { border-color: var(--brand); }
.menu-btn.folder .icon { font-size: 46px; }

/* --- Касса-герой на главной --- */
.sell-hero {
  display: flex;
  align-items: center;
  gap: 22px;
  background: linear-gradient(120deg, var(--green) 0%, #15803d 100%);
  color: #fff;
  border-radius: var(--radius);
  padding: 28px 32px;
  box-shadow: var(--shadow-lg);
  margin-bottom: 18px;
  transition: transform .08s ease, filter .12s ease;
}
.sell-hero:hover { text-decoration: none; transform: translateY(-2px); filter: brightness(1.04); }
.sell-hero .sell-hero-icon { font-size: 64px; line-height: 1; }
.sell-hero .sell-hero-main { flex: 1; }
.sell-hero .sell-hero-main b { display: block; font-size: 42px; font-weight: 800; line-height: 1; }
.sell-hero .sell-hero-main small { display: block; margin-top: 6px; font-size: 18px; color: rgba(255,255,255,.85); }
.sell-hero .sell-hero-stat { text-align: right; }
.sell-hero .sell-hero-stat b { display: block; font-size: 30px; font-weight: 800; }
.sell-hero .sell-hero-stat small { display: block; font-size: 14px; color: rgba(255,255,255,.8); }

.home-quick {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
  margin-bottom: 16px;
}
.home-quick .menu-btn { min-height: 120px; flex-direction: row; gap: 14px; font-size: 22px; }
.home-quick .menu-btn .icon { font-size: 40px; }

.home-signals { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 8px; }
.home-signals .signal {
  flex: 1; min-width: 160px;
  background: var(--surface); border: 2px solid var(--border); border-radius: 12px;
  padding: 12px 18px; color: var(--text); font-size: 16px; box-shadow: var(--shadow);
}
.home-signals .signal:hover { text-decoration: none; border-color: var(--brand); }
.home-signals .signal b { font-size: 26px; font-weight: 800; margin-right: 8px; }
.home-signals .signal.red b { color: var(--red); }
.home-signals .signal.yellow b { color: var(--yellow); }

.home-section-title { margin: 22px 0 12px; color: var(--muted); font-size: 18px; text-transform: uppercase; letter-spacing: .04em; }

/* --- Карточки-счётчики --- */
.stats { display: flex; gap: 16px; flex-wrap: wrap; margin-bottom: 24px; }
.stat {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 18px 22px;
  box-shadow: var(--shadow);
  flex: 1;
  min-width: 180px;
}
.stat .num { font-size: 34px; font-weight: 800; }
.stat .label { color: var(--muted); font-size: 16px; }
.stat.green .num { color: var(--green); }
.stat.red .num { color: var(--red); }
.stat.yellow .num { color: var(--yellow); }

/* --- Кнопки --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: none;
  border-radius: 12px;
  padding: 14px 24px;
  font-size: 19px;
  font-weight: 700;
  cursor: pointer;
  background: var(--brand);
  color: #fff;
  box-shadow: var(--shadow);
  transition: filter .12s ease, transform .06s ease;
}
.btn:hover { filter: brightness(1.07); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn.big { padding: 20px 36px; font-size: 24px; width: 100%; }
.btn.green { background: var(--green); }
.btn.red { background: var(--red); }
.btn.gray { background: #475569; }
.btn.outline { background: #fff; color: var(--text); border: 2px solid var(--border); box-shadow: none; }
.btn.outline:hover { border-color: var(--brand); }
.btn.sm { padding: 8px 14px; font-size: 16px; }

/* --- Формы --- */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-weight: 600; font-size: 16px; }
input, select, textarea {
  font-size: 19px;
  padding: 12px 14px;
  border: 2px solid var(--border);
  border-radius: 10px;
  background: #fff;
  color: var(--text);
  width: 100%;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(29,78,216,.15);
}
textarea { min-height: 80px; resize: vertical; }
.checkbox-row { display: flex; align-items: center; gap: 10px; }
.checkbox-row input { width: auto; transform: scale(1.4); }

/* --- Панель / карточка --- */
.panel {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow);
  margin-bottom: 20px;
}
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.row.between { justify-content: space-between; }
.spacer { flex: 1; }
.sale-layout { align-items: flex-start; gap: 20px; }
.sale-column { flex: 1; min-width: 340px; }
.form-action { margin-top: 12px; }
.checkout-submit { margin-top: 16px; }

/* --- Таблицы --- */
table { width: 100%; border-collapse: collapse; background: var(--surface); border-radius: var(--radius); overflow: hidden; }
th, td { padding: 14px 16px; text-align: left; border-bottom: 1px solid var(--border); font-size: 17px; }
th { background: #f8fafc; font-size: 15px; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); }
tbody tr:hover { background: #f8fafc; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }

/* --- Цветные метки остатка --- */
.tag {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 15px;
  font-weight: 700;
}
.tag.green { background: var(--green-bg); color: var(--green); }
.tag.yellow { background: var(--yellow-bg); color: var(--yellow); }
.tag.red { background: var(--red-bg); color: var(--red); }
.tag.gray { background: var(--gray-bg); color: var(--gray); }

.dot { display: inline-block; width: 14px; height: 14px; border-radius: 50%; vertical-align: middle; }
.dot.green { background: var(--green); }
.dot.yellow { background: var(--yellow); }
.dot.red { background: var(--red); }
.dot.gray { background: var(--gray); }

/* строки таблицы с цветной левой границей */
tr.stock-green td:first-child { border-left: 5px solid var(--green); }
tr.stock-yellow td:first-child { border-left: 5px solid var(--yellow); }
tr.stock-red td:first-child { border-left: 5px solid var(--red); }
tr.stock-gray td:first-child { border-left: 5px solid var(--gray); }

/* --- Фильтры-чипсы --- */
.chips { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.chip {
  padding: 10px 18px;
  border-radius: 999px;
  background: #fff;
  border: 2px solid var(--border);
  font-weight: 600;
  font-size: 16px;
  color: var(--text);
}
.chip.active { background: var(--brand); color: #fff; border-color: var(--brand); }
.chip:hover { text-decoration: none; border-color: var(--brand); }

/* --- Поиск --- */
.search-box { position: relative; }
.search-box input { font-size: 24px; padding: 18px 20px; }
.search-results {
  margin-top: 10px;
  border-radius: var(--radius);
  overflow: hidden;
}
.search-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 16px 18px;
  background: #fff;
  border: 2px solid var(--border);
  border-radius: 12px;
  margin-bottom: 8px;
  cursor: pointer;
}
.search-item:hover { border-color: var(--brand); background: #f0f6ff; }
.search-item .name { font-size: 19px; font-weight: 700; }
.search-item .meta { color: var(--muted); font-size: 15px; }
.search-item .price { font-size: 22px; font-weight: 800; color: var(--brand); white-space: nowrap; }

/* --- Корзина продажи --- */
.cart-item {
  display: grid;
  grid-template-columns: 1fr auto auto auto;
  gap: 12px;
  align-items: center;
  padding: 14px;
  border-bottom: 1px solid var(--border);
}
.cart-item .ci-name { font-weight: 700; font-size: 18px; }
.cart-item input { width: 90px; text-align: center; }
.cart-total {
  font-size: 32px;
  font-weight: 800;
  text-align: right;
  padding: 16px;
  color: var(--brand);
}

/* --- Уведомления --- */
.alert { padding: 16px 20px; border-radius: 12px; margin-bottom: 18px; font-weight: 600; }
.alert.green { background: var(--green-bg); color: #14532d; }
.alert.red { background: var(--red-bg); color: #7f1d1d; }
.alert.yellow { background: var(--yellow-bg); color: #78350f; }
.alert-dismiss { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.alert-close {
  flex: none; border: none; background: rgba(0,0,0,.08); color: inherit;
  width: 34px; height: 34px; border-radius: 8px; font-size: 18px; font-weight: 700;
  cursor: pointer; line-height: 1;
}
.alert-close:hover { background: rgba(0,0,0,.16); }

.empty { text-align: center; padding: 60px 20px; color: var(--muted); }
.empty .icon { font-size: 64px; }

.photo { max-width: 220px; border-radius: 12px; border: 2px solid var(--border); }
.photo-placeholder {
  width: 220px; height: 160px; border-radius: 12px;
  background: var(--gray-bg); display: flex; align-items: center; justify-content: center;
  font-size: 48px; color: var(--gray); border: 2px dashed var(--border);
}

.confidence-bar { height: 10px; background: var(--border); border-radius: 6px; overflow: hidden; width: 80px; }
.confidence-bar > span { display: block; height: 100%; background: var(--green); }

/* --- Адаптивность для планшета/телефона --- */
@media (max-width: 720px) {
  :root { --fs-base: 17px; }
  body { padding-bottom: 82px; background: #eef2f7; }
  .topbar {
    position: sticky;
    padding: 12px 14px;
    min-height: 58px;
    border-bottom: 1px solid rgba(255,255,255,.18);
  }
  .topbar .brand {
    font-size: 18px;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .topbar .nav { display: none; }
  .container { padding: 14px; }
  h1 { font-size: 24px; margin-bottom: 12px; }
  h2 { font-size: 19px; }
  .desktop-home { display: none; }
  .mobile-home {
    display: block;
    margin: -2px 0 18px;
  }
  .mobile-hero {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 14px;
    align-items: center;
    padding: 18px;
    background: #12203a;
    color: #fff;
    border-radius: 18px;
    box-shadow: var(--shadow);
  }
  .mobile-kicker {
    color: rgba(255,255,255,.72);
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
  }
  .mobile-hero strong {
    display: block;
    margin-top: 2px;
    font-size: 30px;
    line-height: 1.05;
  }
  .mobile-hero span {
    display: block;
    margin-top: 5px;
    color: rgba(255,255,255,.75);
    font-size: 14px;
  }
  .mobile-primary-action {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 56px;
    padding: 0 18px;
    border-radius: 14px;
    background: var(--green);
    color: #fff;
    font-size: 18px;
    font-weight: 800;
    box-shadow: 0 8px 18px rgba(22,163,74,.28);
  }
  .mobile-primary-action:hover { text-decoration: none; }
  .mobile-action-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-top: 12px;
  }
  .mobile-action {
    min-height: 116px;
    padding: 14px;
    border: 1px solid #d8dee8;
    border-radius: 16px;
    background: #fff;
    color: var(--text);
    box-shadow: var(--shadow);
  }
  .mobile-action:hover { text-decoration: none; }
  .mobile-action span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    margin-bottom: 10px;
    border-radius: 12px;
    background: #edf4ff;
    color: var(--brand);
    font-size: 22px;
    font-weight: 900;
  }
  .mobile-action b,
  .mobile-action small { display: block; }
  .mobile-action b { font-size: 18px; }
  .mobile-action small {
    margin-top: 4px;
    color: var(--muted);
    font-size: 13px;
    line-height: 1.25;
  }
  .mobile-signal-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin-top: 12px;
  }
  .mobile-signal-row a {
    padding: 12px 8px;
    border-radius: 14px;
    background: #fff;
    color: var(--text);
    text-align: center;
    border: 1px solid #d8dee8;
  }
  .mobile-signal-row a:hover { text-decoration: none; }
  .mobile-signal-row b {
    display: block;
    font-size: 22px;
    line-height: 1;
    color: var(--brand);
  }
  .mobile-signal-row span {
    display: block;
    margin-top: 5px;
    color: var(--muted);
    font-size: 12px;
  }
  .mobile-more {
    margin-top: 12px;
    border-radius: 14px;
    background: #fff;
    border: 1px solid #d8dee8;
    overflow: hidden;
  }
  .mobile-more summary {
    min-height: 50px;
    padding: 14px;
    font-weight: 800;
    cursor: pointer;
  }
  .mobile-more div {
    display: grid;
    border-top: 1px solid var(--border);
  }
  .mobile-more a {
    padding: 14px;
    color: var(--text);
    border-bottom: 1px solid var(--border);
    font-weight: 700;
  }
  .mobile-more a:last-child { border-bottom: 0; }
  .mobile-more a:hover { text-decoration: none; background: #f8fafc; }
  .mobile-tabbar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 900;
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    padding: 7px 8px calc(7px + env(safe-area-inset-bottom));
    background: rgba(255,255,255,.96);
    border-top: 1px solid #d8dee8;
    box-shadow: 0 -8px 24px rgba(15,23,42,.10);
    backdrop-filter: blur(14px);
  }
  .mobile-tabbar a {
    display: flex;
    min-width: 0;
    min-height: 52px;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    border-radius: 13px;
    color: #64748b;
    font-size: 11px;
    font-weight: 800;
  }
  .mobile-tabbar a:hover { text-decoration: none; }
  .mobile-tabbar a.active {
    background: #e8f1ff;
    color: var(--brand);
  }
  .mobile-tabbar span {
    font-size: 22px;
    line-height: 1;
  }
  .mobile-tabbar b {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 11px;
  }
  .panel {
    padding: 16px;
    border-radius: 16px;
    box-shadow: none;
    border: 1px solid #d8dee8;
  }
  .sale-layout { display: block; }
  .sale-column { min-width: 0; }
  .search-box input {
    min-height: 58px;
    font-size: 20px;
    border-radius: 14px;
  }
  .search-item {
    align-items: flex-start;
    padding: 14px;
    border-radius: 14px;
  }
  .search-item .name { font-size: 17px; }
  .search-item .price { font-size: 19px; }
  .form-grid { grid-template-columns: 1fr; gap: 12px; }
  input, select, textarea {
    min-height: 48px;
    font-size: 17px;
  }
  .btn {
    min-height: 48px;
    border-radius: 14px;
    font-size: 17px;
  }
  .btn.big {
    min-height: 58px;
    font-size: 20px;
  }
  .cart-item {
    grid-template-columns: 1fr 74px 88px 48px;
    gap: 8px;
    padding: 12px 0;
  }
  .cart-item .ci-name {
    font-size: 16px;
    line-height: 1.2;
  }
  .cart-item input {
    width: 100%;
    min-height: 44px;
    padding: 8px;
    font-size: 16px;
  }
  .cart-item .btn.sm {
    min-height: 44px;
    padding: 8px;
  }
  .cart-total {
    padding: 12px 0;
    font-size: 26px;
    text-align: left;
  }
  .sale-checkout-panel {
    position: sticky;
    bottom: 78px;
    z-index: 20;
    margin-bottom: 10px;
    border-color: #cfd8e6;
  }
  .checkout-submit { margin-top: 12px; }
  table {
    display: block;
    overflow-x: auto;
    border-radius: 14px;
    -webkit-overflow-scrolling: touch;
  }
  th, td { padding: 10px; font-size: 15px; white-space: nowrap; }
  .hide-mobile { display: none; }
}

.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--green); color: #fff; padding: 16px 28px; border-radius: 12px;
  font-size: 20px; font-weight: 700; box-shadow: var(--shadow-lg); z-index: 1000;
  opacity: 0; pointer-events: none; transition: opacity .25s ease;
}
.toast.show { opacity: 1; }
.toast.error { background: var(--red); }
