@import url('https://fonts.googleapis.com/css2?family=Vazirmatn:wght@400;500;600;700;800&display=swap');

:root {
  --bg: #0c0f14;
  --bg-card: #141821;
  --bg-card-2: #1a1f2b;
  --border: #262b38;
  --text: #e6e8ec;
  --muted: #8b93a7;
  --green: #22c55e;
  --green-dim: #16341f;
  --red: #ef4444;
  --red-dim: #3a1818;
  --amber: #f59e0b;
  --purple: #8b5cf6;
  --blue: #3b82f6;
  --radius: 12px;
}

/* ─── Light Mode ─── */
body.light-mode {
  --bg: #f0f2f5;
  --bg-card: #ffffff;
  --bg-card-2: #f7f8fa;
  --border: #dde1ea;
  --text: #1a1f2b;
  --muted: #6b7280;
  --green-dim: #d1fae5;
  --red-dim: #fee2e2;
}
body.light-mode code { background: #e8eaf0; }
body.light-mode pre { background: #e8eaf0; }
body.light-mode .topbar { background: var(--bg); }
body.light-mode tr:hover td { background: #f0f4ff; }
body.light-mode td { border-bottom: 1px solid #e8eaf0; }
body.light-mode .nav-item:hover { background: #e8eaf0; }
body.light-mode .nav-item.active { background: var(--green-dim); color: #15803d; }
body.light-mode .tag-green { background: #d1fae5; color: #15803d; }
body.light-mode .tag-red { background: #fee2e2; color: #b91c1c; }
body.light-mode .tag-amber { background: #fef3c7; color: #b45309; }
body.light-mode .tag-purple { background: #ede9fe; color: #7c3aed; }
body.light-mode .tag-blue { background: #dbeafe; color: #1d4ed8; }
body.light-mode .alert-ok { background: #d1fae5; color: #15803d; }
body.light-mode .alert-warn { background: #fef3c7; color: #b45309; }
body.light-mode .alert-danger { background: #fee2e2; color: #b91c1c; }
body.light-mode .btn-secondary { background: #f0f2f5; color: var(--text); }
body.light-mode select, body.light-mode input, body.light-mode textarea {
  background: #ffffff; border-color: #cbd5e1; color: var(--text);
}

/* ─── Theme Toggle Button ─── */
.theme-toggle {
  background: var(--bg-card-2);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 6px 12px;
  cursor: pointer;
  font-size: 14px;
  color: var(--text);
  display: flex; align-items: center; gap: 6px;
  transition: background 0.2s;
}
.theme-toggle:hover { background: var(--border); }

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Vazirmatn', 'Vazir', Tahoma, sans-serif;
  font-size: 14px;
  transition: background 0.2s, color 0.2s;
}

a { color: inherit; text-decoration: none; }
code { background: #1c2230; padding: 2px 6px; border-radius: 6px; font-size: 12px; }
pre { background: #1c2230; padding: 10px; border-radius: 8px; overflow-x: auto; }
.muted { color: var(--muted); }
.small { font-size: 12px; }

/* --- Layout --- */
.layout { display: flex; min-height: 100vh; }

.sidebar {
  width: 230px;
  background: var(--bg-card);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 16px 10px;
  flex-shrink: 0;
}
.brand { font-weight: 700; font-size: 16px; padding: 10px 12px 18px; }
.sidebar nav { display: flex; flex-direction: column; gap: 2px; flex: 1; overflow-y: auto; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: 8px; color: var(--muted); font-size: 13px;
}
.nav-item:hover { background: #1c2230; color: var(--text); }
.nav-item.active { background: var(--green-dim); color: var(--green); font-weight: 600; }
.icon { width: 18px; text-align: center; }
.sidebar-footer { padding-top: 10px; border-top: 1px solid var(--border); margin-top: 8px; }

.content { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 24px; border-bottom: 1px solid var(--border);
  position: sticky; top: 0; background: var(--bg); z-index: 5;
}
.topbar-title { font-weight: 700; font-size: 16px; }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.user-chip { background: var(--bg-card-2); padding: 6px 12px; border-radius: 20px; font-size: 12px; color: var(--muted); }
.page-body { padding: 24px; display: flex; flex-direction: column; gap: 18px; }

select, input, textarea {
  background: var(--bg-card-2); border: 1px solid var(--border); color: var(--text);
  padding: 8px 10px; border-radius: 8px; font-family: inherit; font-size: 13px;
}
.inline-form { display: inline-block; }

/* --- Cards / KPI --- */
.grid { display: grid; gap: 16px; }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
@media (max-width: 1100px) { .grid-4, .grid-3 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 700px) { .grid-4, .grid-3, .grid-2 { grid-template-columns: 1fr; } .sidebar { display:none; } }

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
}
.kpi-label { color: var(--muted); font-size: 12px; margin-bottom: 8px; }
.kpi-value { font-size: 28px; font-weight: 700; }
.kpi-value.green { color: var(--green); }
.kpi-value.red { color: var(--red); }
.kpi-sub { font-size: 12px; color: var(--muted); margin-top: 6px; }

.section-title { font-size: 15px; font-weight: 700; margin: 0 0 12px; display:flex; align-items:center; gap:8px; }

/* --- Table --- */
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: right; color: var(--muted); font-weight: 500; padding: 10px 12px; border-bottom: 1px solid var(--border); }
td { padding: 10px 12px; border-bottom: 1px solid #1c2230; }
tr:hover td { background: #161b25; }
.tag {
  display: inline-block; padding: 2px 10px; border-radius: 20px; font-size: 11px; font-weight: 600;
}
.tag-green { background: var(--green-dim); color: var(--green); }
.tag-red { background: var(--red-dim); color: var(--red); }
.tag-amber { background: #3a2c12; color: var(--amber); }
.tag-purple { background: #2a1f3d; color: var(--purple); }
.tag-blue { background: #16263d; color: var(--blue); }

.badge-count {
  background: var(--bg-card-2); border: 1px solid var(--border);
  border-radius: 20px; padding: 2px 10px; font-size: 12px; color: var(--muted);
}

/* --- Buttons --- */
.btn-primary, .btn-secondary, .btn-danger {
  display: inline-flex; align-items: center; gap: 6px; cursor: pointer;
  border: none; border-radius: 8px; padding: 9px 16px; font-size: 13px; font-weight: 600; font-family: inherit;
}
.btn-primary { background: var(--green); color: #06200f; }
.btn-secondary { background: var(--bg-card-2); color: var(--text); border: 1px solid var(--border); }
.btn-danger { background: var(--red-dim); color: var(--red); }
.btn-primary:hover { opacity: .9; }
.btn-danger:hover { opacity: .85; }

/* --- Alerts --- */
.alert { padding: 12px 16px; border-radius: 10px; font-size: 13px; margin-bottom: 10px; }
.alert-ok { background: var(--green-dim); color: var(--green); }
.alert-warn { background: #3a2c12; color: var(--amber); }
.alert-danger { background: var(--red-dim); color: var(--red); }

/* --- Login / Setup pages --- */
.login-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.login-card {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: 16px;
  padding: 36px; width: 380px; text-align: center;
}
.setup-card { width: 480px; text-align: right; }
.login-card h1 { font-size: 18px; margin-bottom: 6px; }
.btn-google {
  display: block; margin-top: 18px; background: var(--text); color: #0c0f14;
  padding: 11px; border-radius: 8px; font-weight: 700;
}
.form { display: flex; flex-direction: column; gap: 12px; margin-top: 12px; }
.form label { display: flex; flex-direction: column; gap: 6px; font-size: 12px; color: var(--muted); }
.form h3 { font-size: 13px; margin: 10px 0 0; color: var(--text); }

/* --- Misc --- */
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.pill-group { display: flex; gap: 8px; flex-wrap: wrap; }
.empty-state { text-align: center; padding: 40px 20px; color: var(--muted); }

/* --- Danger Zone (settings) --- */
.danger-zone { border-color: var(--red) !important; }
.danger-zone .section-title { color: var(--red); }

/* ─── v3.2 UI refinements: clearer day/night, dashboard modules ─── */
:root {
  color-scheme: dark;
  --shadow: 0 14px 35px rgba(0,0,0,.20);
  --ring: rgba(34,197,94,.22);
}
html[data-theme="light"] body,
body.light-mode {
  --bg: #eef2f7;
  --bg-card: #ffffff;
  --bg-card-2: #f8fafc;
  --border: #d7deea;
  --text: #111827;
  --muted: #64748b;
  --green-dim: #dcfce7;
  --red-dim: #fee2e2;
  color-scheme: light;
}
html[data-theme="dark"] body {
  color-scheme: dark;
}
.card { box-shadow: var(--shadow); }
.hero-card {
  background: linear-gradient(135deg, var(--bg-card), var(--bg-card-2));
  border-color: color-mix(in srgb, var(--border) 80%, var(--green) 20%);
}
.wrap-gap { gap: 12px; flex-wrap: wrap; }
.inline-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.inline-actions input { flex: 1; min-width: 240px; }
.grid-5 { grid-template-columns: repeat(5, 1fr); }
@media (max-width: 1300px) { .grid-5 { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 800px) { .grid-5 { grid-template-columns: 1fr; } .topbar-right { flex-wrap: wrap; justify-content: flex-end; } }
.kpi-card, .mini-card, .rank-bucket-card { position: relative; overflow: hidden; }
.kpi-card:before, .rank-bucket-card:before {
  content: ''; position: absolute; inset: 0 0 auto 0; height: 3px;
  background: linear-gradient(90deg, var(--green), var(--blue), var(--purple)); opacity: .75;
}
.progress { height: 7px; border-radius: 999px; background: var(--bg-card-2); overflow: hidden; margin: 10px 0 6px; border: 1px solid var(--border); }
.progress span { display: block; height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--green), var(--blue)); }
.compact { padding: 5px 10px !important; font-size: 12px !important; border-radius: 7px !important; }
.insight-box {
  background: var(--bg-card-2); border: 1px solid var(--border); border-radius: 12px; padding: 14px; display: flex; flex-direction: column; gap: 6px;
}
.insight-box b { color: var(--text); }
.insight-box span { color: var(--muted); font-size: 12px; line-height: 1.8; }
.trend-dots { display: flex; align-items: center; gap: 4px; direction: ltr; justify-content: flex-end; }
.trend-dot { width: 9px; height: 9px; border-radius: 999px; display: inline-block; border: 1px solid var(--border); }
.dot-green { background: var(--green); }
.dot-blue { background: var(--blue); }
.dot-amber { background: var(--amber); }
.dot-red { background: var(--red); }
.dot-muted { background: var(--muted); opacity: .45; }
.ltr-url { direction: ltr; text-align: left; unicode-bidi: plaintext; font-size: 12px; max-width: 560px; word-break: break-all; }
.theme-toggle {
  min-width: 92px; justify-content: center; box-shadow: inset 0 0 0 1px rgba(255,255,255,.02);
}
.theme-toggle:focus, input:focus, select:focus, textarea:focus {
  outline: 3px solid var(--ring); outline-offset: 1px;
}
body.light-mode .card,
html[data-theme="light"] body .card { box-shadow: 0 12px 28px rgba(15,23,42,.07); }
html[data-theme="light"] body .hero-card,
body.light-mode .hero-card { background: linear-gradient(135deg, #ffffff, #f6f9ff); }
html[data-theme="light"] body .progress,
body.light-mode .progress { background: #eef2f7; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* ─── v3.3 client report + keyword import ─── */
.compact-form { gap: 10px; }
.compact-form input[type="file"] { width: 100%; }
.check-row { flex-direction: row !important; align-items: center; gap: 8px !important; color: var(--text) !important; }
.check-row input { width: auto; }
.report-feature-list { display: grid; gap: 10px; }
.report-feature-list span {
  background: var(--bg-card-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 12px;
  color: var(--text);
  font-size: 13px;
}
html[data-theme="light"] body .report-feature-list span,
body.light-mode .report-feature-list span { background: #f8fafc; }
@media (max-width: 1100px) { .grid-3 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 700px) { .grid-3 { grid-template-columns: 1fr; } }


/* ─── v3.4 global typography + footer ─── */
html, body, button, input, select, textarea, table { font-family: 'Vazirmatn', 'Vazir', Tahoma, sans-serif; }
.app-footer { margin: 0 24px 18px; padding: 12px 18px; color: var(--muted); font-size: 12px; text-align: center; border: 1px solid var(--border); border-radius: 12px; background: var(--bg-card); }
.login-version { position: fixed; bottom: 14px; left: 0; right: 0; text-align: center; color: var(--muted); font-size: 12px; }
.url-status-grid { display:grid; grid-template-columns:repeat(3,1fr); gap:14px; }
@media (max-width: 900px) { .url-status-grid { grid-template-columns: 1fr; } }

/* ─── v3.7 internal link operator tasks ─── */
.operator-summary { display:flex; align-items:center; gap:10px; flex-wrap:wrap; margin:12px 0 14px; }
.task-table td { vertical-align: top; line-height: 1.8; }
.task-table th:first-child, .task-table td:first-child { width:44px; text-align:center; }
.task-table b { color: var(--text); }
body.light-mode .task-table tr:hover td { background:#f8fbff; }

/* Monthly Growth */
.growth-filter-form .range-pill{display:inline-flex;align-items:center;gap:6px;border:1px solid var(--border);border-radius:999px;padding:8px 13px;cursor:pointer;background:var(--bg-card);font-size:13px;color:var(--text)}
.growth-filter-form .range-pill input{display:none}
.growth-filter-form .range-pill.active{background:rgba(37,99,235,.14);border-color:#2563eb;color:#93c5fd;font-weight:700}
html[data-theme="light"] .growth-filter-form .range-pill.active{color:#1d4ed8;background:#eff6ff}
.custom-range-row{margin-top:12px;align-items:end}.submit-label button{width:100%;margin-top:4px}
.growth-svg{width:100%;height:auto;border:1px solid var(--border);border-radius:18px;background:var(--bg-card);display:block;overflow:hidden}.growth-svg .svg-title{font-size:15px;font-weight:800;fill:var(--text)}.growth-svg .svg-label{font-size:11px;fill:var(--muted)}.growth-svg .svg-value{font-size:11px;fill:var(--text);font-weight:800}.growth-svg .svg-axis{stroke:var(--border);stroke-width:1}.growth-svg .svg-grid{stroke:rgba(148,163,184,.35);stroke-width:1}.growth-svg .svg-line{fill:none;stroke:#3b82f6;stroke-width:3.5;stroke-linecap:round;stroke-linejoin:round}.growth-svg .svg-bar-good{fill:#22c55e}.growth-svg .svg-bar-bad{fill:#ef4444}


/* --- v4.3 Account status strip --- */
.account-status-bar {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  padding: 12px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}
.account-status-item {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 12px;
  min-width: 0;
}
.account-status-item span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  margin-bottom: 4px;
}
.account-status-item b {
  display: block;
  color: var(--text);
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.account-status-item small {
  display: block;
  color: var(--muted);
  font-size: 10px;
  margin-top: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
@media (max-width: 1100px) { .account-status-bar { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 700px) { .account-status-bar { grid-template-columns: 1fr; padding: 10px 14px; } }

