/* ═══════════════════════════════════════════
   Components — Buttons, Cards, Badges, Forms, Modals, Toasts
   v2.1.0 — Drag-to-Resize Sheets + Visual Polish
   ═══════════════════════════════════════════ */

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-sm);
  padding: 10px var(--sp-md);
  border-radius: var(--r-md);
  font-size: var(--fs-sm);
  font-weight: var(--fw-semibold);
  line-height: 1;
  transition: all var(--tr-normal);
  white-space: nowrap;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.btn svg { width: 16px; height: 16px; flex-shrink: 0; }

.btn-primary {
  background: var(--c-primary);
  color: white;
  box-shadow: 0 2px 8px rgba(59, 130, 246, 0.3);
}
.btn-primary:hover { background: var(--c-primary-hover); transform: translateY(-1px); box-shadow: 0 4px 12px rgba(59, 130, 246, 0.4); }
.btn-primary:active { transform: none; box-shadow: 0 1px 4px rgba(59, 130, 246, 0.2); }

.btn-secondary {
  background: var(--c-surface-solid);
  border: 1px solid var(--c-border);
  color: var(--c-text);
}
.btn-secondary:hover { background: var(--c-surface-hover); border-color: var(--c-primary); color: var(--c-primary); }

.btn-ghost {
  color: var(--c-text-secondary);
}
.btn-ghost:hover { background: var(--c-surface); color: var(--c-text); }

.btn-danger {
  background: var(--c-error-soft);
  color: var(--c-error);
  border: 1px solid rgba(239, 68, 68, 0.2);
}
.btn-danger:hover { background: var(--c-error); color: white; border-color: var(--c-error); }

.btn-success {
  background: var(--c-success-soft);
  color: var(--c-success);
}
.btn-success:hover { background: var(--c-success); color: white; }

.btn-sm { padding: 6px 10px; font-size: var(--fs-xs); border-radius: var(--r-sm); }
.btn-lg { padding: 14px var(--sp-lg); font-size: var(--fs-base); }
.btn-block { width: 100%; }
.btn-icon {
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: var(--r-md);
  color: var(--c-text-secondary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.btn-icon:hover { background: var(--c-surface); color: var(--c-text); }
.btn-icon svg { width: 18px; height: 18px; }

/* ── Cards ── */
.card {
  background: var(--c-surface-solid);
  border: 1px solid var(--c-border);
  border-radius: var(--r-lg);
  padding: var(--sp-md);
  transition: all var(--tr-normal);
  box-shadow: var(--shadow-xs);
}

.card-interactive {
  cursor: pointer;
}
.card-interactive:hover {
  background: var(--c-surface-hover);
  border-color: var(--c-primary);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}
.card-interactive:active {
  transform: translateY(0);
}

/* Stat Cards — prominent with color accents */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--sp-sm);
}

.stat-number {
  font-size: var(--fs-3xl);
  font-weight: var(--fw-bold);
  letter-spacing: -1px;
  line-height: 1;
}

.stat-label {
  font-size: var(--fs-sm);
  color: var(--c-text-secondary);
  margin-top: var(--sp-xs);
  font-weight: var(--fw-medium);
}

/* ── Note / Task Cards ── */
.note-card, .task-card {
  background: var(--c-surface-solid);
  border: 1px solid var(--c-border);
  border-radius: var(--r-lg);
  padding: var(--sp-md);
  cursor: pointer;
  transition: all var(--tr-normal);
  position: relative;
  box-shadow: var(--shadow-xs);
}

.note-card:hover, .task-card:hover {
  border-color: var(--c-primary);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

.note-card:active, .task-card:active {
  transform: none;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: var(--sp-sm);
  margin-bottom: var(--sp-sm);
}

.card-title {
  font-size: var(--fs-sm);
  font-weight: var(--fw-semibold);
  line-height: var(--lh-tight);
  flex: 1;
  min-width: 0;
}

.card-content {
  font-size: var(--fs-sm);
  color: var(--c-text-secondary);
  line-height: var(--lh-normal);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-content.expanded {
  -webkit-line-clamp: unset;
  overflow: visible;
}

.card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: var(--sp-sm);
  font-size: var(--fs-xs);
  color: var(--c-text-muted);
}

.card-meta {
  display: flex;
  gap: var(--sp-sm);
  align-items: center;
  flex-wrap: wrap;
}

.card-project {
  color: var(--c-primary);
  font-weight: var(--fw-medium);
}

/* ── Status Dot ── */
.status-dot {
  width: 10px;
  height: 10px;
  border-radius: var(--r-full);
  flex-shrink: 0;
  box-shadow: 0 0 6px currentColor;
}
.status-dot.new, .status-dot.inbox { background: var(--c-status-inbox); color: var(--c-status-inbox); }
.status-dot.todo, .status-dot.open { background: var(--c-status-open); color: var(--c-status-open); }
.status-dot.in-progress { background: var(--c-status-in-progress); color: var(--c-status-in-progress); }
.status-dot.done, .status-dot.answered { background: var(--c-status-done); color: var(--c-status-done); }
.status-dot.error { background: var(--c-status-error); color: var(--c-status-error); }
.status-dot.archived { background: var(--c-status-archived); color: var(--c-status-archived); }

/* ── Badges ── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  border-radius: var(--r-full);
  font-size: var(--fs-xs);
  font-weight: var(--fw-semibold);
  white-space: nowrap;
  line-height: 1;
}

.badge-primary { background: var(--c-primary-soft); color: var(--c-primary); }
.badge-success { background: var(--c-success-soft); color: var(--c-success); }
.badge-warning { background: var(--c-warning-soft); color: var(--c-warning); }
.badge-error { background: var(--c-error-soft); color: var(--c-error); }
.badge-muted { background: var(--c-surface); color: var(--c-text-muted); }

/* ── Filter Chips ── */
.chip-bar {
  display: flex;
  gap: var(--sp-xs);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  padding-bottom: var(--sp-xs);
}
.chip-bar::-webkit-scrollbar { display: none; }

.chip {
  padding: 6px 14px;
  border-radius: var(--r-full);
  border: 1px solid var(--c-border);
  background: var(--c-surface-solid);
  font-size: var(--fs-xs);
  font-weight: var(--fw-medium);
  color: var(--c-text-secondary);
  white-space: nowrap;
  transition: all var(--tr-fast);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.chip:hover { border-color: var(--c-primary); color: var(--c-primary); }
.chip.active {
  background: var(--c-primary);
  border-color: var(--c-primary);
  color: white;
  box-shadow: 0 2px 8px rgba(59, 130, 246, 0.3);
}

/* ── Inputs / Forms ── */
.input {
  width: 100%;
  padding: 10px 12px;
  background: var(--c-bg);
  border: 1px solid var(--c-border);
  border-radius: var(--r-md);
  font-size: var(--fs-sm);
  color: var(--c-text);
  transition: border-color var(--tr-fast), box-shadow var(--tr-fast);
}

.input::placeholder { color: var(--c-text-muted); }
.input:focus {
  border-color: var(--c-primary);
  box-shadow: 0 0 0 3px var(--c-primary-soft);
}

textarea.input {
  min-height: 100px;
  resize: vertical;
  line-height: var(--lh-normal);
}

select.input {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2394A3B8' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 30px;
}

.field {
  margin-bottom: var(--sp-md);
}

.field-label {
  display: block;
  font-size: var(--fs-xs);
  font-weight: var(--fw-semibold);
  color: var(--c-text-secondary);
  margin-bottom: 6px;
  letter-spacing: 0.1px;
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--sp-sm);
}

/* ── Sheet / Modal Overlay ── */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: var(--z-overlay);
  display: flex;
  align-items: flex-end;
  animation: fadeIn var(--tr-fast);
}

