:root {
  --bg: #ffffff;
  --surface: #ffffff;
  --surface-soft: #f7f8fa;
  --ink: #202124;
  --muted: #80868b;
  --line: #eceff3;
  --line-strong: #d5d9df;
  --primary: #1a73e8;
  --primary-ink: #ffffff;
  --danger: #c5221f;
  --pink: #d95b75;
  --day: #ffd60a;
  --night: #3d3d3f;
  --resource: #18c37e;
  --radius: 8px;
  --shadow: 0 14px 35px rgba(32, 33, 36, 0.18);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
  width: 100%;
  overflow-x: hidden;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family:
    "Segoe UI",
    "Malgun Gothic",
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    sans-serif;
  letter-spacing: 0;
}

body.dark-mode {
  --bg: #111315;
  --surface: #191c20;
  --surface-soft: #20242a;
  --ink: #f1f3f4;
  --muted: #a6adb6;
  --line: #2c333a;
  --line-strong: #3b434c;
  --shadow: 0 14px 35px rgba(0, 0, 0, 0.34);
}

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

button,
.file-button {
  min-height: 44px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  padding: 8px 12px;
  touch-action: manipulation;
}

button:hover,
.file-button:hover {
  background: #f8fafd;
}

button.primary {
  border-color: var(--primary);
  background: var(--primary);
  color: var(--primary-ink);
}

button.danger {
  border-color: #f0b4b2;
  background: #fff8f8;
  color: var(--danger);
}

.secondary {
  background: var(--surface);
}

.app-shell {
  min-height: 100vh;
  max-width: 100%;
  background: var(--bg);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  height: 78px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  backdrop-filter: blur(10px);
  overflow: hidden;
}

.topbar-left {
  display: flex;
  flex: 1 1 auto;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.topbar h1 {
  margin: 0;
  font-size: clamp(24px, 6vw, 32px);
  line-height: 1.1;
  font-weight: 800;
  white-space: nowrap;
}

.topbar p {
  max-width: min(56vw, 520px);
  margin: 5px 0 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
}

.toolbar-icon,
.icon-button {
  display: inline-grid;
  place-items: center;
  min-width: 44px;
  min-height: 44px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  padding: 0;
  color: #3f4246;
  font-size: 24px;
  font-weight: 800;
}

.toolbar-icon:hover,
.icon-button:hover {
  background: #f1f3f4;
}

.toolbar-icon.text-icon {
  min-width: 54px;
  border-radius: 22px;
  font-size: 14px;
}

.settings-backdrop {
  position: fixed;
  inset: 0;
  z-index: 39;
  background: rgba(32, 33, 36, 0.32);
}

.settings-panel {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 40;
  display: flex;
  width: min(330px, calc(100vw - 34px));
  transform: translateX(-105%);
  flex-direction: column;
  gap: 10px;
  padding: 12px;
  border-right: 1px solid var(--line);
  background: var(--surface);
  box-shadow: var(--shadow);
  overflow: auto;
  transition: transform 160ms ease;
}

body.settings-open .settings-panel {
  transform: translateX(0);
}

.settings-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 4px 2px 8px;
}

.settings-head strong {
  display: block;
  font-size: 18px;
}

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

.settings-panel section,
.selected-panel {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 12px;
}

.settings-panel h2,
.selected-panel h2,
.event-form h2 {
  margin: 0 0 10px;
  font-size: 15px;
  line-height: 1.3;
}

label {
  display: grid;
  gap: 6px;
  margin-bottom: 10px;
  color: #5f6368;
  font-size: 12px;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  padding: 9px 10px;
  outline: none;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(26, 115, 232, 0.14);
}

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

.check-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  margin-top: 18px;
  color: var(--ink);
}

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

.quick-shifts,
.pattern-preview,
.legend,
.team-status,
.pattern-tools,
.stacked-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.quick-shifts button,
.pattern-chip,
.legend-item,
.team-pill,
.event-pill {
  flex: 0 0 auto;
  min-height: 32px;
  border-radius: var(--radius);
  border: 1px solid rgba(32, 33, 36, 0.12);
  padding: 6px 9px;
  color: #202124;
  line-height: 1.1;
}

.pattern-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 800;
}

