/*
 * Dark theme styling
 */

:root {
  --bg-color: #0b1810;
  --sidebar-color: #111f16;
  --text-color: #dde8e2;
  --primary-color: #267a50;
  --primary-hover-color: #1f6341;
  --border-color: #1c2c20;
  --card-bg: #0f1c13;
  --primary-focus-ring: rgba(38, 122, 80, 0.25);
  --primary-focus-shadow: rgba(38, 122, 80, 0.35);
  --primary-focus-border: rgba(38, 122, 80, 0.4);
  --primary-focus-strong: rgba(38, 122, 80, 0.6);
  --primary-focus-outline: rgba(38, 122, 80, 0.75);
}

:root[data-theme='dark-blue'] {
  --bg-color: #121212;
  --sidebar-color: #1f1f1f;
  --text-color: #e0e0e0;
  --primary-color: #0d6efd;
  --primary-hover-color: #0b5ed7;
  --border-color: #343a40;
  --card-bg: #242424;
  --primary-focus-ring: rgba(13, 110, 253, 0.25);
  --primary-focus-shadow: rgba(13, 110, 253, 0.35);
  --primary-focus-border: rgba(13, 110, 253, 0.4);
  --primary-focus-strong: rgba(13, 110, 253, 0.6);
  --primary-focus-outline: rgba(13, 110, 253, 0.75);
}

body {
  font-family: Arial, sans-serif;
  background-color: var(--bg-color);
  color: var(--text-color);
  margin: 0;
  min-height: 100vh;
}

.auth-layout {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
}

.auth-card {
  width: 100%;
  max-width: 420px;
  background-color: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 1rem;
  padding: 2.5rem 2rem;
  box-shadow: 0 1rem 2rem rgba(0, 0, 0, 0.35);
}

.auth-card h1 {
  font-size: 1.75rem;
}

.auth-card .form-control {
  background-color: var(--sidebar-color);
  color: var(--text-color);
  border-color: var(--border-color);
}

.auth-card .form-control:focus {
  background-color: var(--sidebar-color);
  color: var(--text-color);
  border-color: var(--primary-color);
  box-shadow: 0 0 0 0.25rem var(--primary-focus-ring);
}

.auth-card .form-control::placeholder {
  color: rgba(224, 224, 224, 0.6);
}

.auth-card .input-group .btn {
  color: var(--text-color);
  background-color: var(--sidebar-color);
  border-color: var(--border-color);
}

.auth-card .input-group .btn:hover,
.auth-card .input-group .btn:focus {
  color: var(--text-color);
  background-color: var(--border-color);
}

.auth-card .btn-primary {
  width: 100%;
}

.auth-footer {
  font-size: 0.85rem;
  color: #b5b5b5;
}

.auth-card .auth-warning {
  font-size: 0.8rem;
  color: #ffc107;
}

.not-found {
  max-width: 480px;
  margin: 10vh auto;
  padding: 2rem;
  text-align: center;
  background: rgba(255, 255, 255, 0.9);
  border-radius: 12px;
  box-shadow: 0 1rem 2rem rgba(0, 0, 0, 0.2);
}

.not-found h1 {
  margin-bottom: 1rem;
}

.not-found a {
  color: inherit;
  font-weight: 600;
}

.legal-card {
  max-width: 900px;
  margin: 3rem auto;
  background-color: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 1rem;
  padding: 2rem;
  color: var(--text-color);
  box-shadow: 0 1rem 2rem rgba(0, 0, 0, 0.35);
}

.legal-card h2 {
  font-size: 1.35rem;
  margin-top: 2rem;
}

.legal-card h3 {
  font-size: 1.1rem;
  margin-top: 1.5rem;
}

.legal-card ul {
  padding-left: 1.25rem;
}

.legal-card ul.index {
  list-style: none;
  padding-left: 0;
}

.legal-card ul.index li {
  margin-bottom: 0.25rem;
}

.legal-card .seal {
  margin-top: 2rem;
  font-size: 0.85rem;
}

.app-container {
  min-height: 100vh;
  height: 100vh;
  display: flex;
  flex-direction: column;
}

