:root {
  color-scheme: light;
  --ink: #172026;
  --muted: #66717b;
  --line: #d8dee4;
  --soft: #f4f7f6;
  --paper: #ffffff;
  --accent: #23675a;
  --accent-strong: #174b42;
  --gold: #c88a20;
  --red: #b6423c;
  --blue: #315f9c;
  --shadow: 0 16px 40px rgba(23, 32, 38, 0.1);
  font-family: "Microsoft JhengHei", "PingFang TC", "Noto Sans TC", Arial, sans-serif;
}

/* 全站統一字級：桌面 16pt、手機 14pt。 */
html,
body,
body * {
  font-size: 16pt !important;
}

@media (max-width: 620px) {
  html,
  body,
  body * {
    font-size: 14pt !important;
  }
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: #f5f8fb;
  color: var(--ink);
}

[hidden] {
  display: none !important;
}

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

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  min-height: 100vh;
}

.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: #eef4f1;
}

.login-panel {
  width: min(420px, 100%);
  display: grid;
  gap: 16px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 28px;
}

.login-logo {
  width: min(280px, 100%);
  height: 180px;
  object-fit: contain;
  justify-self: center;
}

.login-panel h1 {
  margin: 4px 0 0;
  font-size: 30px;
  text-align: center;
}

.login-panel .eyebrow {
  text-align: center;
}

.login-error {
  margin: 0;
  color: var(--red);
  font-weight: 700;
}

.sidebar {
  position: sticky;
  top: 0;
  align-self: start;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  height: 100vh;
  overflow: hidden;
  background: #e5f3ef;
  color: #173c35;
  border-right: 1px solid #c7e1da;
  padding: 24px 18px;
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 14px;
}

.brand-copy {
  min-width: 0;
}

.bluetooth-device-button {
  flex: 0 0 auto;
  min-height: 38px;
  margin-left: auto;
  padding: 6px 10px;
  color: #ffffff;
  background: #164f86;
  border-color: #164f86;
  white-space: nowrap;
}

.bluetooth-device-button:hover {
  background: #0e3d6c;
}

.bluetooth-device-button.is-connected {
  background: #176b4f;
  border-color: #176b4f;
}

@media (min-width: 901px) {
  .bluetooth-device-button {
    display: none;
  }
}

.brand-logo {
  width: 64px;
  height: 46px;
  border-radius: 8px;
  background: #ffffff;
  object-fit: contain;
  padding: 4px;
}

.brand h1,
.brand p,
.topbar h2,
.topbar p,
.dialog-head h3,
.dialog-head p {
  margin: 0;
}

.brand h1 {
  font-size: 20px;
  letter-spacing: 0;
}

.brand p {
  color: #5f7e77;
  font-size: 13px;
  margin-top: 3px;
}

.sidebar-account {
  display: grid;
  gap: 10px;
  margin-bottom: 18px;
  padding: 12px;
  background: #f5fbf9;
  border: 1px solid #c7e1da;
  border-radius: 10px;
}

.sidebar-account .user-badge {
  display: block;
  color: #315c53;
  white-space: normal;
  line-height: 1.45;
}

.sidebar-account-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 7px;
}

.sidebar-account-actions .ghost-button {
  min-height: 36px;
  padding: 0 8px;
  background: #ffffff;
  font-size: 13px;
}

.sidebar-account-actions #changePasswordButton,
.sidebar-account-actions #exportButton {
  color: #ffffff;
  background: #164f86;
  border-color: #164f86;
}

.sidebar-account-actions #changePasswordButton {
  font-size: 10pt !important;
  white-space: nowrap;
}

.sidebar-account-actions #logoutButton {
  color: #ffffff;
  background: #b94a13;
  border-color: #b94a13;
}

.sidebar-account-actions #changePasswordButton:hover,
.sidebar-account-actions #exportButton:hover {
  background: #0e3d6c;
}

.sidebar-account-actions #logoutButton:hover {
  background: #91380d;
}

.sidebar-account-actions #logoutButton {
  grid-column: 1 / -1;
}

.module-nav {
  display: grid;
  min-height: 0;
  align-content: start;
  overflow-y: auto;
  gap: 6px;
  padding: 8px;
  background: #eaf3ff;
  border: 1px solid #cedff3;
  border-radius: 10px;
}

.nav-button {
  width: 100%;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #315c53;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px;
  text-align: left;
}

.nav-button:hover,
.nav-button.active {
  background: #cce7df;
  color: #153f36;
}

