:root {
  --black: #050505;
  --panel: #111010;
  --panel-soft: #171414;
  --rose: #b76e79;
  --rose-strong: #d89aa5;
  --gold: #d7b46a;
  --text: #fbf7f3;
  --muted: #b9aaa4;
  --line: rgba(215, 180, 106, 0.18);
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.38);
}

* {
  box-sizing: border-box;
}

html {
  background: var(--black);
}

body {
  min-height: 100vh;
  margin: 0;
  background:
    radial-gradient(circle at 50% -10%, rgba(183, 110, 121, 0.22), transparent 34rem),
    linear-gradient(180deg, #090807 0%, #050505 58%);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", sans-serif;
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  width: min(100%, 480px);
  min-height: 100vh;
  margin: 0 auto;
  padding: max(18px, env(safe-area-inset-top)) 16px max(28px, env(safe-area-inset-bottom));
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 8px 2px 18px;
}

.eyebrow {
  margin: 0 0 3px;
  color: var(--gold);
  font-size: 12px;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: 27px;
  font-weight: 720;
  line-height: 1.05;
}

.today-pill {
  flex: 0 0 auto;
  min-width: 64px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(17, 16, 16, 0.82);
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

.main-tabs,
.view-toggle {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
}

.tab,
.view-btn {
  min-height: 38px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  font-size: 14px;
  font-weight: 650;
}

.tab.active,
.view-btn.active {
  background: linear-gradient(135deg, var(--rose), #e7b7be);
  color: #120b0c;
}

.screen {
  display: none;
  padding-top: 14px;
}

.screen.active {
  display: block;
}

.calendar-panel,
.form-panel,
.list-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(17, 16, 16, 0.86);
  box-shadow: var(--shadow);
}

.calendar-panel {
  overflow: hidden;
}

.calendar-panel.compact {
  margin-bottom: 14px;
}

.calendar-head {
  display: grid;
  grid-template-columns: 42px 1fr 42px;
  align-items: center;
  gap: 8px;
  padding: 12px;
}

.icon-btn,
.period-title {
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
}

.icon-btn {
  color: var(--gold);
  font-size: 30px;
  line-height: 1;
}

.period-title {
  color: var(--text);
  font-size: 16px;
  font-weight: 720;
}

.view-toggle {
  margin: 0 12px 12px;
}

.calendar-wrap {
  padding: 0 12px 14px;
}

.weekday-row,
.month-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 6px;
}

.weekday-row {
  margin-bottom: 7px;
  color: var(--gold);
  font-size: 11px;
  text-align: center;
  text-transform: uppercase;
}

.day-cell,
.month-card,
.week-day {
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.035);
  color: var(--text);
}

.day-cell {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 43px;
  padding: 5px 0;
}

.day-cell.muted {
  color: rgba(251, 247, 243, 0.28);
}

.day-cell.selected {
  outline: 2px solid var(--gold);
  outline-offset: -2px;
}

.day-cell.one {
  border-color: var(--rose-strong);
}

.day-cell.full {
  border-color: var(--rose);
  background: linear-gradient(135deg, rgba(183, 110, 121, 0.95), rgba(216, 154, 165, 0.9));
  color: #160c0e;
  font-weight: 800;
}

.day-count {
  position: absolute;
  right: 4px;
  bottom: 3px;
  color: var(--gold);
  font-size: 10px;
  font-weight: 800;
}

.full .day-count {
  color: #281113;
}

.year-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 9px;
}

.month-card {
  min-height: 84px;
  padding: 10px 8px;
  text-align: left;
}

.month-card strong {
  display: block;
  margin-bottom: 8px;
  font-size: 13px;
}

.month-card span {
  color: var(--muted);
  font-size: 11px;
}

.month-card.has-items {
  border-color: var(--rose);
}

.week-list {
  display: grid;
  gap: 8px;
}

.week-day {
  display: grid;
  grid-template-columns: 58px 1fr;
  align-items: center;
  gap: 10px;
  min-height: 72px;
  padding: 10px;
  text-align: left;
}

.week-date {
  color: var(--gold);
  font-weight: 800;
}

.week-day.full {
  background: linear-gradient(135deg, rgba(183, 110, 121, 0.95), rgba(216, 154, 165, 0.9));
  color: #160c0e;
}

.week-day.full .week-date,
.week-day.full .week-info {
  color: #160c0e;
}

.week-info {
  color: var(--muted);
  font-size: 13px;
}

.form-panel,
.list-panel {
  margin-top: 14px;
  padding: 14px;
}

.archive-panel {
  margin-top: 18px;
  border-color: rgba(215, 180, 106, 0.12);
  background: rgba(17, 16, 16, 0.58);
}

.selected-date {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  color: var(--muted);
}

