:root {
  color-scheme: light;
  --bg: #f6f7f3;
  --panel: #ffffff;
  --panel-2: #fbfbf8;
  --line: #d8ddd1;
  --line-strong: #aeb8a6;
  --text: #1f2821;
  --muted: #647066;
  --accent: #0f766e;
  --accent-soft: #d9f0ec;
  --amber: #b7791f;
  --amber-soft: #fff0c6;
  --blue: #2563eb;
  --blue-soft: #e3ecff;
  --red: #b42318;
  --red-soft: #fde8e5;
  --green-soft: #e7f6df;
  --shadow: 0 10px 24px rgba(31, 40, 33, 0.08);
  --radius: 8px;
  font-family:
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Hiragino Sans",
    "Yu Gothic",
    sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 1180px;
  background: var(--bg);
  color: var(--text);
}

button,
input,
select {
  font: inherit;
}

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

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(12px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  display: grid;
  width: 40px;
  height: 40px;
  place-items: center;
  border: 1px solid #0c5f58;
  border-radius: var(--radius);
  background: var(--accent);
  color: white;
  font-weight: 800;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 18px;
  line-height: 1.2;
}

#statusLine {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
}

.icon-button {
  display: inline-grid;
  width: 36px;
  height: 36px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--panel);
  color: var(--text);
  cursor: pointer;
  font-size: 20px;
  line-height: 1;
}

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

.icon-button.danger:hover {
  border-color: var(--red);
  color: var(--red);
}

.file-input {
  display: none;
}

.icon-button.compact {
  width: 30px;
  height: 30px;
  font-size: 18px;
}

.nav-button {
  display: inline-grid;
  height: 36px;
  min-width: 104px;
  place-items: center;
  border: 1px solid var(--accent);
  border-radius: 7px;
  background: var(--accent);
  color: white;
  padding: 0 12px;
  font-size: 13px;
  font-weight: 750;
  text-decoration: none;
}

.nav-button:hover {
  filter: brightness(0.96);
}

select,
input {
  height: 36px;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: white;
  color: var(--text);
  padding: 0 10px;
}

#monthSelect {
  width: 112px;
}

.main-layout {
  display: grid;
  grid-template-columns: minmax(820px, 1fr) 330px;
  gap: 16px;
  padding: 16px;
}

.work-area,
.side-panel {
  min-width: 0;
}

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

.segmented {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
}

.tab-button {
  height: 32px;
  min-width: 72px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  padding: 0 14px;
  font-weight: 650;
}

.tab-button.active {
  background: var(--accent);
  color: white;
}

.summary-strip {
  display: flex;
  align-items: center;
  gap: 8px;
  overflow: hidden;
}

.metric {
  min-width: 92px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
}

.metric strong {
  display: block;
  font-size: 16px;
  line-height: 1.1;
}

.metric span {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 11px;
}

