/* Laatulehti – toimituksen työpöytä. Tumma toimitusteema, kultainen korostus. */
:root {
    --bg: hsl(225 30% 7%);
    --bg-2: hsl(225 26% 10%);
    --panel: hsl(225 22% 12.5%);
    --panel-2: hsl(225 20% 15.5%);
    --line: hsl(225 18% 20%);
    --line-soft: hsl(225 18% 16%);
    --text: hsl(40 20% 92%);
    --muted: hsl(225 12% 62%);
    --faint: hsl(225 10% 45%);
    --gold: hsl(39 74% 63%);
    --gold-deep: hsl(33 70% 48%);
    --gold-glow: hsl(39 80% 60% / .18);
    --teal: hsl(172 50% 52%);
    --red: hsl(4 70% 62%);
    --amber: hsl(32 85% 60%);
    --radius: 14px;
    --serif: 'Fraunces', Georgia, serif;
    --sans: 'Inter', system-ui, sans-serif;
    --shadow: 0 1px 0 hsl(0 0% 100% / .03) inset, 0 12px 32px -18px hsl(225 60% 2% / .9);
}

* { box-sizing: border-box; }
html { color-scheme: dark; }
body {
    margin: 0;
    font: 15px/1.5 var(--sans);
    color: var(--text);
    background:
        radial-gradient(1200px 600px at 85% -10%, hsl(39 60% 40% / .10), transparent 60%),
        radial-gradient(900px 500px at -10% 10%, hsl(215 60% 40% / .10), transparent 60%),
        var(--bg);
    min-height: 100vh;
}
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; cursor: pointer; }

/* ── Yläpalkki ─────────────────────────────────────────── */
.topbar {
    position: sticky; top: 0; z-index: 20;
    display: flex; align-items: center; gap: 28px;
    padding: 14px 28px;
    background: hsl(225 30% 7% / .78);
    backdrop-filter: blur(14px) saturate(140%);
    border-bottom: 1px solid var(--line-soft);
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
    display: grid; place-items: center; width: 34px; height: 34px; border-radius: 9px;
    font: 650 20px var(--serif); color: var(--bg);
    background: linear-gradient(140deg, var(--gold), var(--gold-deep));
    box-shadow: 0 6px 20px -6px var(--gold-glow), 0 0 0 1px hsl(39 80% 70% / .3) inset;
}
.brand-text { font: 650 19px var(--serif); letter-spacing: .2px; }
.brand-text em { font-style: normal; color: var(--muted); font-weight: 500; margin-left: 4px; }

.mainnav { display: flex; gap: 4px; }
.mainnav a {
    padding: 7px 14px; border-radius: 999px; color: var(--muted); font-weight: 500;
    transition: color .2s, background .2s;
}
.mainnav a:hover { color: var(--text); background: var(--panel); }
.mainnav a.active { color: var(--text); background: var(--panel-2); box-shadow: 0 0 0 1px var(--line) inset; }

