:root {
  --bg: #f4f6fb;
  --card: #ffffff;
  --ink: #1d2433;
  --muted: #6b7385;
  --line: #e3e7f0;
  --primary: #3b6fd1;
  --primary-dark: #2c58ad;
  --green: #2faa6a;
  --danger: #d1495b;
  --radius: 16px;
  --shadow: 0 4px 20px rgba(30, 45, 90, 0.08);
}

* { box-sizing: border-box; }

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

.hidden { display: none !important; }
.muted { color: var(--muted); }
.error { color: var(--danger); margin: 4px 0; }

/* --- Кнопки --- */
button { font-family: inherit; cursor: pointer; }

.btn-primary {
  width: 100%;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 12px;
  padding: 14px;
  font-size: 18px;
  font-weight: 600;
  transition: background 0.15s;
}
.btn-primary:hover { background: var(--primary-dark); }

.btn-ghost {
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 14px;
  color: var(--ink);
  font-size: 15px;
}
.btn-ghost:hover { background: #f0f2f8; }

/* --- Экран входа --- */
#login-view {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.login-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 32px;
  width: 100%;
  max-width: 360px;
  text-align: center;
}
.login-card .logo { font-size: 52px; }
.login-card h1 { margin: 8px 0 2px; font-size: 24px; }
.login-card form { text-align: left; margin-top: 18px; }

/* --- Поля ввода --- */
label {
  display: block;
  font-size: 14px;
  color: var(--muted);
  margin-bottom: 12px;
  font-weight: 500;
}
input[type="text"], input[type="password"], input[type="number"] {
  width: 100%;
  margin-top: 5px;
  padding: 12px;
  font-size: 16px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fbfcfe;
  color: var(--ink);
}
input:focus { outline: 2px solid var(--primary); border-color: var(--primary); }

/* --- Шапка --- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  background: var(--card);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 10;
}
.brand { font-size: 19px; font-weight: 700; }

main {
  max-width: 640px;
  margin: 0 auto;
  padding: 18px 16px 60px;
}

.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 20px;
}
.add-form h2 { margin: 0 0 14px; font-size: 19px; }

/* --- Сворачиваемая форма добавления --- */
.add-header {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: transparent;
  border: none;
  padding: 0;
  font-size: 19px;
  font-weight: 700;
  color: var(--ink);
}
.add-header .chevron {
  font-size: 16px;
  color: var(--muted);
  transition: transform 0.2s;
}
.add-form:not(.collapsed) .add-header .chevron { transform: rotate(180deg); }
.add-body { margin-top: 16px; }
.add-form.collapsed .add-body { display: none; }

.field { margin-bottom: 16px; }
.field-label {
  display: block;
  font-size: 14px;
  color: var(--muted);
  font-weight: 500;
  margin-bottom: 8px;
}

.row { display: flex; gap: 12px; }
.row .grow { flex: 1; }
.row .qty { width: 90px; flex-shrink: 0; }

/* --- Чипсы выбора --- */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 13px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fbfcfe;
  font-size: 15px;
  color: var(--ink);
  transition: all 0.12s;
}
.chip:hover { border-color: var(--primary); }
.chip.selected {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}
.chip .swatch {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 1px solid rgba(0,0,0,0.15);
  flex-shrink: 0;
}

/* --- Вкладки --- */
.tabs { display: flex; gap: 8px; margin-bottom: 14px; }
.tab {
  flex: 1;
  padding: 11px;
  border: 1px solid var(--line);
  background: var(--card);
  border-radius: 12px;
  font-size: 15px;
  font-weight: 600;
  color: var(--muted);
}
.tab.active { background: var(--ink); color: #fff; border-color: var(--ink); }

/* --- Фильтр --- */
.filter-bar { display: flex; flex-wrap: wrap; gap: 7px; margin-bottom: 14px; }
.filter-bar .chip { padding: 6px 11px; font-size: 14px; }

/* --- Список --- */
.list { display: flex; flex-direction: column; gap: 10px; }
.item {
  background: var(--card);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 14px;
}
.item.washed { opacity: 0.6; }
.item .icon { font-size: 28px; flex-shrink: 0; }
.item .info { flex: 1; min-width: 0; }
.item .title { font-weight: 600; }
.item .sub { font-size: 13px; color: var(--muted); margin-top: 2px; }
.item .badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  background: #eef1f8;
  padding: 2px 8px;
  border-radius: 999px;
  margin-right: 4px;
}
.item .badge .swatch {
  width: 11px; height: 11px; border-radius: 50%;
  border: 1px solid rgba(0,0,0,0.15);
}
.item .qty-pill {
  font-size: 13px; font-weight: 700; color: var(--primary);
}
.item .actions { display: flex; gap: 8px; flex-shrink: 0; }
.icon-btn {
  border: none;
  background: #f0f2f8;
  border-radius: 10px;
  width: 40px; height: 40px;
  font-size: 18px;
  display: grid;
  place-items: center;
}
.icon-btn.wash { background: #e6f6ee; }
.icon-btn.wash:hover { background: var(--green); }
.icon-btn.undo:hover { background: #ffe9b8; }
.icon-btn.edit:hover { background: #e3ecfb; }
.icon-btn.del:hover { background: #fbe0e4; }

/* --- Модальное окно --- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(20, 28, 48, 0.5);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 24px 16px;
  overflow-y: auto;
  z-index: 100;
}
.modal {
  width: 100%;
  max-width: 560px;
  margin: auto;
}
.modal h2 { margin: 0 0 16px; font-size: 20px; }
.modal-actions {
  display: flex;
  gap: 12px;
  margin-top: 8px;
}
.modal-actions .btn-ghost { flex: 1; padding: 14px; font-size: 16px; }
.modal-actions .btn-primary { flex: 2; width: auto; }

.empty { text-align: center; color: var(--muted); padding: 40px 0; font-size: 18px; }

@media (max-width: 420px) {
  body { font-size: 16px; }
  .item .actions { flex-direction: column; }
}
