:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --panel: #ffffff;
  --text: #17202a;
  --muted: #65717f;
  --line: #d9e0e8;
  --primary: #176b87;
  --primary-dark: #0d4f66;
  --accent: #c77922;
  --ok: #237a57;
  --danger: #b63b3b;
}

* {
  box-sizing: border-box;
}

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

button,
input {
  font: inherit;
}

button {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  color: var(--text);
  padding: 0 14px;
  cursor: pointer;
}

button:hover {
  border-color: var(--primary);
}

.loginView {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(180deg, rgb(255 255 255 / 0.72), rgb(246 247 249 / 0.95)),
    var(--bg);
}

.loginPanel {
  width: min(420px, 100%);
  display: grid;
  gap: 22px;
  padding: 30px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 18px 50px rgb(23 32 42 / 0.09);
}

.loginPanel h1 {
  margin: 4px 0 0;
  font-size: 28px;
  letter-spacing: 0;
}

.eyebrow {
  margin: 0;
  color: var(--primary);
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
}

.loginCopy,
.loginStatus {
  margin: 8px 0 0;
  color: var(--muted);
}

.primaryButton {
  min-height: 44px;
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.primaryButton:hover {
  background: var(--primary-dark);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 18px 24px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}

.topbar h1 {
  margin: 0;
  font-size: 22px;
  letter-spacing: 0;
}

.topbar p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.actions,
.nav,
.viewSwitch,
.dialogActions,
.accountBox {
  display: flex;
  gap: 8px;
  align-items: center;
}

#refreshButton,
.dialogActions button[type="submit"] {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

#refreshButton:hover,
.dialogActions button[type="submit"]:hover {
  background: var(--primary-dark);
}

.accountBox {
  justify-content: flex-end;
  gap: 10px;
}

.avatar {
  width: 38px;
  height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--primary);
  background-size: cover;
  background-position: center;
  color: #fff;
  font-size: 13px;
  font-weight: 800;
}

.accountText {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.accountText span,
.accountText small {
  max-width: 240px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.accountText span {
  font-weight: 700;
}

.accountText small {
  color: var(--muted);
}

.shell {
  max-width: 1280px;
  margin: 0 auto;
  padding: 20px 24px 32px;
}

.toolbar {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  align-items: center;
  gap: 16px;
  margin-bottom: 14px;
}

#periodTitle {
  margin: 0;
  text-align: center;
  font-size: 20px;
}

.viewSwitch {
  background: #e8edf2;
  padding: 4px;
  border-radius: 8px;
}

.viewSwitch button {
  border-color: transparent;
  background: transparent;
}

.viewSwitch button.active {
  background: var(--panel);
  border-color: var(--line);
  color: var(--primary-dark);
}

.message {
  margin: 12px 0;
  padding: 12px 14px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: var(--panel);
}

.message.error {
  border-color: #e0a3a3;
  color: var(--danger);
}

.hidden {
  display: none;
}

.calendar {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
}

.weekday {
  padding: 10px 12px;
  background: #eef2f5;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  border-right: 1px solid var(--line);
}

.weekday:last-child {
  border-right: none;
}

.day {
  min-height: 128px;
  padding: 8px;
  border-top: 1px solid var(--line);
  border-right: 1px solid var(--line);
  background: #fff;
}

.day:nth-child(7n) {
  border-right: none;
}

.day.outside {
  background: #f7f9fb;
  color: #98a3ae;
}

.day.today .date {
  background: var(--primary);
  color: white;
}

.date {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  font-size: 13px;
  font-weight: 700;
}

.event {
  width: 100%;
  display: block;
  min-height: 30px;
  margin-top: 6px;
  padding: 6px 8px;
  border: 0;
  border-left: 4px solid var(--accent);
  border-radius: 4px;
  background: #fff4e6;
  text-align: left;
  line-height: 1.25;
}

.event strong,
.event span {
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.event span {
  color: var(--muted);
  font-size: 12px;
}

.dayView,
.weekList {
  display: grid;
  gap: 12px;
  padding: 16px;
}

.listDay {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 12px;
}

.listDay h3 {
  margin: 0 0 8px;
  font-size: 16px;
}

.empty {
  margin: 0;
  color: var(--muted);
}

dialog {
  width: min(680px, calc(100vw - 32px));
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 20px;
}

dialog::backdrop {
  background: rgb(23 32 42 / 0.35);
}

.close {
  float: right;
  width: 34px;
  min-height: 34px;
  padding: 0;
}

.detailGrid {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 10px 14px;
}

.detailGrid dt {
  color: var(--muted);
}

.detailGrid dd {
  margin: 0;
  overflow-wrap: anywhere;
}

@media (max-width: 820px) {
  .topbar,
  .toolbar {
    grid-template-columns: 1fr;
    display: grid;
    align-items: stretch;
  }

  .actions,
  .nav,
  .viewSwitch,
  .accountBox {
    justify-content: stretch;
  }

  .actions button,
  .nav button,
  .viewSwitch button,
  #refreshButton {
    flex: 1;
  }

  .accountText {
    flex: 1;
  }

  .weekday {
    padding: 8px 4px;
    text-align: center;
  }

  .day {
    min-height: 108px;
    padding: 6px;
  }

  .event {
    padding: 5px 6px;
  }
}