.grid-wrap {
  overflow: auto;
  height: calc(100vh - 118px);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.shift-grid {
  width: max-content;
  min-width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  table-layout: fixed;
}

.shift-grid th,
.shift-grid td {
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  height: 36px;
  padding: 0;
  text-align: center;
  vertical-align: middle;
}

.shift-grid thead th {
  position: sticky;
  top: 0;
  z-index: 8;
  background: #eef2ea;
  color: var(--text);
  font-size: 12px;
}

.shift-grid thead tr:first-child th {
  height: 34px;
  font-weight: 750;
}

.shift-grid thead tr:nth-child(2) th {
  top: 34px;
  height: 26px;
  color: var(--muted);
  font-weight: 600;
}

.shift-grid .name-col,
.shift-grid .summary-col {
  position: sticky;
  z-index: 9;
  background: var(--panel);
}

.shift-grid .name-col {
  left: 0;
  width: 164px;
  min-width: 164px;
  padding: 0 10px;
  text-align: left;
  font-weight: 700;
}

.shift-grid thead .name-col {
  z-index: 12;
  background: #e3eadc;
}

.shift-grid .summary-col {
  right: 0;
  width: 70px;
  min-width: 70px;
  font-weight: 700;
  background: #f7f8f4;
}

.shift-grid thead .summary-col {
  z-index: 12;
  background: #e3eadc;
}

.shift-grid tfoot th,
.shift-grid tfoot td {
  position: sticky;
  bottom: 0;
  z-index: 10;
  height: 34px;
  border-top: 1px solid var(--line-strong);
  background: #e7f2ef;
  color: var(--accent);
  font-size: 13px;
  font-weight: 850;
}

.shift-grid tfoot .name-col {
  z-index: 13;
  background: #d9eee9;
}

.shift-grid tfoot .summary-col {
  z-index: 13;
  background: #d9eee9;
}

.daily-count.weekend {
  background: #f0e9dc;
  color: var(--amber);
}

.daily-count.holiday {
  background: #f8dfdc;
  color: var(--red);
}

.day-col {
  width: 46px;
  min-width: 46px;
}

.day-col.weekend {
  background: #f4eee5;
}

.day-col.holiday {
  background: #f8e7e3;
}

.employee-meta {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 500;
}

.shift-cell {
  position: relative;
  width: 46px;
  height: 36px;
  border: 0;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  font-weight: 750;
}

.shift-cell:hover,
.shift-cell.selected {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

.shift-cell.manual {
  box-shadow: inset 0 -3px 0 var(--accent);
}

.shift-cell.conflict {
  background: var(--red-soft);
  color: var(--red);
}

.shift-cell.pending::after {
  position: absolute;
  right: 3px;
  top: 3px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--amber);
  content: "";
}

.code-A,
.code-B,
.code-C,
.code-D,
.code-E,
.code-F,
.code-G,
.code-I,
.code-CE,
.code-EF,
.code-BI {
  background: var(--green-soft);
}

.code-off,
.code-requested,
.code-paid {
  background: var(--amber-soft);
}

.code-paid {
  background: var(--blue-soft);
  color: var(--blue);
}

.code-other {
  background: #ece8f5;
}

.day-event {
  display: block;
  margin-top: 1px;
  color: var(--amber);
  font-size: 10px;
  font-weight: 700;
}

.side-panel {
  display: flex;
  flex-direction: column;
  gap: 10px;
  height: calc(100vh - 90px);
  overflow: hidden;
}

.side-tabs {
  position: sticky;
  top: 0;
  z-index: 5;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.side-tab {
  height: 32px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 12px;
  font-weight: 750;
}

.side-tab:hover {
  border-color: var(--line-strong);
  color: var(--text);
}

.side-tab.active {
  background: var(--accent);
  color: white;
}

.side-tab.is-hidden {
  display: none;
}

.side-panel-view {
  display: none;
  min-height: 0;
  overflow: auto;
}

.side-panel-view.active {
  display: block;
  flex: 1;
}

.panel-section {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.panel-heading {
  display: flex;
  min-height: 44px;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  background: var(--panel-2);
}

.panel-heading h2 {
  font-size: 14px;
}

.panel-heading span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

.panel-actions,
.request-actions {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.field-stack,
.request-form {
  display: grid;
  gap: 10px;
  padding: 12px;
}

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

label input,
label select,
label textarea {
  width: 100%;
  color: var(--text);
}

textarea {
  min-height: 142px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: white;
  padding: 9px 10px;
  font: inherit;
  line-height: 1.45;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.check-row input {
  width: 16px;
  height: 16px;
}

.cell-note {
  min-height: 20px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.copy-tools {
  display: grid;
  gap: 8px;
  padding: 9px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--panel-2);
}

.copy-status {
  min-height: 18px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
  line-height: 1.4;
}

.copy-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.mini-button {
  height: 32px;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: white;
  color: var(--text);
  cursor: pointer;
  font-size: 12px;
  font-weight: 750;
}

.mini-button:hover:not(:disabled) {
  border-color: var(--accent);
  color: var(--accent);
}

.mini-button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.mini-button.wide {
  background: var(--accent-soft);
  border-color: #b7d7d2;
}

.course-detail {
  display: grid;
  gap: 8px;
}

.course-card {
  display: grid;
  gap: 6px;
  padding: 9px 10px;
  border: 1px solid #b7d7d2;
  border-radius: 7px;
  background: var(--accent-soft);
}

.course-card strong {
  font-size: 13px;
}

.course-card span,
.course-card li {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.course-card ul {
  margin: 0;
  padding-left: 18px;
}

.request-list,
.warning-list {
  display: grid;
  gap: 8px;
  padding: 0 12px 12px;
}

.request-item,
.warning-item {
  display: grid;
  gap: 3px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--panel-2);
}

.request-item {
  cursor: default;
}

.request-item:hover {
  border-color: var(--line-strong);
}

.request-item header,
.warning-item header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.request-item strong,
.warning-item strong {
  font-size: 13px;
}

.request-item span,
.warning-item span {
  color: var(--muted);
  font-size: 12px;
}

.request-item.approved {
  border-color: #a6d8cf;
  background: var(--accent-soft);
}

.request-item.pending {
  border-color: #ead18e;
  background: var(--amber-soft);
}

.request-item.rejected {
  opacity: 0.65;
}

.warning-item {
  border-color: #efb4ad;
  background: var(--red-soft);
}

.tiny-action {
  width: 24px;
  height: 24px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: white;
  cursor: pointer;
}

.tiny-action:disabled {
  cursor: not-allowed;
  opacity: 0.35;
}

.wide-button {
  height: 36px;
  border: 1px solid var(--accent);
  border-radius: 7px;
  background: var(--accent);
  color: white;
  cursor: pointer;
  font-weight: 750;
}

.wide-button:hover {
  filter: brightness(0.96);
}

.wide-button.secondary {
  border-color: var(--line-strong);
  background: white;
  color: var(--text);
}

.wide-button.danger-button {
  border-color: #d9aaa4;
  background: var(--red-soft);
  color: var(--red);
}

.button-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.rule-block {
  display: grid;
  gap: 6px;
}

.rule-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

.weekday-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}

.weekday-grid label {
  display: flex;
  height: 32px;
  align-items: center;
  justify-content: center;
  gap: 4px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: white;
  color: var(--text);
}

.weekday-grid input {
  width: 14px;
  height: 14px;
}

.rule-two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

body.employee-page {
  min-width: 0;
}

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

.employee-topbar {
  flex-wrap: wrap;
}

.employee-layout {
  display: grid;
  grid-template-columns: minmax(320px, 420px) minmax(360px, 1fr);
  gap: 16px;
  width: min(1180px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 16px 0 24px;
}

.employee-panel {
  min-width: 0;
  overflow: hidden;
}

.employee-page .request-form {
  gap: 12px;
  padding: 14px;
}

.employee-page label {
  font-size: 13px;
}

.employee-page select,
.employee-page input {
  height: 46px;
  font-size: 16px;
}

.employee-page textarea {
  min-height: 92px;
  font-size: 16px;
}

.employee-hidden-field {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.employee-type-toggle {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.type-button {
  height: 52px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  background: white;
  color: var(--text);
  cursor: pointer;
  font-size: 16px;
  font-weight: 850;
  touch-action: manipulation;
}

.type-button.active {
  border-color: var(--accent);
  background: var(--accent);
  color: white;
}

.employee-date-panel,
.employee-range-panel {
  display: grid;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--panel-2);
}

.employee-date-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
}

.employee-date-heading strong {
  color: var(--accent);
  font-size: 14px;
}

.employee-date-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 5px;
}

.employee-date-button {
  position: relative;
  display: grid;
  min-width: 0;
  min-height: 58px;
  align-content: center;
  justify-items: center;
  gap: 2px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: white;
  color: var(--text);
  cursor: pointer;
  touch-action: manipulation;
}

.employee-date-button span {
  font-size: 16px;
  font-weight: 900;
  line-height: 1;
}

.employee-date-button small {
  color: var(--muted);
  font-size: 10px;
  font-weight: 750;
}

.employee-date-button.saturday {
  background: #f4eee5;
}

.employee-date-button.sunday {
  border-color: #efb4ad;
  background: #f8e7e3;
}

.employee-date-button.selected {
  border-color: var(--accent);
  background: var(--accent);
  color: white;
}

.employee-date-button.selected small {
  color: rgba(255, 255, 255, 0.84);
}

.employee-date-button.requested::after {
  position: absolute;
  right: 5px;
  top: 5px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--amber);
  content: "";
}

.employee-range-panel summary {
  min-height: 28px;
  cursor: pointer;
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
}

.employee-shift-panel {
  grid-column: 1 / -1;
}

.employee-list {
  max-height: 390px;
  overflow: auto;
}

.employee-shift-summary {
  padding: 12px 12px 0;
}

.employee-shift-person {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--panel-2);
}

.employee-shift-person strong {
  font-size: 14px;
}

.employee-shift-person span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

.employee-shift-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(72px, 1fr));
  gap: 8px;
  padding: 12px;
}

