:root {
  --bg-a: #f2f7ff;
  --bg-b: #e9f8ef;
  --card-bg: rgba(255, 255, 255, 0.95);
  --text: #1f2a37;
  --muted: #6b7280;
  --primary: #0f766e;
  --danger: #b91c1c;
  --border: #d9e3ee;
  --shadow: 0 12px 30px rgba(15, 118, 110, 0.15);
  --side-bg: linear-gradient(180deg, #1e293b 0%, #172033 52%, #111827 100%);
  --side-txt: #e2e8f0;
  --side-active: rgba(51, 65, 85, 0.72);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  color: var(--text);
  background: radial-gradient(circle at 10% 0%, var(--bg-b), var(--bg-a) 45%, #ffffff 100%);
  min-height: 100vh;
}

.door-overlay {
  position: fixed;
  inset: 0;
  z-index: 1200;
  display: flex;
  overflow: hidden;
  pointer-events: auto;
  transform-origin: center center;
  transform: scale(1);
  transition: transform 120ms ease-out;
}
.door-overlay.pre-open { transform: scale(1.015); }
.door-overlay[hidden] {
  display: none !important;
}
.door-half {
  width: 50%;
  height: 100%;
  background-color: #111827;
  background-image: var(--door-desktop-bg, url("/static/img/gaoqing.png"));
  background-repeat: no-repeat;
  background-size: 200% 100%;
  transition: transform 1200ms cubic-bezier(0.22, 0.8, 0.22, 1);
  will-change: transform;
}
.door-left {
  background-position: left center;
  transform: translateX(0);
}
.door-right {
  background-position: right center;
  transform: translateX(0);
}
.door-overlay.opened .door-left {
  transform: translateX(-100%);
}
.door-overlay.opened .door-right {
  transform: translateX(100%);
}
@media (max-width: 900px) {
  .door-overlay {
    flex-direction: column;
  }
  .door-half {
    width: 100%;
    height: 50%;
    background-image: var(--door-phone-bg, url("/static/img/phonegaoqing.png"));
    background-size: 100% 200%;
  }
  .door-left {
    background-position: center top;
    transform: translateY(0);
  }
  .door-right {
    background-position: center bottom;
    transform: translateY(0);
  }
  .door-overlay.opened .door-left {
    transform: translateY(-100%);
  }
  .door-overlay.opened .door-right {
    transform: translateY(100%);
  }
}

.console-layout {
  display: grid;
  grid-template-columns: 174px 1fr;
  min-height: 100vh;
}
.console-layout.collapsed { grid-template-columns: 66px 1fr; }

.console-sidebar {
  background: var(--side-bg);
  color: var(--side-txt);
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.console-sidebar .secondary {
  background: rgba(51, 65, 85, 0.86);
  color: #f8fafc;
}
.console-sidebar .secondary:hover {
  background: rgba(71, 85, 105, 0.92);
}
.console-brand { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.console-brand-main { display: flex; align-items: center; gap: 8px; min-width: 0; }
.console-logo { width: 30px; height: 30px; border-radius: 6px; flex: 0 0 auto; object-fit: cover; background: #fff; }
.console-brand-title { font-weight: 700; white-space: nowrap; }
.console-user { font-size: 12px; color: #cbd5e1; }
.console-menu { display: flex; flex-direction: column; gap: 6px; }
.console-menu .menu-link {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 6px;
  width: 100%;
  text-align: left;
  border: 0;
  background: transparent;
  color: var(--side-txt);
  text-decoration: none;
  border-radius: 8px;
  padding: 9px 10px 9px 0;
  font-size: 14px;
  cursor: pointer;
}
.console-menu .menu-link .menu-text {
  min-width: 0;
}
.console-menu .menu-link .menu-icon {
  width: 14px;
  height: 14px;
  color: #f8fafc;
  opacity: 0.95;
  flex: 0 0 auto;
}
.console-menu .menu-link .menu-icon svg {
  width: 14px;
  height: 14px;
  display: block;
}
.console-menu .menu-link:hover { background: var(--side-active); }
.console-menu .menu-link.active { background: var(--side-active); }
.console-side-actions { margin-top: auto; }

.console-layout.collapsed .console-brand-title,
.console-layout.collapsed .console-user,
.console-layout.collapsed .console-menu,
.console-layout.collapsed .console-side-actions { display: none; }

.console-main { padding: 12px 12px 0 12px; display: flex; flex-direction: column; gap: 10px; min-height: 100vh; }
.tabbar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  border: 1px solid var(--border);
  padding: 8px;
  border-radius: 10px;
  background: #fff;
}
.tabbar-logout {
  margin-left: auto;
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid #cbd5e1;
  background: #f8fafc;
  color: #475569;
  font-size: 12px;
  line-height: 1.1;
}
.tabbar-logout:hover {
  background: #f1f5f9;
  color: #334155;
}
.tab-btn {
  border: 1px solid var(--border);
  background: #f8fafc;
  color: var(--text);
  padding: 6px 8px;
  border-radius: 8px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.tab-btn.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}
.tab-close { font-size: 12px; opacity: 0.8; }

.workspace {
  position: relative;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fff;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}
.workspace-empty {
  padding: 18px;
  color: var(--muted);
}
.tab-frame {
  width: 100%;
  height: 100%;
  border: 0;
}

.company-status-toggle {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 36px;
  padding: 6px 12px;
  border: 1px solid rgba(15, 118, 110, 0.18);
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(240, 253, 250, 0.96));
  color: #475569;
  cursor: pointer;
  user-select: none;
  transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease, color 160ms ease;
}
.company-status-toggle:hover {
  border-color: rgba(15, 118, 110, 0.35);
  box-shadow: 0 8px 18px rgba(15, 118, 110, 0.08);
}
.company-status-toggle input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.company-status-toggle-track {
  position: relative;
  width: 38px;
  height: 22px;
  border-radius: 999px;
  background: #cbd5e1;
  box-shadow: inset 0 1px 3px rgba(15, 23, 42, 0.18);
  transition: background 160ms ease;
}
.company-status-toggle-track::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 6px rgba(15, 23, 42, 0.2);
  transition: transform 160ms ease;
}
.company-status-toggle-text {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.02em;
}
.company-status-toggle input:checked + .company-status-toggle-track {
  background: linear-gradient(135deg, #0f766e, #14b8a6);
}
.company-status-toggle input:checked + .company-status-toggle-track::after {
  transform: translateX(16px);
}
.company-status-toggle input:checked ~ .company-status-toggle-text {
  color: #0f766e;
}
.company-status-toggle:has(input:checked) {
  border-color: rgba(15, 118, 110, 0.42);
  background: linear-gradient(180deg, rgba(240, 253, 250, 0.98), rgba(204, 251, 241, 0.96));
}
.company-status-toggle input:focus-visible + .company-status-toggle-track {
  outline: 2px solid rgba(20, 184, 166, 0.35);
  outline-offset: 2px;
}

.page {
  max-width: 1120px;
  margin: 24px auto;
  padding: 16px;
}
.module-page { padding: 12px; }
.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 20px;
}
.auth-logo-wrap {
  display: flex;
  justify-content: center;
  margin-bottom: 12px;
}
.auth-logo {
  width: 64px;
  height: 64px;
  border-radius: 12px;
  object-fit: cover;
  background: #fff;
  border: 1px solid var(--border);
}
.auth-mark {
  text-align: center;
  font-size: 30px;
  font-weight: 800;
  letter-spacing: 4px;
  color: #0f172a;
  margin-bottom: 8px;
}

h1 { margin: 0 0 8px; font-size: 28px; }
h2 { margin: 0 0 12px; font-size: 20px; }
.subtitle { color: var(--muted); margin-bottom: 20px; }

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

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

label { display: block; font-size: 13px; margin-bottom: 6px; color: var(--muted); }
input, select, textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
}


.actions { display: flex; gap: 10px; margin-top: 16px; flex-wrap: wrap; }
.actions .modal-delete { margin-left: auto; }
.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 16px;
  flex-wrap: wrap;
}
button {
  border: 0;
  border-radius: 10px;
  padding: 10px 14px;
  cursor: pointer;
  background: var(--primary);
  color: #fff;
}
button.secondary { background: #2563eb; color: #fff; }
button.secondary:hover { background: #1d4ed8; }
button.secondary:focus-visible {
  outline: 2px solid rgba(37, 99, 235, 0.35);
  outline-offset: 2px;
}
button.warn { background: var(--danger); }
button:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-spinner {
  width: 14px;
  height: 14px;
  margin-left: 8px;
  border: 2px solid rgba(255, 255, 255, 0.45);
  border-top-color: #ffffff;
  border-radius: 50%;
  display: inline-block;
  vertical-align: middle;
  animation: spin 0.8s linear infinite;
}
.btn-spinner[hidden] {
  display: none !important;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}
.btn-xs {
  padding: 6px 10px;
  border-radius: 8px;
  font-size: 12px;
  line-height: 1.1;
}
.btn-row-remove,
.btn-po-remove {
  width: auto;
  min-width: auto;
  padding: 3px 6px;
  font-size: 10px;
  border-radius: 7px;
  line-height: 1;
  white-space: nowrap;
}
.icon-circle-btn {
  width: 20px;
  height: 20px;
  min-width: 20px;
  border-radius: 50%;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.92);
  border: 1.5px solid currentColor;
  color: #2563eb;
}
.icon-circle-btn.add {
  color: #2563eb;
}
.icon-circle-btn.remove {
  color: #dc2626;
}
.icon-circle-btn svg {
  width: 11px;
  height: 11px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.btn-po-toggle {
  width: 20px;
  height: 20px;
  min-width: 20px;
  padding: 0;
  border-radius: 50%;
  line-height: 20px;
  border: 1.5px solid #94a3b8;
  background: rgba(255, 255, 255, 0.92);
  color: #64748b;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.btn-po-toggle svg {
  width: 11px;
  height: 11px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.note { color: var(--muted); font-size: 13px; margin-top: 10px; }
.error { color: var(--danger); font-size: 13px; margin-top: 10px; min-height: 20px; }
.success { color: #0f766e; font-size: 13px; margin-top: 10px; min-height: 20px; }

.toolbar { display: flex; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.table-wrap { overflow: auto; }
table { width: 100%; border-collapse: collapse; min-width: 860px; }
th, td { border-bottom: 1px solid var(--border); padding: 7px 8px; text-align: left; font-size: 12px; }
.module-page .card > .table-wrap > table > thead > tr > th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: #f8fafc;
  box-shadow: inset 0 1px 0 rgba(0, 0, 0, 0.14), inset 0 -1px 0 rgba(0, 0, 0, 0.18);
}
.management-page .card {
  font-size: 14px;
}
.management-page .panel-header h2,
.management-page h3 {
  font-size: 18px;
}
.management-page label,
.management-page .note,
.management-page .pagination,
.management-page .toolbar,
.management-page .actions {
  font-size: 14px;
}
.management-page th,
.management-page td {
  font-size: 13px;
}
.management-page input,
.management-page select,
.management-page textarea,
.management-page button {
  font-size: 14px;
}
.role-manage-table {
  min-width: 620px;
  table-layout: fixed;
}
.role-manage-table th:first-child,
.role-manage-table td:first-child {
  width: auto;
}
.role-manage-table th:nth-child(2),
.role-manage-table th:nth-child(3),
.role-manage-table td:nth-child(2),
.role-manage-table td:nth-child(3) {
  width: 120px;
  text-align: center;
}
.role-manage-table td:nth-child(2),
.role-manage-table td:nth-child(3) {
  vertical-align: middle;
}
.role-manage-table input[type="checkbox"] {
  display: inline-block;
  margin: 0;
  vertical-align: middle;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.service-income-compact {
  padding: 4px;
}
.service-income-card {
  padding: 10px;
  height: calc(100vh - 10px);
  display: flex;
  flex-direction: column;
}
.service-income-compact h2 {
  margin: 0;
  font-size: 16px;
}
.service-income-compact .toolbar {
  margin-bottom: 8px;
  gap: 8px;
}
.service-income-compact .toolbar label {
  margin-bottom: 4px;
  font-size: 11px;
}
.service-income-compact .toolbar input,
.service-income-compact .toolbar select {
  padding: 6px 8px;
  font-size: 11px;
  border-radius: 8px;
}
.service-income-search-actions {
  align-items: flex-end;
  margin-top: 0;
}
.sales-action-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0 0 8px 0;
}
.sales-action-row .btn-xs {
  padding: 5px 8px;
}
.service-income-compact .sales-primary-action {
  background: #2563eb;
  color: #fff;
  box-shadow: 0 6px 14px rgba(37, 99, 235, 0.18);
}
.service-income-compact .sales-primary-action:hover {
  background: #1d4ed8;
}
.service-income-compact .sales-primary-action:focus-visible {
  outline: 2px solid rgba(37, 99, 235, 0.35);
  outline-offset: 2px;
}
.list-loading-wrap {
  position: relative;
}
.list-loading {
  position: absolute;
  inset: 38px 0 0;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 120px;
  pointer-events: none;
  z-index: 2;
}
.list-loading-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 58px;
  height: 58px;
  padding: 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.52);
  border: 1px solid rgba(148, 163, 184, 0.2);
  box-shadow: 0 12px 32px rgba(15, 23, 42, 0.1);
  backdrop-filter: blur(10px);
  animation: list-logo-breathe 1.6s ease-in-out infinite;
}
.list-loading-logo {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 999px;
  opacity: 0.72;
  filter: saturate(1.03);
  animation: spin 2.3s linear infinite;
}
.list-loading[hidden] {
  display: none !important;
}
@keyframes list-logo-breathe {
  from {
    transform: scale(0.94);
    opacity: 0.82;
  }
  to {
    transform: scale(1.03);
    opacity: 1;
  }
}
.service-income-compact .table-wrap {
  flex: 1;
  min-height: 0;
}
.finance-transfer-fee-row {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}
.finance-transfer-fee-row[hidden] {
  display: none !important;
}
.service-income-compact table {
  min-width: 760px;
}
.service-income-compact .sales-list-table {
  min-width: 4240px;
  border-collapse: collapse;
}
.service-income-compact .sales-list-table th,
.service-income-compact .sales-list-table td {
  border: 1px solid rgba(0, 0, 0, 0.4);
  padding-left: 2px;
  padding-right: 2px;
  vertical-align: middle;
  text-align: center;
  white-space: nowrap;
}
.service-income-compact .sales-list-table thead th {
  position: sticky;
  top: 0;
  z-index: 3;
  background: #f8fafc;
  box-shadow: inset 0 1px 0 rgba(0, 0, 0, 0.28), inset 0 -1px 0 rgba(0, 0, 0, 0.28);
}
.service-income-compact .sales-list-table th.sales-select-cell,
.service-income-compact .sales-list-table td.sales-select-cell {
  width: 28px;
  min-width: 28px;
  padding: 0;
}
.sales-select-checkbox {
  width: 14px;
  height: 14px;
  margin: 0;
  cursor: pointer;
  accent-color: #0f766e;
}
.service-income-compact .sales-list-table td[rowspan] {
  vertical-align: middle;
}
.service-income-compact .sales-list-table td.sales-multiline {
  white-space: pre-line;
  line-height: 1.25;
  text-align: center;
}
.service-income-compact .sales-list-table td.sales-dynamic-cell {
  vertical-align: middle;
  text-align: center;
}
.service-income-compact .sales-list-table th.sales-orderno-cell,
.service-income-compact .sales-list-table td.sales-orderno-cell {
  width: 1%;
  min-width: 1%;
  padding-left: 5px !important;
  padding-right: 5px !important;
  white-space: nowrap;
}
.service-income-compact .sales-list-table td.sales-remark-cell {
  max-width: 20ch;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.service-income-compact .sales-list-table tr.sales-order-row-start > th,
.service-income-compact .sales-list-table tr.sales-order-row-start > td {
  border-top: 1px solid rgba(0, 0, 0, 0.4);
}
.service-income-compact .sales-list-table tr.sales-order-row-end > th,
.service-income-compact .sales-list-table tr.sales-order-row-end > td {
  border-bottom: 1px solid #000;
}
.service-income-compact .sales-list-table td.sales-rowspan {
  border-bottom: 1px solid #000;
}
.service-income-compact .sales-list-table tr.sales-order-selected.sales-order-row-start > th,
.service-income-compact .sales-list-table tr.sales-order-selected.sales-order-row-start > td {
  border-top: 2px solid #16a34a;
}
.service-income-compact .sales-list-table tr.sales-order-selected.sales-order-row-end > th,
.service-income-compact .sales-list-table tr.sales-order-selected.sales-order-row-end > td,
.service-income-compact .sales-list-table tr.sales-order-selected.sales-order-row-start > td.sales-rowspan,
.service-income-compact .sales-list-table tr.sales-order-selected.sales-order-row-start > td[rowspan] {
  border-bottom: 2px solid #16a34a;
}
.sales-section-header {
  justify-content: flex-start;
  gap: 8px;
}
.sales-section-header h3 {
  margin: 0;
}
.sales-due-warning-box {
  margin-left: 12px;
  display: inline-flex;
  flex-direction: column;
  gap: 2px;
}
.sales-due-warning-line {
  font-size: 12px;
  color: #dc2626;
  line-height: 1.2;
  cursor: pointer;
}
.sales-due-warning-count {
  border: 0;
  background: transparent;
  color: #dc2626;
  cursor: pointer;
  padding: 0;
  margin: 0 1px 0 0;
  font-size: 12px;
  line-height: 1.2;
  text-decoration: underline;
}
.sales-due-warning-count:hover {
  color: #b91c1c;
}
.company-opening-total {
  margin-left: 8px;
  color: #64748b;
  font-size: 12px;
  font-weight: 500;
}
.dashboard-card .panel-header {
  align-items: flex-start;
}
.dashboard-overview {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 10px;
}
.dashboard-kpi {
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  background: #f8fafc;
  padding: 8px 10px;
}
.dashboard-kpi-label {
  font-size: 12px;
  color: #64748b;
  margin-bottom: 4px;
}
.dashboard-kpi-value {
  font-size: 22px;
  line-height: 1.2;
  font-weight: 700;
  color: #0f172a;
}
.dashboard-kpi-value--blue {
  color: #2563eb;
}
.dashboard-kpi-value--red {
  color: #dc2626;
}
.dashboard-kpi-value--green {
  color: #16a34a;
}
.dashboard-card table thead th {
  font-size: 16px;
}
.dashboard-card table tbody td {
  font-size: 15px;
}
.dashboard-charts-grid {
  margin-top: 12px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.dashboard-chart-card {
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  background: #fff;
  padding: 10px;
  min-height: 280px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.dashboard-chart-title {
  margin: 0;
  font-size: 14px;
  color: #334155;
}
.dashboard-chart-svg-wrap {
  position: relative;
  width: 100%;
  min-height: 220px;
}
.dashboard-pie-slice {
  cursor: pointer;
  transition: transform 160ms ease, filter 160ms ease;
  transform-origin: center;
}
.dashboard-pie-slice:hover {
  filter: brightness(1.03);
}
.dashboard-pie-tooltip {
  position: absolute;
  z-index: 6;
  min-width: 130px;
  max-width: 220px;
  background: rgba(15, 23, 42, 0.96);
  color: #f8fafc;
  border-radius: 8px;
  padding: 7px 8px;
  font-size: 12px;
  line-height: 1.35;
  box-shadow: 0 8px 20px rgba(2, 6, 23, 0.28);
  pointer-events: none;
}
.dashboard-pie-tooltip-name {
  font-weight: 700;
  margin-bottom: 4px;
  color: #e2e8f0;
}
.dashboard-chart-empty {
  min-height: 220px;
  display: grid;
  place-items: center;
  color: #64748b;
  font-size: 13px;
}
.dashboard-pie-legend {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px 10px;
}
.dashboard-pie-legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  font-size: 12px;
  color: #334155;
}
.dashboard-pie-legend-item .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  flex: 0 0 auto;
}
.dashboard-pie-legend-item .name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.dashboard-pie-legend-item .val {
  margin-left: auto;
  color: #0f172a;
  font-weight: 600;
  white-space: nowrap;
}
.dashboard-line-legend {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  font-size: 12px;
  color: #475569;
}
.dashboard-line-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.dashboard-line-legend .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}
.dashboard-line-legend .dot-blue { background: #2563eb; }
.dashboard-line-legend .dot-red { background: #dc2626; }
.dashboard-line-legend .dot-green { background: #16a34a; }
.dashboard-line-point-hit {
  cursor: pointer;
}
.dashboard-line-tooltip {
  position: absolute;
  z-index: 6;
  min-width: 130px;
  max-width: 220px;
  background: rgba(15, 23, 42, 0.96);
  color: #f8fafc;
  border-radius: 8px;
  padding: 7px 8px;
  font-size: 12px;
  line-height: 1.35;
  box-shadow: 0 8px 20px rgba(2, 6, 23, 0.28);
  pointer-events: none;
}
.dashboard-line-tooltip-name {
  font-weight: 700;
  margin-bottom: 4px;
  color: #e2e8f0;
}
.dashboard-amount--blue {
  color: #2563eb;
  font-weight: 600;
}
.dashboard-amount--red {
  color: #dc2626;
  font-weight: 600;
}
.dashboard-amount--green {
  color: #16a34a;
  font-weight: 600;
}
.sales-status-warning {
  position: relative;
  color: #dc2626;
  font-weight: 600;
  cursor: default;
}
.sales-status-with-tip {
  position: relative;
  cursor: default;
}
.sales-status-tip {
  position: absolute;
  left: 50%;
  top: calc(100% + 6px);
  transform: translateX(-50%);
  min-width: 148px;
  max-width: 240px;
  background: rgba(15, 23, 42, 0.96);
  color: #f8fafc;
  border-radius: 8px;
  padding: 6px 8px;
  font-size: 12px;
  line-height: 1.3;
  text-align: left;
  white-space: pre-wrap;
  box-shadow: 0 8px 20px rgba(2, 6, 23, 0.28);
  z-index: 5;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}
.sales-status-warning:hover .sales-status-tip {
  opacity: 1;
  visibility: visible;
}
.sales-status-with-tip:hover .sales-status-tip {
  opacity: 1;
  visibility: visible;
}
.sales-readonly-summary {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 4px 10px;
  margin: 0 0 8px 0;
  padding: 8px 10px;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  background: #f8fafc;
}
.sales-readonly-item {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  line-height: 1.25;
}
.sales-readonly-item.wide {
  grid-column: 1 / -1;
}
.sales-readonly-item .k {
  color: var(--muted);
  white-space: nowrap;
}
.sales-readonly-item .k::after {
  content: ":";
}
.sales-readonly-item .v {
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sales-base-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px 10px;
}
.sales-base-remark {
  grid-column: span 1;
}
.sales-base-contract {
  grid-column: span 1;
  display: flex;
  flex-direction: column;
}
.sales-base-contract-label {
  visibility: hidden;
  flex: 0 0 auto;
}
.sales-due-input-group {
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
}
.sales-due-input-label {
  flex: 0 0 auto;
  white-space: nowrap;
  color: var(--muted);
  font-size: 12px;
}
.sales-due-input-group > input[type="date"] {
  flex: 2.4 1 0;
}
.sales-base-contract .invoice-upload-wrap {
  flex: 1 1 auto;
  display: inline-flex;
  align-items: center;
}
.sales-due-input-group > input {
  flex: 1 1 0;
  min-width: 0;
}
.sales-due-days-input {
  text-align: left;
  max-width: 106px;
  min-width: 138px;
  font-size: 13px;
}
.sales-due-days-input::placeholder {
  font-size: 11px;
}
.modal-card.sales-full-edit-mode #salesReadonlySummary {
  display: none !important;
}
.modal-card.sales-sub-edit-mode #salesBaseForm {
  display: none !important;
}
.sales-po-top-row {
  display: grid;
  grid-template-columns: 14px minmax(180px, 1.35fr) minmax(96px, 0.64fr) minmax(300px, 1.55fr) minmax(120px, 0.9fr) minmax(180px, 1fr) auto auto;
  gap: 4px;
  margin-bottom: 8px;
  align-items: center;
}
.sales-unit-amount-input,
.purchase-unit-amount-input {
  max-width: 90px;
  width: 100%;
  justify-self: center;
}
.po-purchase-amount.purchase-unit-amount-input {
  margin-right: 2px;
}
.sales-po-top-row input[type="number"],
.sales-row input[type="number"],
.sales-base-grid input[type="number"] {
  -moz-appearance: textfield;
}
.sales-po-top-row input[type="number"]::-webkit-outer-spin-button,
.sales-po-top-row input[type="number"]::-webkit-inner-spin-button,
.sales-row input[type="number"]::-webkit-outer-spin-button,
.sales-row input[type="number"]::-webkit-inner-spin-button,
.sales-base-grid input[type="number"]::-webkit-outer-spin-button,
.sales-base-grid input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.sales-section-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.sales-cell-stack {
  display: flex;
  flex-direction: column;
  min-height: 100%;
  margin: -7px -8px;
}
.sales-cell-segment {
  flex: 1 1 0;
  display: flex;
  align-items: center;
  padding: 6px 8px;
  border-top: 1px solid var(--border);
  box-sizing: border-box;
}
.sales-cell-segment:first-child {
  border-top: 0;
}
.sales-cell-segment .sales-multiline {
  width: 100%;
}
.po-remark,
.po-contract-upload {
  min-width: 0;
}
.po-contract-upload .invoice-upload-wrap {
  width: 100%;
}
.po-required-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #dc2626;
  display: inline-block;
  margin-top: -14px;
}
.sales-row .btn-row-remove {
  justify-self: end;
  align-self: center;
  border-radius: 50%;
  width: 20px;
  height: 20px;
  min-width: 20px;
  padding: 0;
  line-height: 20px;
}
.sales-item-row .item-row-index {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  color: #64748b;
  user-select: none;
}
.sales-dialog-section {
  margin-left: -18px;
  margin-right: -18px;
  padding-left: 18px;
  padding-right: 18px;
}
.sales-dialog-section + .sales-dialog-section {
  border-top: 1px dashed #cbd5e1;
  margin-top: 10px;
  padding-top: 8px;
}
.po-items-summary {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 2px 0 8px 0;
  color: var(--muted);
  font-size: 12px;
}
.po-items-total-price {
  color: var(--text);
  font-weight: 600;
}
.link-like-btn {
  background: transparent;
  color: #2563eb;
  border: 0;
  padding: 0;
  font-size: 12px;
  line-height: 1.2;
  text-decoration: underline;
}
.link-like-btn:hover {
  color: #1d4ed8;
}
.sales-po-link {
  font-size: inherit;
  line-height: 1.2;
  text-decoration: none;
  color: #2563eb;
  cursor: pointer;
}
.sales-po-link:hover {
  color: #1d4ed8;
  text-decoration: underline;
}
.sales-items-preview-card {
  width: min(1380px, 99vw);
  position: relative;
  padding: 10px 8px 8px;
}
.sales-items-preview-header {
  padding-right: 34px;
  margin-bottom: 8px;
}
.sales-items-preview-line {
  display: flex;
  align-items: center;
  flex-wrap: nowrap;
  gap: 12px;
  min-width: 0;
  max-width: 100%;
  padding-right: 6px;
  overflow: hidden;
}
.sales-items-preview-order-no {
  font-size: 18px;
  font-weight: 700;
  line-height: 1.2;
  white-space: nowrap;
  flex: 0 0 auto;
  color: #0f172a;
}
.sales-items-preview-meta {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  font-size: 13px;
  color: #334155;
}
#poItemsPreviewSupplier {
  flex: 0 1 auto;
  min-width: 24px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sales-items-preview-price {
  flex: 0 0 auto;
}
.sales-items-preview-price strong {
  font-size: 14px;
  color: #0f172a;
}
.preview-close-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 22px;
  height: 22px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: #64748b;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  line-height: 1;
  cursor: pointer;
}
.preview-close-btn svg {
  width: 12px;
  height: 12px;
  display: block;
}
.preview-close-btn svg path {
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  fill: none;
}
.preview-close-btn:hover {
  background: #f1f5f9;
  color: #334155;
}
.sales-items-preview-table {
  width: auto;
  min-width: 820px;
  border-collapse: collapse;
  table-layout: fixed;
  margin: 0 auto;
}
.sales-items-preview-table th,
.sales-items-preview-table td {
  border: 1px solid rgba(0, 0, 0, 0.65);
  padding: 3px 4px;
  text-align: center;
  vertical-align: middle;
  font-size: 13px;
  line-height: 1.25;
}
.sales-items-preview-table th:nth-child(1),
.sales-items-preview-table td:nth-child(1) {
  width: 44px;
}
.sales-items-preview-table th:nth-child(2),
.sales-items-preview-table td:nth-child(2) {
  width: 170px;
}
.sales-items-preview-table th:nth-child(3),
.sales-items-preview-table td:nth-child(3) {
  width: 150px;
}
.sales-items-preview-table th:nth-child(4),
.sales-items-preview-table td:nth-child(4) {
  width: 80px;
}
.sales-items-preview-table th:nth-child(5),
.sales-items-preview-table td:nth-child(5),
.sales-items-preview-table th:nth-child(6),
.sales-items-preview-table td:nth-child(6) {
  width: 96px;
}
.sales-items-preview-table th:nth-child(7),
.sales-items-preview-table td:nth-child(7) {
  width: 220px;
}
.sales-items-preview-table td.sales-multiline {
  white-space: pre-wrap;
  word-break: break-word;
}
.invoice-status-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
}
.invoice-status-wrap .invoice-status-label {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
}
.invoice-status-wrap select {
  min-width: 72px;
  max-width: 96px;
}
.invoice-upload-label {
  display: inline-flex;
  align-items: center;
  gap: 0;
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  cursor: pointer;
}
.invoice-upload-wrap {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
  height: 100%;
}
.invoice-upload-label input[type="file"] {
  width: 0.1px;
  height: 0.1px;
  opacity: 0;
  position: absolute;
  pointer-events: none;
}
.invoice-upload-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 30px;
  padding: 0 10px;
  border: 1px solid #93c5fd;
  border-radius: 999px;
  background: #eff6ff;
  color: #1d4ed8;
  font-size: 12px;
  line-height: 30px;
  transition: all 0.15s ease;
  white-space: nowrap;
}
.invoice-upload-label:hover .invoice-upload-btn {
  background: #dbeafe;
  border-color: #60a5fa;
  color: #1e40af;
}
.invoice-upload-label:active .invoice-upload-btn {
  transform: translateY(0.5px);
}
.invoice-upload-label:focus-within .invoice-upload-btn {
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.25);
}
.invoice-upload-label .invoice-upload-btn {
  position: relative;
  white-space: nowrap;
}
.invoice-file-link {
  display: inline-flex;
  align-items: center;
  height: 30px;
  line-height: 30px;
  font-size: 12px;
  color: #2563eb;
  text-decoration: underline;
  white-space: nowrap;
}
.invoice-file-link[hidden] {
  display: none !important;
}
.sales-pinv-row,
.sales-sinv-row,
.sales-billing-row {
  align-items: center;
}
.sales-billing-row {
  box-sizing: border-box;
  padding: 10px 12px;
  border: 1px solid rgba(15, 23, 42, 0.28);
  border-radius: 8px;
  background: rgba(15, 23, 42, 0.02);
}
.sales-billing-row .sb-payment-date {
  background: #f8fafc;
  color: #475569;
}
.sales-billing-field {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 4px;
}
.sales-billing-field > span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.2;
  white-space: nowrap;
}
.sales-billing-date-field > span {
  color: #dc2626;
}
.sales-billing-compact-field {
  grid-column: span 2;
}
.sales-billing-money-field {
  grid-column: span 1;
}
.sales-billing-days-field {
  grid-column: span 1;
}
.sales-billing-delivery-no-field {
  grid-column: span 2;
}
.sales-billing-field-wide {
  grid-column: span 4;
}
.sales-billing-field input {
  width: 100%;
}
.sales-billing-row .invoice-upload-wrap {
  min-width: 0;
  height: auto;
}
.sales-billing-upload-field {
  grid-column: span 2;
  justify-content: flex-end;
}
.service-income-compact th,
.service-income-compact td {
  padding: 5px 7px;
  font-size: 14px;
  line-height: 1.1;
}
.service-income-compact td.finance-desc-cell {
  max-width: 40ch;
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
  line-height: 1.3;
}
.service-income-compact td.debt-remark-cell {
  max-width: 40ch;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
  line-height: 1.3;
}
.service-income-compact td.sales-multiline {
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.3;
}
.service-income-transfer-block {
  margin-top: 8px;
}
.service-income-transfer-row .btn-row-remove {
  justify-self: end;
  align-self: center;
  border-radius: 50%;
  width: 20px;
  height: 20px;
  min-width: 20px;
  padding: 0;
  line-height: 20px;
}
.service-income-pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: nowrap;
  gap: 10px;
  margin-top: 6px;
  font-size: 12px;
}
.service-income-pageinfo {
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
}
.service-income-page-controls {
  display: flex;
  align-items: center;
  flex-wrap: nowrap;
  gap: 6px;
}
.service-income-page-controls label {
  display: inline-block;
  margin: 0;
  font-size: 11px;
  white-space: nowrap;
}
.service-income-page-controls select,
.service-income-page-controls input {
  width: auto;
  min-width: 56px;
  padding: 4px 6px;
  font-size: 11px;
  border-radius: 8px;
}
.service-income-page-controls input#jumpPage {
  width: 64px;
}
.service-income-compact .error,
.service-income-compact .success {
  margin-top: 4px;
  min-height: 16px;
  font-size: 12px;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  display: grid;
  place-items: center;
  z-index: 30;
}
.modal-overlay[hidden] {
  display: none !important;
}
.modal-card {
  width: min(760px, 92vw);
  max-height: 86vh;
  overflow: auto;
  background: #fff;
  border-radius: 14px;
  border: 1px solid var(--border);
  padding: 18px;
}
.modal-title { font-size: 18px; font-weight: 700; margin-bottom: 12px; }