.toolbar { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.segmented {
    display: inline-flex; padding: 3px; gap: 2px; border-radius: 999px;
    background: var(--panel); box-shadow: 0 0 0 1px var(--line) inset;
}
.segmented button {
    border: 0; background: transparent; padding: 5px 12px; border-radius: 999px;
    font-size: 13px; font-weight: 500; color: var(--muted); transition: all .2s;
}
.segmented button:hover { color: var(--text); }
.segmented button.active { background: var(--panel-2); color: var(--gold); box-shadow: 0 0 0 1px var(--line) inset; }

.btn-primary {
    display: inline-flex; align-items: center; gap: 9px;
    border: 0; padding: 8px 16px; border-radius: 999px; font-weight: 600; font-size: 14px;
    color: hsl(225 40% 8%);
    background: linear-gradient(140deg, var(--gold), var(--gold-deep));
    box-shadow: 0 8px 24px -10px var(--gold-glow);
    transition: transform .15s, filter .2s, box-shadow .2s;
}
.btn-primary:hover { transform: translateY(-1px); filter: brightness(1.06); box-shadow: 0 12px 28px -10px hsl(39 80% 55% / .45); }
.btn-primary:disabled { filter: grayscale(.4) brightness(.8); cursor: progress; transform: none; }
.btn-primary .dot { width: 7px; height: 7px; border-radius: 50%; background: hsl(225 40% 10%); }
.btn-primary.busy .dot { animation: pulse 1s ease-in-out infinite; }
@keyframes pulse { 50% { transform: scale(.4); opacity: .4; } }

/* ── Tilapalkki ────────────────────────────────────────── */
.statusbar {
    display: flex; flex-wrap: wrap; gap: 26px; align-items: center;
    padding: 12px 28px; color: var(--muted); font-size: 13px;
    border-bottom: 1px solid var(--line-soft);
}
.statusbar b { color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }
.statusbar .live { display: inline-flex; align-items: center; gap: 8px; }
.statusbar .live::before {
    content: ''; width: 8px; height: 8px; border-radius: 50%; background: var(--teal);
    box-shadow: 0 0 0 0 hsl(172 50% 52% / .6); animation: ring 2.2s infinite;
}
@keyframes ring { 70% { box-shadow: 0 0 0 8px hsl(172 50% 52% / 0); } 100% { box-shadow: 0 0 0 0 hsl(172 50% 52% / 0); } }

/* ── Näkymät ───────────────────────────────────────────── */
.view { padding: 28px; max-width: 1800px; margin: 0 auto; animation: fadein .35s ease; }
@keyframes fadein { from { opacity: 0; transform: translateY(6px); } }

.view-head { display: flex; align-items: end; gap: 20px; flex-wrap: wrap; margin-bottom: 22px; }
.view-head h1 { margin: 0; font: 650 clamp(26px, 3vw, 36px)/1.1 var(--serif); letter-spacing: -.3px; }
.view-head p { margin: 6px 0 0; color: var(--muted); max-width: 70ch; }
.view-head .spacer { flex: 1; }

/* ── Yleiskuvan maakortit ──────────────────────────────── */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 16px; }
.card {
    position: relative; display: flex; flex-direction: column;
    background: linear-gradient(180deg, var(--panel), var(--bg-2));
    border: 1px solid var(--line-soft); border-radius: var(--radius);
    box-shadow: var(--shadow); overflow: hidden;
    transition: border-color .25s, transform .25s;
    animation: rise .45s ease both;
}
.card:hover { border-color: var(--line); transform: translateY(-2px); }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } }
.card-head {
    display: flex; align-items: center; gap: 12px; padding: 14px 16px 10px;
}
.cc {
    display: inline-grid; place-items: center; min-width: 36px; height: 26px; padding: 0 6px; border-radius: 7px;
    font: 600 12px var(--sans); letter-spacing: .8px; color: var(--gold);
    background: hsl(39 70% 50% / .1); box-shadow: 0 0 0 1px hsl(39 70% 60% / .22) inset;
}
.cc-lg { min-width: 48px; height: 34px; font-size: 15px; margin-right: 14px; vertical-align: 6px; }
.card-head h2 { margin: 0; font: 600 18px var(--serif); }
.card-head h2 a:hover { color: var(--gold); }
.card-head .meta { margin-left: auto; font-size: 12px; color: var(--faint); white-space: nowrap; }
.card-head .meta b { color: var(--muted); font-weight: 600; }

.headlines { list-style: none; margin: 0; padding: 0 8px 8px; }
.headline {
    display: block; padding: 9px 10px; border-radius: 9px;
    transition: background .18s;
}
.headline:hover { background: hsl(225 20% 18% / .7); }
.headline .t { font: 500 15px/1.35 var(--serif); color: var(--text); }
.headline:hover .t { color: hsl(40 40% 96%); }
.headline .orig { display: block; margin-top: 3px; font-size: 12.5px; color: var(--faint); line-height: 1.35; }
.headline .row { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; margin-top: 5px; font-size: 12px; color: var(--faint); }
.headline .row > span { white-space: nowrap; }
.src { color: var(--muted); font-weight: 500; }
.badge {
    display: inline-flex; align-items: center; padding: 1px 7px; border-radius: 999px;
    font-size: 10.5px; font-weight: 600; letter-spacing: .4px; text-transform: uppercase;
}
.badge.new { color: var(--teal); background: hsl(172 50% 50% / .12); }
.badge.top { color: var(--gold); background: hsl(39 70% 55% / .12); }
.badge.untr { color: var(--faint); background: hsl(225 10% 50% / .12); }
.badge.skip { color: var(--faint); background: transparent; border: 1px dashed hsl(225 10% 50% / .35); }
.badge.fail { color: hsl(4 80% 68%); background: hsl(4 75% 55% / .14); cursor: help; }
.badge.act {
    color: var(--gold); background: hsl(39 70% 55% / .08); border: 1px solid hsl(39 70% 55% / .35);
    cursor: pointer; transition: background .15s, transform .15s;
}
.badge.act:hover, .badge.act:focus-visible { background: hsl(39 70% 55% / .2); transform: translateY(-1px); outline: none; }
.badge.act.busy { cursor: progress; opacity: .7; animation: badge-blink 1.2s ease-in-out infinite; }

