:root {
  color-scheme: light;
  --bg: #f5f7fb;
  --panel: #ffffff;
  --panel-2: #eef3f8;
  --ink: #1c2633;
  --muted: #64748b;
  --line: #d9e2ec;
  --blue: #2268b5;
  --green: #1f8a70;
  --red: #b84a4a;
  --amber: #a76a13;
  --shadow: 0 16px 36px rgba(24, 39, 75, 0.08);
}

* {
  box-sizing: border-box;
}

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

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

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

.topbar h2,
.section-heading h3 {
  margin: 0;
}

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

.workspace {
  padding: 26px;
  min-width: 0;
  max-width: 1580px;
  margin: 0 auto;
}

.topbar,
.section-heading,
.section-actions {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
}

.section-actions {
  gap: 10px;
}

.topbar h2 {
  font-size: 28px;
}

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

.actions label {
  display: grid;
  gap: 4px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

input {
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 0 10px;
}

select {
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 0 30px 0 10px;
  font-size: 13px;
  font-weight: 700;
}

.actions button {
  height: 40px;
  border: 0;
  border-radius: 8px;
  background: var(--blue);
  color: #fff;
  padding: 0 14px;
  font-weight: 700;
}

.actions .secondary-action {
  background: #111827;
}

.entry-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 40px;
  border: 0;
  border-radius: 8px;
  background: var(--blue);
  color: #fff;
  padding: 0 14px;
  font-weight: 800;
  text-decoration: none;
  white-space: nowrap;
}

.login-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-shell {
  width: min(100%, 420px);
}

.login-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 28px;
}

.login-panel h1 {
  margin: 6px 0 24px;
  font-size: 26px;
  line-height: 1.25;
}

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

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

.login-form input {
  width: 100%;
  height: 44px;
}

.login-form button {
  height: 44px;
  border: 0;
  border-radius: 8px;
  background: var(--blue);
  color: #fff;
  font-weight: 800;
}

.login-form button:disabled {
  opacity: 0.65;
  cursor: default;
}

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

.entry-button.secondary {
  background: #111827;
}

.status-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 12px;
  margin-top: 22px;
}

