/* BSNSoft AI portal — tokens 1:1 from bsnsoft.de (docs/DESIGN.md). No framework, no CDN. */

:root {
  --color-primary: #1a2b4a;
  --color-primary-light: #2a4270;
  --color-accent: #eab24f;
  --color-accent-hover: #d4a043;
  --color-text: #333;
  --color-text-light: #666;
  --color-text-muted: #999;
  --color-bg: #ffffff;
  --color-bg-light: #f8f9fa;
  --color-bg-dark: #1a2b4a;
  --color-border: #e0e0e0;
  --color-success: #28a745;
  --color-error: #dc3545;
  --color-warning: #eab24f;
  --color-info: #2a4270;
  --shadow-sm: 0 2px 4px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.1);
  --shadow-lg: 0 8px 30px rgba(0,0,0,0.12);
  --radius-sm: 6px;
  --radius-md: 12px;
  --radius-lg: 20px;
  --font-main: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --max-width: 1200px;
  --transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --navbar-height: 70px;
}

/* --- Reset & base (as on bsnsoft.de) --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; }
body {
  font-family: var(--font-main);
  color: var(--color-text);
  background: var(--color-bg);
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
body.body--auth, body.body--app { background: var(--color-bg-light); }
img { max-width: 100%; height: auto; display: block; }
a { color: var(--color-accent); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--color-accent-hover); }
h1, h2, h3 { font-weight: 700; line-height: 1.3; color: var(--color-primary); }
h1 { font-size: 1.8rem; }
h2 { font-size: 1.35rem; }
h3 { font-size: 1.1rem; }
p { margin-bottom: 1rem; color: var(--color-text-light); }
strong { color: var(--color-text); font-weight: 600; }
[hidden] { display: none !important; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--color-text-muted); }
.lead { font-size: 1.05rem; }
.hint { font-size: 0.9rem; color: var(--color-text-muted); margin-top: 1rem; }
.icon { flex-shrink: 0; }
.inline-form { display: inline; }
:focus-visible { outline: 2px solid var(--color-accent); outline-offset: 2px; }

.container { width: 100%; max-width: var(--max-width); margin: 0 auto; padding: 0 1.5rem; }

/* --- Buttons --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.85rem 2rem;
  font-size: 1rem;
  font-weight: 600;
  font-family: var(--font-main);
  border: 2px solid transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition);
  text-decoration: none;
  line-height: 1.4;
  background: none;
}
.btn--primary { background: var(--color-accent); color: var(--color-primary); border-color: var(--color-accent); }
.btn--primary:hover { background: var(--color-accent-hover); border-color: var(--color-accent-hover); color: var(--color-primary); transform: translateY(-2px); box-shadow: var(--shadow-md); }
.btn--outline { background: transparent; color: var(--color-primary); border-color: var(--color-accent); }
.btn--outline:hover { background: var(--color-accent); color: var(--color-primary); transform: translateY(-2px); }
.btn--danger { background: transparent; color: var(--color-error); border-color: var(--color-error); }
.btn--danger:hover { background: var(--color-error); color: #fff; transform: translateY(-2px); }
.btn--sm { padding: 0.4rem 1rem; font-size: 0.9rem; }
.btn--block { width: 100%; }
.btn:disabled, .btn[aria-busy="true"] { opacity: 0.55; cursor: not-allowed; transform: none; box-shadow: none; }
.btn--danger:disabled:hover { background: transparent; color: var(--color-error); }

/* --- Navbar --- */
.navbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--color-bg);
  box-shadow: var(--shadow-sm);
  min-height: var(--navbar-height);
  display: flex;
  align-items: center;
}
.navbar__inner { display: flex; align-items: center; justify-content: space-between; gap: 1.5rem; }
.navbar__logo { display: flex; align-items: center; gap: 0.85rem; text-decoration: none; }
.navbar__logo img { height: 45px; width: auto; }
.wordmark { color: var(--color-text-light); font-weight: 600; font-size: 0.95rem; letter-spacing: 0.2px; white-space: nowrap; }
.navbar__logo .wordmark { padding-left: 0.85rem; border-left: 1px solid var(--color-border); line-height: 1.6; }
.navbar__menu { display: flex; align-items: center; gap: 1.5rem; flex: 1; justify-content: space-between; }
.navbar__nav { display: flex; align-items: center; gap: 0.5rem; list-style: none; }
.navbar__link {
  display: inline-block;
  padding: 0.5rem 1rem;
  color: var(--color-primary);
  font-weight: 500;
  font-size: 0.95rem;
  border-radius: var(--radius-sm);
  border-bottom: 2px solid transparent;
  transition: all var(--transition);
}
.navbar__link:hover { color: var(--color-accent); background: rgba(234, 178, 79, 0.08); }
.navbar__link--active { color: var(--color-primary); border-bottom-color: var(--color-accent); border-radius: var(--radius-sm) var(--radius-sm) 0 0; }
.navbar__user { display: flex; align-items: center; gap: 1rem; font-size: 0.9rem; }
.navbar__email { color: var(--color-text-light); overflow-wrap: anywhere; }
.navbar__logout {
  font: inherit;
  font-weight: 600;
  color: var(--color-primary);
  background: none;
  border: 2px solid var(--color-accent);
  border-radius: var(--radius-sm);
  padding: 0.35rem 0.9rem;
  cursor: pointer;
  transition: all var(--transition);
}
.navbar__logout:hover { background: var(--color-accent); }
.navbar__toggle-input { position: absolute; opacity: 0; pointer-events: none; }
.navbar__toggle { display: none; flex-direction: column; gap: 5px; cursor: pointer; padding: 0.5rem; }
.navbar__toggle span { display: block; width: 24px; height: 2px; background: var(--color-text); border-radius: 2px; }

