:root {
  --color-primary: #2e7d32;
  --color-primary-dark: #1b5e20;
  --color-accent: #4caf50;
  --color-primary-light: #e8f5e9;
  --color-surface: #ffffff;
  --color-bg: #f5f5f5;
  --color-text: #212121;
  --color-text-secondary: #757575;
  --color-border: #e0e0e0;
  --color-footer-bg: #1a1a2e;
  --color-footer-text: #ccc;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,0.08);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  color: var(--color-text);
  background: var(--color-bg);
  line-height: 1.5;
}

a { color: inherit; text-decoration: none; }
img { max-width: 100%; height: auto; }
button { cursor: pointer; font-family: inherit; }

.container { max-width: 1280px; margin: 0 auto; padding: 0 1rem; }
.page-content { padding-top: 1.5rem; padding-bottom: 2rem; min-height: 60vh; }

/* HEADER */
.site-header { position: sticky; top: 0; z-index: 100; box-shadow: 0 2px 8px rgba(0,0,0,0.1); }
.header-top { background: var(--color-primary); }
.header-top-inner { display: flex; align-items: center; gap: 1rem; padding: 0.6rem 0; }
.logo { font-weight: 700; font-size: 1.3rem; color: #fff; display: flex; align-items: center; gap: 0.4rem; white-space: nowrap; }
.search-form { flex: 1; max-width: 520px; margin: 0 auto; display: flex; background: #fff; border-radius: var(--radius); overflow: hidden; }
.search-form input { flex: 1; border: none; padding: 0.5rem 0.8rem; outline: none; font-size: 0.9rem; }
.search-form button { background: var(--color-accent); color: #fff; border: none; padding: 0.5rem 1rem; font-weight: 500; font-size: 0.9rem; }
.header-links { display: flex; gap: 1rem; }
.header-link { color: #fff; font-size: 0.85rem; }

.header-nav { background: var(--color-primary-dark); }
.header-nav-inner { display: flex; gap: 0.25rem; }
.nav-link { color: rgba(255,255,255,0.9); padding: 0.55rem 0.9rem; font-size: 0.88rem; border-bottom: 3px solid transparent; transition: border-color 0.2s; }
.nav-link:hover { border-bottom-color: var(--color-accent); }

/* FOOTER */
.site-footer { background: var(--color-footer-bg); color: var(--color-footer-text); margin-top: 2rem; }
.footer-inner { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 2rem; padding: 2rem 0 1.5rem; }
.footer-brand { font-weight: 700; font-size: 1.2rem; color: #fff; margin-bottom: 0.5rem; }
.footer-desc { font-size: 0.85rem; line-height: 1.6; }
.footer-heading { font-weight: 600; color: #fff; margin-bottom: 0.5rem; font-size: 0.95rem; }
.footer-col { display: flex; flex-direction: column; gap: 0.3rem; }
.footer-col a { color: #aaa; font-size: 0.85rem; }
.footer-col a:hover { color: #fff; }
.footer-bottom { border-top: 1px solid rgba(255,255,255,0.1); padding: 0.75rem 0; display: flex; justify-content: space-between; font-size: 0.8rem; color: #888; flex-wrap: wrap; gap: 0.5rem; }

/* HERO */
.hero { background: linear-gradient(135deg, var(--color-primary), var(--color-primary-dark)); border-radius: var(--radius); padding: 2rem; margin-bottom: 2rem; color: #fff; }
.hero h1 { margin-bottom: 0.3rem; font-size: 1.6rem; }
.hero p { opacity: 0.9; font-size: 0.95rem; }

/* CARDS GRID */
.cards-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; }
@media (max-width: 900px) { .cards-grid { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 650px) { .cards-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 400px) { .cards-grid { grid-template-columns: 1fr; } }
.card { background: var(--color-surface); border-radius: var(--radius); padding: 0; box-shadow: var(--shadow); transition: box-shadow 0.2s, transform 0.15s; display: flex; flex-direction: column; overflow: hidden; }
.card:hover { box-shadow: 0 4px 16px rgba(0,0,0,0.13); transform: translateY(-2px); }
.card-img { width: 100%; height: 180px; background: #f8f8f8; display: flex; align-items: center; justify-content: center; overflow: hidden; padding: 0.75rem; }
.card-img img { width: 100%; height: 100%; object-fit: contain; }
.card-body { padding: 0.75rem; display: flex; flex-direction: column; flex: 1; }
.card-shop { font-size: 0.72rem; color: var(--color-text-secondary); }
.card-meta { font-size: 0.72rem; display: flex; align-items: center; gap: 0.3rem; flex-wrap: wrap; margin-bottom: 0.25rem; }
.card-brand { color: var(--color-accent); font-weight: 600; }
.card-sep { color: #ccc; }
.card-name { font-weight: 600; font-size: 0.85rem; margin-bottom: 0.3rem; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; min-height: 2.55rem; }
.card-price-row { display: flex; align-items: baseline; gap: 0.5rem; margin-top: auto; }
.card-price { color: var(--color-accent); font-weight: 700; font-size: 1.05rem; }
.card-old-price { color: var(--color-text-secondary); text-decoration: line-through; font-size: 0.8rem; }
.card-discount { background: #c62828; color: #fff; font-size: 0.7rem; font-weight: 600; padding: 0.1rem 0.35rem; border-radius: 3px; }

/* CAROUSEL */
.carousel { display: flex; gap: 1rem; overflow-x: auto; padding-bottom: 0.5rem; scroll-snap-type: x mandatory; }
.carousel .card { min-width: 220px; max-width: 220px; scroll-snap-align: start; }

/* CATEGORY CHIPS */
.cat-chips { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-bottom: 1.5rem; }
.cat-chip { padding: 0.4rem 0.9rem; background: var(--color-primary-light); color: var(--color-primary-dark); border-radius: 20px; font-size: 0.85rem; font-weight: 500; border: 1px solid var(--color-border); transition: all 0.2s; }
.cat-chip:hover, .cat-chip.active { background: var(--color-accent); color: #fff; border-color: var(--color-accent); }

/* SHOP CARDS */
.shop-card { background: var(--color-surface); border-radius: var(--radius); padding: 1.25rem; box-shadow: var(--shadow); }
.shop-card h3 { font-size: 1.05rem; margin-bottom: 0.2rem; }
.shop-card .domain { color: var(--color-text-secondary); font-size: 0.85rem; margin-bottom: 0.5rem; }
.shop-card a { color: var(--color-accent); font-weight: 500; font-size: 0.9rem; }

/* PROMOCODE CARD */
.promo-card { background: var(--color-surface); border-radius: var(--radius); padding: 1.25rem; box-shadow: var(--shadow); display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; }
.promo-code { font-size: 1.15rem; font-weight: 700; color: var(--color-accent); }
.promo-shop { font-size: 0.85rem; color: var(--color-text-secondary); margin-top: 0.15rem; }
.promo-desc { font-size: 0.9rem; margin-top: 0.3rem; }
.promo-date { font-size: 0.8rem; color: #999; margin-top: 0.3rem; }
.btn-copy { background: var(--color-accent); color: #fff; padding: 0.45rem 0.9rem; border: none; border-radius: var(--radius); font-weight: 500; font-size: 0.85rem; white-space: nowrap; }
.btn-buy { width: 100%; padding: 0.9rem; background: var(--color-accent); color: #fff; border: none; border-radius: var(--radius); font-size: 1.05rem; font-weight: 600; }

/* PRODUCT DETAIL */
.product-layout { display: flex; gap: 2rem; flex-wrap: wrap; }
.product-image { flex: 1 1 400px; min-height: 300px; background: #f0f0f0; border-radius: var(--radius); display: flex; align-items: center; justify-content: center; overflow: hidden; }
.product-image img { max-height: 400px; object-fit: contain; }
.product-info { flex: 1 1 400px; }
.breadcrumb { font-size: 0.875rem; color: var(--color-text-secondary); margin-bottom: 0.5rem; }
.breadcrumb a { color: var(--color-text-secondary); }
.product-title { font-size: 1.5rem; margin-bottom: 0.5rem; }
.product-price-main { font-size: 2rem; font-weight: 700; color: var(--color-accent); }
.product-price-muted { color: var(--color-text-secondary); }
.product-out-of-stock { margin-top: 1rem; padding: 0.9rem 1rem; background: #fff3e0; border: 1px solid #ffcc80; border-radius: var(--radius); color: #e65100; font-size: 0.95rem; display: flex; flex-direction: column; gap: 0.25rem; }
.out-of-stock-badge { align-self: flex-start; background: #424242; color: #fff; font-size: 0.7rem; font-weight: 600; padding: 0.15rem 0.5rem; border-radius: 10px; text-transform: uppercase; letter-spacing: 0.02em; margin-bottom: 0.35rem; }
.product-info .out-of-stock-badge { background: #e65100; font-size: 0.8rem; padding: 0.25rem 0.65rem; margin-bottom: 0.75rem; }
.product-price-old { font-size: 1.2rem; color: var(--color-text-secondary); text-decoration: line-through; margin-left: 1rem; }

/* TABS */
.tabs { display: flex; gap: 0.5rem; border-bottom: 2px solid var(--color-border); margin-bottom: 1rem; margin-top: 2rem; overflow-x: auto; }
.tab-btn { padding: 0.7rem 0.9rem; border: none; background: none; font-size: 0.9rem; border-bottom: 2px solid transparent; color: var(--color-text-secondary); font-weight: 400; white-space: nowrap; }
.tab-btn.active { color: var(--color-accent); border-bottom-color: var(--color-accent); font-weight: 600; }
.tab-content { display: none; }
.tab-content.active { display: block; }

/* TABLE */
.spec-table { width: 100%; border-collapse: collapse; }
.spec-table td { padding: 0.5rem; border-bottom: 1px solid var(--color-border); }
.spec-table td:first-child { font-weight: 600; width: 40%; color: var(--color-text-secondary); }

/* REVIEW */
.review-item { padding: 1rem; border-bottom: 1px solid var(--color-border); }
.review-header { display: flex; justify-content: space-between; margin-bottom: 0.3rem; }

/* LISTS */
.empty-state { text-align: center; padding: 4rem 1rem; color: #999; }
.section-title { font-size: 1.3rem; margin-bottom: 0.75rem; }
.page-title { font-size: 1.5rem; margin-bottom: 1rem; }

/* SIDEBAR */
.catalog-layout { display: flex; gap: 2rem; }
.catalog-sidebar { width: 280px; flex-shrink: 0; }
.catalog-sidebar h3 { font-size: 1.1rem; margin-bottom: 0.75rem; }

.sidebar-item { display: flex; align-items: center; gap: 0.25rem; padding: 0.2rem 0; cursor: default; user-select: none; }
.sidebar-item a { flex: 1; }
.sidebar-item.has-children { cursor: pointer; }
.sidebar-item.active-branch > a { font-weight: 600; }

.sidebar-item.depth-0 { padding-left: 0; }
.sidebar-item.depth-0 .sidebar-link { font-weight: 600; font-size: 0.9rem; }
.sidebar-item.depth-1 { padding-left: 1.2rem; }
.sidebar-item.depth-1 .sidebar-link { font-size: 0.85rem; color: var(--color-text-secondary); }
.sidebar-item.depth-2 { padding-left: 2.2rem; }
.sidebar-item.depth-2 .sidebar-link { font-size: 0.82rem; color: var(--color-text-secondary); opacity: 0.85; }
.sidebar-item.depth-3 { padding-left: 3.2rem; }
.sidebar-item.depth-3 .sidebar-link { font-size: 0.8rem; color: var(--color-text-secondary); opacity: 0.7; }

.toggle-icon { font-size: 0.6rem; width: 1rem; text-align: center; flex-shrink: 0; color: var(--color-text-secondary); transition: transform 0.15s; }
.toggle-icon.toggle-placeholder { visibility: hidden; }
.sidebar-link { display: block; padding: 0.15rem 0; font-size: 0.9rem; line-height: 1.4; }
.sidebar-link.active { color: var(--color-accent); font-weight: 700; }

.sidebar-children { display: none; }
.sidebar-children.open { display: block; }

/* PAGINATION */
.pagination { display: flex; justify-content: center; gap: 0.5rem; margin-top: 2rem; }
.page-link { padding: 0.45rem 0.7rem; border: 1px solid var(--color-border); border-radius: 4px; font-size: 0.9rem; background: var(--color-surface); }
.page-link.active { background: var(--color-accent); color: #fff; border-color: var(--color-accent); }

/* ADMIN */
.admin-form { max-width: 600px; }
.admin-form label { display: block; margin-bottom: 0.5rem; font-weight: 500; font-size: 0.9rem; }
.admin-form input, .admin-form select, .admin-form textarea {
  width: 100%; padding: 0.55rem 0.75rem; border: 1px solid var(--color-border); border-radius: var(--radius);
  font-size: 0.95rem; margin-bottom: 1rem; background: var(--color-surface);
}
.admin-form textarea { min-height: 100px; resize: vertical; }
.btn-primary { background: var(--color-accent); color: #fff; padding: 0.6rem 1.5rem; border: none; border-radius: var(--radius); font-weight: 600; font-size: 0.95rem; }
.btn-danger { background: #dc3545; color: #fff; padding: 0.4rem 0.8rem; border: none; border-radius: 4px; font-size: 0.85rem; }
table.admin-table { width: 100%; border-collapse: collapse; background: var(--color-surface); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
table.admin-table th, table.admin-table td { padding: 0.6rem 0.8rem; text-align: left; border-bottom: 1px solid var(--color-border); font-size: 0.9rem; }
table.admin-table th { background: var(--color-primary); color: #fff; font-weight: 500; }
.status-badge { padding: 0.15rem 0.5rem; border-radius: 10px; font-size: 0.8rem; font-weight: 500; }
.status-active { background: var(--color-primary-light); color: var(--color-primary-dark); }
.status-inactive { background: #fce4ec; color: #c62828; }

/* AUTH */
.login-form { max-width: 400px; margin: 3rem auto; background: var(--color-surface); padding: 2rem; border-radius: var(--radius); box-shadow: var(--shadow); }

/* PARTNER */
.partner-layout { display: flex; min-height: 100vh; }
.partner-sidebar { width: 240px; background: var(--color-primary-dark); color: #fff; display: flex; flex-direction: column; flex-shrink: 0; }
.partner-sidebar a { color: rgba(255,255,255,0.85); }
.partner-sidebar .active { background: rgba(255,255,255,0.15); font-weight: 600; color: #fff; }
.partner-main { flex: 1; padding: 1.5rem 2rem; max-width: 1100px; }
.partner-header { padding: 1rem; border-bottom: 1px solid rgba(255,255,255,0.1); }
.partner-user { padding: 1rem; border-top: 1px solid rgba(255,255,255,0.1); font-size: 0.85rem; }
.partner-balance { font-size: 2rem; font-weight: 700; color: var(--color-accent); }
.partner-stat-card { padding: 1.25rem; }
.partner-stat-label { font-size: 0.85rem; color: var(--color-text-secondary); }
.partner-stat-value { font-size: 2rem; font-weight: 700; color: var(--color-accent); }

/* RESPONSIVE */
@media (max-width: 768px) {
  .catalog-layout { flex-direction: column; }
  .catalog-sidebar { width: 100%; }
  .product-layout { flex-direction: column; }
  .header-top-inner { flex-wrap: wrap; }
  .search-form { order: 3; max-width: 100%; flex-basis: 100%; }
  .carousel .card { min-width: 160px; max-width: 160px; }
}