.sheet {
  background: var(--c-bg-elevated);
  border: 1px solid var(--c-border-subtle);
  border-radius: var(--r-xl) var(--r-xl) 0 0;
  width: 100%;
  max-height: 90dvh;
  display: flex;
  flex-direction: column;
  animation: slideUp var(--tr-slow);
  box-shadow: var(--shadow-lg);
  position: relative;
}

.sheet-resizing {
  user-select: none;
  -webkit-user-select: none;
}

/* ── Corner Resize Grip (top-left for bottom-sheet) ── */
.sheet-resize-grip {
  position: absolute;
  top: 0;
  left: 0;
  width: 28px;
  height: 28px;
  cursor: nwse-resize;
  z-index: 2;
  touch-action: none;
}
.sheet-resize-grip::before {
  content: '';
  position: absolute;
  top: 6px;
  left: 6px;
  width: 10px;
  height: 10px;
  border-top: 2px solid var(--c-text-muted);
  border-left: 2px solid var(--c-text-muted);
  opacity: 0.4;
  transition: opacity var(--tr-fast);
}
.sheet-resize-grip:hover::before {
  opacity: 0.8;
}

/* ── Sheet Body (scrollable content) ── */
.sheet-body {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: var(--sp-lg);
  padding-bottom: calc(var(--sp-lg) + var(--safe-bottom));
  min-height: 0;
}

.sheet-title {
  font-size: var(--fs-xl);
  font-weight: var(--fw-bold);
  margin-bottom: var(--sp-md);
  letter-spacing: -0.3px;
}

.sheet-actions {
  display: flex;
  gap: var(--sp-sm);
  margin-top: var(--sp-lg);
  flex-wrap: wrap;
}

/* ── Modal (Centered) ── */
.modal-overlay {
  composes: overlay;
  align-items: center;
  justify-content: center;
  padding: var(--sp-lg);
}

.modal {
  background: var(--c-bg-elevated);
  border: 1px solid var(--c-border);
  border-radius: var(--r-xl);
  padding: var(--sp-lg);
  width: 100%;
  max-width: 420px;
  animation: slideUp var(--tr-slow);
}

/* ── Toast ── */
.toast {
  display: flex;
  align-items: center;
  gap: var(--sp-sm);
  padding: 12px var(--sp-md);
  border-radius: var(--r-md);
  background: var(--c-bg-elevated);
  border: 1px solid var(--c-border);
  box-shadow: var(--shadow-lg);
  font-size: var(--fs-sm);
  pointer-events: auto;
  animation: slideDown var(--tr-slow);
  cursor: pointer;
}

.toast-success { border-left: 3px solid var(--c-success); }
.toast-error { border-left: 3px solid var(--c-error); }
.toast-warning { border-left: 3px solid var(--c-warning); }
.toast-info { border-left: 3px solid var(--c-primary); }

.toast-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.toast-dismiss {
  animation: fadeIn var(--tr-fast);
  opacity: 0;
  transition: opacity var(--tr-normal);
}
.toast:hover .toast-dismiss { opacity: 1; }

/* ── Empty State ── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--sp-2xl) var(--sp-lg);
  text-align: center;
  color: var(--c-text-muted);
}

.empty-state svg {
  width: 48px;
  height: 48px;
  margin-bottom: var(--sp-md);
  opacity: 0.4;
  stroke: currentColor;
}

.empty-state p {
  font-size: var(--fs-sm);
  max-width: 280px;
}

/* ── Spinner ── */
.spinner {
  width: 24px;
  height: 24px;
  border: 2px solid var(--c-border);
  border-top-color: var(--c-primary);
  border-radius: var(--r-full);
  animation: spin 0.6s linear infinite;
}

/* ── Progress Ring ── */
.progress-ring {
  width: 44px;
  height: 44px;
  border-radius: var(--r-full);
  background: conic-gradient(var(--c-primary) var(--progress-deg, 0deg), var(--c-surface) var(--progress-deg, 0deg));
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.progress-ring span {
  width: 34px;
  height: 34px;
  border-radius: var(--r-full);
  background: var(--c-surface-solid);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--fs-xs);
  font-weight: var(--fw-bold);
  color: var(--c-text);
}

/* ── Section Headers ── */
.section-title {
  font-size: var(--fs-sm);
  font-weight: var(--fw-semibold);
  color: var(--c-text-secondary);
  letter-spacing: -0.1px;
  margin-bottom: var(--sp-sm);
}

/* ── Grid Layouts ── */
.grid {
  display: grid;
  gap: var(--sp-sm);
}

.grid-cards {
  grid-template-columns: 1fr;
}

.list {
  display: flex;
  flex-direction: column;
  gap: var(--sp-sm);
}

/* ── Tabs ── */
.tabs {
  display: flex;
  gap: var(--sp-xs);
  margin-bottom: var(--sp-md);
  border-bottom: 1px solid var(--c-border-subtle);
  padding-bottom: var(--sp-xs);
  overflow-x: auto;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }

.tab {
  padding: var(--sp-sm) var(--sp-md);
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
  color: var(--c-text-muted);
  border-bottom: 2px solid transparent;
  transition: all var(--tr-fast);
  white-space: nowrap;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.tab:hover { color: var(--c-text); }
.tab.active {
  color: var(--c-primary);
  border-bottom-color: var(--c-primary);
  font-weight: var(--fw-semibold);
}

.tab-count {
  margin-left: var(--sp-xs);
  font-size: var(--fs-2xs);
  opacity: 0.6;
}

/* ── Quick Add Bar ── */
.quick-add {
  display: flex;
  gap: var(--sp-sm);
  margin-bottom: var(--sp-md);
}

.quick-add .input { flex: 1; }

/* ── Divider ── */
.divider {
  height: 1px;
  background: var(--c-border-subtle);
  margin: var(--sp-md) 0;
}

/* ── Surface Elevated (for nested cards) ── */
.card .card {
  background: var(--c-bg);
}

/* ═══════════════════════════════════════════
   Settings Page
   ═══════════════════════════════════════════ */

.settings-container {
  max-width: 600px;
}

.settings-section {
  background: var(--c-surface-solid);
  border: 1px solid var(--c-border);
  border-radius: var(--r-lg);
  padding: var(--sp-md);
  margin-bottom: var(--sp-md);
}

.settings-title {
  font-size: var(--fs-sm);
  font-weight: var(--fw-bold);
  color: var(--c-text);
  margin-bottom: var(--sp-sm);
  padding-bottom: var(--sp-xs);
  border-bottom: 1px solid var(--c-border-subtle);
}

.settings-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--sp-sm) 0;
  gap: var(--sp-sm);
}

.settings-item + .settings-item {
  border-top: 1px solid var(--c-border-subtle);
}

.settings-label {
  font-size: var(--fs-sm);
  color: var(--c-text-secondary);
  font-weight: var(--fw-medium);
}

/* ── Toggle Button ── */
.toggle {
  width: 44px;
  height: 24px;
  border-radius: var(--r-full);
  background: var(--c-border);
  position: relative;
  cursor: pointer;
  transition: background var(--tr-fast);
  flex-shrink: 0;
}
.toggle::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  border-radius: var(--r-full);
  background: white;
  transition: transform var(--tr-fast);
}
.toggle.active {
  background: var(--c-primary);
}
.toggle.active::after {
  transform: translateX(20px);
}

/* ═══════════════════════════════════════════
   Calendar Page
   ═══════════════════════════════════════════ */

.calendar-container {
  display: flex;
  flex-direction: column;
  gap: var(--sp-sm);
}

/* ── Stable Controls Bar — never changes height/layout ── */
.calendar-controls {
  display: flex;
  gap: var(--sp-xs);
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--c-page-bg, var(--c-surface-solid));
  padding: var(--sp-xs) 0;
  min-height: 44px;
}

.cal-nav-btn {
  min-width: 72px;
  min-height: 40px;
  text-align: center;
  flex-shrink: 0;
  touch-action: manipulation;
  -webkit-tap-highlight-color: rgba(59,130,246,0.2);
  cursor: pointer;
}

.calendar-view-btns, .calendar-orient-btns {
  display: flex;
  gap: 2px;
  background: var(--c-surface-solid);
  border: 1px solid var(--c-border);
  border-radius: var(--r-md);
  padding: 2px;
}

.calendar-view-btn {
  padding: 6px 12px;
  font-size: var(--fs-xs);
  font-weight: var(--fw-semibold);
  border-radius: var(--r-sm);
  color: var(--c-text-secondary);
  transition: all var(--tr-fast);
  cursor: pointer;
  white-space: nowrap;
  touch-action: manipulation;
}
.calendar-view-btn:hover { color: var(--c-text); background: var(--c-surface); }
.calendar-view-btn.active {
  background: var(--c-primary);
  color: white;
  box-shadow: 0 1px 4px rgba(59,130,246,0.3);
}

.calendar-nav-row {
  display: flex;
  gap: var(--sp-xs);
  align-items: center;
  justify-content: center;
  padding: var(--sp-xs) 0;
}

.calendar-nav-title {
  min-width: 120px;
  text-align: center;
  font-size: var(--fs-sm);
  font-weight: var(--fw-bold);
  white-space: nowrap;
  flex-shrink: 0;
  flex: 1;
}

/* calendar-separator removed — 4-button nav replaces old ← title → layout */

/* ── Header Day Entries (Terminvorschau) ── */
.calendar-day-entries {
  display: flex;
  align-items: center;
  gap: var(--sp-sm);
  padding: var(--sp-sm) var(--sp-md);
  background: var(--c-surface-solid);
  border: 1px solid var(--c-border);
  border-radius: var(--r-md);
  overflow-x: auto;
  min-height: 40px;
}

.calendar-day-entries-date {
  font-size: var(--fs-sm);
  font-weight: var(--fw-bold);
  color: var(--c-primary);
  white-space: nowrap;
  flex-shrink: 0;
}

.calendar-day-entries-empty {
  font-size: var(--fs-xs);
  color: var(--c-text-muted);
}

.header-day-entry {
  display: flex;
  align-items: center;
  gap: var(--sp-2xs);
  padding: var(--sp-2xs) var(--sp-sm);
  background: var(--c-surface);
  border: 1px solid var(--c-border-subtle);
  border-radius: var(--r-sm);
  cursor: pointer;
  white-space: nowrap;
  transition: all var(--tr-fast);
  flex-shrink: 0;
}
.header-day-entry:hover {
  border-color: var(--c-primary);
  background: var(--c-surface-hover);
}

.header-day-entry-color {
  width: 8px;
  height: 8px;
  border-radius: var(--r-full);
  flex-shrink: 0;
}

.header-day-entry-time {
  font-size: var(--fs-xs);
  color: var(--c-text-muted);
}

.header-day-entry-title {
  font-size: var(--fs-xs);
  font-weight: var(--fw-semibold);
}

/* ── + Button in header entries bar ── */
.cal-add-btn {
  margin-left: auto;
  flex-shrink: 0;
  min-width: 32px;
  min-height: 28px;
  font-size: var(--fs-base);
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ── View Container — fixed min-heights for stability ── */
.cal-view-container {
  min-height: 400px;
}

/* ── Month-V internal nav (inside view container, not in controls) ── */
.cal-monthv-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-sm);
  padding: var(--sp-sm) var(--sp-md);
  background: var(--c-surface-solid);
  border: 1px solid var(--c-border);
  border-radius: var(--r-md);
  backdrop-filter: blur(10px);
  margin-bottom: var(--sp-sm);
}

/* ── Create Modal extras ── */
.cal-modal-type-picker {
  display: flex;
  gap: var(--sp-sm);
  margin-bottom: var(--sp-md);
}

.cal-color-picker {
  display: flex;
  gap: var(--sp-sm);
}
.cal-color-opt {
  width: 28px;
  height: 28px;
  border-radius: var(--r-full);
  cursor: pointer;
  border: 2px solid transparent;
  transition: all var(--tr-fast);
}
.cal-color-opt:hover { transform: scale(1.15); }
.cal-color-opt.selected {
  border-color: white;
  box-shadow: 0 0 0 2px var(--c-primary);
}