.app-header {
  background-color: var(--sidebar-color);
  border-bottom: 1px solid var(--border-color);
}

#user-controls {
  gap: 0.75rem;
}

#user-controls .dropdown-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--text-color);
  border-color: var(--border-color);
  background-color: transparent;
}

#user-controls .dropdown-toggle:hover,
#user-controls .dropdown-toggle:focus {
  color: var(--text-color);
  background-color: var(--sidebar-color);
  border-color: var(--primary-color);
}

.user-menu-label {
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-color);
  opacity: 0.7;
}

.dropdown-menu {
  background-color: var(--card-bg);
  color: var(--text-color);
  border-color: var(--border-color);
}

.dropdown-menu .text-muted,
.dropdown-menu .text-secondary,
.dropdown-menu .form-text,
.dropdown-menu small.text-muted {
  color: color-mix(in srgb, var(--text-color) 72%, transparent) !important;
}

.dropdown-menu a {
  color: #6eda9f;
}

.dropdown-menu a:hover,
.dropdown-menu a:focus {
  color: #a3e9c2;
}

.dropdown-menu .dropdown-divider {
  border-color: var(--border-color);
}

.dropdown-menu .dropdown-item {
  color: var(--text-color);
}

.dropdown-menu .dropdown-item:hover,
.dropdown-menu .dropdown-item:focus {
  background-color: var(--sidebar-color);
  color: var(--text-color);
}

.dropdown-menu .dropdown-item.text-danger:hover,
.dropdown-menu .dropdown-item.text-danger:focus {
  background-color: rgba(220, 53, 69, 0.2);
  color: #ffb3b8;
}

.user-settings-menu {
  min-width: 260px;
  max-height: 85vh;
  overflow-y: auto;
}

.settings-section-toggle {
  border: 0;
  background: transparent;
  cursor: pointer;
  letter-spacing: 0.04em;
  text-align: left;
  gap: 0.5rem;
}

.settings-section-toggle:hover .settings-section-chevron,
.settings-section-toggle:focus-visible {
  color: var(--text-color);
}

.settings-section-toggle:focus-visible {
  outline: 2px solid #6eda9f;
  outline-offset: 2px;
  border-radius: 4px;
}

.settings-section-chevron {
  transition: transform 0.15s ease-in-out;
}

.settings-section-toggle[aria-expanded='true'] .settings-section-chevron {
  transform: rotate(180deg);
}

.user-settings-menu .form-label {
  color: var(--text-color);
}

.user-settings-menu .form-select {
  background-color: var(--sidebar-color);
  color: var(--text-color);
  border-color: var(--border-color);
}

.sidebar-toggle-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 2.5rem;
  padding: 0.25rem;
}

.sidebar-toggle-icon {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
  width: 100%;
  height: 100%;
}

.sidebar-toggle-icon span {
  display: block;
  width: 1.25rem;
  height: 2px;
  background-color: var(--text-color);
  border-radius: 999px;
}

.sidebar-toggle-button:focus-visible .sidebar-toggle-icon span,
.sidebar-toggle-button:hover .sidebar-toggle-icon span {
  background-color: #fff;
}

.app-body {
  flex-grow: 1;
  min-height: 0;
  overflow: hidden;
}

#sidebar {
  min-height: 100%;
  width: 260px;
  flex: 0 0 260px;
  flex-basis: 260px;
  background-color: var(--sidebar-color);
  border-right: 1px solid var(--border-color);
  transition: width 0.3s ease, flex-basis 0.3s ease, padding 0.3s ease, border-right-color 0.3s ease;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#sidebar .sidebar-content {
  transition: opacity 0.3s ease;
}

#sidebar.collapsed {
  width: 0;
  flex: 0 0 0;
  flex-basis: 0;
  padding: 0 !important;
  border-right-color: transparent;
  overflow: hidden;
}

#sidebar.collapsed .sidebar-content {
  opacity: 0;
  pointer-events: none;
}

#sidebar.collapsed .sidebar-content > * {
  visibility: hidden;
}

