:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --panel: #ffffff;
  --ink: #20242c;
  --muted: #6d7480;
  --line: #dce1e8;
  --head: #eef3f8;
  --blue: #2563eb;
  --teal: #0f766e;
  --amber: #b45309;
  --red: #b91c1c;
  --green: #15803d;
  --shadow: 0 12px 30px rgba(32, 36, 44, 0.08);
  --person-column-width: clamp(210px, 18vw, 260px);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Microsoft JhengHei", "Noto Sans TC", system-ui, sans-serif;
  overflow: auto;
}

.app-shell {
  width: calc(100vw - 20px);
  margin: 0 auto;
  padding: clamp(8px, 1.4vw, 20px) 0;
}

.login-overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(246, 247, 249, 0.96);
}

.login-overlay[hidden] {
  display: none;
}

.login-card {
  width: min(420px, 100%);
  display: grid;
  gap: 14px;
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #ffffff;
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.16);
}

.login-card h1 {
  font-size: 28px;
}

.login-card button {
  height: 42px;
  border: 1px solid #1d4ed8;
  border-radius: 7px;
  background: #2563eb;
  color: #ffffff;
  font: inherit;
  font-weight: 900;
  cursor: pointer;
}

.login-card button:disabled {
  opacity: 0.7;
  cursor: progress;
}

.login-card .login-secondary-button {
  border-color: #d8e2ef;
  background: #ffffff;
  color: #1d4ed8;
}

.login-message {
  min-height: 20px;
  color: var(--red);
  font-size: 13px;
  font-weight: 800;
}

.topbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
  padding: clamp(12px, 1.2vw, 20px);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--blue);
  font-size: 13px;
  font-weight: 700;
}

h1 {
  margin: 0;
  font-size: clamp(22px, 2vw, 30px);
  line-height: 1.2;
}

.muted {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.connection-status {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  margin-top: 8px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
}

.connection-status.online {
  color: #047857;
  background: #d1fae5;
}

.current-user-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 28px;
  margin-top: 8px;
  padding: 4px 6px 4px 10px;
  border: 1px solid #bfdbfe;
  border-radius: 999px;
  background: #eff6ff;
  color: #1e3a8a;
  font-size: 12px;
  font-weight: 900;
}

.current-user-badge[hidden] {
  display: none;
}

.current-user-badge button {
  height: 24px;
  padding: 0 8px;
  border: 1px solid #bfdbfe;
  border-radius: 999px;
  background: #ffffff;
  color: #1d4ed8;
  font: inherit;
  font-size: 12px;
  font-weight: 900;
  cursor: pointer;
}

.connection-status.syncing {
  color: #1d4ed8;
  background: #dbeafe;
}

.connection-status.offline {
  color: #b91c1c;
  background: #fee2e2;
}

.holiday-status {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  margin-top: 8px;
  margin-left: 6px;
  padding: 3px 9px;
  border: 0;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
}

.holiday-status.ready {
  color: #0f766e;
  background: #ccfbf1;
}

.holiday-status.loading,
.holiday-status.idle {
  color: #1d4ed8;
  background: #dbeafe;
}

.holiday-status.error,
.holiday-status.unknown {
  color: #b45309;
  background: #ffedd5;
}

.controls {
  display: grid;
  grid-template-columns: minmax(260px, 360px) auto;
  gap: 10px 12px;
  align-items: end;
  justify-content: end;
}

.search-control {
  grid-row: span 2;
  min-width: 0;
}

.control-action-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(86px, 1fr));
  gap: 8px;
}

.view-toolbar {
  display: grid;
  grid-template-columns: 1fr;
  align-items: center;
  gap: 12px;
  margin-bottom: clamp(10px, 1vw, 16px);
}

.view-left {
  display: flex;
  align-items: end;
  flex-wrap: wrap;
  gap: 10px;
  min-width: 0;
}

.view-toolbar .tabs,
.view-left {
  justify-self: start;
}

.person-filters {
  display: grid;
  grid-template-columns: repeat(4, minmax(104px, 150px));
  gap: 8px;
  align-items: end;
}

.person-filters label {
  font-size: 12px;
}

.person-filters select {
  height: 34px;
  padding: 0 8px;
  font-size: 13px;
}

.multi-select-filter {
  position: relative;
  min-width: 150px;
}

.multi-select-filter summary {
  display: flex;
  align-items: center;
  height: 34px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  font-size: 13px;
  cursor: pointer;
  list-style: none;
}

.multi-select-filter summary::-webkit-details-marker {
  display: none;
}

.multi-select-filter summary::after {
  content: "▾";
  margin-left: auto;
  color: var(--muted);
  font-size: 11px;
}

.multi-select-options {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  z-index: 40;
  display: grid;
  gap: 4px;
  width: max(220px, 100%);
  max-height: 260px;
  overflow: auto;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  box-shadow: var(--shadow);
}

.person-filter-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--line);
}

.person-filter-actions button {
  height: 28px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: #f8fafc;
  color: var(--ink);
  font: inherit;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
}

.person-filter-check {
  display: grid;
  grid-template-columns: 18px 1fr;
  align-items: center;
  gap: 8px;
  min-height: 28px;
  color: var(--ink);
  font-size: 13px;
}

.person-filter-check input {
  width: 16px;
  height: 16px;
  padding: 0;
}

.person-filter-check b {
  color: var(--muted);
  font-weight: 700;
}

.issue-list-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
  width: 100%;
  padding: 12px 14px;
  border: 0;
  border-bottom: 1px solid #eef1f5;
  background: #fff;
  color: var(--ink);
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.issue-list-item:hover {
  background: #eff6ff;
}

.issue-list-item strong,
.issue-list-item small {
  display: block;
}

.issue-list-item small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.issue-list-item > span {
  color: var(--red);
  font-weight: 800;
}

.mini-empty {
  padding: 10px;
  font-size: 13px;
}

