:root {
  --bg: #f3efe6;
  --bg-deep: #e7e0d2;
  --ink: #1c2420;
  --ink-soft: #5a655e;
  --line: rgba(28, 36, 32, 0.12);
  --panel: rgba(255, 252, 246, 0.88);
  --panel-solid: #fffdf8;
  --sidebar: #15201b;
  --sidebar-ink: #d7e0da;
  --accent: #0f6b4c;
  --accent-2: #c45c26;
  --accent-3: #2b5f8a;
  --danger: #a33b2b;
  --ok: #1f7a4d;
  --shadow: 0 18px 50px rgba(28, 36, 32, 0.08);
  --radius: 18px;
  --font: "DM Sans", system-ui, sans-serif;
  --display: "Instrument Serif", Georgia, serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(15, 107, 76, 0.12), transparent 60%),
    radial-gradient(900px 500px at 100% 0%, rgba(196, 92, 38, 0.10), transparent 55%),
    linear-gradient(180deg, var(--bg) 0%, var(--bg-deep) 100%);
}

body.login-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

.app-shell {
  display: grid;
  grid-template-columns: 280px 1fr;
  min-height: 100vh;
}

.sidebar {
  background:
    linear-gradient(180deg, rgba(255,255,255,0.04), transparent 30%),
    var(--sidebar);
  color: var(--sidebar-ink);
  padding: 28px 20px;
  display: flex;
  flex-direction: column;
  gap: 28px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  display: flex;
  gap: 14px;
  align-items: center;
  padding: 4px 8px;
}

.brand-mark {
  width: 46px;
  height: 46px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  font-weight: 700;
  letter-spacing: 0.04em;
  background: linear-gradient(145deg, #1f8a63, #0d5a41);
  color: #f4fff9;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.25);
}

.brand-name {
  font-family: var(--display);
  font-size: 1.55rem;
  color: #f7faf8;
  line-height: 1;
}

.brand-sub {
  font-size: 0.78rem;
  opacity: 0.65;
  margin-top: 4px;
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
}

.nav-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  text-decoration: none;
  color: inherit;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid transparent;
  transition: background 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
}

.nav-item:hover {
  background: rgba(255,255,255,0.06);
  transform: translateX(2px);
}

.nav-item.is-active {
  background: rgba(31, 138, 99, 0.22);
  border-color: rgba(127, 211, 176, 0.28);
  color: #fff;
}

.nav-count {
  min-width: 28px;
  text-align: center;
  font-size: 0.78rem;
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(255,255,255,0.08);
}

.sidebar-footer {
  display: grid;
  gap: 14px;
}

.user-chip {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 0.85rem;
  opacity: 0.85;
  padding: 0 4px;
}

.user-chip a {
  color: #9fd9bf;
  text-decoration: none;
}

.main {
  padding: 28px 28px 40px;
  min-width: 0;
}

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 20px;
  margin-bottom: 22px;
}

.eyebrow {
  margin: 0 0 6px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 0.72rem;
  color: var(--ink-soft);
}

.page-header h1 {
  margin: 0;
  font-family: var(--display);
  font-weight: 400;
  font-size: clamp(2rem, 3vw, 2.7rem);
  letter-spacing: -0.02em;
}

.header-hint {
  margin: 0;
  color: var(--ink-soft);
  font-size: 0.9rem;
}

.filter-bar {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: calc(var(--radius) + 2px);
  box-shadow: var(--shadow);
  padding: 18px 18px 14px;
  margin-bottom: 18px;
}

.filter-form {
  display: grid;
  gap: 14px;
}

.filter-row {
  display: grid;
  grid-template-columns: minmax(200px, 2fr) repeat(2, minmax(120px, 0.7fr)) minmax(130px, 0.9fr) minmax(100px, 0.7fr) auto;
  gap: 12px;
  align-items: end;
}

.filter-row label {
  display: grid;
  gap: 6px;
  font-size: 0.78rem;
  color: var(--ink-soft);
  letter-spacing: 0.02em;
}

.filter-row input,
.filter-row select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 11px 12px;
  font: inherit;
  color: var(--ink);
  background: #fff;
}

.filter-row input:focus,
.filter-row select:focus {
  outline: none;
  border-color: rgba(15, 107, 76, 0.45);
  box-shadow: 0 0 0 3px rgba(15, 107, 76, 0.12);
}

