/*
 * Portal styles, built from the Kurt König design system's component cards (EP page
 * pattern). Each block names the KK component it follows; values are the cards' values.
 * Strokes sit inside (inset box-shadows), corners are radius 4, almost nothing casts a
 * shadow, and colour carries meaning only.
 */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 20px;
  color: var(--text);
  background: var(--surface-base);
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}
.kk-icon { display: inline-flex; flex: none; line-height: 0; }
.muted { color: var(--text-secondary); }
.error-text { color: var(--text); }

/* ---------------------------------------------------------------- Header (variant="ep") */
.app-header {
  display: flex; align-items: center; gap: var(--space-24);
  height: var(--header); padding: 0 var(--space-28);
  background: var(--surface-dark); color: var(--text-on-dark);
  position: sticky; top: 0; z-index: 10;
}
.app-header .home { display: inline-flex; line-height: 0; }
.app-header .home img { height: 28px; width: auto; }
.app-header .spacer { flex: 1; }
.app-header .user { font-weight: 500; }
.avatar {
  display: inline-flex; align-items: center; justify-content: center; flex: none;
  width: 48px; height: 48px; border-radius: var(--radius-pill);
  background: var(--black-600); color: var(--black-1500); font-weight: 500; font-size: 20px; line-height: 24px;
}

/* ---------------------------------------------------------------- Button */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-8);
  min-height: var(--control-l); padding: var(--space-16) var(--space-24);
  border: 0; border-radius: var(--radius-4); cursor: pointer; text-decoration: none;
  font-size: 20px; line-height: 24px; font-weight: 700;
  background: var(--action-primary); color: var(--text-on-dark);
}
.btn:hover { background: var(--action-primary-hover); }
.btn-s { min-height: var(--control-s); padding: var(--space-8) var(--space-16); }
.btn-secondary { background: transparent; color: var(--text); font-weight: 500; box-shadow: inset 0 0 0 2px var(--black-1500); }
.btn-secondary.btn-s { min-height: var(--input-48); }
.btn-secondary:hover { background: transparent; box-shadow: inset 0 0 0 2px var(--action-secondary-hover); }
.btn-secondary:focus-visible { box-shadow: var(--focus-ring); }
.btn-text { background: transparent; color: var(--text); font-weight: 500; padding-inline: 0; min-height: var(--control-s); }
.btn-text:hover { background: transparent; text-decoration: underline; }
.btn-text:focus-visible { box-shadow: var(--focus-ring-text); }
.btn-white { background: transparent; color: var(--text-on-dark); font-weight: 500; padding-inline: var(--space-8); }
.btn-white:hover { background: var(--surface-dark-hover); }
.btn[disabled] { background: var(--action-disabled); color: var(--white); cursor: not-allowed; }
.btn-primary { background: var(--action-primary); color: var(--text-on-dark); }
.btn-ghost { background: transparent; color: var(--text); padding: var(--space-8); min-height: var(--control-s); }
.btn-ghost:hover { background: var(--surface-input); }

/* ---------------------------------------------------------------- simple pages */
.page-narrow {
  max-width: 34rem; margin: var(--space-48) auto; padding: var(--space-48);
  background: var(--surface-card); border-radius: var(--radius-4); box-shadow: inset 0 0 0 1px var(--border);
}
.page-narrow h1 { font-size: 30px; line-height: 36px; margin: 0 0 var(--space-24); }
.persona-list { display: grid; gap: var(--space-8); margin: var(--space-24) 0 0; padding: 0; list-style: none; }
.persona-list .btn { width: 100%; justify-content: flex-start; }
.field { display: grid; gap: var(--space-8); margin-bottom: var(--space-16); color: var(--text-label); }
.field input, .search select, .date-form input {
  min-height: var(--input-48); padding: 0 var(--space-16);
  border: 0; border-radius: var(--radius-4); background: var(--surface-input);
  color: var(--text); font-weight: 500; font-size: 18px; line-height: 22px;
}
.field input:hover, .search select:hover, .date-form input:hover { background: var(--surface-input-hover); }
.field input:focus-visible, .search select:focus-visible, .date-form input:focus-visible { box-shadow: inset 0 0 0 2px var(--focus); }
.page-wide { max-width: var(--content-1440); margin: var(--space-40) auto; padding: 0 var(--space-60); }
.page-wide h1 { font-size: 40px; line-height: 48px; margin: 0 0 var(--space-24); }
.page-wide h2 { font-size: 24px; line-height: 30px; margin: var(--space-32) 0 var(--space-12); }
.page-wide table { border-collapse: collapse; width: 100%; font-size: 16px; line-height: 20px; }
.page-wide th { text-align: left; height: 56px; padding: 0 var(--space-16); background: var(--surface-dark-raised); color: var(--text-on-dark); font-weight: 700; }
.page-wide td { height: 52px; padding: 0 var(--space-16); }
.page-wide tbody tr:nth-child(even) td { background: var(--surface-input); }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: var(--space-8) var(--space-24); margin: 0; }
.facts dt { color: var(--text-secondary); }
.facts dd { margin: 0; }

