:root {
  color-scheme: light;
  --bg: #f5f7fb;
  --panel: #ffffff;
  --text: #172033;
  --muted: #667085;
  --line: #e5e7eb;
  --accent: #1f6feb;
  --accent-soft: #eaf2ff;
  --header-bg: #dceaff;
  --header-text: #12315f;
  --shadow: 0 18px 45px rgba(15, 23, 42, 0.08);
  --table-height: 72vh;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: radial-gradient(circle at top left, #eaf2ff 0, transparent 34rem), var(--bg);
  color: var(--text);
}

.page-header {
  padding: 2.5rem clamp(1rem, 4vw, 4rem) 1.25rem;
}

.eyebrow {
  margin: 0 0 .5rem;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: .12em;
  font-size: .78rem;
  font-weight: 700;
}

h1 {
  margin: 0;
  font-size: clamp(2rem, 5vw, 4rem);
  line-height: 1;
}

.subtitle {
  max-width: 48rem;
  margin: 1rem 0 0;
  color: var(--muted);
  font-size: 1.05rem;
}

.container {
  width: min(1500px, calc(100% - 2rem));
  margin: 0 auto 3rem;
}

.toolbar,
.status-card,
.table-card {
  background: rgba(255, 255, 255, .92);
  border: 1px solid var(--line);
  border-radius: 1.25rem;
  box-shadow: var(--shadow);
}

.toolbar {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(180px, 260px);
  gap: 1rem;
  padding: 1rem;
  align-items: end;
}

.control-group {
  display: grid;
  gap: .4rem;
}

label {
  color: var(--muted);
  font-size: .85rem;
  font-weight: 700;
}

input,
select {
  width: 100%;
  min-height: 2.65rem;
  border: 1px solid #d0d5dd;
  border-radius: .85rem;
  background: #fff;
  color: var(--text);
  padding: .65rem .8rem;
  font: inherit;
}

input:focus,
select:focus {
  outline: 3px solid rgba(31, 111, 235, .16);
  border-color: var(--accent);
}

.status-card {
  display: none;
  margin-top: 1rem;
  padding: 1rem;
  color: var(--muted);
}

.status-card.show { display: block; }
.status-card.error { color: #b42318; background: #fff6f5; border-color: #fecdca; }
.status-card.success { color: #027a48; background: #f6fef9; border-color: #abefc6; }

.table-card {
  margin-top: 1rem;
  overflow: hidden;
}

.table-meta {
  display: flex;
  gap: .75rem;
  justify-content: space-between;
  align-items: center;
  padding: .9rem 1rem;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
}

.table-meta strong { color: var(--text); }

/*
  Fixierter Tabellenkopf nach dem Prinzip aus dem Beispiel:
  - Tabelle bleibt 100 % breit,
  - tbody ist der vertikal scrollbare Bereich,
  - die Zeilen werden als Flex-Reihen gerendert,
  - die Spalte description erhält bewusst deutlich mehr Breite,
  - die schmalen Spalten umbrechen, damit möglichst kein horizontaler Scroll entsteht.
*/
.table-wrap {
  display: block;
  overflow-x: hidden;
  overflow-y: hidden;
}

#dataTable {
  display: block;
  width: 100%;
  table-layout: fixed;
  border-collapse: separate;
  border-spacing: 0;
  background-color: #fff;
  font-size: .92rem;
}

#dataTable thead {
  display: block;
  width: 100%;
  background: var(--header-bg);
}

#dataTable thead tr,
#dataTable tbody tr {
  display: flex;
  width: 100%;
}

#dataTable tbody {
  display: block;
  width: 100%;
  max-height: var(--table-height);
  overflow-y: auto;
  overflow-x: hidden;
}

#dataTable th,
#dataTable td {
  padding: .72rem .8rem;
  border-bottom: 1px solid var(--line);
  border-right: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
  overflow-wrap: anywhere;
  word-break: break-word;
  hyphens: auto;
}

#dataTable th {
  display: block;
  background: var(--header-bg);
  color: var(--header-text);
  font-weight: 800;
  cursor: pointer;
  user-select: none;
}

#dataTable .col-short_name {
  flex: 0.55 1 4.2rem;
  max-width: 8rem;
  width: auto;
}
#dataTable .col-description {
  flex: 3 1 24rem;
  min-width: 0;
}
#dataTable .col-link {
  flex: 0.75 1 6rem;
  min-width: 0;
}
#dataTable .col-long_name,
#dataTable .col-specimen_name,
#dataTable .col-synonym,
#dataTable .col-hinweise_pa,
#dataTable .col-hinweise_ad,
#dataTable .col-hinweise_ks,
#dataTable .col-billing_description,
#dataTable .col-versandparameter,
#dataTable .col-partnerlabor {
  flex: 1 1 8rem;
  min-width: 0;
}

