:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #f9fafb;
  --ink: #111827;
  --muted: #667085;
  --line: #d8dde5;
  --accent: #126c5a;
  --accent-strong: #0b4f42;
  --blue: #2563eb;
  --danger: #b42318;
  --shadow: 0 12px 30px rgba(17, 24, 39, 0.08);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background:
    linear-gradient(180deg, #eef4f2 0, rgba(238, 244, 242, 0) 260px),
    var(--bg);
  color: var(--ink);
}

a {
  color: inherit;
}

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

button,
a.button {
  min-height: 38px;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 0 14px;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  white-space: nowrap;
}

button:disabled,
.upload-link.disabled {
  cursor: not-allowed;
  opacity: 0.58;
}

.primary {
  background: var(--accent);
  color: #ffffff;
}

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

.secondary,
.ghost {
  background: #ffffff;
  color: var(--ink);
  border-color: var(--line);
}

.secondary:hover,
.ghost:hover {
  border-color: #aeb8c7;
}

.hidden {
  display: none !important;
}

.topbar {
  height: 68px;
  padding: 0 32px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 8px 24px rgba(17, 24, 39, 0.04);
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand {
  display: flex;
  align-items: baseline;
  gap: 10px;
  text-decoration: none;
}

.brand span {
  font-size: 18px;
  font-weight: 700;
}

.brand strong {
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

.session-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--muted);
  font-size: 14px;
}

main {
  width: min(1280px, calc(100vw - 36px));
  margin: 0 auto;
}

.auth-layout {
  min-height: calc(100vh - 64px);
  display: grid;
  grid-template-columns: minmax(0, 1fr) 390px;
  gap: 44px;
  align-items: center;
  padding: 54px 0;
}

.auth-copy p,
.workspace-head p {
  margin: 0 0 10px;
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
}

.auth-copy h1,
.workspace-head h1 {
  margin: 0;
  font-size: 42px;
  line-height: 1.12;
  letter-spacing: 0;
}

.auth-copy span {
  display: block;
  margin-top: 18px;
  color: var(--muted);
  font-size: 17px;
  line-height: 1.7;
  max-width: 560px;
}

.auth-panel,
.admin-toolbar,
.orders-panel,
.detail-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.auth-panel {
  padding: 22px;
}

.tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  padding: 4px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 7px;
  margin-bottom: 18px;
}

.tab {
  border-radius: 5px;
  background: transparent;
  color: var(--muted);
}

.tab.active {
  background: #ffffff;
  color: var(--ink);
  border-color: var(--line);
}

.form-stack,
.order-form {
  display: grid;
  gap: 14px;
}

.form-stack label,
.order-form label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

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

textarea {
  resize: vertical;
  line-height: 1.55;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(18, 108, 90, 0.12);
}

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

.message.error {
  color: var(--danger);
}

.workspace {
  padding: 30px 0 52px;
}

.workspace-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  margin-bottom: 20px;
}

.workspace-head h1 {
  font-size: 32px;
}

.summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

.summary div {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  box-shadow: 0 8px 22px rgba(17, 24, 39, 0.05);
}

.summary span,
.section-head span,
.order-card small,
.detail-meta dt {
  color: var(--muted);
  font-size: 13px;
}

.summary strong {
  display: block;
  margin-top: 8px;
  font-size: 24px;
}

.admin-toolbar {
  padding: 12px;
  margin-bottom: 18px;
  display: flex;
  align-items: center;
  gap: 12px;
  justify-content: space-between;
}

.section-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.section-head h2 {
  margin: 0 0 5px;
  font-size: 18px;
}

.section-head input {
  max-width: 280px;
}

.order-form {
  grid-template-columns: 1fr;
  gap: 20px;
}

.span-2 {
  grid-column: span 2;
}

.span-4 {
  grid-column: 1 / -1;
}

.form-section {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdfc;
  padding: 20px;
}

.form-section-head {
  display: flex;
  gap: 12px;
  align-items: start;
  margin-bottom: 18px;
  padding-bottom: 14px;
  border-bottom: 1px solid #e4ece9;
}

.form-section-head > span {
  width: 26px;
  height: 26px;
  display: inline-grid;
  place-items: center;
  border-radius: 999px;
  background: #126c5a;
  color: #ffffff;
  font-size: 13px;
  font-weight: 800;
  flex: 0 0 auto;
}

.form-section-head strong,
.form-section-head small {
  display: block;
}

.form-section-head strong {
  color: var(--ink);
  font-size: 15px;
}

.form-section-head small {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px 18px;
  align-items: start;
}

.compact-field {
  max-width: 160px;
}

