:root {
  color-scheme: light;
  --bg: #f6f7f3;
  --surface: #ffffff;
  --surface-soft: #f0f3ef;
  --text: #17201a;
  --muted: #657067;
  --line: #d9dfd8;
  --accent: #276749;
  --accent-strong: #1f513a;
  --warning: #a15c00;
  --danger: #a33a2b;
  --focus: #2c7a7b;
  --shadow: 0 10px 30px rgba(23, 32, 26, 0.08);
  font-family: "Segoe UI", "Microsoft JhengHei", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
}

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

button {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  padding: 0 14px;
  cursor: pointer;
}

button:hover {
  border-color: var(--accent);
}

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

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

button.primary:hover {
  background: var(--accent-strong);
}

.icon-button {
  width: 42px;
  padding: 0;
  font-size: 20px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 24px;
  border-bottom: 1px solid var(--line);
  background: #fbfcfa;
}

.topbar h1 {
  margin: 0;
  font-size: 22px;
  line-height: 1.2;
  letter-spacing: 0;
}

.topbar p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(280px, 360px) minmax(420px, 1fr) minmax(280px, 340px);
  gap: 16px;
  padding: 16px;
  align-items: start;
}

.panel {
  min-width: 0;
  background: transparent;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 42px;
  margin-bottom: 10px;
}

.panel-header h2 {
  margin: 0;
  font-size: 17px;
  letter-spacing: 0;
}

.metric {
  min-width: 36px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
  font-size: 13px;
}

.drop-zone {
  display: grid;
  place-items: center;
  min-height: 160px;
  border: 1.5px dashed #a8b5a8;
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
  cursor: pointer;
  text-align: center;
  padding: 22px;
}

.drop-zone.dragover {
  border-color: var(--focus);
  background: #eef7f3;
}

.drop-zone input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.drop-title {
  display: block;
  font-size: 17px;
  font-weight: 650;
}

.drop-meta {
  display: block;
  margin-top: 8px;
  color: var(--muted);
  font-size: 13px;
}

.actions,
.report-form {
  display: flex;
  gap: 8px;
  margin: 12px 0;
}

.actions button {
  flex: 1;
}

.queue-list,
.invoice-list,
.report-list {
  display: grid;
  gap: 10px;
}

.queue-item,
.invoice-card,
.report-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.queue-item {
  padding: 12px;
}

.queue-name {
  overflow-wrap: anywhere;
  font-weight: 650;
  line-height: 1.35;
}

.queue-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 12px;
}

.badge.warning {
  border-color: #dfb36d;
  background: #fff6e6;
  color: var(--warning);
}

.badge.danger {
  border-color: #df958c;
  background: #fff0ee;
  color: var(--danger);
}

.invoice-card {
  display: grid;
  grid-template-columns: minmax(180px, 260px) minmax(280px, 1fr);
  min-height: 340px;
  overflow: hidden;
}

.invoice-preview {
  background: #edf0ea;
  border-right: 1px solid var(--line);
  min-height: 340px;
  display: grid;
  place-items: center;
  padding: 10px;
}

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

.invoice-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  padding: 12px;
}

.invoice-form .wide {
  grid-column: 1 / -1;
}

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

input,
textarea {
  min-width: 0;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  padding: 9px 10px;
}

textarea {
  resize: vertical;
}

input:focus,
textarea:focus,
button:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.form-footer {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border-top: 1px solid var(--line);
  padding-top: 10px;
}

.form-footer button {
  min-width: 110px;
}

.report-form {
  align-items: end;
}

.report-form label {
  flex: 1;
}

.report-item {
  display: grid;
  gap: 6px;
  padding: 12px;
}

.report-title {
  font-weight: 650;
}

.report-meta {
  color: var(--muted);
  font-size: 13px;
}

.report-item a {
  color: var(--accent);
  font-weight: 650;
  text-decoration: none;
}

.empty {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
  padding: 18px;
  text-align: center;
}

.toast {
  position: fixed;
  right: 16px;
  bottom: 16px;
  max-width: min(420px, calc(100vw - 32px));
  border-radius: 8px;
  background: #17201a;
  color: #fff;
  padding: 12px 14px;
  opacity: 0;
  transform: translateY(12px);
  pointer-events: none;
  transition: opacity 160ms ease, transform 160ms ease;
  box-shadow: var(--shadow);
}

.toast.visible {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 1100px) {
  .workspace {
    grid-template-columns: 1fr 1fr;
  }

  .reports-panel {
    grid-column: 1 / -1;
  }
}

@media (max-width: 760px) {
  .topbar {
    padding: 14px;
  }

  .workspace {
    grid-template-columns: 1fr;
    padding: 12px;
  }

  .reports-panel {
    grid-column: auto;
  }

  .invoice-card {
    grid-template-columns: 1fr;
  }

  .invoice-preview {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .invoice-form {
    grid-template-columns: 1fr;
  }
}
