/* ---------- Farben im Stil von progmode.de ----------
   --brand ist die Markenfarbe von transfer.progmode.de (#172b3a).
   Alle anderen Werte sind darauf abgestimmt und lassen sich hier zentral
   an das Stylesheet der Hauptseite angleichen. */
:root {
  color-scheme: light;
  --brand: #172b3a;
  --brand-ink: #FFFFFF;
  --brand-soft: rgba(255, 255, 255, 0.78);
  --brand-hover: rgba(255, 255, 255, 0.12);
  --accent: #1F6F8B;
  --ground: #EEF2F5;
  --surface: #FFFFFF;
  --ink: #172b3a;
  --muted: #4B5B69;
  --line: #C2CCD5;
  --line-soft: #DCE3E9;
  --web: var(--accent);
  --social: #B3430A;
  --up: #1E6B3A;
  --down: #B42318;
  --warn-bg: #FFF4E5;
  --warn-line: #E8B66B;
  --error-bg: #FDECEA;
  --success-bg: #E7F4EC;
  --info-bg: #E6F0F5;
  --chart: var(--accent);
  --chart-fill: rgba(31, 111, 139, 0.14);
  --radius: 10px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --brand: #172b3a;
    --accent: #7CC4DD;
    --ground: #0E1B25;
    --surface: #172b3a;
    --ink: #EEF2F5;
    --muted: #A9B8C4;
    --line: #36505F;
    --line-soft: #243B4B;
    --social: #F29B6B;
    --up: #6FCF97;
    --down: #F59C92;
    --warn-bg: #3A2C14;
    --warn-line: #8A6420;
    --error-bg: #3D1C1A;
    --success-bg: #173324;
    --info-bg: #1B3444;
    --chart-fill: rgba(124, 196, 221, 0.16);
  }
  .topbar { border-bottom: 1px solid var(--line-soft); }
  :root .btn-primary { background: var(--accent); border-color: var(--accent); color: #0E1B25; }
  :root .btn-primary:hover { background: var(--ink); border-color: var(--ink); color: #0E1B25; }
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
}

a { color: var(--accent); }
a:hover { color: var(--ink); }

:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

h1, h2, h3 { line-height: 1.2; margin: 0; letter-spacing: -0.01em; }
h1 { font-size: clamp(26px, 3vw, 34px); font-weight: 750; }
h2 { font-size: 20px; font-weight: 700; }
p { margin: 0; }
code { font-family: var(--mono); font-size: 0.92em; }

.skip {
  position: absolute; left: 12px; top: -48px; padding: 10px 14px;
  background: var(--ink); color: var(--surface); border-radius: 8px; z-index: 10;
}
.skip:focus { top: 12px; }

.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

.muted { color: var(--muted); }
.small { font-size: 14px; }
.prewrap { white-space: pre-wrap; }

/* ---------- Kopf- und Fußzeile ---------- */

body { min-height: 100vh; display: flex; flex-direction: column; }

.topbar { background: var(--brand); color: var(--brand-ink); }
.topbar-inner {
  max-width: 1200px; margin: 0 auto; padding: 10px clamp(16px, 4vw, 32px);
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 24px;
}
.is-auth .topbar-inner { justify-content: center; }
.brand {
  display: inline-flex; align-items: center; gap: 12px; min-height: 44px;
  color: var(--brand-ink); text-decoration: none;
}
.brand:hover { color: var(--brand-ink); }
.brand-logo { height: 34px; width: auto; display: block; }
.brand-name { font-weight: 800; font-size: 19px; letter-spacing: -0.01em; }
.brand-app {
  font-size: 15px; color: var(--brand-soft);
  padding-left: 12px; border-left: 1px solid rgba(255, 255, 255, 0.28);
}
.mainnav { display: flex; flex-wrap: wrap; gap: 4px; flex: 1; }
.mainnav a {
  display: inline-flex; align-items: center; min-height: 44px; padding: 0 12px;
  border-radius: 8px; color: var(--brand-ink); text-decoration: none; font-weight: 550;
}
.mainnav a:hover { background: var(--brand-hover); color: var(--brand-ink); }
.mainnav a[aria-current="page"] { background: var(--brand-hover); box-shadow: inset 0 -3px 0 var(--brand-ink); }
.topbar :focus-visible { outline-color: var(--brand-ink); }
.logout { display: flex; align-items: center; gap: 12px; }
.topbar-user { color: var(--brand-soft); font-size: 15px; }

.footer {
  margin-top: auto; padding: 20px clamp(16px, 4vw, 32px);
  color: var(--muted); font-size: 14px; text-align: center;
}
.footer span { margin: 0 8px; }

/* ---------- Seitenrahmen ---------- */

.main {
  width: 100%; max-width: 1200px; margin: 0 auto;
  padding: clamp(20px, 4vw, 40px) clamp(16px, 4vw, 32px) 80px;
  display: flex; flex-direction: column; gap: 28px;
}
.page-narrow { max-width: 720px; width: 100%; display: flex; flex-direction: column; gap: 20px; }

.auth { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px; padding: 24px 16px; }
.auth-card {
  width: 100%; max-width: 420px; background: var(--surface);
  border: 1px solid var(--line-soft); border-radius: 14px; padding: 32px;
  display: flex; flex-direction: column; gap: 16px;
}
.auth-card-wide { max-width: 560px; }
.auth .flash { width: 100%; max-width: 420px; }

.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 16px; }
.page-head > div:not(.head-actions) { display: flex; flex-direction: column; gap: 8px; }
.head-actions { display: flex; flex-wrap: wrap; gap: 8px; }