/* ── Inline add button in week-v ── */
.cal-inline-add {
  float: right;
  padding: 0 6px;
  font-size: var(--fs-base);
  line-height: 1;
}

/* ── Day View ── */
.cal-day {
  display: flex;
  flex-direction: column;
  gap: var(--sp-sm);
}

.cal-day-list {
  background: var(--c-surface-solid);
  border: 1px solid var(--c-border);
  border-radius: var(--r-lg);
  padding: var(--sp-md);
}

.cal-day-section-title {
  font-size: var(--fs-sm);
  font-weight: var(--fw-bold);
  margin-bottom: var(--sp-sm);
}

.cal-day-empty {
  color: var(--c-text-muted);
  font-size: var(--fs-sm);
  text-align: center;
  padding: var(--sp-lg) 0;
}

.cal-day-item {
  display: flex;
  align-items: center;
  gap: var(--sp-sm);
  padding: var(--sp-sm) var(--sp-sm) var(--sp-sm) var(--sp-md);
  border-left: 2px solid var(--c-primary);
  border-radius: 0 var(--r-md) var(--r-md) 0;
  margin-bottom: var(--sp-xs);
  cursor: pointer;
  transition: all var(--tr-fast);
}
.cal-day-item:hover { background: var(--c-surface-hover); }

.cal-day-item-time {
  font-size: var(--fs-xs);
  color: var(--c-primary);
  white-space: nowrap;
  flex-shrink: 0;
}

.cal-day-item-badge {
  font-size: 9px;
  font-weight: var(--fw-semibold);
  padding: 2px 6px;
  border-radius: var(--r-sm);
  white-space: nowrap;
  flex-shrink: 0;
}
.cal-day-item-badge.task {
  background: var(--c-primary-soft);
  color: var(--c-primary);
}
.cal-day-item-badge.event {
  background: var(--c-success-soft, rgba(34,197,94,0.15));
  color: var(--c-success, #22c55e);
}

.cal-dot {
  width: 8px;
  height: 8px;
  border-radius: var(--r-full);
  flex-shrink: 0;
}

.cal-day-item-title {
  flex: 1;
  font-size: var(--fs-sm);
  font-weight: var(--fw-semibold);
}

.cal-day-item-meta {
  font-size: var(--fs-xs);
  color: var(--c-text-muted);
}

.cal-holiday-bar {
  padding: var(--sp-sm) var(--sp-md);
  background: var(--c-error-soft);
  border: 1px solid rgba(239,68,68,0.3);
  border-radius: var(--r-md);
  font-size: var(--fs-sm);
  color: var(--c-error);
}

/* Event Detail */
.cal-event-detail { display: flex; flex-direction: column; gap: var(--sp-sm); }
.cal-event-color-bar { height: 4px; border-radius: 2px; }
.cal-event-title { font-size: var(--fs-lg); font-weight: var(--fw-bold); }
.cal-event-time { font-size: var(--fs-sm); color: var(--c-primary); }
.cal-event-desc { font-size: var(--fs-sm); color: var(--c-text-secondary); }
.cal-event-meta { display: flex; gap: var(--sp-sm); flex-wrap: wrap; }

.cal-event-field {
  font-size: var(--fs-sm);
  color: var(--c-text-secondary);
  padding: var(--sp-2xs) 0;
}

.cal-event-linked {
  margin-top: var(--sp-sm);
  padding-top: var(--sp-sm);
  border-top: 1px solid var(--c-border-subtle);
}

.cal-event-linked-title {
  font-size: var(--fs-xs);
  font-weight: var(--fw-bold);
  color: var(--c-text-secondary);
  margin-bottom: var(--sp-xs);
}

.cal-event-linked-item {
  display: flex;
  align-items: center;
  gap: var(--sp-xs);
  font-size: var(--fs-sm);
  padding: var(--sp-2xs) 0;
}

/* ── Week Horizontal ── */
.cal-week-h {
  display: flex;
  gap: 1px;
  background: var(--c-border-subtle);
  border: 1px solid var(--c-border);
  border-radius: var(--r-lg);
  overflow: hidden;
  height: 700px;
}

.cal-time-col {
  width: 48px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  padding-top: 36px;
  background: var(--c-surface-solid);
}

.cal-time-label {
  flex: 1;
  font-size: var(--fs-2xs);
  color: var(--c-text-muted);
  text-align: center;
  padding-top: 2px;
}

.cal-day-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--c-surface-solid);
  min-width: 0;
}
.cal-day-col.today { background: rgba(59,130,246,0.04); }
.cal-day-col.selected { background: rgba(59,130,246,0.08); }

.cal-day-col-header {
  padding: var(--sp-xs) var(--sp-2xs);
  font-size: var(--fs-2xs);
  font-weight: var(--fw-bold);
  text-align: center;
  border-bottom: 1px solid var(--c-border-subtle);
  white-space: nowrap;
}

.cal-header-holiday {
  display: block;
  font-size: 8px;
  font-weight: var(--fw-normal, 400);
  color: var(--c-error);
  line-height: 1.2;
  margin-top: 2px;
}

.cal-slots-wrapper {
  position: relative;
  flex: 1;
}

.cal-time-slot {
  height: calc(100% / 17);
  box-sizing: border-box;
  border-bottom: 1px solid color-mix(in srgb, var(--c-border-subtle) 50%, transparent);
  cursor: pointer;
}
.cal-time-slot:hover {
  background: rgba(59,130,246,0.04);
}
.cal-time-slot:nth-child(even) {
  border-bottom-style: dotted;
}

.cal-event-overlay {
  position: absolute;
  left: 2px;
  right: 2px;
  border-radius: 0 4px 4px 0;
  padding: 3px 5px;
  font-size: 10px;
  color: var(--c-text);
  overflow: hidden;
  cursor: pointer;
  z-index: 3;
  border-left: 2px solid var(--cal-entry-color, var(--c-primary));
  background: var(--cal-entry-bg, rgba(59,130,246,0.15));
  display: flex;
  flex-direction: column;
}
.cal-event-overlay-title { font-weight: 600; line-height: 1.2; }
.cal-event-overlay-time { font-size: 9px; color: var(--c-text-muted); }

/* ── Week Vertical ── */
.cal-week-v {
  display: flex;
  flex-direction: column;
  gap: var(--sp-xs);
}

