/* =========================================================
   Portal – gleiches Design-System wie das Profit Cockpit
   (Tokens aus profit-webapp-design.md, Abschnitt 3)
   ========================================================= */

:root {
  --bg: #F7F8FA;
  --surface: #FFFFFF;
  --sidebar: #FBFBFC;
  --border: #E8EAEE;
  --text: #0F172A;
  --text-muted: #64748B;
  --accent: #4F46E5;
  --positive: #16A34A;
  --negative: #DC2626;

  --accent-08: color-mix(in srgb, var(--accent) 8%, transparent);
  --accent-16: color-mix(in srgb, var(--accent) 16%, transparent);
  --pos-10: color-mix(in srgb, var(--positive) 10%, transparent);
  --neg-10: color-mix(in srgb, var(--negative) 10%, transparent);
  --hover: #F3F4F7;
  --track: #D7DBE2;
  --shadow: 0 1px 2px rgba(0, 0, 0, .04);

  --font: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --fs-body: 14px;
  --fs-label: 13px;
  --fs-small: 12px;
  --fs-title: 20px;

  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 20px; --s6: 24px; --s8: 32px;
  --radius: 12px;
  --radius-sm: 8px;
  --topbar-h: 64px;

  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0B0D12; --surface: #13161D; --sidebar: #0F1218; --border: #232833;
    --text: #E6E8EC; --text-muted: #8A93A3; --accent: #818CF8; --positive: #22C55E; --negative: #F87171;
    --hover: #1A1E27; --track: #2C3240; --shadow: none;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0B0D12; --surface: #13161D; --sidebar: #0F1218; --border: #232833;
  --text: #E6E8EC; --text-muted: #8A93A3; --accent: #818CF8; --positive: #22C55E; --negative: #F87171;
  --hover: #1A1E27; --track: #2C3240; --shadow: none;
  color-scheme: dark;
}

/* ---------- Basis ---------- */
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--text); font-family: var(--font); font-size: var(--fs-body); line-height: 1.45; -webkit-font-smoothing: antialiased; }
button, input, select { font: inherit; color: inherit; }
a { color: inherit; }
h1, h2, p { margin: 0; }
.icon { flex-shrink: 0; display: block; }
.muted { color: var(--text-muted); }
[hidden] { display: none !important; }

