:root {
  color-scheme: light;
  --ink: #1f2630;
  --muted: #647084;
  --line: #d8dee8;
  --soft: #f4f7fa;
  --panel: #ffffff;
  --accent: #0b6b60;
  --accent-dark: #064a43;
  --danger: #a73535;
  --rest: #6a7280;
  --early: #0b6b60;
  --late: #275c9a;
  --night: #6e4aa5;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  background: #eef2f6;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.55;
  overflow-x: hidden;
}

button,
input,
select,
textarea {
  font: inherit;
}

button,
.file-button {
  min-height: 40px;
  border: 1px solid #bdc7d5;
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  font-weight: 700;
}

button:hover,
.file-button:hover {
  border-color: var(--accent);
}

input,
select,
textarea {
  min-width: 0;
  min-height: 40px;
  border: 1px solid #bdc7d5;
  border-radius: 6px;
  padding: 0 10px;
  background: #fff;
  color: var(--ink);
}

textarea {
  width: 100%;
  min-height: 110px;
  padding: 8px 10px;
  resize: vertical;
}

.app-header,
.app-shell {
  width: min(1440px, calc(100% - 28px));
  margin: 0 auto;
}

.print-heading {
  display: none;
}

.app-header {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 16px 0;
}

.back-link {
  color: var(--accent-dark);
  font-weight: 800;
  text-decoration: none;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
}

h1,
h2 {
  margin: 0;
  line-height: 1.25;
  letter-spacing: 0;
}

h1 {
  font-size: 26px;
}

h2 {
  font-size: 18px;
}

.policy,
.caution {
  padding: 14px 16px;
  border: 1px solid #d3bd8f;
  border-radius: 8px;
  background: #fff8e8;
  color: #563b12;
}

.policy p,
.caution p {
  margin: 0;
}

.privacy-strip {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 10px;
}

.privacy-strip span {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border: 1px solid #bad7d2;
  border-radius: 999px;
  background: #edf8f6;
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 800;
}

.toolbar {
  display: flex;
  align-items: end;
  gap: 10px;
  flex-wrap: wrap;
  margin: 14px 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.month-field {
  display: grid;
  gap: 4px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.file-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 12px;
  position: relative;
  overflow: hidden;
}

.file-button input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.danger {
  color: #fff;
  border-color: var(--danger);
  background: var(--danger);
}

.save-button {
  color: #fff;
  border-color: var(--accent);
  background: var(--accent);
}

.save-status {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  margin: 0;
  padding: 0 10px;
  border-radius: 6px;
  background: var(--soft);
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.save-status.is-dirty {
  background: #fff4d6;
  color: #6a4800;
}

.save-status.is-saved {
  background: #e8f6ed;
  color: #225c35;
}

.workspace {
  display: grid;
  grid-template-columns: 330px minmax(0, 1fr);
  gap: 14px;
}

.side {
  display: grid;
  align-content: start;
  gap: 14px;
}

.panel,
.board-area {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.panel {
  padding: 14px;
}

.inline-form {
  display: grid;
  grid-template-columns: 1fr 70px;
  gap: 8px;
  margin-top: 12px;
}

.staff-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 8px;
}

.staff-actions button {
  min-height: 34px;
  padding: 0 10px;
  font-size: 13px;
}

.bulk-box,
.copy-row-box {
  margin-top: 10px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fbfcfe;
}

.bulk-box summary {
  cursor: pointer;
  font-size: 13px;
  font-weight: 800;
}

.bulk-box textarea {
  margin-top: 8px;
}

.bulk-box button {
  width: 100%;
  margin-top: 8px;
}

.copy-row-box h3 {
  margin: 0 0 8px;
  font-size: 13px;
  line-height: 1.35;
}

.copy-row-controls {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  gap: 8px;
  align-items: center;
}

.copy-row-controls button {
  grid-column: 1 / -1;
}

.shift-form {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 12px;
}

.shift-form button {
  grid-column: 1 / -1;
}

.shift-form.is-editing {
  padding: 10px;
  border: 1px solid #d3bd8f;
  border-radius: 6px;
  background: #fff8e8;
}

.shift-form.is-editing button {
  grid-column: auto;
}

.secondary-action {
  background: #f8fafc;
}

.stack-list {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.list-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto auto auto;
  align-items: center;
  gap: 6px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--soft);
}

.list-row strong,
.list-row span {
  min-width: 0;
  overflow-wrap: anywhere;
}

.icon-btn {
  width: 34px;
  min-height: 34px;
  padding: 0;
}

.icon-btn:disabled {
  cursor: not-allowed;
  opacity: 0.35;
}

.palette {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 12px;
}

.palette button,
.sheet-options button {
  color: #fff;
  border: 0;
  background: var(--accent);
}

.palette button[aria-pressed="true"] {
  outline: 3px solid #ffd15d;
  outline-offset: 2px;
}

.eraser {
  width: 100%;
  margin-top: 8px;
}

.eraser[aria-pressed="true"] {
  outline: 3px solid #ffd15d;
  outline-offset: 2px;
}

.board-area {
  min-width: 0;
  padding: 14px;
}

.board-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: end;
  margin-bottom: 12px;
}