.period-picker {
  display: inline-flex;
  align-items: end;
  gap: 6px;
}

.period-picker label {
  width: 170px;
}

.period-picker > button,
#exportImage,
#shortcutSettings,
#hrExport,
#quickSchedule,
#staffNote,
#leaveStats {
  min-width: 38px;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
}

#exportImage {
  width: auto;
  padding: 0 12px;
  font-size: 14px;
  font-weight: 800;
}

#shortcutSettings {
  width: auto;
  padding: 0 12px;
  font-size: 14px;
  font-weight: 800;
}

#hrExport {
  width: auto;
  padding: 0 12px;
  font-size: 14px;
  font-weight: 800;
}

#quickSchedule {
  width: auto;
  padding: 0 12px;
  font-size: 14px;
  font-weight: 800;
}

#staffNote,
#leaveStats {
  width: auto;
  padding: 0 12px;
  font-size: 14px;
  font-weight: 800;
}

.period-picker > button:disabled {
  color: #cbd5e1;
  cursor: not-allowed;
}

.active-date-group {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  gap: 8px;
  padding: 0 4px;
  white-space: nowrap;
}

.today-button {
  min-width: 0;
  height: 40px;
  padding: 0 8px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--blue);
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
  white-space: nowrap;
}

.today-button:hover {
  text-decoration: underline;
}

.today-button.is-hidden {
  visibility: hidden;
  pointer-events: none;
}

