/* greatpower — бело-серый минималистичный дизайн */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

:root {
  --bg: #ffffff;
  --bg-subtle: #f7f7f8;
  --bg-card: #ffffff;
  --border: #e5e5e8;
  --border-hover: #d4d4d8;
  --text: #18181b;
  --text-muted: #71717a;
  --text-faint: #a1a1aa;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --accent-soft: #eff6ff;
  --success: #4b9668;
  --danger: #dc2626;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(0,0,0,0.04), 0 1px 3px rgba(0,0,0,0.06);
  --shadow-hover: 0 4px 12px rgba(0,0,0,0.08), 0 2px 4px rgba(0,0,0,0.04);
  --sidebar-w: 232px;
  --sidebar-active-bg: #e4e4e7;
  --sidebar-active-text: #18181b;
  --cta-bg: #27272a;
  --cta-text: #ffffff;
  --input-bg: #ffffff;
  --stock-in-bg: #eaf5ee;
  --stock-out-bg: #fbeceb;
}

[data-theme="dark"] {
  --sidebar-active-bg: #2a2a2e;
  --sidebar-active-text: #ffffff;
  --input-bg: #1c1c1f;
  --stock-in-bg: #16261c;
  --stock-out-bg: #2a1a1a;
  --bg: #121214;
  --bg-subtle: #1b1b1e;
  --bg-card: #18181b;
  --border: #2b2b2f;
  --border-hover: #3a3a3f;
  --text: #f4f4f5;
  --text-muted: #a1a1aa;
  --text-faint: #6b6b71;
  --accent: #3b82f6;
  --accent-hover: #60a5fa;
  --accent-soft: #1e293b;
  --success: #5fb37e;
  --danger: #ef4444;
  --shadow: 0 1px 2px rgba(0,0,0,0.3), 0 1px 3px rgba(0,0,0,0.4);
  --shadow-hover: 0 4px 16px rgba(0,0,0,0.5), 0 2px 6px rgba(0,0,0,0.3);
}

[data-theme="dark"] body { background: var(--bg); }
[data-theme="dark"] .card-image-placeholder { background: linear-gradient(135deg, #232326, #1a1a1c); }

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

body { transition: background-color 0.2s, color 0.2s; }

a { color: inherit; text-decoration: none; }

.layout {
  display: flex;
  min-height: 100vh;
}

/* ---------- Sidebar ---------- */

.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  border-right: 1px solid var(--border);
  background: var(--bg-card);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 20px 16px;
  font-weight: 800;
  font-size: 16.5px;
  letter-spacing: -0.02em;
}

.logo-mark {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--bg);
  font-weight: 800;
  font-size: 14px;
  flex-shrink: 0;
}

.sidebar-balance {
  margin: 4px 16px 16px;
  padding: 12px 14px;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.sidebar-balance .label { font-size: 11.5px; color: var(--text-faint); text-transform: uppercase; letter-spacing: 0.03em; margin-bottom: 3px; }
.sidebar-balance .value { font-size: 17px; font-weight: 800; }
.sidebar-balance a { display: block; margin-top: 8px; }

.sidebar-nav {
  flex: 1;
  padding: 4px 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sidebar-section-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-faint);
  font-weight: 700;
  padding: 14px 10px 6px;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  font-weight: 500;
  font-size: 14px;
  color: var(--text-muted);
  transition: all 0.13s;
}
.sidebar-link svg { flex-shrink: 0; opacity: 0.85; }
.sidebar-link:hover { background: var(--bg-subtle); color: var(--text); }
.sidebar-link.active { background: var(--sidebar-active-bg); color: var(--sidebar-active-text); }
.sidebar-link.active svg { opacity: 1; }

.sidebar-footer {
  padding: 12px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.theme-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text-muted);
  background: none;
  border: none;
  width: 100%;
  font-family: inherit;
}
.theme-toggle:hover { background: var(--bg-subtle); color: var(--text); }

/* ---------- Main content area ---------- */

.main-area {
  flex: 1;
  min-width: 0;
}