@media (max-width: 768px) {
  .navbar__inner { flex-wrap: wrap; padding-top: 0.75rem; padding-bottom: 0.75rem; }
  .navbar__toggle { display: flex; }
  .navbar__logo { gap: 0.6rem; }
  .navbar__logo img { height: 36px; }
  .navbar__logo .wordmark { padding-left: 0.6rem; font-size: 0.85rem; }
  .navbar__menu { display: none; flex-basis: 100%; flex-direction: column; align-items: stretch; gap: 0.75rem; padding-bottom: 0.5rem; }
  .navbar__toggle-input:checked ~ .navbar__menu { display: flex; }
  .navbar__nav { flex-direction: column; align-items: stretch; gap: 0; }
  .navbar__link { display: block; padding: 0.8rem 1rem; font-size: 1.05rem; }
  .navbar__link--active { border-bottom: none; border-left: 3px solid var(--color-accent); border-radius: 0; }
  .navbar__user { justify-content: space-between; border-top: 1px solid var(--color-border); padding-top: 0.75rem; }
}

/* --- Layout --- */
main { flex: 1; }
.app { padding: 2.5rem 0 4rem; }
.page-header { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.actions { display: flex; flex-wrap: wrap; gap: 0.75rem; margin-top: 1.5rem; }

/* --- Cards --- */
.card {
  background: var(--color-bg);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  padding: 1.5rem;
  transition: box-shadow var(--transition);
}
.card:hover { box-shadow: var(--shadow-md); }
.card--flush { padding: 0; overflow-x: auto; }
.form-card { max-width: 640px; }

/* --- Auth pages (login, registration, errors when logged out) --- */
.auth { display: flex; align-items: center; justify-content: center; padding: 3rem 1rem; }
.auth__card { width: 100%; max-width: 440px; text-align: center; padding: 2.5rem 2rem; }
.auth__logo { display: inline-block; margin-bottom: 1.75rem; }
.auth__logo img { height: 45px; width: auto; margin: 0 auto; }
.auth__wordmark { margin: -1rem 0 1.5rem; }
.auth__title { font-size: 1.35rem; margin-bottom: 0.75rem; }
.auth__subtitle { font-weight: 600; color: var(--color-text); margin: -0.4rem 0 0.75rem; }
.auth__email { display: block; font-size: 1.05rem; font-weight: 600; color: var(--color-text); overflow-wrap: anywhere; }
.auth__lead { margin-bottom: 1.5rem; }
.auth__hint { font-size: 0.85rem; color: var(--color-text-muted); margin: 1.25rem 0 0; }
.auth .message { text-align: left; }

/* --- Forms --- */
.form-group { margin-bottom: 1.5rem; }
.form-group label { display: block; font-size: 0.9rem; font-weight: 600; margin-bottom: 0.5rem; color: var(--color-text); }
.form-control {
  width: 100%;
  padding: 0.8rem 1rem;
  font-size: 1rem;
  font-family: var(--font-main);
  border: 2px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-bg);
  color: var(--color-text);
  transition: border-color var(--transition);
}
.form-control:focus { outline: none; border-color: var(--color-accent); }
.form-control--sm { padding: 0.4rem 0.75rem; font-size: 0.95rem; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.form-hint { display: block; font-size: 0.8rem; color: var(--color-text-muted); margin-top: 0.35rem; }
@media (max-width: 600px) { .form-row { grid-template-columns: 1fr; } }
.rename-form { display: flex; gap: 0.5rem; align-items: center; min-width: 260px; }
.net { margin: 0 0 1.5rem; color: var(--color-text); font-weight: 600; }
.net strong { color: var(--color-primary); font-size: 1.1rem; }
.net strong.net--negative { color: var(--color-error); }
.form-hint--inline { display: inline; margin-left: 0.25rem; font-weight: 400; }

/* --- Messages --- */
.message {
  display: flex;
  gap: 0.6rem;
  align-items: flex-start;
  padding: 1rem 1.25rem;
  border-radius: var(--radius-sm);
  margin: 0 0 1.25rem;
  font-size: 0.95rem;
}
.message--success { background: rgba(40, 167, 69, 0.1); color: var(--color-success); border: 1px solid rgba(40, 167, 69, 0.2); }
.message--error { background: rgba(220, 53, 69, 0.1); color: var(--color-error); border: 1px solid rgba(220, 53, 69, 0.2); }
.message--info { background: rgba(42, 66, 112, 0.08); color: var(--color-info); border: 1px solid rgba(42, 66, 112, 0.2); }

/* --- Badges & status --- */
.badge {
  display: inline-block;
  background: var(--color-accent);
  color: var(--color-primary);
  font-size: 0.7rem;
  font-weight: 700;
  padding: 0.2rem 0.7rem;
  border-radius: 50px;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  vertical-align: middle;
}
.status { display: inline-block; font-size: 0.8rem; font-weight: 700; padding: 0.15rem 0.6rem; border-radius: 50px; background: var(--color-bg-light); color: var(--color-text-light); }
.status--ok { background: rgba(40, 167, 69, 0.12); color: var(--color-success); }
.status--off { background: rgba(220, 53, 69, 0.12); color: var(--color-error); }
.status--open { background: rgba(234, 178, 79, 0.2); color: var(--color-primary); }

/* --- Tables --- */
.table { width: 100%; border-collapse: collapse; font-size: 0.95rem; }
.table th { background: var(--color-bg-light); text-align: left; font-weight: 600; color: var(--color-primary); padding: 0.75rem 1rem; border-bottom: 1px solid var(--color-border); white-space: nowrap; }
.table td { padding: 0.75rem 1rem; border-bottom: 1px solid var(--color-border); vertical-align: middle; }
.table tbody tr:nth-child(even) { background: var(--color-bg-light); }
.table tbody tr:last-child td { border-bottom: none; }
.table__actions { text-align: right; }
@media (max-width: 768px) {
  .table thead { display: none; }
  .table, .table tbody, .table tr, .table td { display: block; width: 100%; }
  .table tr { padding: 0.75rem 0; border-bottom: 1px solid var(--color-border); }
  .table td { border: none; padding: 0.35rem 1rem; text-align: left; }
  .table td::before { content: attr(data-label); display: block; font-size: 0.75rem; font-weight: 600; color: var(--color-text-muted); }
  .rename-form { min-width: 0; }
}

/* --- TAKT-11: keys, user administration --- */
.subnav { display: flex; flex-wrap: wrap; gap: 0.25rem; margin: -0.5rem 0 1.5rem; border-bottom: 1px solid var(--color-border); }
.subnav a { padding: 0.5rem 1rem; color: var(--color-text-light); font-weight: 500; font-size: 0.95rem; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.subnav a:hover { color: var(--color-primary); }
.subnav a[aria-current="page"] { color: var(--color-primary); border-bottom-color: var(--color-accent); }
.back-link { display: inline-block; font-size: 0.9rem; font-weight: 500; margin-bottom: 0.25rem; }
.badges { display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; }
h2.section { margin: 2rem 0 0.75rem; }
.section-card { margin-top: 1.25rem; }
.form-card--wide { max-width: 860px; }
.form-row--3 { grid-template-columns: repeat(3, 1fr); align-items: start; }
@media (max-width: 800px) { .form-row--3 { grid-template-columns: 1fr; } }
.form-section { margin: 0.5rem 0 1rem; }
select.form-control { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--color-text-light) 50%), linear-gradient(135deg, var(--color-text-light) 50%, transparent 50%); background-position: calc(100% - 18px) 55%, calc(100% - 13px) 55%; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 2.25rem; }
select.form-control--sm { padding-right: 2rem; }
.cell-num, .table th.cell-num, .table td.cell-num { text-align: right; white-space: nowrap; }
.table--compact th.table__actions { text-align: right; }
.row-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; justify-content: flex-end; align-items: center; }
@media (min-width: 1100px) { .row-actions { flex-wrap: nowrap; } }
.nowrap { white-space: nowrap; }
.key-name { display: block; line-height: 1.4; }
.table .btn--sm { padding: 0.35rem 0.8rem; }
.table--compact th, .table--compact td { padding-left: 0.7rem; padding-right: 0.7rem; }
.table--compact .row-actions { gap: 0.4rem; }
@media (max-width: 768px) {
  .row-actions { justify-content: flex-start; }
  .cell-num, .table th.cell-num, .table td.cell-num { text-align: left; white-space: normal; }
}
.limits { list-style: none; font-size: 0.9rem; line-height: 1.5; white-space: nowrap; }
.actions--flush { margin-top: 0.5rem; align-items: center; }
.hint--flush { margin: 0; }
.message--warning { background: rgba(234, 178, 79, 0.15); color: var(--color-primary); border: 1px solid rgba(234, 178, 79, 0.5); }
.message--warning .icon { color: var(--color-accent-hover); }
td .keyid { font-size: 0.78rem; margin-top: 0.15rem; display: inline-block; }
.keyid { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.85rem; color: var(--color-primary); background: var(--color-bg-light); border: 1px solid var(--color-border); border-radius: var(--radius-sm); padding: 0.1rem 0.45rem; white-space: nowrap; }
.keycode, .codeblock { display: block; flex: 1; min-width: 0; background: var(--color-primary); color: #fff; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.9rem; line-height: 1.6; padding: 0.9rem 1.1rem; border-radius: var(--radius-sm); overflow-wrap: anywhere; white-space: pre-wrap; user-select: all; cursor: text; margin: 0; }
.keycode { font-size: 1rem; font-weight: 600; letter-spacing: 0.2px; }
.copy-row { display: flex; gap: 0.75rem; align-items: flex-start; }
@media (max-width: 600px) { .copy-row { flex-direction: column; align-items: stretch; } }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 0.35rem 1.5rem; margin: 0 0 1.5rem; font-size: 0.95rem; }
.kv dt { color: var(--color-text-muted); font-weight: 600; }
.kv dd { color: var(--color-text); margin: 0; }
.access-card { padding: 0 1.5rem; }
.access-row { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; padding: 1.1rem 0; border-bottom: 1px solid var(--color-border); }
.access-row:last-child { border-bottom: none; }
.access-row h3 { margin-bottom: 0.15rem; }
.inline-fields { display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; margin-top: 0.6rem; }