.save-hint {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.quick-palette {
  position: sticky;
  top: 0;
  z-index: 8;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin: 0 0 10px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgb(255 255 255 / 94%);
}

.quick-palette button {
  min-width: 48px;
  min-height: 36px;
  padding: 0 10px;
  color: #fff;
  border: 0;
  text-shadow: 0 1px 1px rgb(0 0 0 / 35%);
}

.quick-palette button[aria-pressed="true"] {
  outline: 3px solid #ffd15d;
  outline-offset: 2px;
}

.quick-palette button.clear-shortcut {
  color: var(--ink);
  border: 1px solid #bdc7d5;
  background: #f8fafc;
  text-shadow: none;
}

.table-scroll {
  max-width: 100%;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
}

.table-scroll.compact {
  margin-top: 10px;
  max-height: 330px;
}

table {
  width: max-content;
  min-width: 100%;
  border-collapse: separate;
  border-spacing: 0;
}

th,
td {
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: #fff;
}

th {
  font-size: 12px;
  font-weight: 800;
}

.schedule-table th,
.schedule-table td {
  min-width: 54px;
  height: 42px;
  padding: 4px;
  text-align: center;
}

.schedule-table thead th {
  position: sticky;
  top: 0;
  z-index: 3;
  background: #eef4f3;
}

.schedule-table .staff-head,
.schedule-table .staff-cell {
  position: sticky;
  left: 0;
  z-index: 4;
  min-width: 140px;
  max-width: 180px;
  text-align: left;
  background: #f7fafc;
  box-shadow: 1px 0 0 var(--line);
}

.schedule-table .staff-head {
  top: 0;
  z-index: 5;
}

.staff-cell {
  font-weight: 800;
  overflow-wrap: anywhere;
}

.day-weekend {
  color: #9b3434;
}

.shift-cell {
  border: 0;
  width: 100%;
  height: 32px;
  border-radius: 5px;
  background: #f2f5f8;
  color: var(--ink);
  font-weight: 800;
  touch-action: manipulation;
  user-select: none;
}

.shift-cell.filled {
  color: #fff;
}

.shift-cell:hover {
  outline: 2px solid #94a3b8;
}

.shift-cell.is-painting {
  outline: 3px solid #ffd15d;
}

.summary-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-top: 14px;
}

.summary-table th,
.summary-table td {
  padding: 8px 10px;
  text-align: left;
  white-space: nowrap;
}

.caution {
  margin: 14px 0 28px;
}

.mobile-sheet {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  align-items: end;
  background: rgb(14 23 38 / 52%);
}

.mobile-sheet[hidden] {
  display: none;
}

.sheet-panel {
  padding: 16px;
  border-radius: 12px 12px 0 0;
  background: #fff;
}

.sheet-panel p {
  margin: 0 0 12px;
  font-weight: 800;
}

