/* Tuno – Valtion budjetti */
/* lang="fi" mahdollistaa suomenkielisen tavutuksen ruuduissa */
.tunob {
	--tunob-surface: #ffffff;
	--tunob-surface-2: #f4f4f2;
	--tunob-border: #deddd8;
	--tunob-text: #0b0b0b;
	--tunob-text-2: #52514e;
	--tunob-muted: #6b6a66;
	--tunob-meno: #256abf;
	--tunob-meno-hover: #1c5cab;
	--tunob-tulo: #0b7a3e;
	--tunob-tulo-hover: #086632;
	--tunob-accent: var(--tunob-meno);
	--tunob-accent-hover: var(--tunob-meno-hover);
	--tunob-up: #0b7a3e;
	--tunob-down: #c0392b;
	--tunob-focus: #f2b700;
	--tunob-radius: 10px;

	box-sizing: border-box;
	color: var(--tunob-text);
	background: var(--tunob-surface);
	border: 1px solid var(--tunob-border);
	border-radius: var(--tunob-radius);
	padding: 20px;
	margin: 1.5em 0;
	font-size: 15px;
	line-height: 1.45;
	max-width: 100%;
}
.tunob *, .tunob *::before, .tunob *::after { box-sizing: border-box; }
.tunob[data-side-active="tulot"] {
	--tunob-accent: var(--tunob-tulo);
	--tunob-accent-hover: var(--tunob-tulo-hover);
}
.tunob button { font: inherit; }
.tunob :focus-visible { outline: 3px solid var(--tunob-focus); outline-offset: 2px; }

.tunob-loading, .tunob-empty { color: var(--tunob-muted); padding: 2em 0; text-align: center; margin: 0; }

.tunob-head { margin-bottom: 12px; }
.tunob .tunob-title { margin: 0; font-size: 1.6em; line-height: 1.2; }
.tunob-sub { margin: 4px 0 0; color: var(--tunob-text-2); }

.tunob-controls { display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: flex-end; margin-bottom: 12px; }
.tunob-ctl { display: flex; flex-direction: column; gap: 2px; font-size: .82em; color: var(--tunob-text-2); margin: 0; }
.tunob-select, .tunob-search-input {
	font: inherit; font-size: 15px; color: var(--tunob-text); background: var(--tunob-surface);
	border: 1px solid var(--tunob-border); border-radius: 8px; padding: 7px 10px; min-height: 40px; max-width: 100%;
}
.tunob-ctl-version .tunob-select { max-width: 340px; }

.tunob-seg { display: inline-flex; border: 1px solid var(--tunob-border); border-radius: 999px; padding: 3px; background: var(--tunob-surface-2); }
.tunob-seg-btn {
	border: 0; background: transparent; color: var(--tunob-text); padding: 6px 16px; border-radius: 999px; cursor: pointer;
	display: flex; flex-direction: column; align-items: center; line-height: 1.15; min-height: 40px; justify-content: center;
}
.tunob-seg-btn.is-active { background: var(--tunob-accent); color: #fff; }
.tunob-seg-btn[data-side="tulot"].is-active { background: var(--tunob-tulo); }
.tunob-seg-btn[data-side="menot"].is-active { background: var(--tunob-meno); }
.tunob-seg-label { font-weight: 600; }
.tunob-seg-total { font-size: .78em; opacity: .85; font-variant-numeric: tabular-nums; }

.tunob-search { position: relative; flex: 1 1 220px; min-width: 200px; }
.tunob-search-input { width: 100%; }
.tunob-search-list {
	position: absolute; z-index: 20; left: 0; right: 0; top: calc(100% + 4px); margin: 0; padding: 4px; list-style: none;
	background: var(--tunob-surface); border: 1px solid var(--tunob-border); border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,.12);
	max-height: 360px; overflow: auto;
}
.tunob-search-opt { display: grid; grid-template-columns: auto 1fr auto; gap: 8px; padding: 7px 8px; border-radius: 6px; cursor: pointer; align-items: baseline; }
.tunob-search-opt:hover, .tunob-search-opt.is-active { background: var(--tunob-surface-2); }
.tunob-search-code { color: var(--tunob-muted); font-variant-numeric: tabular-nums; font-size: .85em; }
.tunob-search-amt { color: var(--tunob-text-2); font-size: .85em; white-space: nowrap; font-variant-numeric: tabular-nums; }
.tunob-search-none { padding: 8px; color: var(--tunob-muted); }

