/*
 * SAGAS Trade V5.67 responsive alignment release
 * Deep-green and mint ERP cockpit design system.
 * The stylesheet is intentionally consolidated: page-specific rules extend one
 * shared token set instead of overriding historical version blocks.
 */

:root {
  color-scheme: light;
  --bg: #f3f6f5;
  --bg-soft: #f8faf9;
  --panel: #ffffff;
  --panel-tint: #f5faf8;
  --text: #17231f;
  --text-strong: #10251e;
  --muted: #687871;
  --muted-2: #82908b;
  --line: #dfe8e4;
  --line-strong: #cbdad4;
  --green-950: #0e2921;
  --green-900: #132f27;
  --green-800: #154b3e;
  --green-700: #176b5b;
  --green-600: #23806c;
  --green-500: #2e927b;
  --mint-500: #5fc7aa;
  --mint-400: #72d6ba;
  --mint-200: #c9ede2;
  --mint-100: #e5f4ef;
  --mint-50: #f1f9f6;
  --primary: var(--green-700);
  --primary-hover: var(--green-800);
  --primary-2: var(--green-500);
  --success: #287a56;
  --success-soft: #e9f6ef;
  --warning: #9a6816;
  --warning-soft: #fff6df;
  --danger: #b33a3a;
  --danger-soft: #fff0f0;
  --info: #376d91;
  --info-soft: #edf5fa;
  --purple: #6f5a91;
  --purple-soft: #f2eef8;
  --shadow-xs: 0 2px 8px rgba(24, 52, 44, 0.04);
  --shadow-sm: 0 7px 20px rgba(24, 52, 44, 0.055);
  --shadow: 0 12px 34px rgba(24, 52, 44, 0.075);
  --shadow-lg: 0 24px 70px rgba(16, 41, 33, 0.15);
  --radius-sm: 10px;
  --radius: 14px;
  --radius-lg: 18px;
  --radius-xl: 24px;
  --sidebar-width: 242px;
  --topbar-height: 76px;
  --content-max: 1680px;
  --focus: 0 0 0 3px rgba(23, 107, 91, 0.16);
  --ease: 160ms ease;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  min-width: 320px;
  min-height: 100%;
  margin: 0;
  overflow-x: hidden;
  color: var(--text);
  background:
    radial-gradient(circle at 92% 0, rgba(95, 199, 170, 0.08), transparent 28rem),
    var(--bg);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Microsoft YaHei", Arial, sans-serif;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.erp-layout,
.erp-main,
.erp-content,
.erp-content > *,
.card,
.table-scroll {
  min-width: 0;
  max-width: 100%;
}

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

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

button,
[type="button"],
[type="submit"],
[role="button"] {
  touch-action: manipulation;
}

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

img,
svg {
  max-width: 100%;
}

h1,
h2,
h3,
h4,
p {
  overflow-wrap: anywhere;
}

:focus-visible {
  outline: 2px solid var(--green-600);
  outline-offset: 2px;
}

.muted,
.helper-note,
.muted-note,
.form-note,
.finance-currency-hint {
  color: var(--muted);
}

.helper-note,
.muted-note,
.form-note,
.finance-currency-hint {
  font-size: 12px;
  font-weight: 650;
  line-height: 1.55;
}

.money {
  color: var(--green-700);
  font-variant-numeric: tabular-nums;
}

.version-badge,
.build-badge,
.app-version {
  display: none;
}

/* -------------------------------------------------------------------------- */
/* Login                                                                       */
/* -------------------------------------------------------------------------- */

body.login-page,
.login-page {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at 11% 16%, rgba(95, 199, 170, 0.22), transparent 31%),
    radial-gradient(circle at 89% 84%, rgba(23, 107, 91, 0.14), transparent 35%),
    linear-gradient(135deg, #eaf3f0 0%, #f7f9f8 48%, #edf5f2 100%);
}

.login-shell {
  width: min(1040px, calc(100vw - 32px));
  min-height: 620px;
  display: grid;
  grid-template-columns: minmax(0, 1.06fr) minmax(420px, 0.94fr);
  overflow: hidden;
  border: 1px solid rgba(23, 107, 91, 0.17);
  border-radius: 26px;
  background: rgba(255, 255, 255, 0.97);
  box-shadow: 0 34px 100px rgba(24, 52, 44, 0.18);
}

.login-shell > .login-card {
  grid-column: 1 / -1;
  width: min(500px, calc(100% - 32px));
  align-self: center;
  justify-self: center;
}

.login-visual {
  position: relative;
  isolation: isolate;
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding: 54px 48px;
  overflow: hidden;
  color: #effaf6;
  background:
    linear-gradient(145deg, rgba(12, 48, 39, 0.98), rgba(23, 107, 91, 0.94)),
    var(--green-900);
}

.login-visual::before,
.login-visual::after {
  content: "";
  position: absolute;
  z-index: -1;
  border-radius: 50%;
  background: rgba(114, 214, 186, 0.13);
}

.login-visual::before {
  width: 320px;
  height: 320px;
  top: -96px;
  right: -130px;
}

.login-visual::after {
  width: 230px;
  height: 230px;
  bottom: -92px;
  left: -96px;
}

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

.login-logo,
.login-visual .brand-mark {
  width: 56px;
  height: 56px;
  flex: 0 0 56px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 17px;
  background: linear-gradient(135deg, #8ce2ca, #4db398);
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.18);
  color: var(--green-950);
  font-size: 18px;
  font-weight: 900;
}

.login-brand b,
.login-visual-brand b {
  display: block;
  font-size: 19px;
}

.login-brand small,
.login-brand span,
.login-visual-brand small,
.login-visual-brand span {
  display: block;
  margin-top: 3px;
  color: #bdd8d0;
  font-size: 12px;
}

.login-copy,
.login-visual-copy {
  margin-top: 64px;
}

.login-copy h1,
.login-visual-copy h1 {
  max-width: 460px;
  margin: 0 0 16px;
  color: #fff;
  font-size: clamp(30px, 3.1vw, 38px);
  line-height: 1.26;
  letter-spacing: 0.3px;
}

.login-copy p,
.login-visual-copy p {
  max-width: 460px;
  margin: 0;
  color: #c7ddd6;
  font-size: 14px;
  line-height: 1.8;
}

.login-feature-list {
  display: grid;
  gap: 11px;
  margin-top: 34px;
}

.login-feature {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 11px 13px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 13px;
  background: rgba(255, 255, 255, 0.065);
}

.login-feature > span:first-child {
  flex: 0 0 auto;
}

.login-feature strong {
  display: block;
  color: #fff;
  font-size: 13px;
}

.login-feature small {
  display: block;
  margin-top: 3px;
  color: #bad2cb;
  font-size: 12px;
  line-height: 1.5;
}

.login-form-panel {
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 48px 50px;
  background: rgba(255, 255, 255, 0.98);
}

.login-card {
  width: 100%;
  min-width: 0;
  padding: 36px;
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  background: rgba(255, 255, 255, 0.98);
  box-shadow: var(--shadow);
}

.login-form-panel .login-card {
  padding: 0;
  border: 0;
  border-radius: 0;
  box-shadow: none;
}

.login-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 18px;
}

.login-form-panel > h1,
.login-form-panel > h2,
.login-card > h1,
.login-card > h2 {
  margin: 0 0 7px;
  color: var(--text-strong);
  font-size: 28px;
  line-height: 1.22;
  letter-spacing: -0.35px;
}

.login-subtitle,
.login-help {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.65;
}

.login-subtitle {
  margin: 0 0 24px;
}

.login-help {
  margin: 16px 0 0;
}

.login-form {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
  margin-top: 22px;
}

.login-form label:not(.remember-line) {
  display: grid;
  gap: 7px;
}

.login-form label > span,
.login-form-panel label > span {
  color: #4e5d58;
  font-size: 12px;
  font-weight: 800;
}

.login-form input:not([type="checkbox"]),
.login-form select,
.login-form-panel input:not([type="checkbox"]),
.login-form-panel select {
  width: 100%;
  height: 46px;
  min-width: 0;
  border: 1px solid #d5e0dc;
  border-radius: 12px;
  padding: 0 13px;
  background: #fff;
  outline: none;
  transition: border-color var(--ease), box-shadow var(--ease), background var(--ease);
}

.login-form input:focus,
.login-form select:focus,
.login-form-panel input:focus,
.login-form-panel select:focus {
  border-color: #65a997;
  box-shadow: var(--focus);
}

.password-box {
  position: relative;
}

.password-box input {
  padding-right: 70px;
}

.password-toggle {
  position: absolute;
  top: 7px;
  right: 7px;
  height: 32px;
  border: 0;
  border-radius: 8px;
  padding: 0 10px;
  color: var(--green-700);
  background: var(--mint-100);
  font-size: 11px;
  font-weight: 800;
}

.remember-line {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 40px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 11px;
  color: #58655f;
  background: var(--bg-soft);
  font-size: 12px;
  font-weight: 700;
}

.remember-line input {
  width: 17px;
  height: 17px;
  flex: 0 0 17px;
  accent-color: var(--green-700);
}

.login-remember-tip {
  margin: -5px 0 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.55;
}

.login-form .btn.primary,
.login-submit {
  width: 100%;
  height: 48px;
  border: 0;
  border-radius: 12px;
  color: #fff;
  background: linear-gradient(135deg, var(--green-700), var(--green-500));
  box-shadow: 0 12px 28px rgba(23, 107, 91, 0.22);
  font-weight: 850;
}

.login-message {
  min-height: 20px;
  margin-top: 10px;
  color: var(--danger);
  font-size: 12px;
}

.login-demo {
  margin-top: 12px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--muted);
  background: var(--bg-soft);
  font-size: 11px;
  line-height: 1.65;
}

/* -------------------------------------------------------------------------- */
/* Application shell                                                          */
/* -------------------------------------------------------------------------- */

.app-shell {
  width: 100%;
  min-height: 100vh;
  min-height: 100dvh;
}

.erp-layout {
  width: 100%;
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
}

.erp-sidebar {
  position: sticky;
  top: 0;
  z-index: 40;
  height: 100vh;
  height: 100dvh;
  min-width: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  color: #edf7f3;
  background:
    radial-gradient(circle at 100% 0, rgba(95, 199, 170, 0.12), transparent 16rem),
    var(--green-950);
  box-shadow: 10px 0 30px rgba(16, 41, 33, 0.05);
}