.sheet-options {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.sheet-panel > button {
  width: 100%;
  margin-top: 10px;
}

@media (max-width: 900px) {
  .workspace,
  .summary-grid {
    grid-template-columns: 1fr;
  }

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

  .schedule-table th,
  .schedule-table td {
    min-width: 50px;
  }
}

@media (max-width: 560px) {
  .app-header,
  .app-shell {
    width: min(100% - 20px, 1440px);
  }

  .app-header {
    align-items: flex-start;
    flex-direction: column;
    gap: 8px;
  }

  .toolbar {
    align-items: stretch;
  }

  .toolbar button,
  .toolbar .file-button,
  .month-field {
    flex: 1 1 140px;
  }

  .board-head {
    align-items: flex-start;
    flex-direction: column;
  }
}

@page {
  size: A4 landscape;
  margin: 10mm;
}

@media print {
  * {
    box-shadow: none !important;
    text-shadow: none !important;
  }

  body {
    color: #000;
    background: #fff;
    overflow: visible;
    font-size: 10px;
  }

  .no-print,
  .side,
  .caution,
  .mobile-sheet,
  .ad-row,
  .info-grid,
  .related-tools,
  .comments-panel,
  .return-links,
  .app-footer {
    display: none !important;
  }

  .print-heading {
    display: block;
    margin: 0 0 5mm;
    color: #000;
  }

  .print-heading h1 {
    font-size: 18px;
  }

  .print-heading p {
    margin: 1mm 0 0;
    font-size: 11px;
  }

  .app-shell {
    width: 100%;
    margin: 0;
  }

  .workspace,
  .summary-grid {
    display: block;
    gap: 0;
  }

  .board-area,
  .panel {
    border: 0;
    padding: 0;
    background: #fff;
    break-inside: avoid;
    page-break-inside: avoid;
  }

  .board-head {
    display: block;
    margin: 0 0 3mm;
  }

  .board-head .eyebrow,
  .board-head p,
  .save-hint {
    display: none !important;
  }

  .board-head h2 {
    color: #000;
    font-size: 15px;
  }

  .table-scroll {
    overflow: visible;
    border: 0;
    max-height: none;
  }

  table {
    width: 100%;
    min-width: 0;
    border-collapse: collapse;
    font-size: 9px;
    color: #000;
  }

  th,
  td {
    border: 1px solid #777 !important;
    color: #000 !important;
    background: #fff !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  .schedule-table th,
  .schedule-table td {
    min-width: 0;
    height: auto;
    padding: 2px 3px;
    vertical-align: middle;
  }

  .schedule-table thead th,
  .schedule-table .staff-head,
  .schedule-table .staff-cell {
    position: static;
  }

  .schedule-table .staff-head,
  .schedule-table .staff-cell {
    min-width: 80px;
    max-width: 110px;
    font-weight: 800;
  }

  .shift-cell {
    height: auto;
    min-height: 16px;
    padding: 0;
    color: #000 !important;
    background: transparent !important;
    border: 0 !important;
    font-weight: 800;
  }

  .summary-grid {
    margin-top: 6mm;
  }

  .summary-card {
    margin-top: 5mm;
    break-inside: avoid;
    page-break-inside: avoid;
  }

  .summary-table {
    font-size: 9px;
  }
}

.page-lead {
  max-width: 860px;
  margin: 8px 0 0;
  color: var(--muted);
  font-weight: 700;
}

.mobile-note {
  width: min(1440px, calc(100% - 28px));
  margin: 12px auto 0;
  border: 1px solid #d8e3ee;
  border-radius: 8px;
  padding: 10px 14px;
  background: #f8fbff;
  color: #526173;
}

.mobile-note p {
  margin: 0;
}

.ad-row,
.info-grid,
.related-tools,
.comments-panel,
.return-links,
.app-footer {
  width: min(1440px, calc(100% - 28px));
  margin: 18px auto 0;
}

.ad-row {
  min-height: 250px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #fff;
}

.ad-label {
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.08em;
}

.info-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.info-card,
.related-tools,
.comments-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  background: var(--panel);
}

.info-card h2,
.related-tools h2 {
  margin: 4px 0 10px;
}

.info-card p,
.info-card li {
  color: #3b4757;
}

.related-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.related-grid a,
.return-links a {
  display: grid;
  gap: 4px;
  min-width: 0;
  border: 1px solid #d8e0eb;
  border-radius: 8px;
  padding: 12px;
  color: var(--ink);
  background: #f9fbfd;
  text-decoration: none;
}

.related-grid a:hover,
.return-links a:hover {
  border-color: var(--accent);
}

.related-grid span,
.return-links span,
.return-links small {
  color: var(--muted);
}

.return-links {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.app-footer {
  padding: 20px 0 32px;
  color: var(--muted);
  text-align: center;
}

@media (max-width: 760px) {
  .info-grid,
  .related-grid,
  .return-links {
    grid-template-columns: 1fr;
  }

  .ad-row {
    min-height: 280px;
  }
}

@media print {
  .ad-row,
  .info-grid,
  .related-tools,
  .comments-panel,
  .return-links,
  .app-footer {
    display: none !important;
  }
}