.topbar {
  height: 60px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  gap: 10px;
  position: sticky;
  top: 0;
  background: rgba(255,255,255,0.85);
  backdrop-filter: blur(8px);
  z-index: 40;
}
[data-theme="dark"] .topbar { background: rgba(18,18,20,0.85); }

.topbar-icon-btn {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  transition: all 0.15s;
}
.topbar-icon-btn:hover { background: var(--bg-subtle); color: var(--text); }

.notif-badge {
  position: absolute;
  top: 2px;
  right: 2px;
  min-width: 16px;
  height: 16px;
  padding: 0 3px;
  border-radius: 999px;
  background: var(--success);
  color: white;
  font-size: 10px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  border: 2px solid var(--bg-card);
}

.dropdown-wrap { position: relative; }

.dropdown-menu {
  display: none;
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 220px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-hover);
  z-index: 60;
  overflow: hidden;
}
.dropdown-menu.open { display: block; }

.dropdown-header {
  padding: 12px 16px;
  font-weight: 700;
  font-size: 13.5px;
  border-bottom: 1px solid var(--border);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text-muted);
  transition: all 0.12s;
}
.dropdown-item:hover { background: var(--bg-subtle); color: var(--text); }

/* ---------- Toast (добавлено в корзину) ---------- */

.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 18px;
  background: var(--stock-in-bg);
  color: var(--success);
  border: 1px solid var(--success);
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-weight: 600;
  box-shadow: var(--shadow-hover);
  opacity: 0;
  transform: translateY(10px);
  transition: all 0.25s ease;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast-icon { display: flex; flex-shrink: 0; }

.btn-added {
  background: var(--stock-in-bg) !important;
  color: var(--success) !important;
  border: 1px solid var(--success) !important;
}

/* ---------- Модальные окна (FAQ, и т.д.) ---------- */

.modal-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 80;
}
.modal-backdrop.open { display: block; }

.modal-box {
  display: none;
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 90%;
  max-width: 380px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-hover);
  z-index: 90;
  overflow: hidden;
}
.modal-box.open { display: block; }

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
}
.modal-body { padding: 20px; }

.faq-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.faq-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 18px 10px;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  transition: all 0.15s;
}
.faq-tile:hover { border-color: var(--accent); color: var(--accent); }

/* ---------- Корзина-шторка (выезжает справа) ---------- */

.drawer-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 85;
}
.drawer-backdrop.open { display: block; }

.cart-drawer {
  position: fixed;
  top: 0;
  right: 0;
  height: 100vh;
  width: 380px;
  max-width: 92vw;
  background: var(--bg-card);
  border-left: 1px solid var(--border);
  z-index: 95;
  transform: translateX(100%);
  transition: transform 0.25s ease;
  display: flex;
  flex-direction: column;
}
.cart-drawer.open { transform: translateX(0); box-shadow: -8px 0 24px rgba(0,0,0,0.2); }

.cart-drawer-body { flex: 1; overflow-y: auto; padding: 16px 20px; }

.cart-drawer-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.cart-drawer-row:last-child { border-bottom: none; }
.cart-drawer-row-info { font-size: 13.5px; }
.cart-drawer-row-price { font-weight: 700; font-size: 13.5px; white-space: nowrap; }

/* ---------- Переключатель плитка/список ---------- */

.view-toggle {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.view-toggle button {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 34px;
  background: var(--bg-card);
  border: none;
  color: var(--text-muted);
  cursor: pointer;
}
.view-toggle button.active { background: var(--sidebar-active-bg); color: var(--sidebar-active-text); }
.view-toggle button:not(:last-child) { border-right: 1px solid var(--border); }

.list-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
  transition: all 0.15s;
}
.list-row:hover { border-color: var(--border-hover); background: var(--bg-subtle); }
.list-row-thumb { width: 44px; height: 44px; border-radius: 8px; object-fit: cover; flex-shrink: 0; background: var(--bg-subtle); }
.list-row-thumb-placeholder {
  width: 44px; height: 44px; border-radius: 8px; flex-shrink: 0;
  background: var(--bg-subtle); display: flex; align-items: center; justify-content: center; color: var(--text-faint);
}
.list-row-title { font-weight: 600; font-size: 14px; flex: 1; }

