.calendar-page {
  --ink: #24312d;
  --muted: #68736e;
  --line: #dfe6e2;
  background: #f7f9f8;
  letter-spacing: 0;
}

.calendar-page [hidden] { display: none !important; }
.calendar-page :focus-visible { outline: 3px solid #0f766e; outline-offset: 3px; }

.calendar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 18px;
  padding: 20px 28px;
  border-top: 3px solid #0f766e;
  border-bottom: 1px solid var(--line);
  background: #fff;
}
.calendar-brand, .calendar-header nav { display: flex; align-items: center; gap: 14px; }
.calendar-brand { min-width: 0; }
.calendar-brand > div { min-width: 0; }
.calendar-brand img { object-fit: contain; flex: 0 0 44px; }
.calendar-brand h1 { margin: 0 0 7px; font-size: 22px; line-height: 1.25; overflow-wrap: anywhere; }
.calendar-clock { display: flex; flex-wrap: wrap; align-items: center; gap: 7px; color: var(--muted); font-size: 12px; }
.calendar-clock svg { width: 14px; height: 14px; flex: 0 0 14px; }
.calendar-clock time { font-variant-numeric: tabular-nums; }
.calendar-timezone { border-left: 1px solid var(--line); padding-left: 8px; }
.calendar-header nav { gap: 8px; }
.calendar-header .btn { gap: 8px; min-height: 40px; border-radius: 6px; font-size: 13px; font-weight: 600; padding: 0 12px; }
.calendar-header .btn:hover { transform: none; }
.calendar-header .btn svg { width: 16px; height: 16px; flex: 0 0 16px; }

