/* ==========================================================================
   Дизайн-система платформы совместных закупок
   Минимализм + зелёный акцент, mobile-first, без фреймворков.
   ========================================================================== */

/* --- Токены --- */
:root {
  --bg: #f8faf9;
  --surface: #ffffff;
  --text: #1b2a20;
  --muted: #6b7280;
  --accent: #16a34a;
  --accent-hover: #15803d;
  --accent-bg: #dcfce7;
  --border: #e5e7eb;
  --danger: #dc2626;
  --info: #2563eb;
  --radius-card: 12px;
  --radius-btn: 8px;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
}

/* --- Сброс и база --- */
* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--text);
  background: var(--bg);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

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

img { max-width: 100%; display: block; }

h1 { font-size: 1.5rem; margin: 0 0 1rem; }
h2 { font-size: 1.15rem; margin: 1.5rem 0 0.75rem; }

.cat-title {
  font-size: 0.95rem;
  color: var(--muted);
  margin: 1.25rem 0 0.5rem;
  font-weight: 600;
}

.container {
  max-width: 1080px;
  margin: 0 auto;
  padding: 1.25rem 1rem;
}

.muted { color: var(--muted); font-size: 0.9rem; }
.error { color: var(--danger); }

/* --- Шапка --- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.topbar__inner {
  max-width: 1080px;
  margin: 0 auto;
  padding: 0.75rem 1rem;
  display: flex;
  align-items: center;
  gap: 1rem;
}

.brand {
  font-weight: 700;
  font-size: 1.05rem;
}
.brand a { color: var(--text); }
.brand a:hover { text-decoration: none; }

.nav { display: flex; gap: 0.25rem; }
.nav a {
  color: var(--text);
  padding: 0.4rem 0.75rem;
  border-radius: 8px;
  font-weight: 500;
}
.nav a:hover { background: var(--bg); text-decoration: none; }
.nav a.is-active { background: var(--accent-bg); color: var(--accent-hover); }

.topbar__actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.username { font-weight: 600; }

.badge {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.1rem 0.55rem;
  border-radius: 999px;
  background: var(--accent-bg);
  color: var(--accent-hover);
}
.badge--muted { background: #f3f4f6; color: var(--muted); }
.badge--danger { background: #fee2e2; color: var(--danger); }
.badge--info { background: #dbeafe; color: var(--info); }

/* Бургер (мобильная навигация) */
.burger {
  display: none;
  margin-left: auto;
  background: none;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.4rem 0.6rem;
  cursor: pointer;
  font-size: 1.1rem;
  line-height: 1;
  color: var(--text);
}

@media (max-width: 640px) {
  .nav {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    flex-direction: column;
    padding: 0.5rem;
  }
  .nav.is-open { display: flex; }
  .burger { display: block; }
  .topbar__actions .username { display: none; }
}

/* --- Кнопки --- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.55rem 0.9rem;
  border: 1px solid transparent;
  border-radius: var(--radius-btn);
  font: inherit;
  font-weight: 500;
  cursor: pointer;
  background: var(--accent);
  color: #fff;
}
.btn:hover { background: var(--accent-hover); text-decoration: none; }
.btn--secondary {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border);
}
.btn--secondary:hover { background: var(--bg); }
.btn--danger { background: var(--danger); }
.btn--sm { padding: 0.3rem 0.6rem; font-size: 0.85rem; }

.btn-link {
  background: none;
  border: none;
  color: var(--accent);
  font: inherit;
  cursor: pointer;
  padding: 0;
}
.btn-link:hover { text-decoration: underline; }

/* --- Формы --- */
.form {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  max-width: 400px;
}
.form label {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.9rem;
  color: var(--muted);
}
.form input, .form select, .form textarea {
  padding: 0.55rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-btn);
  font: inherit;
  color: var(--text);
  background: var(--surface);
}
.form input:focus, .form select:focus, .form textarea:focus {
  outline: 2px solid var(--accent-bg);
  border-color: var(--accent);
}
.form .checkbox {
  flex-direction: row;
  align-items: center;
  gap: 0.4rem;
}

/* --- Сетка карточек --- */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 1rem;
}

/* --- Карточка (товар / закупка / поставщик) --- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  overflow: hidden;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
}
.card a.card__link { color: inherit; }
.card a.card__link:hover { text-decoration: none; }

.card__img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  background: #f3f4f6;
}

.card__body { padding: 0.75rem; display: flex; flex-direction: column; gap: 0.4rem; flex: 1; }

.card__title {
  font-weight: 600;
  font-size: 0.95rem;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card__price { font-weight: 700; font-size: 1.05rem; }

.card__meta { color: var(--muted); font-size: 0.85rem; }

.card__foot { margin-top: auto; display: flex; gap: 0.4rem; flex-wrap: wrap; }

/* --- Таблицы --- */
.table-wrap { overflow-x: auto; }

.table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  overflow: hidden;
}
.table th, .table td {
  text-align: left;
  padding: 0.6rem 0.75rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.table th { font-weight: 600; color: var(--muted); font-size: 0.85rem; }
.table tr:last-child td { border-bottom: none; }

.thumb {
  height: 2.25rem;
  width: 2.25rem;
  object-fit: cover;
  border-radius: 6px;
  vertical-align: middle;
  margin-right: 0.4rem;
}

/* --- Блоки --- */
.order, .act {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  padding: 1rem;
  margin-bottom: 1rem;
}

.actions {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  margin: 1rem 0;
  flex-wrap: wrap;
}

.inline { display: inline; }

.result {
  background: var(--accent-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.6rem 0.75rem;
}

.total { margin: 0.5rem 0; }

.add-item {
  display: flex;
  gap: 0.4rem;
  align-items: center;
  margin: 0.5rem 0;
  flex-wrap: wrap;
}
.add-item select, .add-item input {
  padding: 0.4rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font: inherit;
}

/* Счётчик количества в строке */
.qty-input { width: 4.5rem; padding: 0.3rem; border: 1px solid var(--border); border-radius: 6px; font: inherit; }

/* --- Кнопки внутри форм и панелей действий (совместимость) --- */
.form button {
  padding: 0.55rem 0.9rem;
  border: 1px solid transparent;
  border-radius: var(--radius-btn);
  font: inherit;
  font-weight: 500;
  cursor: pointer;
  background: var(--accent);
  color: #fff;
}
.form button:hover { background: var(--accent-hover); }

.actions button {
  padding: 0.5rem 0.75rem;
  border: 1px solid transparent;
  border-radius: var(--radius-btn);
  background: var(--accent);
  color: #fff;
  font: inherit;
  cursor: pointer;
}
.actions button.danger { background: var(--danger); }
.actions input[type="datetime-local"] {
  padding: 0.4rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font: inherit;
}

.order h2 { font-size: 1.1rem; margin-top: 0; }

.order-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border);
}
.order-row:last-child { border-bottom: none; }
.order-row__name { flex: 1; font-weight: 500; }
.order-row__sum { font-weight: 600; white-space: nowrap; }

.act-link { font-size: 0.85rem; font-weight: 400; margin-left: 0.5rem; }

.add-item button {
  padding: 0.4rem 0.6rem;
  border: 1px solid transparent;
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  font: inherit;
  cursor: pointer;
}
.add-item button:hover { background: var(--accent-hover); }