.nav-order-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  min-width: 21px;
  height: 21px;
  margin-left: auto;
  padding: 0 6px;
  border-radius: 999px;
  background: #d92d20;
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.nav-icon {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 7px;
  background: #f5fbf9;
  color: #23675a;
  font-size: 14px;
}

.workspace {
  min-width: 0;
  background: #f6f8fc;
  padding: 28px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  flex-wrap: nowrap;
  gap: 18px;
  overflow-x: auto;
  margin-bottom: 20px;
  padding: 18px;
  background: #eaf3ff;
  border: 1px solid #cedff3;
  border-radius: 10px;
}

.eyebrow {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.topbar h2 {
  font-size: 32px;
  margin-top: 4px;
}

.topbar-title-row,
.inventory-topbar-date {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 10px;
}

.inventory-topbar-date[hidden] {
  display: none;
}

.inventory-topbar-date {
  white-space: nowrap;
}

.inventory-topbar-date input {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  padding: 5px 9px;
}

.topbar-actions,
.dialog-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-badge {
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
  white-space: nowrap;
}

.primary-button,
.ghost-button,
.danger-button,
.icon-button {
  min-height: 40px;
  border-radius: 8px;
  border: 1px solid transparent;
  padding: 0 15px;
  font-weight: 700;
}

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

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

.ghost-button {
  background: var(--paper);
  color: var(--ink);
  border-color: var(--line);
}

.danger-button {
  background: #fff4f3;
  color: var(--red);
  border-color: #efc7c3;
}

.icon-button {
  width: 40px;
  padding: 0;
  background: transparent;
  border-color: var(--line);
  font-size: 24px;
  line-height: 1;
}

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

.transaction-volume-summary {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-start;
  gap: 28px;
  margin-bottom: 18px;
  padding: 14px 18px;
  border: 1px solid #efcbd5;
  border-radius: 8px;
  background: #fdecef;
  color: #6f263d;
  box-shadow: var(--shadow);
}

.transaction-volume-label {
  font-weight: 800;
}

.transaction-volume-summary strong {
  color: #8c2548;
  font-weight: 900;
}

.metric {
  background: #edf8f2;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  min-height: 96px;
}

.metric:nth-child(2) {
  background: #eef5ff;
  border-color: #cfdef2;
}

.metric:nth-child(3) {
  background: #fff8e8;
  border-color: #eadcb8;
}

.metric:nth-child(4) {
  background: #fff0f2;
  border-color: #edced4;
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 8px;
}

.metric strong {
  font-size: 26px;
}

.content-band {
  background: #f8f5ff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.content-band.pricing-view {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 460px;
}

.content-band.inventory-view {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 1px;
  background: var(--line);
}

.content-band.inventory-view .table-wrap,
.vehicle-inventory-panel {
  min-width: 0;
  background: #f8f5ff;
}

.inventory-panel-title {
  padding: 14px 16px;
  color: #173f37;
  background: #b8d0ca;
  font-weight: 900;
}

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

.content-band.inventory-view table {
  width: 100%;
  min-width: 620px;
}

.vehicle-inventory-panel table {
  width: 100%;
  min-width: 480px;
}

.inventory-inline-input {
  width: 78px;
  min-height: 40px;
  border: 1px solid #9db7b1;
  border-radius: 7px;
  background: #ffffff;
  padding: 5px 8px;
  text-align: right;
}

.content-band.inventory-view > .table-wrap th:nth-child(2),
.content-band.inventory-view > .table-wrap td:nth-child(2) {
  color: #197044;
  font-weight: 900;
}

.content-band.inventory-view > .table-wrap th:nth-child(5),
.content-band.inventory-view > .table-wrap td:nth-child(5),
.vehicle-inventory-panel th:nth-child(2),
.vehicle-inventory-panel td:nth-child(2) {
  color: #185fa8;
  font-weight: 900;
}

.content-band.inventory-view > .table-wrap th:nth-child(6),
.content-band.inventory-view > .table-wrap td:nth-child(6) {
  color: #c62828;
  font-weight: 900;
}

.vehicle-inventory-panel th:nth-child(2),
.vehicle-inventory-panel td:nth-child(2) {
  color: #185fa8;
  font-weight: 900;
}

.vehicle-inventory-panel th:nth-child(3),
.vehicle-inventory-panel td:nth-child(3) {
  color: #197044;
  font-weight: 900;
}

.vehicle-inventory-panel th:nth-child(4),
.vehicle-inventory-panel td:nth-child(4) {
  color: #a9470b;
  font-weight: 900;
}

.content-band.pricing-view .toolbar {
  grid-column: 1 / -1;
}

.toolbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 12px;
  padding: 16px;
  border-bottom: 1px solid var(--line);
  background: #fff8e8;
}

