/* ==========================================================================
   DigiMarkki – käyttöliittymän tyylit
   Tumma teema, Syne (otsikot) + DM Sans (leipäteksti)
   ========================================================================== */

:root {
  --bg: #0b0e14;
  --bg-alt: #11151f;
  --surface: #161b27;
  --surface-2: #1c2230;
  --border: #262d3d;
  --border-light: #323a4d;

  --text: #e8ecf4;
  --text-muted: #9aa5bb;
  --text-dim: #6b7689;

  --accent: #5b8cff;
  --accent-hover: #7aa2ff;
  --accent-dim: rgba(91, 140, 255, 0.14);

  --success: #3ecf8e;
  --success-dim: rgba(62, 207, 142, 0.14);
  --warning: #f5a524;
  --warning-dim: rgba(245, 165, 36, 0.14);
  --danger: #f45b5b;
  --danger-dim: rgba(244, 91, 91, 0.14);
  --critical: #ff3b6b;
  --info: #52b8e8;

  --radius: 10px;
  --radius-lg: 16px;
  --shadow: 0 2px 16px rgba(0, 0, 0, 0.35);
  --sidebar-w: 250px;
  --font-display: 'Syne', ui-sans-serif, system-ui, sans-serif;
  --font-body: 'DM Sans', ui-sans-serif, system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5 {
  font-family: var(--font-display);
  font-weight: 700;
  line-height: 1.25;
  margin: 0 0 0.5em;
  letter-spacing: -0.01em;
}
h1 { font-size: 1.9rem; }
h2 { font-size: 1.4rem; }
h3 { font-size: 1.12rem; }
h4 { font-size: 1rem; }

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

p { margin: 0 0 1em; }
small { font-size: 0.82rem; }
code, pre { font-family: ui-monospace, 'SF Mono', Menlo, monospace; font-size: 0.85em; }
code { background: var(--surface-2); padding: 2px 6px; border-radius: 5px; color: #a9c6ff; }
pre {
  background: var(--bg-alt); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px; overflow-x: auto; line-height: 1.5;
}
hr { border: none; border-top: 1px solid var(--border); margin: 24px 0; }

/* ── Layout ───────────────────────────────────────────────────────────── */
.app { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w); flex-shrink: 0; background: var(--bg-alt);
  border-right: 1px solid var(--border); padding: 20px 0; position: sticky;
  top: 0; height: 100vh; overflow-y: auto;
}
.sidebar .brand {
  font-family: var(--font-display); font-weight: 800; font-size: 1.28rem;
  padding: 0 20px 18px; display: block; color: var(--text); letter-spacing: -0.02em;
}
.sidebar .brand span { color: var(--accent); }
.sidebar .brand:hover { text-decoration: none; }

.nav-section { padding: 14px 20px 6px; font-size: 0.68rem; text-transform: uppercase;
  letter-spacing: 0.09em; color: var(--text-dim); font-weight: 600; }
.nav-link {
  display: flex; align-items: center; gap: 10px; padding: 8px 20px;
  color: var(--text-muted); font-size: 0.9rem; border-left: 2px solid transparent;
}
.nav-link:hover { background: var(--surface); color: var(--text); text-decoration: none; }
.nav-link.active { background: var(--accent-dim); color: var(--accent); border-left-color: var(--accent); }
.nav-link .badge { margin-left: auto; }

.project-switcher { padding: 0 16px 12px; }
.project-switcher select {
  width: 100%; background: var(--surface); border: 1px solid var(--border);
  color: var(--text); padding: 8px 10px; border-radius: var(--radius); font-size: 0.88rem;
}

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; gap: 16px; padding: 14px 28px;
  border-bottom: 1px solid var(--border); background: var(--bg-alt); position: sticky;
  top: 0; z-index: 20;
}
.topbar .spacer { flex: 1; }
.topbar .user { color: var(--text-muted); font-size: 0.86rem; }
.content { padding: 28px; max-width: 1400px; width: 100%; }

.page-head { display: flex; align-items: flex-start; gap: 20px; margin-bottom: 24px; flex-wrap: wrap; }
.page-head h1 { margin: 0 0 4px; }
.page-head .subtitle { color: var(--text-muted); margin: 0; font-size: 0.94rem; }
.page-head .actions { margin-left: auto; display: flex; gap: 10px; flex-wrap: wrap; }

/* ── Kortit ───────────────────────────────────────────────────────────── */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 20px; margin-bottom: 18px;
}
.card.tight { padding: 14px 16px; }
.card-head {
  display: flex; align-items: center; gap: 12px; margin: -4px 0 16px;
}
.card-head h2, .card-head h3 { margin: 0; }
.card-head .actions { margin-left: auto; display: flex; gap: 8px; }

.grid { display: grid; gap: 18px; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }

