* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "Segoe UI", "Microsoft YaHei", "PingFang SC", sans-serif;
  font-size: 14px;
  color: #1f2937;
  background: #f3f4f6;
}
main { padding: 16px 24px 48px; }
h1 { font-size: 20px; } h2 { font-size: 16px; margin-top: 28px; }
a { color: #1d4ed8; text-decoration: none; }
a:hover { text-decoration: underline; }
.hint { color: #6b7280; font-size: 13px; }

/* Top bar */
.topbar {
  display: flex; align-items: center; gap: 24px;
  background: #111827; color: #fff; padding: 0 24px; height: 48px;
}
.topbar .brand { font-weight: 600; }
.topbar nav { display: flex; gap: 16px; flex: 1; }
.topbar nav a { color: #d1d5db; }
.topbar nav a:hover { color: #fff; text-decoration: none; }
.userbox { display: flex; align-items: center; gap: 8px; color: #d1d5db; }

/* Flash */
.flash { padding: 10px 24px; }
.flash-success { background: #dcfce7; color: #166534; }
.flash-error { background: #fee2e2; color: #991b1b; }
.flash-warning { background: #fef9c3; color: #854d0e; }

/* Buttons & forms */
button, .btn-plain {
  font: inherit; padding: 6px 14px; border-radius: 6px; cursor: pointer;
  border: 1px solid #1d4ed8; background: #1d4ed8; color: #fff;
}
button:hover { background: #1e40af; }
button:disabled { background: #9ca3af; border-color: #9ca3af; cursor: not-allowed; }
.btn-plain { background: #fff; color: #1f2937; border-color: #d1d5db; display: inline-block; }
.btn-plain:hover { text-decoration: none; background: #f9fafb; }
button.linklike {
  background: none; border: none; color: #1d4ed8; padding: 0; font-size: inherit;
}
button.linklike:hover { text-decoration: underline; background: none; }
button.linklike.danger { color: #b91c1c; }
input, select, textarea {
  font: inherit; padding: 6px 8px; border: 1px solid #d1d5db; border-radius: 6px;
  background: #fff;
}
input:focus, select:focus, textarea:focus { outline: 2px solid #93c5fd; }

/* Filters */
.filters { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0 16px; align-items: center; }

/* Tables */
.table-wrap { overflow-x: auto; background: #fff; border: 1px solid #e5e7eb; border-radius: 8px; }
table.data { border-collapse: collapse; width: 100%; background: #fff; }
table.data th, table.data td { padding: 6px 10px; border-bottom: 1px solid #e5e7eb; text-align: left; white-space: nowrap; }
table.data td.desc { white-space: normal; min-width: 220px; }
table.data th { background: #f9fafb; position: sticky; top: 0; }
table.data td.num, table.data th.num { text-align: right; }
table.data tfoot td { font-weight: 600; background: #f9fafb; }
table.data .empty { text-align: center; color: #6b7280; padding: 24px; }
td.actions { display: flex; gap: 8px; align-items: center; }
td.issues { color: #b91c1c; white-space: normal; }

/* Status colors */
.status-select { font-size: 13px; }
.status-arrived_not_delivered { background: #ede9fe; }
.status-delivering_awaiting_do { background: #fef9c3; }
.status-cancelled_awaiting_supplier_inv { background: #fee2e2; }
.status-delivered { background: #dcfce7; }

/* Preview rows */
tr.row-error { background: #fef2f2; }
tr.row-dup { background: #fefce8; }
.preview-summary { display: flex; gap: 8px; margin: 12px 0; }
.badge { padding: 4px 10px; border-radius: 999px; font-size: 13px; }
.badge-ok { background: #dcfce7; color: #166534; }
.badge-dup { background: #fef9c3; color: #854d0e; }
.badge-err { background: #fee2e2; color: #991b1b; }

/* Dashboard cards */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; margin: 16px 0; }
.card {
  display: block; padding: 16px; border-radius: 8px; border: 1px solid #e5e7eb;
  background: #fff; color: inherit;
}
.card:hover { text-decoration: none; box-shadow: 0 2px 8px rgba(0,0,0,.08); }
.card-count { font-size: 28px; font-weight: 700; margin: 4px 0; }
.card-sub { color: #6b7280; font-size: 13px; }

/* PO form */
.po-form { max-width: 900px; }
.po-form fieldset {
  border: 1px solid #e5e7eb; border-radius: 8px; background: #fff;
  display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px; padding: 16px; margin-bottom: 16px;
}
.po-form legend { font-weight: 600; padding: 0 6px; }
.po-form label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: #374151; }
.po-form label.wide { grid-column: 1 / -1; }
.totals-preview { margin: 8px 0 16px; font-weight: 600; color: #166534; }
.form-actions { display: flex; gap: 12px; align-items: center; }
.confirm-form { margin-top: 16px; display: flex; gap: 16px; align-items: center; }
.checkbox { display: flex; gap: 6px; align-items: center; }

/* Upload */
.upload-form { background: #fff; border: 1px solid #e5e7eb; border-radius: 8px; padding: 20px; max-width: 560px; display: flex; flex-direction: column; gap: 12px; align-items: flex-start; }

/* Pager */
.pager { display: flex; gap: 6px; margin-top: 12px; }
.pager .current { font-weight: 700; padding: 2px 8px; }
.pager a { padding: 2px 8px; }

/* Login */
body.login-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.login-card {
  background: #fff; border: 1px solid #e5e7eb; border-radius: 12px;
  padding: 32px; width: 360px; box-shadow: 0 4px 16px rgba(0,0,0,.06);
}
.login-card h1 { font-size: 18px; margin: 0 0 4px; }
.login-card form { display: flex; flex-direction: column; gap: 14px; margin-top: 16px; }
.login-card label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: #374151; }
.login-card .flash { border-radius: 6px; padding: 8px 12px; font-size: 13px; }
