* { box-sizing: border-box; }
body { margin: 0; font-family: system-ui, -apple-system, Segoe UI, sans-serif; background: #e5e7eb; color: #0f172a; }
button, input, select, textarea { font: inherit; }
.app-shell { max-width: 1180px; margin: 0 auto; padding: 12px; }
.topbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 4px; }
.app-title { font-size: 22px; font-weight: 800; }
.who { color: #475569; font-size: 14px; }
.top-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.logout { color: #0f172a; text-decoration: none; font-weight: 700; background: #fff; padding: 10px 14px; border-radius: 14px; }
.calendar-card { background: #fff; border-radius: 24px; padding: 14px; box-shadow: 0 10px 30px rgba(15,23,42,.10); }
.calendar-toolbar { display: grid; grid-template-columns: 46px 72px 46px 1fr auto; gap: 8px; align-items: center; margin-bottom: 10px; }
.calendar-toolbar h1 { font-size: 28px; margin: 0; text-align: center; text-transform: capitalize; }
.nav-btn, .today-btn, .primary-btn, .danger-btn, .xbtn { border: 0; border-radius: 14px; padding: 11px 14px; cursor: pointer; font-weight: 800; }
.nav-btn, .today-btn { background: #f1f5f9; }
.nav-btn { font-size: 26px; line-height: 1; padding: 7px 12px; }
.primary-btn { background: #0f172a; color: #fff; }
.danger-btn { background: #fee2e2; color: #991b1b; }
.weekdays { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; margin-bottom: 6px; }
.weekdays div { text-align: center; color: #64748b; font-weight: 800; }
.calendar-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; transition: opacity .16s ease, transform .16s ease; }
.calendar-grid.is-loading { opacity: .55; transform: scale(.995); }
.day { min-height: 122px; background: #f8fafc; border: 2px solid transparent; border-radius: 18px; padding: 8px; text-align: left; cursor: pointer; overflow: hidden; transition: transform .08s ease, background .12s ease, border-color .12s ease; -webkit-tap-highlight-color: transparent; }
.day:active { transform: scale(.985); background: #eef2ff; }
.day.empty { visibility: hidden; }
.day.today { border-color: #0f172a; }
.day.busy { background: #fff; }
.day-num { font-size: 30px; line-height: 1; font-weight: 900; margin-bottom: 7px; }
.event-list { display: flex; flex-direction: column; gap: 4px; margin-left: -5px; margin-right: -5px; }
.event-chip { --event-color: #2563eb; border-left: 5px solid var(--event-color); border-radius: 9px; padding: 4px 7px; font-size: 13px; font-weight: 850; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.event-chip.range-single { border-radius: 10px; }
.event-chip.range-start { border-radius: 10px 3px 3px 10px; margin-right: -7px; }
.event-chip.range-middle { border-radius: 3px; margin-left: -7px; margin-right: -7px; border-left-color: transparent; }
.event-chip.range-end { border-radius: 3px 10px 10px 3px; margin-left: -7px; border-left-color: transparent; }
.more-events { color: #64748b; font-size: 12px; font-weight: 800; padding-left: 4px; }
.modal-backdrop { position: fixed; inset: 0; background: rgba(15,23,42,.50); display: flex; align-items: flex-end; justify-content: center; padding: 12px; z-index: 20; }
.modal-backdrop.hidden, .hidden { display: none !important; }
.modal { background: #fff; width: min(620px, 100%); border-radius: 24px; padding: 18px; box-shadow: 0 20px 50px rgba(15,23,42,.30); max-height: calc(100vh - 24px); overflow: auto; }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.modal h2 { margin: 0 0 12px; }
.xbtn { background: #f1f5f9; font-size: 24px; width: 44px; height: 44px; padding: 0; }
label { display: block; font-weight: 800; margin: 12px 0 6px; }
input, select, textarea { width: 100%; border: 1px solid #cbd5e1; border-radius: 14px; padding: 12px; background: #fff; }
input:focus, select:focus, textarea:focus { outline: 2px solid #c7d2fe; border-color: #818cf8; }
.two-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.check-row { display: flex; align-items: center; gap: 8px; font-weight: 700; }
.check-row input { width: auto; }
.modal-actions { display: flex; justify-content: space-between; gap: 10px; margin-top: 16px; }
.conflicts { margin-top: 12px; padding: 12px; border-radius: 14px; background: #fef3c7; color: #92400e; line-height: 1.35; }
.login-body { min-height: 100vh; display: grid; place-items: center; padding: 16px; background: #0f172a; }
.login-card { width: min(420px, 100%); background: #fff; border-radius: 24px; padding: 24px; box-shadow: 0 20px 50px rgba(0,0,0,.35); }
.login-card h1 { margin: 0 0 4px; }
.login-card p { margin-top: 0; color: #64748b; }
.login-card button { margin-top: 16px; width: 100%; border: 0; border-radius: 14px; background: #0f172a; color: #fff; padding: 13px; font-weight: 900; }
.alert { background: #fee2e2; color: #991b1b; padding: 10px 12px; border-radius: 12px; margin-bottom: 12px; font-weight: 700; }
.notice { background: #dcfce7; color: #166534; padding: 10px 12px; border-radius: 12px; margin-bottom: 12px; font-weight: 700; }
.login-link { display: block; margin-top: 14px; color: #0f172a; text-align: center; font-weight: 800; }
.admin-panel { background: #fff; border-radius: 18px; padding: 16px; margin-bottom: 14px; box-shadow: 0 10px 30px rgba(15,23,42,.08); }
.admin-panel h2 { margin: 0 0 8px; }
.user-form { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px 10px; align-items: end; padding: 12px 0; border-top: 1px solid #e2e8f0; }
.user-form:first-of-type { border-top: 0; }
.user-form label { margin: 0; font-size: 13px; }
.user-form .check-row { align-self: center; margin-top: 18px; }
.user-form button { min-height: 45px; }
@media (max-width: 760px) {
  .app-shell { padding: 8px; }
  .topbar { padding: 8px 2px; }
  .app-title { font-size: 19px; }
  .who { font-size: 12px; }
  .logout { padding: 8px 11px; border-radius: 12px; }
  .calendar-card { padding: 10px; border-radius: 18px; }
  .calendar-toolbar { grid-template-columns: 42px 62px 42px 1fr; }
  .calendar-toolbar h1 { grid-column: 1 / -1; grid-row: 2; font-size: 24px; }
  #newEventBtn { grid-column: 4; grid-row: 1; padding: 10px; }
  .weekdays { gap: 3px; }
  .calendar-grid { gap: 3px; }
  .day { min-height: 92px; border-radius: 12px; padding: 5px; }
  .day-num { font-size: 24px; margin-bottom: 5px; }
  .event-list { gap: 3px; margin-left: -3px; margin-right: -3px; }
  .event-chip { font-size: 11px; padding: 3px 4px; border-left-width: 4px; line-height: 1.15; }
  .event-chip.range-start { margin-right: -5px; }
  .event-chip.range-middle { margin-left: -5px; margin-right: -5px; }
  .event-chip.range-end { margin-left: -5px; }
  .two-cols { grid-template-columns: 1fr; }
  .user-form { grid-template-columns: 1fr; }
  .user-form .check-row { margin-top: 4px; }
  .modal { border-radius: 22px 22px 0 0; padding-bottom: calc(18px + env(safe-area-inset-bottom)); }
}
