/*
 * Huoltoportaali – käyttöliittymän tyylit.
 * Kaikki tyylit on rajattu .hp-app-luokan alle, jotta ne toimivat minkä tahansa teeman kanssa.
 */

.hp-app {
	--hp-accent: #1a6dd8;
	--hp-bg: #f5f7fa;
	--hp-card: #ffffff;
	--hp-text: #1d2430;
	--hp-muted: #667085;
	--hp-line: #e4e7ec;
	--hp-radius: 12px;
	--hp-shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
	--hp-done: #067647;
	--hp-done-bg: #ecfdf3;
	--hp-wait: #b54708;
	--hp-wait-bg: #fffaeb;
	--hp-open: #175cd3;
	--hp-open-bg: #eff8ff;

	box-sizing: border-box;
	color: var(--hp-text);
	font-family: inherit;
	font-size: 15px;
	line-height: 1.5;
	text-align: left;
	max-width: 100%;
}

.hp-app *,
.hp-app *::before,
.hp-app *::after {
	box-sizing: border-box;
}

.hp-app h1,
.hp-app h2,
.hp-app h3,
.hp-app h4,
.hp-app p,
.hp-app dl,
.hp-app dd,
.hp-app ul {
	margin: 0;
	padding: 0;
	letter-spacing: normal;
	text-transform: none;
}

.hp-app ul {
	list-style: none;
}

/* ---------- Otsikko ---------- */

.hp-header {
	display: flex;
	align-items: center;
	gap: 14px;
	flex-wrap: wrap;
	margin-bottom: 20px;
}

.hp-logo {
	height: 40px;
	width: auto;
}

.hp-app .hp-title {
	font-size: 26px;
	font-weight: 700;
	line-height: 1.2;
	color: var(--hp-text);
	flex: 1 1 auto;
}

.hp-user {
	display: flex;
	align-items: center;
	gap: 12px;
	font-size: 14px;
}

.hp-company {
	background: var(--hp-bg);
	border: 1px solid var(--hp-line);
	border-radius: 999px;
	padding: 4px 12px;
	font-weight: 600;
}

.hp-app a.hp-logout {
	white-space: nowrap;
	color: var(--hp-muted);
	text-decoration: underline;
}

/* ---------- Painikkeet ja kentät ---------- */

.hp-app .hp-btn,
.hp-app .hp-seg-btn,
.hp-app .hp-icon-btn,
.hp-app .hp-sort,
.hp-app .hp-link {
	font: inherit;
	font-size: 14px;
	line-height: 1.2;
	cursor: pointer;
	text-transform: none;
	letter-spacing: normal;
	box-shadow: none;
	margin: 0;
	min-height: 0;
	width: auto;
}

.hp-app .hp-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 6px;
	padding: 10px 16px;
	border-radius: 8px;
	border: 1px solid var(--hp-line);
	background: var(--hp-card);
	color: var(--hp-text);
	font-weight: 600;
	white-space: nowrap;
}

.hp-app .hp-btn:hover {
	border-color: var(--hp-accent);
	color: var(--hp-accent);
}

.hp-app .hp-btn:disabled {
	opacity: .5;
	cursor: default;
}

.hp-app .hp-btn-primary,
.hp-app .hp-btn-primary:hover {
	background: var(--hp-accent);
	border-color: var(--hp-accent);
	color: #fff;
}

.hp-app .hp-btn-primary:hover {
	filter: brightness(1.08);
}

.hp-app .hp-icon-btn {
	width: 40px;
	height: 40px;
	border-radius: 8px;
	border: 1px solid var(--hp-line);
	background: var(--hp-card);
	color: var(--hp-text);
	font-size: 16px;
	padding: 0;
	display: inline-flex;
	align-items: center;
	justify-content: center;
}

.hp-app .hp-link {
	background: none;
	border: 0;
	padding: 0 0 0 8px;
	color: var(--hp-accent);
	text-decoration: underline;
	font-weight: 500;
}

.hp-app .hp-input {
	font: inherit;
	font-size: 15px;
	line-height: 1.3;
	height: 42px;
	padding: 8px 12px;
	border: 1px solid var(--hp-line);
	border-radius: 8px;
	background: var(--hp-card);
	color: var(--hp-text);
	margin: 0;
	box-shadow: none;
	max-width: 100%;
}

.hp-app .hp-input:focus,
.hp-app .hp-btn:focus-visible,
.hp-app .hp-seg-btn:focus-visible,
.hp-app .hp-icon-btn:focus-visible,
.hp-app .hp-sort:focus-visible,
.hp-app .hp-row:focus-visible {
	outline: 2px solid var(--hp-accent);
	outline-offset: 1px;
	border-color: var(--hp-accent);
}

