/* ─────────────────────────────────────────────────────────────
   Risely GA4 Machine
   Flat geometric system. No gradients, shadows, glow, or layered
   transparency anywhere — every surface is a solid fill.

   Palette is closed: blue carries meaning, one pastel per view,
   dark is used sparingly for weight. Light mode only, by design:
   the brand specifies #F1F1F1 as the default ground and caps dark
   at roughly a tenth of the surface.
   ───────────────────────────────────────────────────────────── */

:root {
    --bg:        #F1F1F1;
    --surface:   #FFFFFF;
    --ink:       #141414;
    --blue:      #2462EB;
    --green:     #D9EFC5;
    --pink:      #FFDFFA;
    --yellow:    #FFEFBC;

    /* Derived neutrals — contrast-checked against --bg */
    --muted:     #5A5A5A;   /* 7.0:1 on #F1F1F1 */
    --line:      #D8D8D8;   /* recessive rules and grid */
    --line-firm: #BFBFBF;

    --radius:    6px;
    --gap:       24px;
    --maxw:      1320px;

    --mono: ui-monospace, "SF Mono", "Cascadia Mono", "Roboto Mono", Menlo, Consolas, monospace;
    --sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: var(--sans);
    font-size: 15px;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -0.015em; }
h1 { font-size: 30px; line-height: 1.2; }
h2 { font-size: 19px; }
h3 { font-size: 15px; }

/* ── Shell ──────────────────────────────────────────────── */

.masthead {
    background: var(--surface);
    border-bottom: 2px solid var(--ink);
}
.masthead__inner {
    max-width: var(--maxw);
    margin: 0 auto;
    padding: 0 28px;
    display: flex;
    align-items: center;
    gap: 32px;
    min-height: 64px;
    flex-wrap: wrap;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 600;
    font-size: 16px;
    color: var(--ink);
    letter-spacing: -0.02em;
}
.brand:hover { text-decoration: none; }
/* The mark: a solid blue square with a square notch cut out of it —
   a fragment removed from a whole, which is what a breakdown is. */
.brand__mark {
    width: 18px; height: 18px;
    background: var(--blue);
    border-radius: 3px;
    position: relative;
    flex: none;
}
.brand__mark::after {
    content: "";
    position: absolute;
    right: 3px; bottom: 3px;
    width: 7px; height: 7px;
    background: var(--surface);
    border-radius: 1px;
}

.nav { display: flex; gap: 4px; flex-wrap: wrap; }
.nav a {
    padding: 7px 13px;
    border-radius: var(--radius);
    color: var(--muted);
    font-size: 14px;
    font-weight: 500;
}
.nav a:hover { background: var(--bg); color: var(--ink); text-decoration: none; }
.nav a.is-active { background: var(--blue); color: #fff; }

.masthead__end { margin-left: auto; display: flex; align-items: center; gap: 14px; font-size: 13px; color: var(--muted); }

.wrap { max-width: var(--maxw); margin: 0 auto; padding: 32px 28px 72px; }

.page-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: var(--gap);
    flex-wrap: wrap;
    margin-bottom: 26px;
}
.page-head p { margin: 6px 0 0; color: var(--muted); font-size: 14px; max-width: 62ch; }

/* ── Cards ──────────────────────────────────────────────── */

.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 22px;
}
.card + .card { margin-top: var(--gap); }
.card__head {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 16px;
    margin-bottom: 18px;
    flex-wrap: wrap;
}
.card__head p { margin: 4px 0 0; color: var(--muted); font-size: 13px; }

