:root {
  font-family: "Segoe UI", "Segoe UI Variable Text", system-ui, sans-serif;
  color: #1a1a1a;
  background: #ffffff;
  --tp-surface: #f3f3f3;
  --tp-page-bg: #ffffff;
  --tp-divider: #e0e0e0;
  --tp-border: #e0e0e0;
  --tp-focus: #4e83c3;
  --tp-text: #1a1a1a;
  --tp-muted: #616161;
  --tp-shadow: #0004;
  --tp-bg: #fafafa;
  --tp-radius: 8px;
  --tp-radius-sm: 6px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--tp-page-bg);
  color: var(--tp-text);
}

button,
input,
select {
  font: inherit;
}

.shell {
  min-height: 100vh;
  width: min(1200px, 100%);
  margin: 0 auto;
  background: var(--tp-surface);
  box-shadow: 0 2px 18px rgb(0 0 0 / 14%);
  display: grid;
  grid-template-rows: auto 1fr auto;
}

.toolbar,
footer {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--tp-divider);
}

.toolbar {
  flex-wrap: wrap;
}

input,
select,
button {
  min-height: 32px;
}

input,
select {
  border: 1px solid #d6d6d6;
  border-radius: var(--tp-radius-sm);
  padding: 0 10px;
  background: #fff;
}

.toolbar input {
  height: 32px;
}

button,
input,
select {
  border-radius: var(--tp-radius-sm);
}

.toolbar button,
.entry button,
footer button,
dialog button {
  border: 1px solid #d6d6d6;
  background: #fbfbfb;
  padding: 0 12px;
  cursor: pointer;
}

.toolbar button:hover,
.entry button:hover,
footer button:hover,
dialog button:hover {
  background: #f0f0f0;
}

.toolbar button:focus-visible,
input:focus-visible,
select:focus-visible,
dialog button:focus-visible {
  border-color: #747a84;
  outline: none;
}

.switch {
  margin-left: auto;
  display: flex;
  flex: 0 0 auto;
  gap: 7px;
  align-items: center;
  font-size: 14px;
  white-space: nowrap;
  cursor: pointer;
}

.switch input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.switch-control {
  position: relative;
  width: 38px;
  height: 20px;
  border: 1px solid #8d939d;
  border-radius: 999px;
  background: #e8e9ec;
  transition: background 0.15s, border-color 0.15s;
}

.switch-control::after {
  content: "";
  position: absolute;
  top: 1px;
  left: 1px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #fff;
  border: 1px solid #747a84;
  transition: transform 0.15s;
}

.switch input:checked + .switch-control {
  background: var(--tp-text);
  border-color: var(--tp-text);
}

.switch input:checked + .switch-control::after {
  transform: translateX(18px);
  border-color: #fff;
}

.switch input:focus-visible + .switch-control {
  outline: 2px solid var(--tp-focus);
  outline-offset: 2px;
}

.board {
  padding: 16px;
  overflow: auto;
}

.week {
  display: grid;
  grid-template-columns: repeat(5, minmax(430px, 1fr));
  gap: 10px;
  min-width: fit-content;
  margin-right: 10px;
}

.day {
  min-width: 0;
}

.day-head {
  display: flex;
  justify-content: space-between;
  margin: 2px 2px 8px;
  font-weight: 600;
}

.total,
.muted,
#status {
  color: var(--tp-muted);
  font-size: 13px;
  font-weight: 400;
}

.entry {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 100px 32px;
  gap: 8px;
  padding: 10px;
  margin-bottom: 6px;
  border: 1px solid var(--tp-border);
  border-radius: var(--tp-radius);
  background: var(--tp-bg);
}

.week .entry {
  grid-template-columns: minmax(260px, 1fr) 96px 32px;
}

.entry:focus-within {
  border-color: var(--tp-border);
  box-shadow: none;
}

.entry input {
  min-width: 0;
  max-width: 100%;
}

.week .entry input {
  min-width: 260px;
}

.entry button {
  width: 32px;
  height: 32px;
  padding: 0;
  color: #4f555f;
  display: grid;
  place-items: center;
}

