:root {
  --ink: #17202e;
  --muted: #667085;
  --line: #d8e0ea;
  --line-soft: #edf1f6;
  --paper: #f4f7fa;
  --panel: #ffffff;
  --accent: #0f6f8c;
  --accent-dark: #0b5871;
  --accent-soft: #e6f4f8;
  --accent-2: #b45309;
  --ok: #166534;
  --warn: #9a3412;
  --danger: #b91c1c;
  --shadow: 0 10px 28px rgba(24, 33, 47, 0.07);
  --shadow-soft: 0 1px 2px rgba(24, 33, 47, 0.06);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  color: var(--ink);
  background:
    linear-gradient(180deg, #f8fafc 0, var(--paper) 260px),
    var(--paper);
  font-family: "Microsoft YaHei", "Segoe UI", sans-serif;
  font-size: 14px;
}

body:has(#detailDialog[open]) {
  overflow: hidden;
}

a {
  color: inherit;
  text-decoration: none;
}

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

select {
  appearance: none;
  background-image:
    linear-gradient(45deg, transparent 50%, #334155 50%),
    linear-gradient(135deg, #334155 50%, transparent 50%);
  background-position:
    calc(100% - 17px) 50%,
    calc(100% - 11px) 50%;
  background-repeat: no-repeat;
  background-size: 6px 6px, 6px 6px;
  padding-right: 34px !important;
}

button,
a,
input,
select,
textarea {
  transition: background-color 0.16s ease, border-color 0.16s ease, box-shadow 0.16s ease, color 0.16s ease, transform 0.16s ease;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid rgba(15, 111, 140, 0.18);
  outline-offset: 2px;
}

input[type="number"] {
  appearance: textfield;
  -moz-appearance: textfield;
}

input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

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

.sidebar {
  background: linear-gradient(180deg, #111827 0%, #172033 100%);
  color: #f8fafc;
  padding: 22px 16px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.sidebar-brand,
.login-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  display: inline-grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 8px;
  background: #fbbf24;
  color: #111827;
  font-weight: 800;
}

.sidebar-brand strong,
.sidebar-brand small {
  display: block;
}

.sidebar-brand small {
  margin-top: 4px;
  color: #aeb7c7;
}

.side-nav {
  display: grid;
  gap: 8px;
  margin-top: 28px;
}

.side-nav a,
.side-nav summary {
  border-radius: 8px;
  color: #cbd5e1;
  cursor: pointer;
  font-weight: 700;
  padding: 10px 12px;
}

.side-nav summary {
  align-items: center;
  display: flex;
  justify-content: space-between;
  list-style: none;
}

.side-nav summary::-webkit-details-marker {
  display: none;
}

.side-nav summary::after {
  border-bottom: 2px solid currentColor;
  border-right: 2px solid currentColor;
  content: "";
  height: 7px;
  opacity: 0.72;
  transform: rotate(45deg);
  transition: transform 0.16s ease;
  width: 7px;
}

.side-nav-group[open] summary::after {
  transform: rotate(225deg);
}

.side-nav a:hover,
.side-nav a.active,
.side-nav summary:hover,
.side-nav-group.active summary {
  background: rgba(255, 255, 255, 0.11);
  color: #ffffff;
}

.side-nav a.active,
.side-nav-group.active summary {
  box-shadow: inset 3px 0 0 #fbbf24;
}

.side-nav-home {
  display: block;
}

.side-nav-group {
  display: grid;
}

.side-nav-group-links {
  display: grid;
  gap: 2px;
  margin-top: 4px;
  padding-left: 10px;
}

.side-nav-group:not([open]) .side-nav-group-links {
  display: none;
}

.side-nav-group-links a {
  color: #9fb0c7;
  font-size: 13px;
  min-height: 34px;
  padding: 8px 10px 8px 16px;
}

.side-nav-group-links a.active {
  color: #ffffff;
}

.content-shell {
  min-width: 0;
  padding: 20px 28px 38px;
}

.quick-entry-launcher {
  align-items: center;
  background: #172033;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px 0 0 8px;
  border-right: 0;
  box-shadow: 0 8px 22px rgba(23, 32, 51, 0.22);
  color: #ffffff;
  display: flex;
  gap: 9px;
  height: 48px;
  justify-content: flex-start;
  overflow: hidden;
  padding: 0 13px;
  position: fixed;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  white-space: nowrap;
  width: 48px;
  z-index: 80;
}

.quick-entry-launcher:hover,
.quick-entry-launcher:focus-visible {
  background: var(--accent-dark);
  box-shadow: 0 10px 26px rgba(11, 88, 113, 0.3);
  color: #ffffff;
  transform: translateY(-50%);
  width: 126px;
}

.quick-entry-launcher svg {
  fill: none;
  flex: 0 0 22px;
  height: 22px;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
  width: 22px;
}

.quick-entry-launcher span {
  font-size: 13px;
  font-weight: 700;
  opacity: 0;
  transition: opacity 0.12s ease;
}

.quick-entry-launcher:hover span,
.quick-entry-launcher:focus-visible span {
  opacity: 1;
}

.quick-entry-dialog {
  background: var(--panel);
  border: 0;
  border-radius: 8px;
  box-shadow: 0 24px 70px rgba(15, 23, 42, 0.28);
  height: calc(100vh - 32px);
  inset: 16px 16px 16px auto;
  margin: 0;
  max-height: none;
  max-width: min(520px, calc(100vw - 32px));
  overflow: hidden;
  padding: 0;
  width: 100%;
}

.quick-entry-dialog[open] {
  display: grid;
  grid-template-rows: 64px minmax(0, 1fr);
}

.quick-entry-dialog::backdrop {
  background: rgba(15, 23, 42, 0.34);
}

.quick-entry-header {
  align-items: center;
  background: #172033;
  color: #ffffff;
  display: flex;
  justify-content: space-between;
  padding: 10px 14px 10px 18px;
}

.quick-entry-header div {
  display: grid;
  gap: 1px;
}

.quick-entry-header span {
  color: #a9bbc3;
  font-size: 11px;
  font-weight: 700;
}

.quick-entry-header h2 {
  font-size: 18px;
  line-height: 1.25;
  margin: 0;
}

.quick-entry-close {
  align-items: center;
  background: #263541;
  border: 1px solid #394955;
  border-radius: 8px;
  color: #ffffff;
  display: flex;
  height: 38px;
  justify-content: center;
  padding: 0;
  width: 38px;
}

.quick-entry-close:hover {
  background: #344654;
}

.quick-entry-close svg {
  fill: none;
  height: 19px;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
  width: 19px;
}

.quick-entry-dialog iframe {
  border: 0;
  height: 100%;
  min-height: 0;
  width: 100%;
}

body:has(.fixed-summary-bar:not([hidden])) .content-shell {
  padding-bottom: 104px;
}

.topbar,
.page-heading,
.panel-header,
.toolbar {
  display: flex;
  align-items: center;
}

.topbar {
  justify-content: space-between;
  gap: 20px;
  min-height: 48px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 22px;
}

.topbar span {
  margin-left: 12px;
  color: #667085 !important;
  font-size: 14px;
}

.account-actions {
  align-items: center;
  display: flex;
  gap: 8px;
  white-space: nowrap;
}

.master-approval-notice {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 12px;
  color: #963a16;
  background: #fff1dc;
  border: 1px solid #edc98f;
  border-radius: 9px;
  text-decoration: none;
  font-size: 14px;
}
.master-approval-notice[hidden] { display: none; }
.master-approval-notice:hover { background: #ffe5b9; }
.master-approval-notice:focus-visible { outline: 2px solid #963a16; outline-offset: 3px; }
.master-approval-notice svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }
@media (max-width: 900px) { .topbar, .account-actions { flex-wrap: wrap; } }

.account-actions span {
  color: var(--ink) !important;
  font-size: 14px;
  font-weight: 800;
  margin-left: 0;
}

.account-actions .ghost-button + .ghost-button,
.account-actions span + .ghost-button {
  border-left: 1px solid var(--line);
  border-radius: 0;
  padding-left: 12px;
}

.ghost-button,
.toolbar button,
.download-button,
.panel-header button,
.login-form > button,
.dialog-actions button,
.row-actions button,
.secondary-button,
.icon-button {
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 700;
}

.ghost-button {
  background: transparent;
  color: var(--accent);
  min-height: 34px;
  padding: 0 10px;
}

.ghost-button:hover {
  background: var(--accent-soft);
}

.page-heading {
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 16px;
}

.eyebrow {
  color: var(--accent);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0;
  margin: 0 0 8px;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  font-size: 26px;
  line-height: 1.25;
  margin-bottom: 0;
}

h2 {
  font-size: 17px;
  margin-bottom: 5px;
}

.toolbar {
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.toolbar input,
.login-form input,
.employee-toolbar input,
.employee-toolbar select,
.dialog-form input,
.dialog-form select,
.dialog-form textarea,
.report-panel input,
.report-panel select,
.ledger-text-filter input,
.business-rules-grid input,
.business-rules-grid select,
.settings-grid input,
.settings-grid select,
.inline-create input,
.inline-create select,
.compact-table input,
.compact-table select,
.master-row input,
.partner-row input {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  min-height: 38px;
  padding: 0 12px;
}

.toolbar input:hover,
.login-form input:hover,
.employee-toolbar input:hover,
.employee-toolbar select:hover,
.dialog-form input:hover,
.dialog-form textarea:hover,
.report-panel input:hover,
.report-panel select:hover,
.ledger-text-filter input:hover,
.business-rules-grid input:hover,
.business-rules-grid select:hover,
.settings-grid input:hover,
.settings-grid select:hover,
.inline-create input:hover,
.inline-create select:hover,
.compact-table input:hover,
.compact-table select:hover,
.master-row input:hover,
.partner-row input:hover,
.filter-grid input:hover,
.filter-grid select:hover,
.pagination-bar select:hover,
.master-filter:hover {
  border-color: #b9c6d6;
}

.toolbar input:focus,
.login-form input:focus,
.employee-toolbar input:focus,
.employee-toolbar select:focus,
.dialog-form input:focus,
.dialog-form textarea:focus,
.report-panel input:focus,
.report-panel select:focus,
.ledger-text-filter input:focus,
.business-rules-grid input:focus,
.business-rules-grid select:focus,
.settings-grid input:focus,
.settings-grid select:focus,
.inline-create input:focus,
.inline-create select:focus,
.compact-table input:focus,
.compact-table select:focus,
.master-row input:focus,
.partner-row input:focus,
.filter-grid input:focus,
.filter-grid select:focus,
.pagination-bar select:focus,
.master-filter:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 111, 140, 0.12);
  outline: 0;
}

.toolbar button,
.download-button,
.panel-header button,
.login-form > button,
.dialog-actions button,
.row-actions button,
.business-rules-grid button,
.settings-grid button {
  background: var(--accent);
  color: #fff;
  min-height: 38px;
  padding: 0 14px;
}

.toolbar button:hover,
.download-button:hover,
.panel-header button:hover,
.login-form > button:hover,
.dialog-actions button:hover,
.row-actions button:hover,
.business-rules-grid button:hover,
.master-list-actions button:hover,
.inline-create button:hover,
.transfer-actions button:hover,
.settings-grid button:hover {
  background: var(--accent-dark);
}

.download-button {
  display: inline-flex;
  align-items: center;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(128px, 1fr));
  gap: 12px;
  margin: 18px 0 16px;
}

.metric-grid article,
.panel,
.login-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow-soft);
}

.metric-grid article {
  min-height: 92px;
  padding: 16px;
}

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

.metric-grid strong {
  font-size: 24px;
  line-height: 1;
}

.work-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(320px, 0.55fr);
  gap: 16px;
}

