:root {
  color-scheme: light dark;
  --bg: #f6f7f9; --surface: #fff; --text: #1a1d21; --muted: #6b7280;
  --border: #e5e7eb; --accent: #2563eb; --accent-hover: #1d4ed8;
  --primary: #2563eb;
  --green: #16a34a; --green-bg: #dcfce7; --red: #dc2626; --red-bg: #fee2e2;
  --amber: #d97706; --amber-bg: #fef3c7; --chip: #eef2ff;
  --glass: rgba(255, 255, 255, .72); --glass-border: rgba(229, 231, 235, .7);
  --th-bg: #f9fafb; --row-hover: #f9fafb;
  --radius: 12px; --shadow: 0 1px 3px rgba(0,0,0,.08), 0 4px 12px rgba(0,0,0,.05);
  --font-sans: 'Roboto', -apple-system, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  --font-display: 'Roboto Serif', Georgia, "Times New Roman", serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1220; --surface: #131c2e; --text: #e8edf5; --muted: #94a3b8;
    --border: #263449; --accent: #2f7cf6; --accent-hover: #3b82f6;
    --primary: #2f7cf6;
    --green: #4ade80; --green-bg: rgba(22, 163, 74, .22); --red: #f87171; --red-bg: rgba(220, 38, 38, .25);
    --amber: #fbbf24; --amber-bg: rgba(217, 119, 6, .22); --chip: #1e3a5f;
    --glass: rgba(19, 28, 46, .72); --glass-border: rgba(38, 52, 73, .7);
    --th-bg: #0f1729; --row-hover: #182238;
    --shadow: 0 1px 3px rgba(0,0,0,.4), 0 4px 14px rgba(0,0,0,.35);
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--font-sans); background: var(--bg); color: var(--text); line-height: 1.5; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button { cursor: pointer; font: inherit; }
input, select, textarea { font: inherit; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text); width: 100%; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: var(--accent); }
h1, h2, h3 { margin: 0 0 12px; line-height: 1.3; font-family: var(--font-display); }
p { margin: 0 0 10px; }