.active-date-label {
  display: inline-flex;
  align-items: center;
  padding: 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  white-space: nowrap;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

select,
input {
  height: 40px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  padding: 0 12px;
  font: inherit;
}

textarea {
  width: 100%;
  min-height: 92px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  padding: 10px 12px;
  font: inherit;
  resize: vertical;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin: clamp(10px, 1vw, 16px) 0;
}

.metrics article {
  min-height: clamp(66px, 7vh, 86px);
  padding: clamp(10px, 1vw, 16px);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.metrics span {
  display: block;
  color: var(--muted);
  font-size: 14px;
}

.metrics strong {
  display: block;
  margin-top: 8px;
  font-size: clamp(24px, 2.4vw, 30px);
  line-height: 1;
}

.metric-breakdown {
  display: flex;
  flex-wrap: wrap;
  gap: 5px 10px;
  margin-top: 10px;
  color: var(--muted);
  font-size: 12px;
}

.metric-breakdown span {
  display: inline-flex;
  gap: 4px;
  align-items: center;
}

.metric-breakdown .name-line,
.metric-breakdown .more-line,
.metric-breakdown .filter-summary {
  flex-basis: 100%;
}

.metric-breakdown b {
  color: #334155;
  font-weight: 800;
}

.metrics .alert strong {
  color: var(--red);
}

.clickable-metric {
  cursor: pointer;
}

.clickable-metric:hover {
  border-color: #b7c4d3;
  box-shadow: 0 8px 22px rgba(32, 36, 44, 0.08);
}

.metric-names {
  display: grid;
  gap: 4px;
}

.metric-names span {
  display: block;
}

.metric-names .name-line {
  overflow: hidden;
  max-width: 100%;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.metric-breakdown .more-line,
.metric-names .more-line {
  color: var(--blue);
  font-weight: 800;
}

.metric-breakdown .filter-summary {
  color: #475569;
  font-weight: 700;
}

.tabs {
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  background: #e9edf2;
  border-radius: 8px;
  margin-bottom: 0;
}

.tab {
  min-width: 92px;
  height: 36px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.tab.active {
  background: var(--panel);
  color: var(--ink);
  box-shadow: 0 1px 5px rgba(32, 36, 44, 0.12);
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.table-wrap {
  position: relative;
  overflow: auto;
  height: min(72vh, calc(100vh - 260px));
  min-height: 360px;
  max-height: none;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.schedule-loading {
  position: absolute;
  inset: 0;
  z-index: 30;
  display: grid;
  place-content: center;
  gap: 8px;
  background: rgba(248, 250, 252, 0.92);
  color: var(--muted);
  text-align: center;
}

.schedule-loading[hidden] {
  display: none;
}

.schedule-loading strong {
  color: var(--ink);
  font-size: 18px;
}

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

th,
td {
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  padding: clamp(5px, 0.5vw, 8px) clamp(6px, 0.6vw, 10px);
  font-size: 13px;
  white-space: nowrap;
  text-align: center;
}

th {
  background: var(--head);
  color: #2e3440;
  font-weight: 700;
}

.date-head {
  cursor: pointer;
  vertical-align: top;
}

.date-head:hover {
  background: #dbeafe;
}

.date-head.selected-date {
  color: #1d4ed8;
  background: #dbeafe;
  box-shadow: inset 0 -3px 0 #2563eb;
}

.date-duty-note {
  display: block;
  width: 100%;
  max-width: 86px;
  min-height: 18px;
  margin: 4px auto 0;
  padding: 2px 4px;
  border: 1px solid #bfdbfe;
  border-radius: 4px;
  background: #eff6ff;
  color: #1d4ed8;
  font: inherit;
  font-size: 11px;
  font-weight: 800;
  line-height: 1.35;
  white-space: normal;
  word-break: keep-all;
  cursor: pointer;
}

.date-duty-note.manual {
  border-color: #fed7aa;
  background: #fff7ed;
  color: #c2410c;
}

.date-duty-note.empty {
  width: 24px;
  color: #94a3b8;
  border-color: transparent;
  background: transparent;
}

.selected-date-cell {
  box-shadow: inset 0 0 0 2px rgba(37, 99, 235, 0.18);
}

.schedule-table thead th {
  position: sticky;
  top: 0;
  z-index: 5;
}

.sticky-left {
  position: sticky;
  left: 0;
  z-index: 12;
  background: #fff;
  text-align: left;
  min-width: var(--person-column-width);
  width: var(--person-column-width);
  max-width: var(--person-column-width);
}

.schedule-table thead .sticky-left {
  left: 0;
  background: var(--head);
  z-index: 20;
  box-shadow: 1px 0 0 var(--line), 0 1px 0 var(--line);
}

.person-cell {
  text-align: left;
}

.person-name {
  display: block;
  font-weight: 800;
}

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

.person-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 6px;
}

.person-tags span {
  padding: 2px 7px;
  border-radius: 999px;
  background: #eef3f8;
  color: #475569;
  font-size: 12px;
  font-weight: 700;
}

.person-tags .duty-tag,
.person-tags .position-tag {
  background: var(--tag-bg);
  color: var(--tag-color);
  border: 1px solid var(--tag-border);
}

.person-tags .new-hire-tag {
  background: #eef2ff;
  color: #4338ca;
  border: 1px solid #c7d2fe;
}

.person-cell {
  cursor: pointer;
}

.person-cell .shift-select {
  cursor: default;
}

.shift {
  min-width: clamp(70px, 5.4vw, 84px);
  font-weight: 700;
  padding: 4px;
  position: relative;
}

.shift.selected-cell {
  box-shadow: inset 0 0 0 3px #2563eb;
  z-index: 1;
}

.shift:focus,
.shift-select:focus {
  outline: none;
}

.bad {
  color: var(--red);
  background: #fef2f2;
}

.ok {
  color: var(--green);
}

.shift-select {
  width: clamp(64px, 5vw, 78px);
  height: 30px;
  padding: 0 6px;
  border-color: transparent;
  background: rgba(255, 255, 255, 0.64);
  color: inherit;
  font-size: 12px;
  font-weight: 800;
  text-align: center;
}

.shift-select:focus {
  border-color: var(--blue);
  outline: none;
}

.leave-badge {
  display: block;
  width: fit-content;
  max-width: 100%;
  margin: 3px auto 0;
  padding: 1px 5px;
  border-radius: 999px;
  background: #fff7ed;
  color: #9a3412;
  font-size: 11px;
  font-weight: 900;
}

.cell-save-badge {
  position: absolute;
  right: 4px;
  bottom: 3px;
  max-width: calc(100% - 8px);
  padding: 1px 5px;
  border-radius: 999px;
  background: rgba(37, 99, 235, 0.1);
  color: #1d4ed8;
  font-size: 10px;
  font-weight: 900;
  pointer-events: none;
}

.cell-save-badge.saved {
  background: rgba(22, 163, 74, 0.12);
  color: #15803d;
}

.cell-save-badge.retry {
  background: rgba(185, 28, 28, 0.12);
  color: var(--red);
}

.leave-form {
  display: grid;
  gap: 12px;
  padding: 18px;
}

.leave-segment-list {
  display: grid;
  gap: 10px;
}

.leave-segment-row {
  display: grid;
  grid-template-columns: minmax(120px, 1fr) minmax(110px, 0.8fr) minmax(110px, 0.8fr) auto;
  gap: 10px;
  align-items: end;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.leave-row-delete {
  height: 38px;
  padding: 0 10px;
  border: 1px solid #fecaca;
  border-radius: 6px;
  background: #fff5f5;
  color: #b91c1c;
  font: inherit;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
}

.leave-row-delete:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.leave-hours-preview {
  min-width: 70px;
  height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-weight: 800;
}

@media (max-width: 760px) {
  .leave-segment-row {
    grid-template-columns: 1fr;
  }
}

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

.check-head {
  min-width: 86px;
  background: #e8f5f2;
}

.check-cell {
  min-width: 86px;
  padding: 7px 8px;
  font-size: 12px;
}

.scroll-spacer {
  min-width: max(160px, calc(100vw - var(--person-column-width) - 130px));
  width: max(160px, calc(100vw - var(--person-column-width) - 130px));
  padding: 0;
  border-right: 0;
  background: transparent;
  pointer-events: none;
}

.check-cell strong,
.check-cell span {
  display: block;
}

.check-cell span {
  margin-top: 2px;
  color: var(--muted);
}

.check-ok {
  color: var(--green);
  background: #f0fdf4;
}

.check-bad {
  color: var(--red);
  background: #fef2f2;
}

.check-skip {
  color: var(--muted);
  background: #f8fafc;
}

.shift-work-early {
  color: #1d4ed8;
  background: #eff6ff;
}

.shift-work-mid {
  color: #0369a1;
  background: #e0f2fe;
}

.shift-work-late {
  color: #0f766e;
  background: #e6fffb;
}

.shift-work-night,
.shift-work-other {
  color: #4338ca;
  background: #eef2ff;
}

.shift-rest {
  color: #15803d;
  background: #f0fdf4;
}

.shift-regular-off {
  color: #047857;
  background: #ecfdf5;
}

.shift-national {
  color: #0f766e;
  background: #ccfbf1;
}

.shift-sick {
  color: #be123c;
  background: #fff1f2;
}

.shift-personal {
  color: #b45309;
  background: #ffedd5;
}

.shift-vacation {
  color: #9d174d;
  background: #fce7f3;
}

.inner-off-warning {
  outline: 3px solid #dc2626;
  outline-offset: -2px;
}

.inner-off-warning .shift-select {
  background: rgba(254, 226, 226, 0.96);
}

.archive-locked {
  background-image: repeating-linear-gradient(
    135deg,
    rgba(100, 116, 139, 0.08) 0,
    rgba(100, 116, 139, 0.08) 6px,
    transparent 6px,
    transparent 12px
  ) !important;
}

.archive-locked .shift-select {
  cursor: not-allowed;
  opacity: 0.72;
}

.history-modal {
  width: min(560px, 100%);
}

.off-list-modal {
  width: min(560px, 100%);
}

.leave-stats-controls {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(138px, 1fr));
  gap: 10px;
  padding: 14px 18px 10px;
  border-bottom: 1px solid var(--line);
}

.leave-stats-check {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 8px;
  min-height: 58px;
}

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

.leave-stats-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 10px 18px;
  border-bottom: 1px solid var(--line);
}

.leave-stats-content {
  overflow: auto;
  padding: 12px 18px 18px;
}

.leave-stats-table {
  min-width: 760px;
  border-collapse: separate;
  border-spacing: 0;
}

.leave-stats-table th,
.leave-stats-table td {
  padding: 8px 10px;
  text-align: right;
}

.leave-stats-table thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: #eef3f8;
  box-shadow: inset 0 -1px 0 var(--line);
}

.leave-stats-table th:first-child,
.leave-stats-table td:first-child {
  text-align: left;
}

.leave-stats-person {
  display: inline-flex;
  flex-direction: column;
  vertical-align: middle;
}

.leave-stats-person span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.leave-stats-summary-row {
  cursor: pointer;
}

.leave-stats-summary-row:hover td {
  background: #f8fbff;
}

.leave-stats-toggle,
.leave-stats-toggle-placeholder {
  display: inline-grid;
  place-items: center;
  width: 24px;
  height: 24px;
  margin-right: 6px;
  vertical-align: middle;
}

.leave-stats-toggle {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  cursor: pointer;
}

.leave-stats-toggle:hover {
  border-color: #93c5fd;
  color: #2563eb;
}

.leave-stats-detail-row td {
  background: #f8fafc;
  color: var(--muted);
  text-align: left;
  line-height: 1.7;
}

@media (max-width: 980px) {
  .leave-stats-controls {
    grid-template-columns: repeat(2, minmax(138px, 1fr));
  }
}

@media (max-width: 620px) {
  .leave-stats-controls {
    grid-template-columns: 1fr;
  }
}

.off-list-content {
  max-height: 58vh;
  overflow: auto;
  padding: 10px 18px 18px;
}

.staff-note-tools {
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: flex-end;
  margin-bottom: 10px;
}

.line-send-status {
  margin-right: auto;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.staff-note-text {
  margin: 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
  color: var(--text);
  font: 700 14px/1.8 "Microsoft JhengHei", sans-serif;
  white-space: pre-wrap;
}

.off-list-group {
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}

.off-list-group:last-child {
  border-bottom: 0;
}

.off-list-group h3 {
  margin: 0 0 8px;
  font-size: 15px;
}

.off-list-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  padding: 7px 0;
  font-size: 14px;
}

.off-list-row strong,
.off-list-row span {
  display: block;
}

.off-list-row small {
  display: block;
  margin-top: 2px;
  color: var(--muted);
}

.off-list-row span {
  color: var(--teal);
  font-weight: 900;
}

.history-list {
  max-height: 50vh;
  overflow: auto;
  padding: 10px 18px 18px;
}

.history-filters {
  padding: 10px 18px 0;
}

.history-person-filter {
  position: relative;
  display: inline-block;
}

.history-person-filter summary {
  min-width: 150px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  font-weight: 900;
  cursor: pointer;
}

.history-person-options {
  position: absolute;
  z-index: 8;
  top: calc(100% + 6px);
  left: 0;
  width: 260px;
  max-height: 280px;
  overflow: auto;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  box-shadow: var(--shadow);
}

.history-item {
  display: grid;
  grid-template-columns: 150px 1fr;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}

.history-item:last-child {
  border-bottom: 0;
}

.history-item time {
  color: var(--muted);
  font-size: 13px;
}

.history-item strong,
.history-item span,
.history-item small {
  display: block;
}

.history-item span {
  margin-top: 4px;
  font-weight: 800;
}

.history-item small {
  margin-top: 4px;
  color: var(--muted);
  font-weight: 800;
}

.holiday-modal {
  width: min(620px, 100%);
}

.holiday-list {
  max-height: 58vh;
  overflow: auto;
  padding: 10px 18px 18px;
}

.holiday-item {
  display: grid;
  grid-template-columns: 72px 1fr;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}

.holiday-item:last-child {
  border-bottom: 0;
}

.holiday-item time {
  color: #0f766e;
  font-weight: 900;
}

.holiday-item strong,
.holiday-item span,
.holiday-item small {
  display: block;
}

.holiday-item span {
  margin-top: 4px;
  color: var(--ink);
  font-weight: 800;
}

.holiday-item small {
  margin-top: 3px;
  color: var(--muted);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(15, 23, 42, 0.42);
}

.modal-backdrop[hidden] {
  display: none;
}

#accountRequestModal {
  z-index: 10010;
}

.confirm-backdrop {
  z-index: 10020;
}

.modal {
  width: min(460px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 24px 70px rgba(15, 23, 42, 0.28);
}

.modal.leave-stats-modal {
  width: min(1120px, calc(100vw - 48px));
  height: min(86vh, 820px);
  max-height: min(86vh, 820px);
  display: grid;
  grid-template-rows: auto auto auto minmax(0, 1fr);
}

.modal.account-request-modal {
  width: min(620px, calc(100vw - 40px));
}

.modal.change-password-modal {
  width: min(460px, calc(100vw - 40px));
}

.account-request-fields {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.account-request-note {
  grid-column: 1 / -1;
}

.account-request-note textarea {
  resize: vertical;
  min-height: 80px;
}

.modal header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 18px 12px;
  border-bottom: 1px solid var(--line);
}

.modal h2 {
  margin: 0;
  font-size: 22px;
}

.icon-button {
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--muted);
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
}

.modal-fields {
  display: grid;
  gap: 14px;
  padding: 18px;
}

.form-status {
  min-height: 20px;
  margin: 0;
  padding: 0 18px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.form-status[data-state="saving"] {
  color: #1d4ed8;
}

.form-status[data-state="saved"] {
  color: #047857;
}

.form-status[data-state="error"] {
  color: var(--red);
}

.date-note-form {
  display: grid;
  gap: 14px;
  padding: 18px;
}

.auto-note-box {
  display: grid;
  gap: 4px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.auto-note-box span {
  color: var(--muted);
  font-size: 13px;
}

.auto-note-box strong {
  color: var(--ink);
}

.cell-action-tabs {
  display: flex;
  gap: 6px;
  padding: 0 18px 12px;
}

.cell-action-tab {
  height: 32px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f8fafc;
  color: var(--muted);
  font-weight: 800;
  cursor: pointer;
}

.cell-action-tab.active {
  background: var(--blue);
  border-color: var(--blue);
  color: #fff;
}

.confirm-modal {
  width: min(440px, calc(100vw - 40px));
}

.confirm-body {
  padding: 16px 18px 6px;
}

.confirm-body p {
  margin: 0;
  color: var(--muted);
  line-height: 1.7;
  font-size: 14px;
}

.confirm-body p[hidden] {
  display: none;
}

.confirm-modal footer {
  gap: 10px;
  justify-content: flex-end;
}

.confirm-modal .primary-button.danger-button {
  background: #a16207;
  color: #fff;
}

.confirm-modal .primary-button.danger-button:hover {
  background: #854d0e;
}

.modal footer {
  display: flex;
  justify-content: end;
  padding: 0 18px 18px;
}

.primary-button {
  height: 38px;
  min-width: 92px;
  border: 0;
  border-radius: 6px;
  background: var(--blue);
  color: #fff;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}

.secondary-button {
  height: 38px;
  min-width: 92px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}

.shortcut-modal {
  width: min(1180px, calc(100vw - 48px));
  height: min(82vh, 760px);
  max-height: min(82vh, 760px);
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
}

.settings-tabs {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding: 10px 18px 0;
  border-top: 1px solid var(--line);
  background: #f8fafc;
}

.settings-tab {
  min-width: max-content;
  padding: 9px 14px;
  border: 1px solid transparent;
  border-radius: 8px 8px 0 0;
  background: transparent;
  color: var(--muted);
  font-weight: 800;
  cursor: pointer;
}

.settings-tab.active {
  border-color: var(--line);
  border-bottom-color: var(--panel);
  background: var(--panel);
  color: var(--ink);
}

.settings-body {
  display: grid;
  gap: 18px;
  min-height: 0;
  padding: 18px;
  overflow: auto;
}

.settings-panel {
  display: none;
}

.settings-panel.active {
  display: block;
}

.settings-section {
  display: grid;
  gap: 10px;
}

.settings-section h3,
.settings-section h4 {
  margin: 0;
}

.settings-section h3 {
  font-size: 17px;
}

.settings-section h4 {
  font-size: 14px;
}

.rule-list,
.setting-control-list {
  display: grid;
  gap: 10px;
}

.rule-list > div,
.setting-control-list > div,
.setting-control-list > label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.rule-list strong,
.setting-control-list strong {
  color: #1f2937;
}

.rule-list span,
.setting-control-list span {
  color: var(--muted);
  font-weight: 700;
  text-align: right;
}

.setting-control-list input[type="number"],
.setting-control-list select {
  width: 120px;
}

.setting-control-list input[type="checkbox"] {
  width: 20px;
  height: 20px;
}

.shortcut-list,
.category-setting-list,
.sort-setting-list,
.people-setting-list,
.quick-group-list,
.duty-rule-list {
  display: grid;
  gap: 10px;
}

.duty-rule-row {
  display: grid;
  grid-template-columns: minmax(72px, 0.5fr) repeat(3, minmax(150px, 1fr));
  gap: 10px;
  align-items: stretch;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f8fafc;
}

.duty-rule-row > strong {
  align-self: center;
  color: var(--ink);
}

.duty-rule-day {
  display: grid;
  gap: 8px;
  padding: 8px;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  background: #ffffff;
}

.duty-rule-day b {
  color: #334155;
  font-size: 13px;
}

.shortcut-row {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 12px;
  align-items: end;
}

.category-settings-grid {
  display: grid;
  grid-template-columns: minmax(170px, 0.8fr) minmax(260px, 1.35fr) minmax(170px, 0.8fr);
  gap: 14px;
}

.category-settings-grid > div {
  display: grid;
  align-content: start;
  gap: 10px;
}

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

#positionSettingList .category-row {
  grid-template-columns: minmax(82px, 1fr) auto auto auto auto;
}

#dutySettingList .category-row {
  grid-template-columns: minmax(82px, 1fr) auto auto auto auto;
}

#shiftSettingList .category-row {
  grid-template-columns: minmax(120px, 1fr) auto auto minmax(84px, 0.6fr) minmax(104px, 0.75fr) minmax(104px, 0.75fr) auto auto auto auto;
}

.sort-row {
  grid-template-columns: 1fr auto auto;
}

.category-color-label {
  min-width: 54px;
}

.category-check-label {
  min-width: 70px;
  display: grid;
  justify-items: center;
}

.category-color,
.category-bg-color,
.category-fg-color {
  width: 36px;
  min-width: 36px;
  height: 34px;
  padding: 2px;
  cursor: pointer;
}

.people-setting-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f8fafc;
}

.people-setting-row strong,
.people-setting-row span {
  display: block;
}

.people-setting-row span {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

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

.quick-group-row {
  display: grid;
  grid-template-columns: minmax(160px, 0.7fr) minmax(240px, 1.3fr) auto;
  gap: 10px;
  align-items: end;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f8fafc;
}

.new-quick-group-grid {
  display: grid;
  grid-template-columns: minmax(180px, 0.7fr) minmax(260px, 1.3fr);
  gap: 10px;
}

.quick-group-people-field {
  display: grid;
  gap: 6px;
}

.field-label {
  color: var(--muted);
  font-size: 13px;
}

.person-check-list {
  display: grid;
  gap: 4px;
  max-height: 180px;
  overflow: auto;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
}

.person-check {
  display: grid;
  grid-template-columns: 18px 1fr;
  align-items: center;
  gap: 8px;
  min-height: 28px;
  color: var(--ink);
  font-size: 13px;
}

.person-check input {
  width: 16px;
  height: 16px;
  padding: 0;
}

.person-check b {
  color: var(--muted);
  font-weight: 700;
}

[data-settings-panel="line"] .settings-section {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 12px;
  align-items: start;
}

[data-settings-panel="line"] .settings-section > h3,
[data-settings-panel="line"] .settings-section > h4,
[data-settings-panel="line"] .settings-section > p.muted {
  grid-column: 1 / -1;
}

[data-settings-panel="line"] .settings-section > h3 {
  margin-top: 14px;
  padding: 14px 0 0;
  border-top: 1px solid #e2e8f0;
  color: #0f172a;
}

[data-settings-panel="line"] .settings-section > h3:first-child {
  margin-top: 0;
  padding-top: 0;
  border-top: 0;
}

[data-settings-panel="line"] .settings-section > .setting-control-list,
[data-settings-panel="line"] .settings-section > .line-target-card,
[data-settings-panel="line"] .settings-section > .line-whitelist-grid,
[data-settings-panel="line"] .settings-section > .line-audit-panel {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #ffffff;
  box-shadow: 0 8px 18px rgba(15, 23, 42, 0.04);
}

[data-settings-panel="line"] .settings-section > .setting-control-list {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

[data-settings-panel="line"] .settings-section > .setting-control-list > label,
[data-settings-panel="line"] .settings-section > .setting-control-list > div {
  display: grid;
  grid-template-columns: minmax(120px, 0.45fr) minmax(180px, 1fr);
  align-items: center;
  gap: 10px;
  min-height: 58px;
  padding: 10px 12px;
}

[data-settings-panel="line"] .settings-section > .setting-control-list > div {
  grid-template-columns: minmax(160px, 0.5fr) minmax(160px, 1fr);
}

[data-settings-panel="line"] .settings-section > .setting-control-list span {
  text-align: left;
}

[data-settings-panel="line"] .setting-control-list input:not([type="checkbox"]),
[data-settings-panel="line"] .setting-control-list select {
  width: 100%;
  min-width: 0;
}

[data-settings-panel="line"] .setting-control-list input[type="checkbox"] {
  justify-self: end;
}

[data-settings-panel="line"] #linePrivateStatus {
  color: #047857;
}

[data-settings-panel="line"] .setting-control-list > div:has(#linePrivateStatus) {
  grid-column: 1 / -1;
}

[data-settings-panel="line"] #saveLinePrivateConfig {
  justify-self: end;
  min-width: 180px;
}

[data-settings-panel="line"] .settings-section > p.muted {
  margin-top: -4px;
}

[data-settings-panel="line"] .settings-section > h4 {
  margin-top: 8px;
  color: #334155;
}

.line-target-card {
  display: grid;
  gap: 5px;
  padding: 12px 14px;
  border: 1px solid #bfdbfe;
  border-radius: 8px;
  background: #eff6ff;
  color: #1e3a8a;
  font-size: 13px;
}

.line-target-card strong {
  color: #1d4ed8;
  font-size: 14px;
}

.line-target-card span {
  color: #334155;
}

[data-settings-panel="line"] .settings-section > .line-target-card {
  border-color: #bfdbfe;
  background: #eff6ff;
}

.line-whitelist-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 10px;
  grid-column: 1 / -1;
  align-items: start;
}