.sidebar-brand {
  min-height: var(--topbar-height);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 17px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.brand-mark {
  width: 46px;
  height: 46px;
  flex: 0 0 46px;
  display: grid;
  place-items: center;
  overflow: hidden;
  border: 1px solid rgba(220, 232, 245, 0.9);
  border-radius: 14px;
  color: transparent;
  background: #fff url("icons/app-icon-192.png?v=battery31") center / 92% auto no-repeat;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.14);
  font-size: 0;
  font-weight: 900;
}

.brand-mark.small {
  width: 42px;
  height: 42px;
  flex-basis: 42px;
  border-radius: 13px;
}

.sidebar-brand b,
.sidebar-brand strong {
  display: block;
  color: #fff;
  font-size: 16px;
  line-height: 1.25;
}

.sidebar-brand small,
.sidebar-brand span:not(.brand-mark) {
  display: block;
  margin-top: 3px;
  color: #9eb8b0;
  font-size: 10.5px;
  line-height: 1.35;
}

.sidebar-search {
  position: relative;
  display: block;
  padding: 12px;
}

.sidebar-search > span {
  position: absolute;
  top: 50%;
  left: 24px;
  z-index: 1;
  transform: translateY(-50%);
  color: #9ab2aa;
  font-size: 14px;
  line-height: 1;
  pointer-events: none;
}

.sidebar-search input {
  display: block;
  width: 100%;
  height: 40px;
  border: 1px solid rgba(255, 255, 255, 0.13);
  border-radius: 11px;
  padding: 0 12px 0 34px;
  color: #fff;
  background: rgba(255, 255, 255, 0.07);
  outline: none;
}

.sidebar-search input::placeholder {
  color: #829d94;
}

.sidebar-search input:focus {
  border-color: rgba(114, 214, 186, 0.7);
  box-shadow: 0 0 0 3px rgba(114, 214, 186, 0.12);
}

.sidebar-nav {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
  overflow: auto;
  overscroll-behavior: contain;
  padding: 0 9px 16px;
  scrollbar-width: thin;
  scrollbar-color: rgba(114, 214, 186, 0.28) transparent;
}

.sidebar-nav a,
.sidebar-nav button {
  width: 100%;
  min-height: 42px;
  display: flex;
  align-items: center;
  gap: 10px;
  border: 0;
  border-radius: 11px;
  padding: 9px 12px;
  color: #b8cec7;
  background: transparent;
  text-align: left;
  font-size: 13px;
  font-weight: 750;
  white-space: nowrap;
  transition: color var(--ease), background var(--ease), box-shadow var(--ease);
}

.sidebar-nav a:hover,
.sidebar-nav button:hover,
.sidebar-nav a.active,
.sidebar-nav button.active,
.sidebar-nav [aria-current="page"] {
  color: #fff;
  background: rgba(104, 209, 179, 0.15);
}

.sidebar-nav a.active,
.sidebar-nav button.active,
.sidebar-nav [aria-current="page"] {
  box-shadow: inset 3px 0 0 var(--mint-400);
}

.sidebar-nav .nav-icon {
  width: 20px;
  flex: 0 0 20px;
  display: inline-grid;
  place-items: center;
}

.sidebar-footer {
  padding: 13px 14px 15px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  color: #91aaa3;
  font-size: 11px;
  line-height: 1.65;
}

.sidebar-footer b,
.sidebar-footer strong {
  color: #d7e7e2;
}

.erp-main {
  min-width: 0;
  min-height: 100vh;
}

.erp-topbar,
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  min-height: var(--topbar-height);
  display: grid;
  grid-template-columns: minmax(210px, 1fr) minmax(280px, 26vw) auto;
  align-items: center;
  gap: 16px;
  padding: 12px 22px;
  border-bottom: 1px solid var(--line);
  background: rgba(243, 246, 245, 0.94);
  box-shadow: 0 6px 18px rgba(24, 52, 44, 0.025);
  backdrop-filter: blur(14px);
}

.page-heading {
  min-width: 0;
  align-self: center;
}

.page-heading p {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topbar-left,
.erp-topbar-left,
.topbar-title {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 12px;
}

.erp-topbar h1,
.topbar h1 {
  margin: 0;
  color: var(--text-strong);
  font-size: 20px;
  line-height: 1.25;
  letter-spacing: -0.25px;
}

.erp-topbar h1 span,
.topbar h1 span {
  display: none;
}

.erp-topbar p,
.topbar p,
.ledger-subtitle {
  display: block;
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 11.5px;
  line-height: 1.4;
}

.topbar-actions,
.erp-topbar-actions {
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 9px;
}

.topbar-actions > form,
.erp-topbar-actions > form {
  margin: 0;
}

.global-po-search,
.table-search,
.select-search {
  position: relative;
  min-width: 0;
}

.global-po-search {
  width: 100%;
  max-width: 500px;
  justify-self: center;
}

.global-po-search > span,
.table-search > span {
  position: absolute;
  top: 50%;
  left: 13px;
  z-index: 2;
  transform: translateY(-50%);
  color: #688078;
  font-size: 14px;
  line-height: 1;
  pointer-events: none;
}

.global-po-search input,
.table-search input,
.select-search input,
.select-search select {
  display: block;
  width: 100%;
  height: 42px;
  min-width: 0;
  border: 1px solid var(--line-strong);
  border-radius: 11px;
  padding: 0 66px 0 36px;
  background: #fff;
  outline: none;
  transition: border-color var(--ease), box-shadow var(--ease);
}

.table-search input {
  padding-right: 12px;
}

.global-po-search input:focus,
.table-search input:focus,
.select-search input:focus,
.select-search select:focus {
  border-color: #72aa9b;
  box-shadow: var(--focus);
}

.global-po-search button,
.table-search button,
.select-search button {
  position: absolute;
  top: 4px;
  right: 5px;
  width: 56px;
  height: 34px;
  min-height: 0;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 8px;
  color: var(--green-700);
  background: var(--mint-100);
  padding: 0;
}

.global-po-results,
.search-results {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 100;
  width: min(440px, calc(100vw - 28px));
  max-height: 360px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 13px;
  padding: 7px;
  background: #fff;
  box-shadow: var(--shadow-lg);
}

.global-po-results a,
.search-results a {
  display: block;
  padding: 9px 10px;
  border-radius: 9px;
  font-size: 12px;
}

.global-po-results a:hover,
.search-results a:hover {
  background: var(--mint-50);
}

.lang-form {
  margin: 0;
}

.lang-form select,
.lang-form.mini select {
  height: 42px;
  min-width: 112px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  padding: 0 30px 0 10px;
  color: #344b43;
  background: #fff;
  outline: none;
}

.lang-form select:focus {
  border-color: #72aa9b;
  box-shadow: var(--focus);
}

.user-badge {
  display: inline-flex;
  align-items: center;
  min-height: 42px;
  border: 1px solid #cfe1da;
  border-radius: 999px;
  padding: 7px 12px;
  color: var(--green-700);
  background: var(--mint-100);
  font-size: 12px;
  font-weight: 850;
  white-space: nowrap;
}

.logout {
  height: 42px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  padding: 0 12px;
  color: #566660;
  background: #fff;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
}

.logout:hover {
  border-color: #e0baba;
  color: var(--danger);
  background: #fff8f8;
}

.erp-content {
  width: min(100%, var(--content-max));
  margin: 0 auto;
  padding: 20px 22px 42px;
}

/* Compatibility navigation for pages that still render the V5.64 shell. */
.app-shell:not(.erp-content) > .topbar,
.app-shell:not(.erp-content) > .main-nav,
.app-shell:not(.erp-content) > .card,
.app-shell:not(.erp-content) > .dashboard-grid,
.app-shell:not(.erp-content) > .flow-strip,
.app-shell:not(.erp-content) > .alert {
  width: min(calc(100% - 28px), var(--content-max));
  margin-right: auto;
  margin-left: auto;
}

.app-shell:not(.erp-content) > .topbar {
  top: 10px;
  margin-top: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
}

.app-shell:not(.erp-content) > .main-nav {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.92);
  box-shadow: var(--shadow-xs);
  scrollbar-width: thin;
}

.app-shell:not(.erp-content) > .main-nav {
  margin-top: 12px;
  margin-bottom: 15px;
}

.app-shell:not(.erp-content) > .main-nav a {
  flex: 0 0 auto;
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 7px 12px;
  color: #40544d;
  background: #fff;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.app-shell:not(.erp-content) > .main-nav a:hover {
  border-color: #b9d8ce;
  color: var(--green-700);
  background: var(--mint-50);
}

.app-shell:not(.erp-content) > .main-nav a.active,
.app-shell:not(.erp-content) > .main-nav a[aria-current="page"] {
  border-color: var(--green-700);
  color: #fff;
  background: linear-gradient(135deg, var(--green-700), var(--green-500));
  box-shadow: 0 7px 17px rgba(23, 107, 91, 0.18);
}

.sidebar-toggle,
.mobile-nav-toggle {
  display: none;
}

.sidebar-backdrop {
  display: none;
}

/* -------------------------------------------------------------------------- */
/* Cards, headings, buttons, messages                                          */
/* -------------------------------------------------------------------------- */

.card,
.inner-card,
.stage-card {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--panel);
  box-shadow: var(--shadow-sm);
}

.card {
  margin-top: 16px;
}

.form-card,
.page-card,
.inner-card {
  padding: 18px;
}

.stage-card {
  margin: 10px 0;
  padding: 15px;
  background: linear-gradient(180deg, #fff, var(--bg-soft));
}

.stage-card h3,
.inner-card h3 {
  margin: 0 0 10px;
  color: var(--text-strong);
  font-size: 16px;
}

.section-title {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin: 0 0 15px;
}

.section-title h1,
.section-title h2,
.section-title h3 {
  margin: 0;
  color: var(--text-strong);
  line-height: 1.3;
}

.section-title h1 {
  font-size: 23px;
}

.section-title h2 {
  font-size: 19px;
}

.section-title h3 {
  font-size: 16px;
}

.section-title p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
}

.btn,
.small-btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid var(--line-strong);
  color: #344840;
  background: #fff;
  font-weight: 800;
  line-height: 1;
  text-align: center;
  white-space: nowrap;
  cursor: pointer;
  transition: transform var(--ease), border-color var(--ease), color var(--ease),
    background var(--ease), box-shadow var(--ease), filter var(--ease);
}

.btn {
  min-height: 42px;
  border-radius: 11px;
  padding: 0 16px;
  font-size: 13px;
}

.btn.small {
  min-height: 34px;
  padding: 0 11px;
  border-radius: 9px;
  font-size: 12px;
}

.btn.tiny {
  min-height: 30px;
  padding: 0 9px;
  border-radius: 8px;
  font-size: 10.5px;
}

