/* Rank Tracker: small, build-free stylesheet */
:root {
  --bg: #f5f6f8; --surface: #fff; --text: #1b1f24; --muted: #6b7280; --line: #e3e6ea;
  --brand: #2554c7; --brand-ink: #fff; --up: #15803d; --down: #c2261b; --warn-bg: #fff6e0; --warn: #8a5a00;
  --err-bg: #fdecea; --ok-bg: #e8f6ee; --chip: #eef1f5; --radius: 10px;
  --shadow: 0 1px 2px rgba(16,24,40,.06), 0 1px 3px rgba(16,24,40,.08);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans Arabic", Tahoma, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root { --bg:#111418; --surface:#1a1e24; --text:#e6e8eb; --muted:#9aa3ae; --line:#2b313a; --brand:#5b8cff;
    --chip:#252b34; --warn-bg:#3a2e12; --warn:#f4c76b; --err-bg:#3d1c1a; --ok-bg:#16301f; --up:#4ade80; --down:#f87171; }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.45; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; margin: 0 0 4px; } h1 small { font-size: 14px; font-weight: 400; }
h2 { font-size: 16px; margin: 0 0 12px; }
code { background: var(--chip); padding: 1px 5px; border-radius: 4px; }
.muted { color: var(--muted); } .small { font-size: 12px; } .nowrap { white-space: nowrap; }
.up { color: var(--up); font-weight: 600; } .down { color: var(--down); font-weight: 600; }
.rtl, [dir="rtl"] { direction: rtl; unicode-bidi: plaintext; }

.topbar { display: flex; align-items: center; gap: 16px; padding: 10px 20px; background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
.brand { font-weight: 700; font-size: 16px; color: var(--text); }
.project-switch { max-width: 240px; }
.topbar nav { margin-left: auto; display: flex; gap: 14px; align-items: center; }
.topbar nav a { color: var(--muted); } .topbar nav a.on { color: var(--text); font-weight: 600; }
.mode { font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 99px; }
.mode-sandbox { background: var(--warn-bg); color: var(--warn); } .mode-live { background: var(--ok-bg); color: var(--up); }

.wrap { max-width: 1400px; margin: 0 auto; padding: 20px; }
.foot { text-align: center; color: var(--muted); font-size: 12px; padding: 20px; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 16px; }
.crumbs { font-size: 12px; color: var(--muted); margin-bottom: 4px; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; margin-bottom: 16px; }
.cards { display: grid; gap: 12px; margin-bottom: 16px; }
.cards .card { margin: 0; }
.cards-3 { grid-template-columns: repeat(3, 1fr); } .cards-4 { grid-template-columns: repeat(4, 1fr); } .cards-6 { grid-template-columns: repeat(6, 1fr); }
.stat-label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .03em; }
.stat-value { font-size: 26px; font-weight: 700; margin-top: 2px; } .stat-value small { font-size: 14px; color: var(--muted); font-weight: 400; }
.meter { height: 6px; background: var(--chip); border-radius: 99px; overflow: hidden; margin-top: 8px; }
.meter span { display: block; height: 100%; background: var(--brand); }
.empty { text-align: center; color: var(--muted); padding: 28px; }

.project-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); gap: 12px; margin-bottom: 16px; }
.project-grid .card { margin: 0; }
.project-card-head { display: flex; justify-content: space-between; align-items: center; }
.project-name { font-size: 17px; font-weight: 700; color: var(--text); }
.mini-stats { display: grid; grid-template-columns: repeat(6, 1fr); gap: 4px; margin: 12px 0; text-align: center; }
.mini-stats b { display: block; font-size: 17px; } .mini-stats span { font-size: 11px; color: var(--muted); }

.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 8px; }
.page-head .actions { margin-top: 0; }
.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: var(--surface); color: var(--text); padding: 7px 12px; border-radius: 8px; cursor: pointer; font: inherit; font-weight: 500; text-decoration: none !important; }
.btn:hover { border-color: var(--muted); }
.btn-primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn-danger { background: var(--down); border-color: var(--down); color: #fff; }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-sm { padding: 4px 9px; font-size: 13px; }
form.inline { display: inline; margin: 0; }

input, select, textarea { font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 7px 9px; width: 100%; }
input[type=checkbox] { width: auto; }
textarea { resize: vertical; }
label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); font-weight: 500; }
label.check { flex-direction: row; align-items: center; gap: 8px; color: var(--text); font-size: 14px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; align-items: end; }
.form-grid .span-2 { grid-column: span 2; } .form-grid .span-all { grid-column: 1 / -1; }
.inline-details { display: inline-block; }
.inline-details[open] { display: block; width: 100%; margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--line); }
.inline-details summary { list-style: none; } .inline-details summary::-webkit-details-marker { display: none; }
.danger-zone { margin-top: 12px; display: flex; gap: 8px; align-items: end; }