.employee-day {
  display: grid;
  min-height: 76px;
  align-content: center;
  justify-items: center;
  gap: 3px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: white;
}

.employee-day.weekend {
  background: #f4eee5;
}

.employee-day.holiday {
  border-color: #efb4ad;
  background: #f8e7e3;
}

.employee-day.work {
  border-color: #b7d7d2;
  background: var(--green-soft);
}

.employee-day.off {
  border-color: #ead18e;
  background: var(--amber-soft);
}

.employee-day span {
  font-size: 13px;
  font-weight: 800;
}

.employee-day small,
.employee-day em {
  color: var(--muted);
  font-size: 11px;
  font-style: normal;
  font-weight: 650;
}

.employee-day strong {
  font-size: 17px;
}

@media (max-width: 1280px) {
  body {
    min-width: 980px;
  }

  body.employee-page {
    min-width: 0;
  }

  .main-layout {
    grid-template-columns: minmax(680px, 1fr) 300px;
  }

  .summary-strip .metric:nth-child(n + 4) {
    display: none;
  }
}

@media (max-width: 900px) {
  body.employee-page {
    min-width: 0;
  }

  .employee-topbar {
    align-items: flex-start;
  }

  .employee-topbar .toolbar {
    width: 100%;
    flex-wrap: wrap;
  }

  .employee-layout {
    grid-template-columns: 1fr;
    width: min(100% - 20px, 680px);
    padding-top: 10px;
  }

  .employee-shift-person {
    align-items: flex-start;
    flex-direction: column;
    gap: 4px;
  }
}