.small-btn {
  min-height: 32px;
  margin: 2px 3px 2px 0;
  border-radius: 9px;
  padding: 0 10px;
  font-size: 11px;
}

.btn:hover,
.small-btn:hover {
  transform: translateY(-1px);
  filter: brightness(0.985);
}

.btn:active,
.small-btn:active {
  transform: translateY(0);
}

.btn:disabled,
.small-btn:disabled,
button:disabled {
  opacity: 0.52;
  cursor: not-allowed;
  transform: none;
}

.btn.primary,
.small-btn.green,
.btn.green {
  border-color: var(--green-700);
  color: #fff;
  background: linear-gradient(135deg, var(--green-700), var(--green-500));
  box-shadow: 0 8px 18px rgba(23, 107, 91, 0.17);
}

.btn.ghost {
  border-color: var(--line-strong);
  color: #40544d;
  background: #fff;
}

.btn.ghost:hover {
  border-color: #a9cec2;
  color: var(--green-700);
  background: var(--mint-50);
}

.btn.blue,
.small-btn.blue {
  border-color: #497d9f;
  color: #fff;
  background: #497d9f;
}

.btn.orange,
.small-btn.orange {
  border-color: #a8741e;
  color: #fff;
  background: #a8741e;
}

.btn.red,
.small-btn.red {
  border-color: var(--danger);
  color: #fff;
  background: var(--danger);
}

.btn.purple,
.small-btn.purple {
  border-color: var(--purple);
  color: #fff;
  background: var(--purple);
}

.btn.dark,
.small-btn.dark,
.trace-link {
  border-color: #3f554d;
  color: #fff;
  background: #3f554d;
}

.trace-link {
  min-height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  border-radius: 9px;
  padding: 0 10px;
  font-size: 11px;
  font-weight: 850;
}

.trace-link::before {
  content: "↗";
  font-size: 11px;
}

.actions,
.form-actions,
.tool-actions,
.track-actions {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
}

.form-actions {
  justify-content: flex-end;
}

.notice,
.alert {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 11px 14px;
  color: #4c6058;
  background: var(--mint-50);
  font-size: 13px;
  font-weight: 700;
  line-height: 1.55;
}

.alert {
  margin: 12px 0;
}

.alert.success,
.alert.ok {
  border-color: #c5e2d5;
  color: #28654d;
  background: var(--success-soft);
}

.alert.error {
  border-color: #efcccc;
  color: #973737;
  background: var(--danger-soft);
}

.alert.warn,
.alert.warning {
  border-color: #ecd6aa;
  color: #795717;
  background: var(--warning-soft);
}

/* -------------------------------------------------------------------------- */
/* Process cockpit                                                             */
/* -------------------------------------------------------------------------- */

.process-control-card {
  position: relative;
  min-width: 0;
  overflow: hidden;
  border: 1px solid #c8e0d8;
  border-radius: var(--radius-lg);
  padding: 16px;
  background:
    radial-gradient(circle at 100% 0, rgba(95, 199, 170, 0.14), transparent 20rem),
    linear-gradient(135deg, #f1f8f6 0%, #ffffff 70%);
  box-shadow: var(--shadow-sm);
}

.process-control-card > .table-toolbar {
  align-items: center;
  padding: 0 0 12px;
}

.process-control-card > .table-toolbar .section-title {
  margin: 0;
}

.status-pill {
  min-height: 30px;
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  border: 1px solid #c8e1d7;
  border-radius: 999px;
  padding: 5px 11px;
  color: #28654d;
  background: var(--success-soft);
  font-size: 11px;
  font-weight: 850;
  line-height: 1.2;
  white-space: nowrap;
}

.process-control-head,
.process-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
}

.process-control-head h2,
.process-control-head h3,
.process-card-head h2,
.process-card-head h3 {
  display: flex;
  align-items: center;
  gap: 9px;
  margin: 0 0 5px;
  color: var(--text-strong);
  font-size: 18px;
}

.process-control-head h2::before,
.process-control-head h3::before,
.process-card-head h2::before,
.process-card-head h3::before {
  content: "";
  width: 4px;
  height: 21px;
  flex: 0 0 4px;
  border-radius: 5px;
  background: linear-gradient(180deg, var(--mint-500), var(--green-700));
}

.process-control-head p,
.process-card-head p {
  max-width: 980px;
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
}

.process-status,
.process-health,
.process-lock {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 29px;
  border-radius: 999px;
  padding: 5px 10px;
  color: #28654d;
  background: var(--success-soft);
  font-size: 11px;
  font-weight: 850;
  white-space: nowrap;
}

.process-status.warning,
.process-health.warning,
.process-lock.blocked {
  color: #7a5718;
  background: var(--warning-soft);
}

.process-status.danger,
.process-health.danger {
  color: #973737;
  background: var(--danger-soft);
}

.process-summary-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 11px;
}

.process-summary-grid > *,
.process-summary-card,
.process-summary-item {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 14px;
  min-height: 62px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 10px 13px;
  background: rgba(255, 255, 255, 0.88);
  box-shadow: var(--shadow-xs);
}

.process-summary-grid h3,
.process-summary-grid h4,
.process-summary-grid b,
.process-summary-card h3,
.process-summary-item h3 {
  display: block;
  margin: 0 0 6px;
  color: #264138;
  font-size: 14px;
}

.process-summary-grid p,
.process-summary-grid small,
.process-summary-grid span,
.process-summary-card p,
.process-summary-item p {
  display: block;
  margin: 0;
  color: var(--muted);
  font-size: 11.5px;
  line-height: 1.55;
}

.process-rail,
.flow-strip.kingdee-flow {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(128px, 1fr);
  gap: 8px;
  overflow-x: auto;
  overscroll-behavior-inline: contain;
  padding: 3px 2px 7px;
  scroll-snap-type: x proximity;
  scrollbar-width: thin;
  scrollbar-color: #b9d5cc transparent;
}

.process-step,
.flow-chip {
  --step-color: var(--muted-2);
  --step-bg: #f8faf9;
  --step-border: var(--line);
  position: relative;
  min-width: 128px;
  min-height: 78px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 4px;
  scroll-snap-align: start;
  border: 1px solid var(--step-border);
  border-radius: 12px;
  padding: 9px 11px;
  color: var(--step-color);
  background: var(--step-bg);
  box-shadow: var(--shadow-xs);
  font-size: 12px;
  font-weight: 800;
  line-height: 1.35;
}

.process-step::after,
.flow-chip::after {
  content: "";
  position: absolute;
  top: 50%;
  right: -9px;
  width: 9px;
  height: 2px;
  background: #cbd9d4;
}

.process-step:last-child::after,
.flow-chip:last-child::after {
  display: none;
}

.process-step b,
.flow-chip b {
  color: currentColor;
  font-size: 15px;
  font-variant-numeric: tabular-nums;
}

.process-step small,
.process-step span,
.flow-chip small {
  color: inherit;
  font-size: 10.5px;
  font-weight: 650;
  opacity: 0.82;
}

.process-step i,
.flow-chip i {
  font-style: normal;
}

.process-step.done,
.process-step.is-done,
.process-step[data-state="done"],
.flow-chip.done {
  --step-color: #22664b;
  --step-bg: #eaf7f1;
  --step-border: #bddfd2;
}

.process-step.current,
.process-step.is-current,
.process-step[data-state="current"],
.flow-chip.current {
  --step-color: #2e6487;
  --step-bg: #edf5fa;
  --step-border: #bfd5e4;
  box-shadow: inset 0 0 0 1px rgba(55, 109, 145, 0.08), var(--shadow-xs);
}

.process-step.blocked,
.process-step.is-blocked,
.process-step[data-state="blocked"],
.flow-chip.blocked {
  --step-color: #805b18;
  --step-bg: #fff7e4;
  --step-border: #ead5a6;
}

.process-step.danger,
.process-step.is-danger,
.process-step[data-state="danger"] {
  --step-color: #963838;
  --step-bg: #fff1f1;
  --step-border: #efcaca;
}

.process-step.future,
.process-step.is-future,
.process-step[data-state="future"] {
  --step-color: #87938e;
  --step-bg: #f7f9f8;
  --step-border: #e3e9e6;
}

/* -------------------------------------------------------------------------- */
/* Dashboard                                                                   */
/* -------------------------------------------------------------------------- */

.dashboard-overview {
  padding: 10px 14px;
}

.dashboard-overview > .section-title {
  flex-direction: row;
  align-items: baseline;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 7px;
}

.dashboard-overview > .section-title p {
  max-width: 720px;
  overflow: hidden;
  text-align: right;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dashboard-grid,
.kpi-primary-grid,
.kpi-secondary-grid {
  display: grid;
  gap: 10px;
  margin: 10px 0;
}

.kpi-primary-grid,
.dashboard-overview .kpi-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.kpi-secondary-grid,
.dashboard-row-currency,
.dashboard-row-business,
.legacy-kpi-grid {
  grid-template-columns: repeat(auto-fit, minmax(175px, 1fr));
}

.metric-card,
.kpi-card {
  --accent: var(--green-700);
  --accent-soft: var(--mint-100);
  position: relative;
  min-width: 0;
  min-height: 96px;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  overflow: hidden;
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent);
  border-radius: 15px;
  padding: 11px 14px;
  color: inherit;
  background: #fff;
  box-shadow: var(--shadow-sm);
  transition: transform var(--ease), border-color var(--ease), box-shadow var(--ease);
}

.kpi-primary-grid .metric-card,
.dashboard-overview .kpi-grid .metric-card {
  min-height: 88px;
  padding: 8px 13px;
}

.dashboard-overview > .kpi-primary-grid {
  margin: 0;
}

.dashboard-overview .metric-sub {
  padding-right: 76px;
}

.dashboard-overview .card-enter {
  position: absolute;
  right: 14px;
  bottom: 10px;
  margin: 0;
}

.metric-card::after,
.kpi-card::after {
  content: "";
  position: absolute;
  top: -24px;
  right: -20px;
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: var(--accent-soft);
}

.metric-card > *,
.kpi-card > * {
  position: relative;
  z-index: 1;
}

.metric-card > span,
.kpi-card > span,
.kpi-card > small {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  line-height: 1.3;
}

.metric-card strong,
.kpi-card strong,
.kpi-card b {
  display: block;
  margin-top: 4px;
  color: var(--text-strong);
  font-size: clamp(21px, 1.7vw, 27px);
  line-height: 1.14;
  letter-spacing: -0.45px;
  word-break: break-word;
  font-variant-numeric: tabular-nums;
}

