:root {
  --bg: #f6f7f4;
  --panel: #ffffff;
  --ink: #17211d;
  --muted: #66716c;
  --line: #dde3dd;
  --brand: #155e4d;
  --brand-2: #f7c948;
  --danger: #b42318;
  --ok: #147a4d;
  --shadow: 0 12px 34px rgba(21, 94, 77, .11);
}

* { box-sizing: border-box; }
html, body { max-width: 100%; overflow-x: hidden; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.45;
}
a { color: inherit; text-decoration: none; }
.app-shell { min-height: 100vh; }
.topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 80;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px clamp(16px, 4vw, 36px);
  background: rgba(246, 247, 244, .92);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(14px);
}
.app-shell {
  padding-top: 74px;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; }
.brand img { width: 34px; height: 34px; }
.nav { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.nav a, .button, button {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font: inherit;
  font-weight: 700;
  padding: 9px 13px;
}
.button.primary, button.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.button.warn { background: #fff6d6; border-color: #efd376; }
.button.danger { color: var(--danger); }
.container { width: min(1180px, 100%); max-width: 100%; margin: 0 auto; padding: 22px clamp(14px, 4vw, 36px) 52px; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.form-action-bar {
  position: sticky;
  top: 72px;
  z-index: 70;
  align-items: center;
  padding: 12px 0;
  background: rgba(246, 247, 244, .94);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
h1 { margin: 0; font-size: clamp(26px, 4vw, 42px); letter-spacing: 0; }
h2 { margin: 0 0 14px; font-size: 20px; }
h3 { margin: 0 0 10px; font-size: 16px; }
.muted { color: var(--muted); }
.grid { display: grid; gap: 14px; }
.stats { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.stat, .panel, .card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}
.stat { padding: 16px; }
.stat-link { display: block; }
.stat strong { display: block; font-size: 28px; }
.panel { padding: 18px; margin-bottom: 16px; }
.cards { display: grid; gap: 12px; }
.appointment {
  display: grid;
  grid-template-columns: 120px 1fr auto;
  gap: 14px;
  align-items: center;
  padding: 14px;
}
.date-badge { background: #edf5f1; border-radius: 8px; padding: 10px; text-align: center; font-weight: 800; }
.date-badge span { display: block; color: var(--muted); font-size: 12px; font-weight: 700; }
.pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 4px 9px;
  border-radius: 999px;
  background: #eef2ee;
  color: #31413a;
  font-size: 13px;
  font-weight: 800;
}
.pill.ok { background: #dff4e9; color: var(--ok); }
.pill.warn { background: #fff1c2; color: #795400; }
.form-grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 12px; }
.field { grid-column: span 4; display: flex; flex-direction: column; gap: 6px; }
.field.wide { grid-column: span 12; }
.field.half { grid-column: span 6; }
label { color: #37433e; font-size: 13px; font-weight: 800; }
input, select, textarea {
  max-width: 100%;
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  padding: 10px 12px;
}
textarea { min-height: 90px; resize: vertical; }
input[type="checkbox"] { width: 20px; min-height: 20px; }
.check-row { flex-direction: row; align-items: center; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 16px; }
.login {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.login-card { width: min(430px, 100%); padding: 24px; }
.alert { padding: 12px 14px; border-radius: 8px; margin-bottom: 14px; background: #fff1f0; color: var(--danger); border: 1px solid #ffd2ce; }
.search-box { position: relative; }
.search-results {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  z-index: 30;
  max-height: 300px;
  max-width: 100%;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
}
.search-result {
  width: 100%;
  border: 0;
  border-radius: 0;
  justify-content: flex-start;
  min-height: 56px;
  border-bottom: 1px solid var(--line);
}
.section-title { border-top: 1px solid var(--line); padding-top: 18px; margin-top: 18px; }
.empty { padding: 24px; text-align: center; color: var(--muted); }
.price-panel {
  margin-top: 18px;
  background: #f9fbf8;
  box-shadow: none;
}
.price-lines {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px 14px;
}
.price-lines span {
  color: var(--muted);
}
.price-lines strong {
  text-align: right;
}
.quick-layout {
  display: grid;
  grid-template-columns: minmax(360px, .8fr) minmax(0, 1.2fr);
  gap: 16px;
  align-items: start;
}
.quick-layout > * { min-width: 0; }
.planning-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}
.date-jump {
  display: flex;
  gap: 8px;
}
.date-jump input {
  min-width: 150px;
}
.day-switch {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 14px;
}
.timeline {
  display: grid;
  gap: 10px;
}
.timeline-item {
  display: grid;
  grid-template-columns: 76px 1fr;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfa;
}
.timeline-time {
  align-self: start;
  padding: 8px 6px;
  border-radius: 8px;
  background: #edf5f1;
  color: var(--brand);
  font-weight: 900;
  text-align: center;
}
.actions.compact {
  margin-top: 8px;
}
.week-panel {
  margin-top: 16px;
}
.week-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}
.calendar-scroll {
  overflow-x: auto;
  padding-bottom: 8px;
  -webkit-overflow-scrolling: touch;
}
.mobile-week-list {
  display: none;
}
.week-grid {
  position: relative;
  display: grid;
  grid-template-columns: 68px repeat(7, minmax(138px, 1fr));
  grid-template-rows: 46px repeat(29, 48px);
  min-width: 1060px;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
}
.calendar-corner,
.day-head,
.time-label,
.calendar-cell {
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}
.calendar-corner {
  position: sticky;
  left: 0;
  z-index: 6;
  grid-column: 1;
  grid-row: 1;
  background: #f6f8f5;
}
.day-head {
  z-index: 4;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: #f6f8f5;
  font-size: 13px;
}
.day-head span {
  color: var(--muted);
  font-size: 12px;
}
.time-label {
  position: sticky;
  left: 0;
  z-index: 5;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 4px;
  background: #f6f8f5;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}
.calendar-cell {
  background: linear-gradient(#fff, #fff);
}
.calendar-cell:nth-child(odd) {
  background: #fbfcfa;
}
.calendar-free-slot {
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 2px;
  border-radius: 6px;
  color: transparent;
  font-weight: 900;
}
.calendar-free-slot:hover {
  background: rgba(21, 94, 77, .08);
  color: var(--brand);
}
.calendar-free-slot span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: rgba(255, 255, 255, .86);
}
.calendar-event {
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: flex-start;
  gap: 3px;
  min-height: 42px;
  margin: 2px 3px;
  padding: 6px 7px;
  border: 0;
  border-radius: 6px;
  color: #101815;
  overflow: hidden;
  text-align: left;
  box-shadow: 0 3px 10px rgba(0, 0, 0, .12);
}
.calendar-event span {
  font-size: 11px;
  font-weight: 900;
}
.calendar-event strong {
  max-width: 100%;
  font-size: 12px;
  line-height: 1.2;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.event-red { background: #df2b2f; color: #fff; }
.event-red small { color: rgba(255,255,255,.82); }
.event-orange { background: #f2a33a; }
.event-amber { background: #f2a33a; }
.event-teal { background: #13d2aa; }
.event-blue { background: #55a6f2; }
.event-yellow { background: #ffe66a; }
.event-black { background: #1f2522; color: #fff; }
.event-black small { color: rgba(255,255,255,.82); }
.event-pink { background: #f0a4c7; }
.event-purple { background: #b44ed1; color: #fff; }
.event-purple small { color: rgba(255,255,255,.82); }
.event-green { background: #2fb56f; color: #fff; }
.event-green small { color: rgba(255,255,255,.82); }
.event-gray { background: #d9ded9; }
.view-switch {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}
.status-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 14px;
  margin-bottom: 14px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfa;
}
.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 800;
  min-height: 34px;
  padding: 6px 10px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: #fff;
}
.legend-item.active {
  border-color: var(--brand);
  box-shadow: inset 0 0 0 1px var(--brand);
}
.legend-item.clear {
  background: #f6f8f5;
}
.legend-dot {
  width: 14px;
  height: 14px;
  border-radius: 999px;
  flex: 0 0 14px;
  border: 1px solid rgba(0, 0, 0, .1);
}
.view-switch .active {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}
.planning-jump {
  margin-bottom: 16px;
  grid-template-columns: auto minmax(220px, 320px) auto;
  align-items: end;
}
.planning-jump label {
  margin-bottom: 6px;
}
.day-agenda {
  display: grid;
  gap: 8px;
}
.day-slot,
.mobile-slot {
  display: grid;
  grid-template-columns: 74px 1fr;
  gap: 10px;
  align-items: stretch;
}
.day-slot-time {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  border-radius: 8px;
  background: #edf5f1;
  color: var(--brand);
  font-weight: 900;
}
.day-slot-content,
.mobile-slot-body {
  min-width: 0;
}
.free-line {
  display: flex;
  align-items: center;
  min-height: 42px;
  padding: 8px 10px;
  border: 1px dashed #b7c5bc;
  border-radius: 8px;
  color: var(--muted);
  background: #fbfcfa;
  font-weight: 800;
}
.month-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 8px;
}
.month-weekday {
  padding: 8px 6px;
  border-radius: 8px;
  background: #edf5f1;
  color: var(--brand);
  font-size: 12px;
  font-weight: 900;
  text-align: center;
}
.month-day {
  min-width: 0;
  min-height: 142px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfa;
}
.month-day-empty {
  background: transparent;
  border-color: transparent;
}
.month-day .mobile-day-head {
  margin-bottom: 6px;
}
.month-day .mobile-day-head h3 {
  font-size: 14px;
}
.month-day .mobile-day-head .button {
  width: 34px;
  min-height: 34px;
  padding: 0;
  font-size: 16px;
}
.month-event {
  width: 100%;
  min-width: 0;
  min-height: 30px;
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr);
  gap: 6px;
  align-items: center;
  margin: 5px 0;
  padding: 6px 7px;
  border: 0;
  border-radius: 6px;
  color: #101815;
  text-align: left;
  box-shadow: none;
}
.month-event span,
.month-event strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.month-event span {
  font-size: 11px;
  font-weight: 900;
}
.month-event strong {
  font-size: 12px;
  font-weight: 900;
}
.month-event.event-red,
.month-event.event-black,
.month-event.event-purple,
.month-event.event-green {
  color: #fff;
}
.month-more {
  display: block;
  margin-top: 6px;
  color: var(--brand);
  font-size: 12px;
  font-weight: 900;
}
.call-date-jump {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 10px;
  align-items: end;
}
.mobile-day-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}
.mobile-day-head h3 {
  margin: 0;
}
.mobile-day-head .button {
  min-height: 36px;
  padding: 7px 10px;
}
.mobile-event {
  width: 100%;
  min-height: 48px;
  display: grid;
  grid-template-columns: 62px 1fr;
  gap: 0 10px;
  align-items: center;
  justify-content: stretch;
  margin: 8px 0;
  padding: 9px 10px;
  border: 0;
  border-radius: 8px;
  text-align: left;
  box-shadow: 0 3px 10px rgba(0,0,0,.12);
}
.mobile-event span {
  font-weight: 900;
}
.mobile-event strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.quick-slots {
  margin-top: 14px;
  box-shadow: none;
}
.quick-slots-head {
  margin-bottom: 10px;
}
.slot-chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.slot-chip {
  min-height: 38px;
  padding: 7px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--ink);
  font-size: 13px;
  font-weight: 900;
}
.slot-chip.active {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}
.recurring-builder {
  margin-top: 14px;
}
.recurring-list {
  display: grid;
  gap: 10px;
  margin-bottom: 10px;
}
.recurring-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
}
.recurring-slot-hint {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 2px 0 4px;
}
.recurring-slot-hint .empty,
.recurring-slot-hint .muted {
  width: 100%;
}
.related-cards {
  margin-top: 10px;
}
.related-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 12px 14px;
}
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 18px;
  background: rgba(15, 24, 20, .42);
}
.modal-backdrop.open {
  display: flex;
}
.rdv-modal {
  width: min(460px, 100%);
  max-height: 88vh;
  overflow: auto;
  padding: 18px;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 24px 80px rgba(0, 0, 0, .28);
}
.rdv-modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}
.rdv-modal-head h2 {
  margin: 0;
}
.rdv-modal .actions form {
  display: inline-flex;
}
.modal-close {
  width: 38px;
  min-height: 38px;
  padding: 0;
  font-size: 22px;
}
.rdv-summary {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 8px 12px;
  margin-bottom: 16px;
}
.rdv-summary span {
  color: var(--muted);
  font-weight: 800;
}
.rdv-summary strong {
  font-weight: 800;
  overflow-wrap: anywhere;
}

@media (max-width: 820px) {
  body { overflow-x: hidden; }
  .app-shell { padding-top: 188px; }
  .container { padding: 14px 10px 36px; }
  .panel { padding: 12px; }
  .topbar { align-items: flex-start; flex-direction: column; }
  .brand span { overflow-wrap: anywhere; }
  .nav { width: 100%; display: grid; grid-template-columns: repeat(2, 1fr); }
  .nav a, .nav button { width: 100%; min-width: 0; padding-left: 8px; padding-right: 8px; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .appointment { grid-template-columns: 1fr; }
  .field, .field.half { grid-column: span 12; }
  .page-head { flex-direction: column; }
  .form-action-bar {
    position: sticky;
    top: 132px;
    padding: 10px 0;
  }
  .page-head .actions { width: 100%; }
  .page-head .actions a { width: 100%; }
  .quick-layout { grid-template-columns: 1fr; }
  .planning-head { flex-direction: column; }
  .planning-jump { grid-template-columns: 1fr; }
  .week-nav { width: 100%; display: grid; grid-template-columns: 1fr; }
  .week-nav .button { width: 100%; }
  .date-jump { width: 100%; }
  .date-jump input, .date-jump button { width: 100%; }
  .day-switch { grid-template-columns: 1fr; }
  .call-date-jump { grid-template-columns: 1fr; }
  .calendar-scroll { display: none; }
  .mobile-week-list {
    display: grid;
    gap: 12px;
  }
  .mobile-day {
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 10px;
    background: #fbfcfa;
  }
  .mobile-slot {
    grid-template-columns: 58px 1fr;
    gap: 8px;
    padding: 6px 0;
    border-top: 1px solid var(--line);
  }
  .day-slot-time {
    min-height: 40px;
    font-size: 13px;
  }
  .mobile-day h3 {
    margin-bottom: 8px;
  }
  .mobile-day-head h3 {
    margin: 0;
  }
  .rdv-summary { grid-template-columns: 1fr; }
  .month-grid { grid-template-columns: 1fr; }
  .month-weekday, .month-day-empty { display: none; }
  .month-day { min-height: auto; }
  .recurring-row { grid-template-columns: 1fr; }
  .related-item { grid-template-columns: 1fr; }
}

@media (max-width: 460px) {
  .stats { grid-template-columns: 1fr; }
  .actions .button, .actions button { width: 100%; }
  .nav { grid-template-columns: 1fr; }
  h1 { font-size: 28px; }
}
