:root {
  --bg: #f6f6f7; --card: #fff; --ink: #1a1a1a; --muted: #6b7280;
  --line: #e5e7eb; --accent: #5a31f4; --up: #0a8a3e; --down: #c0392b; --new: #2563eb;
}
* { box-sizing: border-box; }
body { margin: 0; font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
       color: var(--ink); background: var(--bg); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
.topbar { display: flex; align-items: center; gap: 16px; padding: 12px 24px;
          background: #1a1130; color: #fff; }
.topbar .brand { font-weight: 800; font-size: 20px; letter-spacing: 1px; color: #fff; }
.topbar .tagline { color: #b9aee8; font-size: 13px; }
.topbar nav { margin-left: auto; display: flex; gap: 18px; }
.topbar nav a { color: #d7cfff; }
.wrap { max-width: 1100px; margin: 0 auto; padding: 24px; }
.foot { text-align: center; color: var(--muted); padding: 24px; font-size: 12px; }

h1 { font-size: 22px; margin: 0 0 4px; }
h2 { font-size: 16px; margin: 28px 0 10px; }
.sub { color: var(--muted); margin: 0 0 20px; }
.muted { color: var(--muted); }

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px,1fr)); gap: 12px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; }
.stat .n { font-size: 24px; font-weight: 700; }
.stat .l { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }

.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px,1fr)); gap: 12px; }
.tile { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px;
        display: flex; justify-content: space-between; align-items: center; }
.tile small { color: var(--muted); }

/* Hierarchical category browser */
.cat-grid { columns: 3 300px; column-gap: 16px; }
.cat-col { break-inside: avoid; background: var(--card); border: 1px solid var(--line);
           border-radius: 10px; padding: 14px 16px 16px; margin: 0 0 16px; display: inline-block; width: 100%; }
.cat-col h3 { margin: 0 0 10px; font-size: 15px; display: flex; justify-content: space-between;
              align-items: baseline; gap: 8px; padding-bottom: 8px; border-bottom: 1px solid var(--line); }
.cat-col h3 .cnt { font-weight: 500; font-size: 11px; color: var(--muted); white-space: nowrap; }
.cat-tree, .cat-tree ul { list-style: none; margin: 0; padding: 0; }
.cat-tree ul { margin-left: 12px; border-left: 1px solid var(--line); padding-left: 10px; margin-top: 3px; }
.cat-tree li { margin: 3px 0; }
.cat-tree a { display: flex; justify-content: space-between; gap: 8px; padding: 2px 0; }
.cat-tree .grp { font-weight: 600; color: var(--ink); font-size: 13px; }
.cat-tree .cnt { color: var(--muted); font-size: 11px; font-weight: 500; }

table { width: 100%; border-collapse: collapse; background: var(--card);
        border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
th, td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--line); }
th { background: #fafafa; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
tr:last-child td { border-bottom: 0; }
td.rank { font-weight: 700; width: 48px; }
.appcell { display: flex; align-items: center; gap: 10px; }
.appcell img { width: 28px; height: 28px; border-radius: 6px; border: 1px solid var(--line); }
.star { color: #e1a73e; }
.bfs { display: inline-block; font-size: 10px; font-weight: 700; color: #fff; background: var(--accent);
       border-radius: 4px; padding: 1px 5px; vertical-align: middle; }
.price { color: var(--muted); font-size: 12px; }

.delta { font-weight: 700; font-size: 12px; }
.delta.up { color: var(--up); } .delta.down { color: var(--down); }
.delta.flat { color: var(--muted); } .delta.new { color: var(--new); }

.chartbox { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 16px; margin-bottom: 16px; }
canvas { max-width: 100%; }
.banner { background: #fff7e6; border: 1px solid #ffe0a3; color: #7a5b12; padding: 10px 14px;
          border-radius: 8px; margin-bottom: 16px; }

.search { margin-left: 12px; position: relative; }
.search input { width: 200px; padding: 6px 10px; border-radius: 7px; border: 1px solid #3a2d55;
                background: #2a1f47; color: #fff; font-size: 13px; }
.search input::placeholder { color: #9a8fc0; }
.search.big { display: flex; gap: 8px; margin: 8px 0 4px; }
.search.big input { width: 100%; max-width: 480px; background: #fff; color: var(--ink);
                    border: 1px solid var(--line); padding: 10px 12px; font-size: 15px; }
.search.big button { padding: 10px 18px; border: 0; border-radius: 7px; background: var(--accent);
                     color: #fff; font-weight: 600; cursor: pointer; }

/* Typeahead dropdown */
.sg-dropdown { position: absolute; top: calc(100% + 6px); right: 0; width: 360px; max-width: 80vw;
               background: #fff; color: var(--ink); border: 1px solid var(--line);
               border-radius: 10px; box-shadow: 0 12px 30px rgba(0,0,0,.18); overflow: hidden; z-index: 50; }
.search.big .sg-dropdown { left: 0; right: auto; width: 480px; }
.sg-item { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-bottom: 1px solid #f1f1f3; }
.sg-item:last-child { border-bottom: 0; }
.sg-item:hover, .sg-item.active { background: #f4f1ff; text-decoration: none; }
.sg-item img, .sg-noicon { width: 30px; height: 30px; border-radius: 6px; border: 1px solid var(--line);
                           flex-shrink: 0; background: #f3f3f5; }
.sg-text { display: flex; flex-direction: column; min-width: 0; }
.sg-name { font-weight: 600; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sg-meta { font-size: 12px; color: var(--muted); }
.sg-rating { color: #b8791f; font-weight: 600; }
.sg-empty { padding: 12px; color: var(--muted); }

/* Follow box + buttons */
.follow-box { background: var(--card); border: 1px solid var(--line); border-radius: 10px;
              padding: 14px 16px; margin: 4px 0 22px; }
.follow-form { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.follow-form input[type=email] { flex: 1; min-width: 220px; max-width: 340px; padding: 9px 12px;
              border: 1px solid var(--line); border-radius: 7px; font-size: 14px; }
.follow-form button { padding: 9px 20px; border: 0; border-radius: 7px; background: var(--accent);
              color: #fff; font-weight: 600; cursor: pointer; }
.banner.ok { background: #e9f9ef; border-color: #b4e6c6; color: #0a6b32; }
.btn-link { background: none; border: 0; color: var(--down); cursor: pointer; font-size: 13px; padding: 0; }
.btn-link:hover { text-decoration: underline; }
.btn-secondary { padding: 8px 14px; border: 1px solid var(--line); border-radius: 7px;
              background: #fff; color: var(--ink); cursor: pointer; font-size: 13px; }
.btn-secondary:hover { background: #f4f1ff; }
