:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-muted: #eef1f4;
  --line: #d9dee5;
  --grid-line: #d5d5d5;
  --grid-strong: #a8a8a8;
  --text: #18202b;
  --muted: #687386;
  --brand: #0f766e;
  --brand-strong: #115e59;
  --accent: #2563eb;
  --warning: #b7791f;
  --danger: #b42318;
  --ok: #1d7a45;
  --shadow: 0 10px 30px rgba(24, 32, 43, 0.08);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

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

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
textarea {
  font: inherit;
}

.app-shell {
  min-height: 100vh;
}

.app-header {
  align-items: center;
  background: rgba(255, 255, 255, 0.94);
  border-bottom: 1px solid var(--line);
  display: grid;
  gap: 14px;
  grid-template-columns: auto 1fr auto;
  min-height: 68px;
  padding: 10px 18px;
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand-mark {
  align-items: center;
  background: var(--text);
  border-radius: 8px;
  color: #fff;
  display: flex;
  font-weight: 800;
  height: 40px;
  justify-content: center;
  width: 40px;
}

.app-title {
  display: flex;
  flex-direction: column;
  line-height: 1.1;
}

.app-title span {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

.app-title strong {
  font-size: 18px;
}

.app-actions,
.toolbar-actions,
.toolbar-group {
  align-items: center;
  display: flex;
  gap: 8px;
}

.app-main {
  padding: 18px;
}

.icon-button,
.button {
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
  display: inline-flex;
  gap: 8px;
  justify-content: center;
  min-height: 38px;
  padding: 0 12px;
}

.icon-button {
  background: var(--surface);
  font-size: 18px;
  padding: 0;
  width: 38px;
}

.icon-button.is-active,
.button-primary {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}

.button-ghost {
  background: var(--surface);
  font-size: 22px;
  width: 42px;
}

.button-quiet {
  background: var(--surface);
  color: var(--text);
}

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

.date-heading {
  display: flex;
  flex-direction: column;
  min-width: 190px;
}

.date-heading span {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

.date-heading strong {
  font-size: 16px;
}

.group-tabs {
  border-bottom: 1px solid var(--line);
  display: flex;
  gap: 6px;
  margin-bottom: 14px;
  overflow-x: auto;
}

.notice {
  background: #fff7ed;
  border: 1px solid #fed7aa;
  border-radius: 8px;
  color: #9a3412;
  margin: 0 0 14px;
  padding: 10px 12px;
}

.group-tab {
  border: 1px solid transparent;
  border-radius: 8px 8px 0 0;
  color: var(--muted);
  padding: 10px 14px;
  white-space: nowrap;
}

.group-tab.is-active {
  background: var(--surface);
  border-color: var(--line);
  border-bottom-color: var(--surface);
  color: var(--text);
  font-weight: 700;
  margin-bottom: -1px;
}

.planner-board {
  background: var(--surface);
  border: 2px solid var(--grid-strong);
  border-radius: 8px;
  box-shadow: var(--shadow);
  overflow: auto;
}

.planner-grid {
  display: grid;
  grid-template-columns: 170px repeat(var(--day-count), minmax(330px, 1fr));
  min-width: 1540px;
}

.planner-corner,
.planner-day,
.planner-person,
.planner-cell {
  border-bottom: 2px solid var(--grid-strong);
  border-right: 2px solid var(--grid-strong);
}

.planner-corner,
.planner-day {
  background: #fafbfc;
  min-height: 70px;
  padding: 10px 12px;
  position: sticky;
  top: 0;
  z-index: 2;
}

.planner-corner {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  left: 0;
  text-transform: uppercase;
  z-index: 3;
}

.planner-day {
  display: grid;
  gap: 6px;
}

.planner-day span {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

.planner-day strong {
  font-size: 16px;
}

.hour-ruler {
  color: var(--muted);
  display: grid;
  font-size: 10px;
  gap: 0;
  grid-template-columns: repeat(var(--hour-count), minmax(0, 1fr));
}

.hour-ruler span {
  align-items: center;
  border-left: 1px solid var(--grid-line);
  display: flex;
  justify-content: center;
  padding: 0;
}

.hour-ruler span:first-child {
  border-left: 0;
}

.planner-person {
  background: #fbfcfd;
  left: 0;
  min-height: 96px;
  padding: 12px;
  position: sticky;
  z-index: 1;
}

.planner-person strong {
  display: block;
}

.planner-cell {
  align-content: stretch;
  background-image: linear-gradient(to right, transparent calc(100% - 1px), var(--grid-line) calc(100% - 1px));
  background-size: calc(100% / var(--hour-count)) 100%;
  display: grid;
  gap: 0;
  grid-auto-flow: row dense;
  grid-auto-rows: 22px;
  grid-template-columns: repeat(var(--hour-count), minmax(0, 1fr));
  min-height: 96px;
  padding: 0;
}

.empty-slot {
  background: transparent;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  cursor: pointer;
  grid-column: 1 / -1;
  min-height: 48px;
}

.task-row {
  border-bottom: 1px solid var(--grid-line);
  cursor: pointer;
  display: grid;
  grid-column: 1 / -1;
  grid-template-columns: repeat(var(--hour-count), minmax(0, 1fr));
  min-height: 22px;
  min-width: 0;
  overflow: visible;
  position: relative;
}

.task-row::before {
  background-image: linear-gradient(to right, transparent calc(100% - 1px), var(--grid-line) calc(100% - 1px));
  background-size: calc(100% / var(--hour-count)) 100%;
  content: "";
  grid-column: 1 / -1;
  grid-row: 1;
  min-width: 0;
}

.booking-fill {
  background: #dff3df;
  border-left: 1px solid rgba(15, 118, 110, 0.2);
  border-right: 1px solid rgba(15, 118, 110, 0.16);
  grid-column: var(--task-start) / span var(--task-span);
  grid-row: 1;
  min-height: 22px;
}

.task-line {
  align-self: center;
  color: #092f46;
  font-size: 12px;
  font-weight: 600;
  grid-column: 1 / -1;
  grid-row: 1;
  line-height: 1;
  overflow: visible;
  padding-left: 7px;
  position: relative;
  white-space: nowrap;
  z-index: 2;
}

.task-row.is-complete .booking-fill {
  background: #d6ead7;
  opacity: 0.74;
}

.task-row.is-production-done .booking-fill {
  background: #f3e3c4;
}

.task-row.is-locked .booking-fill {
  background: #ead2d2;
}

.task-row.is-all-day .booking-fill {
  background: #e2e8f0;
}

.task-row.task-color-agreed .booking-fill {
  background: #dccaec;
}

.task-row.task-color-standard .booking-fill {
  background: #bee1b2;
}

.task-row.task-color-unavailable .booking-fill {
  background: #bdbdbd;
}

.task-row.task-color-absence .booking-fill {
  background: #e5bec0;
}

.task-row.task-color-meeting .booking-fill {
  background: #afd9ec;
}

.task-row.task-color-school .booking-fill {
  background: #ffb347;
}

.task-row.task-color-unconfirmed .booking-fill {
  background: #f9ecb7;
}

.task-dialog {
  border: 0;
  border-radius: 8px;
  box-shadow: var(--shadow);
  max-width: 520px;
  width: min(520px, calc(100vw - 28px));
}

.task-dialog::backdrop {
  background: rgba(24, 32, 43, 0.34);
}

.task-dialog header,
.task-dialog footer {
  align-items: center;
  display: flex;
  justify-content: space-between;
  padding: 14px;
}

.dialog-body {
  display: grid;
  gap: 12px;
  padding: 0 14px 14px;
}

.dialog-body label {
  display: grid;
  gap: 6px;
}

.dialog-body span {
  color: var(--muted);
  font-size: 13px;
}

.dialog-body input,
.dialog-body textarea {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  width: 100%;
}

.version-note {
  color: var(--muted);
  font-size: 12px;
  margin: 12px 2px 0;
}

@media (max-width: 780px) {
  .app-main {
    padding: 12px;
  }

  .toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .toolbar-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .planner-grid {
    grid-template-columns: 130px repeat(var(--day-count), minmax(300px, 1fr));
  }
}
