/* Shakta hallinta – perustyylit. Lähde: docs/mockups/shared.css (värit ja komponentit); värit asetetaan brand.json:sta (admin.js applyBrand). */
/* Itse tarjoillut fontit (OFL, assets/fonts/LICENSE-*). Muuttuvat fontit (variable): Fraunces 500–600 (opsz-akseli mukana), Source Sans 3 400–700.
   Build kopioi tiedostot kansioon admin/fonts/ ja korvaa 90571e5f84 (service worker välimuistittaa ?v=-tiedostot). */
@font-face {
  font-family: "Fraunces"; font-style: normal; font-weight: 500 600; font-display: swap;
  src: url("fonts/fraunces-latin-ext.woff2?v=90571e5f84") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Fraunces"; font-style: normal; font-weight: 500 600; font-display: swap;
  src: url("fonts/fraunces-latin.woff2?v=90571e5f84") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Source Sans 3"; font-style: normal; font-weight: 400 700; font-display: swap;
  src: url("fonts/sourcesans3-latin-ext.woff2?v=90571e5f84") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Source Sans 3"; font-style: normal; font-weight: 400 700; font-display: swap;
  src: url("fonts/sourcesans3-latin.woff2?v=90571e5f84") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  --font-sans: "Source Sans 3", "Segoe UI", system-ui, sans-serif;
  --font-serif: "Fraunces", "Iowan Old Style", Georgia, serif;
  --bg: #F3EFE8;
  --bg-elev: #FFFCF8;
  --bg-muted: #EAE4DA;
  --bg-hover: #F7F1EA;
  --bg-sidebar: #1E2A27;
  --bg-sidebar-hover: #2A3935;
  --ink: #1B2422;
  --ink-2: #5C6562;
  --ink-3: #8A918E;
  --on-dark: #EDE9E1;
  --on-dark-2: #A8B0AC;
  --line: #E0D8CC;
  --line-2: #D0C6B8;
  --accent: #B35C42;
  --accent-hover: #9C4D37;
  --accent-soft: #F3E4DE;
  --accent-ink: #7A3728;
  --green: #2F6F52;
  --green-soft: #DCEBE3;
  --amber: #8F6210;
  --amber-soft: #F4E8C9;
  --red: #B03A36;
  --red-soft: #F6DEDC;
  --blue: #3A6574;
  --blue-soft: #D9E6EB;
  --violet: #6B5470;
  --violet-soft: #EDE4EF;
  --sidebar-w: 228px;
  --topbar-h: 56px;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(27, 36, 34, 0.04), 0 6px 20px rgba(27, 36, 34, 0.06);
  --shadow-soft: 0 1px 2px rgba(27, 36, 34, 0.04);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: var(--font-sans);
  font-size: 14.5px;
  line-height: 1.45;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
a { color: inherit; text-decoration: none; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }

.app {
  display: flex;
  min-height: 100vh;
  background: var(--bg);
}

/* ——— Sivupalkki ——— */
.sidebar {
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  background: var(--bg-sidebar);
  color: var(--on-dark);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  align-self: stretch;
}
.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 20px 16px 18px;
}
.brand-name {
  font-family: var(--font-serif);
  font-size: 20px;
  font-weight: 560;
  letter-spacing: -0.02em;
  line-height: 1.1;
}
.brand-sub {
  font-size: 11.5px;
  color: var(--on-dark-2);
  margin-top: 2px;
  letter-spacing: 0.01em;
}
.nav {
  padding: 4px 10px 16px;
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.nav-label {
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #7E8884;
  padding: 14px 10px 6px;
}
.nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  border-radius: 8px;
  color: var(--on-dark-2);
  font-size: 13.5px;
  font-weight: 500;
}
.nav a svg {
  width: 17px;
  height: 17px;
  flex-shrink: 0;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.nav a:hover { background: var(--bg-sidebar-hover); color: var(--on-dark); }
.nav a.active {
  background: #31423D;
  color: #fff;
}
.nav a.active svg { color: #E8B09E; }
.nav .badge {
  margin-left: auto;
  background: var(--accent);
  color: #fff;
  font-size: 10.5px;
  font-weight: 650;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 99px;
  display: grid;
  place-items: center;
}
.sidebar-foot {
  margin-top: auto;
  padding: 12px 10px 16px;
  border-top: 1px solid #31423D;
}
.user-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 8px;
  border-radius: 10px;
}
.avatar, .av {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #3D524C;
  color: #F0E6DC;
  display: grid;
  place-items: center;
  font-size: 11.5px;
  font-weight: 650;
  flex-shrink: 0;
  letter-spacing: 0.02em;
}
.av.sm { width: 26px; height: 26px; font-size: 10px; }
.av.lg { width: 56px; height: 56px; font-size: 20px; font-family: var(--font-serif); font-weight: 560; }
.user-chip .who { font-size: 13px; font-weight: 600; color: var(--on-dark); line-height: 1.2; }
.user-chip .role { font-size: 11.5px; color: var(--on-dark-2); }

/* ——— Pääalue ——— */
.main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.topbar {
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 22px;
  background: color-mix(in srgb, var(--bg) 84%, white);
  border-bottom: 1px solid var(--line);
  z-index: 5;
}
.crumb {
  font-family: var(--font-serif);
  font-size: 20px;
  font-weight: 520;
  letter-spacing: -0.02em;
  white-space: nowrap;
}
.search {
  flex: 1;
  max-width: 420px;
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 14px;
  color: var(--ink-3);
  font-size: 13.5px;
}
.search svg { width: 15px; height: 15px; stroke: currentColor; fill: none; stroke-width: 1.8; }
.clock {
  font-size: 13px;
  color: var(--ink-2);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.content {
  padding: 22px 24px 32px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

/* ——— Yleiset palikat ——— */
.row { display: flex; gap: 16px; align-items: stretch; }
.col { display: flex; flex-direction: column; gap: 16px; }
.grow { flex: 1; min-width: 0; }
.card {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-soft);
}
.card-h {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 18px 0;
}
.card-h h2 {
  font-size: 15px;
  font-weight: 650;
  letter-spacing: -0.01em;
}
.card-h .more { font-size: 13px; color: var(--accent); font-weight: 600; }
.card-b { padding: 12px 18px 16px; }
.muted { color: var(--ink-2); }
.faint { color: var(--ink-3); }
.tiny { font-size: 12px; }
.strong { font-weight: 650; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 34px;
  padding: 0 13px;
  border-radius: 8px;
  border: 1px solid var(--line-2);
  background: var(--bg-elev);
  font-size: 13.5px;
  font-weight: 600;
  color: var(--ink);
  white-space: nowrap;
}
.btn:hover { background: var(--bg-hover); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-hover); }
.btn.ghost { background: transparent; }
.btn.sm { height: 28px; padding: 0 10px; font-size: 12.5px; }
.btn.lg { height: 42px; padding: 0 16px; font-size: 15px; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }
.btn svg { width: 15px; height: 15px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 22px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 650;
  letter-spacing: 0.01em;
  background: var(--bg-muted);
  color: var(--ink-2);
  white-space: nowrap;
}
.tag.green { background: var(--green-soft); color: var(--green); }
.tag.amber { background: var(--amber-soft); color: var(--amber); }
.tag.red { background: var(--red-soft); color: var(--red); }
.tag.blue { background: var(--blue-soft); color: var(--blue); }
.tag.accent { background: var(--accent-soft); color: var(--accent-ink); }
.tag.violet { background: var(--violet-soft); color: var(--violet); }

/* KPI */
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.kpi { padding: 16px 18px 18px; }
.kpi .label { font-size: 12.5px; color: var(--ink-2); font-weight: 550; }
.kpi .value {
  font-family: var(--font-serif);
  font-size: 30px;
  font-weight: 520;
  letter-spacing: -0.03em;
  line-height: 1.15;
  margin: 4px 0 2px;
  font-variant-numeric: tabular-nums;
}
.kpi .delta { font-size: 12.5px; }
.kpi .delta.up { color: var(--green); }
.kpi .delta.down { color: var(--red); }
.kpi .delta.warn { color: var(--amber); }

/* Taulukot */
table.data { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.data th {
  text-align: left;
  font-size: 11px;
  font-weight: 650;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--ink-3);
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
table.data td {
  padding: 9px 10px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
table.data tr:last-child td { border-bottom: 0; }
table.data tbody tr:hover td { background: var(--bg-hover); }
table.data .num, .num { font-variant-numeric: tabular-nums; text-align: right; }
table.data td.person {
  display: table-cell;
}
.person-cell { display: flex; align-items: center; gap: 8px; }
.person-cell .name { font-weight: 600; }
.person-cell .sub { font-size: 12px; color: var(--ink-3); }

/* Täyttöaste */
.fill {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 110px;
}
.fill-bar {
  flex: 1;
  height: 6px;
  background: var(--bg-muted);
  border-radius: 99px;
  overflow: hidden;
}
.fill-bar > span { display: block; height: 100%; border-radius: 99px; background: var(--green); }
.fill-bar.full > span { background: var(--accent); }
.fill-bar.high > span { background: var(--amber); }
.fill .n { font-variant-numeric: tabular-nums; font-weight: 650; font-size: 12.5px; min-width: 42px; }

/* Avataarit väreillä */
.av.c1 { background: #3D524C; color: #F0E6DC; }
.av.c2 { background: #6B5470; color: #F4EAF4; }
.av.c3 { background: #3A6574; color: #E6F1F4; }
.av.c4 { background: #7A3728; color: #F8E8E2; }
.av.c5 { background: #5C6562; color: #EEF0EE; }
.av.c6 { background: #8F6210; color: #F8F0DC; }

.check {
  width: 18px; height: 18px; border-radius: 50%;
  border: 1.6px solid var(--line-2);
  display: inline-grid; place-items: center;
  background: var(--bg-elev);
  flex-shrink: 0;
}
.check.on {
  background: var(--green);
  border-color: var(--green);
  color: #fff;
}
.check.on svg { width: 11px; height: 11px; stroke: #fff; fill: none; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }


/* ——— Shell: logo, koulunvalitsin, kirjautuminen, kapea näyttö ——— */
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.err { color: var(--red); }
.brand { display: block; padding: 20px 18px 14px; }
.brand-logo { display: block; width: 100%; max-width: 176px; height: auto; }
.brand-sub { font-size: 12px; color: var(--on-dark-2); margin-top: 10px; letter-spacing: 0.02em; }
.school-switch { display: block; padding: 0 14px 4px; }
.school-switch .select { width: 100%; background-color: var(--bg-sidebar-hover); color: var(--on-dark); border-color: #3D524C; }
.menu-btn { display: none; align-items: center; justify-content: center; width: 40px; height: 40px; border: 1px solid var(--line-2); border-radius: 8px; background: var(--bg-elev); }
.menu-btn svg { stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; }
.demo-tag { margin-left: auto; }
.clock { margin-left: auto; }
.demo-tag + .clock { margin-left: 0; }
.scrim { display: none; }
.soon .card-b p + p { margin-top: 4px; }

.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login { width: min(420px, 100%); padding: 28px 28px 24px; display: flex; flex-direction: column; gap: 14px; box-shadow: var(--shadow); }
.login-logo { width: 220px; max-width: 70%; height: auto; display: block; margin: 0 auto 6px; }
.login h1 { font-family: var(--font-serif); font-size: 24px; font-weight: 520; letter-spacing: -0.02em; text-align: center; }
.login .muted { text-align: center; }
.fld { display: flex; flex-direction: column; gap: 5px; font-size: 13px; font-weight: 600; color: var(--ink-2); }
.fld input { height: 42px; padding: 0 12px; border: 1px solid var(--line-2); border-radius: 8px; background: #fff; font-size: 15px; font-weight: 400; color: var(--ink); }
.fld input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.login-msg { font-size: 13.5px; background: var(--amber-soft); color: var(--amber); padding: 10px 12px; border-radius: 8px; }
.login-msg.err { background: var(--red-soft); color: var(--red); }
.demo-link { text-align: center; color: var(--accent); font-weight: 600; font-size: 14px; }
.demo-link:hover { text-decoration: underline; }

@media (max-width: 900px) {
  .sidebar { position: fixed; z-index: 30; left: 0; top: 0; bottom: 0; overflow-y: auto; transform: translateX(-100%); transition: transform .2s ease; }
  .nav-open .sidebar { transform: none; box-shadow: 0 0 40px rgba(0,0,0,.35); }
  .nav-open .scrim { display: block; position: fixed; inset: 0; z-index: 20; background: rgba(20, 24, 22, 0.45); }
  .menu-btn { display: inline-flex; }
  .topbar { padding: 0 14px; gap: 10px; }
  .crumb { font-size: 18px; overflow: hidden; text-overflow: ellipsis; }
  .clock { display: none; }
  .content { padding: 16px 14px 28px; }
  .kpis { grid-template-columns: 1fr 1fr; gap: 10px; }
  .kpi { padding: 12px 14px 14px; }
  .kpi .value { font-size: 26px; }
}
@media (max-width: 420px) {
  .kpis { grid-template-columns: 1fr; }
}
/* Henkilökunta (T-1.2) ja kirjautuminen */
.select { height: 34px; padding: 0 28px 0 10px; border: 1px solid var(--line-2); border-radius: 8px; background-color: #fff; font: inherit; font-size: 13.5px; color: var(--ink); max-width: 100%; }
.select:focus-visible, .btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.fld .select { height: 42px; font-size: 15px; font-weight: 400; }
.demo-banner { margin: 0 0 14px; padding: 10px 14px; border: 1px dashed var(--accent); border-radius: 10px; background: var(--accent-soft); color: var(--accent-ink); font-size: 13.5px; font-weight: 600; }
.flash { margin: 0 0 14px; padding: 10px 14px; border-radius: 10px; background: #E6F0E9; color: #1F4D36; font-size: 14px; }
.flash.err { background: #F8E3DF; color: #8A2A1B; }
table.data tr.row-inactive td { color: var(--ink-3); }
table.data td.actions { text-align: right; white-space: nowrap; }
.invite-form { margin-top: 16px; }
.invite-grid { display: grid; grid-template-columns: 1.3fr 1fr 1fr; gap: 12px; margin: 10px 0 14px; }
.logout-btn { margin: 10px 14px 0; width: calc(100% - 28px); justify-content: center; color: var(--on-dark-2); border-color: #3D524C; }
.logout-btn:hover { background: var(--bg-sidebar-hover); color: var(--on-dark); }
.login-checking { text-align: center; padding: 40px 0; }
@media (max-width: 900px) {
  .invite-grid { grid-template-columns: 1fr; }
  table.data.stack thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  table.data.stack, table.data.stack tbody, table.data.stack tr, table.data.stack td { display: block; width: 100%; }
  table.data.stack tr { padding: 10px 14px; border-bottom: 1px solid var(--line); }
  table.data.stack td { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 5px 0; border-bottom: 0; text-align: right; }
  table.data.stack td::before { content: attr(data-label); font-size: 11px; font-weight: 650; letter-spacing: .05em; text-transform: uppercase; color: var(--ink-3); text-align: left; flex: none; }
  table.data.stack td.person { font-weight: 600; }
  table.data.stack tbody tr:hover td { background: transparent; }
}
[hidden] { display: none !important; }
