:root {
  --bg: #f5f5f3;
  --paper: #ffffff;
  --ink: #171717;
  --muted: #6b7280;
  --line: #deded8;
  --line-soft: #eeeeea;
  --header: #111827;
  --accent: #2f6f5f;
  --warn: #9a5a00;
  --danger: #a83232;
  --info: #2c5e91;
  --radius: 8px;
  color-scheme: light;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans TC", sans-serif;
  letter-spacing: 0;
}

button,
input,
select {
  font: inherit;
}

.shell {
  width: min(1440px, 100%);
  margin: 0 auto;
  padding: 20px;
}

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

.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.08em;
}

h1,
h2 {
  margin: 0;
}

h1 {
  font-size: 30px;
  line-height: 1.15;
}

h2 {
  font-size: 15px;
}

.top-actions,
.filters,
.form-row,
.section-head {
  display: flex;
  align-items: end;
  gap: 10px;
}

.button,
.text-button,
.tab {
  cursor: pointer;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper);
  color: var(--ink);
  font-weight: 700;
  text-decoration: none;
}

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

.button.needs-source {
  opacity: 0.65;
}

.button.disabled {
  opacity: 0.55;
  pointer-events: none;
}

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

.text-button {
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 2px 0;
  font-size: 13px;
}

.text-button.danger {
  color: var(--danger);
  justify-self: start;
}

.field {
  display: grid;
  gap: 5px;
  width: 100%;
}

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

.field input,
.field select {
  min-height: 38px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  color: var(--ink);
  padding: 7px 10px;
}

.field input[readonly] {
  background: #f5f5f3;
  color: var(--muted);
}

.field.compact {
  width: 150px;
}

.field.search {
  min-width: 260px;
  flex: 1;
}

.field.small {
  max-width: 92px;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.metric {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper);
  padding: 12px 14px;
}

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

.metric strong {
  display: block;
  margin-top: 4px;
  font-size: 24px;
}

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

.side-panel,
.main-panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper);
}

.side-panel {
  position: sticky;
  top: 12px;
  max-height: calc(100vh - 24px);
  overflow: auto;
}

.panel-section {
  padding: 14px;
  border-bottom: 1px solid var(--line-soft);
}

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

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

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

.member-list {
  display: grid;
  gap: 4px;
  margin: 0;
  padding-left: 24px;
}

.member-list li {
  padding: 6px 0;
  border-bottom: 1px solid var(--line-soft);
  font-size: 14px;
}

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

.adjust-form {
  display: grid;
  gap: 9px;
}

.form-note {
  margin: -2px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.import-stack {
  display: grid;
  gap: 10px;
}

.file-field {
  display: grid;
  gap: 6px;
  width: 100%;
}

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

.file-field input,
.field textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  color: var(--ink);
  padding: 8px 10px;
}

.field textarea {
  min-height: 110px;
  resize: vertical;
}

.button-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.alternative-import {
  border-top: 1px solid var(--line-soft);
  padding-top: 8px;
}

.alternative-import summary {
  cursor: pointer;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.alternative-import[open] summary {
  margin-bottom: 10px;
}

.alternative-import-body {
  display: grid;
  gap: 10px;
}

.ocr-actions {
  display: grid;
  gap: 8px;
}

.ocr-actions[hidden] {
  display: none;
}

.import-status {
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  background: #fafafa;
  color: var(--muted);
  padding: 8px;
  font-size: 13px;
  line-height: 1.45;
}

.schedule-preview {
  width: 100%;
  max-height: 220px;
  object-fit: contain;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}

.draft-list {
  display: grid;
  gap: 7px;
  margin-top: 12px;
}

.draft-item {
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  padding: 8px;
  background: #fafafa;
  font-size: 13px;
}

.draft-item strong {
  display: block;
  margin-bottom: 3px;
}

.draft-item button {
  min-height: 32px;
  margin-top: 8px;
  border: 1px solid #e6b1b1;
  border-radius: 999px;
  background: #fff;
  color: var(--danger);
  padding: 0 12px;
  font-weight: 800;
}

.main-panel {
  overflow: hidden;
}

.tabs {
  display: flex;
  gap: 4px;
  padding: 10px;
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
}

.tab {
  min-height: 36px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: transparent;
  padding: 0 12px;
  color: var(--muted);
  white-space: nowrap;
  font-weight: 700;
}

.tab.active {
  background: var(--header);
  color: #fff;
}

.filters {
  padding: 12px;
  border-bottom: 1px solid var(--line-soft);
}

.table-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  color: var(--muted);
}

.table-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

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

.table-wrap {
  width: 100%;
  overflow: auto;
  max-height: calc(100vh - 260px);
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 940px;
}

th,
td {
  border-bottom: 1px solid var(--line-soft);
  padding: 10px 11px;
  vertical-align: top;
  text-align: left;
  font-size: 14px;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--header);
  color: #fff;
  font-size: 12px;
  white-space: nowrap;
}

tbody tr:nth-child(even) {
  background: #fafafa;
}

.status-select {
  width: 120px;
  min-height: 32px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  padding: 4px 8px;
  font-size: 13px;
  font-weight: 700;
}

.member-mode-select,
.member-target-select {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  padding: 5px 8px;
  font-size: 13px;
}

.member-mode-select {
  width: 190px;
}

.member-target-select {
  width: 210px;
}

.member-target-select:disabled {
  background: #f5f5f3;
  color: var(--muted);
}

.schedule-input {
  width: 82px;
  min-height: 32px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 4px 6px;
  text-align: center;
  background: #fff;
}

.schedule-input.ocr-check {
  border-color: #d28b22;
  background: #fff7e8;
}

.schedule-input.ocr-review {
  border-color: var(--danger);
  background: #fff2f2;
}

.schedule-input.ocr-edited {
  border-color: var(--accent);
  background: #f0fff7;
}

.schedule-input.schedule-alert-code {
  color: var(--danger);
  font-weight: 800;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 2px 9px;
  background: #fff;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.pill.review,
.diff.review {
  color: var(--warn);
}

.pill.done,
.pill.manual,
.diff.manual {
  color: var(--accent);
}

.pill.draft,
.diff.draft {
  color: var(--info);
}

.diff.danger {
  color: var(--danger);
  font-weight: 800;
}

.diff.special {
  color: var(--info);
  font-weight: 800;
}

.row-action {
  min-height: 30px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  padding: 0 10px;
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}

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

@media (max-width: 980px) {
  .shell {
    padding: 12px;
  }

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

  .topbar,
  .top-actions,
  .filters {
    align-items: stretch;
    flex-direction: column;
  }

  .field.compact,
  .field.search {
    width: 100%;
    min-width: 0;
  }

  .side-panel {
    position: static;
    max-height: none;
  }

  .table-wrap {
    max-height: none;
  }
}

@media (max-width: 520px) {
  .summary-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .metric {
    min-width: 0;
    padding: 11px 12px;
  }

  .metric strong {
    font-size: 21px;
    overflow-wrap: anywhere;
  }
}
