/* Kontor – states that inline styles cannot express (hover, focus, pressed, working), feedback infrastructure
   (progress bar, toasts, error bar, dialogs, skeletons) and responsive rules. Values come from the design. */

html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: 'Instrument Sans', Inter, system-ui, sans-serif; color: #1C1B18; background: #E9E3D6;
  -webkit-font-smoothing: antialiased; font-feature-settings: "tnum" 1, "lnum" 1; overflow-x: hidden; }
a { color: #1F4A3D; }
a:hover { color: #143228; }
[hidden] { display: none !important; }
.k-sr { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* ── Focus ─────────────────────────────────────────────────────────────────────────────────────────────── */
:focus { outline: none; }
:focus-visible { outline: 2px solid #1F4A3D; outline-offset: 2px; }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid #1F4A3D; outline-offset: -1px; }

/* ── Buttons: hover, pressed, disabled, working ─────────────────────────────────────────────────────────── */
.k-btn { transition: background-color 120ms ease, border-color 120ms ease, color 120ms ease, transform 60ms ease, box-shadow 120ms ease; -webkit-tap-highlight-color: transparent; }
.k-btn:active:not([disabled]):not([aria-disabled="true"]) { transform: translateY(1px); }
.k-btn--primary:hover:not([disabled]) { background: #143228 !important; border-color: #143228 !important; color: #FDFBF6 !important; }
.k-btn--secondary:hover:not([disabled]) { background: #F1ECE1 !important; }
.k-btn--small:hover:not([disabled]) { background: #F1ECE1 !important; }
.k-btn--primary.k-btn--small:hover:not([disabled]) { background: #143228 !important; }
.k-btn--danger:hover:not([disabled]) { background: #FBF0EC !important; }
.k-btn--link:hover:not([disabled]) { color: #143228 !important; text-decoration-thickness: 2px !important; }
.k-btn--chip:hover:not([disabled]):not([aria-pressed="true"]) { border-color: #1C1B18 !important; }
.k-btn[disabled], .k-btn[aria-disabled="true"] { opacity: 0.55; cursor: not-allowed !important; }
.k-btn[aria-busy="true"] { opacity: 0.7 !important; cursor: progress !important; }
.k-spinner { display: inline-block; flex: none; width: 14px; height: 14px; border: 2px solid rgba(253, 251, 246, 0.4); border-top-color: #FDFBF6; border-radius: 50%; box-sizing: border-box; animation: k-spin 700ms linear infinite; }
.k-btn--secondary .k-spinner, .k-btn--small .k-spinner, .k-btn--link .k-spinner, .k-btn--danger .k-spinner, .k-btn--chip .k-spinner { border-color: rgba(28, 27, 24, 0.25); border-top-color: #1C1B18; }
.k-btn--primary.k-btn--small .k-spinner { border-color: rgba(253, 251, 246, 0.4); border-top-color: #FDFBF6; }
@keyframes k-spin { to { transform: rotate(360deg); } }
[data-planned] { opacity: 0.55; cursor: not-allowed !important; }
.k-switch:hover { background: #FBF8F1 !important; }
/* Role „Nur lesen“: controls of writing forms are locked by kontor.js (data-k-locked). */
[data-k-locked] { cursor: not-allowed !important; }
input[data-k-locked], select[data-k-locked], textarea[data-k-locked] { background-color: #F1ECE1 !important; color: #8A8270 !important; -webkit-text-fill-color: #8A8270; opacity: 1; }
button[data-k-locked], label[data-k-locked], a[data-k-locked], div[data-k-locked] { opacity: 0.55; }
.k-readonly-note { margin: 0; padding: 10px 14px; background: #F7F3EA; border-left: 3px solid #B5AD9C; font-size: 13px; line-height: 1.5; color: #6A6355; }

/* ── Navigation ─────────────────────────────────────────────────────────────────────────────────────────── */
.k-nav a:hover { color: #1C1B18 !important; }
.k-subnav a:hover { color: #1C1B18 !important; }
.k-row-link { cursor: pointer; }
.k-row-link:hover { background: #F5F1E7 !important; }

/* ── Progress bar (every request) ───────────────────────────────────────────────────────────────────────── */
#k-progress { position: fixed; top: 0; left: 0; right: 0; height: 3px; z-index: 1000; pointer-events: none; opacity: 0; transition: opacity 200ms ease; }
#k-progress > span { display: block; height: 100%; width: 0; background: #1F4A3D; transition: width 300ms ease; }
#k-progress.is-active { opacity: 1; }
#k-progress.is-active > span { width: 80%; transition: width 8s cubic-bezier(0.1, 0.6, 0.2, 1); }
#k-progress.is-done > span { width: 100%; transition: width 150ms ease; }

/* ── Toasts (bottom right) ──────────────────────────────────────────────────────────────────────────────── */
#k-toasts { position: fixed; right: clamp(8px, 2.5vw, 40px); bottom: clamp(8px, 2.5vw, 40px); z-index: 1001; display: flex; flex-direction: column; align-items: flex-end; gap: 8px; pointer-events: none; }
#k-toasts > * { pointer-events: auto; animation: k-toast-in 160ms ease-out; }
#k-toasts a, #k-toasts button.k-toast-undo { color: #FDFBF6; }
#k-toasts button.k-toast-undo { border: 0; background: transparent; padding: 0; font: inherit; text-decoration: underline; cursor: pointer; min-height: 24px; }
@keyframes k-toast-in { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ── Error bar (failed request) ─────────────────────────────────────────────────────────────────────────── */
#k-errorbar { position: fixed; top: 8px; left: 50%; transform: translateX(-50%); width: min(960px, calc(100% - 24px)); z-index: 1002; box-shadow: 0 12px 40px rgba(60, 48, 25, 0.18); }
#k-errorbar .k-errorbar-close { border: 0; background: transparent; font-size: 22px; line-height: 1; cursor: pointer; padding: 4px 8px; color: inherit; min-height: 36px; }

/* ── Dialogs ────────────────────────────────────────────────────────────────────────────────────────────── */
dialog.k-dialog { border: 0; padding: 0; margin: clamp(24px, 6vw, 96px) auto auto; width: min(var(--k-dialog-width, 720px), calc(100% - 24px)); max-height: calc(100dvh - 2 * clamp(24px, 6vw, 96px)); overflow: hidden; background: #FDFBF6; border-radius: 3px; box-shadow: 0 1px 0 #D8D0BF, 0 30px 80px rgba(60, 48, 25, 0.25); color: #1C1B18; }
/* Head and footer stay, the body scrolls (footer buttons reachable at any window height). The 4px padding keeps
   focus rings of the outermost controls visible inside the scroll area. */
dialog.k-dialog .k-dialog-frame { max-height: inherit; min-height: 0; }
dialog.k-dialog .k-dialog-body { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 4px; margin: -4px; }
@media (max-height: 560px) { dialog.k-dialog { overflow: auto; } dialog.k-dialog .k-dialog-frame { max-height: none; } dialog.k-dialog .k-dialog-body { overflow: visible; } }
dialog.k-dialog::backdrop { background: rgba(233, 227, 214, 0.35); backdrop-filter: blur(10px) saturate(0.9); -webkit-backdrop-filter: blur(10px) saturate(0.9); }
dialog.k-dialog[open] { animation: k-dialog-in 140ms ease-out; }
@keyframes k-dialog-in { from { transform: translateY(6px); opacity: 0; } to { transform: none; opacity: 1; } }
/* Page scroll lock follows the real dialog state: nothing to un-set when a dialog vanishes without a close event. */
body:has(dialog[open]) { overflow: hidden; }

/* ── Skeleton rows ──────────────────────────────────────────────────────────────────────────────────────── */
.k-skeleton span[style*="background"] { animation: k-pulse 1.4s ease-in-out infinite; }
@keyframes k-pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.55; } }
.htmx-request .k-hide-while-loading, .htmx-request.k-hide-while-loading { display: none; }
.k-show-while-loading { display: none; }
.htmx-request .k-show-while-loading, .htmx-request.k-show-while-loading { display: flex; }

/* ── Form errors ────────────────────────────────────────────────────────────────────────────────────────── */
[aria-invalid="true"] { border: 1.5px solid #8A2A1C !important; }

/* ── Responsive ─────────────────────────────────────────────────────────────────────────────────────────── */
.k-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
img, svg, video { max-width: 100%; }
@media (pointer: coarse) {
  .k-btn, .k-nav a, .k-subnav a, button, select, input[type="checkbox"], input[type="radio"] { min-height: 44px; }
  .k-nav a, .k-subnav a { display: inline-flex !important; align-items: center; }
}
@media (max-width: 640px) {
  dialog.k-dialog { width: calc(100% - 24px); max-width: calc(100% - 24px); margin: 12px auto auto; max-height: calc(100dvh - 24px); border-radius: 3px; }
  .k-stack-sm { flex-direction: column !important; align-items: stretch !important; }
  #k-toasts { left: 8px; right: 8px; align-items: stretch; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; transition-duration: 1ms !important; }
}