.module-page {
  display: grid;
  gap: 16px;
}

.module-page .panel {
  min-width: 0;
}

.business-ledger-page {
  width: 100%;
}

.dashboard-shortcuts,
.business-entry-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-top: 14px;
}

.dashboard-shortcuts a,
.business-entry-grid article {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  display: grid;
  gap: 8px;
  min-height: 92px;
  padding: 16px;
}

.dashboard-shortcuts a:hover {
  border-color: #b8d8e3;
  box-shadow: var(--shadow);
  transform: translateY(-1px);
}

.dashboard-shortcuts strong,
.business-entry-grid strong {
  font-size: 16px;
}

.dashboard-shortcuts span,
.business-entry-grid span {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.panel {
  padding: 16px;
}

.panel-wide {
  grid-row: span 2;
}

.panel-header {
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line-soft);
}

.panel-header p {
  color: var(--muted);
  font-size: 14px;
  margin-bottom: 0;
}

.tab-bar {
  align-items: center;
  background: #eef4f8;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: inline-flex;
  gap: 4px;
  margin-bottom: 14px;
  padding: 4px;
}

.tab-bar button {
  background: transparent;
  border: 0;
  border-radius: 6px;
  color: var(--muted);
  cursor: pointer;
  font-weight: 800;
  min-height: 34px;
  padding: 0 14px;
}

.tab-bar button.active {
  background: #fff;
  color: var(--accent);
  box-shadow: var(--shadow-soft);
}

.business-tab-panel[hidden] {
  display: none;
}

.organization-tabs {
  margin-bottom: 0;
  width: fit-content;
}

.organization-tab-panel {
  min-width: 0;
}

.organization-tab-panel[hidden] {
  display: none;
}

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

.employee-toolbar {
  align-items: end;
  background: #f8fafc;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  display: grid;
  gap: 10px;
  grid-template-columns: minmax(150px, 0.55fr) minmax(220px, 1fr);
  margin-bottom: 12px;
  padding: 10px 12px;
}

.employee-toolbar label {
  color: var(--muted);
  display: grid;
  font-size: 12px;
  font-weight: 800;
  gap: 4px;
}

.employee-toolbar input,
.employee-toolbar select {
  min-height: 38px;
  width: 100%;
}

.employee-table { min-width: 980px; }
.employee-table td:first-child strong { color: var(--ink); }

.employee-role-list {
  display: flex;
  gap: 5px;
}

.employee-role {
  border: 1px solid transparent;
  border-radius: 4px;
  display: inline-flex;
  font-size: 12px;
  font-weight: 800;
  line-height: 24px;
  padding: 0 7px;
}

.employee-role.buyer {
  background: #e8f4ef;
  border-color: #b9dccc;
  color: #176447;
}

.employee-role.saler {
  background: #edf3f8;
  border-color: #c7d8e7;
  color: #245a78;
}

.muted-text { color: var(--muted); }

.employee-dialog { max-width: min(620px, calc(100vw - 28px)); }

#employeeCommissionField[hidden] {
  display: none;
}

.employee-role-field {
  border: 1px solid var(--line);
  border-radius: 8px;
  display: flex;
  gap: 18px;
  margin: 0;
  padding: 10px 12px 12px;
}

.employee-role-field legend {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  padding: 0 4px;
}

.dialog-form .employee-role-field label {
  align-items: center;
  color: var(--ink);
  display: inline-flex;
  font-size: 14px;
  gap: 7px;
}

.dialog-form .employee-role-field input[type="checkbox"] {
  flex: 0 0 18px;
  height: 18px;
  margin: 0;
  min-height: 18px;
  width: 18px;
}

.table-wrap.sticky-header-table {
  max-height: calc(100vh - 300px);
  min-height: 260px;
  overflow: auto;
}

.sticky-header-table th {
  box-shadow: 0 1px 0 var(--line);
  position: sticky;
  top: 0;
  z-index: 4;
}

.ledger-table-wrap.sticky-header-table {
  max-height: calc(100vh - 286px);
}

.report-table.sticky-header-table {
  max-height: calc(100vh - 360px);
}

.expense-table-wrap {
  max-height: calc(100vh - 230px);
  overflow: auto;
}

.table-x-scroll {
  border: 1px solid var(--line);
  border-bottom: 0;
  border-radius: 8px 8px 0 0;
  height: 18px;
  overflow-x: auto;
  overflow-y: hidden;
  background: #f8fafc;
}

.table-x-scroll-spacer {
  height: 1px;
}

.expense-x-scroll + .expense-table-wrap {
  border-radius: 0 0 8px 8px;
}

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

th,
td {
  border-bottom: 1px solid var(--line-soft);
  padding: 11px 12px;
  text-align: left;
  white-space: nowrap;
}

th:last-child,
td:last-child {
  min-width: 96px;
}

th {
  background: #f8fafc;
  color: #536176;
  font-size: 13px;
  font-weight: 800;
}

.expense-table {
  min-width: 3950px;
}

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

.expense-table .amount-col {
  min-width: 96px;
  text-align: right;
}

.expense-table .remark-col {
  max-width: 360px;
  min-width: 260px;
  white-space: normal;
}

.expense-table .action-col {
  min-width: 86px;
}

.expense-table .sticky-col {
  background: #fff;
  position: sticky;
  z-index: 2;
}

.expense-table th.sticky-col {
  background: #f8fafc;
  z-index: 3;
}

.expense-table .sticky-store {
  left: 0;
  min-width: 84px;
}

.expense-table .sticky-car {
  left: 84px;
  min-width: 170px;
}

.expense-table .sticky-plate {
  left: 254px;
  min-width: 126px;
}

.expense-table .sticky-total {
  box-shadow: 8px 0 14px rgba(24, 33, 47, 0.06);
  font-weight: 800;
  left: 380px;
  min-width: 118px;
  text-align: right;
}

tbody tr:hover {
  background: #fbfdff;
}

tbody tr:last-child td {
  border-bottom: 0;
}

tfoot td {
  background: #f8fafc;
  border-top: 1px solid var(--line);
  color: var(--ink) !important;
  font-weight: 800;
}

.fixed-summary-bar {
  align-items: center;
  backdrop-filter: blur(10px);
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid var(--line);
  border-radius: 8px;
  bottom: 12px;
  box-shadow: 0 -10px 24px rgba(24, 33, 47, 0.09);
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  left: 264px;
  margin-top: 0;
  padding: 8px;
  position: fixed;
  right: 28px;
  z-index: 30;
}

.fixed-summary-bar[hidden] {
  display: none;
}

.summary-item {
  align-items: center;
  background: #f8fafc;
  border: 1px solid var(--line-soft);
  border-radius: 7px;
  color: var(--muted);
  display: inline-flex;
  gap: 8px;
  min-height: 34px;
  padding: 0 10px;
  white-space: nowrap;
}

.summary-item strong {
  color: var(--ink);
  font-size: 15px;
}

.summary-item.emphasis {
  background: #eef6ff;
  border-color: #bfdbfe;
}

.summary-item.emphasis strong {
  color: var(--accent);
}

.badge {
  border-radius: 999px;
  display: inline-flex;
  font-size: 12px;
  font-weight: 800;
  padding: 4px 9px;
}

.badge.ok {
  background: #dcfce7;
  color: var(--ok);
}

.badge.warn {
  background: #ffedd5;
  color: var(--warn);
}

.badge.sold {
  background: #f1f5f9;
  color: #475569;
}

.badge.void {
  background: #fee2e2;
  color: var(--danger);
}

.badge.info {
  background: #e0f2fe;
  color: #0369a1;
}

.stack-list {
  display: grid;
  gap: 10px;
}