#sidebar:not(.collapsed) .sidebar-content {
  opacity: 1;
}

.sidebar-top {
  flex: 0 0 auto;
}

.sidebar-categories {
  flex: 1 1 auto;
  min-height: 0;
}

.sidebar-footer {
  flex: 0 0 auto;
  border-top: 1px solid var(--border-color);
}

.sidebar-footer .btn-group-vertical {
  gap: 0.5rem;
}

.sidebar-view-btn {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  justify-content: flex-start;
  width: 100%;
  border-color: rgba(255, 255, 255, 0.15);
  color: var(--text-color);
}

.sidebar-view-btn .sidebar-view-icon {
  width: 1.5rem;
  display: inline-flex;
  justify-content: center;
}

.sidebar-view-btn.active,
.sidebar-view-btn:hover,
.sidebar-view-btn:focus {
  color: #fff;
  border-color: var(--primary-color);
}

.sidebar-view-btn.active {
  background-color: var(--primary-color);
}

.category-input-group {
  flex-wrap: wrap;
}

.category-color-picker {
  width: 3rem;
  height: 2.5rem;
  border: 1px solid var(--border-color);
  border-radius: 0.5rem;
  background-color: var(--card-bg);
  padding: 0;
  cursor: pointer;
}

.category-item .category-color-picker {
  width: 2.5rem;
  height: 2.25rem;
}

.category-color-picker::-webkit-color-swatch {
  border-radius: 0.4rem;
  border: none;
}

.category-color-picker::-moz-color-swatch {
  border-radius: 0.4rem;
  border: none;
}

#add-sheet {
  width: 60px;
  height: 60px;
  font-size: 2rem;
  line-height: 1;
}

#bulk-bin-fab {
  width: 60px;
  height: 60px;
  font-size: 1.6rem;
  line-height: 1;
  z-index: 1030;
}

/* When the + (add-sheet) button is visible, sit just to its left. */
#bulk-bin-fab.bin-fab-beside-add {
  margin-right: calc(1.5rem + 76px) !important;
}

.sheet-summary {
  font-weight: bold;
}

.current-slot-banner {
  position: relative;
  display: flex;
  align-items: center;
  gap: 1.25rem;
  padding: 1.25rem 1.5rem;
  margin-bottom: 1.5rem;
  border: 2px solid var(--primary-focus-border);
  border-radius: 1rem;
  background: linear-gradient(135deg, rgba(38, 122, 80, 0.28), rgba(38, 122, 80, 0.06));
  box-shadow: 0 18px 36px rgba(0, 0, 0, 0.35);
  overflow: hidden;
}

:root[data-theme='dark-blue'] .current-slot-banner {
  background: linear-gradient(135deg, rgba(13, 110, 253, 0.28), rgba(13, 110, 253, 0.08));
  border-color: rgba(13, 110, 253, 0.6);
  box-shadow: 0 20px 40px rgba(13, 110, 253, 0.25);
}

.current-slot-banner::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at top left, rgba(255, 255, 255, 0.12), transparent 60%);
  pointer-events: none;
}

.current-slot-info {
  z-index: 1;
  flex: 1 1 auto;
}

.current-slot-heading {
  font-size: 0.75rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  opacity: 0.8;
  margin-bottom: 0.35rem;
}

.current-slot-details {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  font-size: 1rem;
  font-weight: 600;
}

.current-slot-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 3.5rem;
  padding: 0.35rem 1.1rem;
  border-radius: 999px;
  background: var(--pill-color, var(--primary-color));
  color: var(--pill-text-color, #ffffff);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.35);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.current-slot-desc {
  font-weight: 500;
  opacity: 0.9;
}

.current-slot-time {
  font-size: 1.1rem;
  font-weight: 700;
  color: #ffffff;
  text-shadow: 0 0 12px rgba(0, 0, 0, 0.35);
}

.alarm-toggle {
  position: relative;
  z-index: 1;
  border-color: rgba(255, 255, 255, 0.35);
  color: var(--text-color);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding-inline: 1.35rem;
  padding-block: 0.6rem;
  transition: transform 0.18s ease, box-shadow 0.18s ease, background-color 0.18s ease;
}