.pattern-index {
  color: rgba(32, 33, 36, 0.58);
  font-size: 11px;
  font-weight: 800;
}

.chip-remove {
  display: inline-grid;
  place-items: center;
  width: 20px;
  min-height: 20px;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.7);
  padding: 0;
  font-size: 14px;
  font-weight: 900;
}

.team-pill.mine {
  box-shadow: inset 0 0 0 2px rgba(26, 115, 232, 0.35);
}

.custom-add-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  margin: 10px 0;
}

.pattern-line-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  margin-bottom: 10px;
}

.pattern-tools,
.stacked-actions {
  margin-top: 10px;
}

.pattern-tools {
  display: grid;
  grid-template-columns: 1fr 1fr;
}

.stacked-actions > * {
  flex: 1 1 110px;
  text-align: center;
}

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

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

.content {
  display: flex;
  flex-direction: column;
  min-width: 0;
  max-width: 100%;
  overflow-x: hidden;
}

.status-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  background: #ffffff;
}

.status-card {
  display: grid;
  min-width: 0;
  min-height: 54px;
  justify-items: start;
  align-content: center;
  gap: 3px;
  border-color: var(--line);
  background: var(--surface-soft);
  text-align: left;
}

.status-card span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.status-card strong {
  max-width: 100%;
  overflow: hidden;
  color: var(--ink);
  font-size: 14px;
  font-weight: 900;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.insight-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.insight-card {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
  padding: 9px 10px;
}

.insight-card span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.insight-card strong {
  display: block;
  margin-top: 3px;
  overflow: hidden;
  color: var(--ink);
  font-size: 14px;
  font-weight: 900;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.setting-note {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.overtime-strip {
  display: grid;
  grid-template-columns: minmax(210px, 1.2fr) repeat(3, minmax(0, 0.7fr));
  gap: 8px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.overtime-main-card,
.overtime-metric {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
  padding: 9px 10px;
  text-align: left;
}

.overtime-main-card {
  display: grid;
  align-content: center;
  gap: 4px;
}

.overtime-main-card span {
  width: fit-content;
  border-radius: 999px;
  padding: 4px 8px;
  color: #ffffff;
  font-size: 11px;
  font-weight: 900;
}

.overtime-main-card strong {
  color: var(--ink);
  font-size: 18px;
  font-weight: 950;
}

.overtime-main-card small,
.overtime-metric small {
  display: block;
  overflow: hidden;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.overtime-main-card.plus-month span {
  background: #1a73e8;
}

.overtime-main-card.minus-month span {
  background: #d34d63;
}

.overtime-main-card.zero-month span {
  background: #137333;
}

.overtime-metric span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.overtime-metric strong {
  display: block;
  margin-top: 3px;
  color: var(--ink);
  font-size: 14px;
  font-weight: 900;
}

.overtime-detail-panel {
  display: block;
  border-bottom: 1px solid var(--line);
  background: #fbfcff;
}

.detail-summary {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  min-height: 58px;
  padding: 9px 10px;
  cursor: pointer;
  list-style: none;
  touch-action: manipulation;
}

.detail-summary::-webkit-details-marker {
  display: none;
}

.detail-summary h2 {
  margin: 0;
  font-size: 17px;
}

.detail-summary span,
.detail-summary-right span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.detail-summary-right {
  display: flex;
  align-items: center;
  gap: 7px;
}

.detail-summary-right::after {
  color: var(--muted);
  content: "▾";
  font-size: 14px;
  font-weight: 900;
  transition: transform 0.16s ease;
}

.overtime-detail-panel[open] .detail-summary-right::after {
  transform: rotate(180deg);
}

.overtime-detail-body {
  display: grid;
  gap: 12px;
  padding: 0 10px 10px;
}

.limit-control {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  align-items: center;
  justify-content: flex-end;
}

.limit-control > span {
  color: #4b5563;
  font-size: 12px;
  font-weight: 900;
}

#overtimeInlineBadge {
  border-radius: 6px;
  padding: 5px 8px;
  color: #ffffff;
  font-size: 12px;
}

#overtimeInlineBadge.plus-month {
  background: #1a73e8;
}

#overtimeInlineBadge.minus-month {
  background: #d34d63;
}

#overtimeInlineBadge.zero-month {
  background: #137333;
}

.limit-control select,
.limit-control input {
  min-height: 38px;
  max-width: 160px;
}

.overtime-time-grid,
.overtime-count-grid,
.direct-resource-grid,
.leave-grid {
  display: grid;
  gap: 9px;
}

.overtime-time-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  border-radius: var(--radius);
  background: #eef7ff;
  padding: 10px;
}