.stack-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 12px;
}

.stack-item:hover {
  border-color: #b8d8e3;
}

.stack-item strong {
  display: block;
  margin-bottom: 6px;
}

.stack-item span,
.report-links span {
  color: var(--muted);
  display: block;
  font-size: 14px;
}

.report-links {
  display: grid;
  gap: 10px;
}

.report-links a {
  color: var(--accent);
  font-weight: 800;
}

.row-actions {
  align-items: center;
  display: inline-flex;
  gap: 6px;
}

.row-actions button {
  min-height: 32px;
  padding: 0 10px;
}

.danger-button {
  background: var(--danger) !important;
}

.danger-outline-button {
  background: #fff1f2 !important;
  color: var(--danger) !important;
}

.danger-outline-button:hover:not(:disabled) {
  background: #fee2e2 !important;
}

.more-menu {
  position: relative;
}

.more-menu-trigger {
  background: #e8edf4 !important;
  color: var(--ink) !important;
  font-size: 18px;
  letter-spacing: 0;
  min-width: 34px;
  padding: 0 8px !important;
}

.more-menu-trigger:hover {
  background: #dce5ef !important;
}

.more-menu-list {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 16px 34px rgba(15, 23, 42, 0.16);
  display: none;
  min-width: 112px;
  padding: 6px;
  position: fixed;
  left: var(--more-menu-left);
  top: var(--more-menu-top);
  transform: translateX(-100%);
  z-index: 1200;
}

.more-menu.open .more-menu-list {
  display: grid;
  gap: 2px;
}

.more-menu-list button {
  background: transparent !important;
  border-radius: 6px;
  color: var(--ink) !important;
  display: block;
  font-weight: 700;
  min-height: 34px;
  padding: 0 10px !important;
  text-align: left;
  width: 100%;
}

.more-menu-list button:hover {
  background: #f1f5f9 !important;
}

.more-menu-list .danger-menu-item {
  color: #b91c1c !important;
}

.more-menu-list .danger-menu-item:hover {
  background: #fee2e2 !important;
}

.combobox-panel {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 18px 36px rgba(15, 23, 42, 0.18);
  display: grid;
  gap: 2px;
  max-height: 260px;
  overflow-y: auto;
  padding: 6px;
  position: absolute;
  z-index: 1000;
}

.combobox-panel button {
  background: transparent;
  border: 0;
  border-radius: 6px;
  color: var(--ink);
  cursor: pointer;
  font-weight: 700;
  min-height: 34px;
  padding: 0 10px;
  text-align: left;
}

.combobox-panel button:hover {
  background: var(--accent-soft);
  color: var(--accent-dark);
}

input[data-combobox],
.dialog-form input[data-combobox],
.partner-row input[data-combobox] {
  background-color: #fff;
  background-image:
    linear-gradient(45deg, transparent 50%, #17202e 50%),
    linear-gradient(135deg, #17202e 50%, transparent 50%);
  background-position:
    calc(100% - 17px) 50%,
    calc(100% - 11px) 50%;
  background-repeat: no-repeat;
  background-size: 6px 6px, 6px 6px;
  padding-right: 34px !important;
}

.invalid-combobox {
  border-color: var(--danger) !important;
  box-shadow: 0 0 0 3px rgba(185, 28, 28, 0.12) !important;
}

.secondary-button,
.icon-button {
  background: #e8edf4;
  color: var(--ink);
  min-height: 36px;
  padding: 0 12px;
}

.secondary-button:hover,
.icon-button:hover {
  background: #dce5ef;
}

.icon-button {
  display: inline-grid;
  font-size: 24px;
  height: 36px;
  line-height: 1;
  place-items: center;
  width: 36px;
}

.app-dialog {
  border: 0;
  border-radius: 8px;
  box-shadow: 0 30px 80px rgba(15, 23, 42, 0.26);
  max-width: min(760px, calc(100vw - 28px));
  padding: 0;
  width: 100%;
}

.detail-dialog {
  max-width: min(1660px, calc(100vw - 20px));
  overflow: hidden;
}

.user-dialog {
  max-width: min(640px, calc(100vw - 28px));
}

.store-group-heading th {
  background: #edf3f7;
  border-bottom-color: #d6e0e9;
  padding: 8px 12px;
}

.store-group-heading th > div {
  align-items: center;
  display: flex;
  gap: 10px;
  justify-content: space-between;
}

.store-group-heading strong { color: var(--ink); font-size: 14px; }
.store-group-heading span { color: var(--muted); font-size: 12px; font-weight: 700; }

.password-dialog {
  max-width: min(620px, calc(100vw - 28px));
}

.detail-dialog .dialog-form {
  gap: 6px;
  height: calc(100vh - 28px);
  max-height: calc(100vh - 28px);
  min-height: 0;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  overflow: hidden;
  padding: 12px 16px 10px;
}

.detail-header-actions {
  align-items: center;
  display: flex;
  gap: 8px;
}

.compact-button { min-height: 34px; padding: 6px 10px; }
.file-button { cursor: pointer; display: inline-flex; width: max-content; }
.danger-icon-button { color: #b42318; }

.app-dialog::backdrop {
  background: rgba(15, 23, 42, 0.38);
}

.dialog-form {
  display: grid;
  gap: 16px;
  padding: 20px;
}

.dialog-header,
.dialog-actions,
.inline-header {
  align-items: center;
  display: flex;
  gap: 14px;
  justify-content: space-between;
}

.dialog-header p {
  color: var(--muted);
  font-size: 14px;
  margin-bottom: 0;
}

.dialog-header h2 {
  line-height: 1.25;
  margin-bottom: 2px;
}

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

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

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

.purchase-source-rate {
  display: grid;
  gap: 8px;
  grid-column: span 2;
  grid-template-columns: minmax(0, 1fr) minmax(120px, 0.72fr);
}

.purchase-source-rate:has(#purchaseMessageFeeRateField[hidden]) {
  grid-template-columns: minmax(0, 1fr);
}

#purchaseMessageFeeRateField[hidden] {
  display: none;
}

.dialog-form input,
.dialog-form select,
.dialog-form textarea {
  color: var(--ink);
  min-height: 34px;
  width: 100%;
}

.dialog-form textarea {
  min-height: 38px;
  padding-top: 8px;
  resize: vertical;
}

input[type="date"].empty-date {
  color: transparent;
  position: relative;
}

input[type="date"].empty-date::before {
  color: var(--muted);
  content: attr(data-date-placeholder);
  font-weight: 700;
  left: 12px;
  pointer-events: none;
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
}

input[type="date"].empty-date:focus {
  color: var(--ink);
}

input[type="date"].empty-date:focus::before {
  content: "";
}

.detail-dialog.readonly-business input[type="date"].empty-date,
.detail-dialog.readonly-business input[type="date"].empty-date::-webkit-datetime-edit {
  color: transparent !important;
}

.detail-dialog.readonly-business input[type="date"].empty-date::before {
  content: "";
}

.dialog-actions {
  border-top: 1px solid var(--line);
  padding-top: 8px;
}

.dialog-actions button:disabled,
.toolbar button:disabled,
.panel-header button:disabled,
.row-actions button:disabled {
  background: #cbd5e1 !important;
  color: #64748b !important;
  cursor: not-allowed;
  transform: none;
}

.detail-scroll {
  max-height: none;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  padding-right: 4px;
  scrollbar-gutter: stable;
}

.detail-grid {
  align-content: start;
  display: grid;
  gap: 8px;
  grid-template-columns: 1fr;
  height: 100%;
  grid-template-rows: auto minmax(0, 1fr);
}

.business-summary-grid {
  align-content: start;
  align-items: start;
  display: grid;
  gap: 8px;
  grid-template-columns: minmax(420px, 1fr) minmax(420px, 1fr);
}

.purchase-business-column,
.sale-profit-stack {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.purchase-business-column {
  align-content: start;
}

.sale-profit-stack {
  grid-template-rows: auto 1fr;
}

.detail-section {
  align-self: start;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 6px;
  padding: 9px 12px;
  align-content: start;
}

.detail-section .form-grid {
  gap: 5px 8px;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  justify-content: start;
}

.expense-section .dense-grid {
  grid-template-columns: repeat(auto-fit, minmax(132px, 1fr));
}

.expense-section #expenseFields {
  align-content: start;
  display: grid;
  gap: 6px;
  grid-template-columns: 1fr;
}

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

.expense-total-pill {
  align-items: center;
  background: #f0f9ff;
  border: 1px solid #bae6fd;
  border-radius: 8px;
  color: #075985;
  display: inline-flex;
  gap: 8px;
  min-height: 28px;
  padding: 0 9px;
  white-space: nowrap;
}

.expense-total-pill span {
  color: #536176;
  font-size: 12px;
  font-weight: 800;
}

.expense-total-pill strong {
  color: #0f6f8c;
  font-size: 16px;
  line-height: 1;
}

.expense-group {
  align-items: start;
  background: #fbfdff;
  border: 1px solid #edf2f7;
  border-radius: 8px;
  display: grid;
  gap: 5px;
  grid-template-columns: 70px minmax(0, 1fr);
  min-width: 0;
  padding: 4px 6px;
}

.expense-group:first-child {
  border-top: 1px solid #edf2f7;
  padding-top: 4px;
}

.expense-group-title {
  color: #334155;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  margin: 0;
}

.expense-group-grid {
  display: grid;
  gap: 3px 7px;
  grid-template-columns: repeat(auto-fill, 118px);
  justify-content: start;
}

.expense-field {
  color: #667085;
  display: grid;
  gap: 2px;
  font-size: 11px;
  font-weight: 800;
  min-width: 0;
  width: 118px;
}

.expense-field input {
  height: 25px;
  min-height: 25px;
  padding: 0 8px;
}

.expense-group-other .expense-group-grid {
  grid-template-columns: repeat(auto-fill, 118px);
}

.expense-fixed-panel,
.expense-optional-panel {
  background: #fbfdff;
  border: 1px solid #edf2f7;
  border-radius: 8px;
  display: grid;
  gap: 5px;
  min-width: 0;
  padding: 6px;
}

.expense-panel-head {
  align-items: center;
  display: flex;
  gap: 8px;
  justify-content: space-between;
  min-width: 0;
}

.expense-panel-head h4 {
  color: #334155;
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0;
  margin: 0;
}

.expense-panel-head span {
  color: #8a96a8;
  font-size: 11px;
  font-weight: 800;
}

.expense-fixed-grid,
.expense-added-grid {
  display: grid;
  gap: 4px 7px;
  grid-template-columns: repeat(auto-fill, 118px);
  justify-content: start;
}

.expense-add-control {
  align-items: center;
  display: inline-flex;
  gap: 6px;
}

.expense-add-control select {
  border: 1px solid var(--line);
  border-radius: 8px;
  height: 28px;
  min-height: 28px;
  padding: 0 28px 0 9px;
  width: 126px;
}

.expense-add-control select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 111, 140, 0.12);
  outline: 0;
}

