:root {
  color-scheme: light;
  --bg: #eef3f4;
  --ink: #18212b;
  --muted: #66727f;
  --line: #d8e1e4;
  --panel: #ffffff;
  --primary: #0f766e;
  --primary-dark: #115e59;
  --accent: #2563eb;
  --warn: #a15c07;
  --warn-bg: #fff7e8;
  --ready: #167449;
  --ready-bg: #e2f6eb;
  font-family: Arial, system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: linear-gradient(180deg, #e7f0f1 0%, var(--bg) 260px);
  color: var(--ink);
}

body.modal-open {
  overflow: hidden;
}

.app {
  width: min(1080px, 100%);
  margin: 0 auto;
  padding: 16px 14px 32px;
}

.hidden {
  display: none !important;
}

.login-view {
  min-height: 100vh;
  display: grid;
  place-items: center;
}

.login-card {
  width: min(430px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 24px;
  box-shadow: 0 16px 40px rgba(20, 35, 45, 0.12);
}

.login-copy {
  margin: 8px 0 20px;
  color: var(--muted);
  line-height: 1.45;
}

.login-form {
  display: grid;
  gap: 12px;
}

.login-error {
  min-height: 20px;
  color: #b42318;
  font-size: 13px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 8px 2px 14px;
}

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

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 28px;
}

h2 {
  font-size: 18px;
}

.hero-panel,
.panel,
.stat,
.hint-row,
.week-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 1px 2px rgba(24, 33, 43, 0.05);
}

.hero-panel {
  min-height: 110px;
  padding: 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 12px;
}

.hero-panel h2 {
  margin-top: 10px;
}

.hero-meta {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  text-align: right;
}

.pill {
  display: inline-grid;
  place-items: center;
  min-width: 72px;
  padding: 7px 10px;
  border-radius: 999px;
  background: #e8eef2;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.pill.ready {
  background: var(--ready-bg);
  color: var(--ready);
}

.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 12px;
}

.stat {
  min-height: 76px;
  padding: 12px;
  display: grid;
  align-content: center;
  gap: 4px;
}

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

.stat strong {
  font-size: 26px;
}

.stat.warn {
  background: var(--warn-bg);
  border-color: #f0d09a;
}

.stat.ready {
  background: var(--ready-bg);
  border-color: #b9e6cd;
}

.actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  margin-bottom: 12px;
}

.analysis-progress {
  margin-bottom: 12px;
  padding: 12px 14px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.analysis-progress-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
  font-size: 13px;
}

.analysis-progress-head span {
  color: var(--muted);
  font-weight: 800;
}

.analysis-progress progress {
  display: block;
  width: 100%;
  height: 10px;
  border: 0;
  border-radius: 5px;
  overflow: hidden;
  appearance: none;
}

.analysis-progress progress::-webkit-progress-bar {
  background: #e5ecee;
}

.analysis-progress progress::-webkit-progress-value {
  background: var(--primary);
  transition: width 240ms ease;
}

.analysis-progress progress::-moz-progress-bar {
  background: var(--primary);
}