@media (max-width: 560px) {
  .employee-page .topbar {
    gap: 10px;
    padding: 10px;
  }

  .employee-page .brand-mark {
    width: 36px;
    height: 36px;
  }

  .employee-page .toolbar {
    display: grid;
    grid-template-columns: 44px minmax(0, 1fr) 44px 44px;
    gap: 8px;
  }

  .employee-page .icon-button {
    width: 44px;
    height: 44px;
  }

  .employee-page #employeeMonthSelect {
    width: 100%;
  }

  .employee-page .button-row {
    grid-template-columns: 1fr;
  }

  .employee-page .nav-button {
    grid-column: 1 / -1;
    height: 44px;
    min-width: 100%;
  }

  .employee-layout {
    width: calc(100% - 12px);
    gap: 10px;
  }

  .employee-page .panel-heading {
    min-height: 48px;
    padding: 10px;
  }

  .employee-page .request-form {
    padding: 10px;
  }

  .employee-date-panel,
  .employee-range-panel {
    padding: 8px;
  }

  .employee-date-grid {
    gap: 4px;
  }

  .employee-date-button {
    min-height: 54px;
  }

  .employee-submit-row {
    position: sticky;
    bottom: 8px;
    z-index: 3;
    padding: 8px;
    margin: 0 -8px -8px;
    border: 1px solid var(--line);
    border-radius: 7px;
    background: rgba(255, 255, 255, 0.96);
    box-shadow: var(--shadow);
  }

  .employee-submit-row .wide-button {
    height: 50px;
    font-size: 16px;
  }

  .employee-shift-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 6px;
  }

  .employee-day {
    min-height: 68px;
  }
}
