/* EX Studio Client Portal: light theme modeled on the Reference/ images. */

:root {
  color-scheme: light;
  --bg: #eceef3;
  --surface: #ffffff;
  --surface-2: #f5f6f9;
  --surface-3: #eef0f5;
  --line: #e7e9ef;
  --line-2: #dfe2ea;
  --grid: #eef0f4;
  --axis: #d6d9e2;

  --ink: #171a2b;
  --ink-2: #44495e;
  --muted: #6b7085;   /* 4.9:1 on white: the lightest text that stays readable */
  --faint: #a3a8b8;   /* decoration only, never text */

  --brand: #5b6cf0;
  --brand-2: #7c88f6;
  --brand-ink: #3d4bd6;
  --brand-soft: #eceefe;

  /* Categorical series, validated in this order on #fff (dataviz validator, adjacent pairs). */
  --s1: #5b6cf0;  /* periwinkle */
  --s2: #ef6a2e;  /* orange */
  --s3: #14a87b;  /* aqua */
  --s4: #a55eea;  /* violet */
  --s5: #e9a100;  /* amber: sub-3:1, always paired with labels / table view */
  --s6: #e26ba0;  /* magenta */
  --s7: #2f9fd6;  /* sky: only ever adjacent to magenta and gray */
  --s-none: #b4b9c7; /* de-emphasis gray for "Unattributed" (not a series hue) */

  /* Ordinal ramp (one hue) for ranked buckets: darkest = best. */
  --r1: #262f8f; --r2: #3743bd; --r3: #4f5fe6; --r4: #7581f0; --r5: #98a2f4;

  /* Status (reserved meaning, always with label or icon). */
  --good: #0ca30c; --warn: #fab219; --serious: #ec835a; --crit: #d03b3b;
  --up: #15803d; --up-bg: #e6f5ea; --down: #d92d3a; --down-bg: #fdecee;
  --up-dot: #22a55a; --down-dot: #ec4452;

  --tint-blue: #e9ecfe; --tint-green: #e2f5ee; --tint-violet: #f2e9fd; --tint-orange: #fdeee6; --tint-amber: #fdf3d9; --tint-pink: #fcebf3;

  --r-card: 22px;
  --r-md: 14px;
  --r-sm: 10px;
  --shadow-card: 0 1px 2px rgba(23, 26, 43, .04);
  --shadow-pop: 0 18px 40px -12px rgba(23, 26, 43, .22), 0 2px 6px rgba(23, 26, 43, .06);
  --shadow-active: 0 10px 22px -6px rgba(91, 108, 240, .55);

  --font: 'Urbanist', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif;
  --mono: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--brand-ink); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -.01em; }