/* ---------- Työkalurivi ---------- */

.hp-toolbar {
	background: var(--hp-card);
	border: 1px solid var(--hp-line);
	border-radius: var(--hp-radius);
	box-shadow: var(--hp-shadow);
	padding: 16px;
	display: flex;
	flex-direction: column;
	gap: 12px;
	margin-bottom: 16px;
}

.hp-search {
	display: flex;
	gap: 8px;
	margin: 0;
}

.hp-app .hp-search-input {
	flex: 1 1 auto;
	height: 46px;
	font-size: 16px;
}

.hp-search .hp-btn {
	height: 46px;
	padding: 0 22px;
}

.hp-filters {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 10px;
}

.hp-seg {
	display: inline-flex;
	background: var(--hp-bg);
	border: 1px solid var(--hp-line);
	border-radius: 10px;
	padding: 3px;
	gap: 2px;
}

.hp-app .hp-seg-btn {
	border: 0;
	background: transparent;
	color: var(--hp-muted);
	padding: 8px 12px;
	border-radius: 7px;
	font-weight: 600;
	white-space: nowrap;
}

.hp-app .hp-seg-btn:hover {
	color: var(--hp-text);
}

.hp-app .hp-seg-btn.is-on {
	background: var(--hp-card);
	color: var(--hp-accent);
	box-shadow: var(--hp-shadow);
}

.hp-days {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	font-size: 14px;
	color: var(--hp-muted);
	margin: 0;
}

.hp-app .hp-days-input {
	width: 80px;
	height: 38px;
}

.hp-app .hp-company-select {
	height: 38px;
	padding-top: 4px;
	padding-bottom: 4px;
	min-width: 200px;
}

/* ---------- Lista ---------- */

.hp-listbar {
	display: flex;
	flex-wrap: wrap;
	justify-content: space-between;
	align-items: center;
	gap: 12px;
	margin-bottom: 10px;
}

.hp-listinfo {
	display: flex;
	flex-direction: column;
}

.hp-muted {
	color: var(--hp-muted);
	font-size: 14px;
}

.hp-listtools {
	display: flex;
	gap: 8px;
}

.hp-app .hp-filter {
	width: 240px;
}

.hp-card {
	background: var(--hp-card);
	border: 1px solid var(--hp-line);
	border-radius: var(--hp-radius);
	box-shadow: var(--hp-shadow);
	padding: 18px;
}

.hp-empty,
.hp-notice {
	text-align: center;
	color: var(--hp-muted);
	padding: 32px 18px;
}

.hp-more {
	display: flex;
	flex-wrap: wrap;
	justify-content: center;
	align-items: center;
	gap: 12px;
	margin-top: 14px;
}

.hp-app .hp-more .hp-link {
	padding: 0;
}

.hp-error {
	color: #b42318;
	background: #fef3f2;
	border-color: #fecdca;
}

.hp-table-wrap {
	background: var(--hp-card);
	border: 1px solid var(--hp-line);
	border-radius: var(--hp-radius);
	box-shadow: var(--hp-shadow);
	overflow-x: auto;
}

.hp-app .hp-table {
	width: 100%;
	border-collapse: collapse;
	border: 0;
	margin: 0;
	font-size: 14px;
	background: transparent;
}

.hp-app .hp-table th,
.hp-app .hp-table td {
	padding: 10px 12px;
	border: 0;
	border-bottom: 1px solid var(--hp-line);
	text-align: left;
	vertical-align: middle;
	background: transparent;
}

.hp-app .hp-table th {
	background: var(--hp-bg);
	font-weight: 600;
	white-space: nowrap;
	position: sticky;
	top: 0;
}

.hp-app .hp-table tbody tr:last-child td {
	border-bottom: 0;
}

.hp-app .hp-table .hp-num {
	text-align: right;
	white-space: nowrap;
	font-variant-numeric: tabular-nums;
}

.hp-app .hp-sort {
	background: none;
	border: 0;
	padding: 0;
	color: var(--hp-muted);
	font-weight: 600;
	font-size: 13px;
}

.hp-app .hp-sort.is-on {
	color: var(--hp-text);
}

.hp-row {
	cursor: pointer;
	transition: background-color .12s;
}

.hp-app .hp-row:hover td,
.hp-app .hp-row.is-open td {
	background: var(--hp-open-bg);
}

.hp-num-link {
	color: var(--hp-accent);
	font-weight: 600;
	white-space: nowrap;
}

.hp-badge {
	display: inline-block;
	padding: 2px 10px;
	border-radius: 999px;
	font-size: 12px;
	font-weight: 600;
	line-height: 1.6;
	white-space: nowrap;
	vertical-align: middle;
	background: var(--hp-bg);
	color: var(--hp-muted);
}