.cal-vert-day {
  background: var(--c-surface-solid);
  border: 1px solid var(--c-border);
  border-radius: var(--r-md);
  padding: var(--sp-sm) var(--sp-md);
}
.cal-vert-day.today { border-color: var(--c-primary); background: rgba(59,130,246,0.04); }

.cal-vert-day-header {
  font-size: var(--fs-sm);
  font-weight: var(--fw-bold);
  margin-bottom: var(--sp-xs);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.cal-vert-items { display: flex; flex-direction: column; gap: var(--sp-2xs); }
.cal-vert-empty { font-size: var(--fs-xs); color: var(--c-text-muted); }
.cal-vert-holiday { font-size: var(--fs-xs); color: var(--c-error); }

.cal-vert-item {
  font-size: var(--fs-sm);
  padding: var(--sp-xs) var(--sp-sm);
  border-left: 2px solid var(--c-primary);
  border-radius: 0 var(--r-sm) var(--r-sm) 0;
  cursor: pointer;
  transition: background var(--tr-fast);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cal-vert-item:hover { background: var(--c-surface-hover); }

.cal-vert-item-time {
  font-size: var(--fs-xs);
  color: var(--c-text-muted);
  margin-right: var(--sp-xs);
}

/* ── Month Horizontal ── */
.cal-month {
  display: flex;
  flex-direction: column;
}

.cal-month-header-row {
  display: grid;
  grid-template-columns: 36px repeat(7, 1fr);
  gap: 1px;
  margin-bottom: var(--sp-xs);
}

.cal-kw-header {
  font-size: var(--fs-2xs);
  font-weight: var(--fw-bold);
  color: var(--c-primary);
  text-align: center;
  padding: var(--sp-xs);
}

.cal-month-day-name {
  font-size: var(--fs-xs);
  font-weight: var(--fw-semibold);
  color: var(--c-text-secondary);
  text-align: center;
  padding: var(--sp-xs);
}

.cal-month-grid {
  display: grid;
  grid-template-columns: 36px repeat(7, 1fr);
  gap: 2px;
  min-height: 600px;
}

.cal-kw-cell {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--fs-2xs);
  font-weight: var(--fw-bold);
  color: var(--c-primary);
}

.cal-month-cell {
  min-height: 80px;
  background: var(--c-surface-solid);
  border: 1px solid var(--c-border-subtle);
  border-radius: var(--r-sm);
  padding: var(--sp-2xs);
  cursor: pointer;
  transition: all var(--tr-fast);
}
.cal-month-cell:hover { border-color: var(--c-primary); }
.cal-month-cell.other { opacity: 0.5; }
.cal-month-cell.today { border-color: var(--c-primary); background: rgba(59,130,246,0.08); }
.cal-month-cell.selected { outline: 2px solid var(--c-primary); outline-offset: -2px; }

.cal-month-day-num {
  font-size: var(--fs-sm);
  font-weight: var(--fw-semibold);
  margin-bottom: var(--sp-2xs);
}

.cal-month-event {
  font-size: 10px;
  line-height: 1.3;
  padding: 2px 4px;
  border-radius: 3px;
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cal-month-event.holiday { color: var(--c-error); background: var(--c-error-soft); }
.cal-month-more { font-size: 9px; color: var(--c-text-muted); text-align: center; }

.cal-month-day-num.today-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: var(--r-full);
  background: var(--c-primary);
  color: white;
  font-weight: var(--fw-bold);
}

/* ── Month Vertical ── */
.cal-month-v {
  overflow-x: auto;
}

.cal-month-v-grid {
  display: grid;
  gap: 3px;
}

.cal-mv-corner {
  padding: var(--sp-sm);
  font-size: var(--fs-sm);
  font-weight: var(--fw-bold);
  color: var(--c-primary);
  background: var(--c-surface-solid);
  border-radius: var(--r-sm);
  display: flex;
  align-items: center;
  justify-content: center;
}

.cal-mv-kw-header {
  padding: var(--sp-xs);
  font-size: var(--fs-sm);
  font-weight: var(--fw-bold);
  color: var(--c-primary);
  background: var(--c-surface-solid);
  border-radius: var(--r-sm);
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2xs);
}

.cal-mv-month-label {
  font-size: var(--fs-2xs);
  font-weight: var(--fw-semibold);
  color: var(--c-text-secondary);
}

.cal-mv-kw-num {
  font-size: var(--fs-xs);
  font-weight: var(--fw-bold);
  color: var(--c-primary);
}

.cal-mv-day-label {
  padding: var(--sp-sm);
  font-size: var(--fs-sm);
  font-weight: var(--fw-semibold);
  color: var(--c-text-secondary);
  background: var(--c-surface-solid);
  border-radius: var(--r-sm);
  display: flex;
  align-items: center;
}

.cal-mv-cell {
  padding: var(--sp-xs) var(--sp-sm);
  min-height: 72px;
  background: var(--c-surface-solid);
  border: 1px solid var(--c-border-subtle);
  border-radius: var(--r-sm);
  cursor: pointer;
  transition: all var(--tr-fast);
}
.cal-mv-cell:hover { border-color: var(--c-primary); }
.cal-mv-cell.other { opacity: 0.4; }
.cal-mv-cell.today { border-color: var(--c-primary); background: rgba(59,130,246,0.08); }
.cal-mv-cell.selected { outline: 2px solid var(--c-primary); outline-offset: -2px; }

.cal-mv-day-num {
  font-size: var(--fs-sm);
  font-weight: var(--fw-semibold);
  margin-bottom: var(--sp-2xs);
}

.cal-mv-holiday {
  font-size: 10px;
  color: var(--c-error);
  line-height: 1.3;
}

.cal-mv-event {
  padding: 3px 5px;
  font-size: 11px;
  line-height: 1.3;
  border-radius: 3px;
  margin-bottom: 2px;
  background: var(--c-primary-soft);
}

/* ── Year View (shared for H and V) ── */
.cal-year {
  display: grid;
  gap: var(--sp-md);
  padding: var(--sp-xs);
}

.cal-year-month {
  background: var(--c-surface-solid);
  border: 1px solid var(--c-border);
  border-radius: var(--r-lg);
  padding: var(--sp-sm);
  cursor: pointer;
  transition: all var(--tr-fast);
}
.cal-year-month:hover { border-color: var(--c-primary); transform: translateY(-1px); }
.cal-year-month.has-entries {
  border-color: var(--c-primary);
  box-shadow: 0 0 0 1px rgba(59,130,246,0.15);
}

.cal-year-month-header {
  font-size: var(--fs-sm);
  font-weight: var(--fw-bold);
  margin-bottom: var(--sp-xs);
  text-align: center;
}

