/* Box sizing для всех элементов — важно для точного расчёта ширины */
*,
*::before,
*::after {
  box-sizing: border-box;
}

/* Базовые сбросы */
html, body {
  height: 100%;
  margin: 0;
  padding: 0;
}

:root{
  /* Можно вынести цвета в переменные для удобства изменения темы */
  --bg: #0f1720;
  --card-bg: #0b1220;
  --muted-border: #1f2a37;
  --control-bg: #071025;
  --text: #e6eef8;
  --muted-text: #9fb0c8;
  --link: #7cc0ff;
  --btn-bg: #545454;
  --ghost-border: #334155;

  /* Sidebar */
  --sidebar-bg: #0e182b;
  --sidebar-width: 200px;
  --sidebar-collapsed: 60px;
}

/* Тело страницы */
body{
  font-family: Inter, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  padding: 12px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  line-height: 1.35;
  display: flex;
  overflow-x: hidden;
}

/* --- ЛЕВОЕ ВЫДВИЖНОЕ МЕНЮ --- */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  height: 100%;
  width: var(--sidebar-collapsed);
  background: var(--sidebar-bg);
  border-right: 1px solid var(--muted-border);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding-top: 12px;
  transition: width 0.25s ease;
  overflow: hidden;
  z-index: 1000;
}

.sidebar.open {
  width: var(--sidebar-width);
}

.sidebar .toggle-btn {
  background: none;
  border: none;
  color: var(--link);
  font-size: 24px;
  cursor: pointer;
  margin-bottom: 16px;
  transition: transform 0.3s;
}

.sidebar.open .toggle-btn {
  transform: rotate(90deg);
}

.sidebar a {
  display: flex;
  align-items: center;
  width: 100%;
  padding: 10px 14px;
  color: var(--text);
  text-decoration: none;
  border-radius: 6px;
  gap: 10px;
  white-space: nowrap;
  transition: background 0.2s;
}

.sidebar a:hover {
  background: #162238;
}

.sidebar a span {
  opacity: 0;
  transition: opacity 0.2s ease;
}

.sidebar.open a span {
  opacity: 1;
}

/* --- ОСНОВНОЙ КОНТЕНТ --- */
.content {
  flex: 1;
  margin-left: var(--sidebar-collapsed);
  transition: margin-left 0.25s ease;
  padding: 12px;
  box-sizing: border-box;
  width: 100%;
}

.sidebar.open ~ .content {
  margin-left: var(--sidebar-width);
}

/* Ссылки */
a {
  color: var(--link);
  text-decoration: none;
  margin-right: 12px;
}

/* Заголовки */
h2 { margin: 12px 0; }

/* Кнопки */
.btn {
  background: var(--btn-bg);
  border: none;
  padding: 10px 14px;
  border-radius: 6px;
  color: white;
  cursor: pointer;
  font: inherit;
  line-height: 1;
}
.btn.ghost {
  background: transparent;
  border: 1px solid var(--ghost-border);
}

/* Акцент (например просрочено) */
.expired {
  color: #ffcc00;
  font-weight: bold;
  animation: blink 1s infinite;
  margin-top: 8px;
}

/* Учитываем users who prefer reduced motion */
@media (prefers-reduced-motion: reduce) {
  .expired { animation: none; }
}
@keyframes blink { 50% { opacity: 0; } }

/* Мелкий текст */
.small { font-size: 13px; color: var(--muted-text); }

/* Header */
header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  gap: 12px;
  flex-wrap: wrap;
}

/* Сетка карточек */
.grid {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: center;
  align-items: flex-start;
  margin-top: 8px;
}

/* Карточка */
.card {
  background: var(--card-bg);
  border: 1px solid var(--muted-border);
  border-radius: 8px;
  padding: 12px;
  width: 320px;
  max-width: 100%;
  box-shadow: 0 1px 0 rgba(255,255,255,0.01);
}

/* Картинка внутри карточки */
.card img {
  width: 100%;
  height: 140px;
  object-fit: cover;
  border-radius: 6px;
  display: block;
}

/* Формы и контролы */
input, button, select, textarea {
  padding: 8px;
  border-radius: 6px;
  border: 1px solid #334155;
  background: var(--control-bg);
  color: var(--text);
  font-size: 15px;
  font-family: inherit;
  outline: none;
}

input:focus, button:focus, select:focus, textarea:focus {
  box-shadow: 0 0 0 3px rgba(124,192,255,0.12);
  border-color: var(--link);
}

input::placeholder { color: #7f98af; }

button { cursor: pointer; font: inherit; }

form.inline { display: flex; flex-direction: column; gap: 8px; }

/* Row — гибкая строка с переносом */
.row {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.row > * {
  flex: 1 1 140px;
  min-width: 96px;
}
.row button { flex: 0 0 auto; }

.qty {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: transparent;
  flex: 0 0 auto;
}
.qty input[type="number"]{
  width: 110px;
  min-width: 72px;
  -moz-appearance: textfield;
  text-align: center;
  padding: 6px;
}
.qty input[type="number"]::-webkit-outer-spin-button,
.qty input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.qty button.qty-btn{
  width: 44px;
  height: 44px;
  font-size: 20px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  border: 1px solid #334155;
  background: #0b1624;
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: rgba(0,0,0,0);
  touch-action: manipulation;
}
.qty button.qty-btn:active { transform: translateY(1px); }
.qty.large button.qty-btn{ width: 44px; height: 44px; font-size: 22px; }

.card .row { margin-top: 4px; }
.card input[name="name"],
.card input[name="image"] {
  min-width: 120px;
  flex: 1 1 120px;
}

/* Notification */
#notification {
  position: fixed;
  bottom: 10px;
  right: 10px;
  background: rgba(40,40,40,0.95);
  color: var(--text);
  padding: 10px 14px;
  border-radius: 6px;
  display: none;
  z-index: 3000;
  font-size: 18px;
  box-shadow: 0 6px 18px rgba(0,0,0,0.6);
}

/* Таблица */
table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 12px;
}
th, td {
  padding: 8px;
  border-bottom: 1px solid #0b1220;
  text-align: left;
}

/* Контролы */
.controls { display: flex; gap: 8px; margin-bottom: 8px; }

/* Медиазапросы для очень узких экранов */
@media (max-width: 420px) {
  body { padding: 10px; }
  header { gap: 8px; }
  .card { width: calc(100% - 24px); }
  .qty input[type="number"] { width: 92px; }
  .row > * { flex: 1 1 100%; min-width: 0; }
  .row button { width: 100%; }
  .grid { gap: 10px; }
}

/* Разделитель в меню */
.menu-sep {
  width: 80%;
  border: none;
  border-top: 1px solid var(--muted-border);
  margin: 12px auto;
  opacity: 0.5;
}

/* Кнопка-переключатель вида */
.toggle-view-btn {
  background: transparent;
  border: none;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  width: 100%;
  cursor: pointer;
  text-align: left;
  border-radius: 6px;
  transition: background 0.2s;
  font: inherit;
}

.toggle-view-btn:hover {
  background: #162238;
}

.sidebar:not(.open) .toggle-view-btn .label {
  display: none;
}