:root { color-scheme: light dark; }
* { box-sizing: border-box; }
body {
  margin: 0; min-height: 100vh; display: flex; flex-direction: column;
  font-family: system-ui, -apple-system, sans-serif; font-size: 15px;
  background: var(--tg-theme-bg-color, Canvas);
  color: var(--tg-theme-text-color, CanvasText);
}
#topbar {
  display: flex; align-items: center; gap: .5rem;
  padding: .5rem .75rem; position: sticky; top: 0; z-index: 3;
  background: var(--tg-theme-header-bg-color, var(--tg-theme-bg-color, Canvas));
  border-bottom: 1px solid rgba(128,128,128,.25);
}
#week-title { flex: 1; text-align: center; }
#week-label { font-weight: 600; }
.nav {
  border: 1px solid rgba(128,128,128,.35); background: none; color: inherit;
  border-radius: .5rem; width: 2.2rem; height: 2.2rem; font-size: 1.2rem;
}
main { flex: 1; padding: .5rem .5rem 1rem; }
footer {
  display: flex; justify-content: space-between; padding: .5rem .75rem 1rem;
}
.center { display: grid; place-items: center; min-height: 50vh; text-align: center; padding: 1rem; }
.muted { opacity: .65; font-size: .85em; }
.dept { margin: 1rem 0 .25rem; font-size: 1.05rem; font-weight: 600; }
.grid-wrap { overflow-x: auto; }
table.grid { border-collapse: collapse; min-width: 100%; }
.grid th, .grid td {
  border: 1px solid rgba(128,128,128,.25); padding: .3rem .35rem;
  text-align: center; white-space: nowrap; font-size: .8rem;
}
.grid th.name, .grid td.name {
  position: sticky; left: 0; z-index: 2; text-align: left; max-width: 8.5rem;
  overflow: hidden; text-overflow: ellipsis;
  background: var(--tg-theme-bg-color, Canvas);
}
.grid thead th { font-weight: 600; }
.grid .slots { font-weight: 400; opacity: .7; font-size: .7rem; display: block; }
.grid .warn { color: #e5484d; font-weight: 600; }
tr.me td { background: color-mix(in srgb, var(--tg-theme-button-color, #3390ec) 12%, transparent); }
td.cell-day-off { color: #30a46c; font-weight: 600; }
td.cell-red { color: #e5484d; font-weight: 700; }
td.cell-shift { }
td.cell-any { opacity: .8; font-style: italic; }
td.cell-absence { opacity: .6; font-style: italic; }
.badge {
  display: inline-block; padding: .1rem .5rem; border-radius: 1rem; font-size: .75rem;
  background: var(--tg-theme-button-color, #3390ec);
  color: var(--tg-theme-button-text-color, #fff);
}
button.primary {
  border: none; border-radius: .6rem; padding: .6rem 1.2rem; font-size: 1rem;
  background: var(--tg-theme-button-color, #3390ec);
  color: var(--tg-theme-button-text-color, #fff);
}
code { user-select: all; }
#sheet-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 10;
  display: flex; align-items: flex-end;
}
#sheet {
  background: var(--tg-theme-bg-color, Canvas); width: 100%;
  border-radius: 1rem 1rem 0 0; padding: .75rem .75rem 1.25rem;
}
#sheet h3 { margin: .25rem 0 .5rem; text-align: center; font-size: 1rem; }
#sheet button {
  display: block; width: 100%; padding: .7rem; margin: .3rem 0; font-size: .95rem;
  border-radius: .6rem; border: 1px solid rgba(128,128,128,.3);
  background: none; color: inherit; text-align: center;
}
#sheet button.danger { color: #e5484d; }
#sheet .form-row {
  display: flex; gap: .5rem; align-items: center; margin: .4rem 0; font-size: .9rem;
}
#sheet .form-row label { flex: 1; }
#sheet input {
  padding: .4rem; border-radius: .4rem; border: 1px solid rgba(128,128,128,.4);
  background: none; color: inherit; font-size: .9rem; width: 7.5rem;
}
#sheet input[type=number] { width: 4.5rem; }
#sheet .row-list { max-height: 40vh; overflow-y: auto; }
#sheet .item {
  display: flex; gap: .4rem; align-items: center; justify-content: space-between;
  padding: .3rem 0; border-bottom: 1px solid rgba(128,128,128,.15); font-size: .85rem;
}
#sheet .item button { display: inline-block; width: auto; margin: 0; padding: .3rem .6rem; font-size: .85rem; }
#sheet hr { border: none; border-top: 1px solid rgba(128,128,128,.25); margin: .6rem 0; }
button.linklike {
  border: none; background: none; color: var(--tg-theme-link-color, #3390ec);
  font-size: .85rem; padding: 0;
}