.overtime-count-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  border-radius: var(--radius);
  background: #f7f8fa;
  padding: 10px;
}

.overtime-detail-panel label {
  gap: 5px;
}

.overtime-detail-panel label span {
  color: #53606f;
  font-size: 11px;
  font-weight: 900;
}

.overtime-detail-panel label small {
  color: var(--muted);
  font-size: 10px;
}

.overtime-detail-panel input[readonly] {
  background: #eef1ff;
  color: #3851c9;
  font-weight: 900;
}

.wide-field {
  grid-column: 1 / -1;
}

.direct-resource-toggle {
  display: flex;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  min-height: 42px;
  border-top: 1px dashed var(--line-strong);
  padding-top: 8px;
}

.direct-resource-toggle input {
  width: 18px;
  height: 18px;
}

.direct-resource-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.direct-resource-grid.is-disabled {
  opacity: 0.45;
}

.direct-resource-grid.is-disabled input {
  pointer-events: none;
}

.holiday-auto-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 120px;
  gap: 10px;
  align-items: center;
  border: 1px solid #f1dc7a;
  border-radius: var(--radius);
  background: #fffbe7;
  padding: 10px;
}

.holiday-auto-row strong,
.leave-head strong {
  display: block;
  color: var(--ink);
  font-size: 13px;
}

.holiday-auto-row span,
.leave-head span {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.leave-deduction-box {
  display: grid;
  gap: 10px;
  border: 1px solid #f5c5cd;
  border-radius: var(--radius);
  background: #fff5f7;
  padding: 10px;
}

.leave-head {
  display: grid;
  gap: 4px;
}

.leave-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.holiday-list-box {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 8px 10px;
}

.holiday-list-box summary {
  cursor: pointer;
  color: #4b5563;
  font-size: 12px;
  font-weight: 900;
}

#holidayListText {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

#holidayListText span {
  border-radius: 999px;
  background: var(--surface-soft);
  padding: 5px 8px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.calendar-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  max-width: 100%;
  min-height: 42px;
  padding: 0 10px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  overflow: hidden;
}

.legend {
  justify-content: center;
  min-width: 0;
  overflow: hidden;
}

.legend-item {
  min-height: 26px;
  padding: 5px 8px;
  border: 0;
  font-size: 12px;
  font-weight: 800;
}

.print-heading {
  display: none;
}

.calendar-grid {
  min-width: 0;
  max-width: 100%;
  display: grid;
  grid-template-columns: 1fr;
  background: var(--bg);
  overflow: hidden;
  touch-action: pan-y;
}

.month-card {
  min-width: 0;
  overflow: hidden;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  touch-action: pan-y;
}

.month-header {
  display: none;
}

.weekdays,
.days-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  width: 100%;
  min-width: 0;
}

.weekday {
  display: grid;
  place-items: center;
  min-width: 0;
  min-height: 32px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  color: #4f5357;
  text-align: center;
  font-size: 13px;
  font-weight: 700;
}

.weekday.sunday {
  color: #c24646;
}

.weekday.saturday {
  color: #2d76b8;
}

.days-grid {
  grid-auto-rows: minmax(116px, 1fr);
  touch-action: pan-y;
}

.day-cell {
  position: relative;
  display: block;
  width: 100%;
  min-width: 0;
  min-height: 116px;
  border: 0;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  background: var(--surface);
  color: var(--ink);
  padding: 4px 5px;
  cursor: pointer;
  text-align: left;
  touch-action: pan-y;
}

.day-cell:nth-child(7n) {
  border-right: none;
}

.day-cell.empty {
  cursor: default;
  background: var(--surface-soft);
}

.day-cell.selected {
  background: #e8f2ff;
  outline: 2px solid #d34d63;
  outline-offset: -2px;
}

.day-cell.today .date-number {
  background: #d34d63;
  color: #ffffff;
}