.search-box {
  display: grid;
  gap: 6px;
  width: min(460px, 100%);
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.search-box input,
.toolbar select,
.form-field input,
.form-field select,
.form-field textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--ink);
  min-height: 42px;
  padding: 9px 11px;
}

.toolbar select {
  max-width: 190px;
}

.pricing-date-filter {
  width: 100%;
}

.pricing-date-editbar {
  display: flex;
  flex-wrap: nowrap;
  width: 100%;
  gap: 8px;
  align-items: center;
  justify-content: space-between;
  overflow-x: auto;
}

.pricing-date-editbar input[type="date"] {
  width: 300px;
}

.pricing-date-inline {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.pricing-date-editbar > button,
.pricing-date-editbar > select {
  flex: 0 0 auto;
}

.content-band.pricing-view [data-pricing-inline-edit],
.content-band.pricing-view [data-pricing-copy] {
  border-color: #173f78;
  background: #1f4e8c;
  color: #ffffff;
}

.content-band.pricing-view #statusFilter {
  width: 300px;
  max-width: 300px;
  flex: 0 0 300px;
  margin-left: auto;
  border-color: var(--line);
  background: #ffffff;
  color: var(--ink);
}

.content-band.pricing-view [data-pricing-inline-edit]:hover,
.content-band.pricing-view [data-pricing-copy]:hover {
  background: #173f78;
}

.transaction-date-filter {
  display: flex;
  flex-wrap: nowrap;
  width: 100%;
  gap: 10px;
  align-items: center;
  flex: 1;
  max-width: none;
  overflow-x: auto;
}

.transaction-date-input,
.transaction-date-filter > select,
.transaction-date-filter > button,
.transaction-date-separator {
  flex: 0 0 auto;
}

.transaction-date-input input {
  width: 260px;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--ink);
  padding: 9px 11px;
}

.transaction-date-separator {
  font-weight: 900;
  color: var(--ink);
}

.transaction-date-filter #statusFilter {
  width: 220px;
  max-width: 220px;
  flex: 0 0 220px;
}

.month-report-filter {
  width: min(260px, 100%);
}

.copy-price-card {
  grid-template-columns: auto 1fr;
}

.copy-price-field {
  margin-top: 6px;
}

.table-wrap {
  position: relative;
  overflow-x: auto;
  background: #f8f5ff;
}

.pricing-date-panel {
  border-left: 1px solid var(--line);
  background: #fbfcfb;
  min-width: 0;
}

.pricing-date-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px;
  border-bottom: 1px solid #8da9ca;
  background: #a9bfd9;
}

.pricing-date-panel-head span {
  color: #173f78;
  font-size: 13px;
  font-weight: 800;
}

.pricing-date-panel-head strong {
  color: #173f78;
  font-size: 21px;
  font-weight: 900;
}

.pricing-default-date-button {
  width: fit-content;
  min-height: 38px;
  border: 1px solid #6f91ba;
  border-radius: 8px;
  background: #e7eff8;
  color: #173f78;
  padding: 6px 10px;
  font-size: 21px;
  font-weight: 900;
  text-align: left;
}

.pricing-default-date-button:hover {
  border-color: #315f9c;
  background: #d8e5f3;
  color: #173f78;
}

.pricing-date-panel-head small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.pricing-date-list {
  display: grid;
  gap: 8px;
  padding: 12px;
}

.pricing-date-row {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
}

.pricing-date-select,
.pricing-date-assign,
.pricing-date-delete {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--ink);
  padding: 8px 10px;
  font-weight: 800;
}

.pricing-date-select {
  flex: 1;
  text-align: left;
  min-width: 0;
}

.pricing-date-select span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pricing-date-select small {
  display: block;
  margin-top: 3px;
  color: #526675;
  font-size: 12px;
  font-weight: 800;
  line-height: 1.3;
}

.pricing-date-assign {
  min-width: 62px;
  color: #23675a;
  background: #f4faf7;
}

.pricing-date-delete {
  min-width: 58px;
  color: #a13631;
  background: #fff6f5;
  border-color: #efc5c1;
}