.alarm-toggle:hover,
.alarm-toggle:focus {
  transform: translateY(-1px);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.3);
}

.alarm-toggle.alarm-active {
  background-color: var(--primary-color);
  border-color: var(--primary-focus-border);
  color: #ffffff;
  box-shadow: 0 12px 26px rgba(38, 122, 80, 0.35);
}

:root[data-theme='dark-blue'] .alarm-toggle.alarm-active {
  box-shadow: 0 12px 26px rgba(13, 110, 253, 0.35);
}

@media (max-width: 576px) {
  .current-slot-banner {
    flex-direction: column;
    align-items: stretch;
    text-align: left;
  }

  .current-slot-details {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.6rem;
  }

  .alarm-toggle {
    width: 100%;
  }
}

/* --- Live Tracking --- */

.live-tracking-active {
  transition: border-color 0.3s ease;
}

.live-tracking-over {
  border-color: rgba(220, 53, 69, 0.7) !important;
  background: linear-gradient(135deg, rgba(220, 53, 69, 0.28), rgba(220, 53, 69, 0.06)) !important;
}

.live-tracking-paused {
  border-color: rgba(255, 193, 7, 0.6) !important;
  background: linear-gradient(135deg, rgba(255, 193, 7, 0.18), rgba(255, 193, 7, 0.04)) !important;
}

.live-tracking-over-heading {
  color: #f8d7da;
}

.live-tracking-paused-heading {
  color: #ffc107;
}

.live-tracking-timer {
  font-size: 1.3rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: #ffffff;
  text-shadow: 0 0 12px rgba(0, 0, 0, 0.35);
  white-space: nowrap;
}

.live-tracking-timer-over {
  color: #f8d7da;
}

.live-tracking-timer-paused {
  opacity: 0.7;
}

.live-tracking-deviation {
  display: inline-block;
  font-size: 0.8rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 10px;
  margin-left: 8px;
  vertical-align: middle;
  letter-spacing: 0.3px;
}

.live-tracking-deviation-late {
  background: rgba(239, 68, 68, 0.2);
  color: #fca5a5;
}

.live-tracking-deviation-early {
  background: rgba(34, 197, 94, 0.2);
  color: #86efac;
}

.live-tracking-progress-wrap {
  width: 100%;
  height: 4px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.15);
  overflow: hidden;
  margin-top: 0.25rem;
}

.live-tracking-progress-bar {
  height: 100%;
  border-radius: 2px;
  background: var(--primary-color);
  transition: width 1s linear;
}

.live-tracking-progress-over {
  background: #dc3545;
}

.live-tracking-progress-paused {
  background: #ffc107;
}

/* Slot duration adjuster (+/- buttons) */
.live-tracking-duration-adjuster {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  margin-top: 0.4rem;
}