.analysis-review {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.analysis-diff {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}

.analysis-diff span {
  min-width: 0;
  padding: 7px 5px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #f8fafb;
  text-align: center;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.analysis-diff strong {
  display: block;
  margin-top: 2px;
  color: var(--ink);
  font-size: 17px;
}

.analysis-warning {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.analysis-warning.suspicious {
  padding: 8px;
  border-radius: 7px;
  background: var(--warn-bg);
  color: var(--warn);
  font-weight: 800;
}

.analysis-preview-scroll {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 7px;
}

.analysis-preview-grid {
  min-width: 520px;
  display: grid;
  grid-template-columns: 64px repeat(5, minmax(82px, 1fr));
  background: var(--line);
  gap: 1px;
}

.analysis-preview-cell {
  min-height: 44px;
  padding: 5px;
  display: grid;
  place-items: center;
  background: #fff;
  text-align: center;
  font-size: 11px;
  line-height: 1.25;
  overflow-wrap: anywhere;
  white-space: pre-line;
}

.analysis-preview-cell.head {
  min-height: 34px;
  background: #f3f7f8;
  font-weight: 800;
}

.analysis-preview-cell.lunch {
  background: #f1f3f5;
}

.analysis-review-actions {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 8px;
}

.upload-button.busy {
  opacity: 0.65;
  cursor: wait;
}

button,
.upload-button {
  width: 100%;
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font-size: 15px;
  font-weight: 800;
  display: grid;
  place-items: center;
}

button.primary,
.upload-button.primary {
  border-color: var(--primary);
  background: var(--primary);
  color: #fff;
}

button.ghost {
  background: #f8fafb;
}

button.danger {
  border-color: #f0b8b8;
  background: #fff5f5;
  color: #b42318;
}

button.success {
  border-color: #a8dfbf;
  background: #eefaf3;
  color: #167449;
}

button.danger-soft {
  border-color: #efc6a5;
  background: #fff8f1;
  color: #9a4d08;
}

button.small {
  width: auto;
  min-height: 38px;
  padding: 0 12px;
  font-size: 13px;
}

.upload-button input {
  display: none;
}

.week-panel {
  padding: 14px;
  display: grid;
  gap: 12px;
  margin-bottom: 12px;
}

.week-head {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 12px;
}

.week-head h2 {
  font-size: 20px;
}

.week-head strong {
  padding: 8px 10px;
  border-radius: 8px;
  background: #edf7ff;
  color: #155b86;
  font-size: 13px;
  text-align: right;
  white-space: nowrap;
}

.week-controls,
.week-actions {
  display: grid;
  gap: 8px;
}

.week-controls {
  grid-template-columns: repeat(3, 1fr);
}

.week-date-label {
  grid-column: 1 / -1;
}

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

button:active,
.upload-button:active {
  transform: translateY(1px);
}

.hint-row {
  padding: 10px 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 12px;
}

.bulk-check {
  display: inline-grid;
  grid-template-columns: 20px auto;
  align-items: center;
  gap: 6px;
  color: var(--ink);
  white-space: nowrap;
}

.bulk-check input {
  width: 18px;
  min-height: 18px;
}

.workspace {
  display: grid;
  gap: 12px;
}

.panel {
  padding: 14px;
}

.timetable-panel {
  overflow: hidden;
}

.timetable-grid {
  display: grid;
  grid-template-columns: 72px repeat(5, minmax(92px, 1fr));
  gap: 1px;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--line);
}

.timecell {
  min-height: 76px;
  background: #fff;
  padding: 8px;
  display: grid;
  align-content: start;
  gap: 5px;
}

.timecell.head {
  min-height: 42px;
  align-content: center;
  justify-content: center;
  background: #f8fafb;
  color: var(--ink);
  font-size: 13px;
  font-weight: 800;
}

.timecell.period-head {
  background: #f8fafb;
  align-content: center;
}

.timecell.period-head strong {
  font-size: 13px;
}

.timecell.period-head span {
  color: var(--muted);
  font-size: 11px;
}

.timecell.slot.blank {
  color: #b4bec6;
  place-items: center;
  font-size: 13px;
}

.empty-slot-button {
  width: 100%;
  min-height: 44px;
  border: 1px dashed #cbd6dc;
  border-radius: 7px;
  background: #fbfdfd;
  color: #8a98a3;
  font-size: 20px;
  font-weight: 800;
}

.empty-slot-button:active {
  background: #eef6f5;
}

.timecell.lunch {
  background: #f3f5f6;
}

.slot-chip {
  width: 100%;
  min-height: 34px;
  border: 1px solid #c9d7dc;
  border-radius: 7px;
  background: #f7fbfb;
  color: var(--ink);
  padding: 6px 7px;
  display: grid;
  gap: 3px;
  text-align: left;
  font-size: 13px;
  line-height: 1.25;
  font-weight: 800;
  overflow-wrap: anywhere;
}

.slot-chip small {
  width: max-content;
  max-width: 100%;
  padding: 2px 6px;
  border-radius: 999px;
  background: rgba(22, 116, 73, 0.1);
  color: #167449;
  font-size: 10px;
  line-height: 1.2;
  font-weight: 900;
}

.slot-chip.warn {
  border-color: #e2b75c;
  background: #fff6df;
}

.slot-chip.done {
  border-color: #b9e6cd;
  background: #effaf4;
}

.slot-chip.registered {
  border-color: #86d4aa;
  background: #e8f8ef;
}

.slot-chip.name-color-0 {
  border-color: #8bc4ec;
  background: #edf7ff;
}

.slot-chip.name-color-1 {
  border-color: #9ed8b6;
  background: #effaf3;
}

.slot-chip.name-color-2 {
  border-color: #c4b5fd;
  background: #f5f2ff;
}

.slot-chip.name-color-3 {
  border-color: #f4bf7a;
  background: #fff6e8;
}

.slot-chip.name-color-4 {
  border-color: #7fd6cf;
  background: #eafbf9;
}

.slot-chip.name-color-5 {
  border-color: #f2a3b5;
  background: #fff1f4;
}

.slot-chip.name-color-6 {
  border-color: #a6c8ff;
  background: #f0f6ff;
}

.slot-chip.name-color-7 {
  border-color: #d5c16d;
  background: #fffbe8;
}

.slot-chip.name-color-8 {
  border-color: #b8d986;
  background: #f4fae9;
}

.slot-chip.name-color-9 {
  border-color: #d5a6e6;
  background: #fbf0ff;
}

.slot-chip.lunch-chip {
  border-color: #c8d0d6;
  background: #f1f3f5;
  color: #3d4b55;
}

.slot-chip.lunch-chip small {
  background: rgba(77, 88, 99, 0.12);
  color: #4d5863;
}

.slot-chip.archived {
  background: #f3fbf7;
  color: #456055;
}

.slot-chip.canceled {
  color: #8a97a3;
  background: #f3f5f6;
  text-decoration: line-through;
}

.slot-chip.selected {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(15, 118, 110, 0.16);
}

.edit-form {
  display: grid;
  gap: 10px;
}

.registration-panel {
  display: grid;
  gap: 8px;
  padding: 10px;
  border: 1px solid #b9d7d3;
  border-radius: 8px;
  background: #f3faf9;
}

.registration-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 13px;
}

.registration-panel-head span {
  min-width: 28px;
  padding: 3px 7px;
  border-radius: 999px;
  background: #dcefeb;
  color: var(--primary-dark);
  text-align: center;
  font-size: 12px;
  font-weight: 800;
}

.registration-list {
  display: grid;
  gap: 6px;
}

.registration-option {
  grid-template-columns: 22px 1fr;
  align-items: center;
  min-height: 42px;
  padding: 7px 8px;
  border: 1px solid #d4e6e3;
  border-radius: 7px;
  background: #fff;
  color: var(--ink);
}

.registration-option input {
  min-height: auto;
}

.registration-option span {
  display: grid;
  gap: 2px;
}

.registration-option small,
.registration-panel p {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
}

.edit-meta {
  padding: 10px;
  border-radius: 8px;
  background: #f7fafb;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.issue-panel {
  margin-top: 12px;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  align-items: end;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(18, 29, 38, 0.42);
}

.modal-sheet {
  position: relative;
  width: 100%;
  max-height: min(86dvh, 760px);
  overflow: auto;
  scroll-padding: 18px 0 38vh;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px 18px 0 0;
  padding: 10px 14px max(16px, env(safe-area-inset-bottom));
  box-shadow: 0 -18px 50px rgba(20, 35, 45, 0.22);
}

.modal-sheet:focus {
  outline: none;
}

.modal-handle {
  width: 42px;
  height: 4px;
  margin: 2px auto 12px;
  border-radius: 999px;
  background: #c6d1d7;
}

.modal-status-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: center;
}