.cal-mini-grid {
  display: grid;
  grid-template-columns: 20px repeat(7, 1fr);
  gap: 1px;
  text-align: center;
}

.cal-mini-kw-label {
  font-size: 8px;
  font-weight: 700;
  color: var(--c-primary);
}

.cal-mini-day-label {
  font-size: 10px;
  font-weight: 600;
  color: var(--c-text-secondary);
}

.cal-mini-kw {
  font-size: 7px;
  font-weight: 700;
  color: var(--c-primary);
  display: flex;
  align-items: center;
  justify-content: center;
}

.cal-mini-cell {
  font-size: 11px;
  padding: 2px;
  border-radius: 3px;
  cursor: pointer;
}
.cal-mini-cell.empty { cursor: default; }
.cal-mini-cell.today {
  background: var(--c-primary);
  color: white;
  font-weight: 700;
}
.cal-mini-cell.holiday { color: var(--c-error); }
.cal-mini-cell.has-entry {
  position: relative;
}
.cal-mini-cell.has-entry::after {
  content: '';
  position: absolute;
  bottom: 1px;
  left: 50%;
  transform: translateX(-50%);
  width: 4px;
  height: 4px;
  border-radius: var(--r-full);
  background: var(--c-primary);
}

/* ═══════════════════════════════════════════
   Login + PIN Pad
   ═══════════════════════════════════════════ */

.login-mount {
  min-height: 100vh;
  background: var(--c-bg);
}

page-login {
  display: block;
}

.login-container {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: var(--sp-lg);
  background: var(--c-bg);
}

.login-card {
  width: 100%;
  max-width: 360px;
  background: var(--c-surface-solid);
  border: 1px solid var(--c-border);
  border-radius: var(--r-xl);
  padding: var(--sp-xl);
  box-shadow: 0 8px 32px rgba(0,0,0,0.3);
}

.login-header {
  text-align: center;
  margin-bottom: var(--sp-lg);
}

.login-logo {
  width: 48px;
  height: 48px;
  margin: 0 auto var(--sp-md);
  color: var(--c-primary);
}
.login-logo svg { width: 48px; height: 48px; }

.login-title {
  font-size: var(--fs-xl);
  font-weight: var(--fw-bold);
  margin-bottom: var(--sp-xs);
}

.login-subtitle {
  font-size: var(--fs-sm);
  color: var(--c-text-secondary);
}

.login-error {
  padding: var(--sp-sm) var(--sp-md);
  background: var(--c-error-soft);
  color: var(--c-error);
  border-radius: var(--r-md);
  font-size: var(--fs-sm);
  text-align: center;
  margin-bottom: var(--sp-md);
}

.login-setup-field {
  margin-bottom: var(--sp-sm);
}

.login-divider {
  display: flex;
  align-items: center;
  gap: var(--sp-md);
  margin: var(--sp-lg) 0;
  color: var(--c-text-muted);
  font-size: var(--fs-xs);
}
.login-divider::before, .login-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--c-border);
}

/* PIN Display */
.pin-display {
  display: flex;
  justify-content: center;
  gap: var(--sp-md);
  margin-bottom: var(--sp-lg);
}

.pin-dot {
  width: 16px;
  height: 16px;
  border-radius: var(--r-full);
  border: 2px solid var(--c-border);
  transition: all 0.15s ease;
}
.pin-dot.filled {
  background: var(--c-primary);
  border-color: var(--c-primary);
  box-shadow: 0 0 8px rgba(59,130,246,0.4);
}

/* PIN Pad */
.pin-pad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--sp-sm);
  max-width: 280px;
  margin: 0 auto;
}

.pin-key {
  aspect-ratio: 1.4;
  font-size: var(--fs-xl);
  font-weight: var(--fw-bold);
  border: 1px solid var(--c-border);
  border-radius: var(--r-lg);
  background: var(--c-surface);
  color: var(--c-text);
  cursor: pointer;
  transition: all var(--tr-fast);
  display: flex;
  align-items: center;
  justify-content: center;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}
.pin-key:hover { background: var(--c-surface-hover); border-color: var(--c-primary); }
.pin-key:active { background: var(--c-primary); color: white; transform: scale(0.95); }

.pin-key-action {
  font-size: var(--fs-base);
  color: var(--c-text-secondary);
  background: transparent;
  border-color: transparent;
}
.pin-key-action:hover { color: var(--c-text); background: var(--c-surface); }

/* ═══════════════════════════════════════════
   Admin User Management
   ═══════════════════════════════════════════ */

.admin-user-list {
  display: flex;
  flex-direction: column;
  gap: var(--sp-sm);
}

.admin-user-card {
  display: flex;
  align-items: center;
  gap: var(--sp-md);
  padding: var(--sp-md);
  background: var(--c-surface-solid);
  border: 1px solid var(--c-border);
  border-radius: var(--r-md);
  cursor: pointer;
  transition: all var(--tr-fast);
}
.admin-user-card:hover { border-color: var(--c-primary); }
.admin-user-card.inactive { opacity: 0.5; }