.live-tracking-adj-btn {
  padding: 0.1rem 0.55rem;
  font-size: 1rem;
  line-height: 1;
  border-radius: 50%;
  min-width: 28px;
  min-height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.live-tracking-adj-label {
  font-size: 0.85rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  min-width: 3.5rem;
  text-align: center;
  opacity: 0.85;
}

.live-tracking-actions-area {
  display: flex;
  align-items: center;
  z-index: 1;
  flex-shrink: 0;
}

.live-tracking-actions {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-wrap: wrap;
}

.live-tracking-stop-btn {
  border-color: rgba(220, 53, 69, 0.5) !important;
  color: #f8d7da !important;
}

.live-tracking-stop-btn:hover,
.live-tracking-stop-btn:focus {
  background-color: rgba(220, 53, 69, 0.25);
  border-color: rgba(220, 53, 69, 0.7) !important;
}

/* Trim suggestion bar */
.live-trim-suggestion {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1.25rem;
  margin-bottom: 1rem;
  border: 1px solid rgba(255, 193, 7, 0.4);
  border-radius: 0.75rem;
  background: linear-gradient(135deg, rgba(255, 193, 7, 0.18), rgba(255, 193, 7, 0.04));
  font-size: 0.9rem;
  flex-wrap: wrap;
}

.live-trim-label {
  font-weight: 600;
  color: #ffc107;
}

.live-trim-amount-label {
  opacity: 0.8;
}

.live-trim-value {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  min-width: 3.5rem;
  text-align: center;
}

.live-trim-btn {
  padding: 0.15rem 0.5rem;
  font-size: 1rem;
  line-height: 1;
}

.live-trim-apply {
  font-weight: 600;
}

.live-trim-dismiss {
  font-size: 0.8rem;
}

/* Plan slot live tracking states */
.live-slot-completed {
  opacity: 0.55;
}

.live-slot-active {
  box-shadow: 0 0 0 2px var(--primary-color), 0 4px 16px rgba(0, 0, 0, 0.3);
  z-index: 2;
}

.live-slot-future {
  border-style: dashed !important;
  opacity: 0.75;
}

.live-time-adjusted {
  font-style: italic;
  opacity: 0.7;
}

.live-slot-delta {
  font-size: 0.75rem;
  margin-left: 0.35rem;
}

.live-slot-delta-over {
  color: #f8d7da;
}

.live-slot-delta-under {
  color: #a3cfbb;
}

/* Pause blocks in the plan calendar */
.plan-pause-block {
  background: repeating-linear-gradient(
    -45deg,
    rgba(255, 193, 7, 0.12),
    rgba(255, 193, 7, 0.12) 4px,
    transparent 4px,
    transparent 8px
  ) !important;
  border-color: rgba(255, 193, 7, 0.4) !important;
  border-style: dashed !important;
  color: rgba(255, 193, 7, 0.8) !important;
  z-index: 3;
  pointer-events: none;
  font-size: 0.75rem;
  opacity: 0.85;
}

@media (max-width: 576px) {
  .live-tracking-actions-area {
    width: 100%;
  }
  .live-tracking-actions {
    width: 100%;
    justify-content: stretch;
  }
  .live-tracking-actions .alarm-toggle {
    flex: 1;
  }
  .live-trim-suggestion {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
  }
}

.sheet-summary-status {
  display: inline-flex;
  align-items: center;
  margin-right: 0.5rem;
}

.sheet-summary-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  line-height: 1;
}

.sheet-summary-icon--match {
  color: var(--bs-success, #198754);
}

.sheet-summary-icon--mismatch {
  color: var(--bs-danger, #dc3545);
}

.sheet-card-header {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
}

.sheet-card-header .form-control {
  flex: 1 1 auto;
}

.sheet-card-header .dropdown {
  flex: 0 0 auto;
}

.sheet-actions-toggle {
  min-width: 2.25rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding-inline: 0.5rem;
}

.sheet-actions-toggle::after {
  display: none;
}

.sheet-actions-toggle .kebab-icon {
  font-size: 1.25rem;
  line-height: 1;
}

input[type="number"] {
  -webkit-appearance: auto;
  -moz-appearance: auto;
  appearance: auto;
}

/* Ensure all form controls and list items match dark theme */

.form-control,
.form-select {
  background-color: var(--card-bg);
  color: var(--text-color);
  border-color: var(--border-color);
}

.form-control:focus,
.form-select:focus {
  background-color: var(--card-bg);
  color: var(--text-color);
  border-color: var(--primary-color);
  box-shadow: 0 0 0 0.25rem var(--primary-focus-ring);
}

.form-control::placeholder {
  color: #999;
}

.input-group-text {
  background-color: var(--sidebar-color);
  color: var(--text-color);
  border-color: var(--border-color);
}

.card,
.list-group-item {
  background-color: var(--card-bg);
  color: var(--text-color);
  border-color: var(--border-color);
}

.card.sheet-card-current {
  border-color: var(--primary-color);
  box-shadow: 0 0 0 2px var(--primary-focus-shadow);
}

.modal-content {
  background-color: var(--card-bg);
  color: var(--text-color);
  border-color: var(--border-color);
}

.modal-header,
.modal-footer {
  border-color: var(--border-color);
}

.btn-close {
  filter: invert(1);
}

.category-item {
  border-left-width: 0.6rem;
  border-left-style: solid;
  gap: 1rem;
}

.category-info {
  flex: 1 1 auto;
  min-width: 0;
}

.category-item .category-color-picker {
  width: 2.5rem;
  height: 2.5rem;
  flex: 0 0 2.5rem;
}

.category-item .category-name {
  font-weight: 600;
  min-width: 0;
  white-space: normal;
  word-break: break-word;
}

.category-actions {
  gap: 0.5rem;
}

.category-actions .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
  padding: 0.375rem;
}

.btn-primary {
  background-color: var(--primary-color);
  border-color: var(--primary-color);
}

.btn-primary:hover {
  background-color: var(--primary-hover-color);
  border-color: var(--primary-hover-color);
}

.time-input {
  width: 100%;
  max-width: 12rem;
}

.time-input input {
  text-align: center;
}

.planning-calendar {
  position: relative;
  min-height: 120px;
  padding-right: 16px;
}

.plan-current-time-marker {
  position: absolute;
  left: 0;
  right: 0;
  height: 0;
  pointer-events: none;
  z-index: 5;
}

.plan-current-time-marker::after {
  content: '';
  position: absolute;
  top: 0;
  left: 80px;
  right: 16px;
  border-top: 2px dashed var(--primary-color);
  opacity: 0.85;
}

.plan-current-time-label {
  position: absolute;
  left: 0;
  transform: translateY(-50%);
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--primary-color);
  background-color: var(--card-bg);
  padding: 0.1rem 0.5rem;
  border-radius: 0.25rem;
  box-shadow: 0 0 0 1px var(--primary-focus-border);
  margin-left: 12px;
}