.form-actions {
  position: sticky;
  bottom: -22px;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 12px;
  justify-content: flex-end;
  padding: 14px 0 0;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0), #ffffff 28%);
}

.orders-layout {
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
  gap: 20px;
  align-items: start;
}

.orders-panel,
.detail-panel {
  padding: 18px;
}

.detail-panel {
  background: #eef2f5;
}

.orders-list {
  display: grid;
  gap: 10px;
  max-height: calc(100vh - 286px);
  overflow: auto;
  padding-right: 4px;
}

.order-card {
  width: 100%;
  text-align: left;
  border: 1px solid var(--line);
  background: #ffffff;
  border-radius: 8px;
  padding: 15px;
  display: grid;
  gap: 9px;
  transition: border-color 140ms ease, box-shadow 140ms ease, transform 140ms ease;
}

.order-card:hover,
.order-card.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(18, 108, 90, 0.1);
}

.order-card:hover {
  transform: translateY(-1px);
}

.order-card strong {
  font-size: 15px;
}

.order-card-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.status {
  display: inline-flex;
  align-items: center;
  border: 1px solid #c9d8d3;
  color: var(--accent-strong);
  background: #edf7f4;
  border-radius: 999px;
  min-height: 26px;
  padding: 0 9px;
  font-size: 12px;
  font-weight: 700;
}

.amount {
  font-weight: 700;
}

.empty-detail,
.empty-list {
  min-height: 240px;
  display: grid;
  place-items: center;
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  text-align: center;
  padding: 20px;
}

.voucher-tools {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
  color: var(--muted);
  font-size: 13px;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
}

.voucher-tool-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.pdf-link {
  min-height: 38px;
  border-radius: 6px;
  padding: 0 14px;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  background: var(--accent);
  color: #ffffff;
  font-weight: 700;
  box-shadow: 0 8px 18px rgba(18, 108, 90, 0.18);
}

.voucher-sheet {
  background: #ffffff;
  border: 1px solid #d7e0e7;
  border-radius: 4px;
  min-height: 780px;
  padding: 42px 46px 48px;
  color: #172126;
  box-shadow: 0 18px 48px rgba(17, 24, 39, 0.12);
}

.voucher-company {
  text-align: center;
  font-size: 15px;
  font-weight: 600;
  color: #26343d;
}

.voucher-sheet h2 {
  margin: 24px 0 18px;
  text-align: center;
  font-size: 34px;
  letter-spacing: 0;
  font-weight: 700;
}

.voucher-rule {
  border-top: 2px solid #1f2937;
  margin-bottom: 18px;
}

.voucher-order-meta {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  color: #526776;
  font-size: 14px;
  margin-bottom: 34px;
}

.voucher-section {
  margin-top: 28px;
}

.voucher-section h3 {
  margin: 0 0 12px;
  font-size: 19px;
  letter-spacing: 0;
}

.voucher-customer-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  border: 1px solid #d4dde5;
  background: #ffffff;
}

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

.voucher-status-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  border: 1px solid #d4dde5;
  background: #ffffff;
}

.voucher-status-grid div {
  min-height: 58px;
  padding: 11px 14px;
  border-right: 1px solid #d4dde5;
  border-bottom: 1px solid #d4dde5;
}

.voucher-status-grid div:nth-child(3n) {
  border-right: 0;
}

.voucher-status-grid div:nth-last-child(-n + 3) {
  border-bottom: 0;
}

.voucher-status-grid span {
  display: block;
  color: #526776;
  font-size: 12px;
}

.voucher-status-grid strong {
  display: block;
  margin-top: 6px;
  font-size: 14px;
  overflow-wrap: anywhere;
}

.voucher-customer-grid div {
  display: grid;
  grid-template-columns: 88px minmax(0, 1fr);
  min-height: 48px;
  align-items: center;
  padding: 0 14px;
  border-right: 1px solid #d4dde5;
}

.voucher-customer-grid div:last-child {
  border-right: 0;
}

.voucher-customer-grid span,
.voucher-head span,
.voucher-total span {
  color: #526776;
  font-size: 13px;
}

.voucher-customer-grid strong {
  font-size: 14px;
  overflow-wrap: anywhere;
}

.voucher-table {
  border: 1px solid #d4dde5;
  background: #ffffff;
}

.voucher-row {
  display: grid;
  grid-template-columns: 17% 31% 12% 7% 7% 13% 13%;
}

.voucher-row > * {
  border-right: 1px solid #d4dde5;
  padding: 14px 12px;
  min-width: 0;
}

.voucher-row > *:last-child {
  border-right: 0;
}