/* EP login: surface-dark page, white card */
.login-page {
  min-height: 100vh; background: var(--surface-dark); padding: var(--space-48) var(--space-16);
  display: flex; flex-direction: column; align-items: center; gap: var(--space-32);
}
.login-mark { height: 40px; width: auto; }
.login-page .page-narrow { margin: 0; width: 100%; box-shadow: none; }

/* ---------------------------------------------------------------- page head */
.page-head {
  max-width: var(--content-1440); margin: 0 auto; padding: var(--space-40) var(--space-60) 0;
  display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: var(--space-12) var(--space-24);
}
.page-head h1 { margin: 0; font-size: 40px; line-height: 48px; font-weight: 700; }
.page-head .meta { display: flex; align-items: center; gap: var(--space-12); color: var(--text-secondary); }

/* ---------------------------------------------------------------- Tag (kind="outline") */
.tag {
  display: inline-flex; align-items: center; padding: 2px var(--space-8);
  border-radius: var(--radius-4); box-shadow: inset 0 0 0 1px var(--black-800);
  font-size: 12px; line-height: 16px; font-weight: 500; color: var(--text); white-space: nowrap;
}

/* ---------------------------------------------------------------- team funnel (EP dark block) */
.funnel-band { background: var(--surface-dark-raised); color: var(--text-on-dark); }
.funnel {
  max-width: var(--content-1440); margin: 0 auto; padding: var(--space-24) var(--space-60);
  display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 1px;
}
.funnel-lane { display: grid; gap: var(--space-4); padding: var(--space-16) var(--space-20); background: var(--surface-dark-raised); box-shadow: inset 0 0 0 1px var(--border-on-dark); }
.funnel-label { color: var(--text-on-dark-muted); font-size: 14px; line-height: 18px; }
.funnel-count { font-weight: 700; font-size: 30px; line-height: 36px; }
.funnel-value { font-size: 16px; line-height: 20px; }

/* ---------------------------------------------------------------- SearchInput + owner filter */
.search {
  max-width: var(--content-1440); margin: 0 auto; padding: var(--space-24) var(--space-60) 0;
  display: flex; flex-wrap: wrap; gap: var(--space-16); align-items: flex-end;
}
.search-field { position: relative; flex: 1 1 24rem; }
.search-field .kk-icon { position: absolute; left: var(--space-16); top: 12px; pointer-events: none; }
.search input[type="search"] {
  width: 100%; height: var(--control-l); padding: 0 var(--space-16) 0 64px;
  border: 0; border-radius: var(--radius-4); background: var(--surface-input);
  font-size: 24px; line-height: 30px; color: var(--text);
}
.search input[type="search"]::placeholder { color: var(--text-placeholder); }
.search input[type="search"]:hover { background: var(--surface-input-hover); }
.search input[type="search"]:focus-visible { background: var(--surface-input-hover); box-shadow: inset 0 0 0 2px var(--focus); }
.search select { height: var(--control-l); flex: 0 1 20rem; }
#filter-state { display: none; }  /* hidden inputs only; still submitted */

/* ---------------------------------------------------------------- board */
.board { max-width: var(--content-1440); margin: 0 auto; padding: var(--space-24) var(--space-60) var(--space-60); }

/* Chip (filter chip): 40 px pill, 2 px outline inside, Medium 18/22 */
.heute, .filter-chips {
  display: flex; flex-wrap: wrap; gap: var(--space-8); padding-bottom: var(--space-12);
}
.filter-chips { border-bottom: 1px solid var(--border-subtle); margin-bottom: var(--space-24); }
.heute-chip, .filter-chip {
  flex: none; display: inline-flex; align-items: center; gap: var(--space-8);
  min-height: var(--control-s); padding: var(--space-8) var(--space-16);
  border: 0; border-radius: var(--radius-20); box-shadow: inset 0 0 0 2px var(--black-1500);
  background: var(--surface-base); text-decoration: none; white-space: nowrap; cursor: pointer;
  font-size: 18px; line-height: 22px; font-weight: 500; color: var(--text);
}
.heute-chip:hover, .filter-chip:hover { background: var(--black-300); }
.heute-chip[aria-pressed="true"], .filter-chip[aria-pressed="true"] { background: var(--black-1500); color: var(--text-on-dark); }
.heute-chip:focus-visible, .filter-chip:focus-visible { box-shadow: inset 0 0 0 4px var(--focus); }
.heute-chip[aria-pressed="true"] .kk-icon { color: var(--text-on-dark); }
.chip-divider { width: 1px; align-self: stretch; background: var(--border); margin: 0 var(--space-8); }
.reset { align-self: center; padding: 0 var(--space-8); text-decoration: underline; font-weight: 500; }
.empty { color: var(--text-secondary); padding: var(--space-16) 0; }