.selected-date strong {
  color: var(--gold);
  text-align: right;
}

form {
  display: grid;
  gap: 13px;
}

label,
fieldset {
  display: grid;
  gap: 7px;
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

fieldset {
  min-width: 0;
  padding: 0;
  border: 0;
}

legend {
  margin-bottom: 7px;
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #070707;
  color: var(--text);
  padding: 12px;
  outline: none;
}

input:focus,
textarea:focus {
  border-color: var(--rose-strong);
}

.procedure-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.procedure-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.035);
  color: var(--text);
}

.procedure-chip input {
  width: 18px;
  height: 18px;
  accent-color: var(--rose);
}

.primary-btn,
.ghost-btn,
.danger-btn,
.map-btn,
.small-btn {
  min-height: 44px;
  border: 0;
  border-radius: 8px;
  font-weight: 760;
}

.primary-btn {
  background: linear-gradient(135deg, var(--gold), #f0d994);
  color: #120e05;
}

.ghost-btn,
.small-btn {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
}

.danger-btn {
  background: rgba(183, 110, 121, 0.16);
  color: #ffd8de;
  border: 1px solid rgba(216, 154, 165, 0.34);
}

.map-btn {
  display: inline-grid;
  place-items: center;
  padding: 0 12px;
  background: rgba(215, 180, 106, 0.14);
  color: #f6d98c;
  text-decoration: none;
  border: 1px solid rgba(215, 180, 106, 0.26);
}

.hidden {
  display: none !important;
}

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.section-title span {
  color: var(--text);
  font-weight: 780;
}

.section-title strong {
  display: grid;
  place-items: center;
  min-width: 30px;
  height: 30px;
  border-radius: 8px;
  background: rgba(183, 110, 121, 0.18);
  color: var(--rose-strong);
}

.appointment-list {
  display: grid;
  gap: 10px;
}

.empty-state {
  padding: 26px 12px;
  color: var(--muted);
  text-align: center;
}

.appointment-card {
  display: grid;
  grid-template-columns: 72px 1fr;
  gap: 12px;
  padding: 10px;
  border: 1px solid rgba(216, 154, 165, 0.64);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(183, 110, 121, 0.24), rgba(215, 180, 106, 0.08)),
    rgba(255, 255, 255, 0.045);
  box-shadow: 0 12px 34px rgba(183, 110, 121, 0.13);
}

.date-badge {
  display: grid;
  place-items: center;
  min-height: 72px;
  border-radius: 8px;
  background: linear-gradient(135deg, rgba(183, 110, 121, 0.92), rgba(215, 180, 106, 0.82));
  color: #130b0a;
  text-align: center;
  font-weight: 850;
}

.date-badge span {
  display: block;
}

.date-badge .date-number {
  font-size: 36px;
  line-height: 1;
}

.date-badge .date-month,
.date-badge .date-weekday {
  font-size: 11px;
  line-height: 1.15;
}

.date-badge .date-weekday {
  font-size: 9px;
  text-transform: uppercase;
}

.appointment-card.archived {
  border-color: rgba(215, 180, 106, 0.3);
  background: rgba(255, 255, 255, 0.03);
  opacity: 0.78;
}

.appointment-info {
  min-width: 0;
}

.appointment-info h3 {
  margin: 0 0 3px;
  font-size: 16px;
}

.appointment-info p {
  margin: 3px 0;
  color: var(--muted);
  font-size: 13px;
  overflow-wrap: anywhere;
}

.card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 9px;
}

.small-btn,
.danger-btn,
.map-btn {
  min-height: 36px;
  font-size: 13px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: max(18px, env(safe-area-inset-bottom));
  z-index: 30;
  width: min(calc(100% - 28px), 430px);
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(15, 12, 12, 0.96);
  color: var(--text);
  text-align: center;
  transform: translate(-50%, 120px);
  transition: transform 0.25s ease;
}

.toast.show {
  transform: translate(-50%, 0);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(0, 0, 0, 0.72);
}

.modal-box {
  width: min(100%, 360px);
  padding: 18px;
  border: 1px solid rgba(216, 154, 165, 0.58);
  border-radius: 8px;
  background: #111010;
  box-shadow: 0 20px 70px rgba(0, 0, 0, 0.56);
}

.modal-box h2 {
  margin: 0 0 6px;
  font-size: 20px;
}

.modal-box p {
  margin: 0 0 16px;
  color: var(--muted);
}

.modal-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

@media (max-width: 360px) {
  .app-shell {
    padding-left: 10px;
    padding-right: 10px;
  }

  h1 {
    font-size: 23px;
  }

  .procedure-grid,
  .year-grid {
    grid-template-columns: 1fr 1fr;
  }

  .appointment-card {
    grid-template-columns: 62px 1fr;
  }
}
