:root {
  --ink: #101418;
  --muted: #626973;
  --paper: #ffffff;
  --canvas: #f1f3f5;
  --line: #dcdfe4;
  --line-soft: #e9ebef;
  --navy: #0e2231;
  --navy-soft: #eaeff3;
  --accent: #0f6f7a;
  --accent-soft: #e6f2f3;
  --success: #12735e;
  --danger: #a3293d;
  --danger-soft: #fbecee;
  --success-soft: #e8f4f0;
  --shadow: 0 24px 60px rgba(16, 20, 24, 0.07);
  --radius: 18px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--canvas);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}

button, input, textarea, select { font: inherit; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---------- Kopfzeile ---------- */

.topbar {
  min-height: 78px;
  padding: 16px clamp(20px, 5vw, 68px);
  background: rgba(255, 255, 255, 0.92);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  backdrop-filter: blur(16px);
  position: sticky;
  top: 0;
  z-index: 10;
}

.topbar-primary { min-width: 0; display: flex; align-items: center; gap: 16px; }
.brand {
  display: flex; align-items: center; gap: 16px;
  color: var(--ink); text-decoration: none;
  font-size: 13px; font-weight: 750; letter-spacing: .02em; white-space: nowrap;
}
.brand img { width: 118px; height: auto; display: block; }
.brand-divider { width: 1px; height: 26px; background: var(--line); }
.topbar-nav { display: flex; align-items: center; gap: 2px; }
.topbar-link {
  padding: 9px 13px; border-radius: 9px; color: var(--muted);
  font-size: 12px; font-weight: 750; text-decoration: none;
  transition: color .18s, background .18s;
}
.topbar-link:hover, .topbar-link.is-active { color: var(--accent); background: var(--accent-soft); }

.topbar-actions { display: flex; align-items: center; gap: 14px; }
.status-pill {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 8px 13px; border: 1px solid var(--line); border-radius: 999px;
  color: var(--muted); background: #fff; font-size: 12px; font-weight: 650; white-space: nowrap;
}
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--success); box-shadow: 0 0 0 4px rgba(18, 115, 94, .1); }
.logout-link { color: var(--muted); font-size: 11px; font-weight: 750; text-decoration: none; }
.logout-link:hover { color: var(--accent); }

/* ---------- Anmeldung ---------- */

.login-page {
  min-height: 100vh;
  background:
    radial-gradient(circle at 12% 8%, rgba(15, 111, 122, .12), transparent 34%),
    radial-gradient(circle at 88% 88%, rgba(14, 34, 49, .1), transparent 36%),
    var(--canvas);
}
.login-shell { min-height: 100vh; padding: 32px 18px; display: grid; place-items: center; }
.login-card {
  width: min(400px, 100%); padding: 36px;
  border: 1px solid var(--line); border-radius: 22px; background: #fff; box-shadow: var(--shadow);
}
.login-brands {
  display: flex; align-items: center; justify-content: center; gap: 26px;
  margin: 0 0 20px;
}
/* Optisch ausgeglichen: das Cotana-Zeichen traegt einen Rahmen und wirkt dadurch schwerer. */
.login-brands img { width: auto; max-width: 42%; display: block; }
.login-brands .login-brand-agiletics { height: 32px; }
.login-brands .login-brand-cotana { height: 26px; }
.login-title {
  margin: 0 0 26px; text-align: center;
  font-size: 26px; font-weight: 700; letter-spacing: -.02em; color: var(--navy);
}
.login-card .field { margin-bottom: 16px; }
.login-card .field:first-of-type { margin-top: 0; }
.login-card .alert { margin-bottom: 22px; }

/* ---------- Grundgerüst ---------- */

.page-shell { padding: clamp(28px, 4vw, 46px) clamp(20px, 5vw, 68px) 40px; max-width: 1420px; margin: 0 auto; }

.hero {
  display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between;
  gap: 24px; margin: 0 0 30px;
}
.hero h1 { margin: 6px 0 0; font-size: clamp(30px, 4vw, 44px); line-height: 1.05; letter-spacing: -.03em; }
.hero h1 span { color: var(--muted); }
.eyebrow { margin: 0; font-size: 11px; font-weight: 800; letter-spacing: .13em; text-transform: uppercase; color: var(--accent); }
.intro-copy { margin: 0; max-width: 46ch; color: var(--muted); font-size: 14px; line-height: 1.6; }

.workspace-grid { display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(300px, .85fr); gap: 24px; align-items: start; }

.panel {
  padding: clamp(22px, 2.6vw, 32px);
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--paper); box-shadow: var(--shadow);
}
.sidebar { display: grid; gap: 20px; }
.sidebar .panel { padding: 24px; }