.grid { display: grid; gap: var(--gap); }
.grid--kpi { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.grid--2   { grid-template-columns: repeat(auto-fit, minmax(420px, 1fr)); }

/* ── Stat tiles ─────────────────────────────────────────── */

.stat {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 18px 20px 16px;
    /* Blue rule on the reading edge: the tile's subject marker. */
    border-left: 3px solid var(--blue);
}
.stat__label {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: var(--muted);
    font-weight: 600;
}
.stat__value {
    font-size: 30px;
    font-weight: 650;
    letter-spacing: -0.03em;
    margin-top: 6px;
    font-variant-numeric: tabular-nums;
}
.stat__foot {
    margin-top: 6px;
    font-size: 13px;
    color: var(--muted);
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

/* Direction is carried by the glyph and the sign, not by colour alone. */
.delta { font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.delta--up   { color: var(--blue); }
.delta--down { color: var(--ink); }
.delta--flat { color: var(--muted); }
.delta__arrow { font-size: 11px; }

/* ── Tables ─────────────────────────────────────────────── */

.table-scroll { overflow-x: auto; }

table.data {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
    min-width: 620px;
}
table.data th, table.data td {
    text-align: left;
    padding: 11px 14px;
    border-bottom: 1px solid var(--line);
    vertical-align: middle;
}
table.data th {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: var(--muted);
    font-weight: 600;
    border-bottom: 2px solid var(--ink);
    white-space: nowrap;
}
table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.data tbody tr:hover { background: var(--bg); }
table.data tbody tr:last-child td { border-bottom: none; }
.t-name { font-weight: 550; }
.t-sub { color: var(--muted); font-size: 12px; }

/* ── Insight items ──────────────────────────────────────── */

.insight {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 18px 20px;
    background: var(--surface);
    border-left: 4px solid var(--line-firm);
}
.insight + .insight { margin-top: 12px; }
.insight--critical { border-left-color: var(--ink); }
.insight--warn     { border-left-color: var(--ink); }
.insight--positive { border-left-color: var(--blue); }
.insight--info     { border-left-color: var(--line-firm); }

.insight__top {
    display: flex;
    gap: 12px;
    align-items: baseline;
    flex-wrap: wrap;
    margin-bottom: 6px;
}
.insight__title { font-weight: 600; font-size: 15px; }
.insight__body { color: #3A3A3A; font-size: 14px; white-space: pre-line; margin-top: 4px; }
.insight__meta { margin-top: 10px; font-size: 12px; color: var(--muted); font-family: var(--mono); }

.tag {
    display: inline-block;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-weight: 600;
    padding: 3px 8px;
    border-radius: 4px;
    background: var(--bg);
    color: var(--muted);
    border: 1px solid var(--line);
    white-space: nowrap;
}
.tag--critical { background: var(--ink);   color: #fff;  border-color: var(--ink); }
.tag--warn     { background: var(--yellow); color: var(--ink); border-color: #E8D08A; }
.tag--positive { background: var(--blue);  color: #fff;  border-color: var(--blue); }
.tag--ai       { background: var(--green); color: var(--ink); border-color: #B9D89C; }

/* ── Filter bar ─────────────────────────────────────────── */

.filters {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 16px 18px;
    margin-bottom: var(--gap);
    display: flex;
    gap: 14px;
    align-items: flex-end;
    flex-wrap: wrap;
}
.field { display: flex; flex-direction: column; gap: 5px; }
.field label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: var(--muted);
    font-weight: 600;
}
.field input, .field select {
    font: inherit;
    font-size: 14px;
    padding: 7px 10px;
    border: 1px solid var(--line-firm);
    border-radius: 4px;
    background: var(--surface);
    color: var(--ink);
    min-width: 150px;
}
.field input:focus, .field select:focus {
    outline: 2px solid var(--blue);
    outline-offset: 1px;
    border-color: var(--blue);
}

.btn {
    font: inherit;
    font-size: 14px;
    font-weight: 550;
    padding: 8px 18px;
    border-radius: 4px;
    border: 1px solid var(--blue);
    background: var(--blue);
    color: #fff;
    cursor: pointer;
}
.btn:hover { background: #1B51CC; border-color: #1B51CC; }
.btn--ghost { background: var(--surface); color: var(--ink); border-color: var(--line-firm); }
.btn--ghost:hover { background: var(--bg); border-color: var(--ink); }
.btn--sm { padding: 5px 12px; font-size: 13px; }

.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
    font-size: 13px;
    padding: 6px 12px;
    border-radius: 4px;
    border: 1px solid var(--line-firm);
    background: var(--surface);
    color: var(--muted);
}
.chip:hover { border-color: var(--ink); color: var(--ink); text-decoration: none; }
.chip.is-active { background: var(--ink); color: #fff; border-color: var(--ink); }

/* ── Charts ─────────────────────────────────────────────── */

.chart { width: 100%; display: block; overflow: visible; }
.chart text { font-family: var(--sans); fill: var(--muted); }
.chart .axis-line { stroke: var(--line-firm); stroke-width: 1; }
.chart .grid-line { stroke: var(--line); stroke-width: 1; }
.chart .series-line { fill: none; stroke: var(--blue); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .series-area { fill: var(--blue); opacity: 0.08; }
.chart .bar-pos { fill: var(--blue); }
.chart .bar-neg { fill: var(--ink); }
.chart .bar-track { fill: var(--bg); }
.chart .zero-line { stroke: var(--ink); stroke-width: 1.5; }
.chart .value-label { fill: var(--ink); font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums; }
.chart .cat-label { fill: var(--ink); font-size: 12.5px; }
.chart .tick-label { font-size: 11px; }
.chart .hit { fill: transparent; cursor: crosshair; }
.chart .cursor-line { stroke: var(--ink); stroke-width: 1; stroke-dasharray: 3 3; opacity: 0; }
.chart .cursor-dot { fill: var(--surface); stroke: var(--blue); stroke-width: 2.5; opacity: 0; }

.chart-legend {
    display: flex;
    gap: 18px;
    flex-wrap: wrap;
    font-size: 12.5px;
    color: var(--muted);
    margin-top: 12px;
}
.chart-legend span { display: inline-flex; align-items: center; gap: 7px; }
.swatch { width: 11px; height: 11px; border-radius: 2px; flex: none; }
.swatch--blue { background: var(--blue); }
.swatch--ink  { background: var(--ink); }

.tooltip {
    position: fixed;
    z-index: 60;
    background: var(--ink);
    color: #fff;
    border-radius: 4px;
    padding: 8px 11px;
    font-size: 12.5px;
    line-height: 1.45;
    pointer-events: none;
    opacity: 0;
    transition: opacity .08s linear;
    max-width: 260px;
    font-variant-numeric: tabular-nums;
}
.tooltip.is-on { opacity: 1; }
.tooltip b { font-weight: 600; }

/* ── Accent blocks — exactly one pastel per view ────────── */

.note {
    border-radius: var(--radius);
    padding: 16px 18px;
    font-size: 14px;
    border: 1px solid transparent;
}
.note--accent  { background: var(--accent, var(--green)); color: var(--ink); }
.note--plain   { background: var(--surface); border-color: var(--line); color: var(--muted); }

.empty {
    text-align: center;
    padding: 56px 24px;
    color: var(--muted);
    background: var(--surface);
    border: 1px dashed var(--line-firm);
    border-radius: var(--radius);
}
.empty h3 { color: var(--ink); margin-bottom: 8px; }
.empty code {
    font-family: var(--mono);
    font-size: 13px;
    background: var(--bg);
    padding: 2px 6px;
    border-radius: 3px;
    color: var(--ink);
}

/* ── Login ──────────────────────────────────────────────── */

.login-wrap {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
}
.login-card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-top: 4px solid var(--blue);
    border-radius: var(--radius);
    padding: 34px;
    width: 100%;
    max-width: 380px;
}
.login-card h1 { font-size: 21px; margin-bottom: 6px; }
.login-card .field { margin-top: 16px; }
.login-card .field input { width: 100%; }
.login-card .btn { width: 100%; margin-top: 22px; padding: 11px; }
.alert {
    margin-top: 16px;
    padding: 11px 13px;
    border-radius: 4px;
    font-size: 13.5px;
    background: var(--yellow);
    color: var(--ink);
    border: 1px solid #E8D08A;
}

.flash {
    padding: 12px 16px;
    border-radius: var(--radius);
    margin-bottom: var(--gap);
    font-size: 14px;
    background: var(--green);
    color: var(--ink);
    border: 1px solid #B9D89C;
}
.flash--error { background: var(--yellow); border-color: #E8D08A; }

.muted { color: var(--muted); }
.mono  { font-family: var(--mono); font-size: 13px; }
.nowrap { white-space: nowrap; }

/* ── Progress bar ──────────────────────────────────────── */
.progress {
    height: 10px;
    background: var(--bg);
    border: 1px solid var(--line);
    border-radius: 999px;
    overflow: hidden;
}
.progress__fill {
    height: 100%;
    min-width: 2px;
    background: var(--blue);
    border-radius: 999px;
    transition: width .35s ease;
}
.progress__fill.is-idle { background: var(--line-firm); }
.status-line { display: flex; flex-wrap: wrap; gap: 6px 18px; margin-top: 12px; font-size: 13px; }
.status-line b { font-variant-numeric: tabular-nums; }

.danger-zone { border-color: var(--ink); }
.danger-zone h2 { color: var(--ink); }

@media (max-width: 720px) {
    .wrap { padding: 22px 16px 56px; }
    .masthead__inner { padding: 0 16px; }
    h1 { font-size: 24px; }
    .stat__value { font-size: 25px; }
    .grid--2 { grid-template-columns: 1fr; }
}

@media print {
    .masthead, .filters, .btn { display: none; }
    .card, .stat, .insight { border-color: #999; }
}

/* ── MCP: OAuth prijava i stranica „GA4 za Claude” ───────────── */
.mcp-brand { margin-bottom: 18px; }
.mcp-lead { font-size: 14px; margin: 0; }
.mcp-small { font-size: 12px; margin: 16px 0 0; }
.login-card .btn.mcp-deny { margin-top: 10px; }
.mcp-secret {
    margin: 10px 0 0; padding: 12px 14px; border-radius: 8px;
    background: var(--yellow); border: 1px solid #E8D08A;
    font-family: var(--mono); font-size: 14px; word-break: break-all; user-select: all;
}
.mcp-form { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; }
.mcp-form .field input, .mcp-form .field textarea { min-width: 200px; }
.mcp-form textarea {
    font: inherit; padding: 8px 10px; border: 1px solid var(--line-firm);
    border-radius: 6px; min-height: 64px; min-width: 280px;
}
.mcp-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.mcp-actions form { margin: 0; }
.mcp-args { max-width: 420px; font-size: 12px; color: var(--muted); word-break: break-word; }