/* ── Mittarit ─────────────────────────────────────────────────────────── */
.stat { background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 18px; }
.stat .label { color: var(--text-dim); font-size: 0.76rem; text-transform: uppercase;
  letter-spacing: 0.07em; font-weight: 600; }
.stat .value { font-family: var(--font-display); font-size: 2rem; font-weight: 700;
  line-height: 1.1; margin: 6px 0 2px; }
.stat .delta { font-size: 0.82rem; }
.stat .delta.up { color: var(--success); }
.stat .delta.down { color: var(--danger); }
.stat .hint { color: var(--text-dim); font-size: 0.8rem; }

.score-ring {
  --value: 0; width: 96px; height: 96px; border-radius: 50%; display: grid;
  place-items: center; flex-shrink: 0;
  background: conic-gradient(var(--accent) calc(var(--value) * 1%), var(--surface-2) 0);
  position: relative;
}
.score-ring::before {
  content: ''; position: absolute; inset: 8px; background: var(--surface); border-radius: 50%;
}
.score-ring span { position: relative; font-family: var(--font-display); font-size: 1.5rem;
  font-weight: 700; }
.score-ring.good { --ring: var(--success); background: conic-gradient(var(--success) calc(var(--value) * 1%), var(--surface-2) 0); }
.score-ring.warn { background: conic-gradient(var(--warning) calc(var(--value) * 1%), var(--surface-2) 0); }
.score-ring.bad  { background: conic-gradient(var(--danger) calc(var(--value) * 1%), var(--surface-2) 0); }

/* ── Painikkeet ───────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 9px 16px; border-radius: var(--radius); border: 1px solid var(--border-light);
  background: var(--surface-2); color: var(--text); font-family: var(--font-body);
  font-size: 0.89rem; font-weight: 500; cursor: pointer; transition: all 0.14s;
  text-decoration: none; white-space: nowrap;
}
.btn:hover { background: var(--border); color: var(--text); text-decoration: none; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #08101f; font-weight: 600; }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: #08101f; }
.btn-success { background: var(--success); border-color: var(--success); color: #04150d; font-weight: 600; }
.btn-success:hover { filter: brightness(1.1); color: #04150d; }
.btn-danger { background: transparent; border-color: var(--danger); color: var(--danger); }
.btn-danger:hover { background: var(--danger-dim); color: var(--danger); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-muted); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn-sm { padding: 5px 11px; font-size: 0.8rem; }
.btn-lg { padding: 13px 26px; font-size: 1rem; }
.btn-block { width: 100%; }
.btn:disabled, .btn.disabled { opacity: 0.45; cursor: not-allowed; pointer-events: none; }

/* ── Lomakkeet ────────────────────────────────────────────────────────── */
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 0.84rem; font-weight: 600; margin-bottom: 6px;
  color: var(--text-muted); }
.field .help { font-size: 0.79rem; color: var(--text-dim); margin-top: 5px; }
input[type=text], input[type=email], input[type=password], input[type=url],
input[type=number], input[type=date], input[type=datetime-local], select, textarea {
  width: 100%; background: var(--bg-alt); border: 1px solid var(--border);
  color: var(--text); padding: 10px 12px; border-radius: var(--radius);
  font-family: var(--font-body); font-size: 0.92rem;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-dim);
}
textarea { min-height: 90px; resize: vertical; line-height: 1.55; }
textarea.code { font-family: ui-monospace, monospace; font-size: 0.85rem; min-height: 300px; }
.checkbox { display: flex; align-items: flex-start; gap: 9px; margin-bottom: 11px; }
.checkbox input { margin-top: 3px; accent-color: var(--accent); }
.checkbox label { margin: 0; font-weight: 400; color: var(--text); font-size: 0.89rem; }
.form-row { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }

/* ── Merkinnät ────────────────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px;
  border-radius: 999px; font-size: 0.74rem; font-weight: 600; letter-spacing: 0.01em;
  background: var(--surface-2); color: var(--text-muted); border: 1px solid var(--border);
}
.badge-critical { background: rgba(255,59,107,.14); color: var(--critical); border-color: rgba(255,59,107,.3); }
.badge-high { background: var(--danger-dim); color: var(--danger); border-color: rgba(244,91,91,.3); }
.badge-medium { background: var(--warning-dim); color: var(--warning); border-color: rgba(245,165,36,.3); }
.badge-low { background: var(--accent-dim); color: var(--accent); border-color: rgba(91,140,255,.3); }
.badge-info { background: rgba(82,184,232,.13); color: var(--info); border-color: rgba(82,184,232,.3); }
.badge-success { background: var(--success-dim); color: var(--success); border-color: rgba(62,207,142,.3); }
.badge-neutral { background: var(--surface-2); color: var(--text-muted); }

.pill { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 0.78rem;
  background: var(--surface-2); color: var(--text-muted); margin: 0 4px 4px 0; }

/* ── Taulukot ─────────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--border); }
table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
th {
  text-align: left; padding: 10px 14px; background: var(--bg-alt); color: var(--text-dim);
  font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.06em; font-weight: 600;
  border-bottom: 1px solid var(--border); white-space: nowrap;
}
td { padding: 11px 14px; border-bottom: 1px solid var(--border); vertical-align: top; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--surface-2); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.table-compact td, .table-compact th { padding: 7px 11px; }

/* ── Ilmoitukset ──────────────────────────────────────────────────────── */
.flash-stack { position: fixed; top: 16px; right: 16px; z-index: 1000; max-width: 420px; }
.alert {
  padding: 12px 16px; border-radius: var(--radius); margin-bottom: 10px;
  border: 1px solid var(--border); background: var(--surface); box-shadow: var(--shadow);
  font-size: 0.89rem; display: flex; gap: 10px; align-items: flex-start;
}
.alert-success { border-color: rgba(62,207,142,.4); background: var(--success-dim); }
.alert-error   { border-color: rgba(244,91,91,.4); background: var(--danger-dim); }
.alert-warning { border-color: rgba(245,165,36,.4); background: var(--warning-dim); }
.alert-info    { border-color: rgba(82,184,232,.4); background: rgba(82,184,232,.1); }
.alert .close { margin-left: auto; cursor: pointer; color: var(--text-dim); background: none;
  border: none; font-size: 1.1rem; line-height: 1; }

.notice {
  padding: 12px 16px; border-radius: var(--radius); border-left: 3px solid var(--accent);
  background: var(--surface-2); font-size: 0.88rem; margin-bottom: 16px;
}
.notice.warn { border-left-color: var(--warning); }
.notice.danger { border-left-color: var(--danger); }
.notice.success { border-left-color: var(--success); }

/* ── Edistyminen ──────────────────────────────────────────────────────── */
.progress { height: 6px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.progress .bar { height: 100%; background: var(--accent); transition: width 0.4s ease; }
.job-panel { display: none; }
.job-panel.active { display: block; }

.spinner {
  width: 15px; height: 15px; border: 2px solid var(--border-light);
  border-top-color: var(--accent); border-radius: 50%; animation: spin 0.7s linear infinite;
  display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Löydökset ja diffit ──────────────────────────────────────────────── */
.issue { border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 12px;
  background: var(--surface); overflow: hidden; }
.issue-head { display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px;
  cursor: pointer; }
.issue-head:hover { background: var(--surface-2); }
.issue-head .title { font-weight: 600; }
.issue-head .url { color: var(--text-dim); font-size: 0.8rem; word-break: break-all; }
.issue-body { padding: 0 16px 16px; border-top: 1px solid var(--border); display: none; }
.issue.open .issue-body { display: block; }
.issue-meta { display: flex; gap: 8px; align-items: center; margin-left: auto; flex-shrink: 0; }

.diff { display: grid; gap: 12px; grid-template-columns: 1fr 1fr; margin: 14px 0; }
.diff > div { border-radius: var(--radius); padding: 12px 14px; font-size: 0.86rem;
  border: 1px solid var(--border); }
.diff .before { background: rgba(244,91,91,.07); border-color: rgba(244,91,91,.25); }
.diff .after { background: rgba(62,207,142,.07); border-color: rgba(62,207,142,.25); }
.diff .label { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.07em;
  color: var(--text-dim); font-weight: 600; margin-bottom: 6px; }
@media (max-width: 720px) { .diff { grid-template-columns: 1fr; } }

/* ── Aikajana ─────────────────────────────────────────────────────────── */
.timeline { position: relative; padding-left: 24px; }
.timeline::before { content: ''; position: absolute; left: 6px; top: 6px; bottom: 6px;
  width: 2px; background: var(--border); }
.timeline-item { position: relative; padding-bottom: 18px; }
.timeline-item::before {
  content: ''; position: absolute; left: -22px; top: 6px; width: 9px; height: 9px;
  border-radius: 50%; background: var(--accent); border: 2px solid var(--bg);
}
.timeline-item.plan::before { background: var(--info); }
.timeline-item.apply::before, .timeline-item.publish::before { background: var(--success); }
.timeline-item.error::before { background: var(--danger); }
.timeline-item .time { font-size: 0.76rem; color: var(--text-dim); }
.timeline-item .title { font-weight: 600; font-size: 0.92rem; }
.timeline-item .detail { color: var(--text-muted); font-size: 0.85rem; }

/* ── Välilehdet ───────────────────────────────────────────────────────── */
.tabs { display: flex; gap: 3px; border-bottom: 1px solid var(--border); margin-bottom: 20px;
  overflow-x: auto; }
.tab { padding: 9px 15px; color: var(--text-muted); border-bottom: 2px solid transparent;
  font-size: 0.89rem; white-space: nowrap; }
.tab:hover { color: var(--text); text-decoration: none; }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }

/* ── Julkiset sivut ───────────────────────────────────────────────────── */
.public { max-width: 1120px; margin: 0 auto; padding: 0 24px; }
.public-nav { display: flex; align-items: center; gap: 26px; padding: 20px 0; }
.public-nav .brand { font-family: var(--font-display); font-weight: 800; font-size: 1.3rem;
  color: var(--text); }
.public-nav .spacer { flex: 1; }
.public-nav a { color: var(--text-muted); font-size: 0.92rem; }
.public-nav a:hover { color: var(--text); text-decoration: none; }

.hero { padding: 76px 0 56px; text-align: center; }
.hero h1 { font-size: clamp(2.1rem, 5vw, 3.4rem); margin-bottom: 18px; }
.hero .lead { font-size: 1.15rem; color: var(--text-muted); max-width: 660px;
  margin: 0 auto 32px; }
.hero .gradient { background: linear-gradient(120deg, var(--accent), var(--success));
  -webkit-background-clip: text; background-clip: text; color: transparent; }

.check-box {
  background: var(--surface); border: 1px solid var(--border-light);
  border-radius: var(--radius-lg); padding: 26px; max-width: 620px; margin: 0 auto;
  box-shadow: var(--shadow);
}
.check-box .row { display: flex; gap: 10px; }
.check-box .row input { flex: 1; }
@media (max-width: 620px) { .check-box .row { flex-direction: column; } }

.feature-grid { display: grid; gap: 20px; grid-template-columns: repeat(auto-fit, minmax(290px, 1fr));
  padding: 40px 0; }
.feature { background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 22px; }
.feature .icon { font-size: 1.5rem; margin-bottom: 10px; display: block; }
.feature h3 { margin-bottom: 8px; }
.feature p { color: var(--text-muted); font-size: 0.9rem; margin: 0; }

.price-grid { display: grid; gap: 18px; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  padding: 30px 0; }
.price { background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 24px; }
.price.featured { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent-dim); }
.price .amount { font-family: var(--font-display); font-size: 2.1rem; font-weight: 700; }
.price ul { list-style: none; padding: 0; margin: 16px 0; font-size: 0.88rem;
  color: var(--text-muted); }