.metric-sub {
  margin: 4px 0 0;
  color: #52665e;
  font-size: 11.5px;
  font-weight: 700;
  line-height: 1.42;
}

.dashboard-click-card {
  cursor: pointer;
}

.dashboard-click-card:hover,
.metric-card:hover {
  transform: translateY(-2px);
  border-color: #b9d8ce;
  box-shadow: 0 16px 32px rgba(24, 52, 44, 0.1);
}

.card-enter {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: auto;
  padding-top: 4px;
  color: var(--accent);
  font-size: 11px;
  font-style: normal;
  font-weight: 850;
}

.card-enter::after {
  content: "›";
  font-size: 15px;
  line-height: 1;
}

.metric-card.tone-blue,
.kpi-card.tone-blue {
  --accent: #477a9c;
  --accent-soft: #eaf3f8;
}

.metric-card.tone-green,
.kpi-card.tone-green {
  --accent: var(--green-700);
  --accent-soft: var(--mint-100);
}

.metric-card.tone-red,
.kpi-card.tone-red,
.metric-card.dashboard-warning-text {
  --accent: var(--danger);
  --accent-soft: var(--danger-soft);
}

.metric-card.tone-orange,
.kpi-card.tone-orange {
  --accent: #a8741e;
  --accent-soft: var(--warning-soft);
}

.metric-card.tone-purple,
.kpi-card.tone-purple {
  --accent: var(--purple);
  --accent-soft: var(--purple-soft);
}

.metric-card.tone-gray,
.kpi-card.tone-gray {
  --accent: #687871;
  --accent-soft: #eef2f0;
}

.dashboard-warning-text > span,
.dashboard-warning-text strong,
.dashboard-warning-text .metric-sub,
.dashboard-warning-text .card-enter {
  color: var(--danger);
}

.dashboard-alert-center {
  padding: 0 17px 17px;
}

.dashboard-alert-center > .table-toolbar {
  padding-right: 0;
  padding-left: 0;
}

.dashboard-alert-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(245px, 1fr));
  gap: 12px;
}

.dashboard-alert-card {
  --alert-accent: var(--green-700);
  --alert-soft: var(--mint-50);
  min-width: 0;
  min-height: 128px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-left: 4px solid var(--alert-accent);
  border-radius: 14px;
  padding: 13px 14px;
  background: linear-gradient(180deg, #fff, var(--alert-soft));
  box-shadow: var(--shadow-xs);
}

.dashboard-alert-card.tone-red,
.dashboard-alert-card.dashboard-warning-text {
  --alert-accent: var(--danger);
  --alert-soft: #fff7f7;
}

.dashboard-alert-card.tone-orange {
  --alert-accent: #a8741e;
  --alert-soft: #fffbf1;
}

.dashboard-alert-card.tone-blue {
  --alert-accent: #477a9c;
  --alert-soft: #f5f9fc;
}

.dashboard-alert-card.tone-purple {
  --alert-accent: var(--purple);
  --alert-soft: #faf8fc;
}

.dashboard-alert-card.tone-green {
  --alert-accent: var(--green-700);
  --alert-soft: #f5fbf8;
}

.dashboard-alert-card.tone-gray {
  --alert-accent: #75827d;
  --alert-soft: #f8faf9;
}

.alert-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
  color: var(--text-strong);
  font-size: 14px;
}

.alert-card-head span {
  min-width: 25px;
  height: 25px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  padding: 0 7px;
  color: var(--alert-accent);
  background: color-mix(in srgb, var(--alert-accent) 12%, white);
  font-size: 11px;
  font-weight: 900;
}

.dashboard-alert-card ul {
  display: grid;
  gap: 5px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.dashboard-alert-card li {
  padding-bottom: 5px;
  border-bottom: 1px dashed var(--line);
  color: #43564f;
  font-size: 11.5px;
  line-height: 1.45;
}

.dashboard-alert-card li:last-child {
  padding-bottom: 0;
  border-bottom: 0;
}

.dashboard-alert-card.dashboard-warning-text .alert-card-head span,
.dashboard-alert-card.dashboard-warning-text li {
  color: var(--danger);
}

.chart-card,
.dashboard-bank-table {
  overflow: hidden;
}

.sales-chart-svg {
  width: calc(100% - 32px);
  min-height: 210px;
  display: block;
  margin: 0 16px 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 7px;
  background: linear-gradient(180deg, #fff, var(--mint-50));
}

/* -------------------------------------------------------------------------- */
/* Forms                                                                       */
/* -------------------------------------------------------------------------- */

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

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 13px;
}

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

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

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

.grid-3 > #users {
  grid-column: 1 / -1;
}

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

.field,
.login-form label:not(.remember-line) {
  min-width: 0;
}

.field {
  display: grid;
  gap: 7px;
  align-content: start;
}

.field > span,
.field > label {
  color: #40534c;
  font-size: 12px;
  font-weight: 800;
}

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

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

.field input,
.field select,
.field textarea,
.search-box input,
.inline-form input,
.inline-form select,
.inline-filter input,
.inline-filter select,
.kd-auto-toolbar input,
.order-line input,
.order-line select,
.tier-line input,
.tier-line select,
.perm-row input[type="text"],
.data-table input,
.data-table select,
.data-table textarea {
  width: 100%;
  min-width: 0;
  border: 1px solid #cfdcd7;
  border-radius: 10px;
  background: #fff;
  outline: none;
  transition: border-color var(--ease), box-shadow var(--ease), background var(--ease);
}

.field input,
.field select,
.search-box input,
.inline-form input,
.inline-form select,
.inline-filter input,
.inline-filter select,
.kd-auto-toolbar input,
.order-line input,
.order-line select,
.tier-line input,
.tier-line select,
.data-table input,
.data-table select {
  height: 42px;
  padding: 0 11px;
}

.field textarea,
.data-table textarea {
  min-height: 92px;
  padding: 10px 12px;
  resize: vertical;
  line-height: 1.55;
}

.field select[multiple],
.multi-select {
  height: auto;
  min-height: 128px;
  padding: 9px 10px;
  line-height: 1.55;
}

.field input:focus,
.field select:focus,
.field textarea:focus,
.search-box input:focus,
.inline-form input:focus,
.inline-form select:focus,
.inline-filter input:focus,
.inline-filter select:focus,
.kd-auto-toolbar input:focus,
.order-line input:focus,
.order-line select:focus,
.tier-line input:focus,
.tier-line select:focus,
.data-table input:focus,
.data-table select:focus,
.data-table textarea:focus {
  border-color: #72aa9b;
  box-shadow: var(--focus);
}

.field input:disabled,
.field select:disabled,
.field textarea:disabled {
  color: #75827d;
  background: #f2f5f4;
}

.field small {
  display: block;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.5;
}

.inline-form,
.inline-filter {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.inline-ledger-password {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
}

.inline-ledger-password input {
  width: min(230px, 100%);
  height: 34px;
  min-width: 150px;
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  padding: 0 10px;
  background: #fff;
  outline: none;
}

.inline-ledger-password input:focus {
  border-color: #72aa9b;
  box-shadow: var(--focus);
}

.inline-form input,
.inline-form select,
.inline-filter input,
.inline-filter select {
  width: auto;
  min-width: 140px;
}

.summary-box,
.summary {
  border: 1px solid var(--line);
  border-radius: 13px;
  padding: 13px 14px;
  color: #43564f;
  background: var(--bg-soft);
}

.finance-entry-top {
  align-items: start;
}

.statement-module {
  display: grid;
  gap: 15px;
  min-width: 0;
}

.statement-header {
  align-items: flex-start;
}

.statement-filter {
  display: grid;
  grid-template-columns: minmax(180px, 0.75fr) minmax(220px, 1fr) minmax(240px, 1.15fr) auto;
  gap: 12px;
  align-items: end;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--bg-soft);
}

.statement-filter [hidden] {
  display: none;
}

.statement-filter-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 42px;
}

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

.statement-metrics .metric-card {
  min-height: 92px;
  padding: 12px 14px;
}

.statement-metrics .metric-card strong {
  font-size: clamp(18px, 1.6vw, 24px);
}

.statement-summary,
.statement-detail {
  min-width: 0;
  padding: 15px;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: #fff;
}

.statement-detail {
  border-color: #bcdcd3;
  box-shadow: 0 8px 24px rgba(23, 107, 91, 0.07);
}

.statement-summary .section-title,
.statement-detail .section-title {
  margin-bottom: 11px;
}

.statement-summary .data-table,
.statement-detail .data-table {
  min-width: 860px;
}

.statement-summary td:nth-child(2),
.statement-detail td:nth-child(2) {
  white-space: nowrap;
}

@media (max-width: 1199px) {
  .finance-module-nav {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

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

  .statement-filter-actions {
    grid-column: 1 / -1;
    justify-content: flex-end;
  }

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

@media (max-width: 767px) {
  .statement-header .actions,
  .statement-filter,
  .statement-filter-actions,
  .statement-metrics {
    grid-template-columns: 1fr;
  }

  .statement-header .actions {
    display: grid;
    width: 100%;
  }

  .statement-header .actions .btn,
  .statement-filter-actions .btn {
    width: 100%;
  }

  .statement-filter-actions {
    display: grid;
  }

  .statement-summary,
  .statement-detail {
    padding: 12px;
  }
}

.finance-currency-grid {
  align-items: stretch;
}

.report-preview {
  margin-top: 14px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 15px;
  background: #fff;
  box-shadow: var(--shadow-xs);
}

.report-preview h3 {
  margin: 0 0 12px;
  color: var(--text-strong);
  font-size: 15px;
}

.link {
  color: var(--green-700);
  font-weight: 800;
  text-decoration: underline;
  text-decoration-color: rgba(23, 107, 91, 0.28);
  text-underline-offset: 3px;
}

.link:hover {
  color: var(--green-800);
  text-decoration-color: currentColor;
}

/* Order lines */
.order-lines {
  grid-column: 1 / -1;
  display: grid;
  gap: 9px;
  margin-top: 13px;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 12px;
  background: var(--bg-soft);
}

.order-line {
  min-width: 0;
  display: grid;
  grid-template-columns: 38px minmax(230px, 1fr) minmax(105px, 0.42fr)
    minmax(125px, 0.55fr) minmax(110px, 0.45fr);
  gap: 9px;
  align-items: center;
}

.order-line-head {
  padding: 0 3px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 850;
}

.order-line > b {
  width: 31px;
  height: 31px;
  display: grid;
  place-items: center;
  border-radius: 9px;
  color: var(--green-700);
  background: var(--mint-100);
  font-size: 12px;
}

.line-product-cell {
  min-width: 0;
  display: grid;
  gap: 5px;
}

.line-stock-note {
  color: var(--info);
  font-size: 10.5px;
  font-weight: 800;
  line-height: 1.35;
}

.line-stock-note.ok {
  color: var(--success);
}

.line-stock-note.warn {
  color: var(--danger);
}

.line-currency {
  font-variant-numeric: tabular-nums;
}

.order-line-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 3px 3px 0 47px;
}

.add-line-btn {
  min-width: 112px;
}

.price-tier-box {
  grid-column: 1 / -1;
  display: grid;
  gap: 9px;
  margin: 11px 0;
  border: 1px dashed #bdd6cd;
  border-radius: 14px;
  padding: 13px;
  background: var(--mint-50);
}

.price-tier-box.compact,
.perm-matrix.compact {
  gap: 7px;
  padding: 10px;
}

.price-tier-box h3 {
  margin: 0;
  color: #31584b;
  font-size: 14px;
}

.tier-line {
  display: grid;
  grid-template-columns: 55px repeat(4, minmax(100px, 1fr));
  gap: 9px;
  align-items: center;
}

.tier-line.tier-head {
  padding: 0 3px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 850;
}

.tier-line > b {
  width: 31px;
  height: 31px;
  display: grid;
  place-items: center;
  border-radius: 9px;
  color: var(--green-700);
  background: var(--mint-100);
  font-size: 12px;
}

.tier-actions {
  display: flex;
  justify-content: flex-start;
}

/* Permissions */
.permission-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(130px, 1fr));
  gap: 9px;
  margin: 12px 0;
}

