/* King-OP — dashboard styles. Systems-OP brand (logo colours), light + dark,
   WCAG 2.1 AA. Self-contained: does not depend on the active theme's CSS,
   but uses its self-hosted IBM Plex Sans when the Systems-OP theme is present. */

@font-face {
	font-family: "IBM Plex Sans";
	src: url("../../../themes/systems-op-theme/assets/fonts/ibm-plex-sans.woff2") format("woff2");
	font-weight: 100 700;
	font-display: swap;
}

:root {
	color-scheme: light dark;
	--navy: #001024;
	--royal: #075aea;   /* accent: 5.7:1 on white */
	--sky: #2b93ff;     /* decoration, text on navy only */
	--bg: #f4f6fa;
	--surface: #ffffff;
	--surface-2: #eaf0f8;
	--text: #13202f;
	--text-2: #47525c;
	--mute: #55606c;
	--heading: #001024;
	--line: #d3dbe6;
	--line-strong: #75818f;
	--accent: var(--royal);
	--accent-hover: #0047c2;
	--accent-text: var(--royal);
	--on-accent: #ffffff;
	--ok-text: #146c3a;
	--ok-tint: #e6f4ec;
	--warn-text: #8a4b00;
	--warn-tint: #fff4e0;
	--err-text: #b42318;
	--err-tint: #fdeceb;
	--info-tint: #e3ecfd;
	--focus: var(--royal);
	--font: "IBM Plex Sans", ui-sans-serif, "Segoe UI", "Helvetica Neue", Arial, sans-serif;
	--r: 10px;
	--r-lg: 16px;
	--shadow: 0 1px 2px rgb(0 16 36 / 0.06), 0 8px 24px rgb(0 16 36 / 0.06);
	--pad: clamp(16px, 4vw, 32px);
}
@media (prefers-color-scheme: dark) {
	:root {
		--bg: #030d1d;
		--surface: #081629;
		--surface-2: #0b1d35;
		--text: #e1e8f1;
		--text-2: #b5c1d0;
		--mute: #9aa8ba;
		--heading: #f3f6fa;
		--line: #1b2e48;
		--line-strong: #6a7f9b;
		--accent-hover: #1a66ec; /* white text 5.05:1 (was #2a74f5 = 4.27, failed AA on hover) */
		--accent-text: #5aa8ff;
		--ok-text: #7fd6a1;
		--ok-tint: #0f2c1d;
		--warn-text: #ffc46b;
		--warn-tint: #33240b;
		--err-text: #ff9b91;
		--err-tint: #3a1414;
		--info-tint: #0f2a52;
		--focus: #5aa8ff;
		--shadow: 0 1px 2px rgb(0 0 0 / 0.4), 0 8px 24px rgb(0 0 0 / 0.35);
	}
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body.kop { margin: 0; min-height: 100vh; display: flex; flex-direction: column; background: var(--bg); color: var(--text); font: 400 1rem/1.6 var(--font); -webkit-font-smoothing: antialiased; }
button, input, select { font: inherit; color: inherit; }
img { display: block; max-width: 100%; height: auto; }
h1, h2, h3 { margin: 0 0 0.4em; color: var(--heading); font-weight: 600; line-height: 1.2; letter-spacing: -0.01em; }
h1 { font-size: clamp(1.5rem, 1.2rem + 1.2vw, 2rem); }
h2 { font-size: 1.1875rem; }
p { margin: 0 0 1em; }
a { color: var(--accent-text); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 3px; }
main:focus { outline: none; }
.kop-sr { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.kop-skip { position: absolute; left: 12px; top: -80px; z-index: 10; padding: 10px 16px; border-radius: 6px; background: var(--accent); color: var(--on-accent); font-weight: 600; text-decoration: none; }
.kop-skip:focus { top: 12px; }
.kop-muted { color: var(--text-2); }
.kop-center { text-align: center; }
.kop-wrap { width: 100%; max-width: 1240px; margin-inline: auto; padding-inline: var(--pad); }

/* Buttons */
.kop-btn {
	display: inline-flex; align-items: center; justify-content: center; gap: 8px;
	min-height: 44px; padding: 10px 18px; border: 1px solid var(--accent); border-radius: 8px;
	background: var(--accent); color: var(--on-accent); font-weight: 600; text-decoration: none; cursor: pointer; white-space: nowrap;
}
.kop-btn:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.kop-btn--ghost { background: transparent; color: var(--heading); border-color: var(--line-strong); }
.kop-btn--ghost:hover { background: var(--surface-2); border-color: var(--heading); }
.kop-btn--sm { min-height: 40px; padding: 8px 14px; font-size: 0.9375rem; }
.kop-btn--block { width: 100%; }

/* Sign-in */
.kop-auth { flex: 1; display: grid; place-items: center; padding: 32px var(--pad); }
.kop-auth__card { width: 100%; max-width: 440px; padding: clamp(24px, 5vw, 40px); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow); }
.kop-auth__brand { display: flex; align-items: center; gap: 12px; margin-bottom: 28px; }
.kop-auth__brand img, .kop-bar__brand img { height: 40px; width: auto; }
.kop-auth__product { padding: 3px 10px; border-radius: 999px; background: var(--navy); color: #ffffff; font-size: 0.8125rem; font-weight: 600; letter-spacing: 0.02em; }
@media (prefers-color-scheme: dark) { .kop-auth__product { background: #0f2a52; border: 1px solid var(--line-strong); } }
@media print { .kop-auth__product { background: #001024 !important; border: 0; } }
.kop-wordmark { font-size: 1.25rem; font-weight: 700; color: var(--heading); }
.kop-wordmark span { color: var(--accent-text); }
.kop-form { display: grid; gap: 18px; margin-top: 20px; }
.kop-field { display: grid; gap: 6px; }
.kop-field label { font-weight: 600; font-size: 0.9375rem; color: var(--heading); }
.kop-field input { width: 100%; min-height: 48px; padding: 10px 14px; border: 1px solid var(--line-strong); border-radius: 6px; background: var(--surface); font-size: 1rem; }
.kop-field input#kop-code { font-size: 1.375rem; letter-spacing: 0.3em; text-align: center; }
.kop-alert { margin: 16px 0 0; padding: 12px 14px; border-radius: 8px; background: var(--info-tint); color: var(--text); }
.kop-alert--error { background: var(--err-tint); color: var(--err-text); font-weight: 500; }
.kop-steps { margin: 4px 0 0; padding-left: 1.25em; display: grid; gap: 12px; }
.kop-qr { width: 196px; height: 196px; margin: 12px 0; padding: 8px; background: #ffffff; border-radius: 8px; border: 1px solid var(--line); }
.kop-qr img, .kop-qr svg { width: 100%; height: 100%; }
.kop-key code { display: inline-block; padding: 8px 12px; border-radius: 6px; background: var(--surface-2); font: 600 1rem/1.4 ui-monospace, Menlo, monospace; letter-spacing: 0.06em; overflow-wrap: anywhere; }

/* Top bar */
.kop-bar { background: var(--surface); border-bottom: 1px solid var(--line); }
.kop-bar__in { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 68px; }
.kop-bar__brand { display: inline-flex; align-items: center; gap: 12px; text-decoration: none; }
.kop-bar__right { display: flex; align-items: center; gap: 14px; }
@media (max-width: 560px) { .kop-hide-sm { display: none; } }

/* Dashboard */
.kop-dash { flex: 1; padding-block: 28px 48px; }
.kop-dash__head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 16px 32px; margin-bottom: 24px; }
.kop-dash__head p { margin: 0; }
.kop-period { display: flex; align-items: center; gap: 10px; }
.kop-period label { font-weight: 600; font-size: 0.9375rem; }
.kop-period select { min-height: 44px; padding: 8px 12px; border: 1px solid var(--line-strong); border-radius: 6px; background: var(--surface); }
.js .kop-js-hide { display: none; }
.kop-banner { margin: 0 0 20px; padding: 12px 16px; border-radius: var(--r); background: var(--info-tint); color: var(--text); }
.kop-grid { display: grid; gap: 20px; }
@media (min-width: 980px) { .kop-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } .kop-panel--wide { grid-column: 1 / -1; } }
.kop-panel { min-width: 0; padding: clamp(18px, 2.5vw, 26px); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow); }
.kop-panel__head { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 12px 20px; margin-bottom: 18px; }
.kop-panel__head p { margin: 0; color: var(--text-2); font-size: 0.9375rem; max-width: 46ch; }
.kop-state { margin: 0 0 16px; padding: 10px 14px; border-radius: 8px; font-size: 0.9375rem; }
.kop-state--wait { background: var(--info-tint); color: var(--text); }
.kop-state--warn { background: var(--warn-tint); color: var(--warn-text); font-weight: 500; }
.kop-metrics { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; margin: 0; }
.kop-metric { padding: 14px 16px; border-radius: var(--r); background: var(--surface-2); }
.kop-metric dt { color: var(--text-2); font-size: 0.875rem; }
.kop-metric dd { margin: 2px 0 0; color: var(--heading); font-size: 1.625rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.kop-metrics--placeholder dd { color: var(--mute); }
.kop-metric dd.kop-change { display: block; margin: 2px 0 0; font-size: 0.8125rem; font-weight: 500; color: var(--text-2); }
.kop-metric dd.kop-change--up { color: var(--ok-text); }
.kop-metric dd.kop-change--down { color: var(--err-text); }
.kop-sub { margin: 20px 0 10px; font-size: 1rem; }
.kop-metric--small { font-size: 1.0625rem !important; font-weight: 500 !important; color: var(--text-2) !important; }
.kop-breakdowns { display: grid; gap: 4px 32px; }
@media (min-width: 760px) { .kop-breakdowns { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.kop-bars { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.kop-bars li { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(48px, 1.4fr) auto; align-items: center; gap: 12px; font-size: 0.9375rem; }
.kop-bars__label { min-width: 0; overflow-wrap: anywhere; }
.kop-bars__track { height: 8px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.kop-bars__track span { display: block; height: 100%; border-radius: 999px; background: var(--accent); }
.kop-bars__value { font-variant-numeric: tabular-nums; font-weight: 600; color: var(--heading); }
.kop-note, .kop-empty { margin: 14px 0 0; color: var(--text-2); font-size: 0.875rem; }
.kop-table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--r); }
.kop-table { width: 100%; min-width: 560px; border-collapse: collapse; font-size: 0.9375rem; }
.kop-table th, .kop-table td { padding: 11px 14px; text-align: left; border-bottom: 1px solid var(--line); }
.kop-table th { background: var(--surface-2); color: var(--heading); font-weight: 600; }
.kop-table tr:last-child td { border-bottom: 0; }
.kop-badge { display: inline-block; padding: 2px 10px; border-radius: 999px; background: var(--surface-2); color: var(--text); font-size: 0.8125rem; font-weight: 600; }
.kop-badge--active { background: var(--ok-tint); color: var(--ok-text); }
.kop-table-ph { display: grid; gap: 8px; }
.kop-table-ph span { display: block; height: 40px; border-radius: 8px; background: repeating-linear-gradient(45deg, var(--surface-2), var(--surface-2) 10px, var(--surface) 10px, var(--surface) 20px); border: 1px dashed var(--line); }
.kop-panel--report { grid-column: 1 / -1; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 16px 24px; }
.kop-panel--report .kop-panel__head { margin: 0; }

/* Report */
.kop-report { flex: 1; width: 100%; max-width: 980px; margin-inline: auto; padding: 28px var(--pad) 48px; display: grid; gap: 18px; }
.kop-report__tools { display: flex; flex-wrap: wrap; gap: 10px; }
.kop-report__head { display: flex; align-items: center; gap: 20px; padding-bottom: 16px; border-bottom: 2px solid var(--navy); }
.kop-report__head img { height: 48px; width: auto; }
.kop-report__head p { margin: 0; }

/* Footer */
.kop-foot { padding: 18px var(--pad) 26px; border-top: 1px solid var(--line); color: var(--text-2); font-size: 0.875rem; }
.kop-foot p { max-width: 1240px; margin: 0 auto; display: flex; flex-wrap: wrap; gap: 6px 20px; }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
@media print {
	:root { color-scheme: light; --surface: #ffffff; --surface-2: #f1f4f8; --text: #13202f; --text-2: #47525c; --heading: #001024; --line: #c8d0db; --accent-text: #075aea; }
	body.kop { background: #ffffff; color: #000000; }
	.kop-noprint, .kop-skip, .kop-foot { display: none !important; }
	.kop-panel { box-shadow: none; break-inside: avoid; border-color: #c8d0db; }
	.kop-metric { background: #f1f4f8; }
}