.row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--space-24); align-items: start; }
.row-closed-lanes { grid-template-columns: repeat(2, minmax(0, 1fr)); margin-top: var(--space-16); }
.lane { background: var(--surface-input); border-radius: var(--radius-4); padding: var(--space-16); min-height: 8rem; }
.lane h2 { font-size: 20px; line-height: 24px; font-weight: 700; margin: 0 0 var(--space-12); display: flex; gap: var(--space-8); align-items: baseline; }
.lane-count { color: var(--text-secondary); font-weight: 400; font-size: 16px; line-height: 20px; }
.lane-cards { display: grid; gap: var(--space-12); }
.lane-empty { color: var(--text-secondary); margin: 0; padding: var(--space-16); text-align: center; }
.lane-tabs { display: none; }

.card {
  display: grid; gap: var(--space-8); padding: var(--space-16);
  background: var(--surface-card); border-radius: var(--radius-4); box-shadow: inset 0 0 0 1px var(--border);
  cursor: pointer;
}
.card:hover { box-shadow: inset 0 0 0 1px var(--black-900); }
.card:focus-visible { box-shadow: var(--focus-ring); }
.card p { margin: 0; }
.card-firma { font-weight: 700; font-size: 18px; line-height: 22px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-firma.muted { font-weight: 400; color: var(--text-secondary); }
.card-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-secondary); }
.card-meta { display: flex; justify-content: space-between; align-items: center; gap: var(--space-12); font-size: 14px; line-height: 18px; }
.value { font-weight: 700; font-size: 16px; line-height: 20px; }
.due { display: inline-flex; align-items: center; gap: var(--space-8); }
.due-none, .due-closed { color: var(--text-secondary); }
.card-chips { display: flex; flex-wrap: wrap; gap: var(--space-8); }
.card-closed { background: var(--surface-base); }
.card-move { display: none; }

.row-closed { margin-top: var(--space-24); border-top: 1px solid var(--border-subtle); padding-top: var(--space-16); }
.closed-bar {
  display: inline-flex; align-items: center; gap: var(--space-8); min-height: var(--control-s);
  text-decoration: none; font-weight: 500; font-size: 18px; line-height: 22px;
}
.closed-bar:hover { text-decoration: underline; }

/* ---------------------------------------------------------------- Snackbar (size s) */
.toasts { position: fixed; inset: auto var(--space-24) var(--space-24) auto; display: grid; gap: var(--space-8); z-index: 50; }
.toast {
  display: flex; align-items: center; gap: var(--space-8); margin: 0;
  min-height: 64px; padding: var(--space-12) var(--space-16);
  border-radius: var(--radius-4); background: var(--surface-dark-card); color: var(--text-on-dark);
  box-shadow: var(--shadow-snackbar); font-size: 14px; line-height: 18px; font-weight: 500;
}
.toast-alert { background: var(--signal-700); }

