:root {
  --bg: #f4f1e8;
  --panel: rgba(255, 252, 245, 0.9);
  --ink: #1c2a1f;
  --muted: #5d6d60;
  --line: rgba(28, 42, 31, 0.12);
  --accent: #c26a2e;
  --accent-2: #355f4a;
  --shadow: 0 24px 80px rgba(33, 40, 35, 0.12);
  --shadow-sm: 0 4px 20px rgba(33, 40, 35, 0.08);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: Georgia, "Iowan Old Style", "Palatino Linotype", serif;
  color: var(--ink);
  background:
    radial-gradient(circle at top left,  rgba(194, 106, 46, 0.18), transparent 28%),
    radial-gradient(circle at top right, rgba(53, 95, 74, 0.15),   transparent 30%),
    linear-gradient(180deg, #f8f5ee 0%, var(--bg) 100%);
}

.catalog-shell {
  max-width: 1400px;
  margin: 0 auto;
  padding: 32px 20px 64px;
}

/* ── Hero ──────────────────────────────────────────────────────────────────── */
.hero {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 24px;
  align-items: start;
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 28px;
  background: var(--panel);
  backdrop-filter: blur(14px);
  box-shadow: var(--shadow);
}

.hero h1 {
  margin: 0 0 12px;
  font-size: clamp(2.2rem, 5vw, 4.8rem);
  line-height: 0.95;
}

.hero p {
  margin: 0;
  color: var(--muted);
  font-size: 1.05rem;
}

.hero-meta { display: grid; gap: 12px; }

.pill {
  padding: 12px 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.66);
  color: var(--accent-2);
  font-size: 0.95rem;
}

.pill--live {
  border-color: var(--accent-2);
  color: var(--accent-2);
}

.pill--live::before {
  content: "";
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent-2);
  margin-right: 6px;
  animation: pulse-dot 2s ease-in-out infinite;
  vertical-align: middle;
}

.pill--offline {
  color: var(--muted);
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.3; }
}

/* ── Progress bar (fixed top of window) ─────────────────────────────────────── */
.progress-bar-container {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 9999;
  height: 3px;
  background: transparent;
  overflow: hidden;
  transition: opacity 0.4s ease;
}

.progress-bar-container.progress-done {
  opacity: 0;
}

/* ── Download badge ─────────────────────────────────────────────────────────── */
.download-badge {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 9998;
  padding: 10px 18px;
  border-radius: 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
  font-size: 0.875rem;
  color: var(--accent);
  backdrop-filter: blur(14px);
  animation: badge-in 0.2s ease;
}

.download-badge--out {
  animation: badge-out 0.3s ease forwards;
}

@keyframes badge-in {
  from { opacity: 0; transform: translateY(-10px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes badge-out {
  from { opacity: 1; transform: translateY(0); }
  to   { opacity: 0; transform: translateY(-10px); }
}

.progress-bar-fill {
  height: 100%;
  width: 0%;
  border-radius: 4px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
}

.progress-bar-fill.progress-active::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(255, 255, 255, 0.45) 40%,
    rgba(255, 255, 255, 0.45) 60%,
    transparent 100%
  );
  animation: shimmer 1.4s ease-in-out infinite;
}

@keyframes shimmer {
  0%   { transform: translateX(-100%); }
  100% { transform: translateX(200%); }
}

/* ── Two-column body ────────────────────────────────────────────────────────── */
.catalog-body {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 28px;
  align-items: start;
  margin-top: 28px;
}

.main-content { min-width: 0; }

/* ── Sidebar ────────────────────────────────────────────────────────────────── */
.sidebar {
  position: sticky;
  top: 24px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.78);
  box-shadow: var(--shadow-sm);
  padding: 16px 12px;
  max-height: calc(100vh - 80px);
  overflow-y: auto;
}

.sidebar-header {
  margin: 0 4px 10px;
  font-size: 0.72rem;
  font-weight: bold;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}

.cat-all {
  display: block;
  width: 100%;
  text-align: left;
  padding: 7px 10px;
  margin-bottom: 6px;
  border-radius: 10px;
  border: none;
  background: none;
  cursor: pointer;
  font-size: 0.9rem;
  font-family: inherit;
  color: var(--ink);
  min-width: unset;
}

.cat-all--active,
.cat-all:hover {
  background: rgba(194, 106, 46, 0.1);
  color: var(--accent);
}

.cat-empty {
  font-size: 0.85rem;
  color: var(--muted);
  padding: 6px 10px;
  margin: 0;
  font-style: italic;
}

/* Tree nodes */
.cat-node { margin: 1px 0; }

.cat-row {
  display: flex;
  align-items: center;
  gap: 2px;
  border-radius: 8px;
  padding: 1px 2px;
}

.cat-row--sel {
  background: rgba(194, 106, 46, 0.12);
}

.cat-toggle {
  width: 20px;
  height: 22px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--muted);
  font-size: 0.6rem;
  min-width: unset;
  border-radius: 4px;
  flex-shrink: 0;
}

.cat-toggle:hover { background: rgba(0, 0, 0, 0.06); }

.cat-indent {
  width: 20px;
  flex-shrink: 0;
  display: inline-block;
}

.cat-label {
  flex: 1;
  min-width: 0;
  text-align: left;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 0.88rem;
  font-family: inherit;
  padding: 4px 6px;
  border-radius: 7px;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: unset;
}

.cat-label:hover {
  background: rgba(0, 0, 0, 0.04);
  color: var(--accent);
}