.entry button.delete {
  border-color: #d6d6d6;
  background: #fbfbfb;
}

.entry button.delete:hover {
  background: #f0f2f6;
}

.entry button svg {
  width: 15px;
  height: 15px;
  fill: currentColor;
}

.ghost {
  background: #fbfbfb;
  border-color: #d6d6d6;
}

button.icon-button {
  min-width: 32px;
  max-width: 32px;
  min-height: 32px;
  max-height: 32px;
  padding: 0;
  flex: 0 0 32px;
  display: grid;
  place-items: center;
  color: #1d1d20;
  line-height: 0;
  overflow: hidden;
}

button.icon-button > svg {
  width: 16px;
  height: 16px;
  min-width: 16px;
  max-width: 16px;
  min-height: 16px;
  max-height: 16px;
  display: block;
  flex: none;
  fill: currentColor;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

footer {
  border-top: 1px solid var(--tp-divider);
  border-bottom: 0;
}

footer > #status {
  flex: 1;
  text-align: right;
}

dialog {
  border: 1px solid #ccd1da;
  border-radius: 12px;
  box-shadow: 0 12px 40px var(--tp-shadow);
  padding: 0;
  max-width: 520px;
  width: min(calc(100% - 32px), 520px);
}

dialog::backdrop {
  background: #15182145;
}

dialog form {
  padding: 16px;
  display: grid;
  gap: 15px;
}

#authFields {
  display: grid;
  gap: 15px;
}

.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-head h2 {
  margin: 0;
  font-size: 20px;
  font-weight: 650;
}

.modal-head button {
  width: 32px;
  height: 32px;
  padding: 0;
  border: 0;
  background: transparent;
}

.dates {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 15px;
}

.dates label,
dialog label {
  display: grid;
  gap: 5px;
  font-weight: 600;
  font-size: 14px;
}

dialog h3 {
  margin: 0;
  font-size: 15px;
}

dialog hr {
  width: 100%;
  border: 0;
  border-top: 1px solid #e3e5e9;
}

.tabs {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: max-content;
  gap: 8px;
  margin-bottom: 15px;
  overflow-x: auto;
  border-bottom: 1px solid #e3e5e9;
}

.tabs button {
  border: 0;
  border-bottom: 2px solid transparent;
  background: transparent;
  padding: 0 8px;
  white-space: nowrap;
}

.tabs button.active {
  border-bottom-color: #1d1d20;
  font-weight: 600;
}

.tabs button:hover {
  background: #f4f5f8;
}

.account-panel {
  display: grid;
  gap: 15px;
}

dialog nav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

dialog nav button {
  padding: 0 6px;
  border: 0;
  background: transparent;
  color: #1769aa;
  text-decoration: underline;
  min-height: auto;
}

@media (max-width: 600px) {
  .shell {
    width: 100%;
    height: 100vh;
    height: 100dvh;
    min-height: 100vh;
    min-height: 100dvh;
    overflow: hidden;
  }

  .toolbar {
    padding: 10px;
  }

  .switch-label {
    font-size: 0;
  }

  .switch-label::after {
    content: attr(data-mobile-label);
    font-size: 14px;
  }

  .board {
    padding: 10px;
    min-height: 0;
  }

  footer {
    padding: 8px 10px max(8px, env(safe-area-inset-bottom));
  }

  .entry {
    grid-template-columns: minmax(0, 1fr) 85px 30px;
  }

  .dates {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 440px) {
  .toolbar {
    display: grid;
    grid-template-columns: 32px minmax(0, 1fr) 32px auto;
  }

  .toolbar .switch {
    grid-column: 1 / -1;
    grid-row: 1;
    justify-self: end;
  }

  .toolbar #previous {
    grid-column: 1;
    grid-row: 2;
  }

  .toolbar #datePicker {
    grid-column: 2;
    grid-row: 2;
    min-width: 0;
    width: 100%;
  }

  .toolbar #next {
    grid-column: 3;
    grid-row: 2;
  }

  .toolbar #today {
    grid-column: 4;
    grid-row: 2;
    white-space: nowrap;
  }
}