.alert { padding: 10px 14px; border-radius: 8px; margin-bottom: 12px; }
.alert-ok { background: var(--ok-bg); } .alert-warn { background: var(--warn-bg); color: var(--warn); } .alert-err { background: var(--err-bg); color: var(--down); }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin: -4px 0 16px; flex-wrap: wrap; }
.tabs button { border: 0; background: none; padding: 8px 12px; cursor: pointer; font: inherit; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs button.on { color: var(--text); border-bottom-color: var(--brand); font-weight: 600; }

.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.toolbar input[type=search] { max-width: 260px; } .toolbar select, .toolbar input { width: auto; }
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.table th { font-size: 12px; color: var(--muted); font-weight: 600; white-space: nowrap; position: sticky; top: 0; background: var(--surface); cursor: pointer; user-select: none; }
.table th.nosort { cursor: default; }
.table th.sort-asc::after { content: " ▲"; } .table th.sort-desc::after { content: " ▼"; }
.table .num { text-align: right; white-space: nowrap; }
.table tbody tr:hover { background: var(--bg); }
.table tr.paused { opacity: .6; }
.comp { color: var(--muted); }
.kw-link { font-weight: 600; color: var(--text); }
.kw-link.rtl { font-family: "Noto Sans Arabic", Tahoma, sans-serif; font-size: 15px; display: inline-block; }
.kw-meta { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 4px; }
.chip { display: inline-block; font-size: 11px; background: var(--chip); color: var(--muted); padding: 1px 7px; border-radius: 99px; }
.chip-group { color: var(--brand); } .chip-off { color: var(--down); }
.feat { font-size: 10px; border: 1px solid var(--line); color: var(--muted); padding: 0 6px; border-radius: 4px; }
.pos { display: inline-block; min-width: 36px; text-align: center; padding: 2px 6px; border-radius: 6px; background: var(--chip); }
.pos.top3 { background: #dcfce7; color: #166534; } .pos.\34-10 { background: #e0ecff; color: #1d4ed8; }
@media (prefers-color-scheme: dark) { .pos.top3 { background: #14532d; color: #bbf7d0; } .pos.\34-10 { background: #1e3a8a; color: #dbeafe; } }
.url-cell { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pill { border: 0; border-radius: 99px; padding: 2px 10px; font-size: 12px; cursor: pointer; }
.pill-on { background: var(--ok-bg); color: var(--up); } .pill-off { background: var(--chip); color: var(--muted); }
.list { list-style: none; padding: 0; margin: 0 0 12px; } .list li { padding: 6px 0; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; gap: 8px; }

.dropdown { position: relative; }
.dropdown-menu { display: none; position: absolute; right: 0; top: calc(100% + 4px); background: var(--surface); border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow); min-width: 220px; z-index: 30; }
.dropdown.open .dropdown-menu { display: block; }
.dropdown-menu a { display: block; padding: 9px 12px; color: var(--text); } .dropdown-menu a:hover { background: var(--bg); text-decoration: none; }

.modal { border: 0; border-radius: 12px; padding: 18px; width: min(900px, 95vw); background: var(--surface); color: var(--text); box-shadow: 0 10px 40px rgba(0,0,0,.25); }
.modal::backdrop { background: rgba(0,0,0,.4); }
.modal-head { display: flex; justify-content: space-between; align-items: center; }
.chart-box { position: relative; height: 380px; }
.confirm-card { max-width: 720px; margin: 0 auto; }
.confirm-actions { display: flex; flex-direction: column; gap: 10px; }

.login-body { display: grid; place-items: center; min-height: 100vh; }
.login-card { width: 340px; display: flex; flex-direction: column; gap: 12px; }

@media (max-width: 1000px) { .cards-6 { grid-template-columns: repeat(3, 1fr); } .cards-4 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 640px) {
  .cards-3, .cards-6, .cards-4 { grid-template-columns: repeat(2, 1fr); }
  .topbar { flex-wrap: wrap; } .project-switch { max-width: 100%; }
  .wrap { padding: 12px; } .form-grid .span-2 { grid-column: 1 / -1; }
}