/* --- Error pages --- */
.error-page__code { font-size: 3rem; font-weight: 800; color: var(--color-accent); line-height: 1; margin-bottom: 0.75rem; }
.app .error-page { max-width: 560px; margin: 2rem auto; text-align: center; background: var(--color-bg); border-radius: var(--radius-md); box-shadow: var(--shadow-sm); padding: 2.5rem 2rem; }

/* --- Footer --- */
.footer { background: var(--color-bg-dark); color: rgba(255,255,255,0.7); padding: 1.5rem 0; font-size: 0.85rem; }
.footer__inner { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.footer__logo { height: 36px; width: auto; }
.footer__line { margin: 0; color: rgba(255,255,255,0.6); }
.footer__line a { color: rgba(255,255,255,0.6); }
.footer__line a:hover { color: var(--color-accent); }
@media (max-width: 600px) { .footer__inner { flex-direction: column; text-align: center; } }

/* --- TAKT-06: dashboard & admin overview --------------------------------- */
.section { margin-top: 2.5rem; }
.section .page-header { margin-bottom: 0.75rem; }
.actions--inline { margin-top: 0; }
.refresh-note { font-size: 0.85rem; color: var(--color-text-muted); margin: -0.5rem 0 1.5rem; }
.card .message { margin-bottom: 0; }
.page-header + .message, .refresh-note + .message { margin-bottom: 1.5rem; }

/* Key figures in the style of the website's hero stats: big number, small label. */
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1.25rem; }
.stat { display: flex; flex-direction: column; gap: 0.15rem; padding: 1.25rem 1.5rem; }
.stat__label { margin: 0; font-size: 0.85rem; font-weight: 500; color: var(--color-text-light); letter-spacing: 0.2px; }
.stat__value { margin: 0; font-size: 1.75rem; font-weight: 700; line-height: 1.25; color: var(--color-primary); overflow-wrap: anywhere; }
.stat__value--error { color: var(--color-error); }
.stat__unit { display: inline-block; white-space: nowrap; font-size: 0.95rem; font-weight: 500; color: var(--color-text-light); }
.stat__setup { font-size: 1.1rem; font-weight: 600; color: var(--color-text-light); }
.stat__detail { margin: 0 0 0.35rem; font-size: 0.9rem; font-weight: 600; color: var(--color-text); }
.stat__hint { margin: 0.6rem 0 0; font-size: 0.8rem; line-height: 1.5; color: var(--color-text-muted); }
@media (max-width: 1000px) { .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 560px) { .stats { grid-template-columns: 1fr; } }