.status-grid article,
.data-section {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.status-grid article {
  padding: 16px;
}

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

.status-grid strong {
  display: block;
  margin-top: 8px;
  font-size: 26px;
}

.status-grid .range-card strong {
  font-size: 16px;
  line-height: 1.35;
}

.status-grid p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.data-section {
  margin-top: 16px;
  padding: 16px;
}

.workbook-section {
  margin-top: 16px;
  padding: 16px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.option-volume-section {
  margin-top: 16px;
  padding: 16px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.live-entry-section {
  margin-top: 16px;
  padding: 16px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.live-section {
  margin-top: 16px;
  padding: 16px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.live-meta {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  text-align: right;
}

.option-volume-meta {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  text-align: right;
}

.workbook-board {
  margin-top: 12px;
  max-height: 560px;
  overflow: auto;
  border: 1px solid #cfcfcf;
  background: #fff;
}

.option-volume-board {
  margin-top: 12px;
  max-height: 320px;
  overflow: auto;
  border: 1px solid #cfcfcf;
  background: #fff;
}

.live-board {
  margin-top: 12px;
  max-height: 420px;
  overflow: auto;
  border: 1px solid #aeb8c4;
  background: #fff;
}

.live-page-board {
  max-height: calc(100vh - 190px);
}

.sheet-wrap {
  min-width: 0;
}

.excel-sheet {
  border-collapse: collapse;
  width: 100%;
  min-width: max-content;
  background: #fff;
}

.live-sheet {
  border-collapse: collapse;
  width: 100%;
  min-width: max-content;
  background: #f8fbff;
}

.option-volume-sheet {
  border-collapse: collapse;
  width: 100%;
  min-width: 920px;
  background: #fff;
}

.option-volume-sheet thead {
  position: sticky;
  top: 0;
  z-index: 2;
}

.option-volume-sheet th,
.option-volume-sheet td {
  border: 1px solid #cfcfcf;
  height: 24px;
  padding: 4px 8px;
  font-size: 12px;
  line-height: 1.2;
  white-space: nowrap;
}

.option-volume-sheet th {
  background: #c6efce;
  color: #26313f;
  text-align: center;
  font-weight: 800;
}

.option-volume-sheet td {
  background: #f4fff0;
}

.option-volume-sheet .volume-date {
  background: #fff;
  color: #1f4e78;
  font-weight: 800;
  text-align: left;
}

.excel-sheet thead {
  position: sticky;
  top: 0;
  z-index: 3;
}

.excel-sheet th,
.excel-sheet td {
  border: 1px solid #cfcfcf;
  padding: 4px 7px;
  height: 24px;
  font-size: 12px;
  line-height: 1.2;
  white-space: nowrap;
}

.live-sheet td {
  border: 1px solid #d0dae6;
  min-width: 70px;
  height: 24px;
  padding: 4px 7px;
  color: #102033;
  font-size: 12px;
  line-height: 1.2;
  white-space: nowrap;
  background: #fff;
}

.live-sheet td.live-head {
  background: #e5edf7;
  color: #243244;
  font-weight: 800;
  text-align: center;
}

.live-sheet td span {
  display: inline;
  margin-left: 5px;
  color: #7b8796;
  font-size: 10px;
}

.excel-sheet th {
  background: #fff200;
  color: #26313f;
  text-align: center;
  font-weight: 800;
}

.excel-sheet .date-head {
  background: #fff;
  min-width: 54px;
}

.excel-sheet .green-head {
  background: #c6efce;
}

.excel-sheet .matrix-head {
  background: #d9ecff;
}

.excel-sheet .yellow-head {
  background: #fff200;
}

.excel-sheet .next-head {
  background: #ffe699;
}

.excel-sheet td {
  background: #ffff00;
  color: #111;
}

.excel-sheet .sticky-col {
  position: sticky;
  left: 0;
  z-index: 2;
}

.excel-sheet th.sticky-col {
  z-index: 4;
}

.excel-sheet .sheet-date {
  background: #fff;
  color: #1f4e78;
  font-weight: 800;
  text-align: left;
}

.excel-sheet .sheet-date.week-mark {
  color: #0645d9;
  text-decoration: underline;
}

.excel-sheet td span {
  display: inline;
  margin-left: 4px;
  color: #546376;
  font-size: 10px;
}

.excel-sheet .change.up {
  color: #941100;
}

.excel-sheet .change.down {
  color: #0f5f2c;
}

.excel-sheet .change.flat {
  color: #3b4652;
}

.excel-sheet .event-cell,
.excel-sheet .matrix-cell.event-cell {
  background: #ff00ea;
  color: #101010;
}

.excel-sheet .matrix-cell {
  background: #d9ecff;
}

.excel-sheet .next-cell {
  background: #fff2cc;
}

#exportWorkbookBtn {
  height: 36px;
  border: 0;
  border-radius: 8px;
  background: #111827;
  color: #fff;
  padding: 0 12px;
  font-weight: 800;
  white-space: nowrap;
}

.empty-row {
  color: var(--muted);
  text-align: center;
}

.num {
  text-align: right;
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  max-width: min(520px, calc(100vw - 40px));
  border-radius: 8px;
  background: var(--green);
  color: #fff;
  padding: 12px 14px;
  box-shadow: var(--shadow);
}

.toast.is-error {
  background: var(--red);
}

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

@media (max-width: 560px) {
  .workspace {
    padding: 16px;
  }

  .status-grid,
  .actions {
    grid-template-columns: 1fr;
    display: grid;
    width: 100%;
  }

  .topbar h2 {
    font-size: 23px;
  }

  input,
  select,
  .actions button,
  #exportWorkbookBtn {
    width: 100%;
  }
}
