/* =========================================================
   Basis: Schriften, Farben, Formulare, Buttons, Dialoge
   ========================================================= */

@font-face {
  font-family: 'Manrope';
  font-style: normal;
  font-weight: 200 800;
  font-display: swap;
  src: url('/fonts/manrope-latin.woff2') format('woff2');
}
@font-face {
  font-family: 'Fraunces';
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url('/fonts/fraunces-latin.woff2') format('woff2');
}

:root {
  --bg-0: #eef1f6;
  --bg-1: #ffffff;
  --bg-2: #f6f8fb;
  --bg-3: #eceff4;
  --bg-hover: #f0f3f8;
  --border: #e2e6ee;
  --border-strong: #cdd4e0;
  --text-0: #0f1729;
  --text-1: #2b3650;
  --text-2: #5a6678;
  --text-3: #7d879a;
  --text-4: #a3abba;

  --accent: #b08322;
  --accent-strong: #946d18;
  --accent-dim: #c8a154;
  --accent-bg: rgba(176,131,34,0.10);

  --navy-0: #0d1b2e;
  --navy-1: #14263d;
  --navy-2: #1d3550;

  --danger: #dc2626;
  --danger-bg: rgba(220,38,38,0.08);
  --success: #16a34a;
  --warning: #d97706;
  --info: #2563eb;

  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 18px;

  --shadow-sm: 0 1px 2px rgba(15,23,41,0.06);
  --shadow: 0 4px 16px rgba(15,23,41,0.08), 0 1px 3px rgba(15,23,41,0.06);
  --shadow-lg: 0 24px 60px rgba(15,23,41,0.18), 0 6px 16px rgba(15,23,41,0.10);

  --font-sans: 'Manrope', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-display: 'Fraunces', Georgia, 'Times New Roman', serif;
  --font-mono: 'SF Mono', Menlo, Monaco, 'Cascadia Mono', monospace;

  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
html, body { height: 100%; }
body {
  font-family: var(--font-sans);
  background: var(--bg-0);
  color: var(--text-1);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
[hidden] { display: none !important; }
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; font-size: inherit; }
input, textarea, select { font-family: inherit; color: inherit; background: none; border: none; outline: none; font-size: inherit; }
a { color: inherit; }
img { display: block; }
:focus-visible { outline: 2px solid var(--accent-dim); outline-offset: 2px; }

.icon { width: 16px; height: 16px; flex-shrink: 0; }

/* ---------------- Buttons ---------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px; font-weight: 600;
  transition: background 0.12s, border-color 0.12s, color 0.12s, box-shadow 0.12s;
  border: 1px solid transparent;
  white-space: nowrap;
  text-decoration: none;
  min-height: 36px;
}
.btn .icon { width: 15px; height: 15px; }
.btn:disabled { opacity: 0.55; cursor: default; }
.btn-ghost { color: var(--text-2); }
.btn-ghost:hover { background: var(--bg-2); color: var(--text-0); }
.btn-secondary { background: var(--bg-2); color: var(--text-1); border-color: var(--border); }
.btn-secondary:hover { background: var(--bg-3); border-color: var(--border-strong); }
.btn-primary {
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-strong) 100%);
  color: #fff;
  box-shadow: 0 4px 14px rgba(176,131,34,0.30), inset 0 1px 0 rgba(255,255,255,0.2);
}
.btn-primary:hover:not(:disabled) { background: linear-gradient(135deg, var(--accent-dim) 0%, var(--accent) 100%); }
.btn-danger { color: var(--danger); }
.btn-danger:hover { background: var(--danger-bg); }
.btn-danger-solid { background: var(--danger); color: #fff; }
.btn-danger-solid:hover { background: #b91c1c; }
.btn-sm { padding: 5px 10px; font-size: 12px; min-height: 30px; }
.btn-block { width: 100%; }

.icon-btn {
  width: 34px; height: 34px;
  border-radius: var(--radius-sm);
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--text-3);
  transition: background 0.12s, color 0.12s;
  flex-shrink: 0;
}
.icon-btn:hover { background: var(--bg-2); color: var(--text-0); }
.icon-btn .icon { width: 17px; height: 17px; }

/* ---------------- Formulare ---------------- */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field.full { grid-column: 1 / -1; }
.field > label, .label {
  font-size: 11px; color: var(--text-3);
  text-transform: uppercase; letter-spacing: 0.06em; font-weight: 700;
}
.field .hint { font-size: 12px; color: var(--text-3); }
.input, .textarea, .select-field {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  font-size: 14px;
  color: var(--text-0);
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
  width: 100%;
  min-height: 40px;
}
.input:focus, .textarea:focus, .select-field:focus {
  border-color: var(--accent-dim);
  background: var(--bg-1);
  box-shadow: 0 0 0 3px var(--accent-bg);
}
.input::placeholder, .textarea::placeholder { color: var(--text-4); }
.input[readonly] { color: var(--text-2); }
.textarea { resize: vertical; min-height: 84px; line-height: 1.5; }
.textarea.mono { font-family: var(--font-mono); font-size: 12px; }
.select-field, .select {
  appearance: none; -webkit-appearance: none;
  cursor: pointer;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 24 24' fill='none' stroke='%238a93a6' stroke-width='2.5'><polyline points='6 9 12 15 18 9'/></svg>");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 30px;
}
.select {
  background-color: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 7px 28px 7px 10px;
  font-size: 13px;
  color: var(--text-1);
  min-height: 34px;
  max-width: 220px;
}
.select:hover { border-color: var(--border-strong); }
.select.is-set { border-color: var(--accent-dim); background-color: var(--accent-bg); color: var(--accent-strong); font-weight: 600; }

.check-row { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-1); cursor: pointer; }
.check-row input { width: 18px; height: 18px; accent-color: var(--accent); }