.admin-user-avatar {
  width: 40px;
  height: 40px;
  border-radius: var(--r-full);
  background: linear-gradient(135deg, var(--c-primary), #357abd);
  color: white;
  font-weight: var(--fw-bold);
  font-size: var(--fs-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.admin-user-info { flex: 1; min-width: 0; }
.admin-user-name { font-weight: var(--fw-semibold); }
.admin-user-meta { font-size: var(--fs-xs); color: var(--c-text-muted); }

/* ═══════════════════════════════════════════
   Report Page
   ═══════════════════════════════════════════ */

.report-container {
  max-width: 700px;
}

.report-nav {
  display: flex;
  align-items: center;
  gap: var(--sp-sm);
  margin-bottom: var(--sp-lg);
  flex-wrap: wrap;
}

.report-date {
  flex: 1;
  text-align: center;
  font-size: var(--fs-base);
  font-weight: var(--fw-bold);
}

.report-sections {
  display: flex;
  flex-direction: column;
  gap: var(--sp-lg);
}

.report-section {
  background: var(--c-surface-solid);
  border: 1px solid var(--c-border);
  border-radius: var(--r-lg);
  overflow: hidden;
}

.report-section-header {
  display: flex;
  align-items: center;
  gap: var(--sp-sm);
  padding: var(--sp-md);
  border-bottom: 1px solid var(--c-border-subtle);
}

.report-section-icon {
  width: 20px;
  height: 20px;
  color: var(--c-primary);
  display: flex;
  align-items: center;
}
.report-section-icon svg { width: 20px; height: 20px; }

.report-section-title {
  font-size: var(--fs-base);
  font-weight: var(--fw-bold);
}

.report-section-body {
  padding: var(--sp-md);
}

.report-subsection-title {
  font-size: var(--fs-sm);
  font-weight: var(--fw-semibold);
  color: var(--c-text-secondary);
  margin-bottom: var(--sp-sm);
}

.report-empty {
  color: var(--c-text-muted);
  font-size: var(--fs-sm);
  padding: var(--sp-md) 0;
  text-align: center;
}

.report-task-list {
  display: flex;
  flex-direction: column;
  gap: var(--sp-xs);
  margin-bottom: var(--sp-md);
}

.report-task-item {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-sm);
  padding: var(--sp-sm);
  border: 1px solid var(--c-border);
  border-radius: var(--r-md);
  cursor: pointer;
  transition: all var(--tr-fast);
}
.report-task-item:hover { border-color: var(--c-primary); }
.report-task-item.checked { opacity: 0.5; }
.report-task-item.done { opacity: 0.7; }

.report-task-check {
  width: 20px;
  height: 20px;
  border: 2px solid var(--c-border);
  border-radius: var(--r-sm);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--tr-fast);
  margin-top: 2px;
}
.report-task-check svg { width: 14px; height: 14px; color: var(--c-primary); }
.report-task-item.checked .report-task-check {
  background: var(--c-primary-soft);
  border-color: var(--c-primary);
}
.report-task-check.done {
  background: var(--c-success-soft);
  border-color: var(--c-success);
}
.report-task-check.done svg { color: var(--c-success); }

.report-task-info { flex: 1; min-width: 0; }

.report-task-title {
  font-size: var(--fs-sm);
  font-weight: var(--fw-semibold);
}
.report-task-item.checked .report-task-title { text-decoration: line-through; }
.report-task-item.done .report-task-title { text-decoration: line-through; }

.report-task-meta {
  display: flex;
  gap: var(--sp-sm);
  margin-top: var(--sp-2xs);
  font-size: var(--fs-xs);
}

.report-task-priority { font-weight: var(--fw-semibold); }
.report-task-project { color: var(--c-primary); }

.report-field {
  margin-top: var(--sp-md);
}

.report-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--sp-sm);
  margin-top: var(--sp-lg);
  padding-top: var(--sp-md);
  border-top: 1px solid var(--c-border-subtle);
}

.report-stat {
  text-align: center;
}

.report-stat-num {
  font-size: var(--fs-xl);
  font-weight: var(--fw-bold);
  line-height: 1;
}

.report-stat-label {
  font-size: var(--fs-xs);
  color: var(--c-text-muted);
  margin-top: var(--sp-2xs);
}

/* ═══════════════════════════════════════════
   Handschrift Canvas
   ═══════════════════════════════════════════ */

.canvas-wrapper {
  border: 1px solid var(--c-border);
  border-radius: var(--r-md);
  overflow: hidden;
  background: var(--c-bg);
}

.canvas-color-btn {
  width: 24px;
  height: 24px;
  border-radius: var(--r-full);
  border: 2px solid var(--c-border);
  cursor: pointer;
  transition: all var(--tr-fast);
}
.canvas-color-btn:hover { transform: scale(1.15); }
.canvas-color-btn.active {
  border-color: var(--c-primary);
  box-shadow: 0 0 0 2px var(--c-primary-soft);
}

.canvas-size-btn {
  width: 28px;
  height: 28px;
  border-radius: var(--r-sm);
  border: 1px solid var(--c-border);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--tr-fast);
}
.canvas-size-btn:hover { border-color: var(--c-primary); }
.canvas-size-btn.active {
  border-color: var(--c-primary);
  background: var(--c-primary-soft);
}

/* ═══════════════════════════════════════════
   Entry Panel — Responsive side/bottom/fullscreen
   ═══════════════════════════════════════════ */

/* Overlay (tablet + mobile only) */
.ep-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 90;
  backdrop-filter: blur(2px);
}

/* Panel base */
.entry-panel {
  position: fixed;
  z-index: 95;
  background: var(--c-surface-solid);
  display: flex;
  flex-direction: column;
  box-shadow: -4px 0 24px rgba(0,0,0,0.15);
}

/* Desktop: Right side panel */
.entry-panel--desktop {
  top: 0;
  right: 0;
  bottom: 0;
  min-width: 320px;
  max-width: 600px;
  border-left: 1px solid var(--c-border);
  animation: ep-slide-left 0.2s ease-out;
}

/* Tablet: Bottom sheet */
.entry-panel--tablet {
  left: 0;
  right: 0;
  bottom: 0;
  max-height: 70vh;
  border-radius: var(--r-xl) var(--r-xl) 0 0;
  border-top: 1px solid var(--c-border);
  animation: ep-slide-up 0.25s ease-out;
}

/* Mobile: Fullscreen */
.entry-panel--mobile {
  inset: 0;
  animation: ep-fade-in 0.15s ease-out;
}

@keyframes ep-slide-left {
  from { transform: translateX(100%); }
  to { transform: translateX(0); }
}
@keyframes ep-slide-up {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}
@keyframes ep-fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* Resize handle (desktop only) */
.ep-resize-handle {
  position: absolute;
  left: -3px;
  top: 0;
  bottom: 0;
  width: 6px;
  cursor: col-resize;
  z-index: 10;
}
.ep-resize-handle:hover {
  background: var(--c-primary);
  opacity: 0.3;
}

/* Header */
.ep-header {
  display: flex;
  align-items: center;
  gap: var(--sp-sm);
  padding: var(--sp-md);
  border-bottom: 1px solid var(--c-border);
  flex-shrink: 0;
}

.ep-header-title {
  flex: 1;
  font-size: var(--fs-base);
  font-weight: var(--fw-bold);
}

.ep-back {
  display: flex;
  align-items: center;
  gap: var(--sp-xs);
  padding: var(--sp-xs);
  border-radius: var(--r-md);
  cursor: pointer;
  color: var(--c-text-secondary);
  font-size: var(--fs-sm);
  transition: all var(--tr-fast);
}
.ep-back:hover { color: var(--c-text); background: var(--c-surface); }
.ep-back-icon { display: flex; }
.ep-back-icon svg { width: 18px; height: 18px; }

.ep-delete svg { width: 16px; height: 16px; color: var(--c-error); }

/* Type picker */
.ep-type-picker {
  display: flex;
  gap: var(--sp-sm);
  padding: var(--sp-sm) var(--sp-md);
  border-bottom: 1px solid var(--c-border-subtle);
  flex-shrink: 0;
}