#dataTable td.col-link {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  word-break: normal;
  overflow-wrap: normal;
  hyphens: none;
}

#dataTable td.col-link a,
#dataTable td.col-link .table-link {
  display: inline-block;
  max-width: 100%;
  color: var(--accent);
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  pointer-events: auto;
  position: relative;
  z-index: 2;
}

#dataTable td.col-link a:hover,
#dataTable td.col-link a:focus,
#dataTable td.col-link .table-link:hover,
#dataTable td.col-link .table-link:focus {
  text-decoration: underline;
}


#dataTable tbody tr:nth-child(even) td { background: #fcfcfd; }
#dataTable tbody tr:hover td { background: #f8fbff; }

#dataTable th.sort-asc::after { content: " ▲"; font-size: .75em; }
#dataTable th.sort-desc::after { content: " ▼"; font-size: .75em; }

.empty-state {
  padding: 2rem !important;
  color: var(--muted);
  text-align: center;
  width: 100% !important;
  max-width: none !important;
  flex-basis: 100% !important;
}

@media (max-width: 860px) {
  :root {
    --table-height: 68vh;
  }

  .page-header {
    padding: 1.5rem 1rem 1rem;
  }

  .container {
    width: calc(100% - 1rem);
    margin-bottom: 1rem;
  }

  .toolbar {
    grid-template-columns: 1fr;
    border-radius: 1rem;
  }

  .table-card {
    border-radius: 1rem;
  }

  .table-meta {
    display: grid;
    gap: .35rem;
    align-items: start;
  }

  #dataTable {
    font-size: .86rem;
  }

  #dataTable thead {
    display: none;
  }

  #dataTable tbody {
    max-height: none;
    overflow: visible;
  }

  #dataTable tbody tr {
    display: grid;
    width: 100%;
    gap: .45rem;
    padding: .8rem;
    border-bottom: 1px solid var(--line);
  }

  #dataTable th,
  #dataTable td,
  #dataTable .col-short_name,
  #dataTable .col-long_name,
  #dataTable .col-description,
  #dataTable .col-specimen_name,
  #dataTable .col-synonym,
  #dataTable .col-link,
  #dataTable .col-hinweise_pa,
  #dataTable .col-hinweise_ad,
  #dataTable .col-hinweise_ks,
  #dataTable .col-billing_description,
  #dataTable .col-versandparameter,
  #dataTable .col-partnerlabor {
    flex: none;
    width: 100%;
  }

  #dataTable td {
    display: grid;
    grid-template-columns: 8.5rem minmax(0, 1fr);
    gap: .75rem;
    padding: .15rem 0;
    border: 0;
  }

  #dataTable td::before {
    content: attr(data-label);
    color: var(--muted);
    font-weight: 800;
  }

  #dataTable tbody tr:nth-child(even) td,
  #dataTable tbody tr:hover td {
    background: transparent;
  }
}

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1rem;
}

.login-card {
  width: min(440px, 100%);
  background: rgba(255, 255, 255, .96);
  border: 1px solid var(--line);
  border-radius: 1.25rem;
  box-shadow: var(--shadow);
  padding: clamp(1.25rem, 5vw, 2rem);
}

.login-card h1 {
  font-size: clamp(2rem, 8vw, 3rem);
}

.login-form {
  display: grid;
  gap: .75rem;
  margin-top: 1.25rem;
}

.login-form label {
  font-weight: 700;
  color: var(--header-text);
}

.login-form input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: .8rem;
  padding: .9rem 1rem;
  font: inherit;
  background: #fff;
}

.login-form button {
  border: 0;
  border-radius: .8rem;
  padding: .9rem 1rem;
  font: inherit;
  font-weight: 800;
  color: #fff;
  background: var(--accent);
  cursor: pointer;
}

.login-error {
  margin-top: 1rem;
  border: 1px solid #fecaca;
  background: #fff1f2;
  color: #991b1b;
  border-radius: .8rem;
  padding: .75rem 1rem;
  font-weight: 700;
}

.logout-line {
  margin: .75rem 0 0;
}

.logout-line a {
  color: var(--accent);
  font-weight: 700;
  text-decoration: none;
}