.date-line {
  position: absolute;
  top: 4px;
  right: 5px;
  left: 5px;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 4px;
  min-height: 20px;
  pointer-events: none;
}

.date-number {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  border-radius: 3px;
  color: #5f6368;
  font-size: 13px;
  font-weight: 700;
  line-height: 1;
}

.holiday-label {
  justify-self: end;
  max-width: 100%;
  overflow: hidden;
  color: #c24646;
  font-size: 10px;
  font-weight: 800;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.main-shift {
  display: grid;
  place-items: center;
  width: min(74px, 16vw);
  min-width: 48px;
  aspect-ratio: 1;
  margin: 20px auto 0;
  border-radius: 50%;
  border: 0;
  text-align: center;
  font-size: clamp(18px, 4vw, 24px);
  font-weight: 900;
  line-height: 1;
}

.main-shift small {
  display: none;
}

.main-shift.shift-day {
  background: var(--day);
  color: #2d2d2d;
}

.main-shift.shift-night {
  background: var(--night);
  color: #ffffff;
}

.main-shift.shift-off,
.main-shift.shift-rest {
  width: auto;
  min-width: 0;
  aspect-ratio: auto;
  margin-top: 26px;
  background: transparent;
  color: var(--pink);
  font-size: clamp(18px, 4vw, 22px);
}

.main-shift.shift-duty,
.main-shift.shift-resource,
.main-shift.shift-leave,
.main-shift.shift-edu,
.main-shift.shift-other {
  width: auto;
  min-width: 42px;
  height: auto;
  min-height: 34px;
  aspect-ratio: auto;
  margin-top: 30px;
  border-radius: var(--radius);
  padding: 6px 8px;
  font-size: 14px;
}

.main-shift.shift-flex,
.main-shift.shift-day-resource,
.main-shift.shift-night-resource {
  width: min(74px, 16vw);
  min-width: 48px;
  aspect-ratio: 1;
  margin-top: 20px;
  border-radius: 50%;
  padding: 0;
  font-size: clamp(16px, 3.6vw, 21px);
}

.main-shift.shift-flex {
  background: #dff2a3;
  color: #202124;
}

.main-shift.shift-day-resource {
  background: #bff4d8;
  color: #202124;
}

.main-shift.shift-night-resource {
  background: #3d3d3f;
  color: #ffffff;
}

.other-teams {
  margin-top: 6px;
  display: grid;
  gap: 3px;
}

.other-team {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.78);
  padding: 3px 4px;
  font-size: 10px;
  font-weight: 800;
}

.cell-events {
  position: absolute;
  right: 4px;
  bottom: 4px;
  left: 4px;
  display: grid;
  gap: 3px;
}

.event-pill {
  display: block;
  min-height: 22px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  font-size: 10px;
  font-weight: 900;
}

.selected-panel {
  display: grid;
  grid-template-columns: minmax(150px, 0.7fr) minmax(220px, 1.3fr) auto;
  gap: 10px;
  align-items: start;
  min-width: 0;
  max-width: calc(100vw - 20px);
  margin: 10px;
  border-color: var(--line);
  background: var(--surface);
  overflow: hidden;
}

.selected-panel h2 {
  margin-bottom: 0;
  font-size: 16px;
}