.tunob-notice { background: #fff6d6; border: 1px solid #ecd78a; color: #4a3b00; border-radius: 8px; padding: 10px 12px; margin-bottom: 12px; }

.tunob-crumbs ol { list-style: none; margin: 0 0 10px; padding: 0; display: flex; flex-wrap: wrap; gap: 4px; font-size: .92em; }
.tunob-crumbs li { display: flex; align-items: center; gap: 4px; color: var(--tunob-text-2); }
.tunob-crumbs li + li::before { content: "›"; color: var(--tunob-muted); }
.tunob-crumbs [aria-current] { font-weight: 600; color: var(--tunob-text); }
.tunob-crumb { border: 0; background: none; padding: 2px 0; color: var(--tunob-accent); cursor: pointer; text-decoration: underline; text-underline-offset: 2px; }

.tunob-nav { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; margin-bottom: 10px; }
.tunob-nav .tunob-crumbs ol { margin: 0; }
.tunob-nav-btns { display: flex; gap: 6px; }
.tunob-nav-btn {
	border: 1px solid var(--tunob-border); background: var(--tunob-surface); color: var(--tunob-text);
	border-radius: 8px; padding: 6px 12px; min-height: 36px; cursor: pointer; white-space: nowrap; font-size: .92em;
}
.tunob-nav-btn:hover:not(:disabled) { border-color: var(--tunob-accent); color: var(--tunob-accent); }
.tunob-nav-btn:disabled { opacity: .45; cursor: default; }

.tunob-body {
	display: grid; gap: 16px; align-items: start;
	grid-template-columns: 270px minmax(0, 1fr) 320px;
	grid-template-areas: "tree map panel";
}
.tunob-tree { grid-area: tree; min-width: 0; background: var(--tunob-surface-2); border-radius: 8px; }
.tunob-map-wrap { grid-area: map; }
.tunob-panel { grid-area: panel; }
.tunob-tree-summary { list-style: none; cursor: pointer; font-weight: 600; font-size: .9em; padding: 10px 12px; border-bottom: 1px solid var(--tunob-border); }
.tunob-tree-summary::-webkit-details-marker { display: none; }
.tunob-tree-summary::after { content: "▾"; float: right; color: var(--tunob-muted); }
.tunob-tree:not([open]) .tunob-tree-summary::after { content: "▸"; }
.tunob-tree-list { max-height: 560px; overflow-y: auto; overscroll-behavior: contain; padding: 6px 4px 8px; position: relative; }
.tunob-tree-ul { list-style: none; margin: 0; padding: 0; }
.tunob-tree-ul .tunob-tree-ul { margin-left: 12px; padding-left: 6px; border-left: 2px solid var(--tunob-border); }
.tunob-tree-row { display: grid; grid-template-columns: 22px minmax(0, 1fr); grid-template-rows: auto auto; column-gap: 2px; padding: 3px 4px; border-radius: 6px; }
.tunob-tree-row.is-path { background: rgba(37, 106, 191, .07); }
.tunob[data-side-active="tulot"] .tunob-tree-row.is-path { background: rgba(11, 122, 62, .08); }
.tunob-tree-row.is-current, .tunob-tree-row.is-selected { background: var(--tunob-surface); box-shadow: inset 3px 0 0 var(--tunob-accent); }
.tunob-tree-toggle {
	grid-row: 1 / span 2; border: 0; background: none; padding: 0; width: 22px; height: 22px; cursor: pointer;
	color: var(--tunob-text-2); font-size: 12px; line-height: 22px; text-align: center; border-radius: 4px;
}
.tunob-tree-toggle:hover:not(.is-leaf) { background: var(--tunob-border); }
.tunob-tree-toggle.is-leaf { cursor: default; color: var(--tunob-muted); }
.tunob-tree-label { border: 0; background: none; padding: 1px 0; text-align: left; cursor: pointer; color: var(--tunob-text); display: flex; flex-direction: column; min-width: 0; font-size: 13px; line-height: 1.3; }
.tunob-tree-label:hover .tunob-tree-name { color: var(--tunob-accent); text-decoration: underline; text-underline-offset: 2px; }
.tunob-tree-row.is-current .tunob-tree-name, .tunob-tree-row.is-selected .tunob-tree-name { font-weight: 700; }
.tunob-swatch { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: 5px; vertical-align: 1px; }
.tunob-tree-code { color: var(--tunob-muted); font-variant-numeric: tabular-nums; }
.tunob-tree-amt { color: var(--tunob-text-2); font-size: 11.5px; font-variant-numeric: tabular-nums; }
.tunob-tree-bar { grid-column: 2; display: block; height: 3px; background: var(--tunob-border); border-radius: 2px; margin-top: 2px; }
.tunob-tree-bar > span { display: block; height: 100%; background: var(--tunob-accent); border-radius: 2px; }

@media (max-width: 1180px) {
	.tunob-body { grid-template-columns: 250px minmax(0, 1fr); grid-template-areas: "tree map" "tree panel"; }
	.tunob-tree-list { max-height: 900px; }
}
.tunob-map-wrap { position: relative; min-width: 0; }
.tunob-map { position: relative; overflow: hidden; border-radius: 8px; background: var(--tunob-surface); transition: opacity .2s; }
.tunob-map.is-loading { opacity: .5; }
.tunob-layer { position: absolute; inset: 0; }
.tunob-layer.is-animating { transition: transform .45s cubic-bezier(.2,.7,.2,1), opacity .45s; }
.tunob-hint { margin: 6px 0 0; font-size: .82em; color: var(--tunob-muted); }

.tunob-tile {
	position: absolute; margin: 0; padding: 8px 10px; border: 2px solid var(--tunob-surface); border-radius: 6px;
	background: var(--tunob-accent); color: #fff; text-align: left; cursor: pointer; overflow: hidden;
	display: flex; flex-direction: column; justify-content: flex-start; gap: 2px;
}
.tunob-tile { transition: filter .15s; }
.tunob-tile:hover, .tunob-tile:focus-visible { filter: brightness(.85) saturate(1.1); }
.tunob-tile:focus-visible { outline: 3px solid var(--tunob-focus); outline-offset: -3px; z-index: 2; }
.tunob-tile.is-selected { box-shadow: inset 0 0 0 3px rgba(255,255,255,.9); }
.tunob-tile.is-small { padding: 0; }
.tunob-tile.has-children::after {
	content: ""; position: absolute; right: 6px; bottom: 6px; width: 7px; height: 7px;
	border-right: 2px solid rgba(255,255,255,.75); border-bottom: 2px solid rgba(255,255,255,.75); transform: rotate(-45deg);
}
.tunob-tile.is-small.has-children::after { display: none; }
.tunob-tile-name {
	font-weight: 600; font-size: 13.5px; line-height: 1.25;
	display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: break-word; hyphens: auto;
}
.tunob-tile-amount { font-size: 12.5px; opacity: .92; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.tunob-tip {
	position: absolute; z-index: 10; pointer-events: none; max-width: 280px;
	background: var(--tunob-text); color: var(--tunob-surface); border-radius: 8px; padding: 8px 10px; font-size: 13px; line-height: 1.35;
	display: flex; flex-direction: column; gap: 2px; box-shadow: 0 6px 20px rgba(0,0,0,.2);
}
.tunob-tip[hidden] { display: none; }
.tunob-tip-muted { opacity: .75; }

.tunob-panel {
	background: var(--tunob-surface-2); border-radius: 8px; padding: 16px; min-width: 0;
}
.tunob-panel-kicker { margin: 0; font-size: .8em; text-transform: uppercase; letter-spacing: .04em; color: var(--tunob-muted); }
.tunob .tunob-panel-title { margin: 2px 0 8px; font-size: 1.15em; line-height: 1.3; }
.tunob-panel-amount { margin: 0; font-size: 1.9em; font-weight: 700; line-height: 1.1; font-variant-numeric: tabular-nums; }
.tunob-panel-full { margin: 2px 0 12px; color: var(--tunob-text-2); font-size: .88em; font-variant-numeric: tabular-nums; }
.tunob-facts { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; margin: 0 0 12px; font-size: .92em; }
.tunob-facts dt { color: var(--tunob-text-2); margin: 0; }
.tunob-facts dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
.tunob .is-up { color: var(--tunob-up); }
.tunob .is-down { color: var(--tunob-down); }
.tunob .tunob-panel-h { margin: 14px 0 6px; font-size: .95em; }
.tunob-parts { list-style: none; margin: 0; padding: 0; font-size: .9em; }
.tunob-parts li { display: flex; justify-content: space-between; gap: 8px; padding: 3px 0; border-bottom: 1px solid var(--tunob-border); font-variant-numeric: tabular-nums; }
.tunob-btn { border: 0; background: var(--tunob-accent); color: #fff; border-radius: 8px; padding: 8px 14px; cursor: pointer; min-height: 40px; }
.tunob-btn:hover { background: var(--tunob-accent-hover); }
.tunob-link-btn { border: 0; background: none; padding: 0; color: var(--tunob-accent); cursor: pointer; text-align: left; text-decoration: underline; text-underline-offset: 2px; }
.tunob-muted { color: var(--tunob-muted); font-size: .9em; }
.tunob-text { font-size: .92em; }
.tunob-text-body { overflow-wrap: anywhere; }
.tunob-text-body {
	max-height: 420px; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch;
	background: var(--tunob-surface); border: 1px solid var(--tunob-border); border-radius: 6px; padding: 8px 12px;
}
.tunob-text-body.is-scroll { box-shadow: inset 0 -12px 10px -10px rgba(0,0,0,.18); }
.tunob-text-body.is-expanded { max-height: none; box-shadow: none; }
.tunob-text-more { margin: 6px 0 0; }
.tunob-text-body table { border-collapse: collapse; width: 100%; font-size: .9em; display: block; overflow-x: auto; }
.tunob-text-body td, .tunob-text-body th { border: 1px solid var(--tunob-border); padding: 3px 5px; }
.tunob-text-body h3, .tunob-text-body h4, .tunob-text-body h5 { font-size: 1em; margin: 1em 0 .3em; }
.tunob-ext { color: var(--tunob-accent); }

.tunob-table-wrap { margin-top: 20px; overflow-x: auto; }
.tunob-table { width: 100%; border-collapse: collapse; font-size: .92em; }
.tunob-table caption { text-align: left; font-weight: 600; padding-bottom: 6px; }
.tunob-table th { text-align: left; font-weight: 600; color: var(--tunob-text-2); border-bottom: 1px solid var(--tunob-border); padding: 6px 8px; white-space: nowrap; }
.tunob-total th, .tunob-total td { border-top: 2px solid var(--tunob-text); border-bottom: 0; padding: 8px; font-weight: 700; text-align: left; color: var(--tunob-text); background: var(--tunob-surface-2); }
.tunob-table td { border-bottom: 1px solid var(--tunob-border); padding: 6px 8px; vertical-align: top; }
.tunob-table tr.is-selected td { background: var(--tunob-surface-2); }
.tunob-sort { border: 0; background: none; padding: 0; font: inherit; font-weight: 600; color: inherit; cursor: pointer; white-space: nowrap; }
.tunob-sort:hover, .tunob-sort.is-on { color: var(--tunob-accent); }
.tunob-sort-icon { font-size: .8em; opacity: .7; }
.tunob-num { text-align: right !important; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tunob-td-code { color: var(--tunob-muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.tunob-td-name { min-width: 200px; }
.tunob-bar { display: block; height: 4px; background: var(--tunob-surface-2); border-radius: 2px; margin-top: 4px; }
.tunob-bar > span { display: block; height: 100%; background: var(--tunob-accent); border-radius: 2px; }

.tunob-foot { margin-top: 14px; font-size: .8em; color: var(--tunob-muted); }
.tunob-foot a { color: inherit; }

@media (max-width: 899px) {
	.tunob-body { grid-template-columns: 1fr; grid-template-areas: "tree" "map" "panel"; }
	.tunob-tree-list { max-height: 360px; }
	.tunob-nav-btn { padding: 6px 10px; }
	.tunob-panel { max-height: none; }
}
@media (max-width: 560px) {
	.tunob { padding: 14px; border-radius: 0; border-left: 0; border-right: 0; }
	.tunob .tunob-title { font-size: 1.3em; }
	.tunob-ctl, .tunob-ctl .tunob-select { width: 100%; }
	.tunob-ctl-version .tunob-select { max-width: none; }
	.tunob-seg { width: 100%; }
	.tunob-seg-btn { flex: 1; }
	.tunob-table .tunob-td-code { display: none; }
	.tunob-table th:first-child { display: none; }
}
@media (prefers-reduced-motion: reduce) {
	.tunob-layer.is-animating, .tunob-tile { transition: none; }
}
