:root {
  --primary: #0284c7;
  --primary-dark: #075985;
  --on-primary: #ffffff;
  --primary-container: #dcf1fc;
  --bg: #f4fafe;
  --surface: #ffffff;
  --surface-2: #e3eff7;
  --outline: #d2e2ec;
  --text: #16232d;
  --text-2: #5c6e7b;
  --green: #1e9e62;
  --green-bg: #c8f2dc;
  --red: #e5484d;
  --red-bg: #ffddde;
  --yellow: #b45309;
  --yellow-bg: #fdebc8;
  --radius: 18px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --primary: #8ccff5;
    --primary-dark: #5eb8ec;
    --on-primary: #04344e;
    --primary-container: #14506f;
    --bg: #0f1519;
    --surface: #18222a;
    --surface-2: #26343e;
    --outline: #3b4c58;
    --text: #e6eef4;
    --text-2: #a9bac6;
    --green: #6fe0a8;
    --green-bg: #14432b;
    --red: #ff8a8f;
    --red-bg: #5a1216;
    --yellow: #f5c169;
    --yellow-bg: #4a3410;
  }
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

.wrap {
  max-width: 480px;
  margin: 0 auto;
  padding: 20px 16px 40px;
}

h1 { font-size: 24px; letter-spacing: -0.02em; }
.subtitle { color: var(--text-2); font-size: 14px; margin-top: 2px; margin-bottom: 18px; }

.card {
  background: var(--surface);
  border: 1px solid var(--outline);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 14px;
}

.section-title { font-size: 15px; font-weight: 700; margin-bottom: 10px; }

label { display: block; font-size: 13px; color: var(--text-2); margin: 12px 0 4px; }
label:first-of-type { margin-top: 0; }

input[type="text"], input[type="tel"], textarea {
  width: 100%;
  padding: 12px 14px;
  font-size: 16px;
  color: var(--text);
  background: var(--surface);
  border: 1.5px solid var(--outline);
  border-radius: 12px;
  outline: none;
}
input:focus, textarea:focus { border-color: var(--primary); }
textarea { resize: vertical; min-height: 64px; }

/* Чипы процедур */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  padding: 9px 14px;
  border: 1.5px solid var(--outline);
  border-radius: 100px;
  background: var(--surface);
  color: var(--text);
  font-size: 14px;
  cursor: pointer;
}
.chip small { color: var(--text-2); }
.chip.on {
  background: var(--primary);
  border-color: var(--primary);
  color: var(--on-primary);
}
.chip.on small { color: var(--on-primary); opacity: 0.8; }

/* Календарь */
.cal-head { display: flex; align-items: center; margin-bottom: 8px; }
.cal-title { flex: 1; font-size: 17px; }
.cal-title b { font-weight: 700; }
.cal-title span { color: var(--text-2); }
.cal-nav {
  width: 38px; height: 38px;
  border: none; background: none; cursor: pointer;
  color: var(--primary); font-size: 20px; border-radius: 50%;
}
.cal-nav:active { background: var(--surface-2); }

.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.cal-dow { text-align: center; font-size: 12px; color: var(--text-2); padding: 4px 0; }
.cal-day {
  position: relative;
  height: 42px;
  border: none; background: none;
  border-radius: 12px;
  font-size: 14px; color: var(--text);
  cursor: pointer;
}
.cal-day:disabled { cursor: default; }
.cal-day.other { color: var(--outline); }
.cal-day.closed { color: var(--red); opacity: 0.45; }
.cal-day.open { background: var(--green-bg); color: var(--green); font-weight: 700; }
.cal-day.past { opacity: 0.35; background: none; }
.cal-day.sel { background: var(--primary); color: var(--on-primary); font-weight: 700; }
.legend { display: flex; gap: 16px; margin-top: 10px; font-size: 12px; color: var(--text-2); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 5px; }
.legend .g { background: var(--green); }
.legend .r { background: var(--red); }

/* Слоты времени */
.slots { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.slot {
  padding: 11px 0;
  border: 1.5px solid var(--outline);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
  font-size: 15px;
  cursor: pointer;
  text-align: center;
}
.slot.on { background: var(--primary); border-color: var(--primary); color: var(--on-primary); font-weight: 700; }
.hint { color: var(--text-2); font-size: 13px; }

/* Кнопки */
.btn {
  display: block;
  width: 100%;
  padding: 15px;
  margin-top: 6px;
  border: none;
  border-radius: 14px;
  background: var(--primary);
  color: var(--on-primary);
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
}
.btn:disabled { opacity: 0.45; }
.btn.outline {
  background: none;
  border: 1.5px solid var(--outline);
  color: var(--text);
}
.btn.danger { background: none; border: 1.5px solid var(--red); color: var(--red); }

/* Статусы */
.status-pill {
  display: inline-block;
  padding: 6px 14px;
  border-radius: 100px;
  font-size: 14px;
  font-weight: 700;
}
.st-pending { background: var(--yellow-bg); color: var(--yellow); }
.st-confirmed { background: var(--green-bg); color: var(--green); }
.st-moved { background: var(--primary-container); color: var(--primary-dark); }
.st-declined { background: var(--red-bg); color: var(--red); }
.st-done { background: var(--surface-2); color: var(--text-2); }

/* Детали записи */
.row { display: flex; justify-content: space-between; padding: 9px 0; border-bottom: 1px solid var(--outline); font-size: 15px; }
.row:last-child { border-bottom: none; }
.row .k { color: var(--text-2); }
.row .v { font-weight: 600; text-align: right; }

.note {
  background: var(--surface-2);
  border-radius: 12px;
  padding: 12px;
  font-size: 14px;
  margin-top: 12px;
}
.note.err { background: var(--red-bg); color: var(--red); }

.center { text-align: center; }
.big-icon { font-size: 52px; margin: 12px 0; }
.hidden { display: none !important; }
.err-text { color: var(--red); font-size: 13px; margin-top: 8px; }

/* Подвал с правовыми ссылками */
.legal-footer {
  margin-top: 28px;
  padding: 16px 0 8px;
  text-align: center;
  font-size: 13px;
  color: var(--text-2);
}
.legal-footer a { color: var(--text-2); text-decoration: underline; }
.legal-footer span { margin: 0 6px; }