.line-whitelist-grid > div {
  display: grid;
  gap: 8px;
}

.line-contact-list {
  max-height: 220px;
}

.line-contact-list .muted {
  padding: 8px;
  font-size: 13px;
}

.line-contact-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  padding: 10px;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  background: #fff;
}

.line-contact-check {
  display: grid;
  grid-template-columns: 18px 1fr;
  align-items: center;
  gap: 8px;
}

.line-contact-check input {
  width: 16px;
  height: 16px;
  padding: 0;
}

.line-contact-check strong,
.line-contact-check small {
  display: block;
}

.line-contact-check small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

.line-contact-alias,
.line-contact-binding {
  display: grid;
  gap: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.line-contact-binding select {
  width: 100%;
}

.line-contact-delete {
  width: max-content;
  height: 32px;
  padding: 0 10px;
  border: 1px solid #fecaca;
  border-radius: 6px;
  background: #fff5f5;
  color: #b91c1c;
  font: inherit;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
}

.line-audit-panel {
  display: grid;
  gap: 10px;
  margin-top: 14px;
  grid-column: 1 / -1;
}

.line-audit-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

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

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

.line-audit-filters select {
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
}

.line-audit-list {
  display: grid;
  gap: 14px;
}

.line-audit-list section {
  display: grid;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.line-audit-list h5 {
  margin: 0;
  color: #334155;
  font-size: 13px;
}

.line-audit-item {
  display: grid;
  gap: 5px;
  padding: 10px;
  border-left: 4px solid #94a3b8;
  border-radius: 6px;
  background: #fff;
}

.line-audit-item > div {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-size: 12px;
}

.line-audit-item strong {
  color: #0f172a;
}

.line-audit-item p {
  margin: 0;
  color: var(--ink);
  font-weight: 800;
}

.line-audit-item small {
  color: var(--muted);
  font-size: 12px;
}

.line-audit-item.pending {
  border-left-color: #f59e0b;
}

.line-audit-item.confirmed {
  border-left-color: #10b981;
}

.line-audit-item.failed,
.line-audit-item.invalid,
.line-audit-item.unauthorized {
  border-left-color: #ef4444;
}

.line-audit-item.cancelled {
  border-left-color: #64748b;
}

.user-list {
  display: grid;
  gap: 8px;
}

.show-disabled-users {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  width: fit-content;
  color: var(--text);
  font-size: 13px;
  font-weight: 800;
}

.show-disabled-users input {
  width: 16px;
  height: 16px;
}

.account-request-admin {
  display: grid;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #ffffff;
}

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

.user-row strong,
.user-row span,
.user-row small {
  display: block;
}

.user-row small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

.user-row.disabled {
  opacity: 0.58;
}

.user-row-actions {
  display: flex;
  gap: 6px;
  align-items: center;
}

.account-request-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 0.9fr);
  align-items: start;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.account-request-row strong,
.account-request-row small,
.account-request-row span {
  display: block;
}

.account-request-row small,
.account-request-row span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.account-request-actions {
  display: grid;
  grid-template-columns: minmax(110px, 1fr) minmax(150px, 1.2fr) auto auto;
  gap: 8px;
  align-items: end;
}

.user-row button {
  height: 34px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #ffffff;
  color: #0f172a;
  font: inherit;
  font-size: 12px;
  font-weight: 900;
  cursor: pointer;
}

.user-editor {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #ffffff;
}

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

.user-disabled-check {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 40px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f8fafc;
}

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

.user-editor-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.permission-matrix {
  border: 1px solid #d8e2ef;
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
}

.permission-row {
  display: grid;
  grid-template-columns: minmax(160px, 1.4fr) repeat(3, minmax(88px, 0.8fr));
  align-items: center;
  min-height: 46px;
  border-bottom: 1px solid #e5edf6;
}

.permission-row:last-child {
  border-bottom: 0;
}

.permission-row > span,
.permission-row > label {
  padding: 10px 12px;
}

.permission-row > label {
  display: flex;
  justify-content: center;
}

.permission-head {
  font-weight: 700;
  color: #23364d;
  background: #eef5fb;
}

.permission-option:disabled {
  opacity: 0.45;
}

.settings-backup-panel {
  display: grid;
  gap: 8px;
  margin-top: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.settings-health-panel {
  display: grid;
  gap: 12px;
  margin-top: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

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

.settings-health-head h4 {
  margin: 0 0 4px;
}

.settings-health-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.settings-health-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(145px, 1fr));
  gap: 8px;
}

.settings-health-card {
  min-height: 62px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.settings-health-card strong {
  display: block;
  color: #0f172a;
  font-size: 18px;
  line-height: 1.25;
}

.settings-health-card span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.settings-health-card.ok strong {
  color: #047857;
}

.settings-health-card.warn strong {
  color: #b45309;
}

.settings-health-card.error strong {
  color: var(--red);
}

.settings-health-issues {
  display: grid;
  gap: 6px;
}

.settings-health-issue {
  padding: 8px 10px;
  border-left: 3px solid #f59e0b;
  border-radius: 6px;
  background: #fffbeb;
  color: #92400e;
  font-weight: 800;
}

.settings-health-issue.ok {
  border-left-color: #10b981;
  background: #ecfdf5;
  color: #047857;
}

.settings-backup-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.backup-list-panel {
  display: grid;
  gap: 12px;
  margin-top: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

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

.backup-list-head h4 {
  margin: 0 0 4px;
}

.backup-list {
  display: grid;
  gap: 8px;
}

.backup-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 10px 12px;
  border: 1px solid #d8e2ef;
  border-radius: 8px;
  background: #f8fafc;
}

.backup-row strong,
.backup-row span,
.backup-row small {
  display: block;
}

.backup-row span {
  margin-top: 3px;
  color: #334155;
  font-size: 13px;
  font-weight: 800;
}

.backup-row small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
  word-break: break-all;
}

.backup-row-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.backup-row-actions button {
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #ffffff;
  color: #0f172a;
  font: inherit;
  font-size: 12px;
  font-weight: 900;
  cursor: pointer;
}

.backup-row-actions .danger-button {
  border-color: #fecaca;
  background: #fff1f2;
  color: #be123c;
}

.import-settings-button {
  display: inline-grid;
  place-items: center;
}

.import-settings-button input {
  display: none;
}

@media (max-width: 760px) {
  [data-settings-panel="line"] .settings-section {
    grid-template-columns: 1fr;
  }

  [data-settings-panel="line"] .settings-section > .setting-control-list,
  .line-whitelist-grid,
  .line-audit-filters {
    grid-template-columns: 1fr;
  }

  [data-settings-panel="line"] .settings-section > .setting-control-list > label,
  [data-settings-panel="line"] .settings-section > .setting-control-list > div {
    grid-template-columns: 1fr;
  }

  [data-settings-panel="line"] .setting-control-list input[type="checkbox"] {
    justify-self: start;
  }

  [data-settings-panel="line"] #saveLinePrivateConfig {
    grid-column: auto;
    justify-self: stretch;
  }

  .settings-health-head {
    flex-direction: column;
  }

  .settings-health-actions {
    justify-content: flex-start;
  }

  .backup-list-head,
  .backup-row {
    grid-template-columns: 1fr;
  }

  .backup-list-head {
    flex-direction: column;
  }

  .backup-row-actions {
    justify-content: flex-start;
  }

  .user-editor-grid,
  .user-row,
  .account-request-fields,
  .account-request-row,
  .account-request-actions {
    grid-template-columns: 1fr;
  }
}

