/* ==========================================================================
   Obhijaan SEO Console — Enterprise design system
   Tokens & components ported from the "Enterprise Edition" mockup.
   Light theme by default; dark via prefers-color-scheme or [data-theme].
   Existing app class names (.cards, .panel, .badge, .score, …) are kept
   and restyled so every page inherits the new look without markup changes.
   ========================================================================== */
:root {
  --bg: #f1f5f9;
  --bg2: #e2e8f0;
  --card: #ffffff;
  --card-h: #f8fafc;
  --tx: #0f172a;
  --tx2: #334155;
  --mut: #64748b;
  --bd: #e2e8f0;
  --bd2: #cbd5e1;
  --pri: #0d9488;
  --pri-d: #0f766e;
  --pri-l: #ccfbf1;
  --pri-glow: rgba(13, 148, 136, 0.14);
  --sec: #2563eb;
  --sec-l: #dbeafe;
  --pur: #7c3aed;
  --pur-l: #ede9fe;
  --ok: #16a34a;
  --okb: #dcfce7;
  --bad: #dc2626;
  --badb: #fee2e2;
  --warn: #d97706;
  --warnb: #fef3c7;
  --side: #09111e;
  --side2: #111c2d;
  --sidetx: #94a3b8;
  --sh-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
  --sh: 0 4px 12px -2px rgba(15, 23, 42, 0.06), 0 2px 4px -2px rgba(15, 23, 42, 0.04);
  --sh-lg: 0 12px 32px -4px rgba(15, 23, 42, 0.12);
  --rad: 14px;
  --rad-sm: 8px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #070d17;
    --bg2: #0f172a;
    --card: #0f1928;
    --card-h: #162235;
    --tx: #f1f5f9;
    --tx2: #cbd5e1;
    --mut: #94a3b8;
    --bd: #1e293b;
    --bd2: #334155;
    --pri: #2dd4bf;
    --pri-d: #14b8a6;
    --pri-l: #0d3635;
    --pri-glow: rgba(45, 212, 191, 0.15);
    --sec: #60a5fa;
    --sec-l: #172554;
    --pur: #a78bfa;
    --pur-l: #2e1065;
    --ok: #4ade80;
    --okb: #06391e;
    --bad: #f87171;
    --badb: #451010;
    --warn: #fbbf24;
    --warnb: #422006;
    --side: #050911;
    --side2: #0c1424;
    --sidetx: #94a3b8;
    --sh-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --sh: 0 4px 16px rgba(0, 0, 0, 0.35);
    --sh-lg: 0 14px 36px rgba(0, 0, 0, 0.55);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #070d17;
  --bg2: #0f172a;
  --card: #0f1928;
  --card-h: #162235;
  --tx: #f1f5f9;
  --tx2: #cbd5e1;
  --mut: #94a3b8;
  --bd: #1e293b;
  --bd2: #334155;
  --pri: #2dd4bf;
  --pri-d: #14b8a6;
  --pri-l: #0d3635;
  --pri-glow: rgba(45, 212, 191, 0.15);
  --sec: #60a5fa;
  --sec-l: #172554;
  --pur: #a78bfa;
  --pur-l: #2e1065;
  --ok: #4ade80;
  --okb: #06391e;
  --bad: #f87171;
  --badb: #451010;
  --warn: #fbbf24;
  --warnb: #422006;
  --side: #050911;
  --side2: #0c1424;
  --sidetx: #94a3b8;
  --sh-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --sh: 0 4px 16px rgba(0, 0, 0, 0.35);
  --sh-lg: 0 14px 36px rgba(0, 0, 0, 0.55);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--tx);
  font: 13.5px/1.55 "Inter", "Hind Siliguri", system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}
code, pre, .mono { font-family: "JetBrains Mono", ui-monospace, monospace; }
a { color: var(--pri); }
.mu { color: var(--mut); }
.small { font-size: 13px; color: var(--mut); }