.breadcrumb { display: flex; flex-wrap: wrap; gap: 6px; font-size: 14px; }
.breadcrumb a { color: var(--muted); }
.breadcrumb a + a::before { content: "/"; color: var(--line); margin-right: 6px; }

.section { display: flex; flex-direction: column; gap: 14px; }
.section-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; }

.panel {
  background: var(--surface); border: 1px solid var(--line-soft);
  border-radius: var(--radius); padding: clamp(16px, 3vw, 24px);
}
.panel h2 { margin-bottom: 12px; }
.panel ul { margin: 8px 0 0; padding-left: 20px; }
.panel-warning { background: var(--warn-bg); border-color: var(--warn-line); }

.columns { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 360px), 1fr)); gap: 20px; }
.columns .panel { display: flex; flex-direction: column; gap: 12px; }
.columns .panel h2 { margin-bottom: 0; }

.stack { display: flex; flex-direction: column; gap: 16px; }

.empty {
  border: 2px dashed var(--line); border-radius: var(--radius); padding: 28px;
  display: flex; flex-direction: column; align-items: flex-start; gap: 16px; max-width: 720px;
}

/* ---------- Kennzahlen ---------- */

.kpis {
  margin: 0; display: grid; gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 150px), 1fr));
}
.kpi {
  background: var(--surface); border: 1px solid var(--line-soft); border-radius: var(--radius);
  padding: 16px 18px; display: flex; flex-direction: column; gap: 4px;
}
.kpi dt { color: var(--muted); font-size: 14px; }
.kpi dd { margin: 0; font-size: 28px; font-weight: 750; font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
.kpi dd.kpi-note { font-size: 13px; font-weight: 400; color: var(--muted); letter-spacing: 0; }

.delta { font-variant-numeric: tabular-nums; }
.delta-up { color: var(--up); }
.delta-down { color: var(--down); }

/* ---------- Listen und Tabellen ---------- */

.project-list { list-style: none; margin: 0; padding: 0; background: var(--surface); border: 1px solid var(--line-soft); border-radius: var(--radius); }
.project-row {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px 24px;
  padding: 14px 18px; border-top: 1px solid var(--line-soft);
}
.project-row:first-child { border-top: 0; }
.project-main { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.project-name { font-weight: 650; color: var(--ink); }
.project-actions { display: flex; flex-wrap: wrap; gap: 8px; }

.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line-soft); border-radius: var(--radius); }
.table { width: 100%; border-collapse: collapse; font-size: 15px; }
.table th, .table td { padding: 10px 14px; text-align: left; vertical-align: middle; border-top: 1px solid var(--line-soft); }
.table thead th { border-top: 0; font-size: 13px; font-weight: 600; color: var(--muted); white-space: nowrap; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table tr.is-archived td { color: var(--muted); }
.row-actions { text-align: right; white-space: nowrap; }
.row-actions form { display: inline; }
.link-quiet { color: var(--ink); }

.tags { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; font-size: 14px; }
.tag, .status, .platform {
  display: inline-flex; align-items: center; padding: 2px 8px; border-radius: 6px;
  font-size: 13px; font-weight: 600; white-space: nowrap; border: 1px solid var(--line);
}
.tag-website, .tag-webshop, .tag-webapp { color: var(--web); border-color: currentColor; }
.tag-content { color: var(--social); border-color: currentColor; }
.status-aktiv { background: var(--success-bg); border-color: transparent; }
.status-pausiert { background: var(--warn-bg); border-color: transparent; }
.status-archiviert { color: var(--muted); }
.platform { margin-right: 8px; color: var(--ink); background: var(--ground); border-color: transparent; }
.platform-lg { font-size: 0.55em; vertical-align: middle; padding: 4px 10px; }

.details {
  margin: 0; display: grid; gap: 0;
  background: var(--surface); border: 1px solid var(--line-soft); border-radius: var(--radius);
}
.details > div { display: flex; flex-wrap: wrap; gap: 4px 24px; padding: 12px 18px; border-top: 1px solid var(--line-soft); }
.details > div:first-child { border-top: 0; }
.details dt { flex: 0 0 140px; color: var(--muted); }
.details dd { margin: 0; flex: 1 1 260px; min-width: 0; overflow-wrap: anywhere; }
.details-plain { background: none; border: 0; }
.details-plain > div { padding: 10px 0; }

.copy-row { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.code-block {
  display: inline-block; padding: 8px 10px; border-radius: 8px; background: var(--ground);
  overflow-wrap: anywhere; font-family: var(--mono); font-size: 14px;
}
pre.code-block { white-space: pre-wrap; display: block; }

.secret { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.secret-value { min-width: 8ch; overflow-wrap: anywhere; }

/* ---------- Diagramme ---------- */

.chart-panel { padding: 16px; }
.chart { width: 100%; height: auto; display: block; }
.chart-grid { stroke: var(--line-soft); stroke-width: 1; }
.chart-label { fill: var(--muted); font-size: 12px; font-family: var(--font); }
.chart-line { fill: none; stroke: var(--chart); stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round; }
.chart-area { fill: var(--chart-fill); stroke: none; }
.chart-dot { fill: var(--surface); stroke: var(--chart); stroke-width: 2; }
.spark { width: 120px; height: 32px; display: block; }
.spark .chart-line { stroke-width: 2; }

/* ---------- Formulare ---------- */

.field { display: flex; flex-direction: column; gap: 6px; }
.field > span { font-weight: 600; font-size: 15px; }
.field em { font-style: normal; font-weight: 400; color: var(--muted); font-size: 13px; margin-left: 4px; }
.field small { color: var(--muted); font-size: 13px; }
.field small.error { color: var(--down); font-weight: 600; }
.field.has-error input { border-color: var(--down); }

input, select, textarea {
  font: inherit; color: var(--ink); background: var(--surface);
  border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; min-height: 44px; width: 100%;
}
textarea { resize: vertical; }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 3px solid var(--web); outline-offset: 0; border-color: var(--web); }

.input-with-toggle { display: flex; gap: 8px; }
.input-with-toggle input { flex: 1; min-width: 0; }

.check { display: flex; align-items: center; gap: 10px; min-height: 44px; }
.check input { width: 20px; height: 20px; min-height: 0; }

.fieldset { border: 1px solid var(--line-soft); border-radius: var(--radius); padding: 16px; margin: 0; display: flex; flex-direction: column; gap: 14px; }
.fieldset legend { font-weight: 700; padding: 0 6px; }
.fieldset legend em { font-style: normal; font-weight: 400; color: var(--muted); font-size: 13px; }

.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr)); gap: 16px; }
.form-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; padding-top: 4px; }

