:root {
  --ink: #172033;
  --muted: #697386;
  --blue: #315fce;
  --blue-dark: #244aa7;
  --blue-pale: #edf2ff;
  --mint: #d8f5eb;
  --surface: #ffffff;
  --canvas: #f3f6fb;
  --line: #e3e8f1;
  --danger: #b62e45;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--canvas);
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; background: linear-gradient(160deg, #eef3ff 0, var(--canvas) 42%, #f6f8fb 100%); }
button, input, textarea { font: inherit; }
button { cursor: pointer; }

.app-shell { width: min(100%, 680px); min-height: 100dvh; margin: 0 auto; padding: calc(18px + env(safe-area-inset-top)) 16px calc(32px + env(safe-area-inset-bottom)); }
.topbar, .calendar-header, .section-heading, .dialog-heading, .slot-header, .admin-event-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.topbar { margin: 0 2px 20px; }
h1, h2, h3, p { margin: 0; }
h1 { font-size: clamp(1.5rem, 6vw, 2rem); letter-spacing: -0.04em; }
h2 { font-size: 1.15rem; letter-spacing: -0.025em; }
h3 { font-size: 1rem; margin: 4px 0 12px; }
.eyebrow { color: var(--blue); font-size: .69rem; font-weight: 800; letter-spacing: .1em; }
.muted, small { color: var(--muted); }
small { display: block; font-size: .76rem; line-height: 1.35; margin-top: 5px; }

.icon-button, .nav-button, .close-button { border: 0; color: var(--ink); background: transparent; }
.icon-button { display: grid; place-items: center; width: 42px; height: 42px; border-radius: 50%; background: var(--surface); box-shadow: 0 3px 12px #1b31561a; }
.icon-button svg { width: 20px; fill: currentColor; }
.nav-button { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 11px; color: var(--blue); font-size: 2rem; line-height: 1; }
.nav-button:hover { background: var(--blue-pale); }

.calendar-card, .event-card, .admin-panel, .notice { border: 1px solid #e7ebf3; background: var(--surface); box-shadow: 0 7px 22px #2032520d; }
.calendar-card { border-radius: 22px; padding: 14px 10px 10px; }
.calendar-header { padding: 0 2px 8px; }
.calendar-header h2 { text-transform: capitalize; }
.weekdays, .calendar-grid { display: grid; grid-template-columns: repeat(7, 1fr); }
.weekdays { color: var(--muted); font-size: .67rem; font-weight: 700; text-align: center; padding: 3px 0 7px; }
.calendar-day { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 48px; padding: 4px 1px; border: 1px solid transparent; border-radius: 13px; background: transparent; color: var(--ink); font-size: .81rem; }
.calendar-day:hover { background: #f0f4fe; }
.calendar-day.is-outside { color: #b8c0cb; }
.calendar-day.is-today > b { display: grid; place-items: center; width: 25px; height: 25px; border-radius: 50%; background: var(--blue); color: white; }
.calendar-day.is-selected { border-color: #b8ccff; background: var(--blue-pale); }
.event-dot { display: flex; gap: 2px; min-height: 5px; margin-top: 3px; }
.event-dot i { width: 5px; height: 5px; border-radius: 50%; background: #42aa86; }

.section-heading { margin: 27px 2px 12px; }
.count-badge { display: grid; place-items: center; min-width: 27px; height: 27px; border-radius: 14px; padding: 0 8px; color: var(--blue); background: var(--blue-pale); font-weight: 800; font-size: .77rem; }
.event-list, .admin-event-list { display: grid; gap: 10px; }
.event-card { overflow: hidden; border-radius: 18px; }
.event-card-main { padding: 16px 16px 13px; }
.event-card h3 { margin: 0 0 6px; font-size: 1.06rem; }
.event-date { color: var(--blue); font-size: .78rem; font-weight: 800; }
.event-description { margin-top: 8px; color: #506077; font-size: .87rem; line-height: 1.45; }
.slots { border-top: 1px solid var(--line); }
.slot { padding: 12px 16px; border-bottom: 1px solid var(--line); }
.slot:last-child { border-bottom: 0; }
.slot-time { display: flex; align-items: center; gap: 7px; font-size: .9rem; font-weight: 800; }
.slot-time::before { content: "◷"; color: var(--blue); font-size: 1rem; }
.booking-name { margin-top: 5px; color: #547064; font-size: .78rem; }
.slot-actions { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 9px; }
.slot-button, .text-button { min-height: 34px; padding: 7px 10px; border: 0; border-radius: 9px; color: var(--blue); background: var(--blue-pale); font-weight: 750; font-size: .76rem; }
.slot-button:hover, .text-button:hover { background: #dbe6ff; }
.slot-button.locked { color: #5c6473; background: #f0f2f5; }
.slot-button.master { color: var(--danger); background: #fff0f2; }
.empty-state { padding: 28px 16px; border: 1px dashed #ccd5e3; border-radius: 18px; text-align: center; color: var(--muted); }
.empty-state span { display: block; font-size: 2rem; color: #aebbd0; margin-bottom: 5px; }
.empty-state p { font-weight: 700; }

.notice { margin-bottom: 15px; border-radius: 15px; padding: 12px 14px; color: #614b00; background: #fff9e8; border-color: #f6e5af; font-size: .84rem; line-height: 1.45; }
.notice code { padding: 1px 4px; border-radius: 4px; background: #f6e8bb; }
.admin-panel { margin-top: 30px; padding: 17px; border-radius: 20px; }
.event-form { display: grid; gap: 13px; margin-top: 13px; }
label { display: grid; gap: 6px; color: #354057; font-size: .82rem; font-weight: 760; }
.optional { color: var(--muted); font-weight: 500; }
input, textarea, select { width: 100%; border: 1px solid #ccd5e3; border-radius: 11px; padding: 11px 12px; color: var(--ink); background: white; outline: none; }
input:focus, textarea:focus, select:focus { border-color: var(--blue); box-shadow: 0 0 0 3px #315fce20; }
textarea { resize: vertical; }
.primary-button, .danger-button { min-height: 45px; border: 0; border-radius: 12px; padding: 10px 15px; color: white; background: var(--blue); font-weight: 800; }
.primary-button:hover { background: var(--blue-dark); }
.primary-button:disabled, .danger-button:disabled { cursor: wait; opacity: .65; }
.danger-button { color: var(--danger); background: #fff0f2; }
.secondary-button { min-height: 42px; border: 1px solid #b9ccfa; border-radius: 12px; padding: 9px 14px; color: var(--blue); background: var(--blue-pale); font-weight: 800; }
.secondary-button:hover { background: #dfe9ff; }
.import-card { display: grid; gap: 11px; margin-top: 15px; padding: 14px; border: 1px solid #cbd9fb; border-radius: 16px; background: #f8faff; }
.import-card h3 { margin: -5px 0 0; }
.import-card .muted { font-size: .8rem; line-height: 1.4; }
.import-card textarea { font-size: .8rem; line-height: 1.45; }
.import-note { padding: 9px 10px; border-radius: 10px; color: #34518c; background: #edf3ff; font-size: .79rem; line-height: 1.4; }
.import-preview { padding: 12px; border: 1px solid #d8e1ee; border-radius: 12px; background: white; }
.import-preview-head { display: flex; align-items: center; justify-content: space-between; gap: 9px; margin-bottom: 8px; }
.import-preview-head strong { font-size: .84rem; }
.import-preview-list { display: grid; gap: 6px; max-height: 210px; margin: 0; padding: 0; overflow: auto; list-style: none; }
.import-preview-list li { padding: 8px; border-radius: 8px; background: #f4f7fc; color: #3f4c61; font-size: .76rem; line-height: 1.35; }
.import-warning { margin-top: 10px; color: #926c00; font-size: .76rem; line-height: 1.4; }
.import-preview .primary-button { width: 100%; margin-top: 11px; }
.masters-card { display: grid; gap: 11px; margin-top: 16px; padding: 14px; border: 1px solid #cfe9dd; border-radius: 16px; background: #f7fcf9; }
.masters-card h3 { margin: -5px 0 0; }
.masters-card .muted { font-size: .8rem; line-height: 1.4; }
.export-card { display: grid; gap: 11px; margin-top: 16px; padding: 14px; border: 1px solid #d8d1f5; border-radius: 16px; background: #faf9ff; }
.export-card h3 { margin: -5px 0 0; }
.export-card .muted { font-size: .8rem; line-height: 1.4; }
.master-form { display: grid; gap: 11px; }
.master-list { display: grid; gap: 6px; }
.master-list:not(:empty) { padding-top: 2px; }
.master-item { display: flex; align-items: center; justify-content: space-between; gap: 9px; padding: 8px 10px; border-radius: 9px; color: #3d5a50; background: #e8f6ee; font-size: .77rem; }
.master-item span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.schedule-export-text { min-height: 290px; resize: vertical; color: #334159; background: #f8fafc; font-size: .8rem; line-height: 1.45; white-space: pre-wrap; }
.admin-divider { height: 1px; margin: 23px 0 16px; background: var(--line); }
.admin-event { border: 1px solid var(--line); border-radius: 13px; padding: 12px; }
.admin-event + .admin-event { margin-top: 8px; }
.admin-event-head { align-items: flex-start; }
.admin-event-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; }
.admin-event p { color: var(--muted); font-size: .78rem; margin-top: 4px; }
.admin-event .slot-actions { margin-top: 10px; }
.admin-event .slot-button { padding: 5px 8px; }

.sheet-dialog { width: min(100%, 510px); margin: auto 0 0; max-width: none; padding: 0; border: 0; border-radius: 22px 22px 0 0; background: white; box-shadow: 0 -8px 34px #18244324; }
.sheet-dialog::backdrop { background: #13203a80; }
.dialog-content { display: grid; gap: 14px; padding: 21px 19px calc(24px + env(safe-area-inset-bottom)); }
.dialog-heading { align-items: flex-start; }
.close-button { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; color: var(--muted); background: #f1f4f8; font-size: 1.55rem; }
.booking-when { padding: 10px 12px; border-radius: 10px; color: #2751b2; background: var(--blue-pale); font-size: .84rem; font-weight: 700; }
.form-message { min-height: 18px; color: var(--danger); font-size: .79rem; }
.form-message.success { color: #17795b; }
.dialog-actions { display: flex; gap: 9px; align-items: center; }
.dialog-actions .primary-button { flex: 1; }

@media (min-width: 681px) {
  .app-shell { padding-top: 32px; }
  .calendar-day { min-height: 57px; font-size: .87rem; }
  .sheet-dialog { width: min(510px, calc(100% - 32px)); margin: auto; border-radius: 20px; }
}
