:root {
  --bg: #f5f7fb;
  --card: #ffffff;
  --text: #172033;
  --muted: #667085;
  --line: #e6e9f0;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --danger-bg: #fee2e2;
  --danger: #991b1b;
  --success-bg: #dcfce7;
  --success: #166534;
  --radius: 18px;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background: radial-gradient(circle at top left, #e0ecff, transparent 35%), var(--bg);
}
.app { width: min(1120px, 100%); margin: 0 auto; padding: 24px; }
h1, h2 { margin: 0 0 10px; letter-spacing: -0.03em; }
h1 { font-size: clamp(2rem, 6vw, 3rem); }
h2 { font-size: 1.35rem; }
p { line-height: 1.55; }
.muted, .hint { color: var(--muted); }
.hint { font-size: .95rem; }
.card {
  background: rgba(255,255,255,.92);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: 0 20px 45px rgba(20, 35, 70, .08);
  backdrop-filter: blur(10px);
}
.narrow { max-width: 460px; margin: 8vh auto 0; }
.topbar { display: flex; justify-content: space-between; align-items: flex-start; gap: 18px; margin-bottom: 22px; }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 18px; }
.diary-card { display: flex; flex-direction: column; gap: 12px; }
dl { display: grid; gap: 8px; margin: 0; }
dl div { display: flex; justify-content: space-between; gap: 14px; border-top: 1px solid var(--line); padding-top: 8px; }
dt { color: var(--muted); }
dd { margin: 0; font-weight: 600; text-align: right; }
.form { display: grid; gap: 16px; }
.two-col { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.field, label { display: grid; gap: 7px; font-weight: 650; }
.field small { color: var(--muted); font-weight: 400; }
.span { grid-column: 1 / -1; }
input, textarea, button, .button {
  font: inherit;
  border-radius: 13px;
}
input, textarea {
  width: 100%;
  border: 1px solid #cfd6e3;
  padding: 13px 14px;
  background: #fff;
  color: var(--text);
  font-size: 16px;
}
textarea { min-height: 120px; resize: vertical; }
input:focus, textarea:focus { outline: 3px solid rgba(37,99,235,.15); border-color: var(--primary); }
button, .button {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  border: 0;
  padding: 12px 17px;
  background: var(--primary);
  color: #fff;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
}
button:hover, .button:hover { background: var(--primary-dark); }
.secondary { background: #edf2ff; color: #1d4ed8; }
.secondary:hover { background: #dbe7ff; }
.back { color: var(--primary); text-decoration: none; font-weight: 700; display: inline-block; margin-bottom: 10px; }
.alert, .success { padding: 12px 14px; border-radius: 13px; margin-bottom: 16px; }
.alert { background: var(--danger-bg); color: var(--danger); }
.success { background: var(--success-bg); color: var(--success); }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 720px; }
th, td { text-align: left; padding: 11px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-size: .9rem; }

@media (max-width: 720px) {
  .app { padding: 16px; }
  .topbar { flex-direction: column; }
  .two-col { grid-template-columns: 1fr; }
  .card { padding: 18px; }
  dl div { flex-direction: column; gap: 2px; }
  dd { text-align: left; }
  button, .button { width: 100%; }
}

.order-buttons {
  display: flex;
  gap: 6px;
  white-space: nowrap;
}
.icon-button {
  min-width: 42px;
  padding: 10px 12px;
}
.error {
  background: var(--danger-bg);
  color: var(--danger);
  padding: 12px 14px;
  border-radius: 13px;
  margin-bottom: 16px;
}

@media (max-width: 720px) {
  .order-buttons .icon-button {
    width: auto;
    flex: 1;
  }
}

.field-group {
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 18px;
  margin: 0;
  background: rgba(248, 250, 252, .75);
}
.field-group + .field-group { margin-top: 4px; }
.field-group legend {
  padding: 0 10px;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.02em;
}
.actions {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}
.editor-table { min-width: 1480px; }
.editor-table input,
.editor-table select {
  min-width: 120px;
}
.editor-table input[type="checkbox"] {
  min-width: 0;
  width: 20px;
  height: 20px;
}
select {
  width: 100%;
  border: 1px solid #cfd6e3;
  padding: 13px 14px;
  background: #fff;
  color: var(--text);
  font-size: 16px;
  border-radius: 13px;
}
select:focus { outline: 3px solid rgba(37,99,235,.15); border-color: var(--primary); }

@media (max-width: 720px) {
  .field-group { padding: 14px; }
  .actions { width: 100%; }
  .actions > * { flex: 1 1 100%; }
}
code {
  background: #eef2ff;
  color: #1e3a8a;
  padding: 2px 6px;
  border-radius: 7px;
}
.is-disabled {
  opacity: .58;
  background: #f8fafc;
}
.is-disabled input:not([type="checkbox"]),
.is-disabled select {
  color: #667085;
}
.perm-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
  min-width: 360px;
}
.perm-grid label { font-size: .9rem; }

.mobile-save { position: sticky; bottom: 12px; z-index: 5; }
@media (max-width: 720px) {
  input, textarea, select { font-size: 16px; padding: 15px 14px; }
  .field { gap: 9px; }
  .field-group legend { font-size: 1.05rem; }
  .topbar .actions { width: 100%; }
}

/* Kompakte feldbasierte Breiten je Diary/Feld */
.form.two-col {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}
.field.compact { grid-column: span 1; }
.field.half { grid-column: span 2; }
.field.span { grid-column: 1 / -1; }
.field.compact input,
.field.compact select { max-width: 100%; }
@media (max-width: 920px) {
  .form.two-col { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .field.compact, .field.half { grid-column: span 1; }
  .field.span { grid-column: 1 / -1; }
}
@media (max-width: 720px) {
  .form.two-col { grid-template-columns: 1fr; gap: 13px; }
  .field.compact, .field.half, .field.span { grid-column: 1 / -1; }
  .card { border-radius: 16px; }
  .field-group { padding: 12px; }
  textarea { min-height: 96px; }
}
hr { border: 0; border-top: 1px solid var(--line); width: 100%; margin: 6px 0; }
.profile-details { margin-top: 8px; }
.profile-details summary { cursor: pointer; color: var(--accent); font-weight: 700; }
.profile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
  margin-top: 10px;
  min-width: 320px;
}
.profile-grid label { font-size: .86rem; }
.badge {
  display: inline-block;
  font-size: .72rem;
  padding: 2px 7px;
  border-radius: 999px;
  background: #eef2ff;
  color: #3730a3;
  margin-left: 4px;
}
@media (max-width: 720px) {
  .profile-grid { grid-template-columns: 1fr; min-width: 0; }
}
.button.small { padding: 7px 10px; font-size: .85rem; }
button.danger, .button.danger { background: #b91c1c; color: white; }
.danger-row { justify-content: space-between; flex-wrap: wrap; }

.history-change {
    margin: .35rem 0;
    padding: .45rem .55rem;
    border: 1px solid rgba(0,0,0,.08);
    border-radius: .6rem;
    background: rgba(0,0,0,.025);
}

/* tracknote branding */
.brand-header {
  width: 100%;
  background: var(--card);
  border-bottom: 1px solid rgba(23, 32, 51, 0.08);
  box-shadow: 0 2px 12px rgba(23, 32, 51, 0.04);
}

.brand-wrap {
  max-width: 980px;
  margin: 0 auto;
  padding: 14px 18px;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.brand-title {
  color: var(--text);
  font-weight: 800;
  letter-spacing: -0.03em;
  font-size: 1.45rem;
  text-decoration: none;
}

.brand-subtitle {
  color: var(--muted);
  font-size: 0.92rem;
}

.brand-footer {
  max-width: 980px;
  margin: 28px auto 18px;
  padding: 0 18px;
  text-align: center;
  color: var(--muted);
  font-size: 0.85rem;
}

.brand-footer a {
  color: var(--muted);
  text-decoration: none;
}

.brand-footer a:hover,
.brand-title:hover {
  text-decoration: underline;
}

@media (max-width: 640px) {
  .brand-wrap {
    align-items: flex-start;
    flex-direction: column;
    gap: 2px;
    padding: 12px 14px;
  }

  .brand-title {
    font-size: 1.35rem;
  }

  .brand-subtitle {
    font-size: 0.82rem;
  }
}

.maintenance-banner{background:#fff3cd;border-bottom:1px solid #f0d98c;color:#5f4700;padding:.6rem 1rem;text-align:center;font-weight:700}


/* UI-Feinschliff v0.1: kompakter, mobiler, klarer */
:root {
  --shadow-soft: 0 14px 34px rgba(20, 35, 70, .07);
  --touch: 46px;
}

.app { padding-bottom: 88px; }
.card { box-shadow: var(--shadow-soft); }
.card + .card { margin-top: 18px; }

.topbar {
  padding: 4px 0 2px;
}
.topbar h1 { line-height: 1.05; }
.topbar .muted { margin: 6px 0 0; }

.button, button { min-height: var(--touch); }
.button.small { min-height: 38px; }

input, textarea, select {
  min-height: var(--touch);
  box-shadow: inset 0 1px 0 rgba(23,32,51,.02);
}

.field-group {
  transition: background .16s ease, border-color .16s ease;
}
.field-group:focus-within {
  border-color: rgba(37,99,235,.35);
  background: rgba(248,250,252,.95);
}
.field-group legend {
  display: flex;
  align-items: center;
  gap: 8px;
}
.group-toggle {
  border: 0;
  background: #edf2ff;
  color: #1d4ed8;
  border-radius: 999px;
  min-height: 30px;
  min-width: 34px;
  width: auto;
  padding: 3px 9px;
  line-height: 1;
  box-shadow: none;
}
.group-toggle:hover { background: #dbe7ff; }
.field-group.collapsed > :not(legend) { display: none; }

.mobile-save {
  border-radius: 16px;
}
.mobile-save button {
  box-shadow: 0 14px 28px rgba(37,99,235,.22);
}

.badge,
.role-badge,
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 24px;
}

@media (min-width: 721px) {
  .mobile-save {
    position: static;
    display: flex;
    justify-content: flex-end;
  }
  .mobile-save button { width: auto; min-width: 180px; }
}

@media (max-width: 720px) {
  body {
    background: linear-gradient(180deg, #eef5ff 0, #f7f8fb 220px, var(--bg) 100%);
  }
  .app {
    padding: 14px 12px 96px;
  }
  .brand-header {
    position: sticky;
    top: 0;
    z-index: 20;
  }
  .brand-wrap {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }
  .brand-subtitle { display: none; }
  h1 { font-size: clamp(1.65rem, 9vw, 2.25rem); }
  h2 { font-size: 1.15rem; }
  .card {
    padding: 14px;
    border-radius: 18px;
  }
  .grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }
  .field-group {
    padding: 10px 10px 12px;
    border-radius: 15px;
  }
  .field-group legend {
    width: calc(100% - 8px);
    justify-content: space-between;
    padding: 0 4px;
  }
  .mobile-save {
    position: fixed;
    left: 12px;
    right: 12px;
    bottom: 12px;
    z-index: 30;
    padding: 8px;
    background: rgba(245,247,251,.86);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(230,233,240,.85);
    box-shadow: 0 18px 38px rgba(20,35,70,.18);
  }
  .mobile-save button { width: 100%; }
  .table-wrap { overflow: visible; }
  table.responsive-table,
  .responsive-table thead,
  .responsive-table tbody,
  .responsive-table tr,
  .responsive-table th,
  .responsive-table td {
    display: block;
    width: 100%;
    min-width: 0;
  }
  .responsive-table { min-width: 0; border-collapse: separate; border-spacing: 0 10px; }
  .responsive-table thead { display: none; }
  .responsive-table tr {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 15px;
    padding: 8px;
    box-shadow: 0 8px 18px rgba(20,35,70,.05);
  }
  .responsive-table td {
    border-bottom: 0;
    padding: 7px 6px;
  }
  .responsive-table td::before {
    content: attr(data-label);
    display: block;
    font-size: .75rem;
    color: var(--muted);
    font-weight: 700;
    margin-bottom: 2px;
  }
  .responsive-table td:empty { display: none; }
}

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