/* Body (scrollable) */
.ep-body {
  flex: 1;
  overflow-y: auto;
  padding: var(--sp-md);
  -webkit-overflow-scrolling: touch;
}

/* Footer */
.ep-footer {
  display: flex;
  gap: var(--sp-sm);
  padding: var(--sp-md);
  border-top: 1px solid var(--c-border);
  flex-shrink: 0;
}

/* ── Linked Tasks Section ── */
.ep-linked-section {
  margin-top: var(--sp-lg);
  padding-top: var(--sp-md);
  border-top: 1px solid var(--c-border-subtle);
}

.ep-linked-header {
  display: flex;
  align-items: center;
  gap: var(--sp-sm);
  margin-bottom: var(--sp-sm);
}

.ep-linked-title {
  font-size: var(--fs-sm);
  font-weight: var(--fw-bold);
  color: var(--c-text-secondary);
}

.ep-linked-count {
  font-size: var(--fs-2xs);
  font-weight: var(--fw-bold);
  padding: 2px 8px;
  border-radius: var(--r-full);
  background: var(--c-primary-soft);
  color: var(--c-primary);
}

.ep-linked-list {
  display: flex;
  flex-direction: column;
  gap: var(--sp-xs);
  margin-bottom: var(--sp-sm);
}

.ep-linked-item {
  display: flex;
  align-items: center;
  gap: var(--sp-sm);
  padding: var(--sp-sm);
  border-left: 2px solid var(--c-primary);
  border-radius: 0 var(--r-sm) var(--r-sm) 0;
  background: var(--c-surface);
  transition: background var(--tr-fast);
}
.ep-linked-item:hover { background: var(--c-surface-hover); }

.ep-linked-dot {
  width: 6px;
  height: 6px;
  border-radius: var(--r-full);
  flex-shrink: 0;
}

.ep-linked-item-title {
  flex: 1;
  font-size: var(--fs-sm);
  font-weight: var(--fw-semibold);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ep-unlink-btn {
  padding: 2px;
  cursor: pointer;
  color: var(--c-text-muted);
  border-radius: var(--r-sm);
  transition: all var(--tr-fast);
  flex-shrink: 0;
}
.ep-unlink-btn:hover { color: var(--c-error); background: var(--c-error-soft); }
.ep-unlink-btn svg { width: 14px; height: 14px; }

/* Task search */
.ep-task-search {
  position: relative;
  margin-bottom: var(--sp-sm);
}

.ep-task-results {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--c-surface-solid);
  border: 1px solid var(--c-border);
  border-radius: var(--r-md);
  box-shadow: 0 4px 16px rgba(0,0,0,0.15);
  z-index: 10;
  max-height: 200px;
  overflow-y: auto;
}

.ep-task-result {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--sp-sm);
  cursor: pointer;
  font-size: var(--fs-sm);
  transition: background var(--tr-fast);
}
.ep-task-result:hover { background: var(--c-surface-hover); }

/* Inline create */
.ep-inline-create {
  display: flex;
  gap: var(--sp-xs);
  align-items: center;
}
.ep-inline-create .input { flex: 1; }

.ep-inline-create-btn {
  width: 100%;
}

/* View mode */
.ep-view {
  display: flex;
  flex-direction: column;
  gap: var(--sp-sm);
}

.ep-view-color {
  height: 4px;
  border-radius: 2px;
}

.ep-view-title {
  font-size: var(--fs-lg);
  font-weight: var(--fw-bold);
}

.ep-view-field {
  font-size: var(--fs-sm);
  color: var(--c-text-secondary);
}

.ep-view-desc {
  padding: var(--sp-sm);
  background: var(--c-surface);
  border-radius: var(--r-md);
  white-space: pre-wrap;
}

.ep-view-meta {
  display: flex;
  gap: var(--sp-sm);
  flex-wrap: wrap;
}

/* ═══════════════════════════════════════════
   RBAC Matrix — Access Control Grid
   ═══════════════════════════════════════════ */
.rbac-matrix {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--c-border);
  border-radius: var(--r-md);
  overflow: hidden;
  margin-bottom: var(--sp-md);
}
.rbac-header,
.rbac-row {
  display: grid;
  grid-template-columns: 1fr 60px 60px 60px;
  align-items: center;
}
.rbac-header {
  background: var(--c-surface);
  font-size: var(--fs-xs);
  font-weight: var(--fw-semibold);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--c-border);
}
.rbac-header > div {
  padding: var(--sp-xs) var(--sp-sm);
}
.rbac-row {
  border-bottom: 1px solid var(--c-border-light, rgba(255,255,255,0.06));
}
.rbac-row:last-child { border-bottom: none; }
.rbac-row:hover { background: var(--c-surface); }
.rbac-label {
  padding: var(--sp-xs) var(--sp-sm);
  font-size: var(--fs-sm);
}
.rbac-role-header {
  text-align: center;
}
.rbac-cell {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--sp-xs) 0;
}
.rbac-check {
  width: 20px;
  height: 20px;
  accent-color: var(--c-primary);
  cursor: pointer;
}
.rbac-check:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.rbac-field-group {
  margin-bottom: var(--sp-xs);
}
.rbac-field-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: var(--sp-sm);
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--r-md);
  color: var(--c-text);
  font-size: var(--fs-sm);
  font-weight: var(--fw-semibold);
  cursor: pointer;
  touch-action: manipulation;
}
.rbac-field-toggle:hover { background: var(--c-surface-hover, var(--c-surface)); }

/* ═══════════════════════════════════════════
   File Upload Component
   ═══════════════════════════════════════════ */
.file-upload {
  margin-top: var(--sp-sm);
}
.file-upload.compact {
  margin-top: var(--sp-xs);
}
.file-upload-actions {
  display: flex;
  gap: var(--sp-sm);
  align-items: center;
  flex-wrap: wrap;
}
.file-upload-hint {
  display: flex;
  align-items: center;
  gap: var(--sp-sm);
}
.file-upload-list {
  margin-top: var(--sp-sm);
  border: 1px solid var(--c-border);
  border-radius: var(--r-md);
  max-height: 200px;
  overflow-y: auto;
}
.file-upload-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--sp-xs) var(--sp-sm);
  border-bottom: 1px solid var(--c-border-light, rgba(255,255,255,0.06));
  font-size: var(--fs-sm);
}
.file-upload-item:last-child { border-bottom: none; }
.file-upload-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
  min-width: 0;
}
.file-upload-size {
  color: var(--c-text-muted);
  font-size: var(--fs-xs);
  flex-shrink: 0;
  margin-left: var(--sp-sm);
}
