:root {
  --bg: #EEF0EC; --panel: #FFFFFF; --line: #DCE1DF; --line2: #ECEFED; --soft: #F7F8F6;
  --ink: #1B1F1D; --muted: #4E5A57; --faint: #8A9592; --accent: #1F5A55; --accent-ink: #FFFFFF;
  --sel: #E1ECE9; --nav: #1B2422; --nav-ink: #C9D4D1; --nav-on: #2D3B38;
  --red: #A3261B; --amber: #7A4100; --amber-bg: #FCEBD2;
  --ok-bg: #E3EFEA; --ok: #1D5240; --blue-bg: #E4E9F7; --blue: #283C7A; --grey-bg: #E6E8E7; --grey: #3B4643;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: 'IBM Plex Sans', system-ui, sans-serif; font-size: 15px; }
button, input, select, textarea { font: inherit; color: inherit; }
.mono { font-family: 'IBM Plex Mono', ui-monospace, monospace; }
.shell { display: flex; flex-wrap: wrap; min-height: 100vh; }

/* sidebar */
nav.side { flex: 1 1 220px; max-width: 100%; background: var(--nav); color: #E6ECEA; padding: 24px 16px; display: flex; flex-direction: column; gap: 2px; }
nav.side .brand { font-weight: 700; font-size: 18px; padding: 0 12px 4px; }
nav.side .brand .cur { display: none; }
nav.side .where { font-size: 12px; color: #9FB0AC; padding: 0 12px 4px; }
nav.side .grp { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: #9FB0AC; padding: 20px 12px 6px; }
nav.side .sub { font-size: 11px; color: #7F918C; padding: 8px 12px 2px; }
nav.side a { display: flex; align-items: center; gap: 10px; min-height: 40px; padding: 0 12px; border-radius: 8px; color: var(--nav-ink); text-decoration: none; }
nav.side a:hover { background: #24302D; }
nav.side a.on { background: var(--nav-on); color: #fff; font-weight: 600; }
nav.side a.todo { opacity: .45; pointer-events: none; }
nav.side a .ext { margin-left: auto; opacity: .7; }
@media (max-width: 860px) {
  nav.side { flex-basis: 100%; flex-direction: row; flex-wrap: wrap; padding: 10px 12px; gap: 4px; }
  /* phones: no links to the other apps, only this app's name (each is installed as its own app) */
  nav.side .grp, nav.side .sub, nav.side .where, nav.side a, nav.side .brand .hub { display: none; }
  nav.side .brand .cur { display: inline; }
  nav.side .brand { padding: 4px 12px; }
}

main { flex: 999 1 560px; min-width: 0; padding: 28px 32px 48px; display: flex; flex-direction: column; gap: 22px; }
@media (max-width: 600px) { main { padding: 18px 16px 40px; } }
h1 { margin: 0; font-size: 28px; }
.lead { margin: 6px 0 0; color: var(--muted); font-size: 14px; }
.head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 16px; }
.row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }

.btn { min-height: 44px; padding: 0 16px; border-radius: 8px; border: 1px solid #B9C3C0; background: #fff; cursor: pointer; font-weight: 500; }
.btn:hover { border-color: #8C9A96; }
.btn.primary { border: 0; background: var(--accent); color: var(--accent-ink); font-weight: 600; }
.btn.small { min-height: 36px; padding: 0 12px; font-size: 13px; }
.btn.link { border: 0; background: none; color: var(--accent); padding: 0 6px; min-height: 32px; text-decoration: underline; }
.btn:disabled { opacity: .5; cursor: default; }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; }
.kpi { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 16px 18px; }
.kpi .l { font-size: 13px; color: var(--muted); }
.kpi .v { font-size: 30px; font-weight: 700; margin-top: 4px; }
.kpi .n { font-size: 12px; color: var(--muted); margin-top: 2px; }
.kpi .v.red { color: var(--red); }

input.search { flex: 1 1 240px; min-height: 44px; padding: 0 14px; border-radius: 8px; border: 1px solid #B9C3C0; background: #fff; }
.chip { min-height: 44px; padding: 0 14px; border-radius: 999px; border: 1px solid #B9C3C0; background: #fff; cursor: pointer; font-size: 14px; }
.chip.on { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }

.split { display: flex; flex-wrap: wrap; gap: 18px; align-items: flex-start; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; }
.list { flex: 3 1 520px; min-width: 0; overflow: hidden; }
.list .scroll { overflow-x: auto; }
.list .inner { min-width: 640px; }
.grid5 { display: grid; grid-template-columns: 82px minmax(120px, 1.4fr) 92px minmax(140px, 1fr) 122px; column-gap: 10px; gap: 12px; align-items: center; }
.list .th { padding: 12px 18px; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); border-bottom: 1px solid var(--line); background: var(--soft); }
.list .tr { width: 100%; min-height: 52px; padding: 8px 18px; border: 0; border-bottom: 1px solid var(--line2); text-align: left; cursor: pointer; background: #fff; font-size: 14px; }
.list .tr:hover { background: #F4F7F6; }
.list .tr.sel { background: var(--sel); box-shadow: inset 4px 0 0 var(--accent); }
.list .tr.arch { color: #5E6A67; background: var(--soft); }
.list .foot { padding: 12px 18px; border-top: 1px solid var(--line); background: var(--soft); }
.reg { font-family: 'IBM Plex Mono', monospace; font-weight: 600; }

.pill { display: inline-block; padding: 4px 10px; border-radius: 999px; font-size: 13px; font-weight: 600; }
.st-kaytossa { background: var(--ok-bg); color: var(--ok); }
.st-rahoitus { background: var(--blue-bg); color: var(--blue); }
.st-varaosiksi, .st-romutus, .st-myyty { background: var(--grey-bg); color: var(--grey); }
.late { color: var(--red); font-weight: 600; }
.soon { color: var(--amber); font-weight: 600; }
.muted { color: var(--muted); }

.detail { flex: 2 1 380px; min-width: 0; padding: 22px; display: flex; flex-direction: column; gap: 22px; }
.plate { display: inline-block; font-family: 'IBM Plex Mono', monospace; font-weight: 600; font-size: 22px; padding: 4px 10px; border: 2px solid var(--ink); border-radius: 6px; }
.detail h2 { margin: 0 0 10px; font-size: 14px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.h2row { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 8px; margin-bottom: 10px; }
.h2row h2 { margin: 0; }
.fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 16px; }
.f .k { font-size: 12px; color: var(--muted); }
.f .v { font-size: 14px; font-weight: 500; overflow-wrap: anywhere; display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.f .v.empty { color: var(--faint); font-style: italic; font-weight: 400; }
.f label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.f input, .f select, .inp { width: 100%; min-height: 40px; padding: 0 10px; border-radius: 6px; border: 1px solid #8C9A96; background: #fff; font-size: 14px; }
.tag { font-size: 11px; font-weight: 600; padding: 2px 7px; border-radius: 999px; background: var(--blue-bg); color: var(--blue); }
.banner { padding: 12px 14px; border-radius: 10px; font-size: 14px; }
.banner.red { background: var(--red); color: #fff; font-weight: 600; }
.banner.grey { background: #EEF0EF; color: var(--grey); }
.banner.amber { background: var(--amber-bg); color: #5C3100; }
.hist { display: grid; grid-template-columns: 100px minmax(0, 1fr) 100px 100px; gap: 10px; padding: 7px 0; border-top: 1px solid #E6EAE8; font-size: 14px; }
.hist.th { border: 0; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.svc { display: grid; grid-template-columns: 90px 90px minmax(0, 1fr) 100px 32px; gap: 10px; align-items: center; padding: 8px 0; border-top: 1px solid #E6EAE8; font-size: 14px; }
.svc.total { border-top: 2px solid #C9D1CE; font-weight: 600; }
.svcform { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 10px; padding: 12px; background: var(--soft); border-radius: 10px; }
.svcform .wide { grid-column: 1 / -1; }
textarea.inp { min-height: 80px; padding: 10px 12px; resize: vertical; }
.x { border: 0; background: none; cursor: pointer; color: var(--faint); font-size: 18px; min-height: 32px; }
.x:hover { color: var(--red); }
.right { text-align: right; }
.ok { color: var(--ok); }

.modal-bg { position: fixed; inset: 0; background: rgba(20, 28, 26, .55); display: flex; align-items: flex-start; justify-content: center; padding: 48px 16px; overflow-y: auto; z-index: 10; }
.modal { width: 100%; max-width: 680px; background: #fff; border-radius: 14px; padding: 26px; display: flex; flex-direction: column; gap: 16px; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.modal h2 { margin: 0; font-size: 22px; }
.conf { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px 16px; align-items: center; padding: 12px 0; border-top: 1px solid #E6EAE8; font-size: 14px; }
.seg { display: inline-flex; border: 1px solid #B9C3C0; border-radius: 8px; overflow: hidden; }
.seg button { min-height: 40px; padding: 0 12px; border: 0; background: #fff; cursor: pointer; font-size: 13px; }
.seg button.on { background: var(--accent); color: #fff; font-weight: 600; }
.chg { font-size: 13px; padding: 4px 0; color: var(--muted); }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 12px 18px; border-radius: 10px; font-size: 14px; z-index: 20; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* shared: tabs, tables, forms for the document apps */
.tabs { display: flex; flex-wrap: wrap; gap: 4px; border-bottom: 1px solid #C9D1CE; }
.tab { min-height: 44px; padding: 0 18px; border: 0; background: none; cursor: pointer; font-size: 15px; color: var(--muted); border-bottom: 3px solid transparent; margin-bottom: -1px; }
.tab.on { color: var(--ink); font-weight: 600; border-bottom-color: var(--accent); }
.panel-h { padding: 14px 18px; border-bottom: 1px solid var(--line); background: var(--soft); display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 10px; font-size: 14px; }
.tbl { overflow-x: auto; }
.tbl .r { display: grid; gap: 12px; align-items: center; padding: 11px 18px; border-bottom: 1px solid var(--line2); font-size: 14px; }
.tbl .r.h { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); background: var(--soft); border-bottom: 1px solid var(--line); }
.tbl button.r { width: 100%; border: 0; border-bottom: 1px solid var(--line2); background: #fff; text-align: left; cursor: pointer; }
.tbl button.r:hover { background: #F4F7F6; }
.tbl .r.dim { color: #5E6A67; background: var(--soft); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.mini { padding: 3px 8px; border-radius: 6px; background: #EEF2F0; font-size: 13px; }
.formgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.formcard { padding: 18px; display: flex; flex-direction: column; gap: 14px; }
.formcard h2 { margin: 0; font-size: 17px; }
.sel-pill { min-height: 40px; max-width: 200px; padding: 0 10px; border-radius: 999px; font-size: 13px; font-weight: 600; cursor: pointer; }
.b-tyhja { border: 1px solid #C98A2E; background: var(--amber-bg); color: var(--amber); }
.b-pyynto { border: 1px solid #6B7FC0; background: var(--blue-bg); color: var(--blue); }
.b-maksettu { border: 1px solid #8DB8A6; background: var(--ok-bg); color: var(--ok); }
.b-siirto { border: 1px solid #9A86C4; background: #EEE8F6; color: #4B2E83; }
.b-eilask { border: 1px solid #B9C3C0; background: #F1F3F2; color: var(--muted); }
.strike { color: var(--faint); text-decoration: line-through; }
.redtxt { color: var(--red); font-size: 13px; }
.kpi .v.amber { color: var(--amber); }
.bill { padding: 12px 18px; border-bottom: 1px solid var(--line2); display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px 12px; align-items: center; }
.bill .more { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 8px; padding-top: 6px; }