.hp-st-done { background: var(--hp-done-bg); color: var(--hp-done); }
.hp-st-wait { background: var(--hp-wait-bg); color: var(--hp-wait); }
.hp-st-open { background: var(--hp-open-bg); color: var(--hp-open); }

/* Latausanimaatio */
.hp-skeleton {
	display: flex;
	flex-direction: column;
	gap: 12px;
}

.hp-sk-row {
	height: 18px;
	border-radius: 6px;
	background: linear-gradient(90deg, var(--hp-bg) 0%, var(--hp-line) 50%, var(--hp-bg) 100%);
	background-size: 200% 100%;
	animation: hp-shimmer 1.2s infinite linear;
}

.hp-sk-row:nth-child(3n) { width: 70%; }
.hp-sk-row:nth-child(3n+1) { width: 90%; }

@keyframes hp-shimmer {
	from { background-position: 200% 0; }
	to { background-position: -200% 0; }
}

.hp-loading {
	color: var(--hp-muted);
	padding: 24px 0;
}

/* ---------- Sivupaneeli ---------- */

.hp-drawer[hidden] {
	display: none;
}

.hp-drawer {
	position: fixed;
	inset: 0;
	z-index: 100000;
}

.hp-overlay {
	position: absolute;
	inset: 0;
	background: rgba(16, 24, 40, .45);
	opacity: 0;
	transition: opacity .2s;
}

.hp-panel {
	position: absolute;
	top: 0;
	right: 0;
	bottom: 0;
	width: min(880px, 100%);
	background: var(--hp-bg);
	box-shadow: -8px 0 24px rgba(16, 24, 40, .18);
	transform: translateX(100%);
	transition: transform .22s ease;
	overflow-y: auto;
	-webkit-overflow-scrolling: touch;
}

.hp-drawer.is-open .hp-overlay { opacity: 1; }
.hp-drawer.is-open .hp-panel { transform: translateX(0); }

.hp-panel-inner {
	padding: 20px 24px 40px;
}

.hp-panel-head {
	display: flex;
	justify-content: space-between;
	align-items: flex-start;
	gap: 12px;
	flex-wrap: wrap;
	margin-bottom: 18px;
	position: sticky;
	top: -20px;
	background: var(--hp-bg);
	padding: 12px 0;
	z-index: 1;
}

.hp-app .hp-panel-title {
	font-size: 22px;
	font-weight: 700;
	line-height: 1.3;
	color: var(--hp-text);
	display: flex;
	align-items: center;
	gap: 10px;
	flex-wrap: wrap;
}

.hp-panel-sub {
	color: var(--hp-muted);
	font-size: 15px;
	margin-top: 2px;
}

.hp-panel-actions {
	display: flex;
	gap: 8px;
	align-items: center;
}

.hp-grid {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 14px;
}

.hp-span {
	grid-column: 1 / -1;
}

.hp-app .hp-card h3 {
	font-size: 13px;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: .04em;
	color: var(--hp-muted);
	margin-bottom: 12px;
}

.hp-app .hp-card h4 {
	font-size: 14px;
	font-weight: 700;
	color: var(--hp-text);
	margin: 10px 0 4px;
}

.hp-app .hp-card h4:first-of-type {
	margin-top: 0;
}

.hp-dl {
	display: flex;
	flex-direction: column;
	gap: 6px;
}

.hp-field {
	display: grid;
	grid-template-columns: 150px 1fr;
	gap: 10px;
}

.hp-field dt {
	color: var(--hp-muted);
	font-size: 14px;
}

.hp-field dd {
	font-weight: 500;
	word-break: break-word;
}

.hp-pre {
	white-space: pre-line;
}

.hp-parties {
	display: grid;
	grid-template-columns: repeat(3, 1fr);
	gap: 16px;
}

.hp-party p {
	font-size: 14px;
}

.hp-rows {
	margin-bottom: 12px;
}

.hp-card .hp-table-wrap {
	box-shadow: none;
	margin-bottom: 14px;
}

.hp-totals {
	margin-left: auto;
	width: min(320px, 100%);
	display: flex;
	flex-direction: column;
	gap: 4px;
	margin-bottom: 10px;
}

.hp-totals div {
	display: flex;
	justify-content: space-between;
	font-variant-numeric: tabular-nums;
}

.hp-totals dt {
	color: var(--hp-muted);
}

.hp-totals .hp-grand {
	border-top: 1px solid var(--hp-line);
	padding-top: 6px;
	font-size: 17px;
	font-weight: 700;
}

.hp-totals .hp-grand dt {
	color: var(--hp-text);
}

