/* Design Tokens */
:root{
  --bg: #0b0e14;
  --surface: #141824;
  --card: #1a2030;
  --text: #e8ebf3;
  --muted: #9aa3b2;
  --primary: #6ea8fe;
  --primary-600: #4f8cff;
  --primary-700: #2f55c7;
  --border: #273046;
  --ok-bg:#193824; --ok:#7ee2a8;
  --warn-bg:#3a2f1f; --warn:#facc15;
  --error-bg:#3a2123; --error:#f39aa5;

  --radius: 14px;
  --radius-sm: 10px;
  --gap: 16px;
  --gap-lg: 24px;
  --shadow: 0 10px 30px rgba(0,0,0,.35), 0 1px 0 rgba(255,255,255,.02) inset;

  /* Fluid Typography */
  --font-size: clamp(15px, 1.4vw, 16px);
  --h1-size: clamp(22px, 3.2vw, 28px);
  --h2-size: clamp(18px, 2.2vw, 22px);
}

@media (prefers-color-scheme: light){
  :root{
    --bg:#f6f8fb; --surface:#ffffff; --card:#ffffff; --text:#0f172a; --muted:#64748b;
    --primary:#3b82f6; --primary-600:#2563eb; --primary-700:#1d4ed8; --border:#e5e7eb;
    --ok-bg:#e7f5e7; --ok:#166534; --warn-bg:#fff7e0; --warn:#92400e; --error-bg:#ffe6e9; --error:#9f1239;
    --shadow: 0 12px 28px rgba(2,6,23,.06), 0 1px 0 rgba(255,255,255,.6) inset;
  }
}

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

*{ box-sizing:border-box; }
html,body{ height:100%; }
body{
  margin:0;
  background:
    radial-gradient(1000px 600px at 10% -10%, color-mix(in oklab, var(--primary) 12%, transparent), transparent 60%),
    radial-gradient(800px 500px at 110% 10%, color-mix(in oklab, var(--primary) 10%, transparent), transparent 60%),
    var(--bg);
  color:var(--text);
  font: 400 var(--font-size)/1.55 "Inter", system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  padding-bottom: env(safe-area-inset-bottom, 0);
}

/* Header */
.header{
  padding: 18px 16px 0;
}
.header h1{
  margin:0;
  letter-spacing:.2px;
  font-weight: 700;
  font-size: var(--h1-size);
}

/* Layout Container */
.container{
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
  padding: 16px;
}
@media (min-width: 768px){
  .container{ padding: 20px; }
}

/* Cards */
.card{
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: clamp(14px, 2.5vw, 18px);
  margin: 16px 0;
  box-shadow: var(--shadow);
  backdrop-filter: saturate(120%) blur(6px);
}
.card-title{
  display:flex; align-items:center; justify-content:space-between;
  margin-bottom: 8px;
}
.card h2{ margin: 6px 0 10px; font-size: var(--h2-size); font-weight: 700; }

/* Alerts */
.alert{
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  margin-bottom: 12px;
  font-weight: 500;
}
.alert-ok{ background: var(--ok-bg); color: var(--ok); border: 1px solid color-mix(in oklab, var(--ok) 30%, transparent); }
.alert-error{ background: var(--error-bg); color: var(--error); border: 1px solid color-mix(in oklab, var(--error) 30%, transparent); }

/* Forms */
.form{ display:flex; flex-direction:column; gap: var(--gap); }

.field label{
  display:block; margin-bottom:6px; font-weight:600; color:var(--text);
}
.field input[type="text"],
.field input[type="date"],
.field input[type="password"],
.field textarea{
  width:100%;
  appearance:none;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  outline: none;
  transition: border-color .2s, box-shadow .2s, transform .02s, background .2s;
}
.field input::placeholder,
.field textarea::placeholder{
  color: color-mix(in oklab, var(--muted) 80%, transparent);
}
.field input:focus,
.field textarea:focus{
  border-color: color-mix(in oklab, var(--primary) 60%, var(--border));
  box-shadow: 0 0 0 4px color-mix(in oklab, var(--primary) 18%, transparent);
  background: color-mix(in oklab, var(--surface) 92%, white 8%);
}