.expense-add-control button {
  min-height: 28px;
  padding: 0 10px;
}

.expense-input-wrap {
  align-items: center;
  display: flex;
  gap: 3px;
}

.expense-input-wrap input {
  min-width: 0;
  width: 100%;
}

.expense-input-wrap button {
  align-items: center;
  background: #f8fafc;
  border: 1px solid #d8e0ea;
  border-radius: 7px;
  color: #64748b;
  display: inline-flex;
  font-size: 16px;
  height: 25px;
  justify-content: center;
  line-height: 1;
  padding: 0;
  width: 25px;
}

.expense-input-wrap button:hover {
  background: #fff1f2;
  border-color: #fecdd3;
  color: #be123c;
}

.expense-field-removable {
  width: 146px;
}

.expense-field-removable .expense-input-wrap {
  width: 146px;
}

.expense-config-list {
  display: grid;
  gap: 12px;
}

.expense-config-tabs {
  align-items: center;
  background: #eef4f8;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: flex;
  gap: 5px;
  overflow-x: auto;
  padding: 5px;
  width: fit-content;
  max-width: 100%;
}

.expense-config-tabs button {
  align-items: center;
  background: transparent;
  border: 0;
  border-radius: 6px;
  color: var(--muted);
  display: inline-flex;
  font-weight: 700;
  gap: 7px;
  min-height: 34px;
  padding: 0 12px;
  white-space: nowrap;
}

.expense-config-tabs button span {
  background: #dbe6ed;
  border-radius: 10px;
  font-size: 11px;
  line-height: 18px;
  min-width: 18px;
  padding: 0 5px;
  text-align: center;
}

.expense-config-tabs button.active {
  background: #fff;
  box-shadow: var(--shadow-soft);
  color: var(--accent-dark);
}

.expense-config-group {
  display: grid;
  gap: 8px;
}

.expense-config-grid {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
}

.expense-config-item {
  align-content: center;
  align-items: start;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink);
  display: grid;
  gap: 5px;
  min-height: 66px;
  padding: 10px 12px;
  text-align: left;
}

.expense-config-item:hover {
  background: #f7fbfc;
  border-color: #9ccbd8;
}