.pricing-date-row:hover .pricing-date-select,
.pricing-date-row.active .pricing-date-select {
  border-color: var(--accent);
  background: #eef7f4;
  color: var(--accent-strong);
}

.pricing-date-row.active .pricing-date-select {
  box-shadow: inset 4px 0 0 var(--accent);
}

.pricing-date-assign:hover,
.pricing-date-assign.active {
  border-color: #e3a09a;
  background: #fff1f0;
  color: #b6423c;
  font-weight: 900;
}

.pricing-date-delete:hover {
  border-color: #d06962;
  background: #ffe9e7;
  color: #8e2823;
  font-weight: 900;
}

.pricing-date-list p {
  margin: 0;
  color: var(--muted);
  font-weight: 700;
  line-height: 1.5;
}

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

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 13px 16px;
  text-align: left;
  vertical-align: middle;
  white-space: nowrap;
}

th {
  color: #173f37;
  font-size: 13px;
  background: #c6d8d3;
  font-weight: 900;
}

tbody tr {
  transition: background 0.15s ease;
}

tbody tr:hover {
  background: #f4faf7;
}

.date-group-row td {
  background: #edf6f2;
  color: #174b42;
  font-weight: 900;
}

.report-total-row td {
  background: #fff8ec;
  color: #173b31;
  font-size: 16px;
  font-weight: 900;
}

.report-note-row td {
  background: #fbfcfb;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.content-band.pricing-view table {
  min-width: 1000px;
}

.content-band.pricing-view thead th {
  background: #c6d8d3;
  color: #173f37;
  font-weight: 900;
}

.content-band.pricing-view tbody tr,
.content-band.pricing-view tbody tr:nth-child(even),
.content-band.pricing-view tbody td {
  background: #ffffff;
}

.content-band.pricing-view tbody tr:hover {
  background: #eaf6f2;
}

.content-band.pricing-view tbody tr:hover td {
  background: #ffffff;
}

.content-band.pricing-view tbody td:nth-child(1) {
  color: #1d5f91;
  font-weight: 900;
  white-space: nowrap;
}

.pricing-target-type.customer {
  color: #c83232;
  font-weight: 900;
}

.pricing-target-type.supplier {
  color: #23824f;
  font-weight: 900;
}

.content-band.pricing-view tbody td:nth-child(4) {
  color: #173b31;
  font-size: 16px;
  font-weight: 900;
}

.content-band.pricing-view tbody td:nth-child(6) {
  color: #9a5d08;
  font-weight: 900;
}

.content-band.pricing-view tbody td:nth-child(7) {
  color: #16653f;
  font-weight: 900;
}

.inline-price-input {
  width: min(140px, 100%);
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px 9px;
  color: inherit;
  font-weight: 900;
  text-align: right;
}

.content-band.pricing-view tbody td:nth-child(6) .inline-price-input {
  border-color: #e8c98f;
  background: #fff8ec;
}

.content-band.pricing-view tbody td:nth-child(7) .inline-price-input {
  border-color: #a7d9ba;
  background: #eefaf1;
}

.content-band.pricing-view tbody td:nth-child(2),
.content-band.pricing-view tbody td:nth-child(3),
.content-band.pricing-view tbody td:nth-child(5) {
  color: #4f5c66;
  font-weight: 800;
}

.row-action {
  border: 1px solid var(--line);
  background: #ffffff;
  border-radius: 8px;
  min-height: 34px;
  padding: 0 11px;
  white-space: nowrap;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  background: #e9f4f1;
  color: var(--accent-strong);
}

.pill.warn {
  background: #fff1db;
  color: #8a550d;
}

.pill.bad {
  background: #fde9e6;
  color: var(--red);
}

.empty-state {
  display: grid;
  place-items: center;
  gap: 6px;
  min-height: 220px;
  color: var(--muted);
}

.empty-state strong {
  color: var(--ink);
  font-size: 20px;
}

dialog {
  width: min(720px, calc(100vw - 28px));
  border: 0;
  border-radius: 8px;
  padding: 0;
  box-shadow: var(--shadow);
}

dialog:has(.pricing-batch) {
  width: min(1040px, calc(100vw - 28px));
}

dialog::backdrop {
  background: rgba(8, 15, 17, 0.48);
}

.confirm-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(8, 15, 17, 0.5);
}

dialog .confirm-overlay {
  position: fixed;
}