.selected-meta {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.selected-helper {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.selected-helper span {
  min-height: 28px;
  border-radius: 999px;
  background: var(--surface-soft);
  padding: 6px 9px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.eyebrow {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.selected-quick-actions {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  min-width: 0;
  gap: 8px;
}

.selected-quick-actions button {
  display: grid;
  min-width: 0;
  min-height: 54px;
  align-content: center;
  justify-items: start;
  gap: 3px;
  border-color: transparent;
  padding: 8px 10px;
  color: #202124;
  overflow: hidden;
  text-align: left;
  font-weight: 900;
}

.selected-quick-actions button.primary-action {
  outline: 2px solid rgba(26, 115, 232, 0.35);
  outline-offset: -2px;
}

.selected-quick-actions small {
  color: rgba(32, 33, 36, 0.68);
  font-size: 11px;
  font-weight: 800;
}

.selected-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: flex-end;
}

.selected-actions button {
  flex: 1 1 72px;
}

.event-list {
  grid-column: 1 / -1;
  display: grid;
  gap: 6px;
}

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

.event-row strong {
  display: block;
  font-size: 13px;
}

.event-row span {
  color: var(--muted);
  font-size: 12px;
}

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

.shift-day {
  background: #ffdf42;
}

.shift-night {
  background: #e8eaed;
}

.shift-off,
.shift-rest {
  background: #fff4f6;
  color: var(--pink);
}

.shift-duty {
  background: #ffd2dc;
}

.shift-flex {
  background: #e5f2b5;
}

.shift-resource {
  background: #c7f7e1;
}

.shift-day-resource {
  background: #bff4d8;
}

.shift-night-resource {
  background: #d8d7ff;
}

.shift-leave {
  background: #c8f2ee;
}

.shift-edu {
  background: #d8defa;
}

.shift-other {
  background: #e7eaee;
}

dialog {
  width: min(480px, calc(100vw - 28px));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 0;
}

dialog::backdrop {
  background: rgba(32, 33, 36, 0.44);
}

.event-form {
  padding: 16px;
}

.quick-event-buttons {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin: 0 0 12px;
}

.quick-event-buttons button {
  min-width: 0;
  min-height: 48px;
  border-color: var(--line);
  background: var(--surface-soft);
  font-weight: 900;
}

.event-form header,
.event-form footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.event-form footer {
  justify-content: flex-end;
  margin-top: 10px;
}

.alarm-dialog {
  width: min(620px, calc(100vw - 24px));
}

.alarm-form {
  display: grid;
  gap: 10px;
  background: #f2f3f5;
}

.alarm-card {
  display: grid;
  gap: 12px;
  border: 0;
  border-radius: 12px;
  background: #ffffff;
  padding: 14px;
}

.alarm-card h3 {
  margin: 0;
  color: #4d5156;
  font-size: 13px;
}

.alarm-master-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.alarm-master-row strong {
  display: block;
  font-size: 16px;
}

.alarm-master-row span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.switch-row {
  position: relative;
  display: inline-flex;
  width: 54px;
  height: 32px;
  margin: 0;
  flex: 0 0 auto;
}

.switch-row input {
  position: absolute;
  inset: 0;
  opacity: 0;
}

.switch-row span {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  background: #c7c9cc;
  transition: background 120ms ease;
}

.switch-row span::after {
  position: absolute;
  top: 4px;
  left: 4px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 1px 3px rgba(32, 33, 36, 0.24);
  content: "";
  transition: transform 120ms ease;
}

.switch-row input:checked + span {
  background: var(--primary);
}

.switch-row input:checked + span::after {
  transform: translateX(22px);
}

.alarm-shift-row {
  display: flex;
  gap: 10px;
}

.shift-toggle {
  position: relative;
  display: inline-grid;
  width: 50px;
  height: 50px;
  margin: 0;
  place-items: center;
  border: 2px solid transparent;
  border-radius: 50%;
  color: #202124;
  font-size: 21px;
  font-weight: 900;
}

.shift-toggle input {
  position: absolute;
  inset: 0;
  opacity: 0;
}

.shift-toggle:has(input:not(:checked)) {
  opacity: 0.25;
  filter: grayscale(1);
}

.three-fields {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

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

.alarm-preset-row button {
  min-width: 0;
  background: var(--surface-soft);
  font-weight: 900;
}

.status-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.status-pill {
  display: inline-flex;
  min-height: 28px;
  align-items: center;
  border-radius: 999px;
  padding: 5px 9px;
  font-size: 12px;
  font-weight: 800;
}

.status-pill.ok {
  background: #dff7e8;
  color: #137333;
}

.status-pill.warn {
  background: #fff3cd;
  color: #8a5a00;
}

.compact-actions {
  margin-top: 0;
}

.guide-list,
.upcoming-list {
  display: grid;
  gap: 7px;
  margin: 0;
  padding-left: 18px;
  color: #5f6368;
  font-size: 12px;
}

.upcoming-list {
  padding-left: 0;
  list-style: none;
}

.upcoming-list li {
  display: grid;
  gap: 2px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 7px;
}

.upcoming-list li:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.upcoming-list strong {
  color: var(--ink);
  font-size: 13px;
}

.upcoming-list span {
  color: var(--muted);
  font-size: 12px;
}

.toast-host {
  position: fixed;
  right: max(14px, env(safe-area-inset-right));
  bottom: max(14px, env(safe-area-inset-bottom));
  left: max(14px, env(safe-area-inset-left));
  z-index: 70;
  display: grid;
  justify-items: center;
  pointer-events: none;
}

.toast {
  display: flex;
  width: min(420px, 100%);
  min-height: 48px;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-radius: var(--radius);
  background: rgba(32, 33, 36, 0.94);
  color: #ffffff;
  padding: 10px 12px 10px 14px;
  box-shadow: var(--shadow);
  pointer-events: auto;
}

.toast span {
  min-width: 0;
  overflow: hidden;
  font-size: 14px;
  font-weight: 800;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.toast button {
  min-height: 36px;
  border-color: transparent;
  background: #ffffff;
  color: #1a73e8;
  font-size: 13px;
  font-weight: 900;
}

@media (min-width: 900px) {
  .topbar {
    height: 86px;
    padding: 14px 22px;
  }

  .calendar-grid {
    padding: 0;
  }

  .days-grid {
    grid-auto-rows: minmax(128px, 1fr);
  }

  .day-cell {
    min-height: 128px;
  }
}

@media (min-width: 840px) {
  .content {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(300px, 360px);
    grid-template-rows: auto auto auto;
    align-items: start;
  }

  .calendar-toolbar,
  .status-strip,
  .insight-strip,
  .overtime-strip,
  .overtime-detail-panel,
  .print-heading,
  .calendar-grid {
    grid-column: 1;
  }

  .calendar-toolbar {
    position: relative;
    top: auto;
    z-index: 2;
    grid-row: 1;
  }

  .calendar-grid {
    grid-row: 2;
  }

  .status-strip {
    grid-row: 3;
  }

  .insight-strip {
    grid-row: 4;
  }

  .overtime-strip {
    grid-row: 5;
  }

  .overtime-detail-panel {
    grid-row: 6;
  }

  .selected-panel {
    position: sticky;
    top: 88px;
    grid-column: 2;
    grid-row: 1 / span 6;
    grid-template-columns: 1fr;
    max-height: calc(100dvh - 112px);
    margin: 10px 12px 10px 0;
    overflow: auto;
    box-shadow: 0 8px 22px rgba(32, 33, 36, 0.08);
  }

  .selected-actions {
    justify-content: stretch;
  }

  .selected-actions .primary {
    width: 100%;
  }

  .selected-actions .secondary {
    flex: 1 1 0;
  }
}

@media (min-width: 1100px) {
  .content {
    grid-template-columns: minmax(0, 1fr) minmax(330px, 390px);
  }

  .calendar-grid {
    grid-template-columns: repeat(auto-fit, minmax(520px, 1fr));
    gap: 10px;
    padding: 10px;
  }

  .month-card {
    border: 1px solid var(--line);
    border-radius: var(--radius);
  }

  .month-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    min-height: 40px;
    padding: 8px 10px;
    border-bottom: 1px solid var(--line);
  }

  .month-header h2 {
    margin: 0;
    font-size: 16px;
  }

  .month-header span {
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
  }
}

@media (min-width: 900px) {
  .calendar-toolbar {
    top: auto;
  }

  .selected-panel {
    top: 96px;
  }
}

@media (max-width: 839px) {
  .calendar-toolbar {
    order: 1;
  }

  .calendar-grid {
    order: 2;
  }

  .selected-panel {
    order: 3;
  }

  .status-strip {
    order: 4;
  }

  .insight-strip {
    order: 5;
  }

  .overtime-strip {
    order: 6;
  }

  .overtime-detail-panel {
    order: 7;
  }

  .print-heading {
    order: 8;
  }
}

@media (max-width: 700px) {
  .topbar {
    height: 72px;
    padding: 10px 12px;
  }

  .topbar p {
    display: none;
  }

  .topbar-actions {
    gap: 2px;
  }

  .toolbar-icon {
    min-width: 40px;
    min-height: 40px;
  }

  .toolbar-icon.text-icon {
    min-width: 46px;
  }

  .calendar-toolbar {
    min-height: 36px;
    padding: 0 6px;
  }

  .status-strip {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    padding: 7px 8px;
    scrollbar-width: none;
  }

  .status-strip::-webkit-scrollbar {
    display: none;
  }

  .status-card {
    flex: 0 0 112px;
    min-height: 50px;
    padding: 7px 9px;
  }

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

  .legend-item {
    padding: 4px 5px;
    font-size: 11px;
  }

  .weekday {
    min-height: 28px;
    font-size: 12px;
  }

  .days-grid {
    grid-auto-rows: minmax(102px, 1fr);
  }

  .day-cell {
    min-height: 102px;
    padding: 3px;
  }

  .date-number {
    min-width: 18px;
    height: 18px;
    font-size: 12px;
  }

  .holiday-label {
    max-width: 38px;
    font-size: 9px;
  }

  .main-shift {
    width: min(62px, 14vw);
    min-width: 42px;
    margin-top: 16px;
  }

  .main-shift.shift-off,
  .main-shift.shift-rest {
    margin-top: 20px;
  }

  .field-grid,
  .custom-add-row,
  .pattern-line-row,
  .selected-panel {
    grid-template-columns: 1fr;
  }

  .custom-add-row button,
  .pattern-line-row button {
    width: 100%;
  }

  .pattern-preview {
    display: grid;
    grid-template-columns: 1fr;
  }

  .pattern-chip {
    width: 100%;
    justify-content: space-between;
  }

  .selected-panel {
    margin: 8px;
  }

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

  .selected-actions {
    justify-content: flex-start;
  }

  .insight-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    padding: 7px 8px;
  }

  .overtime-strip {
    grid-template-columns: 1fr;
    padding: 7px 8px;
  }

  .detail-summary {
    min-height: 54px;
    padding: 8px;
  }

  .overtime-detail-body {
    padding: 0 8px 8px;
  }

  .detail-summary,
  .overtime-time-grid,
  .overtime-count-grid,
  .direct-resource-grid,
  .leave-grid,
  .holiday-auto-row {
    grid-template-columns: 1fr;
  }

  .limit-control {
    justify-content: stretch;
  }

  .limit-control select,
  .limit-control input {
    max-width: none;
    flex: 1 1 150px;
  }

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

  .overtime-metric strong,
  .overtime-metric small {
    margin-top: 0;
  }

  dialog {
    width: 100vw;
    max-width: none;
    margin: auto 0 0;
    border-radius: 16px 16px 0 0;
  }

  .event-form {
    padding: 18px;
  }

  .quick-event-buttons {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .event-form footer {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .event-form input,
  .event-form select,
  .event-form textarea {
    min-height: 46px;
    font-size: 16px;
  }
}

@media (max-width: 480px) {
  .topbar-left {
    gap: 10px;
  }

  .topbar h1 {
    font-size: 27px;
  }

  #todayBtn,
  #printBtn {
    display: none;
  }
}

@media print {
  @page {
    size: A4 landscape;
    margin: 8mm;
  }

  .topbar,
  .settings-panel,
  .settings-backdrop,
  .selected-panel,
  .calendar-toolbar,
  .status-strip,
  .insight-strip,
  .overtime-strip,
  .overtime-detail-panel,
  dialog {
    display: none !important;
  }

  .print-heading {
    display: block;
    margin-bottom: 8px;
  }

  .print-heading h2 {
    margin: 0 0 3px;
    font-size: 22px;
  }

  .print-heading p {
    margin: 0;
    color: #334155;
    font-size: 12px;
  }

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

  .month-card {
    break-inside: avoid;
    border: 1px solid var(--line);
  }

  .month-header {
    display: flex;
    padding: 7px 9px;
  }

  .month-header h2 {
    margin: 0;
    font-size: 17px;
  }

  .month-header span {
    display: none;
  }

  .weekday {
    min-height: 24px;
    padding: 3px;
    font-size: 11px;
  }

  .days-grid {
    grid-auto-rows: minmax(70px, 1fr);
  }

  .day-cell {
    min-height: 70px;
  }

  .main-shift {
    width: 42px;
    min-width: 42px;
    margin-top: 8px;
    font-size: 14px;
  }
}