.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 32px;
}

.balance-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-weight: 600;
  font-size: 13.5px;
}

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 14px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}

.btn-primary {
  background: var(--cta-bg);
  color: var(--cta-text);
}
.btn-primary:hover { background: #3f3f46; }

.btn-secondary {
  background: var(--bg-card);
  color: var(--text);
  border-color: var(--border);
}
.btn-secondary:hover { border-color: var(--border-hover); background: var(--bg-subtle); }

.btn-accent {
  background: var(--accent);
  color: white;
}
.btn-accent:hover { background: var(--accent-hover); }

.btn-sm { padding: 7px 14px; font-size: 13px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ---------- Cards / Grid ---------- */

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: all 0.18s;
  display: block;
}

.card:hover {
  border-color: var(--border-hover);
  box-shadow: var(--shadow-hover);
  transform: translateY(-2px);
}

.card-image {
  width: 100%;
  aspect-ratio: 16/9;
  object-fit: cover;
  background: var(--bg-subtle);
  display: block;
}

.card-image-placeholder {
  width: 100%;
  aspect-ratio: 16/9;
  background: linear-gradient(135deg, #f0f0f2, #e4e4e7);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  color: var(--text-faint);
}

.card-body {
  padding: 14px 16px;
}

.card-title {
  font-weight: 600;
  font-size: 14.5px;
  margin: 0 0 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.card-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 13px;
  color: var(--text-muted);
}

.flag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  background: var(--bg-subtle);
  border-radius: 999px;
  font-weight: 600;
  font-size: 12px;
}

.region-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px 3px 6px;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-weight: 700;
  font-size: 12px;
}
.region-badge img { width: 18px; height: 13px; border-radius: 2px; object-fit: cover; display: block; }

/* ---------- Section type tiles (homepage) ---------- */

.type-tiles {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
}

.type-tile {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px 24px;
  text-align: left;
  transition: all 0.18s;
}

.type-tile:hover {
  border-color: var(--text);
  box-shadow: var(--shadow-hover);
  transform: translateY(-3px);
}

.type-tile-icon {
  font-size: 32px;
  margin-bottom: 16px;
}

.type-tile-title {
  font-weight: 700;
  font-size: 19px;
  margin: 0 0 6px;
}

.type-tile-count {
  color: var(--text-muted);
  font-size: 14px;
}

/* ---------- Breadcrumbs ---------- */

.breadcrumbs {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13.5px;
  color: var(--text-muted);
  margin-bottom: 24px;
  flex-wrap: wrap;
}
.breadcrumbs a:hover { color: var(--text); }
.breadcrumbs .sep { color: var(--text-faint); }

/* ---------- Page heading ---------- */

.page-title {
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin: 0 0 24px;
}

/* ---------- Product detail ---------- */

.product-hero {
  display: grid;
  grid-template-columns: 340px 1fr;
  gap: 32px;
  margin-bottom: 32px;
}

.product-banner {
  width: 100%;
  border-radius: var(--radius);
  aspect-ratio: 16/9;
  object-fit: cover;
  background: var(--bg-subtle);
}

.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 20px;
}

.tab {
  padding: 10px 18px;
  font-weight: 600;
  font-size: 14px;
  color: var(--text-muted);
  border-bottom: 2px solid transparent;
  cursor: pointer;
  margin-bottom: -1px;
  background: none;
  border-left: none;
  border-right: none;
  border-top: none;
}

.tab.active {
  color: var(--text);
  border-bottom-color: var(--text);
}

table.items-table {
  width: 100%;
  border-collapse: collapse;
}

.items-table th {
  text-align: left;
  font-size: 12.5px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-faint);
  font-weight: 600;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}

.items-table td {
  padding: 14px 12px;
  border-bottom: 1px solid var(--border);
  font-size: 14.5px;
}