.logo { display: flex; align-items: center; gap: var(--s2); font-weight: 600; font-size: 15px; }
.logo-mark { width: 24px; height: 24px; border-radius: 6px; background: var(--accent); color: #fff; display: grid; place-items: center; }

/* ---------- Steuerelemente ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s2); height: 36px; padding: 0 var(--s3); border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--surface); color: var(--text); cursor: pointer; font-weight: 500; font-size: var(--fs-label);
  white-space: nowrap; text-decoration: none;
}
.btn:hover { background: var(--hover); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.05); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--hover); }
.btn.icon-only { width: 36px; padding: 0; }
.btn.small { height: 30px; padding: 0 var(--s3); font-size: var(--fs-small); }
.btn.danger { color: var(--negative); }
.btn.block { width: 100%; height: 40px; }
.btn:disabled { opacity: .6; cursor: default; }
.btn:focus-visible, .input:focus-visible, .select:focus-visible, a:focus-visible,
.tile:has(input:focus-visible), .switch:has(input:focus-visible) .switch-track, .check input:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

.field { display: flex; flex-direction: column; gap: 6px; font-size: var(--fs-label); font-weight: 500; color: var(--text-muted); }
.input, .select {
  height: 40px; padding: 0 var(--s3); border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); color: var(--text);
  font-size: var(--fs-body); width: 100%; outline: none;
}
.input:focus, .select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-16); }
.label { font-size: var(--fs-label); font-weight: 500; color: var(--text-muted); padding: 0; margin-bottom: 6px; }

.check { display: inline-flex; align-items: center; gap: var(--s2); font-size: var(--fs-label); cursor: pointer; user-select: none; }
.check input { width: 16px; height: 16px; margin: 0; accent-color: var(--accent); }

.switch { display: inline-flex; align-items: center; gap: var(--s2); font-size: var(--fs-label); cursor: pointer; user-select: none; position: relative; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch-track { width: 32px; height: 18px; border-radius: 999px; background: var(--track); position: relative; transition: background .15s; flex-shrink: 0; }
.switch-track::after { content: ""; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.2); transition: transform .15s; }
.switch input:checked + .switch-track { background: var(--accent); }
.switch input:checked + .switch-track::after { transform: translateX(14px); }

.badge { display: inline-flex; align-items: center; height: 18px; padding: 0 6px; border-radius: 999px; font-size: 11px; font-weight: 500; background: var(--hover); color: var(--text-muted); vertical-align: 1px; }
.badge.accent { background: var(--accent-08); color: var(--accent); }

.notice { display: flex; align-items: flex-start; gap: var(--s2); padding: 10px var(--s3); border-radius: var(--radius-sm); font-size: var(--fs-label); border: 1px solid; }
.notice .icon { margin-top: 1px; }
.notice.error { background: var(--neg-10); border-color: color-mix(in srgb, var(--negative) 25%, transparent); color: var(--negative); }
.notice.ok { background: var(--pos-10); border-color: color-mix(in srgb, var(--positive) 25%, transparent); color: var(--positive); }
.notice.info { background: var(--accent-08); border-color: var(--accent-16); color: var(--accent); }
.error-text { color: var(--negative); }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: var(--s5); min-width: 0; }
.card.flush { padding: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); margin-bottom: var(--s4); flex-wrap: wrap; }
.card.flush .card-head { padding: var(--s5) var(--s5) 0; }
.card-title { font-size: 15px; font-weight: 600; }

/* ---------- Login & Tool-Auswahl ---------- */
.auth-body .center { min-height: 100vh; display: grid; place-items: center; padding: var(--s8) var(--s4); position: relative; }
.auth-card { width: 100%; max-width: 420px; display: flex; flex-direction: column; gap: var(--s4); padding: var(--s8) 28px 28px; }
.auth-head { display: flex; flex-direction: column; gap: var(--s1); margin-top: var(--s2); }
.auth-head h1 { font-size: var(--fs-title); font-weight: 600; line-height: 1.2; }
.auth-head p { font-size: var(--fs-label); }
.corner { position: absolute; top: var(--s4); right: var(--s4); }

.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s2); min-width: 0; }
.tile {
  position: relative; display: flex; flex-direction: column; gap: var(--s3); padding: var(--s3) 14px 14px; border: 1px solid var(--border); border-radius: 10px;
  cursor: pointer; background: var(--surface); transition: border-color .15s, background .15s; min-width: 0;
}
.tile:hover { background: var(--hover); }
.tile input { position: absolute; opacity: 0; pointer-events: none; }
.tile:has(input:checked) { border-color: var(--accent); background: var(--accent-08); box-shadow: inset 0 0 0 1px var(--accent); }
.tile.disabled { cursor: default; opacity: .55; }
.tile.disabled:hover { background: var(--surface); }
.tile-icon { width: 32px; height: 32px; border-radius: var(--radius-sm); display: grid; place-items: center; background: var(--hover); color: var(--text-muted); }
.tile:has(input:checked) .tile-icon { background: var(--accent); color: #fff; }
.tile-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.tile-name { font-weight: 600; font-size: var(--fs-body); }
.tile-desc { font-size: var(--fs-small); color: var(--text-muted); line-height: 1.35; }

.options { display: flex; flex-direction: column; gap: var(--s3); }
.divider { display: flex; align-items: center; gap: var(--s3); color: var(--text-muted); font-size: var(--fs-small); margin: var(--s1) 0 var(--s4); }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.auth-links { display: flex; justify-content: center; gap: var(--s5); padding-top: var(--s1); }
.auth-links a { display: inline-flex; align-items: center; gap: 6px; font-size: var(--fs-label); color: var(--text-muted); text-decoration: none; }
.auth-links a:hover { color: var(--text); }

/* ---------- Hell/Dunkel-Knopf ---------- */
.theme-moon { display: none; }
:root[data-theme="dark"] .theme-sun { display: none; }
:root[data-theme="dark"] .theme-moon { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-sun { display: none; }
  :root:not([data-theme="light"]) .theme-moon { display: block; }
}

/* ---------- Konto ---------- */
.topbar { position: sticky; top: 0; z-index: 20; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--border); }
.topbar-inner { max-width: 800px; margin: 0 auto; min-height: var(--topbar-h); padding: var(--s3) var(--s6); display: flex; align-items: center; justify-content: space-between; gap: var(--s4); }
.top-links { display: flex; align-items: center; gap: var(--s1); }
.content { max-width: 800px; margin: 0 auto; padding: var(--s6) var(--s6) 64px; display: flex; flex-direction: column; gap: var(--s4); }
.page-head { margin-bottom: var(--s2); }
.page-title { font-size: var(--fs-title); font-weight: 600; line-height: 1.2; }
.page-sub { font-size: var(--fs-small); color: var(--text-muted); margin-top: 2px; }

.rows { list-style: none; margin: 0; padding: 0; }
.row { display: flex; align-items: center; gap: var(--s3); padding: 14px var(--s5); border-top: 1px solid var(--border); }
.rows .row:first-child { border-top: 0; }
.row:hover { background: var(--hover); }
.row.empty-row { font-size: var(--fs-label); }
.row.empty-row:hover { background: none; }
.row-icon { width: 36px; height: 36px; border-radius: var(--radius-sm); background: var(--hover); color: var(--text-muted); display: grid; place-items: center; flex-shrink: 0; }
.row:hover .row-icon { background: var(--surface); }
.row-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.row-title { font-weight: 500; }
.row-meta { font-size: var(--fs-small); color: var(--text-muted); }
.row form { margin: 0; }

.inline-form { display: flex; align-items: flex-end; gap: var(--s3); flex-wrap: wrap; }
.inline-form .field { flex: 1 1 200px; }
.inline-form .switch { height: 40px; }
.stack-form { display: flex; flex-direction: column; gap: var(--s4); max-width: 380px; }
.hint { font-size: var(--fs-small); color: var(--text-muted); margin-top: var(--s3); }
.pad { padding: 0 var(--s5) var(--s5); }
.card.flush .inline-form.pad { border-top: 1px solid var(--border); padding-top: var(--s5); }
.card.flush .hint.pad { margin-top: 0; }
.card.flush .rows { margin-bottom: var(--s4); }
.card.flush .rows + .hint.pad { border-top: 1px solid var(--border); padding-top: var(--s4); }

@media (max-width: 480px) {
  .auth-card { padding: var(--s6) var(--s5) var(--s5); }
  .tiles { grid-template-columns: 1fr; }
  .tile { flex-direction: row; align-items: center; }
  .topbar-inner, .content { padding-left: var(--s4); padding-right: var(--s4); }
  .top-links .btn:not(.icon-only) { padding: 0 var(--s2); }
  .row { padding: var(--s3) var(--s4); flex-wrap: wrap; }
  .row form { margin-left: 48px; }
}