.plan-slot {
  position: absolute;
  left: 80px;
  right: 16px;
  background-color: var(--sidebar-color);
  cursor: move;
  overflow: hidden;
}

.plan-slot.current-plan-slot {
  z-index: 6;
  border-width: 2px;
  box-shadow: 0 0 0 3px var(--current-slot-shadow-color, var(--primary-focus-border)),
    0 14px 28px rgba(0, 0, 0, 0.45);
  animation: current-slot-glow 2.6s ease-in-out infinite alternate;
}

.plan-slot.current-plan-slot.editing {
  box-shadow: 0 0 0 3px var(--primary-focus-strong), 0 12px 24px rgba(0, 0, 0, 0.4);
  animation: none;
}

@keyframes current-slot-glow {
  from {
    box-shadow: 0 0 0 3px var(--current-slot-shadow-color, var(--primary-focus-border)),
      0 12px 24px rgba(0, 0, 0, 0.4);
  }
  to {
    box-shadow: 0 0 0 6px rgba(255, 255, 255, 0.1), 0 18px 32px rgba(0, 0, 0, 0.55);
  }
}

.plan-slot.editing {
  box-shadow: 0 0 0 2px var(--primary-focus-strong);
  cursor: default;
}

.plan-slot-insert-handle {
  position: absolute;
  left: 80px;
  right: 16px;
  height: 14px;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
  z-index: 7;
  display: flex;
  align-items: center;
  justify-content: center;
}

.plan-slot-insert-handle::before {
  content: '';
  position: absolute;
  left: 50%;
  right: 50%;
  height: 2px;
  background-color: var(--text-color);
  border-radius: 1px;
  opacity: 0;
  transition: left 0.15s ease, right 0.15s ease, opacity 0.12s ease;
  pointer-events: none;
}