.items-table tr:hover td { background: var(--bg-subtle); }

.stock-badge svg, .btn svg, .page-title svg, .card-title svg { vertical-align: -3px; }
.icon-row { display: inline-flex; align-items: center; gap: 8px; }
.icon-row-sm { display: inline-flex; align-items: center; gap: 6px; }
.stock-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 13px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 999px;
}
.stock-in { background: var(--stock-in-bg); color: var(--success); }
.stock-out { background: var(--stock-out-bg); color: var(--danger); }

/* ---------- Forms ---------- */

.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 13.5px; font-weight: 600; margin-bottom: 6px; }
.form-input, .form-select, .form-textarea {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14.5px;
  font-family: inherit;
  background: var(--input-bg);
  color: var(--text);
  transition: border-color 0.15s;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  outline: none;
  border-color: var(--accent);
}

/* ---------- Auth / centered box ---------- */

.center-box {
  max-width: 400px;
  margin: 64px auto;
  padding: 40px 32px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-align: center;
}

/* ---------- Misc ---------- */

.muted { color: var(--text-muted); }
.section { padding: 40px 0; }
.empty-state {
  text-align: center;
  padding: 80px 20px;
  color: var(--text-muted);
}
.empty-state-icon { font-size: 40px; margin-bottom: 12px; }

.alert {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  margin-bottom: 16px;
}
.alert-success { background: var(--stock-in-bg); color: var(--success); border: 1px solid var(--success); }
.alert-error { background: var(--stock-out-bg); color: var(--danger); border: 1px solid var(--danger); }
.alert-info { background: var(--accent-soft); color: var(--accent-hover); border: 1px solid #bfdbfe; }

.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-top: 32px;
}
.pagination a, .pagination span {
  min-width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-weight: 600;
  border: 1px solid var(--border);
}
.pagination a:hover { background: var(--bg-subtle); }
.pagination .current { background: var(--cta-bg); color: var(--cta-text); border-color: var(--cta-bg); }

.footer {
  border-top: 1px solid var(--border);
  padding: 32px 0;
  margin-top: 64px;
  color: var(--text-faint);
  font-size: 13px;
  text-align: center;
}

/* ---------- Мобильное меню (бургер + off-canvas сайдбар) ---------- */

.mobile-menu-btn, .mobile-close-btn {
  display: none;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  color: var(--text);
  cursor: pointer;
  padding: 6px;
  border-radius: var(--radius-sm);
}
.mobile-menu-btn:hover, .mobile-close-btn:hover { background: var(--bg-subtle); }

.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 55;
}
.sidebar-backdrop.open { display: block; }

@media (max-width: 900px) {
  .mobile-menu-btn { display: flex; }
  .mobile-close-btn { display: flex; margin-left: auto; }

  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    height: 100vh;
    z-index: 60;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    box-shadow: none;
  }
  .sidebar.open {
    transform: translateX(0);
    box-shadow: 8px 0 24px rgba(0,0,0,0.25);
  }

  .sidebar-logo { justify-content: space-between; }

  .main-area { width: 100%; min-width: 0; }

  .container { padding: 0 16px; }
  .section { padding: 20px 0; }

  .topbar { padding: 0 14px; gap: 8px; }
  .topbar form { flex: 1; }
  .topbar input[type="text"] { width: 100% !important; }

  .page-title { font-size: 21px; }

  .type-tiles { grid-template-columns: 1fr; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
  .product-hero { grid-template-columns: 1fr; gap: 20px; }

  /* Таблицы (номиналы, заказы, транзакции) на мобильном скроллятся горизонтально,
     а не ломают вёрстку и не вылезают за экран. */
  .items-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .items-table { min-width: 480px; }

  .dropdown-menu { min-width: 180px; }
  .toast-container { left: 12px; right: 12px; bottom: 12px; }
  .toast { width: 100%; }
}

@media (max-width: 480px) {
  .grid { grid-template-columns: 1fr 1fr; }
  .center-box { margin: 32px 16px; padding: 28px 20px; }
}
