:root {
  --blue: #234f9d;
  --blue-dark: #173970;
  --brown: #8a5a3b;
  --ink: #182334;
  --muted: #657083;
  --line: #e3e8ef;
  --canvas: #f4f6f9;
  --white: #fff;
  --success: #1b7f52;
  --danger: #b42318;
  --radius: 14px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--canvas);
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--canvas); color: var(--ink); }
a { color: var(--blue); text-decoration: none; }
button, input, select { font: inherit; }
.muted { color: var(--muted); }
.login-page { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: radial-gradient(circle at 15% 10%, #e8eef9, transparent 38%), var(--canvas); }
.login-card { width: min(440px, 100%); padding: 36px; border-radius: 20px; background: var(--white); box-shadow: 0 24px 70px rgba(18, 38, 74, .12); border: 1px solid var(--line); }
.login-logo { display: block; width: 100%; max-width: 330px; height: auto; margin: 0 0 34px; }
.login-card h1 { font-size: 25px; margin: 0 0 6px; }
.login-card form { display: grid; gap: 18px; margin-top: 28px; }
label { display: grid; gap: 7px; color: #354154; font-size: 14px; font-weight: 650; }
input, select { width: 100%; min-height: 44px; padding: 9px 12px; border: 1px solid #cbd3df; border-radius: 9px; background: #fff; color: var(--ink); }
input:focus, select:focus { outline: 3px solid rgba(35,79,157,.16); border-color: var(--blue); }
.button { min-height: 42px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 9px 16px; border: 0; border-radius: 9px; cursor: pointer; font-weight: 720; }
.button-primary { background: var(--blue); color: #fff; }
.button-primary:hover { background: var(--blue-dark); }
.button-quiet { background: #edf1f7; color: var(--ink); }
.alert { padding: 12px 14px; margin: 18px 0; border-radius: 9px; font-size: 14px; }
.alert-error { color: #7a1d16; background: #fef0ef; border: 1px solid #f6c5c0; }
.alert-success { color: #12643f; background: #e6f6ee; border: 1px solid #b8e3cc; }
.app-shell { min-height: 100vh; display: grid; grid-template-columns: 248px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; padding: 24px 18px 18px; background: #fff; border-right: 1px solid var(--line); }
.brand { padding: 4px 5px 28px; }
.brand img { width: 100%; height: auto; display: block; }
.nav { display: grid; gap: 18px; overflow-y: auto; padding-right: 2px; }
.nav-group { display: grid; gap: 4px; }
.nav-group-title { padding: 0 12px 5px; color: #8a95a6; font-size: 10px; font-weight: 800; letter-spacing: .09em; text-transform: uppercase; }
.nav a { display: flex; align-items: center; min-height: 42px; padding: 9px 12px; border-radius: 9px; color: #435066; font-weight: 620; font-size: 14px; }
.nav a:hover { background: #f1f4f8; }
.nav a.active { color: var(--blue); background: #eaf0fb; }
.nav a.unavailable { color: #9aa4b3; }
.sidebar-user { margin-top: auto; padding: 18px 6px 0; border-top: 1px solid var(--line); }
.sidebar-user strong, .sidebar-user span { display: block; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user span { margin-top: 3px; color: var(--muted); font-size: 12px; }
.logout-form { margin-top: 12px; }
.logout-form button { width: 100%; }
.main { min-width: 0; }
.topbar { min-height: 74px; display: flex; align-items: center; gap: 18px; padding: 14px 30px; border-bottom: 1px solid var(--line); background: rgba(255,255,255,.88); backdrop-filter: blur(10px); }
.topbar h1 { margin: 0 auto 0 0; font-size: 24px; }
.filters-form { display: flex; align-items: end; gap: 10px; }
.filters-form label { min-width: 130px; font-size: 12px; }
.filters-form select, .filters-form input { min-height: 38px; padding: 6px 9px; }
.topbar-account { display: flex; align-items: center; gap: 10px; padding-left: 16px; border-left: 1px solid var(--line); white-space: nowrap; }
.topbar-account > span { max-width: 150px; overflow: hidden; text-overflow: ellipsis; font-size: 13px; font-weight: 700; }
.topbar-account .logout-form { margin: 0; }
.topbar-account .logout-form button { width: auto; }
.content { padding: 28px 30px 50px; }
.cards { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.metric { padding: 20px; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; }
.metric .label { display: block; color: var(--muted); font-size: 13px; }
.metric strong { display: block; margin-top: 10px; font-size: 29px; letter-spacing: -.5px; }
.metric small { display: block; margin-top: 8px; color: var(--muted); }
.grid-2 { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(300px, .7fr); gap: 18px; margin-top: 18px; }
.panel { min-width: 0; padding: 22px; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; }
.panel + .panel, .section-gap { margin-top: 18px; }
.panel h2 { margin: 0 0 18px; font-size: 18px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.panel-head h2 { margin: 0; }
.panel-intro { margin: 5px 0 0; }
.measurement-form { display: grid; grid-template-columns: 1.1fr 1fr 1fr auto; align-items: end; gap: 16px; }
.measurement-form label small { min-height: 32px; color: var(--muted); font-size: 12px; font-weight: 400; }
.measurement-form .optional { color: var(--muted); font-size: 12px; font-weight: 400; }
.measurement-submit { padding-bottom: 32px; }
.measurement-submit .button { white-space: nowrap; }
.measurement-switcher { min-width: 260px; }
.measurement-switcher label { font-size: 12px; }
.measurement-detail { margin-bottom: 20px; }
.code-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin: 20px 0 10px; }
.empty-state { text-align: center; }
.empty-state h2 { margin-bottom: 8px; }
.empty-state p { margin: 0; }
.copy-button { white-space: nowrap; }
.chart { width: 100%; height: 260px; display: block; }
.chart-grid { stroke: #e8ecf2; stroke-width: 1; }
.chart-area { fill: rgba(35,79,157,.09); }
.chart-line { fill: none; stroke: var(--blue); stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.chart-label { fill: var(--muted); font-size: 11px; }
.empty { min-height: 180px; display: grid; place-items: center; text-align: center; color: var(--muted); border: 1px dashed #cbd3df; border-radius: 10px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 12px 10px; border-bottom: 1px solid #edf0f4; text-align: left; vertical-align: top; }
th { color: var(--muted); font-size: 12px; font-weight: 720; text-transform: uppercase; letter-spacing: .035em; }
td.num, th.num { text-align: right; white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
.url-cell { max-width: 510px; overflow-wrap: anywhere; }
.badge { display: inline-flex; align-items: center; min-height: 24px; padding: 3px 8px; border-radius: 99px; background: #eef2f7; color: #435066; font-size: 12px; font-weight: 700; }
.badge-success { color: #12643f; background: #e6f6ee; }
.badge-danger { color: #8f241b; background: #fdebea; }
.funnel { display: grid; gap: 10px; }
.funnel-row { display: grid; grid-template-columns: minmax(160px, 1fr) 3fr 110px; align-items: center; gap: 14px; }
.funnel-track { height: 28px; overflow: hidden; background: #edf1f6; border-radius: 6px; }
.funnel-fill { height: 100%; min-width: 2px; background: linear-gradient(90deg, var(--blue), #4d77c4); border-radius: 6px; }
.code { padding: 14px; border-radius: 9px; background: #111827; color: #dbeafe; overflow-x: auto; font: 13px/1.55 ui-monospace, SFMono-Regular, Menlo, monospace; }
.definition { display: grid; grid-template-columns: 210px 1fr; gap: 0; }
.definition dt, .definition dd { margin: 0; padding: 11px 0; border-bottom: 1px solid #edf0f4; }
.definition dt { color: var(--muted); }
.status-dot { width: 8px; height: 8px; display: inline-block; margin-right: 6px; border-radius: 50%; background: var(--success); }
@media (max-width: 1150px) {
  .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-2 { grid-template-columns: 1fr; }
  .topbar { align-items: flex-start; flex-wrap: wrap; }
  .filters-form { order: 3; width: 100%; flex-wrap: wrap; }
  .topbar-account { margin-left: auto; }
  .measurement-form { grid-template-columns: 1fr 1fr; }
  .measurement-submit { padding-bottom: 0; }
  .measurement-switcher { width: 100%; min-width: 0; }
}
@media (max-width: 760px) {
  .app-shell { display: block; }
  .sidebar { position: static; width: 100%; height: auto; padding: 14px; }
  .brand { width: 220px; padding-bottom: 14px; }
  .nav { grid-template-columns: 1fr; gap: 12px; overflow: visible; }
  .nav-group { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .nav-group-title { grid-column: 1 / -1; padding-top: 4px; }
  .sidebar-user { display: none; }
  .topbar { padding: 16px; }
  .content { padding: 18px 16px 40px; }
  .cards { grid-template-columns: 1fr; }
  .topbar-account > span { display: none; }
  .filters-form { display: grid; grid-template-columns: 1fr 1fr; }
  .filters-form label:first-of-type { grid-column: 1 / -1; }
  .measurement-form { grid-template-columns: 1fr; }
  .measurement-form label small { min-height: 0; }
  .measurement-submit .button { width: 100%; }
  .code-head { align-items: stretch; flex-direction: column; }
  .panel-head { align-items: flex-start; flex-wrap: wrap; }
  .copy-button { width: 100%; }
  .definition { grid-template-columns: 1fr; }
  .definition dt { padding-bottom: 2px; border-bottom: 0; }
  .definition dd { padding-top: 2px; }
  .funnel-row { grid-template-columns: 1fr; gap: 6px; }
}