.confirm-card {
  width: min(430px, 100%);
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 14px;
  background: #ffffff;
  border: 1px solid #f0c7c2;
  border-radius: 8px;
  box-shadow: 0 22px 60px rgba(23, 32, 38, 0.24);
  padding: 20px;
}

.password-card {
  width: min(460px, 100%);
}

.bluetooth-setup-card {
  width: min(520px, 100%);
}

.certificate-download-link {
  grid-column: 1 / -1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 46px;
  color: #ffffff;
  background: #164f86;
  border-color: #164f86;
  text-decoration: none;
}

.certificate-download-link:hover {
  background: #0e3d6c;
}

.password-card .form-field,
.password-card .login-error {
  grid-column: 1 / -1;
}

.confirm-icon {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: #fff1f0;
  color: #b6423c;
  font-size: 22px;
  font-weight: 900;
}

.confirm-copy {
  display: grid;
  gap: 7px;
}

.confirm-copy strong {
  color: #172026;
  font-size: 20px;
}

.confirm-copy p {
  margin: 0;
  color: #66717b;
  line-height: 1.55;
}

.confirm-actions {
  grid-column: 1 / -1;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding-top: 8px;
}

.record-form {
  padding: 20px;
}

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

.dialog-head h3 {
  font-size: 24px;
}

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