.error-text { color: var(--danger); font-size: 13px; }
.success-text { color: var(--success); font-size: 13px; }

/* ---------------- Dialoge ---------------- */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(13,27,46,0.45);
  -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  z-index: 100;
  opacity: 0;
  transition: opacity 0.18s;
  padding: 24px;
}
.modal-backdrop.open { opacity: 1; }
.modal {
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 560px;
  max-height: min(88vh, 88dvh);
  display: flex; flex-direction: column;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  transform: translateY(10px) scale(0.98);
  transition: transform 0.2s cubic-bezier(0.32, 0.72, 0, 1);
}
.modal-backdrop.open .modal { transform: none; }
.modal.lg { max-width: 780px; }
.modal.xl { max-width: 920px; }
.modal-head {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 10px;
  flex-shrink: 0;
}
.modal-head h2 { font-size: 16px; font-weight: 700; color: var(--text-0); flex: 1; min-width: 0; }
.modal-body { padding: 20px; overflow-y: auto; flex: 1; -webkit-overflow-scrolling: touch; }
.modal-foot {
  padding: 12px 20px;
  border-top: 1px solid var(--border);
  display: flex; justify-content: flex-end; align-items: center; gap: 8px;
  flex-shrink: 0;
  background: var(--bg-1);
}
.confirm-text { color: var(--text-1); font-size: 14px; line-height: 1.6; }
.confirm-text strong { color: var(--text-0); }

/* ---------------- Toasts ---------------- */
.toast-container {
  position: fixed;
  bottom: calc(24px + var(--safe-bottom)); right: 24px;
  z-index: 500;
  display: flex; flex-direction: column; gap: 8px;
  pointer-events: none;
}
.toast {
  background: var(--navy-0);
  color: #f1f4f9;
  border-radius: var(--radius);
  padding: 11px 16px;
  font-size: 13px; font-weight: 500;
  box-shadow: var(--shadow-lg);
  min-width: 200px; max-width: 380px;
  display: flex; align-items: center; gap: 10px;
  animation: toast-in 0.2s ease-out;
  pointer-events: auto;
}
.toast .dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; background: var(--accent-dim); }
.toast.success .dot { background: #4ade80; }
.toast.error .dot { background: #f87171; }
.toast.out { opacity: 0; transform: translateY(-4px); transition: opacity 0.2s, transform 0.2s; }
@keyframes toast-in { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }

/* Touch-Geräte: 16px verhindert Auto-Zoom auf dem iPhone, größere Tippflächen */
@media (pointer: coarse) {
  .input, .textarea, .select-field, .select { font-size: 16px; }
  .btn { min-height: 42px; }
  .btn-sm { min-height: 36px; }
  .icon-btn { width: 40px; height: 40px; }
}

@media (max-width: 767px) {
  .form-grid { grid-template-columns: 1fr; }
  .modal-backdrop { padding: 0; align-items: flex-end; }
  .modal, .modal.lg, .modal.xl {
    max-width: 100%;
    max-height: calc(100dvh - var(--safe-top) - 12px);
    border-radius: 18px 18px 0 0;
    border-bottom: none;
    transform: translateY(30px);
  }
  .modal-foot { padding-bottom: calc(12px + var(--safe-bottom)); flex-wrap: wrap; }
  .modal-body { padding: 16px; }
  .toast-container { left: 12px; right: 12px; bottom: calc(84px + var(--safe-bottom)); align-items: center; }
  .toast { max-width: 100%; width: 100%; }
}