.price li { padding: 5px 0; border-bottom: 1px solid var(--border); }

.auth-wrap { max-width: 430px; margin: 60px auto; padding: 0 20px; }
.auth-card { background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 30px; }

/* ── Apuluokat ────────────────────────────────────────────────────────── */
.muted { color: var(--text-muted); }
.dim { color: var(--text-dim); }
.small { font-size: 0.83rem; }
.mono { font-family: ui-monospace, monospace; }
.center { text-align: center; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 340px; }
.flex { display: flex; gap: 12px; align-items: center; }
.flex-between { display: flex; gap: 12px; align-items: center; justify-content: space-between; }
.flex-wrap { flex-wrap: wrap; }
.gap-sm { gap: 6px; }
.mt-0 { margin-top: 0; } .mt-1 { margin-top: 8px; } .mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; } .mb-0 { margin-bottom: 0; } .mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; } .mb-3 { margin-bottom: 24px; }
.hidden { display: none !important; }
.text-success { color: var(--success); } .text-danger { color: var(--danger); }
.text-warning { color: var(--warning); } .text-accent { color: var(--accent); }

.empty { text-align: center; padding: 44px 20px; color: var(--text-dim); }
.empty .icon { font-size: 2.2rem; display: block; margin-bottom: 10px; opacity: 0.55; }

.prose { max-width: 760px; line-height: 1.75; }
.prose h2 { margin-top: 1.7em; }
.prose ul, .prose ol { padding-left: 1.3em; }
.prose li { margin-bottom: 0.4em; }
.prose a { text-decoration: underline; }
.prose img { max-width: 100%; border-radius: var(--radius); }
.prose table { margin: 1.4em 0; }

/* ── Tulostus ─────────────────────────────────────────────────────────── */
@media print {
  :root { --bg: #fff; --surface: #fff; --text: #111; --text-muted: #444;
          --border: #ddd; --bg-alt: #fafafa; --surface-2: #f4f4f4; --text-dim: #666; }
  .sidebar, .topbar, .btn, .actions, .flash-stack { display: none !important; }
  body { background: #fff; color: #111; }
  .card { break-inside: avoid; border-color: #ddd; }
  .content { padding: 0; }
}

@media (max-width: 900px) {
  .app { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: static; border-right: none;
    border-bottom: 1px solid var(--border); }
  .content { padding: 18px; }
}
