:root {
  --bg: #f5f7fb;
  --surface: #ffffff;
  --text: #1a2233;
  --text-muted: #6b7280;
  --border: #e5e7eb;
  --primary: #1e40af;
  --primary-light: #2563eb;
  --hover-bg: #f3f4f6;
}
[data-theme="dark"] {
  --bg: #0f172a;
  --surface: #1e293b;
  --text: #e2e8f0;
  --text-muted: #94a3b8;
  --border: #334155;
  --primary: #3b82f6;
  --primary-light: #60a5fa;
  --hover-bg: #334155;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: 'Segoe UI', system-ui, sans-serif; background: var(--bg); color: var(--text); line-height: 1.5; transition: background .2s, color .2s; }
a { color: var(--primary-light); text-decoration: none; }
.container { max-width: 1200px; margin: 0 auto; padding: 0 16px; }
[data-theme="dark"] .topbar, [data-theme="dark"] .footer, [data-theme="dark"] .cat-card,
[data-theme="dark"] .prod-card, [data-theme="dark"] .store-card, [data-theme="dark"] .stat-card,
[data-theme="dark"] .card-box, [data-theme="dark"] .blog-card,
[data-theme="dark"] .auth-wrap, [data-theme="dark"] .empty-card,
[data-theme="dark"] [style*="background:#fff"] { background: var(--surface) !important; border-color: var(--border) !important; color: var(--text); }
[data-theme="dark"] .data-table thead tr,
[data-theme="dark"] [style*="background:#f3f4f6"],
[data-theme="dark"] [style*="background:#f9fafb"] { background: #0f172a !important; }
[data-theme="dark"] input, [data-theme="dark"] textarea, [data-theme="dark"] select { background: var(--surface); color: var(--text); border-color: var(--border); }

.topbar { background: #fff; border-bottom: 1px solid #e5e7eb; position: sticky; top: 0; z-index: 50; }
.topbar.admin-bar { background: #1e293b; border-bottom-color: #334155; }
.topbar.admin-bar .logo { color: #fbbf24; }
.topbar.admin-bar .nav-links a { color: #cbd5e1; }
.topbar.admin-bar .nav-links a.active { color: #fff; border-bottom: 2px solid #fbbf24; padding-bottom: 18px; }
.nav { display: flex; align-items: center; gap: 20px; height: 64px; flex-wrap: wrap; }
.logo { font-size: 22px; font-weight: 800; color: #1e40af; }
.search { flex: 1; display: flex; max-width: 480px; }
.search input { flex: 1; padding: 9px 12px; border: 1px solid #d1d5db; border-radius: 6px 0 0 6px; outline: none; }
.search button { padding: 9px 16px; background: #1e40af; color: #fff; border: 0; border-radius: 0 6px 6px 0; cursor: pointer; }
.nav-links { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; }
.nav-links a { color: #374151; font-weight: 500; }
.nav-links .btn, .btn { background: #1e40af; color: #fff; padding: 8px 14px; border-radius: 6px; border: 0; cursor: pointer; display: inline-block; font-size: 14px; }
.cart { background: #fef3c7; color: #92400e !important; padding: 6px 12px; border-radius: 6px; }

.hero { background: linear-gradient(135deg, #1e3a8a, #2563eb); color: #fff; padding: 60px 0; text-align: center; }
.hero h1 { font-size: 34px; margin-bottom: 14px; }
.hero p { font-size: 16px; opacity: .9; max-width: 680px; margin: 0 auto 22px; }
.btn-lg { display: inline-block; background: #fbbf24; color: #1a2233; padding: 12px 28px; border-radius: 8px; font-weight: 700; }

.sec-title { margin: 38px 0 16px; font-size: 22px; display: flex; justify-content: space-between; align-items: center; }
.more { font-size: 14px; color: #2563eb; }

.grid-cats { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.cat-card { background: #fff; border: 1px solid #e5e7eb; border-radius: 10px; padding: 18px; text-align: center; cursor: pointer; transition: .2s; display: block; }
.cat-card:hover { transform: translateY(-3px); box-shadow: 0 6px 16px rgba(0,0,0,.08); }
.cat-card .ico { font-size: 30px; margin-bottom: 8px; height: 44px; display: flex; align-items: center; justify-content: center; }
.cat-card .ico img { width: 40px; height: 40px; object-fit: contain; }
.cat-card h4 { font-size: 14px; color: #1f2937; }

.grid-stores { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.store-card { background: #fff; border-radius: 10px; padding: 16px; border: 1px solid #e5e7eb; }
.store-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.store-logo { width: 44px; height: 44px; border-radius: 8px; object-fit: cover; border: 1px solid #e5e7eb; flex-shrink: 0; }
.store-logo-placeholder { width: 44px; height: 44px; border-radius: 8px; background: #1e40af; color: #fff; display: flex; align-items: center; justify-content: center; font-size: 20px; font-weight: 700; flex-shrink: 0; }
.store-card h4 { display: flex; justify-content: space-between; align-items: center; gap: 6px; font-size: 15px; margin: 0; flex: 1; }
.badge { font-size: 11px; background: #10b981; color: #fff; padding: 2px 8px; border-radius: 10px; font-weight: 600; }
.badge-warn { font-size: 11px; background: #f59e0b; color: #fff; padding: 2px 8px; border-radius: 10px; margin-left: 6px; }
.store-card p { font-size: 13px; color: #6b7280; margin-bottom: 10px; min-height: 38px; }
.store-card a { font-size: 13px; font-weight: 600; }

.grid-products { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; }
.prod-card { background: #fff; border-radius: 10px; padding: 14px; border: 1px solid #e5e7eb; display: flex; flex-direction: column; }
.prod-card .stock { font-size: 11px; background: #dbeafe; color: #1e40af; padding: 2px 8px; border-radius: 10px; align-self: flex-start; margin-bottom: 8px; }
.prod-card .stock.manual { background: #fef3c7; color: #92400e; }
.prod-card h5 { font-size: 14px; font-weight: 600; flex: 1; margin-bottom: 10px; color: #1f2937; }
.prod-card .price { font-size: 18px; font-weight: 800; color: #059669; }
.prod-card .row { display: flex; justify-content: space-between; align-items: center; margin-top: 8px; }
.prod-card .row a { background: #1e40af; color: #fff; padding: 6px 14px; border-radius: 6px; font-size: 13px; }

.grid-blog { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; margin-bottom: 50px; }
.blog-card { background: #fff; border-radius: 10px; padding: 16px; border: 1px solid #e5e7eb; }
.blog-card .date { font-size: 12px; color: #6b7280; }
.blog-card h4 { margin: 6px 0 10px; font-size: 15px; }

.footer { background: #1e293b; color: #cbd5e1; padding: 30px 0; margin-top: 40px; }
.footer .container { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 14px; }
.footer a { color: #cbd5e1; margin-left: 14px; }

.auth-wrap { max-width: 420px; margin: 60px auto; background: #fff; padding: 30px; border-radius: 12px; box-shadow: 0 4px 20px rgba(0,0,0,.06); }
.auth-wrap h2 { margin-bottom: 20px; text-align: center; }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; margin-bottom: 5px; font-weight: 600; }
.field input, .field textarea, .field select { width: 100%; padding: 10px; border: 1px solid #d1d5db; border-radius: 6px; font-size: 14px; font-family: inherit; }
.btn-full { width: 100%; background: #1e40af; color: #fff; padding: 11px; border: 0; border-radius: 6px; font-weight: 600; cursor: pointer; font-size: 15px; }
.alert { padding: 10px; border-radius: 6px; margin-bottom: 14px; font-size: 14px; }
.alert.err { background: #fee2e2; color: #991b1b; }
.alert.ok { background: #d1fae5; color: #065f46; }

.chat-fab { position: fixed; bottom: 20px; right: 20px; background: #1e40af; color: #fff; border: 0; padding: 12px 20px; border-radius: 30px; cursor: pointer; box-shadow: 0 4px 12px rgba(0,0,0,.2); z-index: 60; }
.chat-box { position: fixed; bottom: 80px; right: 20px; width: 320px; background: #fff; border-radius: 12px; box-shadow: 0 10px 40px rgba(0,0,0,.2); z-index: 60; display: flex; flex-direction: column; height: 420px; }
.chat-box.hidden { display: none; }
.chat-head { background: #1e40af; color: #fff; padding: 12px; border-radius: 12px 12px 0 0; display: flex; justify-content: space-between; }
#chatClose { cursor: pointer; font-size: 20px; line-height: 1; }
.chat-body { flex: 1; padding: 12px; overflow-y: auto; background: #f9fafb; }
.msg { padding: 8px 12px; border-radius: 10px; margin-bottom: 8px; max-width: 80%; font-size: 14px; }
.msg.bot { background: #e5e7eb; }
.msg.me { background: #1e40af; color: #fff; margin-left: auto; }
.chat-foot { display: flex; border-top: 1px solid #e5e7eb; }
.chat-foot input { flex: 1; padding: 10px; border: 0; outline: none; }
.chat-foot button { background: #1e40af; color: #fff; border: 0; padding: 0 16px; cursor: pointer; }

/* Status badges */
.status-pending { background: #fef3c7; color: #92400e; padding: 3px 10px; border-radius: 10px; font-size: 11px; font-weight: 600; text-transform: uppercase; }
.status-approved { background: #d1fae5; color: #065f46; padding: 3px 10px; border-radius: 10px; font-size: 11px; font-weight: 600; text-transform: uppercase; }
.status-rejected { background: #fee2e2; color: #991b1b; padding: 3px 10px; border-radius: 10px; font-size: 11px; font-weight: 600; text-transform: uppercase; }

/* Admin stat cards */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 14px; }
.stat-card { background: #fff; border-radius: 12px; padding: 20px; border: 1px solid #e5e7eb; transition: .2s; display: block; color: inherit; }
.stat-card:hover { transform: translateY(-3px); box-shadow: 0 6px 16px rgba(0,0,0,.08); }
.stat-card .lbl { font-size: 13px; color: #6b7280; margin-bottom: 6px; }
.stat-card .val { font-size: 28px; font-weight: 800; color: #1f2937; }
.stat-card p { font-size: 13px; color: #6b7280; margin-bottom: 6px; }
.stat-card h3 { font-size: 24px; font-weight: 800; }
body.admin .stat-card .val { color: #1e293b; }

/* Dashboard tabs */
.dash-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; margin-bottom: 18px; }
.dash-tabs { display: flex; gap: 4px; border-bottom: 2px solid #e5e7eb; margin-bottom: 18px; flex-wrap: wrap; }
.dash-tabs a { padding: 10px 18px; color: #6b7280; font-weight: 600; font-size: 14px; border-bottom: 2px solid transparent; margin-bottom: -2px; transition: .15s; }
.dash-tabs a:hover { color: #1e40af; }
.dash-tabs a.active { color: #1e40af; border-bottom-color: #1e40af; }

/* Card box (forms inside dashboard) */
.card-box { background: #fff; padding: 24px; border-radius: 12px; border: 1px solid #e5e7eb; }
.empty-card { background: #fff; padding: 30px; border-radius: 10px; text-align: center; color: #6b7280; }

/* Data table reusable */
.data-table { width: 100%; border-collapse: collapse; min-width: 700px; }
.data-table thead tr { background: #f3f4f6; text-align: left; }
.data-table th, .data-table td { padding: 10px; }
.data-table tbody tr { border-top: 1px solid #e5e7eb; }
.data-table th:first-child, .data-table td:first-child { padding-left: 14px; }

/* Legal pages content */
.card-box h3 { font-size: 17px; margin: 22px 0 8px; color: var(--text); }
.card-box p, .card-box ul { font-size: 14.5px; color: var(--text); margin-bottom: 10px; }
.card-box ul { padding-left: 22px; }
.card-box ul li { margin-bottom: 6px; }

/* 3-dot menu */
.dots-menu { position: relative; }
.dots-trigger { background: transparent; border: 1px solid var(--border); border-radius: 8px; padding: 8px 6px; cursor: pointer; display: flex; flex-direction: column; gap: 3px; align-items: center; }
.dots-trigger:hover { background: var(--hover-bg); }
.dots-trigger span { display: block; width: 4px; height: 4px; background: var(--text); border-radius: 50%; }
.dots-dropdown { position: absolute; right: 0; top: calc(100% + 8px); width: 240px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 6px; box-shadow: 0 12px 32px rgba(0,0,0,.18); display: none; z-index: 100; }
.dots-dropdown.show { display: block; }
.dots-dropdown a { display: block; padding: 9px 14px; color: var(--text); border-radius: 6px; font-size: 14px; font-weight: 500; }
.dots-dropdown a:hover { background: var(--hover-bg); }
.dots-section { padding: 8px 14px 4px; font-size: 11px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: .8px; }
.dots-section:not(:first-child) { border-top: 1px solid var(--border); margin-top: 4px; }

/* User dropdown menu */
.user-menu { position: relative; }
.user-trigger { display: flex; align-items: center; gap: 8px; background: transparent; border: 1px solid var(--border); border-radius: 30px; padding: 5px 12px 5px 5px; cursor: pointer; color: var(--text); font-size: 14px; }
.user-trigger:hover { background: var(--hover-bg); }
.user-trigger .avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--primary); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 13px; }
.user-trigger .uname { font-weight: 600; }
.user-trigger .caret { font-size: 11px; color: var(--text-muted); }
.badge-num { background: #dc2626; color: #fff; border-radius: 10px; padding: 1px 7px; font-size: 11px; font-weight: 700; }

.user-dropdown { position: absolute; right: 0; top: calc(100% + 8px); width: 260px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 8px; box-shadow: 0 12px 32px rgba(0,0,0,.18); display: none; z-index: 100; }
.user-dropdown.show { display: block; }
.user-dropdown .user-info { padding: 12px; border-bottom: 1px solid var(--border); margin-bottom: 6px; font-size: 13px; color: var(--text-muted); }
.user-dropdown .user-info strong { color: var(--text); font-size: 15px; }
.user-dropdown .seller-pill { display: inline-block; background: #fef3c7; color: #92400e; padding: 2px 10px; border-radius: 10px; font-size: 11px; font-weight: 700; margin-top: 4px; }
.user-dropdown a, .user-dropdown .theme-toggle { display: flex; align-items: center; gap: 10px; padding: 9px 12px; color: var(--text); border-radius: 6px; font-size: 14px; font-weight: 500; cursor: pointer; background: none; border: 0; width: 100%; text-align: left; font-family: inherit; }
.user-dropdown a:hover, .user-dropdown .theme-toggle:hover { background: var(--hover-bg); }
.user-dropdown .i { width: 22px; height: 22px; display: inline-flex; align-items: center; justify-content: center; background: var(--hover-bg); border-radius: 6px; font-size: 12px; font-weight: 700; color: var(--primary); }
.user-dropdown .dropdown-divider { height: 1px; background: var(--border); margin: 6px 4px; }
.user-dropdown .logout-link { color: #dc2626; }
.user-dropdown .logout-link .i { background: #fee2e2; color: #dc2626; }

/* Google sign-in button */
.google-btn { display: flex; align-items: center; justify-content: center; gap: 10px; width: 100%; padding: 11px; background: #fff; color: #1f2937; border: 1px solid #d1d5db; border-radius: 6px; font-weight: 600; font-size: 14px; margin-bottom: 14px; transition: .15s; }
.google-btn:hover { background: #f9fafb; box-shadow: 0 2px 6px rgba(0,0,0,.08); }
.auth-divider { display: flex; align-items: center; gap: 12px; color: var(--text-muted); font-size: 12px; margin: 14px 0; }
.auth-divider::before, .auth-divider::after { content: ''; flex: 1; height: 1px; background: var(--border); }

@media (max-width: 768px) {
  .nav { flex-wrap: wrap; height: auto; padding: 10px 0; }
  .search { order: 3; width: 100%; max-width: none; }
  .hero h1 { font-size: 24px; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .dash-stats { grid-template-columns: repeat(2, 1fr); }
  .user-trigger .uname { display: none; }
  .user-dropdown { right: -8px; width: 240px; }
}
