/* Erede datahuone – käyttöliittymä
   Hillitty, ammattimainen ilme: Ereden navy, niukat korostukset, tiiviit muodot ja selkeä typografia (Geist).
   Kultaa käytetään vain logossa. */

:root {
  --navy: #0F2A44;
  --navy-700: #163757;
  --navy-600: #1E4670;
  --navy-50: #EEF2F7;
  --gold: #C6A15B;
  --gold-50: #FAF5EA;

  --bg: #F6F7F9;
  --panel: #FFFFFF;
  --surface: #FFFFFF;
  --surface-2: #F8F9FB;
  --border: #E4E7EC;
  --border-strong: #D0D5DD;
  --text: #0E1525;
  --text-2: #3A4253;
  --muted: #6B7383;
  --subtle: #9AA1AE;

  --ok: #067647;      --ok-bg: #ECFDF3;      --ok-border: #C6F1D6;
  --warn: #B54708;    --warn-bg: #FFFAEB;    --warn-border: #FBE3A6;
  --danger: #B42318;  --danger-bg: #FEF3F2;  --danger-border: #FBD3CF;

  --radius: 6px;
  --radius-lg: 8px;
  --shadow-sm: none;
  --shadow-md: 0 2px 6px rgba(14, 21, 37, 0.06);
  --shadow-lg: 0 12px 32px -8px rgba(14, 21, 37, 0.18), 0 2px 6px rgba(14, 21, 37, 0.06);
  --ring: 0 0 0 3px rgba(30, 70, 112, 0.18);

  --font: "Geist", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, monospace;
  --sidebar-w: 240px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--panel); color: var(--text); font: 14px/1.5 var(--font); -webkit-font-smoothing: antialiased; font-feature-settings: "ss01"; }
a { color: var(--navy-600); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 2px; }
h1, h2, h3 { color: var(--text); font-weight: 600; letter-spacing: -0.015em; line-height: 1.3; }
h1 { font-size: 22px; margin: 0 0 4px; letter-spacing: -0.02em; font-weight: 600; }
h2 { font-size: 15px; margin: 32px 0 12px; letter-spacing: -0.01em; }
h3 { font-size: 14px; }
p { margin: 0 0 12px; }
code { font-family: var(--mono); font-size: 12px; background: var(--navy-50); padding: 1px 6px; border-radius: 4px; color: var(--navy); }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.ic { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
:focus-visible { outline: none; box-shadow: var(--ring); border-radius: 4px; }

/* ---------- Sovelluskehys ---------- */

.app { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); min-height: 100vh; }
.sidebar { position: sticky; top: 0; height: 100vh; background: var(--bg); color: var(--text); display: flex; flex-direction: column; padding: 18px 12px 14px; gap: 6px; overflow-y: auto; border-right: 1px solid var(--border); }
.logo { display: flex; align-items: center; gap: 10px; color: inherit; text-decoration: none; padding: 2px 8px 16px; }
.logo:hover { text-decoration: none; }
.logo-mark { width: 30px; height: 30px; border-radius: 5px; background: var(--navy); color: var(--gold); display: grid; place-items: center; font-weight: 700; font-size: 15px; flex: none; }
.logo-text { display: flex; flex-direction: column; line-height: 1.15; }
.logo-word { font-weight: 600; letter-spacing: 0.24em; font-size: 13px; color: var(--navy); }
.logo-sub { font-size: 11.5px; color: var(--muted); margin-top: 2px; }
.nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.nav-label { font-size: 10.5px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; color: var(--subtle); padding: 18px 10px 6px; }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: var(--radius); color: var(--text-2); font-size: 13.5px; font-weight: 500; text-decoration: none; position: relative; transition: background-color 0.12s, color 0.12s; }
.nav-item:hover { background: rgba(14, 21, 37, 0.045); color: var(--text); text-decoration: none; }
.nav-item.active { background: #E9EDF3; color: var(--navy); }
.nav-item .ic { color: var(--muted); }
.nav-item.active .ic { color: var(--navy-600); }
.nav-button { width: 100%; background: none; border: 0; font: inherit; font-weight: 500; cursor: pointer; text-align: left; }
.sidebar-foot { border-top: 1px solid var(--border); padding-top: 12px; display: flex; flex-direction: column; gap: 6px; }
.sidebar-foot form { margin: 0; }
.me { display: flex; align-items: center; gap: 10px; padding: 6px 8px; min-width: 0; }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--navy); color: #fff; display: grid; place-items: center; font-size: 12px; font-weight: 600; flex: none; }
.me-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.3; }
.me-name { font-size: 13px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.me-mail { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.main { min-width: 0; display: flex; flex-direction: column; background: var(--panel); min-height: 100vh; }
.mobilebar { display: none; }
.scrim { display: none; }
.page { width: 100%; max-width: 1240px; margin: 0 auto; padding: 28px 40px 72px; }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head h1 + p, .page-head .muted { font-size: 14px; }
.back { display: inline-flex; align-items: center; gap: 4px; font-size: 12.5px; color: var(--muted); margin-bottom: 8px; }
.back .ic { width: 16px; height: 16px; }

/* ---------- Kortit ---------- */

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 20px; }
.card > h2:first-child { margin-top: 0; }
.empty { text-align: center; padding: 40px 24px; }
.empty h2 { margin: 0 0 4px; font-size: 14.5px; }
.empty .ic-big { width: 36px; height: 36px; border-radius: var(--radius); background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); display: inline-grid; place-items: center; margin-bottom: 12px; }
.detail-grid { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 24px; align-items: start; }

