/* Dotykačka brand: green-led, light surfaces, Poppins (web substitute for Gotham).
   Tokens from the Brand Guidelines 2025 (docs-brand/brands/dotykacka/colors.md). */

@font-face { font-family: "Poppins"; font-weight: 400; font-display: swap; src: url("../fonts/Poppins-Regular.woff2") format("woff2"); }
@font-face { font-family: "Poppins"; font-weight: 500; font-display: swap; src: url("../fonts/Poppins-Medium.woff2") format("woff2"); }
@font-face { font-family: "Poppins"; font-weight: 600; font-display: swap; src: url("../fonts/Poppins-SemiBold.woff2") format("woff2"); }
@font-face { font-family: "Poppins"; font-weight: 700; font-display: swap; src: url("../fonts/Poppins-Bold.woff2") format("woff2"); }

:root {
  --primary: #31B24A;
  --green-dark: #27902E;
  --green-darkest: #1F7024;
  --green-tint: #EAF7EC;
  --ink: #191919;
  --text: #242933;
  --text-2: #404959;
  --muted: #716C80;
  --background: #F6F7FA;
  --surface: #FFFFFF;
  --line: #E6E8EE;
  --line-strong: #D3D7E0;

  /* Chart categorical slots (validated: dataviz validate_palette.js, light). */
  --cat-creativity: #27902E;
  --cat-technical: #0084F4;
  --cat-bug_free: #A115B0;
  --up: #31B24A;
  --down: #E94555;
  --neutral: #404959;

  --radius: 12px;
  --shadow: 0 1px 2px rgba(25, 25, 25, .04), 0 4px 16px rgba(25, 25, 25, .05);
  --font: "Poppins", "Helvetica Neue", Helvetica, Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

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

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

body {
  margin: 0;
  background: var(--background);
  color: var(--text);
  font: 400 16px/1.6 var(--font);
}

a { color: var(--green-dark); }
a:hover { color: var(--green-darkest); }
h1, h2, h3 { color: var(--ink); line-height: 1.25; margin: 0 0 .5em; }
h1 { font-size: clamp(1.75rem, 3vw, 2.5rem); font-weight: 700; }
h2 { font-size: 1.25rem; font-weight: 600; }
h3 { font-size: 1rem; font-weight: 600; }
p { margin: 0 0 1em; }
code { font-family: var(--mono); font-size: .9em; background: var(--background); border: 1px solid var(--line); border-radius: 6px; padding: .05em .35em; }
pre { margin: 0 0 1em; background: #242933; color: #F6F7FA; border-radius: 10px; padding: 14px 16px; overflow-x: auto; font: 13px/1.55 var(--mono); }
pre code { background: none; border: 0; padding: 0; color: inherit; font-size: inherit; white-space: pre; }
.code-block code { white-space: pre-wrap; word-break: break-word; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.strong { font-weight: 600; }
[hidden] { display: none !important; }

/* --- top bar --------------------------------------------------------------- */
.topbar { background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10; }
.topbar__inner { max-width: 1440px; margin: 0 auto; padding: 12px 24px; display: flex; align-items: center; gap: 24px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; color: var(--ink); }
.brand img { display: block; height: 24px; width: auto; }
.brand__app { font-weight: 600; font-size: .95rem; padding-left: 12px; border-left: 1px solid var(--line-strong); color: var(--text-2); }
.nav { display: flex; align-items: center; gap: 4px; margin-left: auto; flex-wrap: wrap; }
.nav a, .linklike { color: var(--text-2); text-decoration: none; font: 500 .95rem var(--font); padding: 8px 12px; border-radius: 8px; background: none; border: 0; cursor: pointer; }
.nav a:hover, .linklike:hover { background: var(--background); color: var(--ink); }
.nav a.is-active { background: var(--green-tint); color: var(--green-darkest); }
.nav__logout { margin: 0; }
html:fullscreen .topbar { display: none; }

/* --- layout ---------------------------------------------------------------- */
.page { max-width: 1080px; margin: 0 auto; padding: 32px 24px 64px; }
.page--wide { max-width: 1840px; }
.card, .panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 24px; margin-bottom: 24px; }
.card__head, .panel__head { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.page-head { margin-bottom: 24px; }
.empty { color: var(--muted); font-style: italic; margin: 8px 0; }
.note { color: var(--text-2); font-size: .9rem; background: var(--background); border-left: 3px solid var(--primary); padding: 8px 12px; border-radius: 0 8px 8px 0; }

.hero { padding: 24px 0 32px; }
.hero--compact { padding-bottom: 16px; }
.eyebrow { color: var(--green-dark); font-weight: 600; text-transform: uppercase; letter-spacing: .08em; font-size: .8rem; margin-bottom: .5em; }
.lead { font-size: 1.15rem; color: var(--text-2); max-width: 760px; }
.hero__actions { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 24px; }
.toc { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 16px; }
.toc a { text-decoration: none; font-weight: 500; font-size: .9rem; padding: 6px 12px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line); }

/* --- buttons & forms ------------------------------------------------------------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; font: 600 .95rem var(--font); padding: 10px 20px; border-radius: 10px; border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink); text-decoration: none; cursor: pointer; }
.btn:hover { border-color: var(--primary); color: var(--green-darkest); }
.btn--primary { background: var(--primary); border-color: var(--primary); color: #FFFFFF; }
.btn--primary:hover { background: var(--green-dark); border-color: var(--green-dark); color: #FFFFFF; }
.btn--small { padding: 6px 12px; font-size: .85rem; border-radius: 8px; }
.btn--danger:hover { border-color: var(--down); color: var(--down); }
.btn:disabled { opacity: .5; cursor: progress; }
.btn:focus-visible, input:focus-visible, textarea:focus-visible, a:focus-visible { outline: 3px solid rgba(49, 178, 74, .35); outline-offset: 2px; }

.field { margin-bottom: 20px; }
.field label { display: block; font-weight: 600; margin-bottom: 6px; color: var(--ink); }
.field__hint { font-size: .85rem; color: var(--muted); margin: 6px 0 0; }
.field__hint output { font-family: var(--mono); color: var(--text-2); word-break: break-all; }
.field__status { font-size: .9rem; margin: 6px 0 0; font-weight: 500; }
.field__status.is-ok { color: var(--green-dark); }
.field__status.is-error { color: var(--down); }
input[type=email], input[type=password], input[type=text], textarea {
  width: 100%; font: 400 1rem var(--font); color: var(--text); background: var(--surface);
  border: 1px solid var(--line-strong); border-radius: 10px; padding: 10px 12px;
}
textarea { font-family: var(--mono); font-size: .85rem; resize: vertical; }
input[type=file] { font: inherit; }

.flash { padding: 12px 16px; border-radius: 10px; margin-bottom: 16px; border: 1px solid; font-weight: 500; }
.flash--ok { background: var(--green-tint); border-color: #BFE6C6; color: var(--green-darkest); }
.flash--warn, .flash--error { background: #FDECEE; border-color: #F6C3C8; color: #A3202D; }

/* --- landing ------------------------------------------------------------- */
.steps__list { list-style: none; margin: 0 0 24px; padding: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; }
.step { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; box-shadow: var(--shadow); }
.step__num { display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: 50%; background: var(--primary); color: #FFFFFF; font-weight: 700; margin-bottom: 12px; }
.step p { color: var(--text-2); margin: 0; }
.category-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; }
.category { display: flex; gap: 12px; align-items: flex-start; }
.category h3 { margin-bottom: 4px; }
.category h3 code { font-weight: 400; font-size: .75rem; }
.category p { color: var(--text-2); font-size: .9rem; margin: 0; }
.category__swatch { flex: none; width: 12px; height: 12px; border-radius: 50%; margin-top: 6px; }
.category--creativity .category__swatch { background: var(--cat-creativity); }
.category--technical .category__swatch { background: var(--cat-technical); }
.category--bug_free .category__swatch { background: var(--cat-bug_free); }

/* --- guide / upload --------------------------------------------------------- */
.snippets h3 { margin: 16px 0 6px; font-size: .9rem; color: var(--text-2); }
.os-tabs { display: inline-flex; gap: 4px; padding: 4px; margin: 4px 0 12px; background: var(--background); border: 1px solid var(--line); border-radius: 10px; }
.os-tabs [role=tab] { font: 500 .85rem var(--font); padding: 6px 14px; border: 0; border-radius: 7px; background: none; color: var(--text-2); cursor: pointer; }
.os-tabs [role=tab]:hover { color: var(--ink); }
.os-tabs [role=tab][aria-selected=true] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
.os-tabs [role=tab]:focus-visible { outline: 3px solid rgba(49, 178, 74, .35); outline-offset: 2px; }
.token-calc { background: var(--green-tint); border-radius: 10px; padding: 16px; margin: 16px 0; }
.token-calc label { display: block; font-weight: 600; margin-bottom: 8px; }
.token-calc__row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.token-calc__row input { flex: 1 1 260px; width: auto; }
.token-calc__out { flex: 1 1 320px; font-family: var(--mono); font-size: .85rem; word-break: break-all; color: var(--ink); }
.upload__actions { display: flex; gap: 12px; flex-wrap: wrap; }
.result { margin-top: 20px; border-radius: 10px; padding: 14px 16px; border: 1px solid var(--line); }
.result.is-ok { background: var(--green-tint); border-color: #BFE6C6; }
.result.is-error { background: #FDECEE; border-color: #F6C3C8; }
.result__title { font-weight: 600; margin: 0; }
.result__list { margin: 8px 0 0; padding-left: 20px; font-family: var(--mono); font-size: .85rem; }
.login { max-width: 420px; margin: 48px auto; }

/* --- tables ---------------------------------------------------------------- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.table th { text-align: left; font-weight: 600; color: var(--text-2); font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; border-bottom: 1px solid var(--line-strong); padding: 8px 10px; white-space: nowrap; }
.table td { border-bottom: 1px solid var(--line); padding: 10px; vertical-align: top; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table .actions { text-align: right; }
.table .actions form { margin: 0; }
.table .comment { color: var(--text-2); max-width: 420px; }
.token { font-size: .78rem; cursor: pointer; word-break: break-all; }
.pill { display: inline-block; font-size: .8rem; font-weight: 600; padding: 2px 10px; border-radius: 999px; background: var(--background); color: var(--muted); text-decoration: none; }
.pill--ok { background: var(--green-tint); color: var(--green-darkest); }

/* --- dashboard ---------------------------------------------------------------- */
.dash__head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.dash__head h1 { margin: 0; }
.dash__tools { display: flex; align-items: center; gap: 16px; }
.live { display: inline-flex; align-items: center; gap: 8px; font-size: .9rem; color: var(--text-2); font-variant-numeric: tabular-nums; }
.live__dot { width: 10px; height: 10px; border-radius: 50%; background: var(--primary); animation: pulse 2s infinite; }
.live.is-error .live__dot { background: var(--down); animation: none; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(49, 178, 74, .5); } 70% { box-shadow: 0 0 0 10px rgba(49, 178, 74, 0); } 100% { box-shadow: 0 0 0 0 rgba(49, 178, 74, 0); } }

.tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 20px; margin-bottom: 20px; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px 24px; }
.tile--hero { background: var(--primary); border-color: var(--primary); color: #FFFFFF; }
.tile__label { font-size: .9rem; font-weight: 500; margin: 0 0 4px; color: inherit; opacity: .85; }
.tile__value { font-size: clamp(2rem, 3.4vw, 3.4rem); font-weight: 600; line-height: 1.1; margin: 0 0 8px; color: var(--ink); }
.tile--hero .tile__value { color: #FFFFFF; }
.tile__of { font-size: .55em; font-weight: 500; opacity: .85; }
.tile__sub { font-size: .9rem; margin: 0; color: var(--text-2); }
.tile--hero .tile__sub { color: #FFFFFF; opacity: .9; }
.tile__cats { display: flex; gap: 12px; flex-wrap: wrap; }
.meter { height: 8px; border-radius: 999px; background: rgba(255, 255, 255, .3); margin-bottom: 10px; overflow: hidden; }
.meter__fill { display: block; height: 100%; width: 0; background: #FFFFFF; border-radius: 999px; transition: width .8s cubic-bezier(.2, .8, .2, 1); }

.dash__grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 20px; align-items: start; }
.dash__grid .panel { margin: 0; min-width: 0; }
.panel h2 { margin-bottom: 4px; }
.panel__sub { color: var(--muted); font-size: .85rem; margin-bottom: 16px; }
.dash__col { display: flex; flex-direction: column; gap: 20px; min-width: 0; }
.dash__col .panel { margin: 0; }
.panel--leaderboard { grid-column: span 7; }
.dash__col--side { grid-column: span 5; }
.panel--dist, .panel--improve { grid-column: span 6; }
.panel--raters, .dash__col--mid, .panel--feed { grid-column: span 4; }

.legend { display: flex; gap: 16px; list-style: none; margin: 0; padding: 0; font-size: .85rem; color: var(--text-2); flex-wrap: wrap; }
.legend li { display: inline-flex; align-items: center; gap: 6px; }
.key { display: inline-block; width: 10px; height: 10px; border-radius: 50%; flex: none; }
.key--lg { width: 14px; height: 14px; }
.key--creativity { background: var(--cat-creativity); }
.key--technical { background: var(--cat-technical); }
.key--bug_free { background: var(--cat-bug_free); }
.pip { display: inline-flex; align-items: center; gap: 5px; font-variant-numeric: tabular-nums; white-space: nowrap; }

.leaderboard { display: flex; flex-direction: column; gap: 6px; }
.lb-row { display: grid; grid-template-columns: 40px minmax(0, 1fr) 56px auto; align-items: center; gap: 14px; padding: 8px 10px; border-radius: 10px; }
.lb-row:hover { background: var(--background); }
.lb-rank { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; background: var(--background); color: var(--text-2); font-weight: 600; }
.lb-row.is-top .lb-rank { background: var(--primary); color: #FFFFFF; }
.lb-name { font-weight: 600; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-bottom: 6px; }
.lb-n { font-weight: 400; font-size: .85rem; color: var(--muted); }
.lb-bar { height: 14px; background: var(--background); border-radius: 0 4px 4px 0; }
.lb-fill { display: block; height: 100%; width: 0; background: var(--primary); border-radius: 0 4px 4px 0; transition: width .7s cubic-bezier(.2, .8, .2, 1); }
.lb-score { font-size: 1.5rem; font-weight: 600; color: var(--ink); text-align: right; }
.lb-cats { display: flex; gap: 12px; font-size: .85rem; color: var(--text-2); }

.winners { display: grid; gap: 12px; }
.winner { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 14px; padding: 12px 16px; border-radius: 10px; background: var(--background); }
.winner__title { font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; color: var(--text-2); margin: 0; font-weight: 600; }
.winner__name { font-size: 1.2rem; font-weight: 600; color: var(--ink); margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.winner__score { font-size: 1.6rem; font-weight: 600; margin: 0; color: var(--ink); }

.multiples { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.multiple { margin: 0; min-width: 0; }
.multiple figcaption { display: flex; align-items: center; gap: 6px; font-weight: 600; font-size: .9rem; margin-bottom: 6px; color: var(--ink); white-space: nowrap; }
.multiple svg, .chart svg, [data-contested] svg { display: block; width: 100%; height: auto; overflow: visible; }

.summary { color: var(--text-2); }
.summary strong { color: var(--ink); }
.diverging { display: flex; flex-direction: column; gap: 6px; }
.dv-row { display: grid; grid-template-columns: minmax(0, 38%) minmax(0, 1fr) 80px; align-items: center; gap: 12px; font-size: .9rem; }
.dv-label { display: flex; flex-direction: column; min-width: 0; }
.dv-label span:first-child { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--ink); font-weight: 500; }
.dv-label .small { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dv-track { position: relative; height: 16px; }
.dv-zero { position: absolute; left: 50%; top: -4px; bottom: -4px; width: 1px; background: var(--line-strong); }
.dv-fill { position: absolute; top: 0; height: 100%; min-width: 2px; }
.dv-fill.is-pos { border-radius: 0 4px 4px 0; }
.dv-fill.is-neg { border-radius: 4px 0 0 4px; }
.dv-value { text-align: right; font-variant-numeric: tabular-nums; color: var(--text-2); white-space: nowrap; }
.fill-up { background: var(--up); }
.fill-down { background: var(--down); }
.fill-neutral { background: var(--neutral); }

.callouts { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; margin-bottom: 16px; }
.callout { background: var(--background); border-radius: 10px; padding: 10px 12px; min-width: 0; }
.callout__title { font-size: .75rem; text-transform: uppercase; letter-spacing: .06em; color: var(--text-2); font-weight: 600; margin: 0; }
.callout__name { font-weight: 600; color: var(--ink); margin: 2px 0; overflow-wrap: anywhere; }
.callout .small { margin: 0; }

.feed { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.feed__item { display: grid; grid-template-columns: 76px minmax(0, 1fr); column-gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: .9rem; }
.feed__item time { grid-row: span 2; color: var(--muted); font-variant-numeric: tabular-nums; }
.feed__name { font-weight: 600; color: var(--ink); }
.feed__item.is-fresh { animation: fresh 2.5s ease-out; }
@keyframes fresh { from { background: var(--green-tint); } to { background: transparent; } }

.bars { display: flex; flex-direction: column; gap: 10px; }
.bars__row { display: grid; grid-template-columns: minmax(0, 34%) minmax(0, 1fr) 44px 56px; align-items: center; gap: 12px; font-size: .9rem; }
.bars__label { color: var(--ink); font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bars__track { height: 14px; }
.bars__fill { display: block; height: 100%; background: var(--primary); border-radius: 0 4px 4px 0; min-width: 2px; }
.bars__value { text-align: right; font-variant-numeric: tabular-nums; color: var(--text-2); }
.bars__extra { font-variant-numeric: tabular-nums; }

.self-list { list-style: none; margin: 0; padding: 0; }
.self-list li { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: .9rem; }

/* SVG chart marks */
.grid { stroke: var(--line); stroke-width: 1; }
.baseline { stroke: var(--line-strong); stroke-width: 1; }
.axis-label { fill: var(--muted); font: 12px var(--font); }
.row-label { fill: var(--ink); font: 500 13px var(--font); }
.row-value, .end-label { fill: var(--text-2); font: 600 13px var(--font); }
.range { stroke: var(--line-strong); stroke-width: 2; stroke-linecap: round; }
.dot { fill: var(--neutral); fill-opacity: .55; stroke: var(--surface); stroke-width: 2; }
.dot:hover, .marker:hover { fill-opacity: 1; }
.mean-tick { stroke: var(--ink); stroke-width: 3; stroke-linecap: round; }
.line { fill: none; stroke: var(--primary); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.area { fill: var(--primary); fill-opacity: .1; stroke: none; }
.marker { fill: var(--primary); stroke: var(--surface); stroke-width: 2; }
.fill-creativity { fill: var(--cat-creativity); }
.fill-technical { fill: var(--cat-technical); }
.fill-bug_free { fill: var(--cat-bug_free); }

.tip { position: fixed; z-index: 50; pointer-events: none; background: var(--ink); color: #FFFFFF; font-size: .85rem; padding: 6px 10px; border-radius: 8px; max-width: 320px; box-shadow: var(--shadow); }

/* --- responsive -------------------------------------------------------------- */
@media (max-width: 1280px) {
  .panel--leaderboard, .dash__col--side, .panel--dist, .panel--improve, .panel--feed { grid-column: span 12; }
  .panel--raters, .dash__col--mid { grid-column: span 6; }
}
@media (max-width: 860px) {
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dash__grid > .panel, .dash__grid > .dash__col { grid-column: span 12; }
  .multiples { grid-template-columns: 1fr; }
  .lb-row { grid-template-columns: 34px minmax(0, 1fr) 48px; }
  .lb-cats { grid-column: 2 / -1; }
  .topbar__inner, .page { padding-left: 16px; padding-right: 16px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