.metric-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 150px), 1fr)); gap: 14px; align-items: end; }
.metric-form .field-wide { grid-column: 1 / -1; }

.help summary { cursor: pointer; font-weight: 600; min-height: 32px; }
.help dl { margin: 8px 0 0; display: flex; flex-direction: column; gap: 4px; font-size: 14px; }
.help dt { font-weight: 700; margin-top: 8px; }
.help dd { margin: 0; color: var(--muted); }

.filters { display: flex; flex-wrap: wrap; gap: 6px; }
.filters a {
  display: inline-flex; align-items: center; min-height: 40px; padding: 0 14px; border-radius: 999px;
  border: 1px solid var(--line); color: var(--ink); text-decoration: none; font-weight: 550; font-size: 15px;
}
.filters a[aria-current="page"] { background: var(--ink); color: var(--surface); border-color: var(--ink); }

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; padding: 0 16px; border-radius: 8px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  font: inherit; font-weight: 600; font-size: 15px; text-decoration: none; cursor: pointer; white-space: nowrap;
}
.btn:hover { border-color: var(--ink); color: var(--ink); }
.btn-primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn-primary:hover { background: var(--accent); border-color: var(--accent); color: var(--brand-ink); }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-ghost:hover { background: var(--ground); border-color: transparent; }
.btn-danger { color: var(--down); border-color: var(--down); background: transparent; }
.btn-danger:hover { background: var(--error-bg); color: var(--down); border-color: var(--down); }
.btn-on-brand { background: transparent; color: var(--brand-ink); border-color: rgba(255, 255, 255, 0.4); }
.btn-on-brand:hover { background: var(--brand-hover); color: var(--brand-ink); border-color: var(--brand-ink); }
.btn-small { min-height: 36px; padding: 0 12px; font-size: 14px; }
.btn-block { width: 100%; }

.danger-zone { border-top: 1px solid var(--line); padding-top: 24px; margin-top: 12px; align-items: flex-start; }
.danger-inline { align-self: flex-start; }

/* ---------- Meldungen ---------- */

.flash { padding: 12px 16px; border-radius: 8px; background: var(--info-bg); display: flex; flex-direction: column; gap: 4px; }
.flash-success { background: var(--success-bg); }
.flash-error { background: var(--error-bg); color: var(--ink); border-left: 0; }
.flash-info { background: var(--info-bg); }

@media (max-width: 640px) {
  .topbar-user { display: none; }
  .logout { margin-left: auto; }
  .mainnav { order: 3; flex-basis: 100%; }
  .kpi dd { font-size: 24px; }
  .details dt { flex-basis: 100%; }
  .row-actions { white-space: normal; }
}

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