/* Nettinotaari – perustyyli. Teemat (css/themes.css) ylikirjoittavat muuttujat. */
:root {
  /* Oletusilme = Nettinotaarin verkkosivut (petrooli, lämmin vaalea pohja, Newsreader + Figtree). Ei punaista. */
  --bg: #f8f6f3;
  --surface: #ffffff;
  --surface-2: #f6ede5;
  --text: #18242a;
  --muted: #5a6569;
  --border: #e2ddd6;
  --primary: #1b4f55;
  --primary-text: #ffffff;
  --accent: #3d7470;
  --mine-bg: #1b4f55;
  --mine-text: #ffffff;
  --theirs-bg: #ffffff;
  --theirs-text: #18242a;
  --messages-bg: #f6ede5;
  --topbar-bg: rgba(248, 246, 243, .9);
  --topbar-text: #18242a;
  --tag-bg: #f6ede5;
  --tag-text: #18242a;
  --tag-strong-text: #ffffff;
  --reason-bg: #f6ede5;
  --avatar-bg: #f2dfd1;
  --avatar-text: #1b4f55;
  --status-new-bg: #f2dfd1;
  --status-new-text: #18242a;
  --ok-bg: #e3efec;
  --ok-text: #1f5a50;
  --error-bg: #f6ede5;
  --error-text: #6b4a1e;
  --star: #c9902a;
  --cta-bg: #173c41;
  --cta-text: #f3efea;
  --cta-btn-bg: #f6ede5;
  --cta-btn-text: #173c41;
  --radius: 20px;
  --radius-sm: 12px;
  --bubble-radius: 18px;
  --bubble-tail: 6px;
  --btn-radius: 8px;
  --brand-radius: 8px;
  --avatar-radius: 12px;
  --shadow: 0 24px 50px -40px rgba(24, 36, 42, .45);
  --font: 'Figtree', 'Segoe UI', system-ui, sans-serif;
  --font-head: 'Newsreader', 'Iowan Old Style', Georgia, serif;
  --head-weight: 500;
  --head-tracking: -0.01em;
  --gap: 20px;
  --topbar-h: 64px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    --bg: #111a1c; --surface: #172326; --surface-2: #242c2e; --text: #ece8e2; --muted: #a2adaf; --border: #2a393c;
    --primary: #86c3c4; --primary-text: #0f1a1c; --accent: #9fd0cb; --mine-bg: #86c3c4; --mine-text: #0f1a1c;
    --theirs-bg: #172326; --theirs-text: #ece8e2; --messages-bg: #1b2a2d; --topbar-bg: rgba(17, 26, 28, .9); --topbar-text: #ece8e2;
    --tag-bg: #242c2e; --tag-text: #ece8e2; --tag-strong-text: #0f1a1c; --reason-bg: #1b2a2d; --avatar-bg: #3d3533; --avatar-text: #ece8e2;
    --status-new-bg: #3d3533; --status-new-text: #ece8e2; --ok-bg: #1d3532; --ok-text: #9fd0cb; --error-bg: #3d3533; --error-text: #f0d2a8;
    --cta-bg: #0b1214; --cta-text: #f1ebe5; --cta-btn-bg: #86c3c4; --cta-btn-text: #0f1a1c;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  background-image: var(--bg-image, none);
  color: var(--text);
  font: 15px/1.55 var(--font);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
h1, h2, h3 { font-family: var(--font-head); font-weight: var(--head-weight); line-height: 1.2; margin: 0 0 .4em; letter-spacing: var(--head-tracking, -0.01em); }
h1 { font-size: 1.9rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }
a { color: var(--primary); }
.muted { color: var(--muted); margin: 0; font-size: .9em; }
.hint { color: var(--muted); font-size: .85em; }
[hidden] { display: none !important; }

/* ---- Yläpalkki ---- */
.topbar {
  height: var(--topbar-h);
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 0 28px;
  background: var(--topbar-bg); color: var(--topbar-text);
  border-bottom: var(--topbar-border, 1px solid var(--border));
  position: sticky; top: 0; z-index: 5; backdrop-filter: blur(10px);
}
.brand { display: flex; align-items: center; gap: 9px; font-family: var(--font-head); font-weight: 500; font-size: 1.45rem; color: inherit; text-decoration: none; }
.brand-logo { flex: none; }
.brand-logo .pin { fill: var(--primary); }
.brand-logo .seal { fill: var(--accent); }
.brand-mark { display: grid; place-items: center; width: 34px; height: 34px; border-radius: var(--brand-radius, 9px); background: var(--accent); color: var(--brand-mark-text, #fff); font-family: Georgia, serif; font-size: 1.1rem; }
.brand-sub { font-family: var(--font); font-weight: 500; font-size: .75rem; padding: 2px 8px; border-radius: 99px; background: var(--tag-bg); color: var(--tag-text); }
.topbar nav { display: flex; gap: 6px; align-items: center; }
.topbar nav > a { color: inherit; text-decoration: none; padding: 8px 14px; border-radius: var(--btn-radius); font-weight: 500; }
.topbar nav > a:hover { background: var(--surface-2); }
.tab { border: 0; background: transparent; color: inherit; font: inherit; font-weight: 500; padding: 8px 14px; border-radius: var(--btn-radius); cursor: pointer; display: inline-flex; gap: 6px; align-items: center; opacity: .75; }
.tab:hover { opacity: 1; }
.tab.active { background: var(--tab-active-bg, var(--surface-2)); color: var(--tab-active-text, inherit); opacity: 1; }
.tab-quiet { font-size: .9em; }
.badge { min-width: 20px; height: 20px; padding: 0 6px; border-radius: 99px; background: var(--primary); color: var(--primary-text); font-size: .75rem; font-weight: 700; display: inline-grid; place-items: center; }

/* ---- Napit ja lomakkeet ---- */
.btn { border: 1.5px solid transparent; border-radius: var(--btn-radius); padding: 10px 18px; font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; gap: 8px; transition: filter .15s, transform .15s; }
.btn:hover { filter: brightness(1.08); transform: translateY(-1px); }
.btn-ghost:hover { border-color: var(--primary); filter: none; }
.btn:disabled { opacity: .5; cursor: wait; }
.btn-primary { background: var(--primary); color: var(--primary-text); box-shadow: var(--btn-shadow, none); }
.btn-ghost { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn-lg { padding: 14px 24px; font-size: 1.02rem; }
.btn-block { width: 100%; }
input, textarea, select { font: inherit; color: var(--text); background: var(--input-bg, var(--surface)); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px 12px; width: 100%; }
textarea { resize: vertical; }
input:focus, textarea:focus, select:focus { outline: 2px solid var(--primary); outline-offset: 1px; }
:focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; }
.eyebrow, .section-label { color: var(--accent); }
label { display: flex; flex-direction: column; gap: 5px; font-size: .9rem; font-weight: 500; }
label.check, .area-option { flex-direction: row; align-items: center; gap: 8px; font-weight: 400; }
label.check input, .area-option input { width: auto; }
.form { display: flex; flex-direction: column; gap: 14px; }
fieldset { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 14px 16px 16px; margin: 0; display: flex; flex-direction: column; gap: 12px; }
legend { font-weight: 600; padding: 0 6px; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.area-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 8px 16px; }
.form-error { color: var(--error-text); background: var(--error-bg); border-radius: var(--radius-sm); padding: 8px 12px; margin: 0; }
.form-ok { color: var(--ok-text); background: var(--ok-bg); border-radius: var(--radius-sm); padding: 8px 12px; margin: 0; }

/* ---- Paneelit ---- */
.panel { background: var(--surface); border: var(--panel-border, 1px solid var(--border)); border-radius: var(--radius); box-shadow: var(--shadow); display: flex; flex-direction: column; min-height: 0; overflow: hidden; }
.panel-head { padding: 18px 22px 14px; border-bottom: 1px solid var(--border); display: flex; flex-direction: column; gap: 6px; }
#conv-view .panel-head, .list-panel .panel-head { flex-direction: row; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 10px; }
.panel-head select { width: auto; flex: none; padding: 6px 10px; }
.empty { color: var(--muted); padding: 24px; margin: 0; text-align: center; }

.app-layout { flex: none; display: grid; grid-template-rows: minmax(0, 1fr); grid-template-columns: var(--chat-cols, minmax(0, 1.4fr) minmax(320px, 1fr)); gap: var(--gap); padding: var(--gap); height: calc(100vh - var(--topbar-h)); max-width: var(--max-w, 1400px); width: 100%; margin: 0 auto; }
.convs-layout { grid-template-columns: minmax(280px, 360px) minmax(0, 1fr); }
.auth-layout { flex: 1; display: flex; justify-content: center; align-items: flex-start; padding: 40px 20px; }
.auth-panel { padding: 32px; width: 100%; max-width: 440px; gap: 18px; overflow: visible; }
.auth-panel.wide { max-width: 820px; }

/* ---- Viestit ---- */
.messages { flex: 1; overflow-y: auto; padding: 20px 22px; display: flex; flex-direction: column; gap: 10px; background: var(--messages-bg, transparent); }
.bubble { max-width: 78%; padding: 10px 14px; border-radius: var(--bubble-radius); background: var(--theirs-bg); color: var(--theirs-text); align-self: flex-start; box-shadow: var(--bubble-shadow, none); border: var(--bubble-border, none); }
.bubble.mine { align-self: flex-end; background: var(--mine-bg); color: var(--mine-text); border-bottom-right-radius: var(--bubble-tail, 4px); }
.bubble.theirs { border-bottom-left-radius: var(--bubble-tail, 4px); }
.bubble.typing .bubble-text { opacity: .6; font-style: italic; }
.bubble.error { background: var(--error-bg); color: var(--error-text); }
.bubble-text { white-space: pre-wrap; }
.bubble-time { font-size: .72rem; opacity: .65; margin-top: 4px; text-align: right; }
.composer { display: flex; gap: 10px; padding: 14px 18px; border-top: 1px solid var(--border); background: var(--composer-bg, var(--surface)); align-items: flex-end; }
.composer textarea { min-height: 46px; max-height: 160px; }
.suggestions { display: flex; flex-wrap: wrap; gap: 8px; padding: 0 22px 14px; }
.chip { border: 1px solid var(--border); background: var(--chip-bg, var(--surface)); color: var(--text); border-radius: 99px; padding: 7px 13px; font: inherit; font-size: .85rem; cursor: pointer; }
.chip:hover { border-color: var(--primary); color: var(--primary); }

/* ---- Toimistokortit ---- */
.side-panel .panel-head .areas { display: flex; flex-wrap: wrap; gap: 6px; }
.firm-scroll { flex: 1; overflow-y: auto; background: var(--firm-list-bg, transparent); display: flex; flex-direction: column; }
.firm-section { padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.firm-section + .firm-section { border-top: 1px solid var(--border); }
.section-label { font-family: var(--font); font-size: .78rem; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); font-weight: 600; margin: 0; }
.list-toolbar { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
label.inline { flex-direction: row; align-items: center; gap: 8px; font-size: .85rem; color: var(--muted); }
label.inline select { width: auto; padding: 5px 8px; font-size: .85rem; }
.filters { border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); }
.filters summary { cursor: pointer; padding: 9px 12px; font-weight: 600; font-size: .9rem; display: flex; align-items: center; gap: 8px; }
.filters[open] summary { border-bottom: 1px solid var(--border); }
.filter-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; padding: 12px; }
.filter-grid label { font-size: .82rem; }
.filter-grid select { padding: 6px 8px; font-size: .85rem; }
.filter-grid fieldset { padding: 8px 10px 10px; gap: 6px; }
.filter-grid fieldset > div { display: flex; flex-direction: column; gap: 6px; }
.filter-grid legend { font-size: .8rem; }
.filter-grid .check { font-size: .84rem; }
.filter-grid #clear-filters { grid-column: 1 / -1; justify-self: start; }
.btn-small { padding: 6px 12px; font-size: .85rem; }
.firm-list { display: flex; flex-direction: column; gap: 14px; }
.firm-card.compact { gap: 8px; padding: 14px; }
.firm-card-title { min-width: 0; }
.firm-stats { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: .85rem; }
.link-btn { border: 0; background: none; padding: 0; font: inherit; color: inherit; cursor: pointer; display: inline-flex; gap: 5px; align-items: center; text-decoration: underline; text-decoration-color: var(--border); text-underline-offset: 3px; }
.link-btn:hover { text-decoration-color: currentColor; }
.stars { color: var(--star); letter-spacing: 1px; }
.stars-off { color: var(--border); }
.tag.tag-type { background: transparent; border: 1px solid var(--border); color: var(--text); }
.tag.tag-ok { background: var(--ok-bg); color: var(--ok-text); }
.reviews-list { display: flex; flex-direction: column; gap: 14px; max-height: 60vh; overflow-y: auto; }
.review { border-bottom: 1px solid var(--border); padding-bottom: 12px; display: flex; flex-direction: column; gap: 6px; }
.review p { margin: 0; }
.review-head { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; font-size: .9rem; }
.verified { font-size: .75rem; color: var(--ok-text); font-weight: 600; }
.review-reply { margin-left: 16px; padding: 8px 12px; background: var(--surface-2); border-radius: var(--radius-sm); font-size: .9rem; }
.reply-form { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.reply-form label { width: 100%; }
.review-box { margin: 0 18px 12px; padding: 12px 14px; border-radius: var(--radius-sm); background: var(--reason-bg, var(--surface-2)); border: 1px solid var(--border); font-size: .9rem; }
.review-box form { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.review-box textarea { min-height: 0; }
.star-input { display: flex; flex-direction: row-reverse; justify-content: flex-end; gap: 2px; }
.star-input label { cursor: pointer; font-size: 1.6rem; line-height: 1; color: var(--border); }
.star-input input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.star-input label:hover, .star-input label:hover ~ label, .star-input label:has(input:checked), .star-input label:has(input:checked) ~ label { color: var(--star); }
.star-input input:focus-visible + span { outline: 2px solid var(--primary); }
.dialog-body { padding: 26px; display: flex; flex-direction: column; gap: 12px; }
.dialog-title { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.dialog-title h2 { margin: 0; }
.stat-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.stat { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 14px; }
.stat strong { display: block; font-size: 1.5rem; font-family: var(--font-head); font-variant-numeric: tabular-nums; }
.stat > span { color: var(--muted); font-size: .85rem; }
.firm-card { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 16px; display: flex; flex-direction: column; gap: 10px; background: var(--card-bg, var(--surface)); box-shadow: var(--card-shadow, none); }
.firm-card-head { display: flex; gap: 12px; align-items: center; }
.firm-card h3 { margin: 0; }
.firm-avatar { flex: none; width: 42px; height: 42px; border-radius: var(--avatar-radius, 10px); background: var(--avatar-bg, var(--tag-bg)); color: var(--avatar-text, var(--tag-text)); display: grid; place-items: center; font-family: var(--font-head); font-weight: 700; font-size: 1.15rem; }
.reason { margin: 0; font-size: .9rem; padding: 10px 12px; background: var(--reason-bg, var(--surface-2)); border-left: 3px solid var(--accent); border-radius: 4px; }
.price { margin: 0; font-size: .85rem; color: var(--muted); }
.tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tag { font-size: .75rem; padding: 3px 9px; border-radius: 99px; background: var(--tag-bg); color: var(--tag-text); font-weight: 500; }
.tag-strong { background: var(--accent); color: var(--tag-strong-text, #fff); }
.mini-firm { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px 12px; display: flex; flex-direction: column; background: var(--surface); font-size: .9rem; }
.mini-firm span { color: var(--muted); font-size: .8rem; }

/* ---- Keskustelulista ---- */
.conv-list { overflow-y: auto; display: flex; flex-direction: column; }
.conv-item { text-align: left; border: 0; border-bottom: 1px solid var(--border); background: transparent; padding: 14px 18px; font: inherit; color: inherit; cursor: pointer; display: flex; flex-direction: column; gap: 4px; }
.conv-item:hover { background: var(--surface-2); }
.conv-item.active { background: var(--surface-2); box-shadow: inset 3px 0 0 var(--primary); }
.conv-item-top, .conv-item-meta { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.conv-item-meta { font-size: .78rem; color: var(--muted); }
.status { font-size: .75rem; font-weight: 600; padding: 2px 8px; border-radius: 99px; background: var(--tag-bg); color: var(--tag-text); }
.status-uusi { background: var(--status-new-bg); color: var(--status-new-text); }
.status-hyväksytty { background: var(--ok-bg); color: var(--ok-text); }
.status-suljettu { background: var(--surface-2); color: var(--muted); }
.case-summary { margin: 14px 22px 0; padding: 12px 14px; border-radius: var(--radius-sm); background: var(--reason-bg, var(--surface-2)); border: 1px dashed var(--border); display: flex; flex-direction: column; gap: 6px; font-size: .9rem; }
.case-summary p { margin: 0; }
.case-summary-label { font-size: .75rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; }

/* ---- Dialogi ---- */
.dialog { border: 0; border-radius: var(--radius); padding: 0; width: min(560px, 94vw); background: var(--surface); color: var(--text); box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.dialog::backdrop { background: rgba(15, 20, 30, .45); }
.dialog form { padding: 26px; display: flex; flex-direction: column; gap: 14px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; }

/* ---- Etusivu ---- */
.page-home main { max-width: 1160px; margin: 0 auto; padding: 0 24px 60px; width: 100%; }
.hero { display: grid; grid-template-columns: 1.1fr .9fr; gap: 48px; align-items: center; padding: 64px 0 48px; }
.hero h1 { font-size: clamp(2rem, 4vw, 3.1rem); }
.eyebrow { text-transform: uppercase; letter-spacing: .12em; font-size: .78rem; font-weight: 700; color: var(--accent); margin: 0 0 12px; }
.lead { font-size: 1.1rem; color: var(--muted); max-width: 560px; }
.hero-actions { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 24px; }
.hero-card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); border: var(--panel-border, 1px solid var(--border)); padding: 22px; display: flex; flex-direction: column; gap: 10px; }
.steps { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--gap); }
.step { background: var(--surface); border: var(--panel-border, 1px solid var(--border)); border-radius: var(--radius); padding: 24px; box-shadow: var(--shadow); }
.step p { color: var(--muted); margin: 0; }
.step-no { display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 99px; background: var(--tag-bg); color: var(--tag-text); font-weight: 700; margin-bottom: 12px; }
.for-firms { margin-top: 40px; padding: 32px; border-radius: var(--radius); background: var(--cta-bg, var(--primary)); color: var(--cta-text, var(--primary-text)); display: flex; justify-content: space-between; align-items: center; gap: 24px; }
.for-firms p { margin: 0; opacity: .85; }
.for-firms .btn-primary { background: var(--cta-btn-bg, #fff); color: var(--cta-btn-text, var(--primary)); }
.footer { text-align: center; color: var(--muted); font-size: .8rem; padding: 20px; }

/* ---- Mobiili ---- */
@media (max-width: 860px) {
  .app-layout, .convs-layout { grid-template-columns: 1fr; grid-template-rows: auto; height: auto; padding: 12px; }
  .side-panel { max-height: 85vh; }
  .filter-grid { grid-template-columns: 1fr; }
  .chat-panel { height: 75vh; }
  .hero, .steps { grid-template-columns: 1fr; }
  .row { grid-template-columns: 1fr; }
  .for-firms { flex-direction: column; align-items: flex-start; }
  .topbar { padding: 0 14px; }
  .brand-sub { display: none; }
}
.side-panel { order: var(--side-order, 0); }
.sub-legend { font-size: .9rem; font-weight: 500; margin-bottom: 6px; }
.check-col { display: flex; flex-direction: column; gap: 6px; }

@media (max-width: 600px) {
  .topbar { height: auto; flex-wrap: wrap; padding-block: 10px; gap: 6px; }
  .topbar nav { width: 100%; overflow-x: auto; }
  .tab, .topbar nav > a { padding: 6px 10px; font-size: .9rem; white-space: nowrap; }
  .brand { font-size: 1.25rem; }
  .bubble { max-width: 90%; }
}

/* ---- Kuvaliitteet ---- */
.attach-btn { padding: 0; width: 46px; height: 46px; flex: none; color: var(--muted); }
.attach-btn:hover { color: var(--primary); }
.attach-strip { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 10px 18px 0; border-top: 1px solid var(--border); background: var(--composer-bg, var(--surface)); }
.attach-strip + .composer { border-top: 0; }
.attach-chip { position: relative; margin: 0; width: 64px; height: 64px; border-radius: var(--radius-sm); overflow: hidden; border: 1px solid var(--border); }
.attach-chip img { width: 100%; height: 100%; object-fit: cover; display: block; }
.attach-chip button { position: absolute; top: 3px; right: 3px; width: 22px; height: 22px; border-radius: 99px; border: 0; background: rgba(24, 36, 42, .75); color: #fff; cursor: pointer; font-size: 15px; line-height: 1; }
.bubble-images { display: flex; flex-wrap: wrap; gap: 6px; margin: 2px 0 6px; }
.bubble-images a, .bubble-images > img { display: block; }
.bubble-images img { max-width: 240px; max-height: 200px; width: auto; height: auto; border-radius: calc(var(--bubble-radius) - 6px); display: block; object-fit: cover; }
@media (max-width: 600px) { .bubble-images img { max-width: 100%; } }

/* ---- Tekstisivut (tietosuoja) ---- */
.prose { gap: 12px; }
.prose h2 { font-size: 1.3rem; margin-top: 10px; }
.prose p, .prose li { max-width: 68ch; }
.prose ul { margin: 0; padding-left: 1.2em; display: flex; flex-direction: column; gap: 6px; }