/* ---------- Taulukot ---------- */

table { width: 100%; border-collapse: separate; border-spacing: 0; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; }
th, td { text-align: left; padding: 10px 16px; border-bottom: 1px solid var(--border); font-size: 13.5px; vertical-align: middle; }
th { font-weight: 600; color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; background: var(--surface-2); white-space: nowrap; padding-top: 9px; padding-bottom: 9px; }
tr:last-child td { border-bottom: 0; }
tbody tr { transition: background-color 0.12s; }
tbody tr:hover { background: #FAFBFC; }
td a { color: var(--text); font-weight: 500; }
td a:hover { color: var(--navy-600); }
.table-scroll { overflow-x: auto; border-radius: var(--radius-lg); }

/* ---------- Painikkeet ---------- */

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; height: 34px; padding: 0 13px; border-radius: var(--radius); border: 1px solid var(--border-strong); background: var(--surface); color: var(--text-2); font: 500 13.5px var(--font); text-decoration: none; cursor: pointer; white-space: nowrap; transition: background-color 0.12s, border-color 0.12s, box-shadow 0.12s; }
.btn:hover { background: var(--surface-2); border-color: var(--border-strong); text-decoration: none; color: var(--text); }
.btn .ic { width: 16px; height: 16px; }
.btn-primary { background: var(--navy); border-color: var(--navy); color: #fff; }
.btn-primary:hover { background: var(--navy-700); border-color: var(--navy-700); color: #fff; }
.btn-danger { color: var(--danger); border-color: var(--danger-border); }
.btn-danger:hover { background: var(--danger-bg); color: var(--danger); border-color: var(--danger-border); }
.btn-ghost { border-color: transparent; box-shadow: none; background: transparent; }
.btn-ghost:hover { background: rgba(16, 24, 40, 0.05); border-color: transparent; }
.btn-block { width: 100%; height: 38px; }
.btn-small { height: 28px; padding: 0 9px; font-size: 12.5px; gap: 5px; }
.icon-btn { width: 34px; height: 34px; display: inline-grid; place-items: center; border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface); color: var(--text-2); cursor: pointer; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.actions form { margin: 0; }

/* ---------- Merkinnät ---------- */

.badge { display: inline-flex; align-items: center; gap: 5px; padding: 1px 7px; border-radius: 4px; font-size: 11.5px; font-weight: 600; white-space: nowrap; border: 1px solid transparent; line-height: 18px; letter-spacing: 0.01em; }
.badge-ok { background: var(--ok-bg); color: var(--ok); border-color: var(--ok-border); }
.badge-warn { background: var(--warn-bg); color: var(--warn); border-color: var(--warn-border); }
.badge-danger { background: var(--danger-bg); color: var(--danger); border-color: var(--danger-border); }
.badge-navy { background: #F0F2F5; color: var(--text-2); border-color: var(--border); }

/* ---------- Lomakkeet ---------- */

.field { margin-bottom: 16px; }
.field label { display: block; font-size: 13px; font-weight: 500; color: var(--text-2); margin-bottom: 5px; }
.field input[type=text], .field input[type=email], .field input[type=password], .field input[type=search], .field input[type=date], .field select, .field textarea,
.toolbar input[type=search], .date-input {
  width: 100%; height: 36px; padding: 0 11px; border: 1px solid var(--border-strong); border-radius: var(--radius); font: 13.5px var(--font); background: var(--surface); color: var(--text); transition: border-color 0.12s, box-shadow 0.12s;
}
.field textarea { height: auto; padding: 10px 12px; line-height: 1.55; resize: vertical; }
.field select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23667085' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; padding-right: 34px; }
.field input:focus, .field select:focus, .field textarea:focus, .toolbar input:focus, .date-input:focus { outline: none; border-color: var(--navy-600); box-shadow: var(--ring); }
.field input:disabled { background: var(--surface-2); color: var(--muted); }
.field input::placeholder, .field textarea::placeholder, .toolbar input::placeholder { color: var(--subtle); }
.field .help { font-size: 13px; color: var(--muted); margin-top: 6px; }
.field .help ul { margin: 4px 0 0; padding-left: 18px; }
.field .error, .errorlist { color: var(--danger); font-size: 13px; margin: 6px 0 0; padding: 0; list-style: none; }
.errorlist.nonfield { background: var(--danger-bg); border: 1px solid var(--danger-border); border-radius: var(--radius); padding: 10px 12px; margin-bottom: 16px; }
.checkbox { display: flex; gap: 10px; align-items: flex-start; }
.checkbox input, input[type=checkbox] { width: 16px; height: 16px; margin: 2px 0 0; accent-color: var(--navy); flex: none; }
.checkbox label { margin: 0; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 20px; }
.code-input { height: 52px !important; font-size: 24px !important; letter-spacing: 0.5em; text-align: center; font-variant-numeric: tabular-nums; padding-left: 0.5em !important; }

/* ---------- Ilmoitukset ---------- */

.messages { list-style: none; margin: 0 0 20px; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.messages li { padding: 10px 14px; border-radius: var(--radius); font-size: 13.5px; background: var(--navy-50); color: var(--navy); border: 1px solid #D5DEEA; border-left-width: 3px; }
.messages .success { background: var(--ok-bg); color: var(--ok); border-color: var(--ok-border); }
.messages .error { background: var(--danger-bg); color: var(--danger); border-color: var(--danger-border); }

/* ---------- Työkalurivi, välilehdet, sivutus ---------- */

.toolbar { display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; align-items: center; }
.toolbar input[type=search] { width: 320px; max-width: 100%; padding-left: 36px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2398A2B3' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cpath d='m21 21-4.3-4.3'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: 12px center; }
.toolbar label { color: var(--muted); }
.date-input { width: auto; }
.tabs { display: inline-flex; gap: 0; background: var(--surface); padding: 0; border: 1px solid var(--border-strong); border-radius: var(--radius); overflow: hidden; }
.tabs a { padding: 6px 12px; font-size: 12.5px; font-weight: 500; text-decoration: none; color: var(--muted); border-right: 1px solid var(--border); }
.tabs a:last-child { border-right: 0; }
.tabs a:hover { color: var(--text); }
.tabs a.active { background: #E9EDF3; color: var(--navy); }
.pagination { margin-top: 16px; display: flex; gap: 12px; align-items: center; font-size: 14px; }
.room-tabs { display: flex; gap: 22px; border-bottom: 1px solid var(--border); margin-bottom: 22px; }
.room-tabs a { display: inline-flex; align-items: center; gap: 7px; padding: 0 1px 11px; text-decoration: none; color: var(--muted); font-size: 13.5px; font-weight: 500; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.room-tabs a:hover { color: var(--text); }
.room-tabs a.active { color: var(--navy); border-bottom-color: var(--navy); }
.room-tabs .ic { width: 16px; height: 16px; }
.room-tabs .count { display: inline-grid; place-items: center; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 4px; background: var(--navy); color: #fff; font-size: 11px; font-weight: 600; font-variant-numeric: tabular-nums; }

/* ---------- Kirjautumissivut ---------- */

.auth { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); min-height: 100vh; }
.auth-side { background: var(--navy); color: #fff; padding: 40px 48px; display: flex; flex-direction: column; justify-content: space-between; position: relative; overflow: hidden; }
.logo-light .logo-word { color: #fff; }
.logo-light .logo-sub { color: rgba(255, 255, 255, 0.55); }
.logo-light .logo-mark { background: var(--gold); color: var(--navy); }
.auth-pitch h2 { color: #fff; font-size: 24px; line-height: 1.25; margin: 0 0 24px; max-width: 380px; letter-spacing: -0.02em; font-weight: 600; }
.auth-pitch ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 14px; }
.auth-pitch li { display: flex; align-items: center; gap: 12px; color: rgba(255, 255, 255, 0.8); font-size: 14px; }
.auth-pitch .ic { color: rgba(255, 255, 255, 0.6); width: 18px; height: 18px; }
.auth-foot { color: rgba(255, 255, 255, 0.4); font-size: 12px; margin: 0; }
.auth-main { display: flex; align-items: center; justify-content: center; padding: 40px 24px; }
.auth-card { width: 100%; max-width: 400px; }
.auth-card h1 { font-size: 22px; margin-bottom: 4px; }
.auth-card .lead { color: var(--muted); font-size: 14px; margin: 0 0 28px; }
.auth-logo-mobile { display: none; color: var(--navy); padding: 0 0 28px; }
.qr { display: flex; justify-content: center; margin: 12px 0; padding: 16px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); }
.qr svg { width: 180px; height: 180px; }
.secret { font-family: var(--mono); font-size: 13px; background: var(--surface); border: 1px dashed var(--border-strong); padding: 10px; border-radius: var(--radius); text-align: center; word-break: break-all; color: var(--text-2); }
.steps { padding-left: 20px; font-size: 14px; color: var(--text-2); margin: 0 0 16px; }
.steps li { margin-bottom: 6px; }

/* ---------- Datahuoneet ---------- */

.room-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.room-card { display: flex; flex-direction: column; gap: 8px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 16px 18px; text-decoration: none; color: inherit; transition: border-color 0.12s; }
.room-card:hover { text-decoration: none; border-color: var(--navy-600); }
.room-card-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.room-icon { width: 32px; height: 32px; border-radius: var(--radius); background: var(--surface-2); color: var(--navy-600); border: 1px solid var(--border); display: grid; place-items: center; }
.room-card-name { font-size: 15px; font-weight: 600; color: var(--text); letter-spacing: -0.01em; }
.room-card p { margin: 0; }
.room-card-foot { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 13px; margin-top: auto; padding-top: 10px; border-top: 1px solid var(--border); }
.room-card-foot .ic { width: 15px; height: 15px; }

.room-layout { display: grid; grid-template-columns: 260px minmax(0, 1fr); gap: 24px; align-items: start; }
.folder-tree { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 6px; position: sticky; top: 16px; max-height: calc(100vh - 32px); overflow-y: auto; }
.tree-title { font-size: 12px; font-weight: 500; color: var(--muted); padding: 8px 10px 6px; }
.tree-item { display: flex; align-items: center; gap: 8px; padding: 6px 10px 6px calc(10px + var(--depth, 0) * 16px); font-size: 13px; color: var(--text-2); text-decoration: none; border-radius: 4px; }
.tree-item:hover { background: var(--surface-2); text-decoration: none; color: var(--text); }
.tree-item.active { background: #E9EDF3; color: var(--navy); font-weight: 600; }
.tree-item .ic { width: 16px; height: 16px; color: var(--subtle); }
.tree-item.active .ic { color: var(--navy-600); }
.tree-item span:last-child { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tree-new { display: flex; gap: 6px; padding: 8px 6px 4px; border-top: 1px solid var(--border); margin-top: 8px; }
.tree-new input { flex: 1; min-width: 0; height: 32px; padding: 0 10px; border: 1px solid var(--border-strong); border-radius: 6px; font: 13px var(--font); }
.tree-new input:focus { outline: none; border-color: var(--navy-600); box-shadow: var(--ring); }
.tree-new .btn { height: 32px; width: 32px; padding: 0; }
.num { color: var(--subtle); font-variant-numeric: tabular-nums; font-weight: 500; }
.crumbs { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 13px; margin-bottom: 6px; flex-wrap: wrap; }
.crumbs a { color: var(--muted); }
.crumbs .sep { color: var(--subtle); }
.folder-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 20px; }
.folder-head h2 { margin: 0; font-size: 20px; }
.subfolders { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 8px; margin-bottom: 20px; }
.subfolder { display: flex; gap: 10px; align-items: center; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 12px; text-decoration: none; color: var(--text); font-size: 13.5px; font-weight: 500; transition: border-color 0.12s; }
.subfolder:hover { text-decoration: none; border-color: var(--navy-600); }
.subfolder .room-icon { width: 30px; height: 30px; }
.subfolder .small { font-weight: 400; }
.dropzone { display: flex; align-items: center; gap: 14px; border: 1px dashed var(--border-strong); border-radius: var(--radius-lg); background: var(--surface-2); padding: 14px 16px; margin-bottom: 18px; transition: border-color 0.12s, background-color 0.12s; }
.dropzone .room-icon { flex: none; }
.dropzone.over { border-color: var(--navy-600); background: var(--navy-50); }
.link { color: var(--navy-600); font-weight: 500; cursor: pointer; }
.link:hover { text-decoration: underline; }
.file-cell { display: flex; align-items: center; gap: 12px; min-width: 0; }
.ext { display: inline-grid; place-items: center; width: 30px; height: 34px; flex: none; border-radius: 4px; font-size: 8.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.03em; background: var(--surface); color: var(--muted); border: 1px solid var(--border-strong); position: relative; }
.ext-pdf { color: #B42318; border-color: #F0C9C4; }
.ext-doc, .ext-docx, .ext-odt, .ext-rtf, .ext-txt { color: #1D4F91; border-color: #C9D7EA; }
.ext-xls, .ext-xlsx, .ext-xlsm, .ext-csv, .ext-ods { color: #1E6B45; border-color: #C5DECF; }
.ext-ppt, .ext-pptx, .ext-odp { color: #A2471C; border-color: #E8CDBE; }
.ext-jpg, .ext-jpeg, .ext-png { color: #5B4A9E; border-color: #D6D1EA; }
.file-name { display: block; font-weight: 500; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-meta { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin-top: 2px; }
.doc-table { table-layout: fixed; overflow: visible; }
.doc-table thead th:first-child { border-top-left-radius: var(--radius-lg); }
.doc-table thead th:last-child { border-top-right-radius: var(--radius-lg); }
.doc-table tbody tr:last-child td:first-child { border-bottom-left-radius: var(--radius-lg); }
.doc-table tbody tr:last-child td:last-child { border-bottom-right-radius: var(--radius-lg); }
.doc-table td { overflow: hidden; }
.doc-table td:last-child { overflow: visible; }
.admin-menu { position: relative; display: inline-block; }
.admin-menu summary { list-style: none; }
.admin-menu summary::-webkit-details-marker { display: none; }
.admin-menu-body { position: absolute; right: 0; top: calc(100% + 6px); width: 280px; z-index: 20; box-shadow: var(--shadow-lg); padding: 6px; text-align: left; }
.admin-menu-body.card { padding: 16px; }
.menu-link { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; background: none; border: 0; padding: 8px 10px; font: 14px var(--font); color: var(--text-2); text-decoration: none; cursor: pointer; border-radius: 6px; }
.menu-link:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.menu-link .ic { width: 16px; height: 16px; color: var(--muted); }
.menu-link.danger, .menu-link.danger .ic { color: var(--danger); }
.menu-link.danger:hover { background: var(--danger-bg); }
.menu-sep { height: 1px; background: var(--border); margin: 4px 0; }
.admin-menu-body form { margin: 0; }
.perm-table td, .perm-table th { padding: 10px 16px; }
.perm-table .center { text-align: center; width: 100px; }
.perm-table th label { display: inline-flex; gap: 6px; align-items: center; cursor: pointer; }

/* ---------- Viestit ---------- */

.unread-dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--navy-600); margin-right: 8px; vertical-align: middle; }
.thread-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.thread-head h2 { font-size: 20px; }
.messages-list { display: flex; flex-direction: column; gap: 14px; }
.msg { display: flex; gap: 12px; max-width: 760px; }
.msg .avatar { background: var(--navy-50); color: var(--navy); width: 34px; height: 34px; }
.msg-erede .avatar { background: var(--navy); color: #fff; }
.msg-bubble { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 10px 14px; min-width: 0; }
.msg-own { align-self: flex-end; flex-direction: row-reverse; }
.msg-own .msg-bubble { background: var(--surface-2); border-color: var(--border); }
.msg-meta { font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.msg-meta strong { color: var(--text); font-weight: 600; }
.msg-body { overflow-wrap: anywhere; color: var(--text-2); }

/* ---------- Raportit ---------- */

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 8px; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 14px 16px; }
.kpi-label { font-size: 11px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; }
.kpi-value { font-size: 24px; font-weight: 600; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; color: var(--text); line-height: 1.2; margin-top: 6px; }
.bar { height: 4px; background: #EAECF0; border-radius: 2px; margin-top: 6px; width: 96px; overflow: hidden; }
.bar span { display: block; height: 100%; background: var(--navy-600); border-radius: 2px; }

/* ---------- PDF-katselin ---------- */

.viewer { display: flex; flex-direction: column; height: 100vh; background: #E7E9EE; }
.viewer-bar { display: flex; align-items: center; gap: 16px; padding: 10px 16px; background: var(--navy); color: #fff; }
.viewer-back { color: #fff; display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: var(--radius); }
.viewer-back:hover { background: rgba(255, 255, 255, 0.1); }
.viewer-title { flex: 1; min-width: 0; }
.viewer-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.viewer-sub { font-size: 12px; color: rgba(255, 255, 255, 0.6); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.viewer-tools { display: flex; align-items: center; gap: 6px; font-size: 13px; }
.viewer-pages { color: rgba(255, 255, 255, 0.7); margin-right: 8px; }
.viewer-zoom { min-width: 48px; text-align: center; font-variant-numeric: tabular-nums; }
.vbtn { background: rgba(255, 255, 255, 0.08); color: #fff; border: 1px solid rgba(255, 255, 255, 0.16); border-radius: var(--radius); min-width: 34px; height: 34px; font: 500 13px var(--font); cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.vbtn:hover { background: rgba(255, 255, 255, 0.16); text-decoration: none; }
.vbtn .ic { width: 16px; height: 16px; }
.vbtn-text { padding: 0 12px; }
.vbtn-primary { background: #fff; border-color: #fff; color: var(--navy); }
.vbtn-primary:hover { background: #D1AE6C; }
.viewer-pages-wrap { flex: 1; overflow: auto; padding: 24px 16px; display: flex; flex-direction: column; align-items: center; gap: 16px; user-select: none; -webkit-user-select: none; }
.viewer-page { background: #fff; box-shadow: var(--shadow-md); border-radius: 2px; flex: none; }
.viewer-page canvas { display: block; }
.viewer-error { background: #fff; padding: 24px; border-radius: var(--radius-lg); }
@media print { .viewer { display: none; } }

/* ---------- Mobiili ---------- */

@media (max-width: 1280px) {
  .page { padding: 32px 32px 72px; }
  .room-layout { grid-template-columns: 220px minmax(0, 1fr); gap: 20px; }
  .hide-narrow { display: none; }
}
@media (max-width: 1180px) {
  .room-layout { grid-template-columns: minmax(0, 1fr); }
  .folder-tree { position: static; max-height: 280px; }
}
@media (max-width: 1100px) {
  .detail-grid { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; width: var(--sidebar-w); z-index: 50; transform: translateX(-100%); transition: transform 0.2s ease; }
  .menu-open .sidebar { transform: none; box-shadow: var(--shadow-lg); background: var(--surface); }
  .main { min-height: 100vh; }
  .scrim { display: block; position: fixed; inset: 0; background: rgba(16, 24, 40, 0.4); z-index: 40; }
  .scrim[hidden] { display: none; }
  .mobilebar { display: flex; align-items: center; gap: 12px; padding: 10px 16px; background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 30; }
  .logo-small { padding: 0; color: var(--navy); }
  .logo-small .logo-mark { width: 28px; height: 28px; font-size: 14px; }
  .page { padding: 20px 16px 60px; }
  .room-layout { grid-template-columns: minmax(0, 1fr); }
  .folder-tree { position: static; max-height: 240px; }
  .auth { grid-template-columns: 1fr; }
  .auth-side { display: none; }
  .auth-logo-mobile { display: flex; }
}
@media (max-width: 640px) {
  .form-grid { grid-template-columns: 1fr; }
  .hide-mobile { display: none; }
  th, td { padding: 10px 12px; }
  .viewer-pages, .viewer-zoom, #zoom-in, #zoom-out { display: none; }
  .dropzone .room-icon { display: none; }
}

/* Aineistopyynnöt */
.room-tabs .count-muted { background: var(--navy-50); color: var(--navy-600); }
.progress-card { margin-bottom: 20px; padding: 18px 20px; }
.progress-top { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.progress { height: 4px; background: #EAECF0; border-radius: 2px; overflow: hidden; }
.progress span { display: block; height: 100%; background: var(--navy); border-radius: 2px; }
.text-danger { color: var(--danger); font-weight: 500; }
.facts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 24px; margin: 0; }
.facts dt { font-size: 12px; color: var(--muted); font-weight: 500; margin-bottom: 2px; }
.facts dd { margin: 0; font-size: 14px; }
.notice { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: var(--radius); font-size: 13px; margin-top: 12px; }
.notice .ic { width: 18px; height: 18px; flex: none; margin-top: 1px; }
.notice-warn { background: var(--warn-bg); color: var(--warn); border: 1px solid var(--warn-border); }
.mini-select { height: 32px; padding: 0 28px 0 10px; border: 1px solid var(--border-strong); border-radius: 6px; font: 13px var(--font); background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%23667085' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") no-repeat right 8px center; appearance: none; max-width: 240px; }
.field input[type=date] { height: 40px; }
.field input[type=file] { font: 13px var(--font); }

/* Toimitukset */
.room-tabs .count-danger { background: var(--danger); color: #fff; }
.cat-title { font-size: 13px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; margin: 20px 0 8px; }
.chips { display: flex; gap: 4px; flex-wrap: wrap; }
.chip { display: inline-grid; place-items: center; min-width: 36px; height: 22px; padding: 0 5px; border-radius: 3px; font-size: 10.5px; font-weight: 600; text-decoration: none; border: 1px solid transparent; font-variant-numeric: tabular-nums; }
.chip:hover { text-decoration: none; filter: brightness(0.96); }
.chip-ok { background: var(--ok-bg); color: var(--ok); border-color: var(--ok-border); }
.chip-late { background: var(--danger-bg); color: var(--danger); border-color: var(--danger-border); }
.chip-open { background: var(--warn-bg); color: var(--warn); border-color: var(--warn-border); }
.summary-title { display: flex; align-items: center; gap: 8px; font-weight: 600; cursor: pointer; list-style: none; }
.summary-title::-webkit-details-marker { display: none; }
.period { margin-bottom: 12px; scroll-margin-top: 24px; }
.period:target { border-color: var(--navy-600); box-shadow: var(--ring); }
.period-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.period-files { display: flex; flex-direction: column; gap: 10px; margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--border); }
.text-warn { color: var(--warn); font-weight: 500; }
.explanation { margin-top: 12px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 12px; }
.explanation-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 4px; }

.link-box { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--border); }
.pick-list { display: flex; flex-direction: column; gap: 2px; max-height: 280px; overflow-y: auto; border: 1px solid var(--border); border-radius: var(--radius); padding: 4px; }
.pick { display: flex; align-items: center; gap: 10px; padding: 6px 8px; border-radius: 6px; cursor: pointer; min-width: 0; }
.pick:hover { background: var(--surface-2); }
.pick .ext { width: 28px; height: 32px; font-size: 8.5px; }
.pick > span:last-child { display: flex; flex-direction: column; min-width: 0; }
.plain-list { list-style: none; margin: 0 0 20px; padding: 0; display: flex; flex-direction: column; gap: 6px; font-size: 14px; }
.plain-list li { display: flex; align-items: center; gap: 8px; }
.plain-list .ic { width: 16px; height: 16px; color: var(--muted); }
.link-badge { display: inline-flex; align-items: center; gap: 4px; font-size: 11.5px; color: var(--text-2); background: #F0F2F5; border-radius: 4px; padding: 1px 6px; max-width: 260px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.link-badge .ic { width: 12px; height: 12px; flex: none; }

.room-tabs { overflow-x: auto; scrollbar-width: none; }
.room-tabs::-webkit-scrollbar { display: none; }
.room-tabs a { white-space: nowrap; flex: none; }

/* Ostajatahot ja vaiheet */
.stage-steps { list-style: none; margin: 16px 0; padding: 0; display: flex; flex-direction: column; gap: 0; }
.stage-step { display: flex; gap: 14px; align-items: center; padding: 12px 0; border-top: 1px solid var(--border); }
.stage-step:first-child { border-top: 0; }
.stage-body { flex: 1; min-width: 0; }
.stage-dot { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; font-weight: 600; font-size: 13px; background: #EAECF0; color: var(--muted); flex: none; }
.stage-step.done .stage-dot { background: var(--navy); color: #fff; }
.stage-step.current .stage-dot { box-shadow: 0 0 0 3px #fff, 0 0 0 4px var(--navy); }
.stage-card { display: flex; gap: 14px; align-items: flex-start; margin-bottom: 12px; padding: 16px; }
.template-card { display: block; margin-bottom: 12px; color: inherit; text-decoration: none; }
.template-card:hover { text-decoration: none; border-color: var(--border-strong); box-shadow: var(--shadow-md); }
.mini-steps { margin: 0; padding-left: 18px; font-size: 13px; color: var(--text-2); }

.access-card.locked { border-color: var(--danger-border); background: #FFFBFA; }

.nav-count { margin-left: auto; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 4px; background: var(--navy); color: #fff; font-size: 11px; font-weight: 600; display: inline-grid; place-items: center; font-variant-numeric: tabular-nums; }
.route-row { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-top: 10px; padding-top: 8px; border-top: 1px dashed var(--border); }
.route-row form { margin: 0; }

.history-row { display: flex; gap: 12px; align-items: baseline; padding: 8px 0; border-bottom: 1px solid var(--border); }
.history-row:last-of-type { border-bottom: 0; }

.move-check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
.move-bar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 10px; }

/* Yleisilme: hienosäätö */
.room-layout > * { min-width: 0; }
.card, .room-card, .subfolder, .kpi, .folder-tree, table { border-color: var(--border); }
.page-head h1 + p, .page-head .muted { color: var(--muted); }
::selection { background: rgba(198, 161, 91, 0.28); }
* { scrollbar-width: thin; scrollbar-color: #D3D7DF transparent; }

/* Poistetut tiedostot (vain ylläpitäjä) */
.deleted-box { margin-top: 20px; }
.deleted-box > summary { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); list-style: none; }
.deleted-box > summary::-webkit-details-marker { display: none; }
.deleted-box > summary .ic { width: 15px; height: 15px; }
.deleted-list { margin-top: 10px; background: var(--surface); border: 1px dashed var(--border-strong); border-radius: var(--radius-lg); }
.deleted-row { display: flex; align-items: center; gap: 12px; padding: 10px 16px; border-top: 1px solid var(--border); }
.deleted-row:first-child { border-top: 0; }
.deleted-row .ext { opacity: 0.55; }
.deleted-row .file-name { color: var(--muted); text-decoration: line-through; text-decoration-color: rgba(107, 115, 131, 0.5); }
.deleted-row form { margin: 0; }

/* Datahuoneen jäsenet */
.members-table .member-name { font-weight: 500; white-space: nowrap; }
.members-table .nowrap, .members-table td:last-child { white-space: nowrap; }
.members-table td:last-child { text-align: right; }
.muted-link { color: inherit; font-weight: 400; }
td a.muted-link { color: var(--muted); font-weight: 400; }
td a.muted-link:hover { color: var(--navy-600); }
.settings-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 24px; margin-top: 24px; align-items: start; }
.settings-grid > .card { margin-top: 0 !important; }
.app-version { font-size: 11px; color: var(--subtle); padding: 0 10px; font-variant-numeric: tabular-nums; }

/* Ehdot */
.terms-layout { display: grid; grid-template-columns: minmax(0, 3fr) minmax(300px, 2fr); gap: 24px; align-items: start; }
.terms-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; padding-bottom: 12px; border-bottom: 1px solid var(--border); }
.terms-head h2 { margin: 0; }
.terms-text { max-height: 62vh; overflow-y: auto; padding: 16px 4px 4px 0; color: var(--text-2); font-size: 14px; line-height: 1.65; }
.terms-text-full { max-height: none; }
.terms-text p { margin: 0 0 12px; }
.terms-form { position: sticky; top: 16px; }
.terms-confirmations { border-top: 1px solid var(--border); padding-top: 16px; margin-top: 4px; }
.terms-confirmations .field label { font-weight: 400; color: var(--text); }
.terms-confirmed li { align-items: flex-start; }
.terms-confirmed .ic { color: var(--ok); margin-top: 3px; }
@media (max-width: 1100px) { .terms-layout { grid-template-columns: 1fr; } .terms-form { position: static; } }
@media print { .sidebar, .mobilebar, .back, .btn { display: none !important; } .main { margin: 0; border: 0; } .terms-text { max-height: none; } }

/* Käyttäjähaku */
.user-picker-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.user-picker-chips:empty { display: none; }
.chip-user { display: inline-flex; align-items: center; gap: 6px; padding: 2px 3px 2px 9px; background: #F0F2F5; border: 1px solid var(--border); border-radius: 4px; font-size: 13px; color: var(--navy); max-width: 100%; }
.chip-user .muted { font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip-remove { border: 0; background: transparent; color: var(--muted); font-size: 16px; line-height: 1; width: 22px; height: 22px; border-radius: 50%; cursor: pointer; }
.chip-remove:hover { background: rgba(14, 21, 37, 0.08); color: var(--text); }
.user-picker-box { position: relative; }
.user-picker-input { padding-left: 36px !important; background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%239AA1AE' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cpath d='m21 21-4.3-4.3'/%3E%3C/svg%3E") no-repeat 12px center !important; }
.user-picker-results { position: absolute; left: 0; right: 0; top: calc(100% + 4px); z-index: 30; list-style: none; margin: 0; padding: 4px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-lg); max-height: 320px; overflow-y: auto; }
.user-picker-results li { display: flex; flex-direction: column; gap: 1px; padding: 8px 10px; border-radius: 8px; cursor: pointer; }
.user-picker-results li.active, .user-picker-results li:hover { background: var(--navy-50); }
.user-picker-results li.empty { cursor: default; background: none; }
.user-picker-results li.invite { color: var(--navy-600); font-weight: 500; border-top: 1px solid var(--border); margin-top: 4px; border-radius: 0 0 8px 8px; }
.user-picker-new { border: 1px dashed var(--border-strong); border-radius: var(--radius); padding: 14px 14px 0; margin-bottom: 16px; background: var(--surface-2); }
.user-picker-new h3 { margin: 0 0 10px; font-size: 13px; }

/* Tarkastus */
.review-task { margin-bottom: 12px; padding: 18px 20px; }
.review-task-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.review-form textarea { min-height: 0; }
.review-delegate { margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--border); }
.review-delegate-body { margin-top: 12px; }
.text-ok { color: var(--ok); font-weight: 500; }
a.badge { text-decoration: none; }
.menu-review { padding: 8px 10px; }
.menu-review label { display: block; margin-bottom: 6px; }
.menu-review-row { display: flex; gap: 6px; }
.menu-review-row .mini-select { flex: 1; min-width: 0; max-width: none; }

/* Kielivalinta */
.lang-switch { display: inline-flex; gap: 0; border: 1px solid var(--border-strong); border-radius: var(--radius); overflow: hidden; margin: 0 8px; align-self: flex-start; }
.lang-switch button { border: 0; background: var(--surface); font: 500 11.5px var(--font); color: var(--muted); padding: 3px 9px; cursor: pointer; }
.lang-switch button.active { background: var(--navy); color: #fff; }
.auth-lang { margin-top: 28px; text-align: center; }
.auth-lang .lang-switch { margin: 0; }

/* Tekoälyagentit */
.agent-choices { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 10px; }
.field .agent-choice { display: flex; font-weight: 400; color: var(--text); margin: 0; gap: 10px; align-items: flex-start; padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--radius); cursor: pointer; }
.agent-choice:has(input:checked) { border-color: var(--navy); background: var(--surface-2); }
.agent-choice input { margin-top: 3px; flex: none; }
.agent-choice strong { display: block; margin-bottom: 2px; }
.agent-docs { max-height: 340px; overflow: auto; border: 1px solid var(--border); border-radius: var(--radius); }
.agent-docs table { margin: 0; }
.field .agent-docs label.file-name { display: inline; cursor: pointer; margin: 0; font-weight: 500; }
.amount { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* Tiedostojen lisäys */
.upload-bulk { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 10px; }
.upload-table td { vertical-align: top; }
.upload-table .mini-select { max-width: 260px; }
.upload-file { display: flex; gap: 10px; align-items: flex-start; min-width: 220px; }
.upload-table tr.row-warn td { background: var(--warn-bg); }
.upload-table .expiry { display: flex; gap: 6px; align-items: center; margin-top: 6px; }
label.dropzone { cursor: pointer; }
.upload-table .expiry[hidden], .upload-table .mismatch[hidden] { display: none; }

/* Pre-DD */
.predd-layout { display: grid; grid-template-columns: 240px 1fr; gap: 20px; align-items: start; }
.predd-nav { display: flex; flex-direction: column; gap: 2px; position: sticky; top: 16px; }
.predd-nav a, .predd-nav .pending { display: block; padding: 8px 12px; border-radius: var(--radius); color: var(--text); text-decoration: none; }
.predd-nav a:hover { background: var(--surface-2); }
.predd-nav a.active { background: var(--navy); color: #fff; }
.predd-nav .pending { color: var(--muted); }
.predd-body { padding: 24px 28px; }
.predd-text p { line-height: 1.65; margin: 0 0 12px; }
@media (max-width: 760px) { .predd-layout { grid-template-columns: 1fr; } .predd-nav { position: static; flex-direction: row; flex-wrap: wrap; } }