.cat-row--sel .cat-label { color: var(--accent); font-weight: 600; }

.cat-children { margin-left: 18px; border-left: 1px solid var(--line); padding-left: 4px; }

/* ── Toolbar ────────────────────────────────────────────────────────────────── */
.toolbar {
  display: flex;
  gap: 12px;
  margin-bottom: 0;
}

.search,
button {
  border-radius: 16px;
  border: 1px solid var(--line);
  padding: 14px 16px;
  font-size: 1rem;
}

.search {
  flex: 1;
  background: rgba(255, 255, 255, 0.82);
}

button {
  background: linear-gradient(135deg, var(--accent), #d98a45);
  color: white;
  cursor: pointer;
  min-width: 160px;
  font-family: inherit;
}

/* ── Breadcrumbs ────────────────────────────────────────────────────────────── */
.breadcrumbs {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  padding: 12px 2px 12px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 18px;
  font-size: 0.9rem;
  gap: 2px;
}

.breadcrumbs--empty {
  color: var(--muted);
  border-bottom-color: transparent;
}

.bc-seg { display: inline-flex; align-items: center; gap: 2px; }

.bc-sep { color: var(--muted); }

.bc-item {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--accent-2);
  padding: 2px 6px;
  border-radius: 6px;
  min-width: unset;
  font-size: 0.9rem;
  font-family: inherit;
}

.bc-item:hover { background: rgba(0, 0, 0, 0.05); }

.bc-current {
  font-weight: 600;
  color: var(--ink);
  padding: 2px 6px;
}

/* ── Products ───────────────────────────────────────────────────────────────── */
.products {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 18px;
}

.product-card,
.empty-state {
  border: 1px solid var(--line);
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.78);
  padding: 20px;
  box-shadow: var(--shadow-sm);
}

.product-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: start;
}

.product-header h3 { margin: 0; font-size: 1.2rem; }

.product-status,
.product-sku,
.product-description,
.product-meta { color: var(--muted); }

.product-status { white-space: nowrap; font-size: 0.85rem; }

.product-meta {
  display: grid;
  gap: 6px;
  margin: 14px 0 18px;
  font-size: 0.85rem;
}

/* ── View toggle ───────────────────────────────────────────────────────────── */
.view-toggle {
  min-width: 120px !important;
  background: rgba(255, 255, 255, 0.85) !important;
  border: 1px solid var(--line) !important;
  color: var(--ink) !important;
}

.view-toggle:hover {
  background: rgba(255, 255, 255, 1) !important;
}

/* ── Product table ─────────────────────────────────────────────────────────── */
.product-table-wrap {
  border: 1px solid var(--line);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.78);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.product-table-wrap:empty { display: none; }

.product-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}

.product-table th {
  position: sticky;
  top: 0;
  background: rgba(245, 242, 235, 0.95);
  backdrop-filter: blur(8px);
  text-align: left;
  padding: 12px 14px;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
  user-select: none;
}

.product-table th .sort-indicator {
  font-size: 0.7rem;
  margin-left: 2px;
}

.product-table td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}

.product-table tbody tr:hover {
  background: rgba(194, 106, 46, 0.04);
}

.product-table tbody tr:last-child td {
  border-bottom: none;
}

.product-table .col-action { text-align: right; }

.table-cart-btn {
  padding: 6px 14px !important;
  min-width: unset !important;
  font-size: 0.82rem !important;
  border-radius: 10px !important;
  background: linear-gradient(135deg, var(--accent), #d98a45) !important;
  color: white !important;
  border: none !important;
  cursor: pointer;
}

/* ── Load more ──────────────────────────────────────────────────────────────── */
.load-more { margin-top: 24px; text-align: center; }

.load-more button {
  min-width: 220px;
  background: rgba(255, 255, 255, 0.85);
  border: 1px solid var(--line);
  color: var(--ink);
}

/* ── Responsive ─────────────────────────────────────────────────────────────── */
@media (max-width: 960px) {
  .catalog-body { grid-template-columns: 1fr; }

  .sidebar {
    position: static;
    max-height: 220px;
  }
}

@media (max-width: 800px) {
  .hero { grid-template-columns: 1fr; }

  .toolbar { flex-direction: column; }

  button { width: 100%; }
}

/* ── Login ──────────────────────────────────────────────────────────────────── */
.login-overlay {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.login-card {
  width: 100%;
  max-width: 380px;
  padding: 40px 36px;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: var(--panel);
  backdrop-filter: blur(14px);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.login-title {
  margin: 0;
  font-size: 1.8rem;
  line-height: 1.1;
}

.login-sub {
  margin: -12px 0 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.login-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.login-field label {
  font-size: 0.85rem;
  color: var(--muted);
  letter-spacing: 0.03em;
}

.login-input {
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.7);
  font-family: inherit;
  font-size: 1rem;
  color: var(--ink);
  outline: none;
  transition: border-color 0.15s;
}

.login-input:focus {
  border-color: var(--accent);
}

.login-error {
  font-size: 0.875rem;
  color: #b94040;
  min-height: 1.2em;
  transition: opacity 0.15s;
}

.login-error--hidden {
  opacity: 0;
  pointer-events: none;
}

.login-btn {
  padding: 12px;
  border: none;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  font-family: inherit;
  font-size: 1rem;
  cursor: pointer;
  transition: opacity 0.15s;
}

.login-btn:hover { opacity: 0.88; }