/* Textarea */
.field textarea{
  min-height: 120px;
  resize: vertical;
  line-height: 1.5;
}

/* Grid (Form-Layout) */
.grid{
  display:grid;
  grid-template-columns: 1fr;
  gap: var(--gap);
}
@media (min-width: 720px){
  .grid{ grid-template-columns: 1fr 1fr; }
}

/* Actions / Buttons */
.actions{
  display:flex; gap: 10px; flex-wrap:wrap;
}
.btn{
  appearance:none;
  border:1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  cursor:pointer;
  min-height: 44px; /* Touch-Ziel */
  transition: transform .02s, background .2s, border-color .2s, box-shadow .2s;
  font-weight: 600;
}
.btn:hover{ border-color: color-mix(in oklab, var(--primary) 40%, var(--border)); }
.btn:active{ transform: translateY(1px); }
.btn.primary{
  background: linear-gradient(180deg, color-mix(in oklab, var(--primary) 12%, white), var(--primary));
  border-color: var(--primary-700);
  color: white;
  box-shadow: 0 6px 16px color-mix(in oklab, var(--primary) 25%, transparent);
}
.btn.primary:hover{ background: linear-gradient(180deg, color-mix(in oklab, var(--primary) 8%, white), var(--primary-600)); }
.btn.small{ padding: 10px 12px; border-radius: 9px; font-size: 14px; min-height: 40px; }

@media (max-width: 560px){
  .actions{ gap: 8px; }
  .btn, .btn.primary{ flex: 1 1 auto; } /* Buttons füllen die Zeile auf Mobile */
}

/* Inline-Form */
.inline-form{ display:inline; }

/* Table Wrapper */
.table-wrap{
  overflow:auto;
  border-radius: var(--radius-sm);
  border:1px solid var(--border);
  -webkit-overflow-scrolling: touch;
  scroll-snap-type: x mandatory;
}

/* Table */
.table{
  width:100%;
  border-collapse: collapse;
  background: var(--surface);
  min-width: 700px; /* Desktop-Layout */
}
.table th, .table td{
  padding: 12px 12px;
  border-bottom: 1px solid var(--border);
  text-align:left;
  vertical-align: top;
}
.table thead th{
  position: sticky; top: 0;
  background: linear-gradient(0deg, var(--surface), var(--card));
  font-weight: 700;
  z-index:1;
}
.table tr:hover td{ background: color-mix(in oklab, var(--surface) 92%, var(--primary) 8%); }

/* Mobile Table Optimierung: mehr Luft und größere Zeilenhöhen */
@media (max-width: 560px){
  .table{ min-width: 100%; }
  .table th, .table td{ padding: 10px 10px; }
}

/* Badges */
.badge{
  display:inline-block; font-size:12px; font-weight:700;
  padding: 4px 10px; border-radius: 999px; border:1px solid var(--border);
}
.badge.ok{ color: var(--ok); background: var(--ok-bg); border-color: color-mix(in oklab, var(--ok) 30%, transparent); }
.badge.warn{ color: var(--warn); background: var(--warn-bg); border-color: color-mix(in oklab, var(--warn) 30%, transparent); }

/* Muted Text */
.muted{ color: var(--muted); font-size: 12px; }

/* Mehrzeiligen Text korrekt umbrechen */
.multiline{
  white-space: pre-wrap;
  word-break: break-word;
}

/* Fokus sichtbar für Tastaturnutzer */
:focus-visible{
  outline: 3px solid color-mix(in oklab, var(--primary) 55%, transparent);
  outline-offset: 2px;
  border-radius: 8px;
}

/* Kleine kosmetische Effekte */
.table tr{
  transition: background-color .15s ease;
}
.card{
  transition: transform .08s ease, box-shadow .2s ease, background .2s ease;
}
.card:hover{
  transform: translateY(-1px);
}

/* Utility: Abstand oben im Header-Inhalt auf großen Bildschirmen */
@media (min-width: 1024px){
  .header{ padding: 24px 20px 0; }
}