.selected-member-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-height: 34px;
  padding: 7px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
}

.member-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 24px;
  padding: 2px 8px;
  border-radius: 999px;
  background: #eef6ff;
  color: #1e40af;
  font-size: 12px;
  font-weight: 800;
}

.member-chip b {
  color: #64748b;
  font-weight: 700;
}

.group-edit-details {
  display: grid;
  gap: 6px;
}

.group-edit-details summary {
  width: max-content;
  cursor: pointer;
  color: var(--blue);
  font-size: 13px;
  font-weight: 800;
}

.group-edit-details[open] summary {
  margin-bottom: 6px;
}

.quick-schedule-modal {
  width: min(620px, 100%);
}

.hr-export-modal {
  width: min(720px, 100%);
}

.quick-schedule-form {
  display: grid;
  gap: 14px;
  padding: 18px;
}

.hr-export-form {
  display: grid;
  gap: 14px;
  padding: 18px;
}

.hr-period-nav {
  display: grid;
  grid-template-columns: 38px 1fr 38px;
  align-items: center;
  gap: 10px;
}

.hr-period-nav strong {
  display: block;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
  text-align: center;
  color: #0f172a;
}

.hr-export-hint {
  display: grid;
  gap: 4px;
  padding: 10px 12px;
  border: 1px solid #bfdbfe;
  border-radius: 8px;
  background: #eff6ff;
  color: #1d4ed8;
  font-size: 13px;
}