.form-field {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.permission-field {
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
}

.permission-field legend {
  padding: 0 6px;
}

.permission-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.permission-grid label {
  display: flex;
  align-items: center;
  gap: 7px;
  min-height: 34px;
  color: var(--ink);
  font-weight: 700;
}

.permission-grid input {
  width: 16px;
  height: 16px;
}

.form-field.full {
  grid-column: 1 / -1;
}

.form-field:has(textarea[name="note"]),
.form-field:has(textarea[name="batchNote"]) {
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
}

.form-field textarea[name="note"],
.form-field textarea[name="batchNote"] {
  height: 40px;
  min-height: 40px;
  resize: vertical;
}

.pricing-batch {
  grid-column: 1 / -1;
  display: grid;
  gap: 14px;
}

.pricing-controls {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.pricing-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.pricing-table {
  min-width: 980px;
}

.transaction-table {
  table-layout: fixed;
  min-width: 900px;
}

.transaction-col-item {
  width: 25%;
}

.transaction-col-unit {
  width: 13%;
}

.transaction-col-qty {
  width: 13%;
}

.transaction-col-total {
  width: 13%;
}

.transaction-col-note {
  width: 20%;
}

.transaction-col-price {
  width: 16%;
}

.pricing-table th,
.pricing-table td {
  padding: 10px 12px;
}

.pricing-table thead th {
  background: #f2f7f5;
  color: #31524b;
  font-weight: 900;
}

.transaction-table .transaction-detail-header th {
  background: #fff;
  color: #173b31;
  font-size: 15px;
  text-align: left;
}

.transaction-table .transaction-detail-header .transaction-price-date {
  color: #e00000;
  text-align: left;
  white-space: nowrap;
}

.pricing-table tbody tr:nth-child(even) {
  background: #fcf7ef;
}

.pricing-table tbody tr:hover {
  background: #eaf6f2;
}

.pricing-table input {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px 9px;
}

.pricing-table strong {
  display: block;
  color: #173b31;
  font-size: 16px;
  font-weight: 900;
}

.pricing-table td:nth-child(2) {
  color: #66717b;
  font-weight: 800;
}

.pricing-table td:nth-child(3) input {
  color: #9a5d08;
  background: #fff8ec;
  border-color: #e8c98f;
  font-weight: 900;
}

.pricing-table td:nth-child(4) input {
  color: #16653f;
  background: #eefaf1;
  border-color: #a7d9ba;
  font-weight: 900;
}

.transaction-table .transaction-price-cell input {
  color: #16653f;
  background: #eefaf1;
  border-color: #a7d9ba;
  font-weight: 900;
}

.transaction-table .transaction-price-cell small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.transaction-table .qty-cell input {
  color: #1d5f91;
  background: #eef6ff;
  border-color: #accbe8;
  font-weight: 900;
}

.transaction-table [data-line-total] {
  color: #9a5d08;
  font-weight: 900;
}

.transaction-section-title {
  color: #173b31;
  font-size: 15px;
  font-weight: 900;
  padding: 4px 0;
}

.transaction-footer {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) repeat(3, minmax(150px, 1fr));
  gap: 14px;
  align-items: end;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
}

.transaction-total-box {
  display: grid;
  gap: 7px;
  min-height: 72px;
  align-content: center;
  padding: 12px;
  border: 1px solid #d6e8df;
  border-radius: 8px;
  background: #eefaf1;
}

.transaction-total-box span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.transaction-total-box strong {
  color: #16653f;
  font-size: 24px;
  font-weight: 900;
}

.checkbox-field {
  align-content: start;
}

.checkbox-field input {
  width: 18px;
  height: 18px;
  min-height: 18px;
  padding: 0;
}

.dialog-actions {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

dialog:has(.transaction-batch) .dialog-actions .ghost-button,
dialog:has(.transaction-batch) .dialog-actions .primary-button {
  width: 96px;
}

@media (max-width: 900px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 5;
    display: block;
    height: auto;
    overflow: visible;
    padding: 14px;
  }

  .brand {
    margin-bottom: 12px;
    gap: 8px;
  }

  .brand-logo {
    width: 58px;
    height: 42px;
  }

  .bluetooth-device-button {
    min-height: 36px;
    padding: 5px 8px;
    font-size: 14pt;
  }

  .module-nav {
    grid-auto-flow: column;
    grid-auto-columns: max-content;
    overflow-x: auto;
    overflow-y: hidden;
    padding-bottom: 2px;
  }

  .nav-button {
    white-space: nowrap;
  }

  .workspace {
    padding: 18px 14px;
  }

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

  .content-band.pricing-view {
    grid-template-columns: 1fr;
  }

  .content-band.inventory-view {
    grid-template-columns: 1fr;
  }

  .pricing-date-panel {
    border-left: 0;
    border-top: 1px solid var(--line);
  }
}

@media (max-width: 620px) {
  body {
    font-size: 16px;
  }

  .topbar {
    align-items: center;
    flex-direction: row;
  }

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

  .topbar-actions {
    display: flex;
    flex: 0 0 auto;
  }

  .primary-button,
  .ghost-button,
  .danger-button,
  .icon-button,
  .row-action {
    min-height: 48px;
    font-size: 16px;
  }

  .toolbar {
    align-items: stretch;
    flex-direction: column;
    padding: 14px;
  }

  .toolbar select {
    max-width: none;
  }

  .search-box {
    width: 100%;
    font-size: 15px;
  }

  .pricing-date-filter {
    width: 100%;
  }

  .pricing-date-editbar {
    grid-template-columns: 1fr;
  }

  .transaction-date-filter {
    width: 100%;
    max-width: none;
    grid-template-columns: 1fr;
  }

  .month-report-filter {
    width: 100%;
  }

  .search-box input,
  .toolbar select,
  .form-field input,
  .form-field select,
  .form-field textarea {
    min-height: 48px;
    font-size: 16px;
  }

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

  .metric {
    min-height: 82px;
  }

  .metric strong {
    font-size: 28px;
  }

  th,
  td {
    padding: 14px 12px;
  }

  .content-band.pricing-view .table-wrap {
    overflow-x: visible;
  }

  .content-band.pricing-view table,
  .content-band.pricing-view thead,
  .content-band.pricing-view tbody,
  .content-band.pricing-view tr,
  .content-band.pricing-view th,
  .content-band.pricing-view td {
    display: block;
    width: 100%;
    min-width: 0;
  }

  .content-band.pricing-view thead {
    display: none;
  }

  .content-band.pricing-view tbody {
    display: grid;
    gap: 12px;
    padding: 12px;
  }

  .content-band.pricing-view tbody tr {
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 12px;
    box-shadow: 0 8px 24px rgba(23, 32, 38, 0.08);
  }

  .content-band.pricing-view tbody td {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    min-height: 42px;
    padding: 8px 0;
    border-bottom: 1px solid #edf1f0;
    font-size: 17px;
  }

  .inline-price-input {
    width: min(190px, 55%);
    min-height: 44px;
    font-size: 17px;
  }

  .content-band.pricing-view tbody td::before {
    flex: 0 0 auto;
    color: var(--muted);
    font-size: 13px;
    font-weight: 900;
  }

  .content-band.pricing-view tbody td:nth-child(1)::before {
    content: "\65e5\671f";
  }

  .content-band.pricing-view tbody td:nth-child(2)::before {
    content: "\5c0d\8c61";
  }

  .content-band.pricing-view tbody td:nth-child(3)::before {
    content: "\5c0d\8c61\540d\7a31";
  }

  .content-band.pricing-view tbody td:nth-child(4)::before {
    content: "\54c1\540d";
  }

  .content-band.pricing-view tbody td:nth-child(5)::before {
    content: "\55ae\4f4d";
  }

  .content-band.pricing-view tbody td:nth-child(6)::before {
    content: "\9032\8ca8\55ae\50f9";
  }

  .content-band.pricing-view tbody td:nth-child(7)::before {
    content: "\51fa\8ca8\55ae\50f9";
  }

  .content-band.pricing-view tbody td:last-child {
    border-bottom: 0;
  }

  .content-band.pricing-view .row-action {
    width: 100%;
  }

  .pricing-controls {
    grid-template-columns: 1fr;
  }

  .transaction-footer {
    grid-template-columns: 1fr;
  }

  .pricing-date-panel-head {
    padding: 18px;
  }

  .pricing-date-panel-head strong {
    font-size: 24px;
  }

  .pricing-date-list {
    padding: 14px;
  }

  .pricing-date-select,
  .pricing-date-assign,
  .pricing-date-delete {
    min-height: 48px;
    font-size: 16px;
  }

  .pricing-table {
    min-width: 640px;
  }

  .pricing-table input {
    min-height: 46px;
    font-size: 16px;
  }

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

  .dialog-actions {
    grid-template-columns: 1fr;
  }

  .login-screen {
    padding: 12px;
  }

  .login-panel {
    width: 100%;
    max-width: 420px;
    gap: 14px;
    padding: 20px;
  }

  .login-logo {
    width: min(240px, 90%);
    height: 150px;
  }

  .sidebar {
    width: 100%;
    min-width: 0;
    max-width: 100vw;
    overflow: hidden;
    padding: 10px 10px 8px;
    box-shadow: 0 4px 16px rgba(8, 15, 17, 0.18);
  }

  .brand {
    margin-bottom: 8px;
    padding: 0 4px;
  }

  .brand h1 {
    font-size: 18px;
  }

  .brand p {
    display: none;
  }

  .sidebar-account {
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
    padding: 8px 10px;
  }

  .sidebar-account .user-badge {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 13px;
  }

  .sidebar-account-actions {
    display: flex;
    gap: 5px;
  }

  .sidebar-account-actions .ghost-button {
    min-height: 40px;
    padding: 0 9px;
    font-size: 13px;
  }

  .sidebar-account-actions #logoutButton {
    grid-column: auto;
  }

  .module-nav {
    width: calc(100% + 20px);
    min-width: 0;
    max-width: calc(100vw + 10px);
    gap: 8px;
    margin: 0 -10px;
    padding: 8px 10px;
    border-right: 0;
    border-left: 0;
    border-radius: 0;
    scrollbar-width: none;
  }

  .module-nav::-webkit-scrollbar {
    display: none;
  }

  .nav-button {
    min-height: 44px;
    padding: 8px 11px;
    border: 1px solid rgba(255, 255, 255, 0.1);
  }

  .nav-icon {
    width: 26px;
    height: 26px;
  }

  .workspace {
    width: 100%;
    min-width: 0;
    max-width: 100vw;
    overflow: hidden;
    padding: 14px 10px 28px;
  }

  .topbar {
    gap: 12px;
    margin-bottom: 14px;
  }

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

  .topbar-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .topbar-actions button {
    width: auto;
    padding: 0 10px;
  }

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

  .metric {
    min-height: 76px;
    padding: 12px;
  }

  .metric span {
    margin-bottom: 5px;
  }

  .metric strong {
    font-size: 23px;
  }

  .content-band {
    border-radius: 10px;
  }

  .content-band:not(.pricing-view) .table-wrap {
    overflow-x: visible;
  }

  .content-band:not(.pricing-view) table,
  .content-band:not(.pricing-view) thead,
  .content-band:not(.pricing-view) tbody,
  .content-band:not(.pricing-view) tr,
  .content-band:not(.pricing-view) th,
  .content-band:not(.pricing-view) td {
    display: block;
    width: 100%;
    min-width: 0;
  }

  .content-band:not(.pricing-view) thead {
    display: none;
  }

  .content-band:not(.pricing-view) tbody {
    display: grid;
    gap: 10px;
    padding: 10px;
  }

  .content-band:not(.pricing-view) tbody tr {
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: #ffffff;
    box-shadow: 0 6px 18px rgba(23, 32, 38, 0.07);
  }

  .content-band:not(.pricing-view) tbody td {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 14px;
    min-height: 44px;
    padding: 10px 12px;
    border-bottom: 1px solid #edf1f0;
    text-align: right;
    white-space: normal;
    overflow-wrap: anywhere;
  }

  .content-band:not(.pricing-view) tbody td::before {
    content: attr(data-label);
    flex: 0 0 34%;
    color: var(--muted);
    font-size: 13px;
    font-weight: 900;
    text-align: left;
  }

  .content-band:not(.pricing-view) tbody td:last-child {
    border-bottom: 0;
  }

  .content-band:not(.pricing-view) tbody td:only-child::before,
  .content-band:not(.pricing-view) tbody td[data-label=""]::before {
    display: none;
  }

  .content-band:not(.pricing-view) .row-action {
    width: 100%;
  }

  dialog,
  dialog:has(.pricing-batch) {
    width: calc(100vw - 16px);
    max-width: none;
    max-height: calc(100dvh - 16px);
    margin: auto;
  }

  .record-form {
    max-height: calc(100dvh - 16px);
    overflow-y: auto;
    padding: 16px;
  }

  .dialog-head {
    position: sticky;
    top: -16px;
    z-index: 3;
    background: var(--paper);
    padding-top: 4px;
  }

  .dialog-actions {
    position: sticky;
    bottom: -16px;
    z-index: 3;
    gap: 8px;
    background: var(--paper);
    padding-bottom: 4px;
  }

  .confirm-overlay {
    padding: 10px;
  }

  .confirm-card {
    grid-template-columns: 1fr;
    padding: 16px;
  }

  .confirm-icon {
    display: none;
  }

  .confirm-actions {
    grid-column: 1;
    display: grid;
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 480px) {
  .login-screen {
    min-height: 100dvh;
    padding:
      max(14px, env(safe-area-inset-top))
      max(14px, env(safe-area-inset-right))
      max(14px, env(safe-area-inset-bottom))
      max(14px, env(safe-area-inset-left));
  }

  .login-panel {
    border-radius: 16px;
    padding: 22px 20px;
  }

  .login-logo {
    width: min(260px, 92%);
    height: 170px;
  }

  .sidebar {
    padding:
      max(10px, env(safe-area-inset-top))
      max(10px, env(safe-area-inset-right))
      8px
      max(10px, env(safe-area-inset-left));
  }

  .module-nav {
    scroll-snap-type: x proximity;
    overscroll-behavior-x: contain;
    -webkit-overflow-scrolling: touch;
  }

  .nav-button {
    scroll-snap-align: start;
  }

  .workspace {
    min-height: calc(100dvh - 98px);
    padding:
      14px
      max(10px, env(safe-area-inset-right))
      max(32px, env(safe-area-inset-bottom))
      max(10px, env(safe-area-inset-left));
  }

  .topbar-actions {
    display: flex;
  }

  .topbar-actions #newRecordButton {
    min-height: 52px;
    font-size: 17px;
  }

  .summary-grid {
    gap: 10px;
  }

  .metric {
    border-radius: 10px;
  }

  .toolbar {
    gap: 10px;
  }

  .content-band:not(.pricing-view) tbody {
    gap: 12px;
    padding: 10px;
  }

  .content-band:not(.pricing-view) tbody tr {
    border-radius: 12px;
  }

  dialog,
  dialog:has(.pricing-batch) {
    width: calc(100vw - max(16px, env(safe-area-inset-left) + env(safe-area-inset-right)));
    max-height: calc(100dvh - max(16px, env(safe-area-inset-top) + env(safe-area-inset-bottom)));
    border-radius: 14px;
  }

  .record-form {
    max-height: calc(100dvh - max(16px, env(safe-area-inset-top) + env(safe-area-inset-bottom)));
    padding-bottom: max(16px, env(safe-area-inset-bottom));
  }

  .dialog-actions {
    padding-bottom: max(4px, env(safe-area-inset-bottom));
  }
}

/* 手機捲動時固定完整抬頭與「頁面名稱＋新增資料」工具列。 */
@media (max-width: 620px) {
  .sidebar {
    position: sticky;
    top: 0;
    z-index: 10;
  }

  .workspace {
    overflow: visible;
  }

  .topbar {
    position: sticky;
    top: var(--mobile-sidebar-height, 150px);
    z-index: 9;
    margin: -14px -10px 14px;
    padding: 10px;
    background: #f6f8fc;
    border-bottom: 1px solid var(--line);
    box-shadow: 0 6px 16px rgba(23, 32, 38, 0.12);
  }
}