.permission-grid label,
.all-perm-line {
  display: flex;
  align-items: center;
  gap: 7px;
  border: 1px solid var(--line);
  border-radius: 11px;
  padding: 9px 10px;
  color: #40534c;
  background: var(--bg-soft);
  font-size: 12px;
  font-weight: 800;
}

.permission-grid input,
.all-perm-line input,
.perm-row input[type="checkbox"] {
  width: 17px;
  height: 17px;
  accent-color: var(--green-700);
}

.perm-matrix {
  display: grid;
  gap: 7px;
  margin: 13px 0;
}

.perm-head,
.perm-row {
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(110px, 1.35fr) repeat(4, minmax(68px, 0.75fr));
  gap: 8px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 11px;
  padding: 9px 10px;
  background: var(--bg-soft);
}

.perm-head {
  color: #36554a;
  background: var(--mint-100);
  font-size: 11px;
  font-weight: 850;
}

.perm-row > span {
  font-size: 12px;
  font-weight: 850;
}

.perm-row label {
  display: flex;
  align-items: center;
  gap: 6px;
  color: #53645e;
  font-size: 11px;
  font-weight: 700;
}

.settings-module-map {
  padding: 16px;
}

.settings-module-map > .section-title {
  margin-bottom: 12px;
}

.settings-module-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 10px;
}

.settings-module-tile {
  min-width: 0;
  display: grid;
  gap: 4px;
  min-height: 76px;
  align-content: center;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px 14px;
  color: var(--text);
  background: linear-gradient(145deg, #ffffff, var(--mint-50));
  box-shadow: 0 7px 20px rgba(24, 52, 44, 0.05);
  text-decoration: none;
}

.settings-module-tile:hover,
.settings-module-tile:focus-visible {
  border-color: var(--green-500);
  box-shadow: 0 0 0 3px rgba(23, 107, 91, 0.12);
  transform: translateY(-1px);
}

.settings-module-tile b {
  color: var(--green-800);
  font-size: 14px;
}

.settings-module-tile span {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.45;
}

/* Personal settings is always available to an authenticated user. */
.my-settings-page {
  width: min(100%, 980px);
  margin: 0 auto;
}

.my-settings-account {
  margin-top: 0;
}

.my-settings-profile {
  display: grid;
  grid-template-columns: 68px minmax(0, 1fr);
  gap: 18px;
  align-items: center;
}

.my-settings-avatar {
  width: 68px;
  height: 68px;
  display: grid;
  place-items: center;
  border-radius: 20px;
  color: #fff;
  background: linear-gradient(145deg, var(--green-500), var(--green-800));
  box-shadow: 0 10px 24px rgba(23, 107, 91, 0.22);
  font-size: 26px;
  font-weight: 900;
}

.my-settings-profile dl {
  min-width: 0;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin: 0;
}

.my-settings-profile dl > div {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  background: var(--mint-50);
}

.my-settings-profile dt {
  color: var(--muted);
  font-size: 11px;
  font-weight: 750;
}

.my-settings-profile dd {
  overflow-wrap: anywhere;
  margin: 4px 0 0;
  color: var(--text-strong);
  font-size: 14px;
  font-weight: 850;
}

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

.my-settings-grid > .card {
  height: calc(100% - 16px);
}

.my-settings-form {
  display: flex;
  min-height: 118px;
  flex-direction: column;
  justify-content: space-between;
  gap: 16px;
}

.my-settings-form .form-actions {
  margin-top: auto;
}

.my-settings-logout {
  min-width: 160px;
}

.user-badge {
  text-decoration: none;
}

@media (max-width: 720px) {
  .my-settings-profile,
  .my-settings-grid {
    grid-template-columns: 1fr;
  }

  .my-settings-avatar {
    width: 56px;
    height: 56px;
    border-radius: 16px;
    font-size: 22px;
  }

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

@media (max-width: 460px) {
  .my-settings-profile dl {
    grid-template-columns: 1fr;
  }

  .my-settings-form .form-actions,
  .my-settings-form .btn {
    width: 100%;
  }
}

.finance-module-map {
  padding: 16px;
}

.finance-module-map > .section-title {
  margin-bottom: 12px;
}

.finance-module-nav {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
}

.finance-module-link {
  position: relative;
  min-width: 0;
  min-height: 88px;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  grid-template-rows: auto auto;
  align-content: center;
  gap: 3px 9px;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px 13px;
  color: var(--text);
  background: linear-gradient(145deg, #ffffff, var(--mint-50));
  box-shadow: 0 7px 20px rgba(24, 52, 44, 0.05);
  text-decoration: none;
  transition: transform var(--ease), border-color var(--ease), box-shadow var(--ease), background var(--ease);
}

.finance-module-link:hover,
.finance-module-link:focus-visible {
  border-color: var(--green-500);
  box-shadow: 0 0 0 3px rgba(23, 107, 91, 0.12);
  transform: translateY(-1px);
}

.finance-module-link.is-active,
.finance-module-link[aria-current="page"] {
  border-color: var(--green-600);
  color: #fff;
  background: linear-gradient(145deg, var(--green-800), var(--green-600));
  box-shadow: 0 12px 26px rgba(23, 107, 91, 0.2);
}

.finance-module-link i {
  width: 29px;
  height: 29px;
  display: grid;
  grid-row: 1 / -1;
  place-items: center;
  align-self: center;
  border-radius: 9px;
  color: var(--green-700);
  background: var(--mint-100);
  font-size: 11px;
  font-style: normal;
  font-weight: 900;
}

.finance-module-link.is-active i,
.finance-module-link[aria-current="page"] i {
  color: var(--green-900);
  background: #dff6ee;
}

.finance-module-link b {
  min-width: 0;
  align-self: end;
  overflow-wrap: anywhere;
  color: inherit;
  font-size: 14px;
  line-height: 1.25;
}

.finance-module-link span {
  min-width: 0;
  align-self: start;
  overflow: hidden;
  overflow-wrap: anywhere;
  color: var(--muted);
  font-size: 10.5px;
  line-height: 1.35;
  text-overflow: ellipsis;
}

.finance-module-link.is-active span,
.finance-module-link[aria-current="page"] span {
  color: rgba(255, 255, 255, 0.82);
}

.finance-module-view {
  min-width: 0;
}

.finance-module-view > .card:first-child,
.finance-module-view > .dashboard-grid:first-child {
  margin-top: 0;
}

.anchor-target,
#ledgers,
#bank_accounts,
#categories,
#qr_rule,
#stocktake,
#print_templates,
#master_edit_delete,
#products,
#suppliers,
#users {
  scroll-margin-top: 86px;
}

.permission-groups {
  display: grid;
  gap: 13px;
  margin: 14px 0;
}

.permission-group-card {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 15px;
  padding: 11px;
  background: #fff;
}

.permission-group-card > header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 12px;
  padding: 2px 3px 7px;
}

.permission-group-card > header h4,
.permission-group-card > header p {
  margin: 0;
}

.permission-group-card > header h4 {
  color: var(--green-800);
  font-size: 14px;
}

.permission-group-card > header p {
  max-width: 68%;
  color: var(--muted);
  font-size: 11px;
  text-align: right;
}

.permission-group-card .perm-matrix {
  margin: 0;
}

.permission-group-card[data-permission-group="dashboard"] {
  border-color: #a9d9ca;
  background: linear-gradient(145deg, #ffffff, #f0faf7);
}

.permission-group-card[data-permission-group="dashboard"] .perm-row {
  border-color: #b8dfd3;
  background: #f5fcfa;
}

.permission-na {
  display: grid;
  min-height: 28px;
  place-items: center;
  color: #a7b3af;
  font-size: 13px;
}

.permission-all-box {
  display: grid;
  gap: 5px;
  border: 1px dashed #b8d5cb;
  border-radius: 13px;
  padding: 10px;
  background: var(--mint-50);
}

.permission-all-box .all-perm-line {
  margin: 0;
  background: #fff;
}

.permission-all-box .helper-note {
  margin: 0;
}

.no-access-card {
  max-width: 780px;
}

/* -------------------------------------------------------------------------- */
/* Tables and pagination                                                       */
/* -------------------------------------------------------------------------- */

.table-card {
  overflow: hidden;
}

.table-toolbar {
  min-width: 0;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 14px;
  padding: 17px 18px 8px;
}

.table-toolbar .section-title {
  margin-bottom: 0;
}

.card > .table-search {
  display: block;
  width: min(420px, calc(100% - 36px));
  margin: 4px 18px 10px auto;
}

.table-scroll {
  width: 100%;
  overflow: auto;
  overscroll-behavior-inline: contain;
  padding: 0 18px 18px;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: #bdcec8 transparent;
}

.data-table {
  width: 100%;
  min-width: 980px;
  border-collapse: separate;
  border-spacing: 0;
  color: #344840;
  font-size: 12px;
}

.data-table th {
  position: sticky;
  top: 0;
  z-index: 2;
  padding: 11px 10px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  color: #52635d;
  background: #f3f7f5;
  font-size: 11px;
  font-weight: 850;
  text-align: left;
  white-space: nowrap;
}

.data-table th:first-child {
  border-left: 1px solid var(--line);
  border-top-left-radius: 10px;
}

.data-table th:last-child {
  border-right: 1px solid var(--line);
  border-top-right-radius: 10px;
}

.data-table td {
  padding: 12px 10px;
  border-bottom: 1px solid #e8eeeb;
  color: #344840;
  background: #fff;
  line-height: 1.5;
  vertical-align: top;
}

.data-table tbody tr:hover td {
  background: #f8fcfa;
}

.data-table b {
  display: block;
  color: var(--text-strong);
  font-size: 12px;
}

.data-table small {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 10.5px;
  line-height: 1.45;
}

.data-table td.actions {
  min-width: 150px;
}

.kd-auto-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  padding: 12px 18px 8px;
  border-top: 1px dashed var(--line);
}

.kd-auto-toolbar input {
  width: min(340px, 100%);
}

.pager,
.finance-pager,
.ar-detail-pager,
.stock-movement-pager {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  flex-wrap: wrap;
  margin: 10px 18px 18px;
}

.pager a,
.pager button,
.finance-pager a,
.finance-pager button,
.ar-detail-pager a,
.ar-detail-pager button,
.stock-movement-pager a,
.stock-movement-pager button {
  min-width: 33px;
  height: 33px;
  display: inline-grid;
  place-items: center;
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  padding: 0 8px;
  color: #43564f;
  background: #fff;
  font-size: 11px;
  font-weight: 800;
}

.pager .active,
.finance-pager .active,
.ar-detail-pager .active,
.stock-movement-pager .active {
  border-color: var(--green-700);
  color: #fff;
  background: var(--green-700);
}

/* Pills and chips */
.pill,
.chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 5px 9px;
  color: #4d6059;
  background: #edf2f0;
  font-size: 10.5px;
  font-weight: 850;
  line-height: 1.2;
  white-space: nowrap;
}