.voucher-head {
  background: #f6faf9;
  border-bottom: 1px solid #d4dde5;
  text-align: center;
}

.voucher-body {
  min-height: 208px;
}

.voucher-body > strong,
.voucher-body > span {
  font-size: 15px;
}

.voucher-body > span {
  text-align: center;
}

.voucher-body > span:nth-last-child(-n + 2) {
  text-align: right;
}

.voucher-body p {
  margin: 0 0 12px;
  line-height: 1.65;
  overflow-wrap: anywhere;
}

.voucher-body p span {
  font-weight: 700;
}

.voucher-total {
  width: min(390px, 100%);
  margin: 30px 0 0 auto;
  border: 2px solid #1f2937;
  background: #ffffff;
}

.voucher-total div {
  display: grid;
  grid-template-columns: 40% 60%;
  min-height: 42px;
  align-items: center;
}

.voucher-total div + div {
  border-top: 1px solid #d4dde5;
}

.voucher-total span,
.voucher-total strong {
  padding: 0 16px;
}

.voucher-total strong {
  text-align: right;
  font-size: 17px;
}

.voucher-note {
  margin: 36px 0 0;
  color: #526776;
  line-height: 1.8;
  font-size: 13px;
  max-width: 560px;
}

.voucher-files {
  border-top: 1px solid #d4dde5;
  margin-top: 26px;
  padding-top: 18px;
}

.voucher-files h3 {
  margin: 0 0 12px;
  font-size: 16px;
}

.voucher-file-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.secondary-link,
.upload-link {
  min-height: 36px;
  border: 1px solid #d4dde5;
  border-radius: 6px;
  padding: 0 12px;
  display: inline-flex;
  align-items: center;
  text-decoration: none;
  background: #ffffff;
  color: var(--ink);
  cursor: pointer;
}

.upload-link input {
  display: none;
}

.danger-button {
  background: #fff5f5;
  color: var(--danger);
  border-color: #f2b8b5;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 24px;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.48);
}

.modal-panel {
  position: relative;
  z-index: 1;
  width: min(1180px, calc(100vw - 32px));
  max-height: min(90vh, 900px);
  overflow: auto;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 24px 70px rgba(15, 23, 42, 0.24);
  padding: 26px;
}

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

.modal-head h2 {
  margin: 0 0 6px;
}

.modal-head span {
  color: var(--muted);
  font-size: 13px;
}

.icon-button {
  width: 36px;
  min-height: 36px;
  padding: 0;
  border-color: var(--line);
  background: #ffffff;
  color: var(--muted);
  font-size: 22px;
}

@media (max-width: 980px) {
  main {
    width: min(100vw - 24px, 720px);
  }

  .auth-layout,
  .orders-layout {
    grid-template-columns: 1fr;
  }

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

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

  .orders-list {
    max-height: none;
  }
}

@media (max-width: 620px) {
  .topbar {
    height: auto;
    min-height: 60px;
    padding: 12px;
  }

  .auth-copy h1 {
    font-size: 30px;
  }

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

  .span-2 {
    grid-column: auto;
  }

  .span-4 {
    grid-column: 1 / -1;
  }

  .form-grid .span-2,
  .form-grid .span-4 {
    grid-column: 1 / -1;
  }

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

  .voucher-row > * {
    border-right: 0;
    border-bottom: 1px solid #d4dde5;
  }

  .voucher-row > *:last-child {
    border-bottom: 0;
  }

  .voucher-head {
    display: none;
  }

  .voucher-body {
    min-height: auto;
  }

  .voucher-customer-grid {
    grid-template-columns: 1fr;
  }

  .voucher-status-grid {
    grid-template-columns: 1fr;
  }

  .voucher-status-grid div,
  .voucher-status-grid div:nth-child(3n),
  .voucher-status-grid div:nth-last-child(-n + 3) {
    border-right: 0;
    border-bottom: 1px solid #d4dde5;
  }

  .voucher-status-grid div:last-child {
    border-bottom: 0;
  }

  .voucher-customer-grid div {
    border-right: 0;
    border-bottom: 1px solid #d4dde5;
  }

  .voucher-customer-grid div:last-child {
    border-bottom: 0;
  }

  .section-head,
  .workspace-head,
  .voucher-tools,
  .voucher-order-meta {
    flex-direction: column;
    align-items: stretch;
  }

  .section-head input {
    max-width: none;
  }

  .modal {
    padding: 10px;
    align-items: stretch;
  }

  .modal-panel {
    width: 100%;
    max-height: calc(100vh - 20px);
    padding: 16px;
  }

  .form-section {
    padding: 14px;
  }
}