.hp-files {
	display: flex;
	flex-direction: column;
	gap: 8px;
}

.hp-app .hp-files a {
	color: var(--hp-accent);
	font-weight: 600;
	text-decoration: none;
}

.hp-app .hp-files a:hover {
	text-decoration: underline;
}

html.hp-locked,
html.hp-locked body {
	overflow: hidden;
}

/* Kirjautuminen */
.hp-login {
	max-width: 420px;
}

.hp-app .hp-h2 {
	font-size: 20px;
	margin-bottom: 12px;
}

.hp-login form p {
	margin-bottom: 12px;
}

.hp-login label {
	display: block;
	font-weight: 600;
	margin-bottom: 4px;
}

.hp-login input[type="text"],
.hp-login input[type="password"] {
	width: 100%;
	height: 42px;
	padding: 8px 12px;
	border: 1px solid var(--hp-line);
	border-radius: 8px;
	font: inherit;
}

.hp-login input[type="submit"] {
	background: var(--hp-accent);
	border: 0;
	color: #fff;
	border-radius: 8px;
	padding: 10px 20px;
	font: inherit;
	font-weight: 600;
	cursor: pointer;
}

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

@media (max-width: 760px) {
	.hp-app .hp-title { font-size: 22px; }
	.hp-filters { gap: 8px; }
	.hp-seg { width: 100%; }
	.hp-app .hp-seg-btn { flex: 1 1 0; padding: 8px 4px; }
	.hp-app .hp-company-select { width: 100%; }
	.hp-listtools { width: 100%; }
	.hp-app .hp-filter { flex: 1 1 auto; width: auto; }

	/* Taulukko korttilistaksi */
	.hp-list .hp-table-wrap { background: none; border: 0; box-shadow: none; overflow: visible; }
	.hp-app .hp-list .hp-table thead,
	.hp-app .hp-rows thead { display: none; }
	.hp-app .hp-list .hp-table,
	.hp-app .hp-list .hp-table tbody,
	.hp-app .hp-list .hp-table tr,
	.hp-app .hp-list .hp-table td,
	.hp-app .hp-rows,
	.hp-app .hp-rows tbody,
	.hp-app .hp-rows tr,
	.hp-app .hp-rows td { display: block; width: 100%; }
	.hp-app .hp-list .hp-table tr {
		background: var(--hp-card);
		border: 1px solid var(--hp-line);
		border-radius: var(--hp-radius);
		box-shadow: var(--hp-shadow);
		margin-bottom: 10px;
		padding: 10px 14px;
	}
	.hp-app .hp-rows tr { border-bottom: 1px solid var(--hp-line); padding: 6px 0; }
	.hp-app .hp-list .hp-table td,
	.hp-app .hp-rows td {
		display: flex;
		justify-content: space-between;
		gap: 12px;
		border: 0;
		padding: 4px 0;
		text-align: right;
	}
	.hp-app .hp-list .hp-table td::before,
	.hp-app .hp-rows td::before {
		content: attr(data-label);
		color: var(--hp-muted);
		text-align: left;
		font-weight: 500;
	}
	.hp-app .hp-list .hp-table td:empty { display: none; }
	.hp-app .hp-row:hover td,
	.hp-app .hp-row.is-open td { background: transparent; }
	.hp-app .hp-row.is-open { border-color: var(--hp-accent); }

	.hp-panel { width: 100%; }
	.hp-panel-inner { padding: 12px 14px 32px; }
	.hp-panel-head { top: -12px; }
	.hp-grid,
	.hp-parties { grid-template-columns: 1fr; }
	.hp-field { grid-template-columns: 120px 1fr; }
	.hp-panel-actions { width: 100%; }
	.hp-panel-actions .hp-btn { flex: 1 1 auto; }
}

/* ---------- Tulostus ---------- */

/* Tulostus: #hp-print piilossa näytöllä, näkyvissä vain tulostettaessa. */
#hp-print { display: none; }

@media print {
	html.hp-locked,
	html.hp-locked body { overflow: visible !important; height: auto !important; }
	body.hp-printing > *:not(#hp-print) { display: none !important; }
	body.hp-printing { background: #fff !important; margin: 0 !important; padding: 0 !important; }
	body.hp-printing #hp-print { display: block !important; position: static !important; font-size: 12px; }
	#hp-print .hp-panel-actions,
	#hp-print .hp-noprint { display: none !important; }
	#hp-print .hp-panel-head { position: static; }
	#hp-print .hp-card,
	#hp-print .hp-table-wrap { box-shadow: none; break-inside: avoid; }
	#hp-print .hp-grid { grid-template-columns: 1fr 1fr; }
	#hp-print .hp-parties { grid-template-columns: repeat(3, 1fr); }
}