.plan-slot-insert-handle::after {
  content: '+';
  position: relative;
  width: 1.1rem;
  height: 1.1rem;
  border-radius: 50%;
  border: 1px solid var(--text-color);
  background-color: var(--sidebar-color, #fff);
  color: var(--text-color);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  font-weight: 700;
  line-height: 1;
  opacity: 0;
  transition: opacity 0.12s ease;
  pointer-events: none;
  z-index: 1;
}

.planning-calendar:hover .plan-slot-insert-handle::before {
  left: 0;
  right: 0;
  opacity: 0.25;
}

.plan-slot-insert-handle:hover::before,
.plan-slot-insert-handle:focus-visible::before,
.plan-slot-insert-handle.is-active::before {
  left: 0;
  right: 0;
  opacity: 0;
}

.plan-slot-insert-handle:hover::after,
.plan-slot-insert-handle:focus-visible::after,
.plan-slot-insert-handle.is-active::after {
  opacity: 1;
}

.plan-slot-insert-handle.is-active::after {
  box-shadow: 0 0 0 2px var(--primary-focus-strong);
}

.plan-slot-insert-handle:focus-visible {
  outline: none;
}

.planning-calendar.is-dragging-slot .plan-slot-insert-handle {
  pointer-events: none;
  opacity: 0;
}

.plan-slot:focus-visible {
  outline: 2px solid var(--primary-focus-outline);
  outline-offset: 2px;
}

.plan-slot .slot-label {
  font-weight: 600;
}

.category-pill {
  display: inline-flex;
  align-items: center;
  padding: 0.1rem 0.6rem;
  border-radius: 999px;
  font-weight: 600;
  font-size: 0.85rem;
  margin-right: 0.5rem;
}

.entry-item {
  border-left-width: 0.45rem;
  border-left-style: solid;
}

.category-select,
.plan-entry-select {
  border-left-width: 0.4rem;
  border-left-style: solid;
}

.plan-entry-select option.plan-entry-option {
  padding-left: 1.6rem;
  background-repeat: no-repeat;
  background-position: 0.5rem 50%;
  background-size: 0.65rem 0.65rem;
  background-image: radial-gradient(circle, var(--option-color, transparent) 60%, transparent 61%);
}

.plan-slot .slot-start,
.plan-slot .slot-end {
  position: absolute;
  font-size: 0.75rem;
}

.plan-slot .slot-start {
  top: 2px;
  left: 4px;
}

.plan-slot .slot-end {
  bottom: 2px;
  right: 4px;
}

.plan-slot .slot-label {
  text-align: center;
  font-size: 0.85rem;
}

.plan-slot.compact-slot .slot-label {
  display: none;
}

.plan-slot-overbooked::before {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-image: repeating-linear-gradient(
    135deg,
    rgba(0, 0, 0, 0.55) 0,
    rgba(0, 0, 0, 0.55) 5px,
    rgba(255, 214, 0, 0.7) 5px,
    rgba(255, 214, 0, 0.7) 10px
  );
  opacity: 0.4;
  z-index: 0;
}

.plan-slot-overbooked > * {
  position: relative;
  z-index: 1;
}

.plan-slot-overbooked-badge {
  position: absolute;
  top: 3px;
  right: 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.25rem;
  height: 1.15rem;
  padding-top: 0.25rem;
  color: #1a1a1a;
  font-size: 0.78rem;
  font-weight: 900;
  line-height: 1;
  cursor: help;
  z-index: 2;
  background-color: #ffd600;
  clip-path: polygon(50% 0%, 100% 100%, 0% 100%);
  text-shadow: 0 0 1px rgba(0, 0, 0, 0.6);
  filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.45));
}

.time-label {
  position: absolute;
  left: 0;
  width: 100%;
  font-size: 0.85rem;
  color: #bbb;
  text-align: left;
  transform: translateY(-50%);
  pointer-events: none;
  padding-left: 12px;
  font-weight: 600;
}

.time-label::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 80px;
  right: 16px;
  border-top: 2px solid var(--border-color);
  transform: translateY(-50%);
}

/* --- Pie Chart --- */
.pie-chart-wrapper {
  display: flex;
  align-items: flex-start;
  gap: 1.25rem;
  flex-wrap: wrap;
}

.pie-chart-wrapper--centered {
  flex-direction: column;
  align-items: center;
  gap: 1.25rem;
}

.pie-chart-svg-container {
  flex: 0 0 auto;
}

.pie-chart {
  display: block;
}

.pie-chart-legend {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.85rem;
}

.pie-chart-legend-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.pie-chart-legend-swatch {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 2px;
  flex-shrink: 0;
}