/* ── Aiheluokittelu ja avainsanat ──────────────────────── */
.badge.topic { font-weight: 600; font-size: 10px; padding: 2px 6px; border-radius: 4px; text-transform: uppercase; letter-spacing: 0.3px; }
.badge.topic-politiikka    { color: #93c5fd; background: hsl(217 91% 60% / 0.15); border: 1px solid hsl(217 91% 60% / 0.28); }
.badge.topic-talous        { color: #6ee7b7; background: hsl(158 64% 52% / 0.15); border: 1px solid hsl(158 64% 52% / 0.28); }
.badge.topic-turvallisuus  { color: #fca5a5; background: hsl(0 91% 71% / 0.15); border: 1px solid hsl(0 91% 71% / 0.28); }
.badge.topic-oikeus        { color: #d8b4fe; background: hsl(271 91% 65% / 0.15); border: 1px solid hsl(271 91% 65% / 0.28); }
.badge.topic-yhteiskunta   { color: #7dd3fc; background: hsl(199 89% 48% / 0.15); border: 1px solid hsl(199 89% 48% / 0.28); }
.badge.topic-terveys       { color: #5eead4; background: hsl(173 80% 40% / 0.15); border: 1px solid hsl(173 80% 40% / 0.28); }
.badge.topic-ymparisto     { color: #86efac; background: hsl(142 69% 58% / 0.15); border: 1px solid hsl(142 69% 58% / 0.28); }
.badge.topic-teknologia    { color: #a5b4fc; background: hsl(239 84% 67% / 0.15); border: 1px solid hsl(239 84% 67% / 0.28); }
.badge.topic-kulttuuri     { color: #f9a8d4; background: hsl(330 81% 60% / 0.15); border: 1px solid hsl(330 81% 60% / 0.28); }
.badge.topic-urheilu       { color: #fdba74; background: hsl(27 96% 61% / 0.15); border: 1px solid hsl(27 96% 61% / 0.28); }
.badge.topic-onnettomuudet { color: #fde047; background: hsl(48 96% 53% / 0.15); border: 1px solid hsl(48 96% 53% / 0.28); }
.badge.topic-lifestyle     { color: #c4b5fd; background: hsl(258 90% 66% / 0.15); border: 1px solid hsl(258 90% 66% / 0.28); }

.badge.geo { font-weight: 500; font-size: 10px; color: var(--muted); background: var(--panel-2); border: 1px solid var(--line); border-radius: 4px; padding: 1px 5px; }

.result-keywords { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 6px; }
.kw-tag { font-size: 11px; color: var(--muted); background: var(--bg-2); border: 1px solid var(--line-soft); border-radius: 999px; padding: 1px 7px; text-decoration: none; transition: all .15s; }
.kw-tag:hover { color: var(--gold); border-color: var(--gold-deep); background: var(--panel); text-decoration: none; }
@keyframes badge-blink { 50% { opacity: .35; } }
#statusbar a.warn { color: hsl(4 80% 68%); text-decoration: none; }
#statusbar a.warn:hover { text-decoration: underline; }
.empty { padding: 18px 18px 22px; color: var(--faint); font-size: 13.5px; }
.card-foot { margin-top: auto; padding: 0 18px 14px; }
.card-foot a { font-size: 13px; color: var(--muted); }
.card-foot a:hover { color: var(--gold); }

/* ── Maanäkymä: lehdet sarakkeina ──────────────────────── */
.columns { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; align-items: start; }
.column { background: var(--panel); border: 1px solid var(--line-soft); border-radius: var(--radius); box-shadow: var(--shadow); }
.column-head { display: flex; align-items: baseline; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--line-soft); }
.column-head h2 { margin: 0; font: 600 17px var(--serif); }
.column-head a.home { margin-left: auto; font-size: 12px; color: var(--faint); }
.column-head a.home:hover { color: var(--gold); }
.column .headlines { padding: 6px; }
.pos { font-variant-numeric: tabular-nums; color: var(--faint); min-width: 22px; }

/* ── Haku ──────────────────────────────────────────────── */
.searchbar { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 18px; }
.input, .select {
    padding: 11px 14px; border-radius: 11px; border: 1px solid var(--line);
    background: var(--panel); color: var(--text); font: inherit; outline: none;
    transition: border-color .2s, box-shadow .2s;
}
.input { flex: 1; min-width: 260px; font-size: 16px; }
.input:focus, .select:focus { border-color: var(--gold-deep); box-shadow: 0 0 0 4px var(--gold-glow); }
.results { background: var(--panel); border: 1px solid var(--line-soft); border-radius: var(--radius); overflow: hidden; }
.result { display: grid; grid-template-columns: 52px 1fr auto; gap: 14px; align-items: start; padding: 12px 16px; border-bottom: 1px solid var(--line-soft); transition: background .18s; }
.result:last-child { border-bottom: 0; }
.result:hover { background: var(--panel-2); }
.result .when { font-size: 12px; color: var(--faint); white-space: nowrap; }
.pager { display: flex; gap: 10px; align-items: center; justify-content: center; margin-top: 16px; color: var(--muted); font-size: 14px; }
.btn-ghost { border: 1px solid var(--line); background: var(--panel); padding: 7px 14px; border-radius: 999px; transition: border-color .2s, color .2s; }
.btn-ghost:hover:not(:disabled) { border-color: var(--gold-deep); color: var(--gold); }
.btn-ghost:disabled { opacity: .4; cursor: default; }

/* ── Lähteet ───────────────────────────────────────────── */
table.tbl { width: 100%; border-collapse: collapse; background: var(--panel); border: 1px solid var(--line-soft); border-radius: var(--radius); overflow: hidden; font-size: 13.5px; }
.tbl th { text-align: left; font-weight: 600; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .5px; padding: 11px 14px; background: var(--bg-2); border-bottom: 1px solid var(--line); }
.tbl td { padding: 10px 14px; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
.tbl tr:hover td { background: var(--panel-2); }
.tbl .err { color: var(--faint); font-size: 12px; max-width: 420px; }
.status { display: inline-flex; align-items: center; gap: 7px; font-weight: 500; }
.status::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: var(--faint); }
.status.ok::before { background: var(--teal); }
.status.empty::before { background: var(--amber); }
.status.error::before { background: var(--red); }
.num { font-variant-numeric: tabular-nums; text-align: right; }

/* ── Muut ──────────────────────────────────────────────── */
.skeleton { height: 260px; border-radius: var(--radius); background: linear-gradient(90deg, var(--panel) 0%, var(--panel-2) 50%, var(--panel) 100%); background-size: 200% 100%; animation: shimmer 1.4s linear infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }
.toast { position: fixed; right: 24px; bottom: 24px; z-index: 50; padding: 12px 18px; border-radius: 12px; background: var(--panel-2); border: 1px solid var(--line); box-shadow: var(--shadow); animation: rise .3s ease; }
.foot { padding: 28px; text-align: center; color: var(--faint); font-size: 12.5px; }

/* ── Tapahtumat ja Aiheryhmät ───────────────────────────── */
.clusters-grid { display: flex; flex-direction: column; gap: 20px; margin-top: 20px; }
.cluster-card {
    background: var(--panel); border: 1px solid var(--line-soft); border-radius: var(--radius);
    padding: 20px 24px; box-shadow: var(--shadow); transition: border-color .2s;
}
.cluster-card:hover { border-color: var(--line); }
.cluster-card-head { display: flex; justify-content: space-between; align-items: baseline; flex-wrap: wrap; gap: 12px; border-bottom: 1px solid var(--line-soft); padding-bottom: 14px; margin-bottom: 16px; }
.cluster-title-wrap { display: flex; align-items: center; gap: 12px; }
.cluster-badge {
    background: var(--gold-glow); color: var(--gold); border: 1px solid hsl(39 80% 60% / .3);
    font-size: 12px; font-weight: 600; padding: 3px 9px; border-radius: 999px; letter-spacing: .2px;
}
.cluster-title { font: 600 20px/1.3 var(--serif); margin: 0; color: var(--text); }
.cluster-time { font-size: 12.5px; color: var(--faint); display: flex; gap: 8px; }

.cluster-items { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.cluster-item-row {
    display: grid; grid-template-columns: 220px 1fr auto; gap: 16px; align-items: start;
    padding: 10px 12px; border-radius: 8px; background: var(--bg-2); border: 1px solid var(--line-soft);
    transition: background .18s;
}
.cluster-item-row:hover { background: var(--panel-2); }
.item-meta-badges { display: flex; flex-direction: column; gap: 4px; }
.tag-type {
    display: inline-block; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .4px;
    padding: 2px 7px; border-radius: 5px; width: fit-content;
}
.tag-lead { background: hsl(39 80% 60% / .2); color: var(--gold); }
.tag-same_event { background: hsl(172 50% 52% / .18); color: var(--teal); }
.tag-follow_up { background: hsl(200 60% 50% / .2); color: hsl(200 80% 70%); }
.tag-source { font-size: 12px; color: var(--muted); font-weight: 500; }
.tag-manual { font-size: 10.5px; color: var(--amber); }

.item-text { display: flex; flex-direction: column; gap: 3px; }
.item-link { font-size: 14.5px; font-weight: 500; color: var(--text); line-height: 1.4; transition: color .18s; }
.item-link:hover { color: var(--gold); }
.orig-sub { font-size: 12px; color: var(--muted); }
.item-actions { display: flex; align-items: center; gap: 10px; font-size: 12px; color: var(--faint); }
.btn-detach {
    background: transparent; border: 1px solid var(--line); color: var(--muted);
    padding: 3px 8px; border-radius: 6px; font-size: 11.5px; transition: border-color .2s, color .2s;
}
.btn-detach:hover { border-color: var(--red); color: var(--red); }

/* Tarkistusjono */
.review-box {
    background: hsl(32 85% 60% / .08); border: 1px solid hsl(32 85% 60% / .3);
    border-radius: var(--radius); padding: 18px 22px; margin-bottom: 24px;
}
.review-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.review-head h3 { margin: 0; font-size: 16px; color: var(--amber); }
.review-head .tag { font-size: 11.5px; background: hsl(32 85% 60% / .2); color: var(--amber); padding: 2px 8px; border-radius: 999px; }
.review-list { display: flex; flex-direction: column; gap: 12px; }
.review-card {
    background: var(--panel); border: 1px solid var(--line-soft); border-radius: 10px;
    padding: 14px 16px; display: flex; flex-direction: column; gap: 10px;
}
.review-pair { display: grid; grid-template-columns: 1fr auto 1fr; gap: 14px; align-items: start; }
.pair-item { display: flex; flex-direction: column; gap: 4px; font-size: 14px; }
.pair-meta { display: flex; align-items: center; gap: 6px; }
.pair-item .source-tag { font-size: 11.5px; color: var(--muted); font-weight: 600; }
.pair-item .lang-tag { font-size: 10px; background: var(--line); color: var(--muted); padding: 1px 5px; border-radius: 4px; font-weight: 600; letter-spacing: 0.5px; }
.pair-title { color: var(--text); font-size: 14px; line-height: 1.35; }
.pair-summary { font-size: 12px; color: var(--muted); line-height: 1.35; margin-top: 2px; }
.pair-vs { color: var(--faint); font-weight: 600; font-size: 12px; text-transform: uppercase; align-self: center; }
.review-reason { font-size: 12.5px; color: var(--muted); background: var(--card-bg, rgba(255,255,255,0.02)); padding: 6px 10px; border-radius: 6px; }
.review-actions { display: flex; gap: 10px; }
.btn-small { padding: 5px 12px; border-radius: 6px; font-size: 12px; font-weight: 500; border: 1px solid transparent; }
.btn-approve { background: var(--teal); color: var(--bg); }
.btn-approve:hover { filter: brightness(1.1); }
.btn-dismiss { background: transparent; border-color: var(--line); color: var(--muted); }
.btn-dismiss:hover { border-color: var(--red); color: var(--red); }

@media (max-width: 860px) {
    .topbar { flex-wrap: wrap; gap: 12px; padding: 12px 16px; }
    .toolbar { margin-left: 0; width: 100%; justify-content: space-between; }
    .view { padding: 18px 14px; }
    .grid { grid-template-columns: 1fr; }
    .result { grid-template-columns: 1fr; gap: 4px; }
    .cluster-item-row { grid-template-columns: 1fr; gap: 8px; }
    .review-pair { grid-template-columns: 1fr; gap: 8px; }
}
