:root {
  color-scheme: light;
  --bg: #f5f7f8;
  --panel: #ffffff;
  --panel-soft: #eef7f4;
  --text: #17202a;
  --muted: #637083;
  --line: #d9e0e7;
  --accent: #0f766e;
  --accent-dark: #115e59;
  --blue: #2457a6;
  --amber: #b7791f;
  --danger-bg: #fff1f0;
  --danger-line: #d64545;
  --success-bg: #eaf7ee;
  --shadow: 0 10px 30px rgba(22, 36, 50, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 1180px;
  background: var(--bg);
  color: var(--text);
  font-family: "Microsoft JhengHei", "PingFang TC", "Noto Sans TC", Arial, sans-serif;
  font-size: 15px;
}

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

button {
  border: 0;
  border-radius: 6px;
  background: var(--accent);
  color: #ffffff;
  cursor: pointer;
  font-weight: 700;
  min-height: 38px;
  padding: 8px 14px;
}

button:hover {
  background: var(--accent-dark);
}

button:disabled {
  cursor: not-allowed;
  background: #aeb8c2;
}

button.secondary {
  background: #e8edf2;
  color: var(--text);
}

button.secondary:hover {
  background: #dbe3ea;
}

button.warning {
  background: var(--amber);
}

button.danger {
  background: #b42318;
}

button.danger:hover {
  background: #8f1d14;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #ffffff;
  color: var(--text);
  outline: none;
  padding: 9px 10px;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.12);
}

textarea {
  min-height: 40px;
  resize: vertical;
}

.app-shell {
  padding: 22px;
}

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

.title-block h1 {
  font-size: 26px;
  letter-spacing: 0;
  line-height: 1.25;
  margin: 0 0 4px;
}

.title-block p {
  color: var(--muted);
  margin: 0;
}

.auth-panel {
  align-items: center;
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  min-width: 560px;
}

.auth-panel input {
  width: 190px;
}

.auth-user {
  align-items: center;
  display: flex;
  gap: 10px;
}

.cloud-note {
  color: var(--muted);
  font-weight: 700;
  white-space: nowrap;
}

.pill {
  align-items: center;
  border-radius: 999px;
  display: inline-flex;
  font-size: 13px;
  font-weight: 700;
  gap: 6px;
  min-height: 30px;
  padding: 5px 10px;
}

.pill.online {
  background: var(--success-bg);
  color: #1d6b35;
}

.pill.offline {
  background: #fff4df;
  color: #8a5b14;
}

.notice {
  background: #fff8e8;
  border: 1px solid #f0d39b;
  border-radius: 8px;
  margin-bottom: 16px;
  padding: 14px;
}

.notice strong {
  display: block;
  margin-bottom: 8px;
}

.config-grid {
  display: grid;
  gap: 10px;
  grid-template-columns: 1fr 1.2fr auto;
}

.message {
  border-radius: 8px;
  margin-bottom: 16px;
  padding: 12px 14px;
}

.message.error {
  background: #fff0f0;
  border: 1px solid #e5aaa6;
  color: #8b1e1e;
}

.message.ok {
  background: #eef8ef;
  border: 1px solid #b7dec0;
  color: #215c31;
}

.entry-band,
.report-section,
.calc-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.entry-band {
  display: grid;
  gap: 12px;
  grid-template-columns: 160px 190px 210px 1fr;
  margin-bottom: 16px;
  padding: 16px;
}

.field label,
.rate-field label {
  color: var(--muted);
  display: block;
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 6px;
}

.calculator-grid {
  display: grid;
  gap: 16px;
  grid-template-columns: 1fr 1fr;
  margin-bottom: 16px;
}

.calc-panel {
  overflow: hidden;
}

.calc-header {
  align-items: center;
  background: var(--panel-soft);
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  padding: 14px 16px;
}

.calc-header h2 {
  font-size: 20px;
  letter-spacing: 0;
  margin: 0;
}

.unit-note {
  color: var(--muted);
  font-weight: 700;
}

.cost-row {
  padding: 14px 16px 4px;
}

.quote-grid {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  padding: 12px 16px 16px;
}

.quote-column {
  border: 1px solid var(--line);
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  min-height: 330px;
  overflow: hidden;
}

.quote-title {
  background: #f6f9fb;
  border-bottom: 1px solid var(--line);
  color: var(--blue);
  font-weight: 800;
  padding: 10px 12px;
}

.quote-body {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 10px;
  padding: 12px;
}

.result-list {
  display: grid;
  gap: 8px;
  margin-top: 2px;
}