.pill.green,
.chip.green {
  border-color: #c5e2d5;
  color: #28654d;
  background: var(--success-soft);
}

.pill.blue,
.chip.blue {
  border-color: #c9dce8;
  color: #376d91;
  background: var(--info-soft);
}

.pill.orange,
.chip.orange,
.pill.warn {
  border-color: #ecd6aa;
  color: #805b18;
  background: var(--warning-soft);
}

.pill.red,
.chip.red {
  border-color: #efcccc;
  color: #a03939;
  background: var(--danger-soft);
}

.pill.purple,
.chip.purple {
  border-color: #d9cfe7;
  color: #6f5a91;
  background: var(--purple-soft);
}

.chips {
  display: flex;
  gap: 7px;
  flex-wrap: wrap;
}

.chips .chip.active {
  border-color: var(--green-700);
  color: #fff;
  background: var(--green-700);
}

/* -------------------------------------------------------------------------- */
/* Master data cards and expandable editors                                   */
/* -------------------------------------------------------------------------- */

#master_edit_delete .section-title {
  margin-bottom: 17px;
  padding-bottom: 11px;
  border-bottom: 1px solid var(--line);
}

#master_edit_delete .section-title h2 {
  display: flex;
  align-items: center;
  gap: 9px;
}

#master_edit_delete .section-title h2::before {
  content: "";
  width: 5px;
  height: 24px;
  border-radius: 6px;
  background: linear-gradient(180deg, var(--mint-500), var(--green-700));
}

#master_edit_delete .grid-2 {
  grid-template-columns: repeat(auto-fit, minmax(330px, 1fr));
  align-items: start;
  gap: 16px;
}

#master_edit_delete .stage-card {
  position: relative;
  overflow: hidden;
  border-radius: 18px;
  padding: 16px;
}

#master_edit_delete .user-permission-stage {
  grid-column: 1 / -1;
}

#master_edit_delete .stage-card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 4px;
  background: linear-gradient(90deg, var(--green-700), var(--mint-500));
}

#master_edit_delete .stage-card h3 {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 2px 0 13px;
  font-size: 17px;
}

#master_edit_delete .stage-card h3::before {
  content: "";
  width: 9px;
  height: 24px;
  border-radius: 999px;
  background: var(--green-700);
  box-shadow: 0 5px 12px rgba(23, 107, 91, 0.2);
}

.mini-list {
  display: grid;
  gap: 9px;
  margin-top: 11px;
}

.product-manage-list,
.ledger-manage-list {
  align-content: start;
}

.mini-row,
.product-manage-row,
.ledger-manage-row {
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 11px;
  border: 1px solid var(--line);
  border-radius: 11px;
  padding: 9px 11px;
  background: var(--bg-soft);
}

.mini-row > span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 750;
  text-align: right;
}

details.edit-details {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: #fff;
  box-shadow: var(--shadow-xs);
  transition: border-color var(--ease), box-shadow var(--ease), transform var(--ease);
}

details.edit-details:hover,
details.edit-details[open] {
  border-color: #acd1c5;
  box-shadow: var(--shadow-sm);
}

details.edit-details:hover {
  transform: translateY(-1px);
}

details.edit-details > summary {
  min-height: 50px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 9px;
  padding: 11px 12px;
  color: var(--text-strong);
  background: linear-gradient(90deg, #fff, var(--mint-50));
  cursor: pointer;
  list-style: none;
}

details.edit-details > summary::-webkit-details-marker {
  display: none;
}

details.edit-details > summary b {
  min-width: 0;
  font-size: 13px;
  line-height: 1.4;
  word-break: break-word;
}

.master-action-pills {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 5px;
  flex-wrap: wrap;
}

.master-action-pills i {
  min-width: 49px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 0 9px;
  font-size: 11px;
  font-style: normal;
  font-weight: 850;
}

.pill-edit {
  border-color: #c9dce8;
  color: #376d91;
  background: var(--info-soft);
}

.pill-perm {
  border-color: #d9cfe7;
  color: var(--purple);
  background: var(--purple-soft);
}

.pill-delete {
  border-color: #efcccc;
  color: var(--danger);
  background: var(--danger-soft);
}

.pill-type {
  border-color: #c5e2d5;
  color: var(--success);
  background: var(--success-soft);
}

details.edit-details > form,
details.edit-details > .price-tier-box,
details.edit-details .perm-grid {
  margin: 11px 12px;
}

details.edit-details form {
  padding: 0 12px 12px;
}

details.edit-details .form-grid {
  margin-top: 9px;
}

details.edit-details .form-actions {
  justify-content: flex-start;
  margin-top: 9px;
}

.product-manage-row,
.ledger-manage-row {
  align-items: flex-start;
}

.product-manage-row > div:first-child,
.ledger-manage-row > div:first-child {
  min-width: 0;
  display: grid;
  gap: 4px;
}

.product-manage-actions,
.ledger-actions {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  flex-wrap: wrap;
}

.product-manage-actions form,
.ledger-actions form {
  display: inline-flex;
  margin: 0;
}

.status-disabled-note {
  color: var(--warning);
  font-size: 11px;
  font-weight: 850;
}

/* Standalone print document helpers. The print renderer also supplies its own
   minimal CSS, while these rules keep the same document readable on screen. */
.print-wrap {
  width: min(980px, calc(100% - 32px));
  margin: 24px auto;
  border: 1px solid var(--line);
  border-radius: 15px;
  padding: 24px;
  background: #fff;
  box-shadow: var(--shadow-sm);
}

.print-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 18px;
  padding-bottom: 16px;
  border-bottom: 2px solid var(--green-700);
}

.print-head h1,
.print-head p {
  margin: 0;
}

.print-head h1 {
  color: var(--text-strong);
  font-size: 24px;
}

.print-head p {
  margin-top: 4px;
  color: var(--muted);
}

.table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 17px;
  font-size: 12px;
}

.table th,
.table td {
  border: 1px solid var(--line-strong);
  padding: 10px;
  text-align: left;
  vertical-align: top;
}

.table th {
  color: #41554d;
  background: var(--mint-50);
}

.print-wrap .summary {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(260px, 0.7fr);
  gap: 14px;
  margin-top: 18px;
}

.print-wrap .footer {
  margin-top: 22px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.65;
}

.print-wrap .sign {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 28px;
  margin-top: 44px;
  text-align: center;
}

.print-wrap .sign > div {
  padding-top: 9px;
  border-top: 1px solid #9eaaa5;
}

.kpi-grid:has(> .kpi) {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 10px;
}

.kpi {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 13px;
  padding: 13px;
  background: var(--bg-soft);
}

.kpi > span,
.kpi > small {
  display: block;
  color: var(--muted);
  font-size: 10.5px;
}

.kpi > b {
  display: block;
  margin: 6px 0 3px;
  color: var(--text-strong);
  font-size: 19px;
  word-break: break-word;
}

.label {
  break-inside: avoid;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  padding: 12px;
  background: #fff;
  text-align: center;
}

.label .code,
.code {
  margin: 7px 0;
  color: var(--text-strong);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-weight: 850;
  overflow-wrap: anywhere;
}

/* -------------------------------------------------------------------------- */
/* Detail panels, overlays and dialogs                                         */
/* -------------------------------------------------------------------------- */

.dashboard-detail-panel {
  overflow: hidden;
  border-color: #c5ddd5;
  box-shadow: 0 18px 45px rgba(23, 107, 91, 0.1);
}

.dashboard-detail-panel .section-title h2::before {
  content: "筛选明细";
  display: inline-flex;
  align-items: center;
  margin-right: 7px;
  border: 1px solid #c5e2d5;
  border-radius: 999px;
  padding: 3px 7px;
  color: var(--green-700);
  background: var(--mint-100);
  font-size: 10px;
  font-weight: 850;
  vertical-align: middle;
}

.modal-backdrop,
.dialog-backdrop,
.dashboard-detail-backdrop,
.dashboard-detail-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: grid;
  place-items: center;
  padding: 22px;
  background: rgba(10, 31, 24, 0.48);
  backdrop-filter: blur(5px);
}

dialog,
.modal-box,
.dialog-panel,
.dashboard-detail-modal,
.dashboard-detail-overlay .dashboard-detail-panel {
  width: min(1180px, calc(100vw - 36px));
  max-height: 86vh;
  max-height: 86dvh;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 0;
  background: #fff;
  box-shadow: var(--shadow-lg);
}

dialog::backdrop {
  background: rgba(10, 31, 24, 0.48);
  backdrop-filter: blur(5px);
}