/* ---------------------------------------------------------------- card drawer (native <dialog>) */
.sheet {
  margin: 0 0 0 auto; height: 100dvh; max-height: none; width: min(520px, 100vw);
  border: 0; padding: 0; background: var(--surface-card); color: var(--text);
}
.sheet:modal { overscroll-behavior: contain; }
.sheet::backdrop { background: var(--surface-overlay); overflow: hidden; overscroll-behavior: contain; }
.detail { display: grid; gap: var(--space-24); padding: var(--space-32) var(--space-40) var(--space-48); }
.detail-head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--space-16); }
.detail-head h2 { margin: 0; font-size: 30px; line-height: 36px; font-weight: 700; }
.detail-head form { margin: 0; }
.detail-title { margin: 0; color: var(--text-secondary); font-size: 18px; line-height: 22px; }
/* Subheadline (size s): Black 20/24 over a 2 px black-700 rule */
.detail-section h3 {
  margin: 0 0 var(--space-12); padding-bottom: var(--space-12);
  font-size: 20px; line-height: 24px; font-weight: 900;
  background: linear-gradient(var(--black-700), var(--black-700)) bottom / 100% 2px no-repeat;
}
.detail-section p { margin: 0 0 var(--space-12); }
.detail-actions { display: flex; flex-wrap: wrap; gap: var(--space-8); }
.detail-actions form { margin: 0; }
.date-form { display: flex; gap: var(--space-8); }
.close-form { margin-bottom: var(--space-12); }
.close-form summary { list-style: none; }
.close-form summary::-webkit-details-marker { display: none; }
.close-form form { padding: var(--space-16) 0; display: grid; gap: var(--space-16); }
.close-form fieldset { border: 0; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-8) var(--space-16); }
.close-form legend { color: var(--text-secondary); margin-bottom: var(--space-8); }
.lost-form:invalid button { background: var(--action-disabled); pointer-events: none; }
/* Radio: 24 px ring, 1.5 px black-1500; selected 14 px dot, ring 2 px */
.radio { display: flex; align-items: center; gap: var(--space-8); min-height: 44px; font-size: 18px; line-height: 22px; cursor: pointer; }
.radio input {
  appearance: none; margin: 0; width: 24px; height: 24px; flex: none; border-radius: var(--radius-pill);
  box-shadow: inset 0 0 0 1.5px var(--black-1500); background: var(--surface-base);
}
.radio input:checked { box-shadow: inset 0 0 0 2px var(--black-1500), inset 0 0 0 5px var(--surface-base); background: var(--black-1500); }
.radio input:hover { box-shadow: inset 0 0 0 1.5px var(--black-1500), var(--focus-ring-outer); }
.radio input:focus-visible { box-shadow: inset 0 0 0 1.5px var(--black-1500), var(--focus-ring-outer); }
.sheet-lanes { display: grid; gap: var(--space-12); }
.sheet-lanes form { margin: 0; }
.sheet-lane { width: 100%; }

/* ---------------------------------------------------------------- phone */
@media (max-width: 768px) {
  .app-header { padding: 0 var(--space-16); gap: var(--space-8); }
  .app-header .home img { height: 22px; }
  .app-header .user { display: none; }
  .app-header .avatar { width: 40px; height: 40px; font-size: 18px; line-height: 22px; }
  .page-head { padding: var(--space-16) var(--space-16) 0; }
  .page-head h1 { font-size: 25px; line-height: 30px; }
  .funnel { padding: var(--space-16); grid-template-columns: repeat(5, minmax(6rem, 1fr)); overflow-x: auto; }
  .search { padding: var(--space-12) var(--space-16) 0; }
  .search input[type="search"] { font-size: 18px; line-height: 22px; }
  .search select { flex: 1 1 100%; }
  .board { padding: var(--space-12) var(--space-16) var(--space-40); }
  .heute, .filter-chips { flex-wrap: nowrap; overflow-x: auto; margin-inline: calc(-1 * var(--space-16)); padding-inline: var(--space-16); scrollbar-width: none; }
  /* Tabs (size="mobile"): shared width, Bold 16/20, 3 px underline on the active tab */
  .lane-tabs {
    display: flex; position: sticky; top: var(--header); z-index: 5;
    background: var(--surface-base); margin: 0 calc(-1 * var(--space-16)) var(--space-12);
    border-bottom: 1px solid var(--border-subtle);
  }
  .lane-tab {
    flex: 1 1 0; display: inline-flex; align-items: center; justify-content: center; gap: var(--space-4);
    min-height: var(--control-l); text-decoration: none; font-weight: 700; color: var(--black-900);
  }
  .lane-tab[aria-pressed="true"] { color: var(--black-1500); box-shadow: inset 0 -3px 0 var(--black-1500); }
  .lane-tab:focus-visible { background: var(--black-300); }
  .row-active { grid-template-columns: 1fr; }
  .row-active .lane { display: none; }
  .row-active[data-active-lane="NEU"] .lane[data-lane="NEU"],
  .row-active[data-active-lane="IN_ARBEIT"] .lane[data-lane="IN_ARBEIT"],
  .row-active[data-active-lane="ANGEBOT"] .lane[data-lane="ANGEBOT"] { display: block; }
  .row-active .lane { background: transparent; padding: 0; }
  .row-active .lane h2 { display: none; }
  .row-closed-lanes { grid-template-columns: 1fr; }
  .card-move { display: inline-flex; justify-self: start; }
  .sheet { margin: auto 0 0; width: 100vw; max-width: none; height: 92dvh; max-height: 92dvh; border-radius: var(--radius-4) var(--radius-4) 0 0; }
  .sheet:has(.sheet-move) { height: fit-content; }
  .detail { padding: var(--space-24) var(--space-16) var(--space-32); }
  .detail-head h2 { font-size: 25px; line-height: 30px; }
  .close-form fieldset { grid-template-columns: 1fr; }
  .toasts { inset: auto var(--space-16) var(--space-16) var(--space-16); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
