:root {
  --bg: #05070a;
  --panel: #080d13;
  --panel2: #0c141d;
  --text: #f3f7fb;
  --muted: #8ea0b3;
  --border: #1b2a38;

  --day: #101923;
  --day-hover: #1b2b3b;
  --weekend: #263f5c;
  --weekend-hover: #315173;
  --empty: #05070a;
  --today: #ffffff;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
}

button,
input,
select {
  font: inherit;
}

.page {
  min-height: 100vh;
  padding: 8px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: center;
  margin-bottom: 14px;
}

h1 {
  margin: 0;
  font-size: 28px;
  color: #f7fbff;
}

p {
  margin: 5px 0 0;
  color: var(--muted);
}

.yearControls {
  display: flex;
  gap: 8px;
  align-items: center;
}

.yearControls button,
.yearControls input {
  border: 1px solid #203244;
  background: #0c141d;
  color: var(--text);
  border-radius: 10px;
  padding: 9px 12px;
}

.yearControls button:hover {
  background: #162638;
}

.yearControls input {
  width: 105px;
  text-align: center;
}

.calendarWrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: #070b10;
  padding: 8px;
}

.calendar {
  min-width: 1420px;
  display: grid;
  grid-template-columns: 105px repeat(31, 1fr);
  gap: 2px;
}

.cell {
  min-height: 46px;
  border-radius: 5px;
  border: 1px solid rgba(255,255,255,0.045);
  background: var(--day);
  overflow: hidden;
}

.headCell {
  min-height: 30px;
  display: grid;
  place-items: center;
  color: #b7cadb;
  font-size: 13px;
  font-weight: 800;
  background: #0b1621;
}

.monthCell {
  display: flex;
  align-items: center;
  padding: 0 10px;
  font-weight: 800;
  color: #ffffff;
  background: #0b1119;
}

.dayCell {
  position: relative;
  cursor: pointer;
  padding: 4px;
  transition: transform 120ms ease, border-color 120ms ease, background 120ms ease;
}

.dayCell:hover {
  transform: translateY(-1px);
  border-color: rgba(255,255,255,0.45);
  background: var(--day-hover);
}

.emptyCell {
  background: var(--empty);
  opacity: 0.85;
  cursor: default;
}

.emptyCell:hover {
  transform: none;
  border-color: rgba(255,255,255,0.045);
  background: var(--empty);
}

.weekendCell {
  background: var(--weekend);
  border-color: rgba(130, 180, 225, 0.18);
}

.weekendCell:hover {
  background: var(--weekend-hover);
  border-color: rgba(170, 215, 255, 0.5);
}

.dayNumber {
  font-size: 10px;
  color: #b8c8d7;
  line-height: 1;
  font-weight: 700;
}

.eventBox {
  margin-top: 4px;
  min-height: 29px;
  border-radius: 4px;
  padding: 3px 4px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 1px;
  text-align: center;
  color: #fff;
  font-weight: 900;
  line-height: 1.05;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.18);
}

.eventTitle {
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.eventTime {
  font-size: 11px;
  opacity: 0.95;
}

.todayMarker {
  outline: 2px solid var(--today);
  outline-offset: -2px;
}

.color-green { background: #0f8f52; }
.color-blue { background: #1a69d8; }
.color-red { background: #bd2f3d; }
.color-yellow { background: #d09b00; color: #101010; }
.color-purple { background: #7b45cf; }
.color-gray { background: #687584; }

.eventDialog {
  width: min(430px, calc(100vw - 24px));
  border: 1px solid #26384a;
  border-radius: 18px;
  padding: 0;
  background: #080d13;
  color: var(--text);
}

.eventDialog::backdrop {
  background: rgba(0,0,0,0.75);
}

.eventDialog form {
  padding: 18px;
}

.dialogHeader {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: start;
  margin-bottom: 18px;
}

.dialogHeader h2 {
  margin: 0;
}

.dialogHeader p {
  margin-top: 4px;
}

.iconBtn {
  border: 0;
  background: transparent;
  color: var(--text);
  font-size: 30px;
  cursor: pointer;
}

label {
  display: grid;
  gap: 7px;
  margin-bottom: 14px;
  color: var(--muted);
}

label input,
label select {
  width: 100%;
  border: 1px solid #26384a;
  border-radius: 10px;
  padding: 11px 12px;
  background: #05090e;
  color: var(--text);
}

.dialogActions {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 18px;
}

.dialogActions button {
  border: 0;
  border-radius: 10px;
  padding: 11px 14px;
  cursor: pointer;
  font-weight: 800;
}

.saveBtn {
  background: #108c50;
  color: white;
}

.saveBtn:hover {
  background: #12a55e;
}

.dangerBtn {
  background: #451923;
  color: #ffb7c1;
}

.dangerBtn:hover {
  background: #5b202d;
}

@media (max-width: 820px) {
  .topbar {
    align-items: stretch;
    flex-direction: column;
  }

  .yearControls {
    flex-wrap: wrap;
  }

  .calendar {
    min-width: 1180px;
  }

  .cell {
    min-height: 42px;
  }
}