.calendar-main { padding: 20px 28px 32px; }
.calendar-controls { display: grid; grid-template-columns: minmax(180px, 1fr) 180px 180px 40px; gap: 12px; align-items: end; }
.calendar-controls label { min-width: 0; gap: 6px; font-size: 12px; font-weight: 600; color: var(--muted); }
.calendar-controls input, .calendar-controls select { min-width: 0; min-height: 40px; height: 40px; padding: 8px 11px; border-radius: 6px; font-size: 13px; font-weight: 500; }
.calendar-controls input::placeholder { color: #7b8580; font-weight: 400; }
.calendar-search-field { position: relative; display: block; }
.calendar-search-field > svg { position: absolute; left: 12px; top: 12px; width: 16px; height: 16px; pointer-events: none; }
.calendar-search-field input { padding-left: 38px; }
.icon-button { display: inline-grid; place-items: center; width: 40px; height: 40px; padding: 0; border: 1px solid var(--line); border-radius: 6px; color: var(--ink); background: #fff; flex: 0 0 40px; cursor: pointer; transition: background .15s, border-color .15s; }
.icon-button svg { width: 18px; height: 18px; }
.icon-button:hover { background: #edf5f1; border-color: #a2b7ad; }
.icon-button:disabled { opacity: .5; cursor: wait; }

.calendar-summary { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; padding: 17px 0; margin-bottom: 16px; border-bottom: 1px solid var(--line); font-size: 12px; color: var(--muted); }
.calendar-overview { display: flex; flex-wrap: wrap; align-items: center; gap: 18px; }
.calendar-total { color: var(--ink); font-size: 13px; font-weight: 600; padding-right: 18px; border-right: 1px solid #d6ded9; }
.calendar-total span { font-variant-numeric: tabular-nums; }
.calendar-legend { display: flex; flex-wrap: wrap; gap: 18px; }
.calendar-legend > span { display: inline-flex; gap: 6px; align-items: center; }
.calendar-legend > span::before { content: ''; width: 7px; height: 7px; flex: 0 0 7px; border-radius: 50%; background: #258657; }
.calendar-legend .legend-pending::before { background: #bb860c; }
.calendar-legend .legend-refused::before { background: #c95164; }
.calendar-legend b { color: var(--ink); min-width: 9px; font-variant-numeric: tabular-nums; }
.calendar-sync { display: inline-flex; align-items: center; gap: 6px; font-size: 11px; }
.calendar-sync::before { content: ''; width: 6px; height: 6px; flex: 0 0 6px; border-radius: 50%; background: #89918e; }
.calendar-sync[data-state="ready"]::before { background: #258657; }
.calendar-sync[data-state="loading"]::before { background: #bb860c; }
.calendar-sync[data-state="error"]::before { background: #c95164; }
.calendar-error { color: #982c3e; background: #fff0f2; border-left: 3px solid #c95164; padding: 14px; margin-bottom: 18px; font-size: 13px; }

#calendar {
  --fc-border-color: #e0e6e2;
  --fc-button-bg-color: #fff;
  --fc-button-text-color: #35443b;
  --fc-button-border-color: #d9e1dc;
  --fc-button-hover-bg-color: #edf4ef;
  --fc-button-hover-border-color: #b5c5ba;
  --fc-button-active-bg-color: #0f766e;
  --fc-button-active-border-color: #0f766e;
  --fc-today-bg-color: #f0f8f4;
  --fc-page-bg-color: #fff;
  --fc-neutral-bg-color: #f4f7f5;
  --fc-list-event-hover-bg-color: #f1f6f3;
}
.fc .fc-toolbar.fc-header-toolbar { gap: 16px; flex-wrap: wrap; margin-bottom: 16px; }
.fc .fc-toolbar-chunk { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; min-width: 0; }
.fc .fc-toolbar-chunk:empty { display: none; }
.fc .fc-toolbar-title { margin: 0; font-size: 23px; font-weight: 700; line-height: 1.3; text-transform: capitalize; }
.fc .fc-toolbar-chunk > :not(:first-child) { margin-left: 0; }
.fc .fc-button { min-height: 36px; padding: 6px 12px; border-radius: 5px; font-size: 12px; font-weight: 600; box-shadow: none !important; }
.fc .fc-button-primary:disabled { opacity: .5; }
.fc .fc-prev-button, .fc .fc-next-button { width: 36px; padding: 5px; }
.fc .fc-prev-button .fc-icon, .fc .fc-next-button .fc-icon { display: none; }
.fc .fc-prev-button::before, .fc .fc-next-button::before { display: inline-block; font-size: 25px; font-weight: 400; line-height: 20px; }
.fc .fc-prev-button::before { content: "\2039"; }
.fc .fc-next-button::before { content: "\203A"; }
.fc .fc-button-primary .fc-icon { font-size: 18px; }
.fc .fc-toolbar-chunk:last-child .fc-button-group { gap: 3px; padding: 3px; background: #eaf0ec; border-radius: 7px; }
.fc .fc-toolbar-chunk:last-child .fc-button { border: 0; border-radius: 5px; background: transparent; margin: 0; color: #5c6961; min-width: 52px; }
.fc .fc-toolbar-chunk:last-child .fc-button:hover { background: #dde8e1; color: var(--ink); }
.fc .fc-toolbar-chunk:last-child .fc-button.fc-button-active { background: #fff; color: #0c655d; box-shadow: 0 1px 4px #233d281a !important; }
.fc .fc-scrollgrid, .fc .fc-list { background: #fff; }
.fc .fc-col-header-cell { padding: 8px 0; background: #f1f5f2; font-size: 12px; font-weight: 600; color: #5c6d61; }
.fc .fc-col-header-cell-cushion { padding: 3px 4px; }
.fc .fc-day-sat, .fc .fc-day-sun { background: #fafbf9; }
.fc .fc-daygrid-day-top { padding: 5px 5px 0; }
.fc .fc-daygrid-day-number { display: grid; place-items: center; width: 28px; height: 28px; padding: 0; border-radius: 50%; font-size: 12px; font-weight: 600; }
.fc .fc-daygrid-day.fc-day-today { background: var(--fc-today-bg-color); }
.fc .fc-day-today .fc-daygrid-day-number { background: #0f766e; color: #fff; }
.fc .fc-daygrid-day-number:hover { background: #e3eee7; }
.fc .fc-day-today .fc-daygrid-day-number:hover { background: #095e57; }
.fc .fc-daygrid-day-frame { min-height: 88px; }
.fc .fc-daygrid-day-events { margin-bottom: 6px; }
.fc .fc-daygrid-event { white-space: normal; margin: 3px 5px; }
.fc .fc-h-event { border-radius: 4px; border-width: 0 0 0 3px; cursor: pointer; transition: filter .15s; }
.fc .fc-h-event:hover { filter: brightness(.97); }
.fc .fc-h-event .fc-event-main { color: inherit; }
.fc .calendar-event-accepted { color: #24613f; background: #edf7f0; border-color: #359363; }
.fc .calendar-event-pending { color: #7b5814; background: #fff8e7; border-color: #c69724; }
.fc .calendar-event-refused { color: #943b4d; background: #fff0f3; border-color: #d36c7d; }
.fc .calendar-event-archived { opacity: .7; filter: saturate(.7); }
.calendar-event-content { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 6px; padding: 6px 8px; min-width: 0; font-size: 11px; line-height: 1.4; text-align: left; }
.calendar-event-content > * { min-width: 0; overflow-wrap: anywhere; }
.calendar-event-topline { grid-column: 1 / -1; display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 2px 6px; }
.calendar-event-time { font-weight: 750; font-size: 12px; font-variant-numeric: tabular-nums; }
.calendar-event-status { font-weight: 600; font-size: 10px; }
.calendar-event-model { grid-column: 1 / -1; font-size: 12px; font-weight: 650; }
.calendar-event-plate { grid-column: 1 / -1; font-family: Consolas, monospace; font-size: 11px; font-weight: 600; }
.calendar-event-kind { grid-column: 1 / -1; font-size: 10px; opacity: .85; }
.calendar-event-archived-label { grid-column: 1 / -1; color: #64748b; font-size: 10px; font-weight: 700; }
.calendar-event-reason { grid-column: 1 / -1; border-top: 1px solid #edcdd3; padding-top: 3px; margin-top: 3px; font-size: 11px; }
.fc-dayGridMonth-view .calendar-event-model,
.fc-dayGridMonth-view .calendar-event-reason { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; }
.fc .fc-daygrid-more-link { display: inline-block; margin: 2px 5px 5px; padding: 3px 6px; border-radius: 4px; font-size: 11px; font-weight: 600; color: #0c655d; background: #eff5f1; }
.fc .fc-popover { border: 1px solid var(--line); border-radius: 6px; box-shadow: 0 8px 30px #233d281f; max-width: calc(100vw - 24px); }
.fc .fc-popover-header { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 10px 8px 12px; font-size: 13px; }
.fc .fc-popover-close {
  position: relative;
  display: inline-grid;
  place-items: center;
  width: 32px;
  min-width: 32px;
  height: 32px;
  margin: 0;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink);
  background: #fff;
  cursor: pointer;
  font-size: 0;
  line-height: 1;
  opacity: 1;
  appearance: none;
}
.fc .fc-popover-close:hover { border-color: #a2b7ad; background: #edf5f1; }
.fc .fc-popover-close::before, .fc .fc-popover-close::after { content: ''; position: absolute; width: 14px; height: 2px; border-radius: 2px; background: currentColor; }
.fc .fc-popover-close::before { transform: rotate(45deg); }
.fc .fc-popover-close::after { transform: rotate(-45deg); }
.fc .fc-popover-body { width: 290px; max-width: calc(100vw - 26px); max-height: 60dvh; overflow-y: auto; }
.fc .fc-popover .calendar-event-model, .fc .fc-popover .calendar-event-reason { display: block; overflow: visible; }

.fc .fc-list { border-radius: 6px; overflow: hidden; }
.fc .fc-list-day-cushion { padding: 10px 16px; font-size: 13px; font-weight: 600; color: #56665b; }
.fc .fc-list-day-text { text-transform: capitalize; }
.fc .fc-list-event { cursor: pointer; }
.fc .fc-list-event td { padding: 14px 16px; }
.fc .fc-list-event-time { font-variant-numeric: tabular-nums; font-size: 13px; font-weight: 650; }
.fc .fc-list-event-dot { border-color: currentColor; }
.fc .fc-list-event-title { font-weight: 400; }
.fc .fc-list-event .calendar-event-content { padding: 0; max-width: 900px; }
.fc .fc-list-event .calendar-event-time { display: none; }
.fc .fc-list-event .calendar-event-model { font-size: 14px; }
.fc .fc-list-event .calendar-event-status { font-size: 11px; }
.fc .fc-list-empty { background: #fff; padding: 60px 20px; color: var(--muted); font-size: 14px; }

.appointment-dialog { width: min(560px, calc(100% - 28px)); max-height: calc(100dvh - 40px); overflow: auto; padding: 26px; border: 1px solid var(--line); border-top: 4px solid #c69724; border-radius: 8px; color: var(--ink); box-shadow: 0 18px 70px #182c2733; }
.appointment-dialog::backdrop { background: #17272073; }
.appointment-dialog[data-status="accepted"] { border-top-color: #359363; }
.appointment-dialog[data-status="refused"] { border-top-color: #d36c7d; }
.appointment-heading { display: flex; align-items: start; justify-content: space-between; gap: 16px; }
.appointment-heading > div { min-width: 0; overflow-wrap: anywhere; }
.appointment-heading h2 { font-size: 24px; margin: 10px 0 8px; line-height: 1.3; }
.appointment-status { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 650; color: #7b5814; }
.appointment-status::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.appointment-dialog[data-status="accepted"] .appointment-status { color: #24613f; }
.appointment-dialog[data-status="refused"] .appointment-status { color: #943b4d; }
.appointment-plate { font-family: Consolas, monospace; font-size: 15px; color: #65746b; }
.appointment-facts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; margin: 22px 0 0; padding-top: 22px; border-top: 1px solid var(--line); }
.appointment-facts dt { color: var(--muted); font-size: 12px; margin-bottom: 6px; }
.appointment-facts dd { margin: 0; font-size: 14px; font-weight: 600; overflow-wrap: anywhere; }
.appointment-reason { border-top: 1px solid var(--line); margin-top: 22px; padding-top: 20px; }
.appointment-reason h3 { font-size: 13px; margin: 0 0 8px; }
.appointment-reason p { margin: 0; font-size: 14px; white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.6; }
.appointment-dialog[data-status="refused"] .appointment-reason h3 { color: #943b4d; }

@media (max-width: 1000px) {
  .calendar-controls { grid-template-columns: minmax(180px, 1fr) 160px 160px 40px; }
  .fc .fc-toolbar-title { font-size: 21px; }
  .fc .fc-toolbar-chunk { gap: 8px; }
  .calendar-overview { gap: 12px; }
  .calendar-total { padding-right: 12px; }
  .calendar-legend { gap: 12px; }
}
@media (max-width: 719px) {
  .calendar-header { padding: 16px; gap: 16px; }
  .calendar-brand { width: 100%; gap: 10px; }
  .calendar-brand h1 { font-size: 19px; }
  .calendar-clock { font-size: 11px; gap: 5px; }
  .calendar-clock time { flex-basis: calc(100% - 20px); }
  .calendar-timezone { border: 0; padding: 0 0 0 19px; }
  .calendar-header nav { width: 100%; }
  .calendar-header nav .btn { flex: 1; min-width: 0; }
  .calendar-main { padding: 16px 12px 24px; }
  .calendar-controls { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 40px; gap: 12px 8px; }
  .calendar-search { grid-column: 1 / -1; grid-row: 1; padding-right: 48px; }
  .calendar-controls label:nth-child(2) { grid-column: 1; grid-row: 2; }
  .calendar-controls label:nth-child(3) { grid-column: 2 / -1; grid-row: 2; }
  .calendar-controls > .icon-button { grid-row: 1; grid-column: 3; }
  .calendar-controls input, .calendar-controls select { padding-right: 6px; font-size: 16px; }
  .calendar-summary { gap: 12px; margin-bottom: 14px; padding: 16px 0; }
  .calendar-overview { width: 100%; gap: 10px; }
  .calendar-total { width: 100%; padding: 0; border: 0; }
  .calendar-legend { gap: 14px; font-size: 11px; }
  .fc .fc-toolbar { display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; }
  .fc .fc-toolbar-chunk:first-child { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; }
  .fc .fc-toolbar-title { grid-column: 1; font-size: 20px; }
  .fc .fc-toolbar-chunk:first-child .fc-button-group { grid-column: 2; grid-row: 1; }
  .fc .fc-today-button { justify-self: start; grid-column: 1 / -1; }
  .fc .fc-toolbar-chunk:last-child .fc-button-group { width: 100%; }
  .fc .fc-toolbar-chunk:last-child .fc-button { min-width: 0; flex: 1; padding: 7px 8px; }
  .fc .fc-view-harness { overflow-x: auto; overscroll-behavior-x: contain; }
  .fc .fc-button { min-height: 40px; }
  .fc .fc-daygrid .fc-scrollgrid { min-width: 680px; }
  .fc .fc-daygrid-day-frame { min-height: 76px; }
  .fc .fc-list-event td { padding: 12px 8px; }
  .fc .fc-list-event-time { white-space: normal; font-size: 12px; }
  .fc .fc-list-event-graphic { padding-left: 0; padding-right: 0; }
  .fc .fc-list-day-cushion { padding: 10px; }
  .appointment-dialog { width: calc(100% - 20px); max-height: calc(100dvh - 20px); padding: 18px; }
  .appointment-heading h2 { font-size: 21px; }
  .appointment-facts { gap: 16px; }
}
@media (max-width: 380px) {
  .calendar-brand h1 { font-size: 18px; }
  .calendar-controls { grid-template-columns: minmax(0, 1fr) 40px; }
  .calendar-controls label:nth-child(2) { grid-column: 1 / -1; grid-row: 2; }
  .calendar-controls label:nth-child(3) { grid-column: 1 / -1; grid-row: 3; }
  .calendar-controls > .icon-button { grid-column: 2; }
  .fc .fc-daygrid .fc-scrollgrid { min-width: 640px; }
  .fc .fc-daygrid-day-frame { min-height: 70px; }
  .fc .fc-toolbar-title { font-size: 18px; }
  .fc .fc-prev-button, .fc .fc-next-button { width: 40px; }
  .appointment-dialog { padding: 16px; }
  .appointment-heading h2 { font-size: 19px; }
  .appointment-facts { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) {
  .calendar-page *, .calendar-page *::before, .calendar-page *::after { transition: none !important; }
}