/* header */
header.site { background: var(--glass); backdrop-filter: blur(14px) saturate(1.5); -webkit-backdrop-filter: blur(14px) saturate(1.5); border-bottom: 1px solid var(--glass-border); position: sticky; top: 0; z-index: 50; }
.header-inner { max-width: 1240px; margin: 0 auto; padding: 10px 16px; display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.logo { font-size: 22px; font-weight: 700; font-family: var(--font-display); color: var(--primary); white-space: nowrap; }
.logo:hover { text-decoration: none; }
nav.main { display: flex; gap: 4px; flex-wrap: wrap; }
nav.main a { padding: 6px 10px; border-radius: 8px; color: var(--text); font-weight: 600; }
nav.main a:hover, nav.main a.active { background: var(--chip); text-decoration: none; }
.search-wrap { position: relative; flex: 1 1 260px; min-width: 200px; }
.search-wrap input { padding-right: 34px; }
.suggest { position: absolute; top: 100%; left: 0; right: 0; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow); margin-top: 4px; z-index: 60; overflow: hidden; }
.suggest button { display: block; width: 100%; text-align: left; background: none; border: 0; padding: 9px 12px; }
.suggest button:hover { background: var(--chip); }
.suggest .stype { color: var(--muted); font-size: 12px; margin-inline-end: 6px; }
.header-controls { display: flex; gap: 8px; align-items: center; margin-inline-start: auto; }
.header-controls select { width: auto; padding: 6px 8px; }
.btn { display: inline-block; padding: 8px 16px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font-weight: 600; text-align: center; }
.btn:hover { text-decoration: none; background: var(--row-hover); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-hover); }
.btn.buy { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.buy:hover { background: var(--accent-hover); }
.btn.out { background: var(--red); border-color: var(--red); color: #fff; cursor: not-allowed; opacity: .85; }
.btn.sub { background: var(--surface); border-color: var(--accent); color: var(--accent); }
.btn.sub.active { background: var(--accent); color: #fff; }
.btn.tg { background: #229ed9; border-color: #229ed9; color: #fff; }
.btn.tg:hover { background: #1b8ac0; }
.btn.danger { border-color: var(--red); color: var(--red); }
.btn:disabled { opacity: .55; cursor: not-allowed; }

/* layout */
main { max-width: 1240px; margin: 0 auto; padding: 20px 16px 60px; }
.hero { background: linear-gradient(135deg, #1e3a8a, #2563eb); color: #fff; border-radius: var(--radius); padding: 28px 24px; margin-bottom: 20px; }
.hero h1 { margin: 0 0 6px; font-size: 26px; color: #fff; }
.hero p { opacity: .9; margin: 0; }
.stats { display: flex; gap: 16px; margin: 20px 0; flex-wrap: wrap; }
.stat { flex: 1; min-width: 140px; background: var(--glass); backdrop-filter: blur(12px) saturate(1.4); -webkit-backdrop-filter: blur(12px) saturate(1.4); border: 1px solid var(--glass-border); border-radius: var(--radius); padding: 14px 18px; box-shadow: var(--shadow); }
.stat b { font-size: 28px; display: block; color: var(--primary); font-family: var(--font-display); }
.stat span { font-size: 13px; color: var(--muted); }
.section { margin: 28px 0 8px; }
.section h2 { font-size: 20px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.section-head a { font-size: 14px; font-weight: 600; white-space: nowrap; }
.muted { color: var(--muted); }
.notice { background: var(--amber-bg); border: 1px solid #fcd34d; color: #92400e; padding: 10px 14px; border-radius: 10px; margin: 12px 0; }
.error { background: var(--red-bg); border: 1px solid #fca5a5; color: #991b1b; padding: 10px 14px; border-radius: 10px; margin: 12px 0; }
.success { background: var(--green-bg); border: 1px solid #86efac; color: #166534; padding: 10px 14px; border-radius: 10px; margin: 12px 0; }

/* product grid / cards */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.card { position: relative; background: var(--glass); backdrop-filter: blur(12px) saturate(1.4); -webkit-backdrop-filter: blur(12px) saturate(1.4); border: 1px solid var(--glass-border); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 10px; }
.card:hover { border-color: #c7d2fe; }
.card-row1 { display: flex; align-items: center; gap: 10px; min-height: 44px; padding-inline-end: 20px; }
.provider-logo { width: 44px; height: 44px; border-radius: 10px; object-fit: contain; background: #f3f4f6; border: 1px solid var(--border); flex: none; }
.provider-logo-fallback { width: 44px; height: 44px; border-radius: 10px; background: var(--accent); color: #fff; display: inline-flex; align-items: center; justify-content: center; font-weight: 800; font-size: 22px; flex: none; }
.provider-name { font-weight: 800; font-size: 16px; }
.stock-dot { position: absolute; top: 12px; right: 12px; width: 12px; height: 12px; border-radius: 50%; border: 2px solid var(--surface); box-shadow: 0 0 0 1px var(--border); }
.stock-dot.in { background: var(--green); }
.stock-dot.out { background: var(--red); }
.stock-dot.unknown { background: var(--amber); }
.badge.region { background: #e0e7ff; color: #3730a3; }
.spec-ic { display: inline-flex; align-items: center; gap: 5px; }
.spec-ic svg { width: 15px; height: 15px; flex: none; }
.badge { display: inline-block; font-size: 11px; font-weight: 700; padding: 2px 7px; border-radius: 999px; margin-inline-start: auto; white-space: nowrap; }
.badge.premium { background: #fef3c7; color: #92400e; }
.badge.in { background: var(--green-bg); color: var(--green); }
.badge.out { background: var(--red-bg); color: var(--red); }
.badge.unknown { background: #e5e7eb; color: #374151; }
.card h3 { margin: 0; font-size: 17px; }
.card h3 a { color: var(--text); }
.tags { display: flex; flex-wrap: wrap; gap: 6px; min-height: 24px; }
.tag { background: var(--chip); color: #3730a3; font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 999px; }
.specs { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 12px; font-size: 13.5px; }
.specs div { display: flex; justify-content: space-between; gap: 8px; border-bottom: 1px dashed #f0f0f0; padding: 2px 0; }
.specs span:first-child { color: var(--muted); }
.locs { font-size: 13px; color: var(--muted); }
.price { display: flex; align-items: baseline; gap: 10px; margin-top: auto; }
.price .m { font-size: 22px; font-weight: 800; color: var(--accent); }
.price .y { font-size: 14px; color: var(--muted); }
.price .orig { font-size: 12px; color: var(--muted); }
.card-actions { display: flex; gap: 8px; }
.card-actions .btn { flex: 1; }
.card-actions .btn.tg { flex: 0 0 auto; }
.rank-chip { font-weight: 800; color: var(--accent); font-size: 15px; flex: none; }
.compare-check { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.compare-check input { width: auto; }

/* hover detail popover */
.popover { display: none; position: absolute; left: 0; right: 0; top: calc(100% + 6px); z-index: 40; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: 0 12px 32px rgba(0,0,0,.18); padding: 14px 16px; font-size: 13.5px; }
.card:hover .popover, .card:focus-within .popover { display: block; }
.popover h4 { margin: 0 0 8px; font-size: 14px; }
.popover .specs { grid-template-columns: 1fr 1fr; }

/* table view */
table.list { width: 100%; border-collapse: collapse; background: var(--surface); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
table.list th, table.list td { padding: 10px 12px; border-bottom: 1px solid var(--border); text-align: left; font-size: 14px; vertical-align: middle; }
table.list th { background: var(--th-bg); font-size: 13px; color: var(--muted); white-space: nowrap; }
table.list tr:hover td { background: var(--row-hover); }
.table-scroll { overflow-x: auto; }

/* filters */
.layout { display: flex; gap: 20px; align-items: flex-start; }
.filters { width: 250px; flex: none; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; position: sticky; top: 76px; max-height: calc(100vh - 96px); overflow-y: auto; }
.filters h3 { font-size: 15px; margin-bottom: 4px; }
.filter-group { margin: 14px 0; }
.filter-group > b { display: block; font-size: 13px; margin-bottom: 6px; }
.filter-group label { display: flex; gap: 6px; align-items: center; font-size: 13.5px; padding: 2px 0; }
.filter-group input[type=checkbox] { width: auto; }
.filter-group input[type=number] { width: 90px; padding: 5px 8px; }
.results { flex: 1; min-width: 0; }
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.toolbar select { width: auto; }
.view-toggle { display: flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.view-toggle button { border: 0; background: var(--surface); padding: 7px 12px; font-weight: 600; }
.view-toggle button.active { background: var(--accent); color: #fff; }

/* providers */
.provider-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.provider-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.provider-card .head { display: flex; gap: 12px; align-items: center; margin-bottom: 8px; }
.provider-card .head img { width: 48px; height: 48px; object-fit: contain; border-radius: 10px; border: 1px solid var(--border); background: #f3f4f6; }
.stars { color: #f59e0b; letter-spacing: 1px; }

/* detail / ranking */
.detail { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px; box-shadow: var(--shadow); }
.detail .head { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; }
.detail .head img { width: 56px; height: 56px; object-fit: contain; border-radius: 12px; border: 1px solid var(--border); }
.kv { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px 24px; margin: 18px 0; font-size: 14.5px; }
.kv div { display: flex; justify-content: space-between; border-bottom: 1px dashed #eee; padding: 4px 0; }
.kv span:first-child { color: var(--muted); }
.rank-item { display: flex; gap: 14px; align-items: center; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 16px; margin-bottom: 10px; }
.rank-num { font-size: 22px; font-weight: 800; width: 34px; text-align: center; color: var(--accent); flex: none; }

/* forms / admin */
.form { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 22px; max-width: 560px; margin: 0 auto; box-shadow: var(--shadow); }
.form label { display: block; font-weight: 600; font-size: 14px; margin: 12px 0 4px; }
.form .row { display: flex; gap: 10px; }
.form .row > * { flex: 1; }
.admin-tabs { display: flex; gap: 6px; flex-wrap: wrap; margin: 16px 0; }
.admin-tabs button { padding: 8px 14px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); font-weight: 600; }
.admin-tabs button.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; margin-bottom: 16px; }
table.admin { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.admin th, table.admin td { border-bottom: 1px solid var(--border); padding: 8px; text-align: left; vertical-align: top; }
table.admin input, table.admin select { padding: 5px 7px; font-size: 13.5px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; word-break: break-all; }

/* compare */
.compare-tray { position: fixed; left: 50%; transform: translateX(-50%); bottom: 16px; z-index: 80; background: #111827; color: #fff; border-radius: 12px; padding: 10px 16px; display: flex; gap: 12px; align-items: center; box-shadow: 0 8px 24px rgba(0,0,0,.3); max-width: calc(100vw - 32px); flex-wrap: wrap; }
.compare-tray .btn { border-color: #374151; background: #1f2937; color: #fff; }
.compare-table { width: 100%; border-collapse: collapse; background: var(--surface); }
.compare-table th, .compare-table td { border: 1px solid var(--border); padding: 10px; text-align: left; font-size: 14px; vertical-align: top; }
.compare-table th { background: var(--th-bg); }
td.diff { background: #fef9c3; font-weight: 700; }

footer.site { border-top: 1px solid var(--border); background: var(--surface); padding: 28px 16px 20px; color: var(--muted); font-size: 13.5px; }
.footer-inner { max-width: 1240px; margin: 0 auto; display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 24px; }
.footer-inner h3 { font-size: 15px; color: var(--text); margin-bottom: 10px; }
.footer-inner ul { list-style: none; margin: 0; padding: 0; }
.footer-inner li { margin: 6px 0; }
.footer-brand .logo { font-size: 20px; }
.footer-bottom { max-width: 1240px; margin: 22px auto 0; padding-top: 14px; border-top: 1px solid var(--border); text-align: center; font-size: 12.5px; }
.pagination { display: flex; gap: 8px; align-items: center; justify-content: center; margin: 22px 0; }
.pagination button { padding: 7px 12px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); font-weight: 600; }
.pagination button.active { background: var(--accent); color: #fff; border-color: var(--accent); }

@media (max-width: 860px) {
  .layout { flex-direction: column; }
  .filters { width: 100%; position: static; max-height: none; }
  .header-inner { gap: 8px; }
  .hero h1 { font-size: 21px; }
  .footer-inner { grid-template-columns: 1fr; }
}
[dir="rtl"] .header-controls { margin-inline-start: 0; margin-inline-end: auto; }
