:root {
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  color-scheme: light;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: #f6f7f9;
  color: #111;
}

a { color: inherit; text-decoration: none; }

.container {
  max-width: 980px;
  margin: 0 auto;
  padding: 16px;
}

/* Header / Navigation */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 12px 0;
}

.brand {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.brand strong { font-size: 16px; }
.brand small { color: #556; font-size: 13px; }

.nav {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

/* Card */
.card {
  background: #fff;
  border-radius: 14px;
  padding: 16px;
  box-shadow: 0 2px 10px rgba(0,0,0,.06);
}

/* Typography */
h1 { margin: 0 0 10px 0; letter-spacing: -0.02em; }
h2 { margin: 0 0 8px 0; }
p  { margin: 10px 0; }

.muted { color: #556; }

/* Forms */
.grid {
  display: grid;
  gap: 12px;
  grid-template-columns: 1fr;
}

@media (min-width: 720px) {
  .grid { grid-template-columns: 1fr 1fr; }
}

label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 14px;
}

input, select, textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #d7dbe0;
  border-radius: 10px;
  font-size: 16px;
  background: #fff;
  outline: none;
}

input:focus, select:focus, textarea:focus {
  border-color: rgba(17,17,17,.35);
  box-shadow: 0 0 0 4px rgba(17,17,17,.06);
}

textarea { min-height: 90px; resize: vertical; }

/* Buttons */
button, .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;

  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid #d7dbe0;
  background: #fff;
  cursor: pointer;
  text-decoration: none;
  color: #111;
  font-size: 14px;
  line-height: 1;
  white-space: nowrap;
}

button:hover, .btn:hover { background: #f0f2f5; }

.btn.primary {
  background: #111;
  border-color: #111;
  color: #fff;
}

.btn.primary:hover { background: #1b1b1b; }

/* Alerts */
.alert {
  background: #ffe9e9;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid #ffc7c7;
  margin: 10px 0;
}

/* Result */
.result {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid #eee;
}

.big { font-size: 18px; }

/* Key-Value section */
.kv {
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.kv > div {
  display: flex;
  gap: 12px;
  justify-content: space-between;
  border-bottom: 1px dashed #eee;
  padding-bottom: 8px;
}

.kv span:first-child { color: #556; }
.kv span:last-child  { text-align: right; max-width: 65%; }

@media (max-width: 860px) {
  .kv span:last-child { max-width: 100%; }
}

.footnote { margin-top: 12px; font-size: 13px; }

/* Badges */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid #d7dbe0;
  background: #fff;
  font-size: 12px;
}

/* TABLE / LIST (Admin User / Medikamente) */
/* Fix: kein unnötiger Scrollbar auf Desktop, nur horizontal wenn wirklich nötig */
.table {
  width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
}

/* Optional: hübscher Scrollbar, aber unaufdringlich */
.table::-webkit-scrollbar { height: 10px; }
.table::-webkit-scrollbar-thumb { background: rgba(0,0,0,.15); border-radius: 999px; }
.table::-webkit-scrollbar-track { background: transparent; }

.row {
  display: grid;
  /* flexibler => weniger Überläufe */
  grid-template-columns: 70px minmax(140px, 1fr) 110px 80px 170px 200px;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid #f0f0f0;
  align-items: center;
}

.row.head {
  font-weight: 700;
  color: #111;
}

/* Aktionen-Spalte: Buttons/Inputs ordentlich nebeneinander */
.row > div:last-child {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  align-items: center;
  flex-wrap: wrap;
}

/* Inputs/Buttons in Tabelle sollen nicht sprengen */
.row input, .row button {
  max-width: 100%;
}

/* Mobile: stapeln, Scrollbar komplett weg */
@media (max-width: 860px) {
  .table { overflow: visible; }
  .row { grid-template-columns: 1fr; }
  .row > div:last-child { justify-content: flex-start; }
}

/* Kleine Helfer */
.spacer { height: 12px; }

/* Button unter den Feldern etwas tiefer */
.actions{
  margin-top: 18px;  /* <- Höhe anpassen, z.B. 24px */
}

/* ===== LOGIN LAYOUT ===== */

.page-center{
  display: flex;
  flex-direction: column;
}

.login-wrapper{
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.login-card{
  width: 100%;
  max-width: 520px;   /* <-- Hier steuerst du die Breite */
}

/* Optional etwas luftiger */
.login-card .card{
  padding: 24px;
}


/* Login: immer untereinander (wie Bild 2) */
.login-grid{
  display: grid;
  gap: 12px;
  grid-template-columns: 1fr !important; /* überschreibt .grid */
}

/* Button-Row im Login */
.login-actions{
  display:flex;
  justify-content:flex-start;
  margin-top: 4px;
}

/* Optional: Button nicht so breit wie das Feld */
.login-actions .btn,
.login-actions button{
  width: auto;
  min-width: 140px;
}

.footer{
  width: 100%;
  display: flex;
  justify-content: center;
  padding: 18px 12px 28px;
  font-size: 12px;
  color: #6a6f77;
}

.footer-inner{
  width: 100%;
  max-width: 520px;   /* gleiche Breite wie Login-Card */
  text-align: center;
}

/* ===== Admin UI Helpers ===== */

.card-title{
  display:flex;
  align-items:flex-end;
  justify-content:space-between;
  gap:12px;
  margin-bottom:10px;
}

.card-title h1, .card-title h2{ margin:0; }

.actions-row{
  grid-column: 1 / -1;
  display:flex;
  justify-content:flex-end;
  gap:10px;
  margin-top: 6px;
}

@media (max-width: 720px){
  .actions-row{ justify-content:stretch; }
  .actions-row button{ width:100%; }
}

/* Status Badges */
.badge.ok{
  border-color: rgba(0,0,0,.12);
  background: #eefaf2;
}
.badge.off{
  border-color: rgba(0,0,0,.12);
  background: #fff2f2;
}

/* Table row polishing */
.row{
  padding: 12px 0; /* etwas luftiger */
}

.row.head{
  color:#556;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: .04em;
}

/* Actions cell layout */
.user-actions{
  display:flex;
  gap:10px;
  justify-content:flex-end;
  align-items:center;
  flex-wrap:wrap;
}

.user-actions form{
  margin:0;
}

.user-actions .pw{
  width: 180px;
}

@media (max-width: 860px){
  .user-actions{ justify-content:flex-start; }
  .user-actions .pw{ width: 100%; }
}

/* Small buttons */
.btn.sm, button.sm{
  padding: 8px 10px;
  border-radius: 10px;
  font-size: 13px;
}

/* Danger-ish button (nur visuell) */
.btn.danger, button.danger{
  border-color: rgba(255, 0, 0, .22);
}
.btn.danger:hover, button.danger:hover{
  background: #ffe9e9;
}

/* Inline form group */
.inline{
  display:flex;
  gap:8px;
  align-items:center;
  flex-wrap:wrap;
}

/* ===== Admin Panel Layout ===== */

.panel{
  display:flex;
  flex-direction:column;
  gap:12px;
}
.card h1, .card h2{ margin:0 0 10px 0; }

.helper{ font-size: 13px; color:#556; }

/* Create form kompakt */
.form-compact{
  display:grid;
  gap:12px;
  grid-template-columns: 1fr;
}

.form-compact .actions-row{
  display:flex;
  justify-content:flex-start; /* <-- links */
  gap:10px;
}

.form-compact .actions-row button{
  width:auto;          /* nicht 100% */
  min-width:140px;     /* optional: wirkt hochwertiger */
} 

/* Real table styling */
.table-real{
  width:100%;
  border-collapse: collapse;
  font-size:14px;
}

.table-real thead th{
  text-align:left;
  font-size:12px;
  letter-spacing:.04em;
  text-transform:uppercase;
  color:#556;
  padding: 10px 8px;
  border-bottom: 1px solid #eef0f3;
}

.table-real tbody td{
  padding: 12px 8px;
  border-bottom: 1px solid #f0f0f0;
  vertical-align: middle;
}

.table-real tbody tr:hover{
  background:#fafbfc;
}

.cell-actions{
  width: 360px;
}

.actions-inline{
  display:flex;
  gap:8px;
  align-items:center;
  justify-content:flex-end;
  flex-wrap:wrap;
}

.actions-inline form{ margin:0; }
.actions-inline input[type="password"]{ width: 170px; }

@media (max-width: 860px){
  .cell-actions{ width:auto; }
  .actions-inline{
    justify-content:flex-start;
  }
  .actions-inline input[type="password"]{
    width: 100%;
  }
}

/* Better badges */
.badge{
  display:inline-flex;
  align-items:center;
  padding: 3px 10px;
  border-radius: 999px;
  border: 1px solid #d7dbe0;
  background:#fff;
  font-size: 12px;
}

.badge.ok{ background:#eefaf2; }
.badge.off{ background:#fff2f2; }

/* ===== Modal ===== */
.modal-backdrop{
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.35);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 18px;
  z-index: 9999;
}

.modal-backdrop.open{ display:flex; }

.modal{
  width: min(520px, 100%);
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 20px 60px rgba(0,0,0,.25);
  padding: 16px;
}

.modal-head{
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.modal-head h3{
  margin:0;
  font-size: 18px;
}

.modal-close{
  border: 1px solid #d7dbe0;
  background:#fff;
  border-radius: 10px;
  padding: 8px 10px;
  cursor:pointer;
}

.modal-body{ margin-top: 10px; }
.modal-body .grid{ grid-template-columns: 1fr; } /* im Modal untereinander */

.modal-actions{
  display:flex;
  gap:10px;
  justify-content:flex-end;
  margin-top: 12px;
  flex-wrap:wrap;
}

@media (max-width: 520px){
  .modal-actions{ justify-content:stretch; }
  .modal-actions button{ width:100%; }
}

/* ===== Accordion / Collapsible ===== */
.collapsible{
  border: 1px solid #eef0f3;
  border-radius: 14px;
  background:#fcfcfd;
  margin-top: 12px;
  overflow: hidden;
}

.collapsible summary{
  list-style: none;
  cursor: pointer;
  padding: 12px 14px;
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
}

.collapsible summary::-webkit-details-marker{ display:none; }

.collapsible summary:hover{
  background:#f7f8fa;
}

.collapsible .meta{
  display:flex;
  flex-wrap:wrap;
  gap:8px;
  align-items:center;
}

.collapsible .title{
  font-weight: 700;
}

.collapsible .body{
  padding: 0 14px 14px;
}

.collapsible .toolbar{
  display:flex;
  justify-content:flex-end;
  gap:10px;
  margin: 10px 0 0;
}

@media (max-width: 720px){
  .collapsible .toolbar{ justify-content:flex-start; }
}

/* Rechner: Button etwas nach unten */
.calc-actions{
  margin-top: 14px;   /* höher = weiter nach unten (z.B. 18px) */
}