.expense-config-item strong {
  font-size: 14px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.expense-config-item span {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.expense-config-item.inactive {
  background: #f8fafc;
  color: #7b8794;
}

.expense-item-dialog {
  width: min(560px, calc(100vw - 32px));
}

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

.detail-section .full-field {
  max-width: none;
}

.expense-section .full-field {
  gap: 2px;
}

.expense-section .full-field input {
  height: 26px;
  min-height: 26px;
}

.full-width-section {
  width: 100%;
}

.sale-section,
.profit-section {
  align-self: stretch;
}

.purchase-section {
  align-self: start;
  grid-auto-rows: max-content;
  min-height: 0;
}

.purchase-section .form-grid {
  align-items: start;
}

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

.purchase-heading {
  align-items: center;
  display: flex;
  gap: 10px;
  justify-content: space-between;
}

.detail-section h3 {
  font-size: 15px;
  margin: 0;
}

.detail-dialog.readonly-business .detail-section {
  background: #f8fafc;
}

.detail-dialog.readonly-business .detail-scroll input,
.detail-dialog.readonly-business .detail-scroll select,
.detail-dialog.readonly-business .detail-scroll textarea {
  background-color: #f1f5f9;
  color: #64748b;
  cursor: not-allowed;
}

.detail-dialog.readonly-business .settlement-toggle,
.detail-dialog.readonly-business .segmented-control label {
  cursor: not-allowed;
  opacity: 0.78;
}

.detail-dialog.readonly-business .partner-editor button {
  background: #e2e8f0 !important;
  color: #64748b !important;
  cursor: not-allowed;
}

.compact-segmented {
  background: #f8fafc;
  flex-shrink: 0;
  padding: 3px;
}

.compact-segmented label {
  font-size: 12px;
  min-height: 28px;
  padding: 0 9px;
}

.purchase-mode-toggle {
  width: max-content;
}

.purchase-mode-summary {
  align-items: center;
  background: #f7fafc;
  border: 1px solid var(--line-soft);
  border-left: 3px solid #708399;
  border-radius: 6px;
  color: #425466;
  display: flex;
  font-size: 13px;
  min-height: 34px;
  margin: 8px 0 10px;
  padding: 8px 10px;
}

.purchase-mode-summary[data-mode="partner"] { border-left-color: #b7791f; }
.purchase-mode-summary[data-mode="consignment"] { border-left-color: var(--accent); }
.purchase-mode-summary.amount-warning { color: #a52a2a; border-color: #e6a3a3; }

.partner-editor {
  display: grid;
  gap: 4px;
  margin-top: 0;
  border-top: 1px solid var(--line-soft);
  padding-top: 5px;
}

.partner-editor[hidden] {
  display: none;
}

.partner-empty-state {
  color: var(--muted);
  font-size: 13px;
  padding: 6px 0 3px;
}

.partner-editor .inline-header {
  min-height: 28px;
  justify-content: start;
}

.partner-editor .inline-header .secondary-button {
  min-height: 28px;
  padding: 0 10px;
}

.mini-stack {
  display: grid;
  gap: 4px;
}

.partner-row {
  align-items: center;
  display: grid;
  gap: 6px;
  grid-template-columns: minmax(210px, 360px) 132px 52px;
  justify-content: start;
  min-height: 30px;
}

.partner-row input {
  height: 30px;
  min-height: 30px;
  padding: 0 10px;
}

.partner-row button {
  height: 30px;
  min-height: 30px;
  padding: 0 8px;
}

.check-row {
  align-items: center;
  display: flex !important;
  flex-direction: row;
  gap: 8px;
  min-height: 40px;
}

.check-row input {
  min-height: 0;
  width: auto;
}

.settlement-toggle {
  align-items: center;
  background: #f8fafc;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  color: #536176;
  cursor: pointer;
  display: grid !important;
  gap: 10px;
  grid-template-columns: 34px minmax(0, 1fr);
  min-height: 46px;
  padding: 6px 10px;
  user-select: none;
}

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

.settlement-mark {
  align-items: center;
  background: #e2e8f0;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  color: #64748b;
  display: inline-flex;
  font-size: 20px;
  font-weight: 900;
  height: 34px;
  justify-content: center;
  line-height: 1;
  width: 34px;
}

.settlement-toggle strong,
.settlement-toggle small {
  display: block;
}

.settlement-toggle .settlement-text.settled {
  display: none;
}

.settlement-toggle .settlement-text.unsettled {
  display: inline;
}

.settlement-toggle:has(input:checked) .settlement-text.settled {
  display: inline;
}

.settlement-toggle:has(input:checked) .settlement-text.unsettled {
  display: none;
}

.settlement-toggle strong {
  color: #334155;
  font-size: 14px;
  line-height: 1.2;
}

.settlement-toggle small {
  color: #7b8797;
  font-size: 12px;
  font-weight: 700;
  margin-top: 1px;
}

.settlement-toggle:has(input:checked) {
  background: #ecfdf3;
  border-color: #22c55e;
  box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.12);
}

.settlement-toggle:has(input:checked) .settlement-mark {
  background: #16a34a;
  border-color: #15803d;
  color: #fff;
}

.settlement-toggle:has(input:checked) strong {
  color: #166534;
}

.notice-message:not(:empty) {
  background: #fff7ed;
  border: 1px solid #fed7aa;
  border-radius: 8px;
  color: var(--warn);
  padding: 10px 12px;
}

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

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

.profit-box div {
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 8px;
  min-height: 50px;
  padding: 5px 8px;
}

.profit-box span {
  color: var(--muted);
  display: block;
  font-size: 12px;
  margin-bottom: 2px;
}

.profit-box strong {
  font-size: 16px;
}

.profit-partners {
  grid-column: 1 / -1;
  min-height: 42px !important;
}

.profit-partners p {
  display: inline-block;
  margin: 0 14px 0 0;
}

.report-panel,
.settings-grid,
.business-rules-grid,
.master-data-grid {
  display: grid;
  gap: 14px;
}

.business-rules-panel {
  margin-bottom: 16px;
}

.business-rules-grid {
  align-items: start;
  background: #f8fafc;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  grid-template-columns: minmax(180px, 220px) minmax(260px, 320px) auto;
  justify-content: start;
  padding: 12px;
}

.business-rules-grid label {
  color: var(--muted);
  display: grid;
  gap: 6px;
  font-size: 13px;
  font-weight: 700;
}

.report-panel .form-grid {
  align-items: end;
  display: grid;
  gap: 10px 12px;
  grid-template-columns: repeat(4, minmax(130px, 1fr));
}

.report-panel .report-field {
  min-width: 0;
}

.report-field[hidden] {
  display: none !important;
}

.report-panel .report-field-wide {
  grid-column: span 2;
}

.report-type-tabs {
  justify-self: start;
  margin: 0;
}

.report-filter-shell {
  background: #f8fafc;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  display: grid;
  gap: 0;
  overflow: hidden;
}

.report-filter-section {
  align-items: start;
  background: transparent;
  border: 0;
  border-bottom: 1px solid #e2e8f0;
  display: grid;
  gap: 12px;
  grid-template-columns: 92px minmax(0, 1fr);
  padding: 9px 12px;
}

.report-filter-section:last-child {
  border-bottom: 0;
}

.report-filter-title {
  align-items: center;
  display: flex;
  min-height: 38px;
  min-width: 0;
}

.report-filter-title strong {
  color: var(--ink);
  font-size: 13px;
  line-height: 1.2;
}

.report-filter-fields {
  align-items: end;
  --report-control-width: 190px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  min-width: 0;
}

.report-filter-fields .report-field {
  color: var(--muted);
  display: grid;
  flex: 0 0 var(--report-control-width);
  font-size: 12px;
  font-weight: 700;
  gap: 4px;
}

.report-filter-fields .report-field input,
.report-filter-fields .report-field select {
  min-height: 36px;
  width: 100%;
}

.report-filter-fields .report-field-medium,
.report-filter-fields .report-field-short,
.report-filter-fields .report-field-narrow,
.report-filter-fields .report-field-days {
  flex: 0 0 var(--report-control-width);
}

.report-filter-fields .report-field-date-presets {
  flex: 0 1 360px;
}

.report-date-presets {
  align-items: center;
  display: inline-flex;
  flex-wrap: wrap;
  gap: 4px;
}

.report-date-presets button {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  min-height: 36px;
  padding: 0 10px;
}

.report-date-presets button.active,
.report-date-presets button:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.report-time-filters .report-field-days {
  flex-basis: var(--report-control-width);
}

.filter-grid {
  display: grid;
  gap: 10px;
  background: #f8fafc;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  margin-bottom: 14px;
  padding: 12px;
}

.car-filter-grid {
  align-items: end;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.car-filter-grid label {
  flex: 0 1 180px;
}

.car-filter-grid .filter-field-store {
  flex-basis: 190px;
}

.car-filter-grid .filter-field-keyword {
  flex: 1 1 360px;
}

.car-filter-grid .filter-field-status {
  flex-basis: 130px;
}

.car-filter-actions {
  align-items: center;
  display: flex;
  flex: 0 0 auto;
  min-height: 38px;
}

.car-filter-actions button {
  justify-content: center;
  min-width: 82px;
}

.filter-grid label {
  color: var(--muted);
  display: grid;
  gap: 6px;
  font-size: 13px;
  font-weight: 700;
}

.filter-grid input,
.filter-grid select,
.pagination-bar select,
.master-filter {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  min-height: 38px;
  padding: 0 12px;
}

.toolbar select,
.employee-toolbar select,
.dialog-form select,
.report-panel select,
.settings-grid select,
.inline-create select,
.compact-table select,
.filter-grid select,
.pagination-bar select {
  background-color: #fff;
  background-image:
    linear-gradient(45deg, transparent 50%, #334155 50%),
    linear-gradient(135deg, #334155 50%, transparent 50%);
  background-position:
    calc(100% - 17px) 50%,
    calc(100% - 11px) 50%;
  background-repeat: no-repeat;
  background-size: 6px 6px, 6px 6px;
  padding-right: 34px !important;
}

.pagination-bar {
  align-items: center;
  border-top: 1px solid var(--line);
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 12px;
  padding-top: 12px;
}

.pagination-bar span {
  color: var(--muted);
  margin-right: auto;
}

.pagination-bar label {
  align-items: center;
  color: var(--muted);
  display: inline-flex;
  font-size: 13px;
  font-weight: 700;
  gap: 8px;
  line-height: 1;
}

.pagination-bar select,
.pagination-bar button {
  align-items: center;
  display: inline-flex;
  height: 40px;
  justify-content: center;
  line-height: 1;
}

.pagination-bar select {
  min-height: 40px;
  min-width: 74px;
  padding-bottom: 0;
  padding-top: 0;
}

.pagination-bar button {
  min-height: 40px;
  padding: 0 15px;
}

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

.segmented-control {
  align-items: center;
  background: #eef4f8;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  width: fit-content;
}

.segmented-control label {
  align-items: center;
  border-radius: 6px;
  color: var(--muted);
  cursor: pointer;
  display: inline-flex;
  font-size: 13px;
  font-weight: 800;
  gap: 6px;
  min-height: 32px;
  padding: 0 10px;
}

.segmented-control label:has(input:checked) {
  background: #fff;
  color: var(--accent);
}

.segmented-control input {
  width: auto;
}

.report-actions {
  justify-content: flex-start;
}

.ledger-tools {
  align-items: center;
  background: #f8fafc;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  color: var(--muted);
  display: grid;
  grid-template-columns: minmax(210px, 1fr) auto minmax(430px, max-content) minmax(150px, auto) auto;
  font-size: 13px;
  font-weight: 700;
  gap: 8px 10px;
  justify-content: stretch;
  margin-bottom: 12px;
  padding: 10px 12px;
}

.ledger-status-text {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ledger-filter {
  display: grid;
  flex-shrink: 0;
  grid-template-columns: repeat(4, max-content);
  width: auto;
}

.ledger-filter label {
  justify-content: center;
  min-width: 0;
  padding: 0 10px;
  white-space: nowrap;
}

.ledger-filter label:has(input:checked) {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 8px 18px rgba(13, 116, 143, 0.22);
}

.ledger-date-filter {
  align-items: center;
  display: flex;
  flex: 0 1 auto;
  flex-wrap: nowrap;
  gap: 5px;
  justify-content: flex-end;
  min-width: 0;
  white-space: nowrap;
}

.ledger-date-filter > span:first-child {
  color: var(--text);
  font-weight: 800;
}

.ledger-date-filter input[type="date"] {
  font-size: 13px;
  height: 34px;
  padding: 6px 7px;
  width: 124px;
}

.ledger-text-filter {
  align-items: center;
  color: var(--text);
  display: inline-flex;
  flex: 0 0 auto;
  font-weight: 800;
  gap: 6px;
  white-space: nowrap;
}

.ledger-inline-filters {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 6px 10px;
  justify-content: flex-end;
  min-width: 0;
}

.ledger-text-filter input {
  font-size: 13px;
  height: 34px;
  padding: 6px 10px;
  width: 122px;
}

.sales-ledger-filters .ledger-text-filter input {
  width: 112px;
}

.ledger-action-tools {
  align-items: center;
  display: inline-flex;
  flex: 0 0 auto;
  gap: 6px;
}

.ledger-action-tools button {
  align-items: center;
  border-radius: 8px;
  display: inline-flex;
  justify-content: center;
  min-height: 34px;
  padding: 0 12px;
}

.ledger-search-button {
  min-width: 58px;
}

.ledger-export-button {
  box-shadow: 0 8px 18px rgba(13, 116, 143, 0.18);
  min-width: 94px;
}

.ledger-date-presets {
  align-items: center;
  display: inline-flex;
  gap: 3px;
}

.ledger-date-presets button {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  min-height: 34px;
  padding: 0 7px;
}

.ledger-date-presets button.active,
.ledger-date-presets button:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.date-range-separator {
  color: var(--muted);
  font-weight: 800;
}

.ledger-table {
  table-layout: fixed;
  min-width: 1480px;
  width: 100%;
}

.ledger-table-sales {
  min-width: 1420px;
  width: 100%;
}

.ledger-col-vin {
  width: 130px;
}

.ledger-table th,
.ledger-table td {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ledger-table th:last-child,
.ledger-table td:last-child {
  background: #fff;
  box-shadow: -8px 0 14px rgba(15, 23, 42, 0.08);
  position: sticky;
  right: 0;
  z-index: 2;
}

.ledger-table th:last-child {
  z-index: 4;
}

.ledger-table-purchases th:nth-child(5),
.ledger-table-purchases td:nth-child(5),
.ledger-table-purchases th:nth-child(11),
.ledger-table-purchases td:nth-child(11),
.ledger-table-sales th:nth-child(5),
.ledger-table-sales td:nth-child(5),
.ledger-table-sales th:nth-child(9),
.ledger-table-sales td:nth-child(9),
.ledger-table-sales th:nth-child(10),
.ledger-table-sales td:nth-child(10),
.ledger-table-sales th:nth-child(11),
.ledger-table-sales td:nth-child(11) {
  text-align: center;
}

.ledger-table-purchases th:nth-child(6),
.ledger-table-purchases td:nth-child(6),
.ledger-table-purchases th:nth-child(7),
.ledger-table-purchases td:nth-child(7),
.ledger-table-purchases th:nth-child(10),
.ledger-table-purchases td:nth-child(10),
.ledger-table-sales th:nth-child(6),
.ledger-table-sales td:nth-child(6),
.ledger-table-sales th:nth-child(7),
.ledger-table-sales td:nth-child(7) {
  text-align: right;
}

.payment-workspace {
  align-items: start;
  display: grid;
  gap: 16px;
  grid-template-columns: minmax(360px, 0.72fr) minmax(620px, 1fr);
}

.payment-editor-panel {
  position: sticky;
  top: 20px;
}

.payment-editor-panel input {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  min-height: 38px;
  padding: 0 12px;
  width: 100%;
}

.payment-editor-panel input:hover {
  border-color: #b9c6d6;
}

.payment-editor-panel input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 111, 140, 0.12);
  outline: 0;
}

.payment-editor-panel input:disabled,
.payment-editor-panel button:disabled {
  cursor: not-allowed;
  opacity: 0.62;
}

.payment-tabs {
  display: flex;
  width: 100%;
}

.payment-tabs button {
  flex: 1 1 0;
}

.payment-tab-panel[hidden] {
  display: none;
}

.payment-tab-panel.active {
  display: grid;
  gap: 12px;
}

.payment-watermark-toggle {
  min-height: 52px;
}

.payment-inline-header {
  margin-bottom: 10px;
}

.payment-account-list {
  display: grid;
  gap: 10px;
}

.payment-account-editor {
  background: #fbfcfe;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 10px;
  padding: 12px;
}

.payment-account-head {
  align-items: center;
  display: flex;
  justify-content: space-between;
}

.payment-account-head strong {
  color: #334155;
}

.payment-account-controls {
  display: inline-flex;
  gap: 6px;
}

.payment-account-controls button {
  background: #eef4f8;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: #334155;
  cursor: pointer;
  font-weight: 900;
  height: 30px;
  min-height: 30px;
  padding: 0;
  width: 32px;
}

.payment-account-controls button:hover {
  background: var(--accent-soft);
  border-color: #bad7e0;
  color: var(--accent-dark);
}

.payment-account-controls .delete-account:hover {
  background: #fef2f2;
  border-color: #fecaca;
  color: var(--danger);
}

.payment-account-fields {
  display: grid;
  gap: 10px;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.45fr);
}

.payment-account-fields .full-field {
  grid-column: 1 / -1;
}

.payment-upload-grid {
  display: grid;
  gap: 12px;
}

.payment-upload-item,
.payment-scale-control {
  background: #fbfcfe;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 10px;
  padding: 12px;
}

.payment-upload-item strong,
.payment-scale-control strong {
  display: block;
  color: #334155;
}

.payment-upload-item small,
.payment-scale-control output {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.payment-upload-box {
  align-items: center;
  background: #fff;
  border: 1px dashed #b7c5d6;
  border-radius: 8px;
  color: var(--accent);
  cursor: pointer;
  display: grid;
  gap: 8px;
  min-height: 122px;
  padding: 10px;
  place-items: center;
}

.payment-upload-box:hover {
  background: #f7fbfd;
  border-color: var(--accent);
}

.payment-upload-preview {
  background: #eef4f8;
  border-radius: 6px;
  display: block;
  height: 72px;
  width: 72px;
}

.payment-upload-preview.has-image {
  background-position: center;
  background-repeat: no-repeat;
  background-size: contain;
  height: 96px;
  width: 100%;
}

.payment-upload-copy {
  font-weight: 800;
}

.payment-scale-control span {
  align-items: center;
  display: flex;
  justify-content: space-between;
}

.payment-scale-control input {
  accent-color: var(--accent);
}

.payment-preview-stage {
  display: grid;
  gap: 10px;
  min-width: 0;
}

.payment-preview-toolbar {
  align-items: center;
  color: var(--muted);
  display: flex;
  justify-content: space-between;
}

.payment-preview-toolbar strong {
  color: var(--ink);
}

.payment-paper {
  --payment-alipay-scale: 85%;
  background: #fff;
  border: 1px solid #d7dde7;
  box-shadow: 0 18px 40px rgba(17, 24, 39, 0.12);
  color: #17202e;
  margin: 0 auto;
  min-height: 1040px;
  overflow: hidden;
  position: relative;
  width: min(100%, 760px);
}

.payment-paper-content {
  display: grid;
  gap: 30px;
  min-height: 1040px;
  padding: 52px 58px 38px;
  position: relative;
  z-index: 2;
}

.payment-document-header {
  text-align: center;
}

.payment-document-kicker {
  color: #64748b;
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0;
  margin-bottom: 12px;
}

.payment-document-header h2 {
  color: #111827;
  font-size: 25px;
  line-height: 1.35;
  margin: 0;
}

.payment-document-header h3 {
  color: #0f6f8c;
  font-size: 28px;
  line-height: 1.25;
  margin: 14px 0 0;
}

.payment-title-rule {
  display: flex;
  justify-content: center;
  margin-top: 18px;
}

.payment-title-rule span {
  background: linear-gradient(90deg, #0f6f8c, #f2b84b);
  border-radius: 999px;
  display: block;
  height: 4px;
  width: 110px;
}

.payment-bank-section,
.payment-code-section {
  display: grid;
  gap: 14px;
}

.payment-section-label {
  align-items: center;
  display: flex;
  gap: 10px;
}

.payment-section-label > span {
  background: #111827;
  border-radius: 6px;
  color: #fff;
  display: inline-grid;
  font-size: 13px;
  font-weight: 900;
  height: 32px;
  place-items: center;
  width: 32px;
}

.payment-section-label strong,
.payment-section-label small {
  display: block;
}

.payment-section-label small {
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  margin-top: 2px;
}

.payment-code-label {
  margin: 0 auto 10px;
  width: 94%;
}

.payment-table-wrap {
  border: 1px solid #cfd8e3;
  border-radius: 8px;
  overflow: hidden;
}

.payment-table-wrap table {
  border-collapse: collapse;
  min-width: 0;
  table-layout: fixed;
  width: 100%;
}

.payment-table-wrap th,
.payment-table-wrap td {
  border-bottom: 1px solid #e4eaf1;
  padding: 12px 14px;
  text-align: left;
  white-space: normal;
  word-break: break-word;
}

.payment-table-wrap th {
  background: #f1f6f9;
  color: #334155;
  font-size: 13px;
}

.payment-table-wrap tr:last-child td {
  border-bottom: 0;
}

.payment-table-wrap th:first-child,
.payment-table-wrap td:first-child {
  text-align: center;
  width: 58px;
}

.payment-table-wrap th:nth-child(2),
.payment-table-wrap td:nth-child(2) {
  width: 36%;
}

.payment-table-wrap th:nth-child(3),
.payment-table-wrap td:nth-child(3) {
  text-align: center;
  width: 18%;
}

.payment-qr-grid {
  align-items: start;
  display: grid;
  gap: 7%;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin: 0 auto;
  width: 94%;
}

.payment-qr-card {
  background: transparent;
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding: 0;
}

.payment-qr-image-wrap {
  align-items: center;
  aspect-ratio: 828 / 930;
  background: #f6f8f7;
  display: grid;
  justify-items: center;
  overflow: hidden;
  position: relative;
  width: 100%;
}

.payment-qr-image-wrap img {
  display: none;
  background: #fff;
  height: auto;
  left: 0;
  min-height: 100%;
  padding: 0;
  position: absolute;
  top: 0;
  width: 100%;
}

.payment-qr-image-wrap.has-image img {
  display: block;
}

.payment-qr-card-alipay .payment-qr-image-wrap {
  background: #1677ff;
}

#paymentAlipayPreviewWrap img {
  background: transparent;
  left: calc((100% - var(--payment-alipay-scale, 85%)) / 2);
  min-height: 0;
  transform: translateY(-17.5%);
  width: var(--payment-alipay-scale, 85%);
}

.payment-qr-empty {
  color: #8491a5;
  display: grid;
  gap: 4px;
  justify-items: center;
  text-align: center;
}

.payment-qr-empty span {
  border: 1px dashed #aebace;
  border-radius: 50%;
  display: inline-grid;
  font-size: 20px;
  height: 34px;
  place-items: center;
  width: 34px;
}

.payment-qr-empty strong {
  color: #64748b;
}

.payment-qr-image-wrap.has-image .payment-qr-empty {
  display: none;
}

.payment-qr-card-brand {
  align-items: center;
  display: flex;
  height: 48px;
  justify-content: center;
  margin-top: 8px;
}

.payment-brand-logo {
  display: block;
  height: 34px;
  max-width: 148px;
  object-fit: contain;
  width: auto;
}

.payment-brand-logo-wechat {
  height: 34px;
}

.payment-brand-logo-alipay {
  height: 34px;
}

.payment-document-footer {
  align-items: end;
  color: #64748b;
  display: grid;
  gap: 10px;
  margin-top: auto;
}

.payment-document-footer strong {
  color: #334155;
  margin-right: 8px;
}

.payment-footer-line {
  background: #dbe3ed;
  display: block;
  height: 1px;
  width: 100%;
}

.payment-stamp {
  display: none;
  opacity: 0.86;
  pointer-events: none;
  position: absolute;
  width: 132px;
  z-index: 3;
}

.payment-stamp.has-image {
  display: block;
}

.payment-stamp-top {
  right: 62px;
  top: 314px;
  transform: rotate(-8deg);
}

.payment-stamp-bottom {
  bottom: 88px;
  right: 84px;
  transform: rotate(8deg);
}

.payment-watermark-layer {
  display: grid;
  gap: 64px;
  grid-template-columns: repeat(3, 1fr);
  inset: -40px;
  opacity: 0.05;
  overflow: hidden;
  pointer-events: none;
  position: absolute;
  transform: rotate(-28deg);
  z-index: 1;
}

.payment-watermark-layer span {
  color: #0f172a;
  font-size: 34px;
  font-weight: 900;
  white-space: nowrap;
}

@media print {
  @page {
    margin: 0;
    size: A4 portrait;
  }

  html,
  body {
    background: #fff !important;
    height: auto;
    min-height: 0;
  }

  body * {
    visibility: hidden !important;
  }

  #paymentPrintArea,
  #paymentPrintArea * {
    visibility: visible !important;
  }

  #paymentPrintArea {
    border: 0 !important;
    box-shadow: none !important;
    left: 0;
    margin: 0 !important;
    min-height: 297mm;
    position: absolute;
    top: 0;
    width: 210mm;
  }

  #paymentPrintArea .payment-paper-content {
    min-height: 297mm;
  }
}

@media (max-width: 1420px) {
  .ledger-tools {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .ledger-status-text {
    grid-column: 1;
  }

  .ledger-action-tools {
    grid-column: 2;
    grid-row: 1;
    justify-self: end;
  }

  .ledger-filter,
  .ledger-date-filter,
  .ledger-inline-filters {
    grid-row: 2;
  }

  .ledger-filter {
    grid-column: 1;
    justify-self: start;
  }

  .ledger-date-filter {
    grid-column: 1 / 3;
    grid-row: 3;
    justify-self: start;
  }

  .ledger-inline-filters {
    grid-column: 2;
    justify-self: end;
  }
}

.ledger-col-store {
  width: 92px;
}

.ledger-col-car {
  width: 220px;
}

.ledger-col-plate {
  width: 130px;
}

.ledger-col-date {
  width: 128px;
}

.ledger-col-money {
  width: 126px;
}

.ledger-col-money-wide {
  width: 150px;
}

.ledger-col-source,
.ledger-col-person,
.ledger-col-customer {
  width: 120px;
}

.ledger-col-phone {
  width: 140px;
}

.ledger-col-status {
  width: 88px;
}

.ledger-col-action {
  width: 96px;
}

.compact-table {
  max-height: 420px;
}

.compact-table input,
.compact-table select {
  min-width: 140px;
  width: 100%;
}

.compact-table table {
  min-width: 900px;
}

.master-maintenance {
  display: grid;
  gap: 14px;
  width: 100%;
}

.master-category-tabs {
  align-items: center;
  background: #eef4f8;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 6px;
  width: fit-content;
}

.master-category-tabs button {
  background: transparent;
  border: 0;
  border-radius: 6px;
  color: var(--muted);
  cursor: pointer;
  font-weight: 800;
  min-height: 34px;
  padding: 0 14px;
}

.master-category-tabs button.active {
  background: #fff;
  box-shadow: var(--shadow-soft);
  color: var(--accent);
}

.master-list-panel {
  background: #fbfcfe;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 12px;
  padding: 14px;
  width: 100%;
}

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

.master-list-toolbar h3 {
  margin-bottom: 4px;
}

.master-list-toolbar p {
  color: var(--muted);
  margin-bottom: 0;
}

.master-list-actions {
  align-items: center;
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

.master-list-actions .master-filter {
  width: 260px;
}

.master-list-actions button {
  min-height: 38px;
  padding: 0 14px;
}

.master-list-actions #openMasterDialogButton {
  background: var(--accent);
  color: #fff;
}

.master-selection-hint {
  color: var(--muted);
  font-size: 13px;
  margin: -2px 0 0;
}

.master-list {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
}

.master-request-list {
  display: grid;
  gap: 10px;
}

.master-request-row {
  align-items: center;
  background: #fff;
  border: 1px solid var(--line-soft);
  display: flex;
  gap: 16px;
  justify-content: space-between;
  padding: 12px 14px;
}

.master-request-row small {
  color: var(--muted);
  display: block;
  margin-top: 4px;
}

.master-row {
  align-items: center;
  background: #fff;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  color: var(--ink);
  cursor: pointer;
  display: block;
  min-height: 42px;
  min-width: 0;
  padding: 0 16px;
  position: relative;
  text-align: left;
  width: 100%;
}

.master-row span {
  color: var(--ink);
  display: block;
  font-weight: 700;
  line-height: 40px;
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.master-row:hover {
  background: #f8fbfd;
  border-color: #cfe0ea;
}

.master-row.selected {
  background: var(--accent-soft);
  border-color: #9ccbd8;
  box-shadow: inset 3px 0 0 var(--accent);
}

.master-row.selected span {
  color: var(--accent-dark);
}

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

.settings-grid button {
  justify-self: start;
}

.inline-create {
  align-items: center;
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(3, minmax(0, 1fr)) auto;
  background: #f8fafc;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  margin-bottom: 14px;
  padding: 12px;
}

.account-create {
  grid-template-columns: repeat(5, minmax(0, 1fr)) auto;
}

.inline-create button,
.transfer-actions button {
  background: var(--accent);
  border: 0;
  border-radius: 8px;
  color: #fff;
  cursor: pointer;
  font-weight: 700;
  min-height: 40px;
  padding: 0 14px;
}

.inline-check {
  align-items: center;
  color: var(--muted);
  display: inline-flex;
  font-size: 13px;
  font-weight: 700;
  gap: 8px;
  min-height: 40px;
}

.inline-check input {
  min-height: auto;
  width: auto;
}

.transfer-actions {
  margin-top: 0;
}

.transfer-actions button {
  min-height: 32px;
  padding: 0 11px;
}

.transfer-workflow {
  background: #f7fafc;
  border-bottom: 1px solid var(--line-soft);
  border-top: 1px solid var(--line-soft);
  display: grid;
  gap: 1px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin: 0 -20px 18px;
}

.transfer-workflow span {
  color: var(--muted);
  font-size: 13px;
  padding: 10px 20px;
}

.transfer-workflow strong {
  color: var(--ink);
  display: block;
  font-size: 12px;
  margin-bottom: 2px;
}

.transfer-group + .transfer-group {
  border-top: 1px solid var(--line);
  margin-top: 18px;
  padding-top: 18px;
}

.transfer-group-heading,
.transfer-item {
  align-items: flex-start;
  display: flex;
  justify-content: space-between;
}

.transfer-group-heading {
  gap: 16px;
  margin-bottom: 10px;
}

.transfer-group-heading h3,
.transfer-group-heading p {
  margin: 0;
}

.transfer-group-heading h3 {
  font-size: 16px;
}

.transfer-group-heading p {
  color: var(--muted);
  font-size: 13px;
  margin-top: 3px;
}

.transfer-count {
  align-items: center;
  background: #edf2f7;
  border-radius: 999px;
  color: var(--ink);
  display: inline-flex;
  font-size: 12px;
  font-weight: 800;
  height: 24px;
  justify-content: center;
  min-width: 24px;
  padding: 0 7px;
}

.transfer-group-list {
  display: grid;
  gap: 8px;
}

.transfer-item {
  align-items: center;
  gap: 18px;
  padding: 8px 10px;
}

.transfer-item.needs-action {
  border-left: 3px solid var(--accent);
}

.transfer-item-main {
  align-items: center;
  display: grid;
  flex: 1 1 auto;
  gap: 6px 14px;
  grid-template-columns: minmax(150px, 1fr) minmax(220px, 1.25fr) minmax(170px, 0.9fr) minmax(180px, 1.1fr);
  min-width: 0;
}

.transfer-item-main strong,
.transfer-item-main span {
  display: block;
  margin: 0;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.transfer-item-side {
  align-items: center;
  display: flex;
  gap: 10px;
  flex: 0 0 auto;
  text-align: right;
}

.transfer-item-side .badge {
  white-space: nowrap;
}

.transfer-approval-status {
  color: var(--ink) !important;
  font-weight: 700;
}

@media (max-width: 1180px) and (min-width: 621px) {
  .transfer-item-main {
    grid-template-columns: minmax(180px, 1fr) minmax(240px, 1.35fr);
  }
}

.transfer-empty {
  color: var(--muted);
  font-size: 13px;
  margin: 0;
  padding: 10px 2px;
}

.login-shell {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at 20% 18%, rgba(15, 111, 140, 0.11), transparent 32%),
    linear-gradient(180deg, #f8fafc, #eef4f7);
}

.login-panel {
  display: grid;
  gap: 28px;
  max-width: 440px;
  padding: 32px;
  width: 100%;
}

.login-brand h1 {
  font-size: 24px;
  margin-bottom: 6px;
}

.login-brand p {
  color: var(--muted);
  margin-bottom: 0;
}

.login-form {
  display: grid;
  gap: 16px;
}

.login-form label {
  color: var(--muted);
  display: grid;
  gap: 8px;
  font-weight: 700;
}

.login-form input {
  width: 100%;
}

.password-field {
  display: block;
  position: relative;
}

.password-field input {
  padding-right: 46px;
}

.password-toggle {
  align-items: center;
  background: transparent !important;
  border: 0;
  border-radius: 8px;
  color: #667085;
  cursor: pointer;
  display: inline-flex;
  height: 34px;
  justify-content: center;
  min-height: 34px;
  padding: 0 !important;
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  width: 34px;
}

.password-toggle:hover {
  background: #eef4fb !important;
  color: var(--ink);
}

.password-toggle svg {
  fill: none;
  height: 20px;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
  width: 20px;
}

.password-toggle .eye-closed {
  display: none;
}

.password-toggle.is-visible .eye-open {
  display: none;
}

.password-toggle.is-visible .eye-closed {
  display: block;
}

.form-message {
  color: var(--accent-2);
  min-height: 20px;
  margin-bottom: 0;
}

.business-cycle-history {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
}

.cycle-history-row {
  align-items: center;
  background: var(--surface-muted);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--ink);
  cursor: pointer;
  display: flex;
  min-height: 40px;
  padding: 7px 10px;
  text-align: left;
  width: 100%;
}

.cycle-history-row.current,
.cycle-history-row.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px rgba(13, 116, 143, 0.12);
}

.cycle-history-row.active {
  background: #e6f4f8;
}

.cycle-history-main {
  align-items: center;
  display: flex;
  gap: 7px;
  width: 100%;
}

.cycle-history-row strong {
  color: var(--accent);
}

.cycle-history-main em {
  background: #e2e8f0;
  border-radius: 999px;
  color: #475569;
  font-size: 11px;
  font-style: normal;
  font-weight: 800;
  line-height: 1;
  margin-left: auto;
  padding: 4px 7px;
}

.cycle-history-row.current .cycle-history-main em {
  background: #d9f99d;
  color: #3f6212;
}

.cycle-history-meta {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.25;
  white-space: nowrap;
}

.empty-inline {
  color: var(--muted);
  font-size: 13px;
  padding: 6px 0;
}

@media (max-width: 1600px) and (max-height: 900px) and (min-width: 1400px) {
  .detail-dialog .dialog-form {
    gap: 4px;
    height: calc(100vh - 16px);
    max-height: calc(100vh - 16px);
    padding: 8px 12px;
  }

  .detail-dialog .dialog-header p {
    display: none;
  }

  .detail-dialog .dialog-header h2 {
    font-size: 18px;
    margin: 0;
  }

  .detail-dialog .dialog-header .icon-button {
    height: 32px;
    min-height: 32px;
    width: 32px;
  }

  .detail-scroll {
    overflow-x: hidden;
    overflow-y: hidden;
    padding-right: 0;
  }

  .detail-grid {
    gap: 5px;
    grid-template-rows: auto auto auto;
    height: auto;
    min-height: 100%;
  }

  .detail-section {
    gap: 4px;
    padding: 6px 9px;
  }

  .business-cycle-history {
    gap: 4px;
  }

  .cycle-history-row {
    min-height: 32px;
    padding: 4px 8px;
  }

  .business-summary-grid,
  .purchase-business-column,
  .sale-profit-stack {
    gap: 5px;
  }

  .detail-section .form-grid {
    gap: 3px 6px;
  }

  .detail-dialog .detail-scroll input,
  .detail-dialog .detail-scroll select {
    height: 30px;
    min-height: 30px;
  }

  .purchase-source-rate {
    gap: 6px;
  }

  .partner-editor {
    gap: 3px;
    padding-top: 3px;
  }

  .partner-editor .inline-header,
  .partner-editor .inline-header .secondary-button {
    min-height: 24px;
  }

  .partner-editor .inline-header .secondary-button {
    padding: 0 8px;
  }

  #partnerRows {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 4px 8px;
  }

  #partnerRows > .muted-line {
    grid-column: 1 / -1;
  }

  .partner-row {
    grid-template-columns: minmax(0, 1fr) 106px 44px;
    min-height: 27px;
  }

  .partner-row input,
  .partner-row button {
    height: 27px;
    min-height: 27px;
  }

  .partner-row button {
    padding: 0 5px;
  }

  .settlement-toggle {
    min-height: 40px;
    padding: 4px 8px;
  }

  .profit-box {
    gap: 3px;
  }

  .profit-box div {
    min-height: 42px;
    padding: 3px 6px;
  }

  .profit-partners {
    min-height: 30px !important;
  }

  .expense-section #expenseFields {
    gap: 2px;
  }

  .expense-group,
  .expense-group:first-child {
    gap: 3px;
    grid-template-columns: 62px minmax(0, 1fr);
    padding: 2px 4px;
  }

  .expense-group-grid,
  .expense-group-other .expense-group-grid {
    gap: 2px 5px;
    grid-template-columns: repeat(auto-fill, 106px);
  }

  .expense-field {
    font-size: 11px;
    gap: 1px;
    width: 106px;
  }

  .expense-field input {
    font-size: 13px;
    height: 22px !important;
    min-height: 22px !important;
    padding: 0 6px;
  }

  .expense-section .full-field input {
    height: 23px;
    min-height: 23px;
  }

  .dialog-actions {
    padding-top: 5px;
  }
}

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

  .sidebar {
    position: static;
    height: auto;
  }

  .side-nav {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .content-shell {
    padding: 18px;
  }

  body:has(.fixed-summary-bar:not([hidden])) .content-shell {
    padding-bottom: 128px;
  }

  .fixed-summary-bar {
    bottom: 8px;
    left: 12px;
    right: 12px;
  }

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

  .dashboard-shortcuts,
  .business-entry-grid {
    grid-template-columns: 1fr;
  }

  .page-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .toolbar {
    justify-content: flex-start;
    width: 100%;
  }

  .toolbar input {
    width: 100%;
  }

  .detail-grid,
  .business-summary-grid,
  .form-grid,
  .dense-grid,
  .profit-box,
  .car-filter-grid,
  .master-data-grid,
  .payment-workspace,
  .settings-grid {
    grid-template-columns: 1fr;
  }

  .payment-editor-panel {
    position: static;
  }

  .payment-paper {
    width: min(100%, 720px);
  }

  .report-panel .form-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .report-filter-section {
    grid-template-columns: 1fr;
    gap: 6px;
  }

  .report-filter-title {
    min-height: auto;
  }

  .report-filter-fields .report-field,
  .report-filter-fields .report-field-medium,
  .report-filter-fields .report-field-short,
  .report-filter-fields .report-field-narrow,
  .report-filter-fields .report-field-date-presets,
  .report-filter-fields .report-field-days {
    flex: 1 1 180px;
  }

  .report-panel .report-field-wide {
    grid-column: span 2;
  }

  .section-title-row {
    align-items: flex-start;
    flex-direction: column;
  }

  .master-row,
  .inline-create,
  .account-create,
  .cycle-history-row {
    grid-template-columns: 1fr;
    width: 100%;
  }

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

@media (max-width: 620px) {
  .employee-panel-header {
    align-items: stretch;
    flex-direction: column;
  }

  .employee-toolbar { grid-template-columns: 1fr; }
  .employee-search { grid-column: auto; }
  .employee-role-field { align-items: flex-start; flex-direction: column; gap: 9px; }

  .organization-store-table {
    border: 0;
    max-height: none;
    overflow: visible;
  }

  .organization-store-table table,
  .organization-store-table tbody,
  .organization-store-table tr {
    display: block;
    min-width: 0;
    width: 100%;
  }

  .organization-store-table thead { display: none; }
  .organization-store-table tbody { display: grid; gap: 10px; }
  .organization-store-table tr {
    border: 1px solid var(--line);
    border-radius: 8px;
    display: grid;
    gap: 10px;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    padding: 12px;
  }

  .organization-store-table td {
    border: 0;
    display: grid;
    gap: 4px;
    min-width: 0;
    padding: 0;
    white-space: normal;
  }

  .organization-store-table td::before {
    color: var(--muted);
    content: attr(data-label);
    font-size: 12px;
    font-weight: 800;
  }

  .organization-store-table td:last-child { grid-column: 1 / -1; }
  .organization-store-table input { min-width: 0; }
  .organization-store-table .row-actions > button { width: 100%; }

  .business-rules-grid {
    grid-template-columns: 1fr;
    width: 100%;
  }

  .business-rules-grid button {
    width: 100%;
  }

  .master-list-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .master-list-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 100%;
  }

  .master-list-actions .master-filter {
    grid-column: 1 / -1;
    width: 100%;
  }

  .master-list-actions button {
    padding-left: 8px;
    padding-right: 8px;
    width: 100%;
  }

  .master-list-actions #openMasterDialogButton {
    grid-column: 1 / -1;
  }

  .transfer-workflow {
    grid-template-columns: 1fr;
    margin-left: -18px;
    margin-right: -18px;
  }

  .transfer-workflow span {
    border-bottom: 1px solid var(--line-soft);
    padding: 8px 18px;
  }

  .transfer-item {
    display: grid;
    gap: 10px;
  }

  .transfer-item-main {
    grid-template-columns: 1fr;
  }

  .transfer-item-main strong,
  .transfer-item-main span {
    white-space: normal;
  }

  .transfer-item-side {
    align-items: center;
    display: flex;
    justify-content: space-between;
    text-align: left;
  }

  .transfer-actions {
    margin-top: 0;
  }

  .detail-dialog .dialog-form {
    padding-left: 10px;
    padding-right: 10px;
  }

  .purchase-heading {
    align-items: stretch;
    flex-direction: column;
  }

  .purchase-mode-toggle {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    width: 100%;
  }

  .purchase-mode-toggle label {
    justify-content: center;
    min-width: 0;
    padding-left: 4px;
    padding-right: 4px;
  }

  .purchase-business-column,
  .sale-profit-stack,
  .detail-section,
  .purchase-mode-summary {
    max-width: 100%;
    min-width: 0;
    width: 100%;
  }

  .purchase-mode-summary {
    overflow-wrap: anywhere;
  }

  .business-cycle-history {
    grid-template-columns: minmax(0, 1fr);
  }

  .expense-config-grid,
  .expense-item-form-grid {
    grid-template-columns: 1fr;
  }

  .quick-entry-dialog {
    border-radius: 0;
    height: 100vh;
    inset: 0;
    max-width: none;
  }

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

  .report-filter-fields .report-field,
  .report-filter-fields .report-field-medium,
  .report-filter-fields .report-field-short,
  .report-filter-fields .report-field-narrow,
  .report-filter-fields .report-field-date-presets,
  .report-filter-fields .report-field-days {
    flex-basis: 100%;
  }

  .report-panel .report-field-wide {
    grid-column: auto;
  }

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

  .payment-account-fields,
  .payment-qr-grid {
    grid-template-columns: 1fr;
  }

  .payment-paper-content {
    gap: 22px;
    padding: 34px 24px 28px;
  }

  .payment-document-header h2 {
    font-size: 20px;
  }

  .payment-document-header h3 {
    font-size: 23px;
  }
}