.result-item {
  background: #f8fafb;
  border-radius: 6px;
  padding: 9px 10px;
}

.result-item span {
  color: var(--muted);
  display: block;
  font-size: 12px;
  font-weight: 700;
  margin-bottom: 4px;
}

.result-item strong {
  display: block;
  font-size: 18px;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.result-item.profit strong {
  color: #0f6c3b;
}

.quote-body button {
  margin-top: auto;
}

.report-section {
  overflow: hidden;
}

.report-header {
  align-items: center;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  padding: 14px 16px;
}

.report-header h2 {
  font-size: 20px;
  margin: 0;
}

.monthly-total {
  color: var(--text);
  font-size: 16px;
  font-weight: 800;
}

.monthly-total strong {
  color: #0f6c3b;
  font-size: 22px;
}

.report-tools {
  align-items: center;
  display: flex;
  gap: 18px;
}

.table-wrap {
  overflow-x: auto;
}

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

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 9px 8px;
  text-align: left;
  vertical-align: middle;
}

th {
  background: #f2f5f8;
  color: #405065;
  font-size: 13px;
  font-weight: 800;
  white-space: nowrap;
}

.sort-button {
  align-items: center;
  background: transparent;
  border-radius: 4px;
  color: #405065;
  display: inline-flex;
  gap: 4px;
  justify-content: flex-start;
  min-height: 28px;
  padding: 4px 6px;
  width: 100%;
}

.sort-button:hover,
.sort-button.active {
  background: #dfe7ee;
  color: var(--text);
}

.sort-mark {
  display: inline-block;
  min-width: 14px;
  text-align: center;
}

td.number,
th.number {
  text-align: right;
}

th.number .sort-button {
  justify-content: flex-end;
}

.select-column {
  min-width: 46px;
  text-align: center;
  width: 46px;
}

.select-column input {
  height: 18px;
  margin: 0;
  width: 18px;
}

tbody tr.pending-row {
  background: var(--danger-bg);
  box-shadow: inset 5px 0 0 var(--danger-line);
}

tbody tr.deleted-row {
  background: #f0f2f4;
  color: #717b86;
  text-decoration: line-through;
}

tbody tr.deleted-row:hover {
  background: #e5e9ed;
}

tbody tr:hover {
  background: #eef7ff;
}

tfoot td {
  background: #e9f7ef;
  border-bottom: 0;
  border-top: 2px solid #9dd7b5;
  color: #124c2d;
  font-weight: 900;
}

tfoot .pending-total-row td {
  white-space: nowrap;
}

tfoot .selected-total-row td {
  background: #eef2ff;
  border-top: 2px solid #a7b7f7;
  color: #1d3c89;
  white-space: nowrap;
}

.status-toggle {
  align-items: center;
  display: inline-flex;
  gap: 6px;
  white-space: nowrap;
}

.status-toggle input {
  height: 16px;
  width: 16px;
}

.row-actions {
  display: flex;
  gap: 6px;
  white-space: nowrap;
}

.modal-backdrop {
  align-items: center;
  background: rgba(17, 24, 39, 0.38);
  display: flex;
  inset: 0;
  justify-content: center;
  padding: 24px;
  position: fixed;
  z-index: 20;
}

.modal {
  background: #ffffff;
  border-radius: 8px;
  box-shadow: 0 18px 45px rgba(15, 23, 42, 0.22);
  max-width: 460px;
  padding: 22px;
  width: 100%;
}

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

.modal p {
  color: var(--muted);
  line-height: 1.65;
  margin: 0;
}

.modal-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 18px;
}

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

.edit-input {
  min-width: 108px;
}

.edit-note {
  min-width: 160px;
}

.currency-badge {
  border-radius: 999px;
  display: inline-block;
  font-weight: 800;
  padding: 4px 8px;
}

.currency-badge.cny {
  background: #eef7f4;
  color: #0f766e;
}

.currency-badge.krw {
  background: #eef2ff;
  color: #2457a6;
}

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

  .app-shell {
    padding: 14px;
  }

  .topbar,
  .auth-panel,
  .report-header {
    align-items: stretch;
    flex-direction: column;
  }

  .report-tools {
    align-items: stretch;
    flex-direction: column;
  }

  .auth-panel {
    min-width: 0;
  }

  .auth-panel input {
    width: 100%;
  }

  .entry-band,
  .calculator-grid,
  .quote-grid,
  .config-grid {
    grid-template-columns: 1fr;
  }
}