.hr-export-hint span {
  color: #475569;
}

.hr-export-form textarea {
  min-height: 150px;
  font-family: Consolas, "Microsoft JhengHei", monospace;
  white-space: pre;
  overflow: auto;
}

.hr-export-people-field {
  display: grid;
  gap: 6px;
}

.hr-export-people-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: #475569;
  font-size: 13px;
  font-weight: 700;
}

.hr-export-people-header > div {
  display: flex;
  gap: 6px;
}

.tiny-button {
  min-height: 28px;
  padding: 4px 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #ffffff;
  color: #0f172a;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
}

.tiny-button:hover {
  border-color: #bfdbfe;
  background: #eff6ff;
}

.hr-export-people-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 6px;
  max-height: 176px;
  overflow: auto;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.hr-person-option {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  padding: 7px 8px;
  border: 1px solid #e2e8f0;
  border-radius: 7px;
  background: #ffffff;
  color: #0f172a;
  font-size: 13px;
  cursor: pointer;
}

.hr-person-option input {
  width: 16px;
  height: 16px;
  margin: 0;
  flex: 0 0 auto;
}

.hr-person-option span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hr-person-option small {
  color: #64748b;
  font-size: 12px;
}

.quick-schedule-preview {
  display: grid;
  gap: 5px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.quick-schedule-preview strong {
  color: var(--ink);
}

.quick-schedule-preview span {
  color: var(--muted);
  font-size: 13px;
}

.shortcut-modal footer {
  gap: 8px;
  align-items: center;
}

.settings-save-status {
  margin-right: auto;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.settings-save-status[data-state="saving"] {
  color: #1d4ed8;
}

.settings-save-status[data-state="saved"] {
  color: #047857;
}

.settings-save-status[data-state="error"] {
  color: var(--red);
}

.inline-add {
  width: max-content;
}

.shortcut-delete,
.category-delete,
.person-delete,
.quick-group-delete,
.move-up,
.move-down {
  height: 40px;
  padding: 0 10px;
  border: 1px solid #fecaca;
  border-radius: 6px;
  background: #fff5f5;
  color: #b91c1c;
  font: inherit;
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
}

.move-up,
.move-down {
  border-color: var(--line);
  background: #fff;
  color: var(--ink);
}

.move-up:disabled,
.move-down:disabled {
  color: #cbd5e1;
  cursor: not-allowed;
}

.shift-not-employed {
  color: #64748b;
  background: #f1f5f9;
}

.employment-locked .shift-select {
  color: #64748b;
  background: rgba(241, 245, 249, 0.96);
}

.daily-board,
.summary-board {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 14px;
}

.list-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.list-panel header {
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--head);
}

.list-panel h2 {
  margin: 0;
  font-size: 17px;
}

.list-panel ul {
  list-style: none;
  margin: 0;
  padding: 6px 0;
}

.list-panel li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 16px;
  border-bottom: 1px solid #eef1f5;
  font-size: 14px;
}

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