@media (max-width: 900px) {
  .console-layout { grid-template-columns: 1fr; }
  .console-sidebar { border-bottom: 1px solid rgba(30, 41, 59, 0.88); }
  .console-layout.collapsed { grid-template-columns: 1fr; }
  .console-layout.collapsed .console-brand-title,
  .console-layout.collapsed .console-user,
  .console-layout.collapsed .console-menu,
  .console-layout.collapsed .console-side-actions { display: block; }
  .workspace { min-height: 70vh; }
  .tab-frame { height: 70vh; }
}

@media (max-width: 768px) {
  .page { margin: 14px auto; padding: 10px; }
  .card { padding: 14px; }
  .grid-2 { grid-template-columns: 1fr; }
  .grid-4 { grid-template-columns: 1fr; }
  .company-status-toggle { padding-inline: 10px; }
  .sales-base-grid { grid-template-columns: 1fr; }
  .sales-base-remark,
  .sales-base-contract { grid-column: auto; }
  .sales-po-top-row { grid-template-columns: 14px minmax(0, 1fr) minmax(0, 1fr) auto auto; }
  .sales-billing-row {
    grid-template-columns: 1fr !important;
  }
  .sales-billing-row .btn-row-remove {
    grid-column: auto !important;
    grid-row: auto !important;
    justify-self: end;
  }
  .po-remark,
  .po-contract-upload { grid-column: 2 / span 2; }
  .sales-due-input-group { flex-wrap: wrap; }
  .sales-due-input-label { width: 100%; }
  .dashboard-overview { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dashboard-kpi-value { font-size: 18px; }
  .dashboard-charts-grid { grid-template-columns: 1fr; }
  .dashboard-pie-legend { grid-template-columns: 1fr; }
  .panel-header { flex-direction: column; align-items: flex-start; }
}