.panel-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin: 0 0 22px; }
.panel-heading.compact { margin-bottom: 18px; }
.panel-heading h2 { margin: 6px 0 0; font-size: 19px; letter-spacing: -.015em; }
.panel-heading h3 { margin: 6px 0 0; font-size: 16px; letter-spacing: -.01em; }
.step-number {
  display: inline-block; padding: 3px 8px; border-radius: 6px;
  background: var(--navy-soft); color: var(--navy);
  font-size: 11px; font-weight: 800; letter-spacing: .06em;
}
.badge, .pill, .count-badge {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line);
  background: #fff; color: var(--muted); font-size: 11px; font-weight: 750; white-space: nowrap;
}
.pill { border-color: transparent; background: var(--accent-soft); color: var(--accent); }
.count-badge { min-width: 30px; }
.section-rule { height: 1px; background: var(--line-soft); margin: 28px 0; }
.back-link { color: var(--muted); font-size: 12px; font-weight: 750; text-decoration: none; white-space: nowrap; }
.back-link:hover { color: var(--accent); }

/* ---------- Formularelemente ---------- */

.field { display: block; margin-bottom: 18px; }
.field > span { display: block; margin: 0 0 7px; font-size: 12px; font-weight: 750; letter-spacing: .01em; }
.field > span small { font-weight: 600; color: var(--muted); text-transform: none; letter-spacing: 0; }
.field input, .field textarea, .field select {
  width: 100%; padding: 11px 13px;
  border: 1px solid var(--line); border-radius: 11px; background: #fff; color: var(--ink);
  font-size: 14px; transition: border-color .16s, box-shadow .16s;
}
.field textarea { resize: vertical; line-height: 1.5; }
.field select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%; background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; padding-right: 36px; }
.field input:focus, .field textarea:focus, .field select:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(15, 111, 122, .13);
}
.field-help { display: block; margin: 6px 0 0; color: var(--muted); font-size: 11.5px; line-height: 1.45; }

.unit-input { position: relative; display: flex; align-items: center; }
.unit-input input { padding-right: 52px; }
.unit-input > span {
  position: absolute; right: 13px; color: var(--muted);
  font-size: 12px; font-weight: 750; pointer-events: none;
}

.form-grid { display: grid; gap: 0 18px; }
.form-grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.conditional[hidden] { display: none; }
.settings-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 0 20px; }

/* ---------- Markenauswahl ---------- */