.empty {
  padding: 26px;
  color: var(--muted);
  text-align: center;
}

@media (max-width: 900px) {
  .topbar {
    align-items: stretch;
    flex-direction: column;
  }

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

  .search-control {
    grid-row: auto;
  }

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

  .period-picker {
    align-items: stretch;
    flex-wrap: wrap;
  }

  .period-picker label {
    width: 100%;
  }

  .view-toolbar {
    align-items: stretch;
    grid-template-columns: 1fr;
  }

  .view-left,
  .view-toolbar .tabs,
  .view-toolbar .period-picker {
    justify-self: stretch;
  }

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

  .person-filters {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

  .category-settings-grid {
    grid-template-columns: 1fr;
  }

  .new-person-grid {
    grid-template-columns: 1fr;
  }

  .duty-rule-row {
    grid-template-columns: 1fr;
  }

  .app-shell {
    width: min(100vw - 12px, 1880px);
    padding-top: 6px;
  }

  .table-wrap {
    height: 68vh;
    min-height: 340px;
  }
}

@media (max-height: 760px) and (min-width: 901px) {
  .topbar {
    align-items: center;
  }

  .muted {
    margin-top: 4px;
  }

  .metrics article {
    min-height: 58px;
  }

  .metrics strong {
    margin-top: 4px;
  }
}

@media (max-height: 640px) and (min-width: 901px) {
  .metrics {
    display: none;
  }

  .table-wrap {
    height: calc(100vh - 150px);
    min-height: 280px;
  }
}

@media (min-aspect-ratio: 2 / 1) and (min-width: 1400px) {
  .app-shell {
    width: calc(100vw - 12px);
    padding: 6px 0;
  }

  .topbar {
    padding: 10px 14px;
  }

  h1 {
    font-size: 24px;
  }

  .muted {
    margin-top: 3px;
    font-size: 13px;
  }

  .controls {
    grid-template-columns: minmax(250px, 320px) auto;
    gap: 8px 10px;
  }

  .metrics {
    gap: 8px;
    margin: 8px 0;
  }

  .metrics article {
    min-height: 52px;
    padding: 8px 14px;
  }

  .metrics span {
    font-size: 13px;
  }

  .metrics strong {
    margin-top: 2px;
    font-size: 24px;
  }

  .tab {
    height: 32px;
  }

  .tabs {
    margin-bottom: 6px;
  }

  .table-wrap {
    height: calc(100vh - 190px);
    min-height: 420px;
  }
}
