:root {
  --bg: #f5f6fa;
  --surface: #ffffff;
  --surface-2: #f8f9fc;
  --border: #e6e8ef;
  --border-strong: #d6d9e3;
  --text: #16181f;
  --text-2: #5b6170;
  --text-3: #9096a5;
  --accent: #4f46e5;
  --accent-hover: #4338ca;
  --accent-soft: #eef0ff;
  --accent-text: #3730a3;
  --up: #15803d;
  --up-soft: #e7f7ec;
  --down: #c62828;
  --down-soft: #fdecec;
  --new: #1d4ed8;
  --new-soft: #e5edff;
  --warn: #b45309;
  --warn-soft: #fff4e0;
  --gold: #f59e0b;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 1px 2px rgba(20, 24, 40, .04), 0 4px 16px rgba(20, 24, 40, .05);
  --shadow-lg: 0 8px 40px rgba(20, 24, 40, .16);
  --font: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --primary-text: #fff;
  --primary-shadow: rgba(79, 70, 229, .25);
  --focus-ring: rgba(79, 70, 229, .15);
  --topbar-bg: rgba(255, 255, 255, .86);
  --brand-grad: linear-gradient(135deg, #6366f1, #4338ca);
  --brand-shadow: rgba(79, 70, 229, .3);
  --btn-hover-border: #c4c8d4;
  --ghost-hover: rgba(0, 0, 0, .05);
  --danger-border: #f2c2c2;
  --seg-bg: #ecedf3;
  --chip-on-bg: #fff8e6; --chip-on-border: #f6d58a; --chip-on-text: #92400e;
  --bar-bg: #e2e4ec;
  --muted-bg: #eef0f4;
  --star-off: #c9cdd8;
  --row-hover: #fafbfe;
  --p1: #166534; --p3: #15803d; --p10: #1e40af;
  --heat-1: #dcf5e3; --heat-3: #eaf8ee; --heat-10: #f2f7ff;
  --login-glow: #e8e9ff;
  --toast-bg: #1b1e2b; --toast-err: #b91c1c; --toast-ok: #166534;
  --sk-a: #eceef3; --sk-b: #f5f6fa;
  --chart: #4f46e5;
  color-scheme: light;
}

/* Чёрно-белая тема */
:root[data-theme="mono"] {
  --bg: #0b0b0b;
  --surface: #141414;
  --surface-2: #1b1b1b;
  --border: #262626;
  --border-strong: #333333;
  --text: #f5f5f5;
  --text-2: #a3a3a3;
  --text-3: #6f6f6f;
  --accent: #ffffff;
  --accent-hover: #e6e6e6;
  --accent-soft: #262626;
  --accent-text: #ffffff;
  --up: #ffffff;
  --up-soft: #2a2a2a;
  --down: #8a8a8a;
  --down-soft: #1d1d1d;
  --new: #ffffff;
  --new-soft: #2a2a2a;
  --warn: #c8c8c8;
  --warn-soft: #1f1f1f;
  --gold: #ffffff;
  --shadow: 0 1px 2px rgba(0, 0, 0, .5), 0 4px 16px rgba(0, 0, 0, .35);
  --shadow-lg: 0 8px 40px rgba(0, 0, 0, .7);
  --primary-text: #000;
  --primary-shadow: rgba(255, 255, 255, .12);
  --focus-ring: rgba(255, 255, 255, .18);
  --topbar-bg: rgba(11, 11, 11, .88);
  --brand-grad: linear-gradient(135deg, #ffffff, #bdbdbd);
  --brand-shadow: rgba(255, 255, 255, .15);
  --btn-hover-border: #4a4a4a;
  --ghost-hover: rgba(255, 255, 255, .08);
  --danger-border: #4a4a4a;
  --seg-bg: #1f1f1f;
  --chip-on-bg: #ffffff; --chip-on-border: #ffffff; --chip-on-text: #000000;
  --bar-bg: #333;
  --muted-bg: #262626;
  --star-off: #3d3d3d;
  --row-hover: #191919;
  --p1: #ffffff; --p3: #ffffff; --p10: #e0e0e0;
  --heat-1: #333333; --heat-3: #262626; --heat-10: #1c1c1c;
  --login-glow: #1e1e1e;
  --toast-bg: #f5f5f5; --toast-err: #f5f5f5; --toast-ok: #f5f5f5;
  --sk-a: #1f1f1f; --sk-b: #2a2a2a;
  --chart: #ffffff;
  color-scheme: dark;
}
:root[data-theme="mono"] .toast { color: #000; }
:root[data-theme="mono"] .brand-mark svg { stroke: #000; }
:root[data-theme="mono"] .chip-toggle.active svg { color: #000; fill: #000; }
:root[data-theme="mono"] .delta.down { color: #bdbdbd; }
:root[data-theme="mono"] .status .dot { background: #fff; }
:root[data-theme="mono"] .status.running .dot { animation-name: pulse-mono; }
@keyframes pulse-mono { 0%, 100% { box-shadow: 0 0 0 0 rgba(255, 255, 255, .5); } 70% { box-shadow: 0 0 0 6px rgba(255, 255, 255, 0); } }

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.45;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  font-feature-settings: 'cv11', 'ss01', 'tnum';
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent); text-decoration: none; }
::selection { background: var(--accent-soft); }

/* ---------- layout ---------- */
.shell { min-height: 100vh; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 30;
  background: var(--topbar-bg);
  backdrop-filter: saturate(160%) blur(12px);
  border-bottom: 1px solid var(--border);
}
.topbar-in {
  max-width: 1600px; margin: 0 auto; padding: 0 24px; height: 60px;
  display: flex; align-items: center; gap: 14px;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 15px; letter-spacing: -.01em; margin-right: 6px; }
.brand-mark { width: 30px; height: 30px; border-radius: 9px; background: var(--brand-grad); display: grid; place-items: center; box-shadow: 0 4px 10px var(--brand-shadow); }
.brand-mark svg { width: 18px; height: 18px; }
.grow { flex: 1; }
.main { max-width: 1600px; width: 100%; margin: 0 auto; padding: 22px 24px 60px; }

/* ---------- controls ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 7px; height: 36px; padding: 0 14px;
  border-radius: var(--radius-sm); border: 1px solid var(--border-strong); background: var(--surface);
  font-weight: 500; white-space: nowrap; transition: background .12s, border-color .12s, box-shadow .12s, transform .05s;
}
.btn:hover { background: var(--surface-2); border-color: var(--btn-hover-border); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: default; transform: none; }
.btn svg { width: 16px; height: 16px; flex: none; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--primary-text); box-shadow: 0 2px 6px var(--primary-shadow); }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-danger { color: var(--down); }
.btn-danger:hover { background: var(--down-soft); border-color: var(--danger-border); }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-ghost:hover { background: var(--ghost-hover); border-color: transparent; }
.btn-sm { height: 30px; padding: 0 10px; font-size: 13px; }
.btn-icon { width: 36px; padding: 0; justify-content: center; }

.input, .select, .textarea {
  height: 36px; padding: 0 12px; border-radius: var(--radius-sm); border: 1px solid var(--border-strong);
  background: var(--surface); outline: none; transition: border-color .12s, box-shadow .12s; width: 100%;
}
.textarea { height: auto; padding: 10px 12px; resize: vertical; min-height: 120px; line-height: 1.5; }
.input:focus, .select:focus, .textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--focus-ring); }
.select { appearance: none; padding-right: 32px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%235b6170' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m4 6 4 4 4-4'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 12.5px; font-weight: 600; color: var(--text-2); }
.hint { font-size: 12.5px; color: var(--text-3); }

.seg { display: inline-flex; background: var(--seg-bg); padding: 3px; border-radius: 10px; gap: 2px; }
.seg button { height: 30px; padding: 0 13px; border: 0; background: transparent; border-radius: 8px; font-weight: 500; color: var(--text-2); transition: all .12s; }
.seg button:hover { color: var(--text); }
.seg button.active { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(0, 0, 0, .25); }

.search { position: relative; }
.search svg { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); width: 15px; height: 15px; color: var(--text-3); }
.search .input { padding-left: 34px; }

/* ---------- app selector ---------- */
.app-select { position: relative; }
.app-btn {
  display: flex; align-items: center; gap: 10px; height: 40px; padding: 4px 12px 4px 5px; border-radius: 11px;
  border: 1px solid var(--border-strong); background: var(--surface); min-width: 240px; max-width: 360px;
}
.app-btn:hover { background: var(--surface-2); }
.app-icon { width: 30px; height: 30px; border-radius: 8px; background: var(--surface-2); object-fit: cover; flex: none; }
.app-icon.lg { width: 44px; height: 44px; border-radius: 12px; }
.app-btn .title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.app-btn .sub { font-size: 12px; color: var(--text-3); display: flex; gap: 6px; align-items: center; }
.app-btn .chev { margin-left: auto; color: var(--text-3); flex: none; }
.dropdown {
  position: absolute; top: calc(100% + 6px); left: 0; z-index: 40; min-width: 320px; max-width: 420px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow-lg); padding: 6px;
}
.dropdown .item { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; width: 100%; border: 0; background: transparent; text-align: left; }
.dropdown .item:hover { background: var(--surface-2); }
.dropdown .item.active { background: var(--accent-soft); }
.dropdown .item .title { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dropdown .item .sub { font-size: 12px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dropdown .sep { height: 1px; background: var(--border); margin: 6px 4px; }
.flag { font-size: 14px; line-height: 1; }
.rating { display: inline-flex; align-items: center; gap: 4px; color: var(--text-2); font-weight: 500; }
.rating svg { width: 13px; height: 13px; color: var(--gold); }

/* ---------- app card ---------- */
.app-card { margin-bottom: 18px; overflow: hidden; }
.app-head { display: flex; align-items: flex-start; gap: 18px; padding: 20px 22px 16px; }
.app-icon.xl { width: 84px; height: 84px; border-radius: 20px; box-shadow: var(--shadow); flex: none; }
.app-info { min-width: 0; flex: 1; display: flex; flex-direction: column; gap: 5px; }
.app-title { font-size: 22px; font-weight: 700; letter-spacing: -.02em; line-height: 1.2; display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.app-title .ver { font-size: 12px; font-weight: 600; color: var(--text-3); background: var(--muted-bg); padding: 2px 8px; border-radius: 6px; }
.app-sub { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-size: 13px; color: var(--text-2); }
.app-sub i { width: 3px; height: 3px; border-radius: 50%; background: var(--text-3); display: inline-block; }
.app-id { font-size: 12.5px; }
.app-id a { color: var(--text-3); }
.app-id a:hover { color: var(--accent); }
.app-actions { flex: none; }
.app-metrics { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); border-top: 1px solid var(--border); }
.metric { padding: 14px 22px 12px; border-right: 1px solid var(--border); display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.metric:last-child { border-right: 0; }
.m-label { font-size: 11.5px; font-weight: 600; color: var(--text-3); text-transform: uppercase; letter-spacing: .05em; }
.m-value { font-size: 24px; font-weight: 700; letter-spacing: -.02em; line-height: 1.15; display: flex; align-items: baseline; gap: 8px; }
.m-sub { font-size: 12px; color: var(--text-3); }
.m-stars { color: var(--gold); font-size: 13px; letter-spacing: 1px; }
.spark { width: 100%; height: 36px; margin-top: 6px; display: block; }
.spark-line { fill: none; stroke: var(--chart); stroke-width: 1.8; stroke-linejoin: round; stroke-linecap: round; vector-effect: non-scaling-stroke; }
.spark-area { fill: var(--chart); opacity: .1; }
.spark-dot { fill: var(--chart); }
.spark-base { stroke: var(--border); stroke-dasharray: 3 3; }
.hist { display: flex; flex-direction: column; gap: 4px; margin-top: 2px; }
.hist-row { display: grid; grid-template-columns: 12px 1fr 40px; align-items: center; gap: 8px; font-size: 12px; color: var(--text-2); }
.hist-row b { font-weight: 600; color: var(--text); text-align: right; font-size: 12px; }
.hist-bar { height: 7px; border-radius: 4px; background: var(--muted-bg); overflow: hidden; }
.hist-bar i { display: block; height: 100%; background: var(--gold); border-radius: 4px; }
.app-foot { display: flex; gap: 14px; flex-wrap: wrap; padding: 10px 22px; border-top: 1px solid var(--border); background: var(--surface-2); }
@media (max-width: 560px) { .app-metrics { grid-template-columns: 1fr; } .metric { border-right: 0; border-bottom: 1px solid var(--border); } .app-head { flex-wrap: wrap; } }

/* ---------- firebase ---------- */
.fb-card { margin-bottom: 18px; }
.fb-head { display: flex; align-items: center; gap: 10px; padding: 14px 22px 0; }
.fb-title { display: inline-flex; align-items: center; gap: 8px; font-weight: 700; font-size: 14px; }
.fb-title svg { width: 18px; height: 18px; color: #f59e0b; }
:root[data-theme="mono"] .fb-title svg { color: #fff; }
.fb-body { padding: 12px 22px 16px; }
.fb-grid { display: grid; grid-template-columns: minmax(260px, 1fr) 2fr; gap: 0; margin-top: 10px; border-top: 1px solid var(--border); }
.fb-tile { padding: 14px 22px 16px; border-right: 1px solid var(--border); min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.fb-tile.wide { border-right: 0; }
.fb-tile .m-value small { font-size: 12px; font-weight: 500; color: var(--text-3); }
.live-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--up); margin-right: 4px; vertical-align: middle; animation: pulse 1.4s infinite; }
.bars { display: flex; align-items: flex-end; gap: 3px; height: 70px; margin-top: 6px; }
.bars.mins i { flex: 1; background: var(--chart); opacity: .7; border-radius: 2px 2px 0 0; display: block; min-width: 3px; }
.bars.mins i:last-child { opacity: 1; }
.bars-axis { display: flex; justify-content: space-between; font-size: 10.5px; color: var(--text-3); }
.bars.days { height: 120px; gap: 10px; }
.bars.days .day { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; min-width: 0; }
.bars.days .day b { font-size: 12px; font-weight: 600; margin-bottom: 4px; }
.bars.days .day i { display: block; width: 100%; max-width: 56px; background: var(--chart); opacity: .75; border-radius: 6px 6px 0 0; }
.bars.days .day:last-child i { opacity: 1; }
.bars.days .day span { font-size: 10.5px; color: var(--text-3); margin-top: 6px; white-space: nowrap; }
@media (max-width: 900px) { .fb-grid { grid-template-columns: 1fr; } .fb-tile { border-right: 0; border-bottom: 1px solid var(--border); } .fb-tile.wide { border-bottom: 0; } }

/* ---------- payments ---------- */
.pay-tiles { display: grid; grid-template-columns: repeat(3, 1fr); border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); margin-top: 10px; }
.pay-tile { padding: 14px 22px; border-right: 1px solid var(--border); display: flex; flex-direction: column; gap: 4px; }
.pay-tile:last-child { border-right: 0; }
.pay-table-wrap { overflow-x: auto; }
.pay-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.pay-table th { text-align: left; font-weight: 500; font-size: 12px; color: var(--text-3); padding: 12px 14px 8px; white-space: nowrap; border-bottom: 1px solid var(--border); }
.pay-table th:first-child, .pay-table td:first-child { padding-left: 22px; }
.pay-table th:last-child, .pay-table td:last-child { padding-right: 22px; }
.pay-table td { padding: 10px 14px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.pay-table tr:last-child td { border-bottom: 0; }
.pay-table .r { text-align: right; }
.pay-table .muted { color: var(--text-3); }
.pay-table .amt { font-weight: 600; }
.pay-table .amt.ok { color: var(--up); }
.pay-table .amt.bad { color: var(--down); }
.pay-table .amt.muted { color: var(--text-3); }
.pst { display: inline-flex; align-items: center; gap: 6px; }
.pst::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: var(--text-3); }
.pst.ok::before { background: var(--up); }
.pst.bad::before { background: var(--down); }
.pay-foot { display: flex; align-items: center; gap: 12px; padding: 10px 22px; border-top: 1px solid var(--border); background: var(--surface-2); }
@media (max-width: 760px) { .pay-tiles { grid-template-columns: 1fr; } .pay-tile { border-right: 0; border-bottom: 1px solid var(--border); } }

/* ---------- store tabs ---------- */
.store-tabs { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; margin-bottom: 14px; }
.project-name { font-size: 15px; font-weight: 700; letter-spacing: -.01em; display: inline-flex; align-items: center; gap: 6px; cursor: pointer; color: var(--text); }
.project-name svg { color: var(--text-3); opacity: 0; transition: opacity .12s; }
.project-name:hover svg { opacity: 1; }
.tabs { display: inline-flex; gap: 4px; background: var(--seg-bg); padding: 3px; border-radius: 12px; flex-wrap: wrap; }
.tab { display: inline-flex; align-items: center; gap: 7px; height: 36px; padding: 0 14px; border: 0; border-radius: 9px; background: transparent; color: var(--text-2); font-weight: 600; transition: all .12s; }
.tab:hover { color: var(--text); }
.tab.active { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(0, 0, 0, .18); }
.tab .tab-sub { font-size: 11px; font-weight: 500; color: var(--text-3); margin-left: 2px; }
.tab.add { color: var(--text-3); font-weight: 500; }
.tab.add svg { width: 14px; height: 14px; }
.tab.add:hover { color: var(--accent); }
.app-actions { display: flex; gap: 6px; }

/* ---------- store badges ---------- */
.store-badge { display: inline-flex; align-items: center; height: 16px; padding: 0 5px; border-radius: 5px; font-size: 10px; font-weight: 700; letter-spacing: .04em; line-height: 1; vertical-align: middle; }
.store-badge.big { height: 22px; padding: 0 8px; font-size: 11.5px; border-radius: 7px; }
.store-badge.st-gp { background: #e3f4e8; color: #1b7a3d; }
.store-badge.st-rs { background: #e6ecff; color: #2f4bd6; }
:root[data-theme="mono"] .store-badge.st-gp { background: #2a2a2a; color: #fff; }
:root[data-theme="mono"] .store-badge.st-rs { background: #ffffff; color: #000; }
.dd-group { display: flex; align-items: center; gap: 6px; padding: 8px 10px 4px; font-size: 11px; font-weight: 600; color: var(--text-3); text-transform: uppercase; letter-spacing: .05em; }
.dd-group + .item { margin-top: 0; }
.app-sub .store-badge { margin-right: 2px; }

/* ---------- status pill ---------- */
.status { display: inline-flex; align-items: center; gap: 8px; height: 32px; padding: 0 12px 0 10px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); font-size: 12.5px; color: var(--text-2); }
.status .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--up); }
.status.running .dot { background: var(--accent); animation: pulse 1.2s infinite; }
.status.error .dot { background: var(--down); }
@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(79, 70, 229, .5); } 70% { box-shadow: 0 0 0 6px rgba(79, 70, 229, 0); } }
.status .bar { width: 70px; height: 4px; border-radius: 4px; background: var(--bar-bg); overflow: hidden; }
.status .bar i { display: block; height: 100%; background: var(--accent); transition: width .3s; }

/* ---------- cards / stats ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 18px; }
.stat { padding: 14px 16px; display: flex; flex-direction: column; gap: 4px; }
.stat .label { font-size: 12px; font-weight: 600; color: var(--text-3); text-transform: uppercase; letter-spacing: .04em; }
.stat .value { font-size: 26px; font-weight: 700; letter-spacing: -.02em; line-height: 1.1; display: flex; align-items: baseline; gap: 8px; }
.stat .value small { font-size: 13px; font-weight: 500; color: var(--text-3); }
.delta { display: inline-flex; align-items: center; gap: 2px; font-size: 12px; font-weight: 600; padding: 1px 6px; border-radius: 6px; line-height: 1.4; }
.delta.up { color: var(--up); background: var(--up-soft); }
.delta.down { color: var(--down); background: var(--down-soft); }
.delta.zero { color: var(--text-3); background: var(--muted-bg); }

.toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.toolbar .search { width: 260px; }
.toolbar .select { width: auto; min-width: 150px; }
.chip-toggle { height: 36px; padding: 0 12px; border-radius: var(--radius-sm); border: 1px solid var(--border-strong); background: var(--surface); display: inline-flex; align-items: center; gap: 6px; font-weight: 500; }
.chip-toggle.active { background: var(--chip-on-bg); border-color: var(--chip-on-border); color: var(--chip-on-text); }
.chip-toggle svg { width: 15px; height: 15px; }
.chip-toggle.active svg { color: var(--gold); fill: var(--gold); }
.date-range { color: var(--text-2); font-size: 13px; display: inline-flex; align-items: center; gap: 8px; }
.date-range svg { width: 15px; height: 15px; color: var(--text-3); }

/* ---------- table ---------- */
.table-wrap { overflow: auto; border-radius: var(--radius); position: relative; max-height: calc(100vh - 150px); }
table.grid { border-collapse: separate; border-spacing: 0; width: 100%; min-width: 100%; }
.grid th, .grid td { border-bottom: 1px solid var(--border); border-right: 1px solid var(--border); padding: 0; }
.grid th { position: sticky; top: 0; z-index: 3; background: var(--surface-2); font-weight: 600; font-size: 12px; color: var(--text-2); }
.grid th.sticky, .grid td.sticky { position: sticky; z-index: 2; background: var(--surface); }
.grid th.sticky { z-index: 4; background: var(--surface-2); }
.grid th.c-check, .grid td.c-check { left: 0; width: 42px; min-width: 42px; text-align: center; }
.grid th.c-fav, .grid td.c-fav { left: 42px; width: 38px; min-width: 38px; text-align: center; }
.grid th.c-kw, .grid td.c-kw { left: 80px; min-width: 260px; max-width: 360px; box-shadow: 4px 0 8px -4px rgba(0, 0, 0, .08); }
.grid th.c-kw { text-align: left; padding: 0 12px; }
.grid td.c-kw { padding: 0 12px; }
.grid th.c-day { min-width: 58px; width: 58px; text-align: center; padding: 8px 4px; vertical-align: top; }
.grid th.c-day.today { background: var(--accent-soft); color: var(--accent-text); }
.grid th.c-day .d { font-size: 12.5px; font-weight: 600; display: block; }
.grid th.c-day .wd { font-size: 10px; text-transform: uppercase; letter-spacing: .04em; color: var(--text-3); font-weight: 600; }
.grid th.c-day .n { display: inline-block; margin-top: 4px; min-width: 20px; padding: 1px 5px; border-radius: 6px; font-size: 11px; font-weight: 600; background: var(--up-soft); color: var(--up); }
.grid th.c-day .n.empty { background: var(--muted-bg); color: var(--text-3); }
.grid td.c-day { text-align: center; height: 52px; vertical-align: middle; }
.grid tr:hover td { background: var(--row-hover); }
.grid tr:hover td.sticky { background: var(--row-hover); }
.grid tr.selected td, .grid tr.selected td.sticky { background: var(--accent-soft); }
.grid tbody tr { cursor: pointer; }

.pos { display: flex; flex-direction: column; align-items: center; gap: 1px; line-height: 1.15; }
.pos .num { font-size: 14px; font-weight: 600; }
.pos .num.p1 { color: var(--p1); }
.pos .num.p3 { color: var(--p3); }
.pos .num.p10 { color: var(--p10); }
.pos .num.none { color: var(--text-3); font-weight: 500; }
.pos .num.out { color: var(--text-3); font-weight: 500; font-size: 12px; }
.pos .num.err { color: var(--warn); font-size: 11px; font-weight: 600; text-transform: lowercase; }
.pos .d { font-size: 10.5px; font-weight: 600; height: 13px; }
.pos .d.up { color: var(--up); }
.pos .d.down { color: var(--down); }
.pos .d.new { color: var(--new); }
.pos .d.lost { color: var(--down); }
td.c-day.heat-1 { background: var(--heat-1) !important; }
td.c-day.heat-3 { background: var(--heat-3) !important; }
td.c-day.heat-10 { background: var(--heat-10) !important; }
td.c-day.heat-err { background: var(--warn-soft) !important; }

.kw-cell { display: flex; align-items: center; gap: 8px; min-height: 52px; }
.kw-text { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tag { font-size: 11px; font-weight: 600; padding: 1px 7px; border-radius: 6px; background: var(--muted-bg); color: var(--text-2); white-space: nowrap; }
.star { width: 18px; height: 18px; color: var(--star-off); transition: color .1s, transform .1s; }
.star.on { color: var(--gold); fill: var(--gold); }
.star-btn { background: none; border: 0; padding: 6px; display: inline-flex; border-radius: 6px; }
.star-btn:hover .star { transform: scale(1.15); color: var(--gold); }
.check { width: 16px; height: 16px; accent-color: var(--accent); cursor: pointer; }

.empty { padding: 60px 20px; text-align: center; color: var(--text-2); }
.empty h3 { margin: 12px 0 6px; font-size: 17px; font-weight: 600; color: var(--text); }
.empty p { margin: 0 0 18px; max-width: 460px; margin-inline: auto; }
.empty .ill { width: 64px; height: 64px; border-radius: 18px; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; margin: 0 auto; }
.empty .ill svg { width: 30px; height: 30px; }

/* ---------- modal ---------- */
.overlay { position: fixed; inset: 0; background: rgba(0, 0, 0, .55); z-index: 100; display: flex; align-items: flex-start; justify-content: center; padding: 60px 16px; overflow: auto; animation: fade .12s; }
@keyframes fade { from { opacity: 0; } }
.modal { width: 100%; max-width: 560px; background: var(--surface); border-radius: 18px; box-shadow: var(--shadow-lg); animation: rise .16s ease-out; }
.modal.wide { max-width: 860px; }
@keyframes rise { from { transform: translateY(8px); opacity: 0; } }
.modal-h { display: flex; align-items: center; gap: 12px; padding: 18px 22px 0; }
.modal-h h2 { margin: 0; font-size: 17px; font-weight: 700; letter-spacing: -.01em; }
.modal-h .close { margin-left: auto; }
.modal-b { padding: 16px 22px; display: flex; flex-direction: column; gap: 14px; }
.modal-f { padding: 0 22px 20px; display: flex; gap: 10px; justify-content: flex-end; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.err-msg { color: var(--down); font-size: 13px; background: var(--down-soft); padding: 8px 12px; border-radius: 8px; }
.suggest { display: flex; flex-wrap: wrap; gap: 6px; }
.suggest button { border: 1px solid var(--border-strong); background: var(--surface); height: 28px; padding: 0 10px; border-radius: 999px; font-size: 12.5px; }
.suggest button:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.suggest button.added { opacity: .45; }

/* ---------- keyword details ---------- */
.detail-head { display: flex; align-items: center; gap: 14px; }
.detail-head h2 { font-size: 20px; }
.detail-meta { display: flex; gap: 18px; flex-wrap: wrap; font-size: 13px; color: var(--text-2); }
.detail-meta b { color: var(--text); font-weight: 600; }
.chart { width: 100%; height: 190px; display: block; }
.chart .line { fill: none; stroke: var(--chart); stroke-width: 2.2; stroke-linejoin: round; stroke-linecap: round; }
.chart .area { fill: url(#grad); }
.chart .pt { fill: var(--surface); stroke: var(--chart); stroke-width: 2; }
.chart .axis { stroke: var(--border); }
.chart text { font-size: 10px; fill: var(--text-3); }
.top-list { display: flex; flex-direction: column; border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
.top-item { display: flex; align-items: center; gap: 12px; padding: 9px 12px; border-bottom: 1px solid var(--border); }
.top-item:last-child { border-bottom: 0; }
.top-item.me { background: var(--accent-soft); }
.top-item .rank { width: 24px; font-weight: 700; color: var(--text-3); text-align: right; font-size: 13px; }
.top-item.me .rank { color: var(--accent); }
.top-item .t { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.top-item .dev { font-size: 12px; color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.top-item .sc { margin-left: auto; font-size: 12.5px; color: var(--text-2); display: inline-flex; gap: 4px; align-items: center; white-space: nowrap; }
.top-item .sc svg { width: 12px; height: 12px; color: var(--gold); }
.section-title { font-size: 12.5px; font-weight: 600; color: var(--text-3); text-transform: uppercase; letter-spacing: .05em; margin: 4px 0 8px; }

/* ---------- login ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: radial-gradient(1200px 600px at 50% -10%, var(--login-glow) 0%, var(--bg) 60%); }
.login .card { width: 100%; max-width: 380px; padding: 30px 28px; }
.login h1 { font-size: 20px; margin: 16px 0 4px; letter-spacing: -.02em; }
.login p { margin: 0 0 20px; color: var(--text-2); }

/* ---------- toasts ---------- */
#toasts { position: fixed; bottom: 20px; right: 20px; z-index: 200; display: flex; flex-direction: column; gap: 8px; }
.toast { background: var(--toast-bg); color: #fff; padding: 10px 14px; border-radius: 10px; box-shadow: var(--shadow-lg); font-size: 13.5px; animation: rise .16s; max-width: 380px; }
.toast.err { background: var(--toast-err); }
.toast.ok { background: var(--toast-ok); }

.sk { background: linear-gradient(90deg, var(--sk-a) 25%, var(--sk-b) 50%, var(--sk-a) 75%); background-size: 200% 100%; animation: sk 1.2s infinite; border-radius: 6px; }
@keyframes sk { to { background-position: -200% 0; } }

@media (max-width: 760px) {
  .topbar-in { padding: 0 14px; gap: 8px; height: auto; flex-wrap: wrap; padding-block: 10px; }
  .main { padding: 14px 14px 40px; }
  .toolbar .search { width: 100%; }
  .app-btn { min-width: 0; max-width: 100%; }
  .grid th.c-kw, .grid td.c-kw { min-width: 180px; }
  .row { grid-template-columns: 1fr; }
  .hide-sm { display: none !important; }
}