.icon-button {
  width: 36px;
  min-height: 36px;
  border-radius: 999px;
  font-size: 22px;
  line-height: 1;
}

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.section-title span,
.status {
  min-width: 32px;
  padding: 5px 8px;
  border-radius: 999px;
  background: #eef4f5;
  text-align: center;
  font-weight: 800;
  font-size: 12px;
}

.cards {
  display: grid;
  gap: 10px;
}

.card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fff;
  display: grid;
  gap: 10px;
  text-align: left;
}

.card.warn {
  border-color: #e2b75c;
  background: #fffaf0;
}

.card-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: flex-start;
}

.card-head p {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.field-grid,
.card-options {
  display: grid;
  gap: 8px;
}

label {
  display: grid;
  gap: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

input {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 8px 10px;
  font-size: 15px;
  color: var(--ink);
}

.checks {
  grid-template-columns: 22px 1fr;
  align-items: center;
  color: var(--ink);
}

.checks input {
  min-height: auto;
}

.empty {
  color: var(--muted);
  font-size: 14px;
  padding: 12px 4px;
}

.log {
  white-space: pre-wrap;
  font-size: 12px;
  color: var(--muted);
  max-height: 160px;
  overflow: auto;
}

@media (min-width: 720px) {
  .actions {
    grid-template-columns: 1.4fr 1fr 0.8fr;
  }

  .week-panel {
    grid-template-columns: 1.05fr 1.2fr 1.45fr;
    align-items: end;
  }

  .week-head,
  .week-controls,
  .week-actions {
    min-width: 0;
  }

  .week-head {
    display: grid;
  }

  .week-head strong {
    text-align: left;
  }

  .week-date-label {
    grid-column: 1 / -1;
  }

  .week-actions {
    grid-template-columns: 1fr 1fr 1.1fr;
  }

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

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

  .card-options {
    grid-template-columns: 1fr 1fr 96px;
    align-items: center;
  }

  .modal {
    align-items: center;
    justify-items: center;
    padding: 24px;
  }

  .modal-sheet {
    width: min(620px, 100%);
    border-radius: 12px;
    padding: 14px 16px 16px;
    box-shadow: 0 24px 70px rgba(20, 35, 45, 0.28);
  }
}

@media (max-width: 520px) {
  .app {
    padding-inline: 10px;
  }

  .hero-panel,
  .hint-row {
    display: grid;
    text-align: left;
  }

  .hero-meta {
    text-align: left;
  }

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

  .stat {
    min-height: 68px;
    padding: 10px;
  }

  .stat strong {
    font-size: 22px;
  }
}