/* --- Statistics Modal --- */
.stats-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1060;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.stats-modal-backdrop--visible {
  opacity: 1;
}

.stats-modal-dialog {
  background-color: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 1rem;
  width: 90%;
  max-width: 520px;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: 0 1.5rem 3rem rgba(0, 0, 0, 0.45);
}

.stats-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border-color);
}

.stats-modal-title {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 700;
}

.stats-modal-body {
  padding: 1.25rem;
}

/* --- Statistics View --- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 1rem;
}

.stats-box {
  background-color: var(--sidebar-color);
  border: 1px solid var(--border-color);
  border-radius: 0.75rem;
  padding: 1rem;
  text-align: center;
}

.stats-box-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--primary-color);
}

.stats-box-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-color);
  opacity: 0.7;
  margin-top: 0.25rem;
}

/* --- Export Toast --- */
.export-toast {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%) translateY(1rem);
  background-color: var(--primary-color);
  color: #fff;
  padding: 0.75rem 1.5rem;
  border-radius: 0.5rem;
  font-weight: 600;
  font-size: 0.9rem;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
  z-index: 9999;
}

.export-toast--visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
  pointer-events: auto;
}

.undo-toast {
  position: fixed;
  bottom: 2.5rem;
  left: 50%;
  transform: translateX(-50%) translateY(1.5rem) scale(0.96);
  display: flex;
  align-items: center;
  gap: 1rem;
  min-width: 340px;
  max-width: min(92vw, 540px);
  background-color: var(--card-bg);
  border: 1px solid var(--border-color);
  border-left: 5px solid var(--primary-color);
  color: var(--text-color);
  padding: 0.9rem 0.9rem 0.9rem 1.35rem;
  border-radius: 0.7rem;
  font-size: 1.05rem;
  box-shadow: 0 14px 38px rgba(0, 0, 0, 0.6), 0 0 0 1px var(--primary-focus-border);
  opacity: 0;
  pointer-events: none;
  overflow: hidden;
  transition: opacity 0.2s ease, transform 0.25s cubic-bezier(0.2, 0.9, 0.3, 1.35);
  z-index: 9999;
}

.undo-toast--visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0) scale(1);
  pointer-events: auto;
}

.undo-toast__icon {
  font-size: 1.35rem;
  line-height: 1;
}

.undo-toast__label {
  font-weight: 600;
  flex-grow: 1;
}

.undo-toast__btn {
  border: none;
  background-color: var(--primary-color);
  color: #fff;
  font-weight: 700;
  font-size: 0.95rem;
  cursor: pointer;
  padding: 0.5rem 1.2rem;
  border-radius: 0.45rem;
  white-space: nowrap;
  transition: background-color 0.15s ease, transform 0.1s ease;
}

.undo-toast__btn:hover,
.undo-toast__btn:focus {
  background-color: var(--primary-hover-color);
}

.undo-toast__btn:active {
  transform: scale(0.96);
}

.undo-toast__progress {
  position: absolute;
  left: 0;
  bottom: 0;
  height: 4px;
  width: 100%;
  transform-origin: left center;
  background-color: var(--primary-color);
  opacity: 0.9;
}

.undo-toast--visible .undo-toast__progress {
  animation: undo-toast-progress var(--undo-duration, 7000ms) linear forwards;
}

@keyframes undo-toast-progress {
  from { transform: scaleX(1); }
  to { transform: scaleX(0); }
}

@media (prefers-reduced-motion: reduce) {
  .undo-toast {
    transition: opacity 0.2s ease;
    transform: translateX(-50%) translateY(0) scale(1);
  }

  .undo-toast--visible .undo-toast__progress {
    animation: none;
  }
}

.save-status {
  font-size: 0.75rem;
  opacity: 0;
  transition: opacity 0.3s ease;
  white-space: nowrap;
}

.save-status[data-state="saving"] {
  opacity: 0.6;
  color: var(--text-color);
}

.save-status[data-state="saved"] {
  opacity: 0.6;
  color: var(--primary-color);
}

.save-status[data-state="error"] {
  opacity: 1;
  color: #dc3545;
}