.brand-choice { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; margin: 0 0 22px; padding: 0; border: 0; }
.brand-card { position: relative; display: block; cursor: pointer; }
.brand-card input { position: absolute; opacity: 0; pointer-events: none; }
.brand-card-body {
  display: flex; align-items: center; justify-content: center;
  min-height: 104px; padding: 20px;
  border: 1.5px solid var(--line); border-radius: 14px; background: #fff;
  transition: border-color .16s, box-shadow .16s, background .16s;
}
.brand-card-body img { width: auto; max-width: 100%; display: block; }
.brand-card-body .brand-logo-agiletics { height: 46px; }
.brand-card-body .brand-logo-cotana { height: 36px; }
.brand-card:hover .brand-card-body { border-color: #bfc5cc; }
.brand-card input:checked + .brand-card-body {
  border-color: var(--navy); background: #fbfcfd;
  box-shadow: 0 0 0 3px rgba(14, 34, 49, .08);
}
.brand-card input:focus-visible + .brand-card-body { box-shadow: 0 0 0 3px rgba(15, 111, 122, .3); }

/* ---------- Preisvorschau ---------- */

.price-summary {
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1px;
  margin: 6px 0 0; border: 1px solid var(--line); border-radius: 13px;
  background: var(--line-soft); overflow: hidden;
}
.price-summary > div { padding: 15px 16px; background: #fff; display: grid; gap: 5px; }
.price-summary span { color: var(--muted); font-size: 11px; font-weight: 750; letter-spacing: .02em; }
.price-summary strong { font-size: 16px; letter-spacing: -.01em; font-variant-numeric: tabular-nums; }
.price-summary .price-total { background: var(--navy); }
.price-summary .price-total span { color: rgba(255, 255, 255, .66); }
.price-summary .price-total strong { color: #fff; }
.preview-note { margin: 10px 0 0; color: var(--muted); font-size: 11.5px; line-height: 1.5; }
.preview-note[hidden] { display: none; }

/* ---------- Aktionen ---------- */

.action-row { display: flex; flex-wrap: wrap; gap: 12px; margin: 24px 0 0; }
.primary-button {
  display: inline-flex; align-items: center; gap: 10px;
  padding: 13px 22px; border: 0; border-radius: 11px;
  background: var(--navy); color: #fff;
  font-size: 13.5px; font-weight: 750; cursor: pointer;
  transition: background .16s, transform .16s;
}
.primary-button:hover { background: #17384e; transform: translateY(-1px); }
.primary-button svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.login-card .primary-button { width: 100%; justify-content: center; margin-top: 8px; }
.secondary-button {
  display: inline-flex; align-items: center;
  padding: 13px 20px; border: 1px solid var(--line); border-radius: 11px;
  background: #fff; color: var(--ink); font-size: 13.5px; font-weight: 700; cursor: pointer;
  transition: border-color .16s, background .16s;
}
.secondary-button:hover { border-color: #bfc5cc; background: #fafbfc; }
.action-note { margin: 14px 0 0; color: var(--muted); font-size: 11.5px; line-height: 1.5; }
.action-note code, .quiet-card code {
  padding: 2px 6px; border-radius: 5px; background: var(--canvas);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 11px;
}

/* ---------- Hinweise ---------- */

.alert { padding: 14px 18px; border-radius: 12px; margin: 0 0 22px; font-size: 13.5px; line-height: 1.5; }
.alert-error { background: var(--danger-soft); color: var(--danger); border: 1px solid rgba(163, 41, 61, .2); }
.alert-success { background: var(--success-soft); color: var(--success); border: 1px solid rgba(18, 115, 94, .2); }

.empty-state { padding: 34px 22px; text-align: center; color: var(--muted); }
.empty-state span { display: block; font-size: 26px; opacity: .35; margin-bottom: 10px; }
.empty-state h3 { margin: 0 0 6px; color: var(--ink); font-size: 15px; }
.empty-state p { margin: 0; font-size: 13px; line-height: 1.55; }
.muted { color: var(--muted); }

/* ---------- Seitenleiste ---------- */

.accent-card { background: linear-gradient(160deg, #fff 0%, var(--accent-soft) 130%); }
.accent-card h3 { margin: 6px 0 16px; font-size: 18px; letter-spacing: -.015em; }
.accent-card > p:last-child { margin: 16px 0 0; color: var(--muted); font-size: 12.5px; line-height: 1.55; }
.counter-list { display: grid; gap: 10px; }
.counter-list > div {
  display: flex; align-items: center; gap: 11px;
  padding: 11px 13px; border: 1px solid var(--line); border-radius: 11px; background: #fff;
}
.counter-name { flex: 1; font-size: 13px; font-weight: 700; }
.counter-list strong { font-size: 13px; font-variant-numeric: tabular-nums; }

.brand-chip {
  display: inline-flex; align-items: center; justify-content: center;
  width: 26px; height: 26px; flex: 0 0 26px; border-radius: 8px;
  background: var(--navy); color: #fff; font-size: 11px; font-weight: 800;
}
.brand-chip.is-cotana { background: var(--accent); }

.invoice-list { display: grid; gap: 8px; }
.invoice-list a {
  display: flex; align-items: center; gap: 11px;
  padding: 11px 12px; border: 1px solid var(--line-soft); border-radius: 11px;
  color: var(--ink); text-decoration: none; transition: border-color .16s, background .16s;
}
.invoice-list a:hover { border-color: var(--line); background: #fafbfc; }
.invoice-meta { flex: 1; min-width: 0; display: grid; gap: 2px; }
.invoice-meta strong { font-size: 13px; }
.invoice-meta small { color: var(--muted); font-size: 11px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.invoice-amount { font-size: 12.5px; font-weight: 750; white-space: nowrap; font-variant-numeric: tabular-nums; }

.quiet-card { background: #fbfbfc; }
.quiet-card p { margin: 8px 0 18px; color: var(--muted); font-size: 12.5px; line-height: 1.55; }
.quiet-card p:last-child { margin-bottom: 0; }

/* ---------- Archivtabelle ---------- */

.table-wrap { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table th {
  padding: 0 14px 12px; text-align: left; white-space: nowrap;
  border-bottom: 1px solid var(--line);
  color: var(--muted); font-size: 11px; font-weight: 800; letter-spacing: .07em; text-transform: uppercase;
}
.data-table td { padding: 13px 14px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
.data-table tr:last-child td { border-bottom: 0; }
.data-table th:first-child, .data-table td:first-child { padding-left: 0; }
.data-table th:last-child, .data-table td:last-child { padding-right: 0; }
.data-table .money { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.data-table .action { text-align: right; }
.cell-invoice { display: flex; align-items: center; gap: 10px; white-space: nowrap; }
.tag {
  display: inline-block; padding: 4px 9px; border-radius: 7px;
  background: var(--navy-soft); color: var(--navy); font-size: 11.5px; font-weight: 700; white-space: nowrap;
}
.tag-sub { display: block; margin-top: 4px; color: var(--muted); font-size: 10.5px; font-weight: 650; }
.download-button {
  display: inline-block; padding: 8px 14px; border: 1px solid var(--line); border-radius: 9px;
  background: #fff; color: var(--ink); font-size: 12px; font-weight: 750; text-decoration: none;
  transition: border-color .16s, background .16s;
}
.download-button:hover { border-color: var(--navy); background: #fafbfc; }

/* ---------- Fußzeile ---------- */

footer {
  display: flex; flex-wrap: wrap; justify-content: space-between; gap: 12px;
  padding: 26px clamp(20px, 5vw, 68px) 34px;
  border-top: 1px solid var(--line);
  color: var(--muted); font-size: 11.5px;
}

@media (max-width: 1080px) {
  .workspace-grid { grid-template-columns: minmax(0, 1fr); }
  .form-grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 720px) {
  .topbar { flex-wrap: wrap; }
  .brand img { width: 96px; }
  .form-grid-2, .form-grid-3 { grid-template-columns: minmax(0, 1fr); }
  .brand-choice { grid-template-columns: minmax(0, 1fr); }
  .price-summary { grid-template-columns: minmax(0, 1fr); }
}