p { margin: 0; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; border-radius: 8px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.ic { flex: none; display: block; }
.muted { color: var(--muted); }
.ink2 { color: var(--ink-2); }
.num { font-variant-numeric: tabular-nums; }
.mono { font-family: var(--mono); font-size: .86em; }
.cents { color: var(--faint); }
.nowrap { white-space: nowrap; }
.show-sm { display: none; }
.spacer { flex: 1; }
.row { display: flex; align-items: center; gap: 10px; }
.stack { display: flex; flex-direction: column; gap: 6px; }

/* ---------- App frame ---------- */
.app { display: grid; grid-template-columns: 92px minmax(0, 1fr); min-height: 100vh; }
.rail {
  /* Above the page content so the hover labels aren't covered by cards. */
  position: sticky; top: 0; height: 100vh; z-index: 40;
  display: flex; flex-direction: column; align-items: center;
  padding: 22px 0 22px; gap: 14px;
}
.rail-logo { width: 46px; height: 46px; display: grid; place-items: center; color: var(--ink); margin-bottom: 8px; }
.rail-nav { display: flex; flex-direction: column; gap: 14px; margin: auto 0; }
.rail-foot { display: flex; flex-direction: column; gap: 14px; }
.rail-sep { width: 28px; height: 1px; background: var(--line-2); margin: 2px auto; }
.rail-btn {
  position: relative; width: 50px; height: 50px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--bg); border: 1.5px solid var(--line-2); color: var(--ink-2);
  transition: background .15s, color .15s, box-shadow .15s, transform .15s;
}
.rail-btn:hover { background: var(--surface); color: var(--ink); text-decoration: none; }
.rail-btn.active {
  background: linear-gradient(140deg, var(--brand-2), var(--brand) 60%, #4c5ce6);
  border-color: transparent; color: #fff; box-shadow: var(--shadow-active);
}
.rail-btn .rail-tip {
  position: absolute; left: 62px; top: 50%; transform: translateY(-50%);
  background: var(--ink); color: #fff; font-size: 13px; font-weight: 500;
  padding: 6px 10px; border-radius: 8px; white-space: nowrap;
  opacity: 0; pointer-events: none; transition: opacity .12s; z-index: 50;
}
.rail-btn:hover .rail-tip, .rail-btn:focus-visible .rail-tip { opacity: 1; }

.main { min-width: 0; padding: 22px 34px 60px 8px; }
.topbar { display: flex; align-items: center; gap: 12px; margin-bottom: 30px; }
.search {
  position: relative; flex: 0 1 300px; display: flex; align-items: center; gap: 10px;
  background: var(--surface); border-radius: 999px; padding: 0 8px 0 16px; height: 46px;
  color: var(--muted);
}
.search input { border: 0; outline: 0; background: transparent; flex: 1; min-width: 0; color: var(--ink); height: 100%; }
.search input::placeholder { color: var(--muted); }
.kbd { font-size: 12px; border: 1px solid var(--line-2); border-radius: 999px; padding: 2px 8px; color: var(--muted); background: var(--surface-2); }
.search-results {
  position: absolute; top: 52px; left: 0; right: 0; background: var(--surface);
  border-radius: 16px; box-shadow: var(--shadow-pop); padding: 6px; z-index: 60; max-height: 360px; overflow: auto;
}
.search-results .sr-group { font-size: 12px; color: var(--muted); padding: 8px 10px 4px; }
.search-results button {
  display: flex; width: 100%; align-items: center; gap: 10px; text-align: left;
  border: 0; background: transparent; padding: 9px 10px; border-radius: 10px; color: var(--ink);
}
.search-results button:hover, .search-results button.hl { background: var(--surface-2); }

.pill {
  display: inline-flex; align-items: center; gap: 8px; height: 46px; padding: 0 18px;
  border-radius: 999px; background: var(--surface); border: 1.5px solid var(--line-2);
  color: var(--ink); font-weight: 500; white-space: nowrap;
}
.pill:hover { border-color: var(--faint); text-decoration: none; }
.pill.sm { height: 36px; padding: 0 14px; font-size: 14px; }
.pill.ghost { background: transparent; }
.pill.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.pill.primary:hover { background: var(--brand-ink); }
.icon-btn {
  width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center;
  background: transparent; border: 1.5px solid var(--line-2); color: var(--ink-2); position: relative;
}
.icon-btn:hover { background: var(--surface); }
.icon-btn .dot { position: absolute; top: 10px; right: 11px; width: 8px; height: 8px; border-radius: 50%; background: var(--s2); border: 2px solid var(--bg); }
.avatar {
  width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center;
  font-weight: 600; font-size: 15px; color: #fff; border: 0;
  background: linear-gradient(140deg, #f2a65a, #ef6a2e);
}
.avatar.sm { width: 34px; height: 34px; font-size: 13px; }
.avatar.lg { width: 56px; height: 56px; font-size: 19px; }
.client-mark {
  width: 34px; height: 34px; border-radius: 11px; display: grid; place-items: center;
  font-weight: 700; font-size: 13px; color: #fff; flex: none;
}

/* ---------- Popovers / menus ---------- */
.pop-wrap { position: relative; }
.menu {
  position: absolute; right: 0; top: calc(100% + 8px); min-width: 240px; z-index: 70;
  background: var(--surface); border-radius: 16px; box-shadow: var(--shadow-pop); padding: 6px;
}
.menu.left { left: 0; right: auto; }
.menu-head { font-size: 12px; color: var(--muted); padding: 8px 12px 4px; }
.menu-item {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left;
  background: transparent; border: 0; padding: 10px 12px; border-radius: 10px; color: var(--ink);
}
.menu-item:hover { background: var(--surface-2); text-decoration: none; }
.menu-item .check { margin-left: auto; color: var(--brand); }
.menu-item .sub { font-size: 13px; color: var(--muted); }
.menu-foot { border-top: 1px solid var(--line); margin-top: 6px; padding: 10px 8px 6px; }
.menu-foot .row { gap: 8px; }
.menu-foot input[type="date"] { flex: 1; min-width: 0; border: 1px solid var(--line-2); border-radius: 10px; padding: 7px 8px; font-size: 13px; }
.notif { display: flex; gap: 12px; padding: 10px 12px; border-radius: 10px; }
.notif:hover { background: var(--surface-2); }
.notif .ni { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; flex: none; }
.notif .nt { font-size: 14px; }
.notif .nd { font-size: 12px; color: var(--muted); }

/* ---------- Page header ---------- */
.page-head { display: flex; align-items: flex-end; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head h1 { font-size: 36px; font-weight: 500; letter-spacing: -.02em; line-height: 1.1; }
.page-head .sub { color: var(--muted); margin-top: 6px; font-size: 15px; }
.page-head .actions { margin-left: auto; display: flex; gap: 10px; flex-wrap: wrap; }
.client-line { display: inline-flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.client-line .sep { color: var(--faint); }

.section-pills { display: flex; gap: 8px; flex-wrap: wrap; margin: -6px 0 18px; }
.section-pills a, .section-pills button {
  padding: 7px 14px; border-radius: 999px; background: var(--surface); color: var(--ink-2); font-size: 14px; font-weight: 500;
  border: 1.5px solid transparent;
}
.section-pills a:hover, .section-pills button:hover { border-color: var(--line-2); text-decoration: none; }

.section-label { display: flex; align-items: center; gap: 12px; margin: 30px 0 14px; }
.section-label h2 { font-size: 22px; font-weight: 500; letter-spacing: -.01em; }
.section-label:first-child { margin-top: 0; }

/* ---------- Layout grids ---------- */
.grid { display: grid; gap: 16px; margin-bottom: 16px; }
.g-stats { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.g-21 { grid-template-columns: minmax(0, 1.65fr) minmax(0, 1fr); }
.g-12 { grid-template-columns: minmax(0, 1fr) minmax(0, 1.65fr); }
.g-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g-3 { grid-template-columns: minmax(0, 1fr) minmax(0, .85fr) minmax(0, 1fr); }
.g-3e { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.span-all { grid-column: 1 / -1; }
.grid.top { align-items: start; }
/* Cards placed directly on the page (not inside a .grid) get the same 16px gap as grid rows. */
.main-content > .card { margin-bottom: 16px; }

/* ---------- Cards ---------- */
.card {
  background: var(--surface); border-radius: var(--r-card); box-shadow: var(--shadow-card);
  padding: 22px 24px; min-width: 0; position: relative;
}
.card.flush { padding: 0; }
.card-head { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; min-height: 36px; }
.card-title { font-size: 19px; font-weight: 500; letter-spacing: -.01em; }
.card-sub { font-size: 13.5px; color: var(--muted); margin-top: 2px; }
.card-actions { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.eyebrow { font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--brand-ink); }
.card-foot { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); font-size: 13px; color: var(--muted); display: flex; gap: 8px; align-items: center; }
.src { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.src .sd { width: 6px; height: 6px; border-radius: 50%; background: var(--s3); }

/* ---------- Stat tiles ---------- */
.stat { padding: 18px 20px 20px; display: flex; flex-direction: column; gap: 18px; }
.stat-top { display: flex; align-items: flex-start; gap: 12px; }
.stat-icon { width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center; flex: none; }
.t-blue { background: var(--tint-blue); color: var(--s1); }
.t-green { background: var(--tint-green); color: var(--s3); }
.t-violet { background: var(--tint-violet); color: var(--s4); }
.t-orange { background: var(--tint-orange); color: var(--s2); }
.t-amber { background: var(--tint-amber); color: #b47c00; }
.t-pink { background: var(--tint-pink); color: #c94f86; }
.stat-label { font-weight: 500; font-size: 15.5px; }
.stat-cmp { font-size: 13px; color: var(--muted); }
.stat-more { margin-left: auto; color: var(--muted); background: transparent; border: 0; padding: 2px; border-radius: 8px; }
.stat-more:hover { color: var(--ink); background: var(--surface-2); }
.stat-bottom { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 8px 10px; }
.stat-value { min-width: 0; overflow-wrap: anywhere; }
.stat-value { font-size: 27px; font-weight: 500; letter-spacing: -.02em; line-height: 1; }
.stat-value small { font-size: 15px; color: var(--muted); font-weight: 500; margin-left: 2px; }
.delta { margin-left: auto; display: inline-flex; align-items: center; gap: 5px; font-size: 13px; font-weight: 600; white-space: nowrap; }
.delta.up { color: var(--up); }
.delta.up .dg { color: var(--up-dot); }
.delta.down { color: var(--down); }
.delta.down .dg { color: var(--down-dot); }
.delta.flat { color: var(--muted); }
.delta-inline { display: inline-flex; align-items: center; gap: 2px; font-weight: 600; font-size: 13px; }
.delta-inline.up { color: var(--up); }
.delta-inline.down { color: var(--down); }
.delta-inline.flat { color: var(--muted); }

/* ---------- Controls ---------- */
.seg { display: inline-flex; background: var(--surface-2); border-radius: 999px; padding: 4px; gap: 2px; }
.seg button { border: 0; background: transparent; padding: 6px 13px; border-radius: 999px; font-size: 13.5px; font-weight: 500; color: var(--muted); }
.seg button.on { background: var(--surface); color: var(--ink); box-shadow: 0 1px 3px rgba(23, 26, 43, .1); }
.select {
  appearance: none; height: 36px; padding: 0 34px 0 14px; border-radius: 999px; border: 1.5px solid var(--line-2);
  background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2344495e' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") no-repeat right 12px center;
  font-size: 14px; font-weight: 500; max-width: 100%;
}
.icon-sm { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; background: transparent; border: 1.5px solid var(--line-2); color: var(--ink-2); }
.icon-sm:hover { background: var(--surface-2); }
.icon-sm.on { background: var(--brand-soft); border-color: transparent; color: var(--brand-ink); }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 42px; padding: 0 18px;
  border-radius: 12px; border: 1.5px solid var(--line-2); background: var(--surface); font-weight: 600; color: var(--ink);
}
.btn:hover { border-color: var(--faint); text-decoration: none; }
.btn.primary { background: var(--brand); color: #fff; border-color: var(--brand); }
.btn.primary:hover { background: var(--brand-ink); }
.btn.soft { background: var(--brand-soft); color: var(--brand-ink); border-color: transparent; }
.btn.sm { height: 34px; padding: 0 12px; font-size: 13.5px; border-radius: 10px; }
.btn.block { width: 100%; }
.btn.danger { color: var(--down); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 999px;
  background: var(--surface-2); color: var(--ink-2); font-size: 12.5px; font-weight: 500; white-space: nowrap;
}
.chip.blue { background: var(--tint-blue); color: var(--brand-ink); }
.chip.green { background: var(--up-bg); color: var(--up); }
.chip.red { background: var(--down-bg); color: var(--down); }
.chip.amber { background: var(--tint-amber); color: #8a5d00; }
.chip.violet { background: var(--tint-violet); color: #7a36c4; }
.chip.orange { background: var(--tint-orange); color: #b2481a; }
.chip-btn { border: 1.5px solid var(--line-2); background: var(--surface); padding: 6px 12px; border-radius: 999px; font-size: 13.5px; font-weight: 500; color: var(--ink-2); }
.chip-btn.on { background: var(--ink); border-color: var(--ink); color: #fff; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.input-search {
  display: flex; align-items: center; gap: 8px; height: 36px; padding: 0 12px; border-radius: 999px;
  border: 1.5px solid var(--line-2); background: var(--surface); color: var(--muted);
}
.input-search input { border: 0; outline: 0; background: transparent; width: 180px; color: var(--ink); font-size: 14px; }

/* ---------- Tables ---------- */
.tbl-wrap { overflow-x: auto; margin: 0 -6px; }
.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl th {
  text-align: left; font-weight: 600; font-size: 12px; color: var(--muted); padding: 8px 10px;
  border-bottom: 1px solid var(--line); white-space: nowrap; letter-spacing: .02em;
}
.tbl th.sortable { cursor: pointer; user-select: none; }
.tbl th.sortable:hover { color: var(--ink); }
.tbl th .sort-ind { opacity: .8; margin-left: 3px; }
.tbl td { padding: 11px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl td.r, .tbl th.r { text-align: right; }
.tbl td.num, .tbl th.num { font-variant-numeric: tabular-nums; }
.tbl tr.me td { background: #f6f7ff; }
.tbl tr.me td:first-child { box-shadow: inset 3px 0 0 var(--brand); }
.tbl .strong { font-weight: 600; }
.tbl .url { color: var(--brand-ink); font-family: var(--mono); font-size: 12.5px; }
.rank-badge {
  display: inline-grid; place-items: center; min-width: 34px; height: 26px; padding: 0 7px; border-radius: 8px;
  font-weight: 700; font-size: 13px; font-variant-numeric: tabular-nums; background: var(--surface-2); color: var(--ink);
}
.rank-badge.top3 { background: #e5f6e9; color: #0d6b2b; }
.rank-badge.top10 { background: var(--tint-blue); color: var(--brand-ink); }
.rank-badge.low { background: var(--surface-2); color: var(--ink-2); }
.you-tag { font-size: 11px; font-weight: 700; padding: 2px 7px; border-radius: 999px; background: var(--brand); color: #fff; margin-left: 6px; }
.empty { padding: 30px 10px; text-align: center; color: var(--muted); }

/* ---------- Lists ---------- */
.bar-list { display: flex; flex-direction: column; gap: 16px; }
.bar-item .bl-top { display: flex; align-items: center; gap: 10px; margin-bottom: 9px; }
.bar-item .bl-name { font-weight: 500; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-item .bl-val { margin-left: auto; color: var(--muted); font-size: 14px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.bar-item .bl-val b { color: var(--ink); font-weight: 600; }
.track { height: 6px; border-radius: 99px; background: var(--surface-3); overflow: hidden; }
.track > i { display: block; height: 100%; border-radius: 99px; }
.bl-logo { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; color: #fff; flex: none; }

.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 13.5px; color: var(--ink-2); }
.legend .lg { display: inline-flex; align-items: center; gap: 7px; }
.legend .sw { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.legend .ln { width: 14px; height: 3px; border-radius: 3px; flex: none; }
.legend .sq { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.legend-rows { display: flex; flex-direction: column; }
.legend-rows .lr { display: flex; align-items: center; gap: 10px; padding: 13px 0; border-bottom: 1px solid var(--line); font-size: 15px; }
.legend-rows .lr:last-child { border-bottom: 0; }
.legend-rows .lr .v { margin-left: auto; color: var(--muted); font-variant-numeric: tabular-nums; }

/* ---------- Charts ---------- */
.chart { position: relative; width: 100%; }
.chart svg { display: block; overflow: visible; }
.chart .ax { font-size: 12px; fill: var(--muted); font-family: var(--font); }
.chart .ax.on { fill: var(--ink); font-weight: 600; }
.chart .gl { stroke: var(--grid); stroke-width: 1; }
.chart .bl { stroke: var(--axis); stroke-width: 1; }
.chart .xh { stroke: var(--faint); stroke-width: 1; }
.chart.loading { opacity: .5; transition: opacity .2s; }
.chart-table { margin-top: 4px; max-height: 320px; overflow: auto; }
.chart-table .tbl { font-size: 13px; }
.tt {
  position: fixed; z-index: 100; pointer-events: none; background: var(--surface);
  border-radius: 12px; box-shadow: var(--shadow-pop); padding: 10px 12px; min-width: 150px;
  font-size: 13px; opacity: 0; transition: opacity .1s; border: 1px solid var(--line);
}
.tt.show { opacity: 1; }
.tt .tt-h { color: var(--ink); font-weight: 600; margin-bottom: 6px; }
.tt .tt-r { display: flex; align-items: center; gap: 8px; padding: 2px 0; }
.tt .tt-r .k { width: 12px; height: 3px; border-radius: 3px; flex: none; }
.tt .tt-r .n { color: var(--muted); }
.tt .tt-r .v { margin-left: auto; font-weight: 600; color: var(--ink); padding-left: 14px; font-variant-numeric: tabular-nums; }

.polar-wrap { display: grid; grid-template-columns: minmax(170px, 1fr) minmax(0, 1.15fr); gap: 18px; align-items: center; }
.gauge-legend { display: flex; justify-content: space-between; gap: 10px; font-size: 13.5px; color: var(--muted); margin-top: 4px; }
.gauge-legend b { color: var(--ink); font-weight: 600; font-size: 16px; margin-left: 4px; }

/* ---------- Movement boxes ---------- */
.mv-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.mv { border-radius: 14px; padding: 12px 14px; background: var(--surface-2); }
.mv .mv-v { font-size: 24px; font-weight: 600; display: flex; align-items: center; gap: 6px; }
.mv .mv-l { font-size: 13px; color: var(--muted); }
.mv.up .mv-v { color: var(--up); }
.mv.down .mv-v { color: var(--down); }

/* ---------- Local grid ---------- */
.geo-top { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin-bottom: 14px; }
.geo-kpi { border-radius: 14px; background: var(--surface-2); padding: 10px 14px; }
.geo-kpi .v { font-size: 22px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.geo-kpi .l { font-size: 12.5px; color: var(--muted); }
.geo-kpi .sw { width: 10px; height: 10px; border-radius: 50%; }
.timeline-dates { display: flex; align-items: flex-start; justify-content: space-between; position: relative; padding: 4px 6px 0; margin: 4px 0 16px; overflow-x: auto; gap: 6px; }
.timeline-dates::before { content: ''; position: absolute; left: 24px; right: 24px; top: 13px; height: 2px; background: var(--line-2); }
.timeline-dates button { position: relative; background: transparent; border: 0; display: flex; flex-direction: column; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); min-width: 64px; padding: 0; }
.timeline-dates button i { width: 14px; height: 14px; border-radius: 50%; background: var(--surface); border: 3px solid var(--brand-2); display: block; }
.timeline-dates button.on { color: var(--ink); font-weight: 600; }
.timeline-dates button.on i { background: var(--brand); border-color: var(--brand-soft); box-shadow: 0 0 0 3px var(--brand); width: 16px; height: 16px; margin-top: -1px; }
.geo-layout { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(260px, 1fr); gap: 16px; align-items: start; }
.geo-map { position: relative; border-radius: 18px; overflow: hidden; background: #edf0f4; }
.geo-map > svg { display: block; width: 100%; height: auto; }
.geo-node { cursor: pointer; }
.geo-node circle.halo { fill: transparent; }
.geo-node:hover circle.dotc, .geo-node:focus-visible circle.dotc { stroke: var(--ink); stroke-width: 2.5; }
.geo-node.sel circle.dotc { stroke: var(--brand); stroke-width: 4; }
.geo-node text { font-family: var(--font); font-weight: 700; font-size: 14px; pointer-events: none; }
.geo-legend { background: var(--surface); padding: 8px 12px; font-size: 12.5px; display: flex; gap: 14px; border-top: 1px solid var(--line); }
.inspector { border-radius: 18px; background: var(--surface-2); padding: 16px; }
.inspector h4 { font-size: 16px; font-weight: 600; }
.insp-meta { display: grid; grid-template-columns: auto 1fr; gap: 6px 12px; font-size: 13px; margin: 12px 0 14px; padding: 12px; background: var(--surface); border-radius: 12px; }
.insp-meta dt { color: var(--muted); }
.insp-meta dd { margin: 0; text-align: right; font-weight: 600; }
.serp-list { display: flex; flex-direction: column; gap: 6px; }
.serp-item { display: flex; align-items: center; gap: 10px; background: var(--surface); border-radius: 12px; padding: 9px 12px; font-size: 13.5px; border: 1.5px solid transparent; }
.serp-item.me { border-color: var(--brand); background: #f6f7ff; }
.serp-item .pos { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-2); font-size: 12px; font-weight: 700; flex: none; }
.serp-item .rt { margin-left: auto; color: var(--muted); font-size: 12.5px; white-space: nowrap; }
.stars { color: #e9a100; letter-spacing: 1px; }

/* ---------- Keyword cards / plan ---------- */
.kw-card { border-radius: 14px; background: var(--surface-2); padding: 12px 14px; display: flex; gap: 12px; align-items: flex-start; }
.kw-card + .kw-card { margin-top: 8px; }
.kw-card .kw { font-weight: 600; }
.kw-card .meta { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.kw-card .side { margin-left: auto; text-align: right; display: flex; flex-direction: column; align-items: flex-end; gap: 4px; flex: none; }
.diag { display: flex; gap: 6px; align-items: flex-start; font-size: 12.5px; color: #8a5d00; margin-top: 6px; }
.plan-card { display: flex; flex-direction: column; gap: 10px; }
.plan-card .pc-top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.plan-card .lift { margin-left: auto; font-size: 13px; font-weight: 600; color: var(--up); white-space: nowrap; }
.plan-card h3 { font-size: 18px; font-weight: 600; line-height: 1.3; }
.plan-card p { color: var(--ink-2); font-size: 14.5px; }
.plan-card .pc-foot { display: flex; align-items: center; gap: 10px; margin-top: auto; padding-top: 12px; border-top: 1px solid var(--line); font-size: 13px; color: var(--muted); flex-wrap: wrap; }
.status-dot { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; font-size: 13px; }
.status-dot i { width: 8px; height: 8px; border-radius: 50%; }
.ai-banner {
  background: linear-gradient(120deg, #eef0ff, #f7f0ff 60%, #fff4ee);
  border-radius: var(--r-card); padding: 22px 24px; display: flex; gap: 16px; align-items: center; margin-bottom: 16px; flex-wrap: wrap;
}
.ai-banner .ai-ic { width: 52px; height: 52px; border-radius: 16px; background: var(--surface); display: grid; place-items: center; color: var(--s4); flex: none; }

/* ---------- Work log ---------- */
.summary-card { background: linear-gradient(120deg, #f4f5ff, #ffffff 70%); }
.summary-card .sum-text { font-size: 15.5px; line-height: 1.6; color: var(--ink-2); }
.summary-card .sum-text p + p { margin-top: 10px; }
.tl { position: relative; padding-left: 26px; }
.tl::before { content: ''; position: absolute; left: 8px; top: 6px; bottom: 6px; width: 2px; background: var(--line); }
.tl-month { font-weight: 600; font-size: 15px; margin: 18px 0 10px -26px; display: flex; align-items: center; gap: 10px; }
.tl-month:first-child { margin-top: 0; }
.tl-month .cnt { font-size: 12.5px; color: var(--muted); font-weight: 500; }
.tl-item { position: relative; background: var(--surface-2); border-radius: 14px; padding: 12px 14px; margin-bottom: 8px; }
.tl-item::before { content: ''; position: absolute; left: -23px; top: 17px; width: 10px; height: 10px; border-radius: 50%; background: var(--surface); border: 2.5px solid var(--brand); }
.tl-item .ti-top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.tl-item .ti-title { font-weight: 600; }
.tl-item .ti-date { margin-left: auto; font-size: 12.5px; color: var(--muted); white-space: nowrap; }
.tl-item .ti-body { font-size: 14px; color: var(--ink-2); margin-top: 4px; white-space: pre-line; }

/* ---------- Forms ---------- */
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 16px; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field.full { grid-column: 1 / -1; }
.field label { font-size: 13px; font-weight: 600; color: var(--ink-2); }
.field .hint { font-size: 12.5px; color: var(--muted); }
.input, .field input, .field select, .field textarea {
  height: 42px; border: 1.5px solid var(--line-2); border-radius: 12px; padding: 0 12px; background: var(--surface); outline: 0; width: 100%;
}
.field textarea { height: auto; min-height: 90px; padding: 10px 12px; resize: vertical; line-height: 1.5; }
.field input:focus, .field select:focus, .field textarea:focus, .input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.switch { position: relative; width: 42px; height: 24px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.switch span { position: absolute; inset: 0; background: var(--line-2); border-radius: 99px; transition: background .15s; cursor: pointer; }
.switch span::after { content: ''; position: absolute; left: 3px; top: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: transform .15s; box-shadow: 0 1px 2px rgba(0, 0, 0, .2); }
.switch input:checked + span { background: var(--brand); }
.switch input:checked + span::after { transform: translateX(18px); }
.switch input:focus-visible + span { outline: 2px solid var(--brand); outline-offset: 2px; }
.conn-row { display: flex; align-items: center; gap: 14px; padding: 14px 0; border-bottom: 1px solid var(--line); }
.conn-row:last-child { border-bottom: 0; }
.conn-ic { width: 44px; height: 44px; border-radius: 14px; display: grid; place-items: center; flex: none; }
.status { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; white-space: nowrap; }
.status .ic { width: 16px; height: 16px; }
.status.ok { color: var(--up); }
.status.warn { color: #8a5d00; }
.status.off { color: var(--muted); }
.status.bad { color: var(--down); }
.note {
  display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: 14px;
  background: var(--tint-blue); color: var(--ink-2); font-size: 14px;
}
.note .ic { color: var(--brand); margin-top: 1px; }
.note.amber { background: var(--tint-amber); }
.note.amber .ic { color: #b47c00; }
.demo-ribbon {
  display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700; color: #8a5d00;
  background: var(--tint-amber); padding: 4px 10px; border-radius: 999px;
}

/* ---------- Modal ---------- */
.modal-back { position: fixed; inset: 0; background: rgba(23, 26, 43, .35); z-index: 90; display: grid; place-items: center; padding: 20px; }
.modal { background: var(--surface); border-radius: 22px; box-shadow: var(--shadow-pop); width: min(560px, 100%); max-height: calc(100vh - 40px); overflow: auto; padding: 24px; }
.modal-head { display: flex; align-items: center; margin-bottom: 18px; }
.modal-head h3 { font-size: 20px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translate(-50%, 20px); background: var(--ink); color: #fff;
  padding: 12px 18px; border-radius: 14px; font-size: 14px; opacity: 0; pointer-events: none; transition: all .2s; z-index: 120; max-width: calc(100vw - 32px);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Login ---------- */
.login-page { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); }
.login-left { display: flex; flex-direction: column; padding: 40px 56px; background: var(--bg); }
.login-form { margin: auto 0; width: min(400px, 100%); }
.login-form h1 { font-size: 34px; font-weight: 600; letter-spacing: -.02em; }
.login-form .lead { color: var(--muted); margin: 8px 0 26px; }
.login-form .field { margin-bottom: 14px; }
.login-form .field input { height: 50px; border-radius: 14px; background: var(--surface); }
.login-err { color: var(--down); font-size: 14px; margin: 4px 0 12px; min-height: 20px; }
.demo-box { margin-top: 26px; padding: 16px; border-radius: 18px; background: var(--surface); }
.demo-box .row + .row { margin-top: 8px; }
.demo-box button { flex: 1; justify-content: flex-start; }
.login-right {
  position: relative; overflow: hidden; margin: 16px; border-radius: 28px;
  background: radial-gradient(120% 90% at 85% 10%, #8e98f8 0%, #5b6cf0 40%, #3a47c8 100%);
  color: #fff; padding: 48px; display: flex; flex-direction: column; justify-content: flex-end;
}
.login-right h2 { font-size: 34px; font-weight: 500; line-height: 1.15; letter-spacing: -.02em; max-width: 480px; }
.login-right p { opacity: .85; margin-top: 12px; max-width: 460px; }
.login-float { position: absolute; background: #fff; color: var(--ink); border-radius: 20px; box-shadow: 0 30px 60px -20px rgba(10, 14, 60, .45); padding: 16px 18px; }
.brand-word { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 20px; letter-spacing: -.01em; }

/* ---------- Report (print view) ---------- */
.report { background: #fff; max-width: 920px; margin: 0 auto; border-radius: 22px; padding: 44px 48px; }
.report-head { display: flex; flex-wrap: wrap; align-items: center; gap: 16px; padding-bottom: 22px; border-bottom: 2px solid var(--ink); margin-bottom: 26px; }
.report h2 { font-size: 20px; margin: 28px 0 12px; }
.report .kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.report .kpi { border: 1px solid var(--line-2); border-radius: 14px; padding: 12px 14px; }
.report .kpi .l { font-size: 12.5px; color: var(--muted); }
.report .kpi .v { font-size: 22px; font-weight: 600; margin-top: 4px; }
.report-toolbar { max-width: 920px; margin: 0 auto 16px; display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }

/* ---------- Responsive ---------- */
@media (max-width: 1280px) {
  .g-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .g-3 > :last-child { grid-column: 1 / -1; }
}
@media (max-width: 1100px) {
  .g-21, .g-12, .g-2, .g-3, .g-3e { grid-template-columns: minmax(0, 1fr); }
  .g-3 > :last-child { grid-column: auto; }
  .geo-layout { grid-template-columns: minmax(0, 1fr); }
  .login-page { grid-template-columns: 1fr; }
  .login-right { display: none; }
}
@media (max-width: 760px) {
  body { font-size: 14.5px; }
  .app { grid-template-columns: minmax(0, 1fr); }
  .rail {
    position: fixed; top: auto; bottom: 0; left: 0; right: 0; height: auto; z-index: 80;
    flex-direction: row; padding: 8px 12px calc(8px + env(safe-area-inset-bottom)); gap: 8px;
    background: rgba(236, 238, 243, .96); backdrop-filter: blur(10px); border-top: 1px solid var(--line-2);
    overflow-x: auto;
  }
  .rail-logo, .rail-sep { display: none; }
  .rail-nav, .rail-foot { flex-direction: row; margin: 0; gap: 8px; }
  .rail-btn { width: 44px; height: 44px; flex: none; }
  .rail-btn .rail-tip { display: none; }
  .main { padding: 16px 16px 100px; }
  .topbar { flex-wrap: wrap; margin-bottom: 20px; }
  .search { flex: 1 1 100%; order: 3; }
  .topbar .grow { flex: 1; }
  .page-head h1 { font-size: 28px; }
  .page-head .actions { margin-left: 0; width: 100%; }
  .card { padding: 18px 16px; border-radius: 18px; }
  .polar-wrap { grid-template-columns: 1fr; }
  .geo-top { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .mv-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .form-grid { grid-template-columns: minmax(0, 1fr); }
  .login-left { padding: 28px 16px; }
  .report { padding: 24px 18px; border-radius: 16px; }
  .report .kpis { grid-template-columns: repeat(2, 1fr); }
  .input-search input { width: 120px; }
  .pill { height: 42px; padding: 0 14px; }
  .hide-sm { display: none !important; }
  .show-sm { display: inline; }
  .g-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .stat { padding: 14px; gap: 12px; }
  .stat-top { gap: 8px; }
  .stat-icon { width: 32px; height: 32px; }
  .stat-icon .ic { width: 16px; height: 16px; }
  .stat-label { font-size: 14px; line-height: 1.25; }
  .stat-cmp, .stat-more { display: none; }
  .stat-bottom { flex-wrap: wrap; gap: 6px; }
  .stat-value { font-size: 22px; }
  .delta { margin-left: 0; }
  .card-head { flex-wrap: wrap; }
  .seg { flex-wrap: wrap; }
  .report-head > div:last-child { margin-left: 0 !important; text-align: left !important; }
}

@media print {
  body { background: #fff; }
  .no-print, .rail, .topbar, .report-toolbar { display: none !important; }
  .app { display: block; }
  .main { padding: 0; }
  .report { box-shadow: none; padding: 0; border-radius: 0; max-width: none; }
  .report section { break-inside: avoid; }
  @page { margin: 14mm; }
}

/* ---------- Not-connected states ---------- */
.nc { display: flex; align-items: center; gap: 16px; background: var(--surface); border: 1.5px dashed var(--line-2); box-shadow: none; }
.nc .nc-ic { width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-2); color: var(--muted); flex: none; }
.nc .nc-chip { margin-left: auto; align-self: flex-start; }
.nc-list { list-style: none; padding: 0; margin: 22px auto 0; max-width: 460px; text-align: left; display: flex; flex-direction: column; gap: 10px; }
.nc-list li { display: flex; gap: 10px; align-items: flex-start; color: var(--ink-2); }
.nc-list li .ic { color: var(--up); margin-top: 2px; }
.stat.pending .stat-value { color: var(--faint); }
@media (max-width: 760px) { .nc { flex-wrap: wrap; } .nc .nc-chip { margin-left: 0; } }

/* ---------- Real map grid (Leaflet + OpenStreetMap) ---------- */
.geo-map { isolation: isolate; } /* keeps Leaflet's layers below menus and popovers */
.geo-leaflet { height: 470px; width: 100%; background: #edf0f4; }
.geo-leaflet .leaflet-tile-pane { filter: grayscale(.85) brightness(1.04) contrast(.92); }
.leaflet-container { font-family: var(--font); }
.geo-pin-wrap { background: transparent; border: 0; }
.geo-pin {
  display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%;
  font: 700 13px var(--font); border: 3px solid #fff; box-shadow: 0 2px 6px rgba(23, 26, 43, .28); cursor: pointer;
}
.geo-pin.sel { box-shadow: 0 0 0 3px var(--brand), 0 2px 6px rgba(23, 26, 43, .28); }
@media (max-width: 760px) { .geo-leaflet { height: 360px; } }

/* ---------- Attribution coverage ---------- */
.coverage { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; padding: 16px 20px; }
.coverage .cov-meter { width: 220px; max-width: 100%; }
.tbl tr.muted td { color: var(--muted); }

/* Choice rows (radio / checkbox) in admin forms */
.fieldset-label { font-size: 13px; font-weight: 600; color: var(--ink-2); margin-bottom: 6px; }
.opts { display: flex; flex-direction: column; gap: 8px; }
.opt { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); cursor: pointer; }
.opt:has(input:checked) { border-color: var(--brand); background: var(--brand-soft); }
.opt input { width: 16px; height: 16px; margin: 2px 0 0; accent-color: var(--brand); flex: none; }
.opt .opt-t { display: block; font-size: 14px; font-weight: 600; color: var(--ink); }
.opt .opt-d { display: block; font-size: 12.5px; color: var(--muted); margin-top: 1px; }
.ghl-connect-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1.6fr) auto; align-items: end; }
@media (max-width: 760px) { .ghl-connect-grid { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 760px) {
  #ghl-card .conn-row { flex-wrap: wrap; }
  #ghl-card .conn-row > .row { width: 100%; justify-content: flex-start !important; }
}
