/* alerno Direkt — Erfassungs-WebApp · modernes, ruhiges Tool-UI */

:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #fbfcfd;
  --primary: #2d6cdf;
  --primary-dark: #2256bd;
  --primary-soft: #eaf1fe;
  --success: #15a34a;
  --success-soft: #e8f7ee;
  --danger: #dc2626;
  --danger-soft: #fdeeee;
  --text: #1e293b;
  --muted: #64748b;
  --line: #e4e8ee;
  --line-strong: #cdd5e0;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .05);
  --shadow: 0 6px 24px rgba(16, 24, 40, .08);
  --shadow-lg: 0 16px 48px rgba(16, 24, 40, .14);
  --ring: 0 0 0 4px rgba(45, 108, 223, .18);
  --tap: 50px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  line-height: 1.5;
}
[hidden] { display: none !important; }

/* ---------- Brand ---------- */
.brand { display: flex; align-items: center; gap: 14px; }
.brand-mark {
  display: grid; place-items: center;
  width: 48px; height: 48px; border-radius: 12px;
  background: linear-gradient(135deg, var(--primary), #4f86f0);
  color: #fff; font-weight: 700; font-size: 18px; letter-spacing: .5px;
  box-shadow: var(--shadow-sm); flex: none;
}
.brand-mark.sm { width: 34px; height: 34px; border-radius: 9px; font-size: 13px; }
.brand-title { font-weight: 700; font-size: 20px; letter-spacing: -.2px; }
.brand-sub { color: var(--muted); font-size: 13px; }

/* ---------- Login ---------- */
.login-screen {
  min-height: 100%; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 18px; padding: 24px;
  background: radial-gradient(120% 80% at 50% -10%, #eef3fd 0%, var(--bg) 55%);
}
.login-card {
  width: 100%; max-width: 400px; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow-lg); padding: 30px 28px;
  display: flex; flex-direction: column; gap: 16px;
}
.login-hint { margin: 4px 0 2px; color: var(--muted); font-size: 14px; }
.login-foot { color: var(--muted); font-size: 12px; }

/* ---------- App-Shell ---------- */
.app { min-height: 100%; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 12px 20px; background: rgba(255,255,255,.85);
  backdrop-filter: saturate(140%) blur(8px);
  border-bottom: 1px solid var(--line);
}
.topbar-brand { display: flex; align-items: center; gap: 10px; }
.topbar-title { font-weight: 600; font-size: 15px; }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.badge {
  font-size: 12.5px; font-weight: 600; color: var(--primary);
  background: var(--primary-soft); padding: 6px 12px; border-radius: 999px;
}
.badge-test { color: #92500e; background: #fdf0d8; }

/* ---------- Schritt-Anzeige ---------- */
.steps {
  display: flex; gap: 8px; padding: 16px 20px 4px;
  max-width: 760px; width: 100%; margin: 0 auto; overflow-x: auto;
}
.step-pill { flex: 1 1 0; min-width: 92px; display: flex; flex-direction: column; gap: 7px; }
.step-bar { height: 5px; border-radius: 999px; background: var(--line); transition: background .25s; }
.step-pill.active .step-bar { background: var(--primary); }
.step-pill.done .step-bar { background: var(--success); }
.step-meta { display: flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--muted); }
.step-pill.active .step-meta { color: var(--text); font-weight: 600; }
.step-num {
  width: 19px; height: 19px; border-radius: 50%; flex: none;
  display: grid; place-items: center; font-size: 11px; font-weight: 700;
  background: var(--line); color: var(--muted);
}
.step-pill.active .step-num { background: var(--primary); color: #fff; }
.step-pill.done .step-num { background: var(--success); color: #fff; }

/* ---------- Content ---------- */
.content { flex: 1; width: 100%; max-width: 760px; margin: 0 auto; padding: 12px 20px 110px; }
.step-h { font-size: 22px; font-weight: 700; letter-spacing: -.3px; margin: 14px 0 4px; }
.step-desc { color: var(--muted); margin: 0 0 20px; font-size: 14.5px; }
.step-panel { animation: rise .28s ease; }
@keyframes rise { from { opacity: 0; transform: translateY(7px); } to { opacity: 1; transform: none; } }

/* ---------- Formfelder ---------- */
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 16px; }
.grid.mt { margin-top: 18px; }
.field { display: flex; flex-direction: column; gap: 7px; }
.field.span-2 { grid-column: 1 / -1; }
.field-label { font-size: 13px; font-weight: 600; color: #475569; }
input, select {
  font: inherit; color: var(--text); background: var(--surface);
  border: 1.5px solid var(--line-strong); border-radius: var(--radius-sm);
  padding: 0 14px; min-height: var(--tap); width: 100%;
  transition: border-color .15s, box-shadow .15s; appearance: none;
}
select { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 40px; }
input::placeholder { color: #aab3c0; }
input:focus, select:focus { outline: none; border-color: var(--primary); box-shadow: var(--ring); }
.field.invalid input, .field.invalid select { border-color: var(--danger); }
.field-err { color: var(--danger); font-size: 12.5px; font-weight: 500; min-height: 0; }

.check { display: flex; align-items: center; gap: 11px; margin-bottom: 16px; font-size: 14.5px; cursor: pointer; user-select: none; }
.check input { width: 22px; height: 22px; min-height: 0; accent-color: var(--primary); flex: none; }

.sepa-note { margin-top: 18px; font-size: 13px; color: var(--muted); background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 12px 14px; }

/* ---------- Produktauswahl ---------- */
.product-list { display: flex; flex-direction: column; gap: 11px; }
.product {
  display: flex; align-items: center; gap: 14px; cursor: pointer;
  border: 1.5px solid var(--line-strong); border-radius: var(--radius);
  padding: 15px 16px; background: var(--surface); transition: all .15s;
}
.product:hover { border-color: var(--line-strong); box-shadow: var(--shadow-sm); }
.product.sel { border-color: var(--primary); background: var(--primary-soft); box-shadow: var(--ring); }
.product-radio { width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--line-strong); flex: none; display: grid; place-items: center; transition: border-color .15s; }
.product.sel .product-radio { border-color: var(--primary); }
.product.sel .product-radio::after { content: ""; width: 11px; height: 11px; border-radius: 50%; background: var(--primary); }
.product-main { flex: 1; min-width: 0; }
.product-name { font-weight: 600; font-size: 15px; }
.product-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.tag { font-size: 11.5px; font-weight: 600; color: var(--muted); background: var(--surface-2); border: 1px solid var(--line); padding: 3px 9px; border-radius: 999px; }
.product-price { flex: none; text-align: right; font-weight: 700; font-size: 17px; color: var(--text); white-space: nowrap; }
.product-price span { display: block; font-size: 11px; font-weight: 500; color: var(--muted); }
.product.sel .product-price { color: var(--primary-dark); }

/* ---------- Vorschau ---------- */
.preview { display: flex; flex-direction: column; gap: 14px; }
.pv-card { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); overflow: hidden; }
.pv-head { display: flex; align-items: center; justify-content: space-between; padding: 13px 16px; background: var(--surface-2); border-bottom: 1px solid var(--line); }
.pv-title { font-weight: 600; font-size: 14px; }
.pv-edit { font-size: 13px; font-weight: 600; color: var(--primary); background: none; border: none; cursor: pointer; padding: 4px; }
.pv-rows { padding: 6px 16px 12px; }
.pv-row { display: flex; justify-content: space-between; gap: 16px; padding: 8px 0; border-bottom: 1px dashed var(--line); font-size: 14px; }
.pv-row:last-child { border-bottom: none; }
.pv-row .k { color: var(--muted); }
.pv-row .v { font-weight: 600; text-align: right; word-break: break-word; }
.sign-area { margin-top: 4px; }
.sign-area .pv-head { padding: 13px 16px; }
.sign-wrap { position: relative; margin: 14px 16px; }
.sign-pad { display: block; width: 100%; height: 190px; background: var(--surface-2); border: 1.5px dashed var(--line-strong); border-radius: var(--radius-sm); touch-action: none; cursor: crosshair; }
.sign-placeholder { position: absolute; inset: 0; display: grid; place-items: center; color: #aab3c0; font-size: 15px; pointer-events: none; }
.sign-area .btn { margin: 0 16px 16px; width: calc(100% - 32px); }

.pv-derived { background: linear-gradient(180deg, #f3f8ff, var(--surface)); border-color: #cfe0fb; }
.pv-derived .pv-head { background: transparent; border-bottom-color: #dce8fc; }
.pv-derived .pv-title { color: var(--primary-dark); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 9px;
  font: inherit; font-weight: 600; font-size: 15px; cursor: pointer;
  border: 1.5px solid transparent; border-radius: var(--radius-sm);
  min-height: var(--tap); padding: 0 22px; transition: all .15s; white-space: nowrap;
}
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-sm { min-height: 38px; padding: 0 14px; font-size: 14px; }
.btn-block { width: 100%; }
.btn-primary { background: var(--primary); color: #fff; box-shadow: var(--shadow-sm); }
.btn-primary:hover:not(:disabled) { background: var(--primary-dark); }
.btn-success { background: var(--success); color: #fff; box-shadow: var(--shadow-sm); }
.btn-success:hover:not(:disabled) { filter: brightness(.95); }
.btn-ghost { background: var(--surface); color: var(--muted); border-color: var(--line-strong); }
.btn-ghost:hover:not(:disabled) { color: var(--text); border-color: var(--line-strong); background: var(--surface-2); }

/* ---------- Footer-Navigation ---------- */
.navbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: flex; align-items: center; gap: 12px;
  padding: 14px 20px calc(14px + env(safe-area-inset-bottom));
  background: rgba(255,255,255,.9); backdrop-filter: blur(8px);
  border-top: 1px solid var(--line);
}
.navbar > .btn { max-width: 760px; }
.navbar-spacer { flex: 1; }
.navbar .btn-primary, .navbar .btn-success { min-width: 170px; }

/* ---------- Alerts ---------- */
.alert { border-radius: var(--radius-sm); padding: 12px 14px; font-size: 14px; font-weight: 500; }
.alert-error { background: var(--danger-soft); color: #a51b1b; border: 1px solid #f3c8c8; }
.alert ul { margin: 6px 0 0; padding-left: 18px; }

/* ---------- Spinner ---------- */
.spinner { width: 18px; height: 18px; border-radius: 50%; border: 2.5px solid rgba(255,255,255,.45); border-top-color: #fff; animation: spin .7s linear infinite; }
.btn-ghost .spinner, .pv-edit .spinner { border-color: rgba(45,108,223,.3); border-top-color: var(--primary); }
@keyframes spin { to { transform: rotate(360deg); } }
.is-loading .btn-label { opacity: .7; }

/* ---------- Erfolg ---------- */
.done-screen { min-height: 100%; display: grid; place-items: center; padding: 24px; }
.done-card { width: 100%; max-width: 440px; text-align: center; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 36px 28px; }
.done-icon { width: 64px; height: 64px; margin: 0 auto 18px; border-radius: 50%; display: grid; place-items: center; background: var(--success-soft); }
.done-icon.test { background: #fdf0d8; }
.done-icon svg { width: 34px; height: 34px; }
.done-card h2 { margin: 0 0 8px; font-size: 22px; }
.done-text { color: var(--muted); margin: 0 0 20px; }
.done-meta { text-align: left; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 6px 14px; margin-bottom: 22px; }
.done-meta .pv-row { font-size: 13.5px; }

/* ---------- Responsive ---------- */
@media (max-width: 560px) {
  .grid { grid-template-columns: 1fr; }
  .field.span-2 { grid-column: auto; }
  .step-pill .step-label { display: none; }
  .step-pill { min-width: 0; }
  .navbar .btn-primary, .navbar .btn-success { min-width: 130px; }
  .step-h { font-size: 20px; }
}