.modal-head,
.dialog-head {
  position: sticky;
  top: 0;
  z-index: 4;
  min-height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
}

.modal-body,
.dialog-body {
  padding: 16px;
}

.modal-foot,
.dialog-foot {
  position: sticky;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.96);
}

/* -------------------------------------------------------------------------- */
/* Tracking and display mode                                                   */
/* -------------------------------------------------------------------------- */

.track-wrap {
  width: min(1180px, 100%);
  margin: 24px auto;
  padding: 0 16px;
}

.track-line {
  margin-left: 12px;
  padding-left: 18px;
  border-left: 3px solid var(--green-600);
}

.track-event {
  margin: 10px 0;
  border: 1px solid var(--line);
  border-radius: 13px;
  padding: 13px 15px;
  background: #fff;
  box-shadow: var(--shadow-xs);
}

.track-event b {
  display: block;
  color: var(--text-strong);
}

.display-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 15px;
}

.display-mode {
  color: #eaf5f1;
  background: #081e18;
}

.display-mode .app-shell {
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  padding: 13px;
}

.display-mode .topbar,
.display-mode .main-nav {
  display: none;
}

.display-mode .card,
.display-mode .metric-card {
  background: rgba(255, 255, 255, 0.97);
  box-shadow: none;
}

.display-mode .workshop-table {
  height: calc(100vh - 265px);
  height: calc(100dvh - 265px);
  display: flex;
  flex-direction: column;
}

.display-mode .display-scroll-panel {
  flex: 1;
  overflow: auto;
}

.display-mode .kd-auto-toolbar {
  display: none;
}

/* -------------------------------------------------------------------------- */
/* Responsive                                                                  */
/* -------------------------------------------------------------------------- */

