:root {
  --bg: #f5f7fb;
  --card: #ffffff;
  --text: #162033;
  --muted: #667085;
  --line: #d8dee9;
  --primary: #2855d9;
  --primary-dark: #1e3fa3;
  --danger: #b42318;
  --ok: #027a48;
  --warn: #b54708;
  --shadow: 0 12px 35px rgba(16, 24, 40, 0.08);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
.topbar {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.9rem 1.4rem;
  background: var(--card);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 10;
}
.brand { font-weight: 800; color: var(--text); font-size: 1.1rem; }
.topbar nav { display: flex; flex-wrap: wrap; gap: 0.8rem; align-items: center; }
.topbar .user { margin-left: auto; color: var(--muted); }
.container { max-width: 1180px; margin: 0 auto; padding: 1.3rem; }
.card, .calendar-card, .auth-card, .score-card, .info-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: 1.2rem;
  margin-bottom: 1.2rem;
}
.auth-card { max-width: 440px; margin: 3rem auto; }
.hero-grid, .two-column {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1.2rem;
}
.score-card { display: flex; flex-direction: column; gap: 0.6rem; }
.eyebrow { color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; font-size: 0.8rem; font-weight: 700; }
.score { font-size: 4rem; font-weight: 900; line-height: 1; }
.muted { color: var(--muted); }
.preline { white-space: pre-line; }
.form-stack { display: flex; flex-direction: column; gap: 0.9rem; }
label { display: flex; flex-direction: column; gap: 0.35rem; font-weight: 650; }
label.check { flex-direction: row; align-items: center; font-weight: 600; }
input, textarea, select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.75rem 0.85rem;
  font: inherit;
  background: white;
}
button, .button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 12px;
  background: var(--primary);
  color: white;
  padding: 0.72rem 0.95rem;
  font-weight: 750;
  cursor: pointer;
  text-decoration: none;
}
button:hover, .button:hover { background: var(--primary-dark); text-decoration: none; }
button.secondary, .button.secondary { background: #eef2ff; color: var(--primary-dark); }
button.secondary:hover, .button.secondary:hover { background: #dfe6ff; }
button.danger { background: var(--danger); }
.calendar-head, .section-head, .request-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 0.65rem;
}
.weekdays { color: var(--muted); font-weight: 800; margin: 1rem 0 0.55rem; text-align: center; }
.day-cell {
  min-height: 132px;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #ffffff;
  padding: 0.7rem;
  overflow: hidden;
}
.day-cell:hover { outline: 2px solid #b7c5ff; text-decoration: none; }
.day-cell.outside { opacity: 0.52; }
.day-cell.today { border-color: var(--primary); }
.day-number { font-weight: 900; margin-bottom: 0.35rem; }
.badges { display: flex; flex-wrap: wrap; gap: 0.25rem; }
.badge, .pill, .status, .approval {
  display: inline-flex;
  border-radius: 999px;
  padding: 0.18rem 0.45rem;
  font-size: 0.75rem;
  font-weight: 750;
  border: 1px solid transparent;
}
.pill { background: var(--danger); color: white; margin-left: 0.25rem; }
.badge.planned { background: #eef2ff; color: #3538cd; }
.badge.met { background: #ecfdf3; color: #027a48; }
.badge.effort { background: #fff6ed; color: #b54708; }
.badge.cancel, .badge.bad { background: #fef3f2; color: #b42318; }
.badge.pending { background: #f2f4f7; color: #344054; }
.note-preview { color: var(--muted); font-size: 0.82rem; margin: 0.45rem 0 0; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 0.75rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-size: 0.85rem; }
.delta { font-weight: 900; }
.details, .request-grid {
  display: grid;
  grid-template-columns: minmax(150px, 220px) 1fr;
  gap: 0.55rem 1rem;
}
dt { color: var(--muted); font-weight: 800; }
dd { margin: 0; }
.request-card {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 1rem;
  margin: 1rem 0;
  background: #fcfcfd;
}
.status.pending { background: #fff6ed; color: var(--warn); }
.status.approved, .approval.approved { background: #ecfdf3; color: var(--ok); }
.status.rejected, .approval.rejected { background: #fef3f2; color: var(--danger); }
.status.withdrawn { background: #f2f4f7; color: #475467; }
.approval-line { display: flex; gap: 0.4rem; flex-wrap: wrap; margin: 0.75rem 0; }
.inline-actions { display: inline-flex; margin-right: 0.5rem; }
.owner-actions, .button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  align-items: center;
  margin-top: 0.8rem;
}
.narrow-card { max-width: 760px; margin-left: auto; margin-right: auto; }
.tabs { display: flex; gap: 0.4rem; flex-wrap: wrap; }
.tab { padding: 0.5rem 0.75rem; border-radius: 999px; background: #f2f4f7; color: var(--text); font-weight: 750; }
.tab.active { background: var(--primary); color: white; }
.messages { margin-bottom: 1rem; }
.message { border-radius: 12px; padding: 0.8rem 1rem; margin: 0.5rem 0; }
.message.success { background: #ecfdf3; color: #05603a; }
.message.error { background: #fef3f2; color: #b42318; }
.hint { margin-top: 1rem; color: var(--muted); font-size: 0.9rem; }
.compact table { font-size: 0.92rem; }

@media (max-width: 800px) {
  .hero-grid, .two-column { grid-template-columns: 1fr; }
  .calendar-head { flex-direction: column; align-items: stretch; text-align: center; }
  .calendar-grid { gap: 0.35rem; }
  .day-cell { min-height: 105px; padding: 0.45rem; }
  .topbar { flex-direction: column; align-items: flex-start; }
  .topbar .user { margin-left: 0; }
  .details, .request-grid { grid-template-columns: 1fr; }
}

.allowance-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}
.allowance-card {
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #fcfcfd;
  padding: 1rem;
}
.allowance-number {
  font-size: 3rem;
  font-weight: 900;
  line-height: 1;
  margin: 0.35rem 0 0.65rem;
}
.counter-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  margin-top: 1rem;
}
.counter-strip span {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fcfcfd;
  padding: 0.45rem 0.7rem;
  color: var(--muted);
}

@media (max-width: 800px) {
  .allowance-grid { grid-template-columns: 1fr; }
}

.badge.unavailable { background: #f2f4f7; color: #344054; }
.badge.conflict { background: #fef3f2; color: var(--danger); border-color: #fecdca; }
.day-cell.unavailable { background: #f8fafc; border-style: dashed; }
.day-cell.conflict { outline: 2px solid #fecdca; }
.impact {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.65rem 0.8rem;
  margin: 0.8rem 0;
  font-weight: 750;
}
.impact.positive { background: #ecfdf3; color: var(--ok); border-color: #abefc6; }
.impact.negative { background: #fef3f2; color: var(--danger); border-color: #fecdca; }
.impact.neutral { background: #f2f4f7; color: #344054; }
.compact-list { margin: 0.35rem 0 0; padding-left: 1.2rem; }
input[type="hidden"] { display: none; }

/* Layout-Fix: Checkboxen im Änderungsformular dürfen nicht die ganze Breite einnehmen. */
input[type="checkbox"] {
  width: auto;
  min-width: 1.05rem;
  height: 1.05rem;
  margin: 0;
  padding: 0;
  accent-color: var(--primary);
  flex: 0 0 auto;
}

label.check {
  flex-direction: row;
  align-items: center;
  justify-content: flex-start;
  gap: 0.65rem;
  width: 100%;
  line-height: 1.25;
  padding: 0.7rem 0.8rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fcfcfd;
  cursor: pointer;
}

label.check:hover {
  border-color: #b7c5ff;
  background: #f8faff;
}

@media (max-width: 800px) {
  label.check {
    align-items: flex-start;
  }
}

.option-row {
  display: grid !important;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center !important;
}
.option-main { min-width: 0; }
.option-points {
  border-radius: 999px;
  padding: 0.18rem 0.5rem;
  font-size: 0.78rem;
  font-weight: 850;
  white-space: nowrap;
}
.option-points.positive { background: #ecfdf3; color: var(--ok); }
.option-points.negative { background: #fef3f2; color: var(--danger); }
.option-points.neutral { background: #f2f4f7; color: #344054; }
.field-hint {
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 500;
  line-height: 1.35;
}
.impact-breakdown {
  margin: -0.35rem 0 0.85rem;
  padding-left: 1.3rem;
  color: var(--muted);
}
.impact-breakdown strong { color: var(--text); }

@media (max-width: 800px) {
  .option-row {
    grid-template-columns: auto minmax(0, 1fr);
  }
  .option-points {
    grid-column: 2;
    justify-self: start;
  }
}

.user-menu {
  margin-left: auto;
  position: relative;
}
.user-menu summary {
  list-style: none;
  cursor: pointer;
  padding: 0.48rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-weight: 800;
  color: var(--text);
  background: #fcfcfd;
}
.user-menu summary::-webkit-details-marker { display: none; }
.user-menu summary::after { content: " ▾"; color: var(--muted); }
.user-menu[open] summary { border-color: #b7c5ff; background: #f8faff; }
.user-menu-panel {
  position: absolute;
  right: 0;
  top: calc(100% + 0.5rem);
  min-width: 220px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 0.45rem;
  z-index: 20;
}
.user-menu-panel a {
  display: block;
  padding: 0.65rem 0.75rem;
  border-radius: 10px;
  color: var(--text);
  font-weight: 700;
}
.user-menu-panel a:hover { background: #f2f4f7; text-decoration: none; }
.option-main {
  display: flex;
  flex-direction: column;
  gap: 0.12rem;
}
.option-rule {
  display: block;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 600;
}
.option-points {
  font-variant-numeric: tabular-nums;
  min-width: max-content;
}
.timeline {
  display: grid;
  gap: 0.7rem;
}
.timeline-item {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fcfcfd;
  padding: 0.8rem;
}
.timeline-item p { margin: 0.35rem 0 0; }
.compact-item { padding: 0.65rem; }
.rules-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
.rules-form .field-hint,
.rules-form button { grid-column: 1 / -1; }

@media (max-width: 800px) {
  .user-menu { margin-left: 0; width: 100%; }
  .user-menu summary { display: inline-flex; }
  .user-menu-panel { left: 0; right: auto; }
  .rules-form { grid-template-columns: 1fr; }
}

.live-total-preview {
  border: 1px solid var(--line);
}
.live-total-preview.positive { background: #ecfdf3; color: var(--ok); }
.live-total-preview.negative { background: #fef3f2; color: var(--danger); }
.live-total-preview.neutral { background: #f2f4f7; color: #344054; }
.label-with-badge {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  width: 100%;
}
@media (max-width: 800px) {
  .label-with-badge {
    align-items: flex-start;
    flex-direction: column;
  }
}


/* Serien-Shortlinks und Kalender-Markierungen */
.shortlink-list {
  list-style: none;
  padding-left: 0;
  display: grid;
  gap: 0.45rem;
}
.shortlink-list li {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.55rem;
}
.mini-link {
  display: inline-flex;
  border-radius: 999px;
  padding: 0.22rem 0.55rem;
  background: #eef2ff;
  color: var(--primary-dark);
  font-size: 0.78rem;
  font-weight: 850;
}
.mini-link:hover { text-decoration: none; background: #dfe6ff; }
.day-cell.series-highlight {
  border-color: #7c3aed;
  outline: 2px solid #ddd6fe;
  background: #faf5ff;
}
.day-cell.series-week-highlight {
  border-color: #2563eb;
  outline: 2px solid #bfdbfe;
}
.badge.series { background: #f3e8ff; color: #6d28d9; }
.badge.series-week { background: #dbeafe; color: #1d4ed8; }
.inline-hint {
  margin-top: 0.35rem;
  font-size: 0.86rem;
}

/* Dashboard-Kurzuebersicht und Kalenderwochen */
.dashboard-allowance {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.65rem;
  margin: 0.35rem 0 0.45rem;
}
.dashboard-allowance div {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fcfcfd;
  padding: 0.7rem;
}
.dashboard-allowance strong {
  display: block;
  font-size: 1.85rem;
  line-height: 1;
  margin-top: 0.25rem;
}
.dashboard-allowance small {
  color: var(--muted);
  font-weight: 700;
}
.day-number {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.35rem;
}
.kw-badge {
  border-radius: 999px;
  padding: 0.12rem 0.38rem;
  background: #f2f4f7;
  color: var(--muted);
  font-size: 0.66rem;
  font-weight: 850;
  line-height: 1.2;
}
@media (max-width: 800px) {
  .dashboard-allowance { grid-template-columns: 1fr; }
  .kw-badge { font-size: 0.58rem; padding: 0.1rem 0.28rem; }
}

/* Abzüge: Kalendertage direkt anklickbar */
.date-link-list,
.reason-link-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}
.reason-link-list { flex-direction: column; align-items: flex-start; }
.date-chip {
  display: inline-flex;
  border-radius: 999px;
  padding: 0.18rem 0.45rem;
  background: #eef2ff;
  color: var(--primary-dark);
  font-weight: 800;
  font-size: 0.78rem;
}
.date-chip:hover { background: #dfe6ff; text-decoration: none; }
.calendar-feed-card .section-head { align-items: flex-start; }
.mono-input {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 0.88rem;
  cursor: text;
}
.calendar-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  align-items: center;
  margin: 0.9rem 0 1rem;
}
.copy-row {
  display: flex;
  gap: 0.5rem;
  align-items: stretch;
}
.copy-row .mono-input {
  flex: 1 1 auto;
  min-width: 0;
}
.button.small {
  padding: 0.55rem 0.75rem;
  white-space: nowrap;
}
.subscribe-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
  margin: 1rem 0;
}
.subscribe-grid.single {
  grid-template-columns: 1fr;
}
.subscribe-option,
.manual-subscribe-box,
.warning-card {
  border: 1px solid var(--border);
  border-radius: 1rem;
  padding: 1rem;
  background: #fff;
}
.subscribe-option.recommended {
  border-color: rgba(37, 99, 235, 0.35);
  background: #f8fbff;
}
.button.wide {
  display: inline-flex;
  justify-content: center;
  width: 100%;
  box-sizing: border-box;
}
.copy-status {
  min-height: 1.2rem;
}
.warning-card code {
  background: #f3f4f6;
  border-radius: 0.35rem;
  padding: 0.1rem 0.35rem;
}
@media (max-width: 760px) {
  .subscribe-grid {
    grid-template-columns: 1fr;
  }
  .copy-row {
    flex-direction: column;
  }
  .button.small {
    width: 100%;
  }
}

.form-grid.two {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.9rem;
}
.form-hint {
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 500;
}
.check-card.inline-check {
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  gap: 0.75rem;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 0.8rem;
  background: #fcfcfd;
}
.check-card.inline-check input {
  width: auto;
  margin-top: 0.2rem;
}
.check-card.inline-check small {
  display: block;
  color: var(--muted);
  font-weight: 500;
  margin-top: 0.15rem;
}
.check-card.subtle {
  background: #fff;
}
.clean-list {
  margin: 0.8rem 0;
  padding-left: 1.25rem;
}
.clean-list li {
  margin: 0.35rem 0;
}
.margin-top {
  margin-top: 1rem;
}
@media (max-width: 800px) {
  .form-grid.two { grid-template-columns: 1fr; }
}

.soft-card {
  background: #f8fafc;
  border: 1px solid #dbe4f0;
  box-shadow: none;
}
.soft-card h2 {
  margin-top: 0;
}