.filter-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.filter-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.preset-chip {
  text-decoration: none;
  color: var(--ink-soft);
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 999px;
  padding: 7px 12px;
  font-size: 0.82rem;
  font-weight: 600;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.preset-chip:hover {
  border-color: rgba(15, 107, 76, 0.35);
  color: var(--accent);
}

.preset-chip.is-active {
  background: rgba(15, 107, 76, 0.12);
  border-color: rgba(15, 107, 76, 0.28);
  color: var(--ok);
}

.filter-meta {
  margin-top: 12px;
  font-size: 0.9rem;
  color: var(--ink-soft);
}

.filter-meta strong {
  color: var(--ink);
}

.filter-meta-hint {
  color: var(--accent-2);
}

.pagination {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 18px;
  padding: 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.page-btn,
.page-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 40px;
  padding: 8px 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.9rem;
}

.page-btn:hover,
.page-num:hover {
  border-color: rgba(15, 107, 76, 0.35);
  color: var(--accent);
}

.page-num.is-current {
  background: rgba(15, 107, 76, 0.14);
  border-color: rgba(15, 107, 76, 0.3);
  color: var(--ok);
}

.page-btn.is-disabled {
  opacity: 0.4;
  pointer-events: none;
}

.page-ellipsis {
  color: var(--ink-soft);
  padding: 0 4px;
}

.search-wrap input {
  width: min(340px, 70vw);
  border: 1px solid var(--line);
  background: var(--panel-solid);
  border-radius: 999px;
  padding: 12px 18px;
  font: inherit;
  color: var(--ink);
  box-shadow: var(--shadow);
}

.search-wrap input:focus {
  outline: 2px solid rgba(15, 107, 76, 0.25);
  border-color: rgba(15, 107, 76, 0.4);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: none;
  border-radius: 12px;
  padding: 12px 16px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn-primary {
  background: linear-gradient(180deg, #17845c, var(--accent));
  color: #f4fff9;
  box-shadow: 0 10px 24px rgba(15, 107, 76, 0.28);
}

.btn-ghost {
  background: transparent;
  color: var(--ink-soft);
  border: 1px solid var(--line);
}

.btn-block {
  width: 100%;
}

.btn-small {
  padding: 8px 12px;
  font-size: 0.82rem;
  border-radius: 10px;
}

.nav-termine {
  margin-top: 8px;
  border-top: 1px solid rgba(255,255,255,0.08);
  padding-top: 14px !important;
}

.termin-chip {
  display: inline-flex;
  align-items: center;
  margin: 0 0 10px;
  padding: 5px 10px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
}

.termin-chip.is-upcoming {
  background: rgba(43, 95, 138, 0.12);
  color: var(--accent-3);
  border: 1px solid rgba(43, 95, 138, 0.22);
}

.termin-chip.is-past {
  background: rgba(163, 59, 43, 0.1);
  color: var(--danger);
  border: 1px solid rgba(163, 59, 43, 0.2);
}

.termin-box {
  display: grid;
  gap: 8px;
  margin-bottom: 12px;
  padding: 10px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: linear-gradient(180deg, #fff, #f7f3ea);
}

.termin-box.is-busy {
  opacity: 0.55;
  pointer-events: none;
}

.termin-label {
  display: grid;
  gap: 5px;
  font-size: 0.72rem;
  color: var(--ink-soft);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.termin-datetime,
.termin-notiz {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 9px 10px;
  font: inherit;
  color: var(--ink);
  background: #fff;
}

.termin-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.termin-save.is-saved {
  box-shadow: 0 0 0 2px rgba(15, 107, 76, 0.35);
}

.table-wrap {
  background: var(--panel);
  backdrop-filter: blur(10px);
  border: 1px solid var(--line);
  border-radius: calc(var(--radius) + 4px);
  box-shadow: var(--shadow);
  overflow: auto;
}

.crm-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  min-width: 1100px;
}

.crm-table th {
  position: sticky;
  top: 0;
  z-index: 2;
  text-align: left;
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-soft);
  background: #faf7f0;
  border-bottom: 1px solid var(--line);
  padding: 16px 14px;
  white-space: nowrap;
}

.crm-table td {
  vertical-align: top;
  padding: 14px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 253, 248, 0.72);
}

.crm-table tbody tr {
  transition: opacity 0.28s ease, transform 0.28s ease, background 0.2s ease;
}

.crm-table tbody tr:hover td {
  background: #fff;
}

.crm-table tbody tr.is-leaving {
  opacity: 0;
  transform: translateX(18px);
}

.id-card,
.stack-card,
.person-card {
  border-radius: 14px;
  padding: 12px;
  background: linear-gradient(180deg, #fff, #f7f3ea);
  border: 1px solid var(--line);
  min-height: 100%;
}

.id-num {
  font-family: var(--display);
  font-size: 1.7rem;
  line-height: 1;
  margin-bottom: 6px;
}

.id-time {
  font-size: 0.82rem;
  color: var(--ink-soft);
  margin-bottom: 10px;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  padding: 5px 10px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  margin-bottom: 10px;
  border: 1px solid transparent;
}

.badge-active {
  background: rgba(15, 107, 76, 0.12);
  color: var(--ok);
  border-color: rgba(15, 107, 76, 0.2);
}

.badge-missed {
  background: rgba(196, 92, 38, 0.12);
  color: var(--accent-2);
  border-color: rgba(196, 92, 38, 0.22);
}

.badge-other {
  background: rgba(43, 95, 138, 0.12);
  color: var(--accent-3);
  border-color: rgba(43, 95, 138, 0.22);
}

.badge-done {
  background: rgba(28, 36, 32, 0.08);
  color: var(--ink);
  border-color: rgba(28, 36, 32, 0.14);
}

.badge-macht-mit {
  background: rgba(15, 107, 76, 0.14);
  color: var(--ok);
  border-color: rgba(15, 107, 76, 0.28);
}

.note-field {
  width: 100%;
  resize: vertical;
  min-height: 72px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #fff;
  padding: 10px;
  font: inherit;
  color: var(--ink);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.note-field:focus {
  outline: none;
  border-color: rgba(15, 107, 76, 0.45);
  box-shadow: 0 0 0 3px rgba(15, 107, 76, 0.12);
}

.note-field.is-saving {
  border-color: rgba(43, 95, 138, 0.45);
}

.note-field.is-saved {
  border-color: rgba(15, 107, 76, 0.55);
}

.note-field.is-error {
  border-color: rgba(163, 59, 43, 0.55);
}

.stack-main {
  font-weight: 600;
  word-break: break-word;
}

.stack-sub,
.stack-label,
.person-line {
  color: var(--ink-soft);
  font-size: 0.86rem;
}

.stack-label {
  margin-top: 8px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.68rem;
}

.stack-card.accent-a {
  border-left: 3px solid var(--accent);
}

.stack-card.accent-b {
  border-left: 3px solid var(--accent-2);
}

.person-name {
  font-size: 1.05rem;
  font-weight: 700;
  margin-bottom: 6px;
}

.person-phone {
  margin-top: 10px;
  font-weight: 600;
  color: var(--accent);
}

.person-card {
  border-left: 3px solid var(--accent-3);
}

.action-stack {
  display: grid;
  gap: 8px;
}

.action-btn {
  width: 100%;
  text-align: left;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #fff;
  padding: 11px 12px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.15s ease, background 0.15s ease, border-color 0.15s ease;
}

.action-btn:hover {
  transform: translateX(3px);
}

.action-meine_datensaetze {
  color: var(--ok);
  border-color: rgba(15, 107, 76, 0.25);
}

.action-nicht_erreicht {
  color: var(--accent-2);
  border-color: rgba(196, 92, 38, 0.28);
}

.action-anderer_grund {
  color: var(--accent-3);
  border-color: rgba(43, 95, 138, 0.28);
}

.action-abschluss {
  color: #5b4570;
  border-color: rgba(91, 69, 112, 0.28);
}

.action-macht_mit {
  color: var(--ok);
  border-color: rgba(15, 107, 76, 0.35);
  font-weight: 700;
}

.action-stack.is-busy {
  opacity: 0.55;
  pointer-events: none;
}

.empty-state {
  display: grid;
  gap: 6px;
  padding: 36px 16px;
  text-align: center;
  color: var(--ink-soft);
}

.empty-state strong {
  color: var(--ink);
  font-size: 1.05rem;
}

.form-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: calc(var(--radius) + 4px);
  box-shadow: var(--shadow);
  padding: 28px;
}

.form-intro h2 {
  margin: 0 0 6px;
  font-family: var(--display);
  font-weight: 400;
  font-size: 2rem;
}

.form-intro p {
  margin: 0 0 22px;
  color: var(--ink-soft);
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.form-grid label,
.login-form label {
  display: grid;
  gap: 7px;
  font-size: 0.9rem;
  color: var(--ink-soft);
}

.form-grid .full {
  grid-column: 1 / -1;
}

.form-grid input,
.form-grid select,
.form-grid textarea,
.login-form input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
  font: inherit;
  color: var(--ink);
  background: #fff;
}

.form-grid input:focus,
.form-grid select:focus,
.form-grid textarea:focus,
.login-form input:focus {
  outline: none;
  border-color: rgba(15, 107, 76, 0.45);
  box-shadow: 0 0 0 3px rgba(15, 107, 76, 0.12);
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 22px;
}

.alert {
  border-radius: 12px;
  padding: 12px 14px;
  margin-bottom: 16px;
}

.alert-error {
  background: rgba(163, 59, 43, 0.1);
  color: var(--danger);
  border: 1px solid rgba(163, 59, 43, 0.2);
}

.login-stage {
  width: min(440px, 100%);
}

.login-panel {
  background: var(--panel-solid);
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 32px;
  box-shadow: var(--shadow);
}

.login-brand {
  text-align: center;
  margin-bottom: 24px;
}

.login-brand .brand-mark {
  margin: 0 auto 14px;
}

.login-brand h1 {
  margin: 0;
  font-family: var(--display);
  font-weight: 400;
  font-size: 2.2rem;
}

.login-brand p {
  margin: 8px 0 0;
  color: var(--ink-soft);
}

.login-form {
  display: grid;
  gap: 14px;
}

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: relative;
    height: auto;
  }

  .page-header {
    flex-direction: column;
    align-items: stretch;
  }

  .filter-row {
    grid-template-columns: 1fr 1fr;
  }

  .filter-search,
  .filter-actions {
    grid-column: 1 / -1;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }
}