@media (max-width: 1199px) {
  .finance-module-nav {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  :root {
    --sidebar-width: 204px;
  }

  .sidebar-brand {
    padding-right: 12px;
    padding-left: 12px;
  }

  .sidebar-brand b,
  .sidebar-brand strong {
    font-size: 14px;
  }

  .sidebar-nav a,
  .sidebar-nav button {
    padding-right: 9px;
    padding-left: 9px;
    font-size: 12px;
  }

  .erp-content {
    padding: 17px 16px 36px;
  }

  .erp-topbar,
  .topbar {
    grid-template-columns: minmax(0, 1fr) auto;
    padding-right: 16px;
    padding-left: 16px;
  }

  .page-heading {
    grid-column: 1;
    grid-row: 1;
  }

  .global-po-search {
    width: 100%;
    max-width: none;
    grid-column: 1 / -1;
    grid-row: 2;
  }

  .topbar-actions,
  .erp-topbar-actions {
    grid-column: 2;
    grid-row: 1;
  }

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

  .process-summary-grid > :last-child:nth-child(odd) {
    grid-column: 1 / -1;
  }

  .kpi-primary-grid,
  .dashboard-overview .kpi-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

@media (max-width: 920px) {
  :root {
    --sidebar-width: 184px;
  }

  .sidebar-brand .brand-mark {
    width: 38px;
    height: 38px;
    flex-basis: 38px;
  }

  .sidebar-brand small,
  .sidebar-brand span:not(.brand-mark),
  .sidebar-footer {
    font-size: 9.5px;
  }

  .topbar-actions,
  .erp-topbar-actions {
    flex-wrap: wrap;
  }

  .grid-2,
  .grid.two {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 820px) {
  body.login-page,
  .login-page {
    padding: 14px;
  }

  .login-shell {
    width: min(520px, calc(100vw - 24px));
    min-height: auto;
    grid-template-columns: 1fr;
  }

  .login-visual {
    display: none;
  }

  .login-form-panel {
    padding: 34px 27px;
  }

  .login-shell > .login-card {
    grid-column: auto;
    width: 100%;
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }
}

@media (max-width: 899px) {
  .finance-module-nav {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  :root {
    --topbar-height: 64px;
  }

  .erp-layout {
    display: block;
  }

  /* Safe no-JS mobile fallback: the sidebar becomes a compact top module rail. */
  .erp-sidebar {
    position: sticky;
    top: 0;
    z-index: 60;
    width: 100%;
    height: auto;
    max-height: none;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    align-items: center;
    overflow: visible;
  }

  .sidebar-brand {
    min-height: 58px;
    border-bottom: 0;
    padding: 8px 10px;
  }

  .sidebar-brand .brand-mark {
    width: 36px;
    height: 36px;
    flex-basis: 36px;
    border-radius: 11px;
  }

  .sidebar-brand b,
  .sidebar-brand strong {
    max-width: 128px;
    overflow: hidden;
    font-size: 12px;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .sidebar-brand small,
  .sidebar-brand span:not(.brand-mark),
  .sidebar-search,
  .sidebar-footer {
    display: none;
  }

  .sidebar-nav {
    min-height: 58px;
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 5px;
    overflow-x: auto;
    padding: 8px 10px 8px 0;
    scroll-snap-type: x proximity;
  }

  .sidebar-nav a,
  .sidebar-nav button {
    width: auto;
    min-height: 44px;
    flex: 0 0 auto;
    scroll-snap-align: start;
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 7px 10px;
    font-size: 11px;
  }

  .sidebar-nav a.active,
  .sidebar-nav button.active,
  .sidebar-nav [aria-current="page"] {
    box-shadow: inset 0 -3px 0 var(--mint-400);
  }

  /* Optional drawer behaviour when the shell supplies an open state. */
  .erp-layout.has-sidebar-drawer .erp-sidebar,
  body.has-sidebar-drawer .erp-sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: min(292px, 86vw);
    height: 100dvh;
    display: flex;
    transform: translateX(-102%);
    transition: transform 220ms ease;
  }

  .erp-layout.has-sidebar-drawer .sidebar-search,
  .erp-layout.has-sidebar-drawer .sidebar-footer,
  body.has-sidebar-drawer .sidebar-search,
  body.has-sidebar-drawer .sidebar-footer {
    display: block;
  }

  .erp-layout.has-sidebar-drawer .sidebar-nav,
  body.has-sidebar-drawer .sidebar-nav {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    padding: 0 9px 16px;
  }

  .erp-layout.has-sidebar-drawer .sidebar-nav a,
  .erp-layout.has-sidebar-drawer .sidebar-nav button,
  body.has-sidebar-drawer .sidebar-nav a,
  body.has-sidebar-drawer .sidebar-nav button {
    width: 100%;
  }

  .erp-layout.has-sidebar-drawer.sidebar-open .erp-sidebar,
  body.has-sidebar-drawer.sidebar-open .erp-sidebar,
  .erp-sidebar.is-open,
  .erp-sidebar[data-open="true"] {
    transform: translateX(0);
  }

  body.has-sidebar-drawer.sidebar-open {
    overflow: hidden;
  }

  body.has-sidebar-drawer.sidebar-open .sidebar-backdrop {
    position: fixed;
    inset: 0;
    z-index: 55;
    display: block;
    border: 0;
    padding: 0;
    background: rgba(10, 31, 24, 0.42);
    backdrop-filter: blur(2px);
  }

  .sidebar-toggle,
  .mobile-nav-toggle {
    width: 44px;
    height: 44px;
    display: inline-grid;
    place-items: center;
    border: 1px solid var(--line-strong);
    border-radius: 10px;
    color: var(--green-700);
    background: #fff;
  }

  .erp-topbar,
  .topbar {
    position: relative;
    min-height: auto;
    grid-template-columns: auto minmax(0, 1fr);
    gap: 9px 10px;
    padding: 10px 12px 12px;
  }

  .sidebar-toggle,
  .mobile-nav-toggle {
    grid-column: 1;
    grid-row: 1;
  }

  .page-heading {
    grid-column: 2;
    grid-row: 1;
  }

  .erp-topbar h1,
  .topbar h1 {
    font-size: 17px;
  }

  .topbar-left .brand-mark,
  .erp-topbar .brand-mark {
    display: none;
  }

  .topbar-actions,
  .erp-topbar-actions {
    width: 100%;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto;
    grid-column: 1 / -1;
    grid-row: 3;
  }

  .global-po-search {
    width: 100%;
    grid-column: 1 / -1;
    grid-row: 2;
  }

  .global-po-search input {
    height: 44px;
  }

  .global-po-search button {
    top: 4px;
    height: 36px;
  }

  .lang-form select,
  .lang-form.mini select {
    width: 100%;
    min-width: 0;
  }

  .user-badge {
    min-width: 0;
    max-width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .erp-content {
    padding: 12px 9px 28px;
  }

  .app-shell:not(.erp-content) > .topbar,
  .app-shell:not(.erp-content) > .main-nav,
  .app-shell:not(.erp-content) > .card,
  .app-shell:not(.erp-content) > .dashboard-grid,
  .app-shell:not(.erp-content) > .flow-strip,
  .app-shell:not(.erp-content) > .alert {
    width: calc(100% - 16px);
  }

  .app-shell:not(.erp-content) > .topbar {
    top: 0;
    margin-top: 8px;
  }

  .process-control-card {
    padding: 13px;
  }

  .process-control-card > .table-toolbar {
    align-items: stretch;
  }

  .process-control-head,
  .process-card-head {
    flex-direction: column;
  }

  .process-summary-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
  }

  .process-summary-grid > :last-child:nth-child(odd) {
    grid-column: auto;
  }

  .process-rail,
  .flow-strip.kingdee-flow {
    grid-auto-columns: minmax(138px, 34%);
  }

  .kpi-primary-grid,
  .dashboard-overview .kpi-grid,
  .kpi-secondary-grid,
  .dashboard-row-currency,
  .dashboard-row-business,
  .legacy-kpi-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .metric-card,
  .kpi-card,
  .kpi-primary-grid .metric-card,
  .dashboard-overview .kpi-grid .metric-card {
    min-height: 96px;
    padding: 11px 12px;
  }

  .metric-card strong,
  .kpi-card strong,
  .kpi-card b {
    font-size: 20px;
  }

  .dashboard-alert-grid {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .dashboard-alert-card {
    min-height: auto;
  }

  .sales-chart-svg {
    min-height: 170px;
  }

  .form-card,
  .page-card,
  .inner-card,
  .dashboard-overview {
    padding: 13px;
  }

  .form-grid,
  .form-grid.single,
  .grid-2,
  .grid.two,
  .grid-3,
  .master-grid,
  .permission-grid {
    grid-template-columns: 1fr;
  }

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

  .permission-group-card > header {
    align-items: flex-start;
    flex-direction: column;
    gap: 3px;
  }

  .permission-group-card > header p {
    max-width: none;
    text-align: left;
  }

  .field.wide {
    grid-column: 1 / -1;
  }

  .inline-form,
  .inline-filter {
    display: grid;
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .inline-form input,
  .inline-form select,
  .inline-filter input,
  .inline-filter select,
  .inline-form .btn,
  .inline-filter .btn {
    width: 100%;
  }

  .order-line {
    grid-template-columns: 32px minmax(0, 1fr);
    align-items: start;
    padding: 8px 0;
    border-bottom: 1px dashed var(--line);
  }

  .order-line:last-of-type {
    border-bottom: 0;
  }

  .order-line-head {
    display: none;
  }

  .order-line > :not(b) {
    grid-column: 2;
    width: 100%;
  }

  .order-line > b {
    grid-row: 1;
    margin-top: 5px;
  }

  .order-line-actions {
    padding-left: 0;
  }

  .tier-line {
    grid-template-columns: 34px minmax(0, 1fr);
  }

  .tier-line.tier-head {
    display: none;
  }

  .tier-line > :not(b) {
    grid-column: 2;
  }

  .perm-head {
    display: none;
  }

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

  .perm-row > span {
    grid-column: 1 / -1;
  }

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

  .card > .table-search {
    width: calc(100% - 26px);
    margin: 4px 13px 9px auto;
  }

  .table-toolbar > .actions,
  .table-toolbar > .table-search,
  .table-search {
    width: 100%;
  }

  .table-scroll {
    padding: 0 9px 13px;
  }

  .data-table {
    min-width: 850px;
  }

  .data-table th,
  .data-table td {
    padding: 9px 7px;
  }

  .kd-auto-toolbar {
    align-items: stretch;
    flex-direction: column;
    padding: 10px 13px 7px;
  }

  .kd-auto-toolbar input {
    width: 100%;
  }

  .form-actions {
    align-items: stretch;
  }

  .form-actions > .btn,
  .form-actions > button {
    flex: 1 1 150px;
  }

  .mini-row,
  .product-manage-row,
  .ledger-manage-row {
    align-items: stretch;
    flex-direction: column;
  }

  .mini-row > span {
    text-align: left;
  }

  .product-manage-actions,
  .ledger-actions {
    justify-content: flex-start;
  }

  details.edit-details > summary {
    grid-template-columns: 1fr;
    align-items: start;
  }

  .master-action-pills {
    justify-content: flex-start;
  }

  .print-wrap {
    width: calc(100% - 18px);
    margin: 9px auto;
    padding: 15px;
  }

  .print-head {
    flex-direction: column;
  }

  .print-wrap .summary,
  .print-wrap .sign {
    grid-template-columns: 1fr;
  }

  .modal-backdrop,
  .dialog-backdrop,
  .dashboard-detail-backdrop,
  .dashboard-detail-overlay {
    align-items: end;
    padding: 0;
  }

  dialog,
  .modal-box,
  .dialog-panel,
  .dashboard-detail-modal,
  .dashboard-detail-overlay .dashboard-detail-panel {
    width: 100%;
    max-width: none;
    max-height: 90vh;
    max-height: 90dvh;
    margin: 0;
    border-right: 0;
    border-bottom: 0;
    border-left: 0;
    border-radius: 19px 19px 0 0;
  }

  .display-head {
    display: block;
  }

  .display-mode .app-shell {
    height: auto;
    overflow: auto;
  }

  .display-mode .workshop-table {
    height: 65vh;
  }
}

@media (max-width: 600px) {
  .finance-module-map {
    padding: 13px;
  }

  .finance-module-nav {
    gap: 8px;
  }

  .finance-module-link {
    min-height: 70px;
    padding: 10px;
  }

  .finance-module-link:last-child:nth-child(odd) {
    grid-column: 1 / -1;
  }

  .erp-topbar p,
  .topbar p {
    display: none;
  }

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

  .settings-module-grid {
    grid-template-columns: 1fr;
  }

  .process-summary-grid > :last-child:nth-child(odd) {
    grid-column: auto;
  }

  .process-rail,
  .flow-strip.kingdee-flow {
    grid-auto-columns: minmax(132px, 72%);
  }

  .dashboard-overview > .section-title {
    align-items: flex-start;
    flex-direction: column;
    gap: 3px;
  }

  .dashboard-overview > .section-title p {
    white-space: normal;
    text-align: left;
  }
}

/* Phone dashboard: keep operational data available, but remove the large
   identity pill and workflow overview requested for the compact phone layout. */
@media (max-width: 640px) {
  .erp-topbar .user-badge,
  .topbar .user-badge,
  .mobile-dashboard-flow-summary {
    display: none !important;
  }
}

@media (max-width: 480px) {
  body.login-page,
  .login-page {
    padding: 8px;
  }

  .login-shell {
    width: calc(100vw - 16px);
    border-radius: 18px;
  }

  .login-form-panel {
    padding: 27px 18px;
  }

  .login-card {
    padding: 24px 17px;
  }

  .login-form-panel > h1,
  .login-form-panel > h2,
  .login-card > h1,
  .login-card > h2 {
    font-size: 24px;
  }

  .sidebar-brand > div:not(.brand-mark) {
    display: none;
  }

  .sidebar-brand {
    gap: 0;
  }

  /* P017: phones opening the PC shell use the narrow drawer requested in the
     field reference; navigation remains centred and touch-friendly. */
  .erp-layout.has-sidebar-drawer .erp-sidebar,
  body.has-sidebar-drawer .erp-sidebar {
    width: min(192px, 78vw);
  }

  .erp-layout.has-sidebar-drawer .sidebar-brand,
  body.has-sidebar-drawer .sidebar-brand {
    justify-content: center;
    padding-right: 0;
    padding-left: 0;
  }

  .erp-layout.has-sidebar-drawer .sidebar-search,
  body.has-sidebar-drawer .sidebar-search {
    width: calc(100% - 20px);
    margin-right: auto;
    margin-left: auto;
    padding-right: 0;
    padding-left: 0;
  }

  .erp-layout.has-sidebar-drawer .sidebar-search > span,
  body.has-sidebar-drawer .sidebar-search > span {
    left: 12px;
  }

  .erp-layout.has-sidebar-drawer .sidebar-search input,
  body.has-sidebar-drawer .sidebar-search input {
    padding-right: 9px;
    padding-left: 28px;
    font-size: 12px;
  }

  .erp-layout.has-sidebar-drawer .sidebar-nav,
  body.has-sidebar-drawer .sidebar-nav {
    align-items: center;
    padding-right: 8px;
    padding-left: 8px;
  }

  .erp-layout.has-sidebar-drawer .sidebar-nav a,
  .erp-layout.has-sidebar-drawer .sidebar-nav button,
  body.has-sidebar-drawer .sidebar-nav a,
  body.has-sidebar-drawer .sidebar-nav button {
    width: min(116px, 100%);
    gap: 6px;
    padding-right: 8px;
    padding-left: 8px;
    font-size: 12px;
  }

  .erp-layout.has-sidebar-drawer .sidebar-nav .nav-icon,
  body.has-sidebar-drawer .sidebar-nav .nav-icon {
    width: 18px;
    flex-basis: 18px;
  }

  .erp-layout.has-sidebar-drawer .sidebar-footer,
  body.has-sidebar-drawer .sidebar-footer {
    padding-right: 8px;
    padding-left: 8px;
    text-align: center;
    font-size: 8.5px;
  }

  .topbar-actions,
  .erp-topbar-actions {
    grid-template-columns: minmax(0, 1fr) auto auto;
  }

  .topbar-actions > .lang-form,
  .erp-topbar-actions > .lang-form {
    grid-column: auto;
  }

  .global-po-search {
    grid-column: 1 / -1;
  }

  .user-badge,
  .logout {
    width: auto;
    min-width: 0;
    justify-content: center;
  }

  .kpi-primary-grid,
  .dashboard-overview .kpi-grid,
  .kpi-secondary-grid,
  .dashboard-row-currency,
  .dashboard-row-business,
  .legacy-kpi-grid {
    grid-template-columns: 1fr;
  }

  .metric-card,
  .kpi-card,
  .kpi-primary-grid .metric-card,
  .dashboard-overview .kpi-grid .metric-card {
    min-height: 100px;
  }

  .form-actions {
    flex-direction: column;
  }

  .form-actions > .btn,
  .form-actions > button {
    width: 100%;
    flex-basis: auto;
  }

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

@media (hover: none), (pointer: coarse) {
  .btn,
  .btn.small,
  .btn.tiny,
  .small-btn,
  .trace-link,
  .logout,
  .sidebar-nav a,
  .sidebar-nav button,
  details > summary {
    min-height: 44px;
  }

  input:not([type="hidden"]):not([type="checkbox"]):not([type="radio"]),
  select {
    min-height: 44px;
  }

  .global-po-search .btn {
    height: 36px;
    min-height: 36px;
  }
}

/* -------------------------------------------------------------------------- */
/* Print                                                                       */
/* -------------------------------------------------------------------------- */

@media print {
  :root {
    --shadow: none;
    --shadow-sm: none;
    --shadow-xs: none;
  }

  body {
    color: #111;
    background: #fff;
  }

  .erp-layout {
    display: block;
  }

  .erp-sidebar,
  .erp-topbar,
  .topbar,
  .main-nav,
  .global-po-search,
  .sidebar-toggle,
  .mobile-nav-toggle,
  .no-print,
  .logout,
  .card-enter,
  .table-search,
  .form-actions,
  .kd-auto-toolbar {
    display: none;
  }

  .erp-content,
  .track-wrap,
  .app-shell {
    width: 100%;
    max-width: none;
    margin: 0;
    padding: 0;
  }

  .card,
  .metric-card,
  .process-control-card,
  .dashboard-alert-card,
  .track-event {
    break-inside: avoid;
    box-shadow: none;
  }

  .process-control-card {
    overflow: visible;
  }

  .process-rail,
  .flow-strip.kingdee-flow {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    grid-auto-flow: row;
    grid-auto-columns: auto;
    overflow: visible;
    padding: 0;
  }

  .process-step,
  .flow-chip {
    min-width: 0;
    break-inside: avoid;
  }

  .process-step::after,
  .flow-chip::after {
    display: none;
  }

  .table-scroll {
    overflow: visible;
    padding: 0;
  }

  .data-table {
    min-width: 0;
    font-size: 9px;
  }

  .data-table th,
  .data-table td {
    padding: 6px;
  }

  .print-only {
    display: block;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto;
    transition-duration: 0.01ms;
    animation-duration: 0.01ms;
    animation-iteration-count: 1;
  }
}