/* Thin progress bars (inline SVG): Ist in Gold, Marke in Dunkelblau, over 100 % red. */
.bar { display: block; width: 100%; height: 10px; border-radius: 5px; overflow: hidden; margin-top: 0.4rem; }
.bar__track { fill: var(--color-border); }
.bar__fill--gold { fill: var(--color-accent); }
.bar__fill--error { fill: var(--color-error); }
.bar__marker { fill: var(--color-primary); }

/* Tables with figures: right-aligned, dense variant for the request list. */
.table .num-r, .table th.num-r { text-align: right; }
.table--dense { font-size: 0.82rem; }
.table--dense th, .table--dense td { padding: 0.5rem 0.5rem; white-space: nowrap; }
.table--dense .status { font-size: 0.72rem; padding: 0.1rem 0.5rem; }
.table--dense th:first-child, .table--dense td:first-child { padding-left: 0.85rem; }
.table--dense th:last-child, .table--dense td:last-child { padding-right: 0.85rem; }
.table td.model { white-space: normal; overflow-wrap: anywhere; min-width: 8rem; }
.table tfoot td { background: var(--color-bg-light); font-weight: 600; color: var(--color-primary); border-top: 2px solid var(--color-border); border-bottom: none; }
.table td a { font-weight: 600; color: var(--color-primary); }
.table td a:hover { color: var(--color-accent-hover); }
.cell-note { font-size: 0.75rem; font-weight: 600; color: var(--color-text-muted); letter-spacing: 0.3px; text-transform: uppercase; }
.table th { vertical-align: bottom; }
.table--dense th { white-space: normal; }
@media (max-width: 768px) {
  .table--dense th, .table--dense td { white-space: normal; }
  /* The request list stays readable on a phone: two label/value pairs per line. */
  .table--dense tr, .table--pairs tr { display: grid; grid-template-columns: 1fr 1fr; gap: 0 0.5rem; }
  .table--dense td, .table--pairs td { padding: 0.2rem 1rem; }
  .table--dense td:first-child, .table--pairs td:first-child, .table--dense td.model { grid-column: 1 / -1; }
  .table tfoot, .table tfoot tr { display: block; }
  .table tfoot td:empty { display: none; }
  .table .num-r, .table th.num-r { text-align: left; }
}

/* Drift facts. */
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 1rem 1.5rem; margin: 1rem 0 0; }
.facts dt { font-size: 0.8rem; font-weight: 500; color: var(--color-text-light); }
.facts dd { margin: 0; font-size: 1.15rem; font-weight: 700; color: var(--color-primary); }
.drift__off { margin: 0; }