/* ---------------------------------------------------------- Layout shell */
.app { display: flex; min-height: 100vh; }
aside.side {
  width: 248px;
  background: var(--side);
  padding: 16px 12px;
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex-shrink: 0;
  overflow-y: auto;
  border-right: 1px solid #1e293b;
  z-index: 30;
}
.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 6px 10px 16px;
  border-bottom: 1px solid #1e293b;
  margin-bottom: 6px;
}
.brand-mark {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, #14b8a6 0%, #2563eb 100%);
  display: grid;
  place-items: center;
  color: #fff;
  font-weight: 800;
  font-size: 17px;
  box-shadow: 0 4px 12px rgba(20, 184, 166, 0.35);
  flex-shrink: 0;
}
.brand-txt { color: #fff; font-weight: 700; font-size: 15px; line-height: 1.25; }
.brand-txt small { display: block; color: var(--sidetx); font-weight: 400; font-size: 11px; margin-top: 2px; }
.nav-grp {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .09em;
  color: #64748b;
  padding: 12px 10px 4px;
  font-weight: 700;
}
aside.side a {
  color: var(--sidetx);
  text-decoration: none;
  padding: 8px 11px;
  border-radius: 9px;
  font-weight: 500;
  display: flex;
  gap: 10px;
  align-items: center;
  font-size: 13px;
  transition: all .15s ease;
}
aside.side a:hover { background: var(--side2); color: #f8fafc; transform: translateX(2px); }
aside.side a.on, aside.side a.active {
  background: linear-gradient(90deg, var(--pri) 0%, #14b8a6 100%);
  color: #042f2e;
  font-weight: 700;
  box-shadow: 0 4px 12px rgba(13, 148, 136, 0.28);
}
aside.side a .ic { width: 18px; text-align: center; font-size: 14px; }
aside.side .side-foot {
  margin-top: auto;
  padding: 12px;
  background: var(--side2);
  border-radius: 10px;
  border: 1px solid #1e293b;
  color: #cbd5e1;
  font-size: 12px;
  line-height: 1.5;
}
aside.side .side-foot strong { color: #fff; }

.shell { flex: 1; min-width: 0; display: flex; flex-direction: column; }
header.topbar {
  background: color-mix(in srgb, var(--card) 88%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--bd);
  padding: 10px 26px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 20;
  flex-wrap: wrap;
}
.top-l, .top-r { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.prop-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  font-size: 13px;
  background: var(--bg);
  padding: 6px 12px;
  border-radius: 9px;
  border: 1px solid var(--bd);
}
.pulse {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--ok);
  box-shadow: 0 0 0 3px var(--okb);
}
.userbox { display: inline-flex; gap: 10px; align-items: center; font-size: 13px; color: var(--mut); }

main.wrap {
  flex: 1;
  padding: 24px 28px 56px;
  max-width: 1380px;
  width: 100%;
  margin: 0 auto;
}
.foot {
  max-width: 1380px;
  width: 100%;
  margin: 0 auto;
  padding: 16px 28px 30px;
  color: var(--mut);
  font-size: 13px;
  border-top: 1px solid var(--bd);
}

/* ---------------------------------------------------------- Page header */
.pg-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.pg-crumb {
  font-size: 11.5px;
  color: var(--pri);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  margin-bottom: 3px;
}
h1 { font-size: 23px; margin: 0 0 4px; font-weight: 800; letter-spacing: -0.02em; }
h2 { font-size: 15px; margin: 24px 0 10px; font-weight: 700; letter-spacing: -0.01em; }
h3 { font-size: 13.5px; margin: 0 0 6px; font-weight: 600; }
.sub { color: var(--mut); font-size: 13px; margin: 0; }

/* ---------------------------------------------------------- Cards & KPI */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 15px; }
.card, .panel {
  background: var(--card);
  border: 1px solid var(--bd);
  border-radius: var(--rad);
  padding: 18px;
  box-shadow: var(--sh);
  transition: border-color .15s, box-shadow .15s;
}
.card:hover, .panel:hover { border-color: var(--bd2); }
.panel { margin-top: 16px; }
.panel.tblwrap { padding: 10px 14px; }
.card .label {
  color: var(--mut);
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
}
.card .value { font-size: 27px; font-weight: 800; line-height: 1.15; margin: 6px 0 8px; letter-spacing: -0.02em; }
.card .sub { font-size: 12.5px; }
.card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.up { color: var(--ok); font-weight: 600; }
.down, .dn { color: var(--bad); font-weight: 600; }
.flat { color: var(--mut); font-weight: 600; }
.warn-tx { color: var(--warn); font-weight: 600; }

/* ---------------------------------------------------------- Controls */
button, select, input, textarea { font: inherit; color: var(--tx); }
button, .btn {
  background: var(--pri);
  color: #042f2e;
  border: 1px solid var(--pri);
  padding: 7px 13px;
  border-radius: var(--rad-sm);
  cursor: pointer;
  font-size: 12.5px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all .15s;
  box-shadow: var(--sh-sm);
  text-decoration: none;
}
button:hover, .btn:hover { background: var(--pri-d); border-color: var(--pri-d); color: #fff; }
.btn-sm { padding: 4px 9px; font-size: 11.5px; border-radius: 6px; }
/* Neutral button (theme toggle, secondary actions) */
.btn.secondary, button.secondary, #themeToggle {
  background: var(--card);
  border: 1px solid var(--bd);
  color: var(--tx);
  font-weight: 600;
  box-shadow: var(--sh-sm);
}
.btn.secondary:hover, button.secondary:hover, #themeToggle:hover {
  border-color: var(--pri);
  background: var(--card-h);
  color: var(--tx);
}
input[type=text], input[type=password], input[type=search], select, textarea {
  background: var(--card);
  border: 1px solid var(--bd);
  border-radius: var(--rad-sm);
  padding: 8px 12px;
  font-size: 13px;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
input[type=text]:focus, input[type=password]:focus, input[type=search]:focus, select:focus, textarea:focus {
  border-color: var(--pri);
  box-shadow: 0 0 0 3px var(--pri-glow);
}
.toolbar {
  display: flex;
  gap: 10px;
  margin: 14px 0;
  flex-wrap: wrap;
  align-items: center;
}
.seg {
  display: inline-flex;
  background: var(--bg);
  padding: 3px;
  border-radius: 9px;
  border: 1px solid var(--bd);
  gap: 2px;
}
.seg span {
  padding: 4px 11px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  color: var(--mut);
  user-select: none;
}
.seg span.on { background: var(--card); color: var(--pri); box-shadow: var(--sh-sm); }

/* ---------------------------------------------------------- Tables */
.tblwrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th {
  text-align: left;
  color: var(--mut);
  font-weight: 700;
  padding: 11px 12px;
  border-bottom: 1px solid var(--bd);
  cursor: pointer;
  white-space: nowrap;
  user-select: none;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .05em;
  background: color-mix(in srgb, var(--bg) 55%, transparent);
}
th:hover { color: var(--tx); }
th.no-sort { cursor: default; }
th.num, td.num { text-align: right; font-variant-numeric: tabular-nums; }
td { padding: 11px 12px; border-bottom: 1px solid var(--bd); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
tbody tr { transition: background .12s; }
tbody tr:hover { background: var(--card-h); }
td a { color: var(--pri); text-decoration: none; font-weight: 600; }
td a:hover { text-decoration: underline; }

/* ---------------------------------------------------------- Badges */
.badge, .bd {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 9px;
  border-radius: 99px;
  font-size: 11.5px;
  font-weight: 700;
  white-space: nowrap;
  background: var(--pri-l);
  color: var(--pri);
}
.badge.ok, .b-ok { background: var(--okb); color: var(--ok); }
.badge.bad, .b-bad { background: var(--badb); color: var(--bad); }
.badge.warn, .b-warn { background: var(--warnb); color: var(--warn); }
.b-n { background: var(--pri-l); color: var(--pri); }
.b-sec { background: var(--sec-l); color: var(--sec); }
.b-pur { background: var(--pur-l); color: var(--pur); }

/* PageSpeed score pill */
.score {
  display: inline-block;
  min-width: 38px;
  text-align: center;
  padding: 3px 8px;
  border-radius: 99px;
  font-weight: 700;
  font-size: 12px;
}
.score.good { background: var(--okb); color: var(--ok); }
.score.mid { background: var(--warnb); color: var(--warn); }
.score.poor { background: var(--badb); color: var(--bad); }

/* ---------------------------------------------------------- Misc blocks */
code {
  background: var(--bg);
  color: var(--pri);
  border: 1px solid var(--bd);
  padding: 2px 6px;
  border-radius: 5px;
  font-size: 12px;
  font-weight: 600;
}
.mono { font-size: 12.5px; word-break: break-all; }
.callout, .err, .okmsg {
  border-radius: 10px;
  padding: 12px 16px;
  margin-bottom: 16px;
  font-size: 13px;
}
.callout { background: var(--pri-l); border-left: 4px solid var(--pri); }
.err { background: var(--badb); border-left: 4px solid var(--bad); color: var(--bad); }
.okmsg { background: var(--okb); border-left: 4px solid var(--ok); color: var(--ok); }
.bar { display: flex; height: 11px; border-radius: 6px; overflow: hidden; margin: 10px 0; background: var(--bg2); gap: 2px; }
.row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 9px 0;
  border-bottom: 1px solid var(--bd);
}
.row:last-child { border: 0; }
canvas { max-width: 100%; }

/* ---------------------------------------------------------- Login / install */
.login-wrap {
  max-width: 400px;
  margin: 9vh auto;
  background: var(--card);
  border: 1px solid var(--bd);
  border-radius: var(--rad);
  padding: 28px;
  box-shadow: var(--sh-lg);
}
.login-wrap h1 { font-size: 21px; margin-bottom: 6px; }
.login-wrap label { display: block; margin: 14px 0 5px; font-size: 13px; font-weight: 600; }
.login-wrap input { width: 100%; }
.login-wrap button { width: 100%; margin-top: 18px; justify-content: center; }
.login-wrap .btn { width: 100%; justify-content: center; }

/* ---------------------------------------------------------- Responsive */
@media (max-width: 980px) {
  .app { flex-direction: column; }
  aside.side {
    width: 100%;
    height: auto;
    position: sticky;
    top: 0;
    flex-direction: row;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 8px 10px;
    gap: 4px;
    align-items: center;
  }
  .brand, .nav-grp, aside.side .side-foot { display: none; }
  aside.side a { white-space: nowrap; padding: 6px 10px; }
  header.topbar { position: static; padding: 10px 14px; }
  main.wrap { padding: 16px 14px 48px; }
  .foot { padding: 14px; }
  .cards { grid-template-columns: 1fr; }
  .card .value { font-size: 24px; }
}

/* ---------------------------------------------------------- Mobile app chrome
   Elements used only by the ≤860px app layout; hidden on desktop so the
   ≥861px design stays pixel-identical. */
.m-brand { display: none; }
.mnav { display: none; }

/* ---------------------------------------------------------- Mobile app layout (≤860px)
   Installed-PWA-first: no sidebar, slim sticky top bar, fixed bottom nav,
   tables scroll inside their panel, 2-up KPI cards, big tap targets. */
@media (max-width: 860px) {
  /* Overflow + touch guards — the page itself never scrolls sideways */
  html, body { overflow-x: clip; }
  body { -webkit-tap-highlight-color: transparent; }
  button, .btn, a, select, input, textarea, label { touch-action: manipulation; }

  /* Shell: sidebar completely off, content full width */
  aside.side { display: none; }
  .shell { min-width: 0; }

  /* Slim sticky top bar: brand left, theme + logout right */
  header.topbar {
    position: sticky;
    top: 0;
    padding: 8px 12px;
    gap: 8px;
    flex-wrap: nowrap;
  }
  .top-l, .top-r { flex-wrap: nowrap; }
  .m-brand {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
    color: var(--tx);
    font-weight: 800;
    font-size: 14.5px;
    letter-spacing: -0.01em;
    white-space: nowrap;
  }
  .m-brand .brand-mark {
    width: 30px;
    height: 30px;
    border-radius: 8px;
    font-size: 14px;
  }
  .prop-pill { display: none; }
  .userbox { gap: 8px; font-size: 12px; }
  .userbox > span { display: none; } /* username text — logout stays */
  #themeToggle { white-space: nowrap; padding: 7px 10px; }
  button, .btn { min-height: 42px; }
  .btn-sm { min-height: 42px; padding: 7px 11px; }

  /* Content clears the fixed bottom nav */
  main.wrap { padding: 16px 12px 96px; }
  .foot { padding: 14px 14px 100px; }

  /* Page header */
  .pg-head { margin-bottom: 14px; gap: 8px; }
  .pg-crumb { font-size: 10.5px; margin-bottom: 2px; }
  h1 { font-size: 19px; }
  h2 { font-size: 14px; margin: 18px 0 8px; }
  .sub, .small { font-size: 12.5px; }

  /* KPI / stat cards: 2-up, compact */
  .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .card, .panel { padding: 13px; min-width: 0; }
  .panel { margin-top: 12px; }
  .panel.tblwrap { padding: 8px 10px; }
  .card .label { font-size: 10.5px; }
  .card .value { font-size: 22px; margin: 4px 0 6px; }
  .card .sub { font-size: 11.5px; }
  .card-head { margin-bottom: 9px; }

  /* Tables scroll horizontally INSIDE their card/panel only */
  .panel, .card { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  table { font-size: 12.5px; }
  th { padding: 9px 10px; }
  td { padding: 9px 10px; font-variant-numeric: tabular-nums; }

  /* Toolbar / filters wrap; controls full-width-friendly + ≥42px targets */
  .toolbar { gap: 8px; margin: 10px 0; }
  .toolbar select, .toolbar input { flex: 1 1 150px; }
  .toolbar .btn, .toolbar button { justify-content: center; }
  input[type=text], input[type=password], input[type=search], select, textarea {
    font-size: 16px; /* ≥16px stops Android/iOS zoom-on-focus */
    min-height: 42px;
  }
  .seg span { padding: 9px 12px; }

  /* Overview chart: capped height so it doesn't dominate the phone screen */
  .chart-m-wrap { position: relative; height: 240px; }
  .chart-m-wrap canvas { max-height: 240px; }

  /* Login / install: edge-to-edge card, comfortable fields */
  .login-wrap { margin: 20px 16px; max-width: none; padding: 22px 18px; }
  .login-wrap h1 { font-size: 20px; }
  .login-wrap input { min-height: 48px; }
  .login-wrap button, .login-wrap .btn { min-height: 48px; font-size: 15px; }

  /* Fixed bottom navigation (app-style) */
  .mnav {
    display: flex;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 50;
    background: color-mix(in srgb, var(--card) 92%, transparent);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border-top: 1px solid var(--bd);
    box-shadow: 0 -2px 10px rgba(15, 23, 42, 0.06);
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }
  .mnav a {
    flex: 1 1 0;
    min-width: 0;
    height: 60px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    color: var(--mut);
    text-decoration: none;
    font-size: 10.5px;
    font-weight: 600;
    -webkit-tap-highlight-color: transparent;
  }
  .mnav a .mi { font-size: 19px; line-height: 1.1; }
  .mnav a .ml { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
  .mnav a.on { color: var(--pri); font-weight: 700; }
  .mnav a.on .mi { transform: scale(1.1); }
  .mnav a:active { background: var(--card-h); }
}
