:root {
  --navy-950: #0b2342;
  --navy-900: #12335e;
  --navy-800: #173b6d;
  --navy-700: #24558d;
  --blue-600: #2b67a3;
  --blue-100: #eaf2fb;
  --blue-50: #f4f8fd;
  --ink: #172033;
  --ink-soft: #405069;
  --muted: #6f7b8e;
  --line: #dbe3ed;
  --line-soft: #edf1f5;
  --surface: #ffffff;
  --canvas: #f3f6fa;
  --success: #13845c;
  --success-bg: #def4e9;
  --warning: #956100;
  --warning-bg: #fff2d6;
  --danger: #a93434;
  --danger-bg: #fde8e8;
  --rub: #355c9a;
  --rub-bg: #edf3ff;
  --cny: #ad542d;
  --cny-bg: #fff1e9;
  --shadow-sm: 0 5px 18px rgba(22, 48, 82, 0.06);
  --shadow: 0 16px 40px rgba(22, 48, 82, 0.10);
  --radius-sm: 10px;
  --radius: 16px;
  --radius-lg: 24px;
  --sidebar-width: 236px;
  --header-height: 76px;
  color-scheme: light;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--canvas);
  scroll-behavior: smooth;
}

body {
  min-height: 100vh;
  margin: 0;
  background:
    radial-gradient(circle at 8% -10%, rgba(43, 103, 163, 0.09), transparent 28rem),
    var(--canvas);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", "PingFang SC", Arial, sans-serif;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

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

button,
select,
input[type="file"],
input[type="checkbox"] {
  cursor: pointer;
}

button:disabled,
input:disabled,
select:disabled,
textarea:disabled {
  cursor: not-allowed;
  opacity: 0.62;
}

button,
a,
input,
select,
textarea,
canvas {
  outline: none;
}

:focus-visible {
  box-shadow: 0 0 0 3px rgba(43, 103, 163, 0.24);
}

[hidden] {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

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

.eyebrow {
  margin: 0 0 5px;
  color: var(--blue-600);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.connection-banner {
  position: fixed;
  inset: 0 0 auto 0;
  z-index: 200;
  min-height: 42px;
  padding: 9px 18px;
  background: var(--danger-bg);
  color: var(--danger);
  font-size: 0.88rem;
  font-weight: 700;
  text-align: center;
  box-shadow: var(--shadow-sm);
}

.connection-banner .text-button {
  margin-left: 10px;
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: 0;
}

.brand-mark {
  position: relative;
  flex: 0 0 auto;
  width: 40px;
  height: 40px;
  border: 2px solid currentColor;
  border-radius: 50%;
}

.brand-mark::before,
.brand-mark::after {
  position: absolute;
  content: "";
  background: currentColor;
}

.brand-mark::before {
  top: 5px;
  bottom: 5px;
  left: 50%;
  width: 2px;
  transform: translateX(-50%);
}

.brand-mark::after {
  top: 50%;
  right: 7px;
  left: 7px;
  height: 2px;
  transform: translateY(-50%);
}

.brand-name,
.brand-subtitle {
  margin: 0;
  line-height: 1.15;
}

.brand-name {
  font-size: 1.05rem;
  font-weight: 900;
  letter-spacing: 0.11em;
}

.brand-subtitle {
  margin-top: 4px;
  font-size: 0.7rem;
  opacity: 0.74;
}

.button {
  display: inline-flex;
  min-height: 42px;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 9px 16px;
  font-weight: 800;
  line-height: 1.2;
  text-decoration: none;
  transition: transform 140ms ease, box-shadow 140ms ease, background 140ms ease;
}

.button:not(:disabled):hover {
  transform: translateY(-1px);
}

.button-primary {
  background: var(--navy-800);
  color: #fff;
  box-shadow: 0 8px 18px rgba(23, 59, 109, 0.18);
}

.button-primary:hover {
  background: var(--navy-900);
}

.button-secondary {
  border-color: var(--line);
  background: #f5f8fb;
  color: var(--navy-800);
}

.button-ghost {
  border-color: rgba(255, 255, 255, 0.26);
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}

.button-light {
  background: #fff;
  color: var(--navy-800);
  box-shadow: 0 10px 26px rgba(10, 33, 61, 0.16);
}

.button-danger {
  background: var(--danger-bg);
  color: var(--danger);
}

.button-large {
  min-height: 50px;
  padding: 13px 21px;
}

.text-button {
  border: 0;
  padding: 4px;
  background: transparent;
  color: var(--blue-600);
  font-weight: 800;
}

.icon-button {
  display: inline-grid;
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: #fff;
  color: var(--ink-soft);
  font-size: 1.45rem;
  line-height: 1;
}

.language-button {
  min-width: 46px;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--navy-800);
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0.08em;
}

.form-error {
  margin: 12px 0 0;
  border: 1px solid #f3caca;
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  background: var(--danger-bg);
  color: var(--danger);
  font-size: 0.88rem;
  font-weight: 700;
}

.field-error {
  margin: 10px 0 0;
  color: var(--danger);
  font-size: 0.76rem;
  font-weight: 750;
}

.currency-fieldset.invalid {
  border-color: #e7a2a2;
  box-shadow: 0 0 0 3px rgba(190, 55, 55, 0.08);
}

.currency-fieldset.invalid input {
  border-color: #d67575;
}

.privacy-note,
.section-help {
  margin: 0;
  color: var(--muted);
  font-size: 0.78rem;
}

/* Login */
.login-shell {
  display: grid;
  min-height: 100vh;
  grid-template-columns: minmax(0, 1.08fr) minmax(380px, 0.92fr);
}

.login-story {
  position: relative;
  display: flex;
  min-height: 100vh;
  flex-direction: column;
  justify-content: space-between;
  overflow: hidden;
  padding: clamp(34px, 6vw, 78px);
  background:
    linear-gradient(148deg, rgba(11, 35, 66, 0.98), rgba(36, 85, 141, 0.94)),
    var(--navy-900);
  color: #fff;
}

.login-story::before,
.login-story::after {
  position: absolute;
  content: "";
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 50%;
}

.login-story::before {
  width: 470px;
  height: 470px;
  right: -180px;
  top: -130px;
}

.login-story::after {
  width: 620px;
  height: 620px;
  right: -270px;
  top: -205px;
}

.brand-lockup-large {
  position: relative;
  z-index: 1;
}

.brand-lockup-large .brand-mark {
  width: 52px;
  height: 52px;
}

.brand-lockup-large .brand-name {
  font-size: 1.35rem;
}

.brand-lockup-large .brand-subtitle {
  font-size: 0.78rem;
}

.login-story-copy {
  position: relative;
  z-index: 1;
  max-width: 650px;
  margin: auto 0;
  padding: 70px 0;
}

.login-story-copy .eyebrow {
  color: #b8d7fa;
}

.login-story-copy h1 {
  max-width: 620px;
  margin: 0;
  font-size: clamp(2.2rem, 4.6vw, 4.7rem);
  font-weight: 850;
  letter-spacing: -0.055em;
  line-height: 1.05;
}

.login-story-copy > p:last-child {
  max-width: 520px;
  margin: 24px 0 0;
  color: rgba(255, 255, 255, 0.72);
  font-size: clamp(1rem, 1.4vw, 1.18rem);
}

.login-features {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
}

.login-features div {
  border-top: 1px solid rgba(255, 255, 255, 0.26);
  padding-top: 15px;
}

.login-features span {
  color: #a9cdf7;
  font-size: 0.7rem;
  font-weight: 900;
  letter-spacing: 0.12em;
}

.login-features p {
  margin: 7px 0 0;
  font-size: 0.86rem;
  font-weight: 700;
}

.login-panel {
  position: relative;
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 70px clamp(28px, 6vw, 90px);
  background: #fbfcfe;
}

.login-language {
  position: absolute;
  top: 28px;
  right: 32px;
}

.login-form {
  display: grid;
  width: min(100%, 430px);
  gap: 21px;
}

.login-form h2 {
  margin: 0 0 6px;
  font-size: clamp(1.8rem, 3vw, 2.4rem);
  letter-spacing: -0.04em;
}

.login-form .muted {
  margin: 0;
}

.password-field {
  position: relative;
}

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

.password-field .text-button {
  position: absolute;
  right: 11px;
  top: 50%;
  transform: translateY(-50%);
}

/* App shell */
.app-shell {
  min-height: 100vh;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 80;
  height: var(--header-height);
  background: linear-gradient(110deg, var(--navy-900), var(--blue-600));
  color: #fff;
  box-shadow: 0 8px 24px rgba(11, 35, 66, 0.14);
}

.header-inner {
  display: flex;
  width: 100%;
  height: 100%;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 0 24px;
}

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

.header-language {
  border-color: rgba(255, 255, 255, 0.28);
  background: rgba(255, 255, 255, 0.09);
  color: #fff;
}

.user-summary {
  display: flex;
  align-items: center;
  gap: 9px;
}

.user-summary > div {
  display: flex;
  min-width: 0;
  flex-direction: column;
}

.user-summary strong,
.user-summary span {
  overflow: hidden;
  max-width: 150px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-summary strong {
  font-size: 0.85rem;
}

.user-summary > div span {
  color: rgba(255, 255, 255, 0.7);
  font-size: 0.7rem;
}

.avatar {
  display: grid;
  width: 36px;
  height: 36px;
  flex: 0 0 36px;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
  font-weight: 900;
}

.menu-toggle {
  display: none;
  width: 44px;
  height: 44px;
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 11px;
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  font-size: 1.25rem;
}

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

.sidebar {
  position: sticky;
  top: var(--header-height);
  display: flex;
  height: calc(100vh - var(--header-height));
  flex-direction: column;
  justify-content: space-between;
  overflow-y: auto;
  border-right: 1px solid var(--line);
  padding: 22px 14px 18px;
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(14px);
}

.nav-list {
  display: grid;
  gap: 5px;
}

.nav-item {
  display: flex;
  width: 100%;
  min-height: 48px;
  align-items: center;
  gap: 12px;
  border: 0;
  border-radius: 12px;
  padding: 10px 13px;
  background: transparent;
  color: var(--ink-soft);
  font-size: 0.92rem;
  font-weight: 750;
  text-align: left;
  transition: background 140ms ease, color 140ms ease, transform 140ms ease;
}

.nav-item:hover {
  background: var(--blue-50);
  color: var(--navy-800);
}

.nav-item.active {
  background: var(--blue-100);
  color: var(--navy-800);
}

.nav-index {
  min-width: 25px;
  color: #91a0b4;
  font-size: 0.66rem;
  font-weight: 900;
  letter-spacing: 0.08em;
}

.nav-item.active .nav-index {
  color: var(--blue-600);
}

.sidebar-footer {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  margin: 20px 6px 0;
  border-top: 1px solid var(--line-soft);
  padding-top: 16px;
}

.sidebar-footer > div {
  display: flex;
  flex-direction: column;
}

.sidebar-footer strong {
  font-size: 0.74rem;
}

.sidebar-footer span:last-child {
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.68rem;
}

.status-dot {
  width: 8px;
  height: 8px;
  flex: 0 0 8px;
  margin-top: 5px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 0 4px var(--success-bg);
}

.workspace {
  width: 100%;
  max-width: 1540px;
  min-width: 0;
  margin: 0 auto;
  padding: clamp(22px, 3vw, 42px);
}

.page-heading {
  display: flex;
  min-height: 72px;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 22px;
}

.page-heading h1 {
  margin: 0;
  font-size: clamp(1.7rem, 2.6vw, 2.45rem);
  letter-spacing: -0.045em;
  line-height: 1.12;
}

.page-heading .muted {
  margin: 8px 0 0;
  font-size: 0.9rem;
}

.page-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 9px;
}

.page {
  display: none;
}

.page.active {
  display: block;
  animation: page-in 180ms ease;
}

@keyframes page-in {
  from { opacity: 0; transform: translateY(5px); }
  to { opacity: 1; transform: translateY(0); }
}

.card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.welcome-strip {
  position: relative;
  display: flex;
  min-height: 180px;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  overflow: hidden;
  border-radius: var(--radius-lg);
  padding: clamp(26px, 4vw, 46px);
  background: linear-gradient(118deg, var(--navy-900), var(--blue-600));
  color: #fff;
  box-shadow: 0 20px 42px rgba(25, 63, 108, 0.2);
}

.welcome-strip::after {
  position: absolute;
  width: 270px;
  height: 270px;
  right: -80px;
  bottom: -155px;
  border: 1px solid rgba(255, 255, 255, 0.17);
  border-radius: 50%;
  content: "";
}

.welcome-strip > * {
  position: relative;
  z-index: 1;
}

.welcome-strip .eyebrow {
  color: #b8d7fa;
}

.welcome-strip h2 {
  margin: 0;
  font-size: clamp(1.55rem, 3vw, 2.5rem);
  letter-spacing: -0.035em;
}

.welcome-strip p:last-child {
  margin: 8px 0 0;
  color: rgba(255, 255, 255, 0.7);
}

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

.metric-card {
  position: relative;
  min-height: 142px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 19px;
  background: #fff;
  box-shadow: var(--shadow-sm);
}

.metric-card > span {
  display: block;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 750;
}

.metric-card strong {
  display: block;
  overflow: hidden;
  margin: 11px 0 0;
  font-size: clamp(1.55rem, 2.5vw, 2.15rem);
  letter-spacing: -0.045em;
  line-height: 1.1;
  text-overflow: ellipsis;
}

.metric-card small {
  display: block;
  margin-top: 7px;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 900;
  letter-spacing: 0.1em;
}

.metric-primary {
  border-color: transparent;
  background: var(--navy-800);
  color: #fff;
}

.metric-primary > span,
.metric-primary small {
  color: rgba(255, 255, 255, 0.7);
}

.currency-rub::after,
.currency-cny::after {
  position: absolute;
  right: 17px;
  bottom: 8px;
  font-size: 4rem;
  font-weight: 900;
  line-height: 1;
  opacity: 0.05;
}

.currency-rub::after { content: "₽"; color: var(--rub); }
.currency-cny::after { content: "¥"; color: var(--cny); }

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

.dashboard-grid .card {
  min-width: 0;
  padding: 20px;
}

.dashboard-rate-alert {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin: 0 0 16px;
}

.dashboard-rate-alert[hidden] {
  display: none;
}

.dashboard-rate-alert div,
.dashboard-rate-alert span {
  min-width: 0;
}

.dashboard-rate-alert span {
  display: block;
  margin-top: 3px;
}

.card-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 10px;
}

.card-heading h2,
.form-card h2,
.section-heading h2 {
  margin: 0;
  font-size: 1.1rem;
  letter-spacing: -0.02em;
}

.stack-list {
  min-height: 150px;
}

.stack-item {
  display: flex;
  min-height: 67px;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  border-top: 1px solid var(--line-soft);
  padding: 11px 2px;
}

.stack-item:first-child {
  border-top: 0;
}

.stack-item-main {
  min-width: 0;
}

.stack-item-main strong,
.stack-item-main span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stack-item-main strong {
  font-size: 0.86rem;
}

.stack-item-main span,
.stack-meta {
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.74rem;
}

.money-pair {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 5px;
  font-size: 0.72rem;
  font-weight: 850;
}

.money-pair span {
  border-radius: 999px;
  padding: 5px 8px;
}

.money-pair .rub { background: var(--rub-bg); color: var(--rub); }
.money-pair .cny { background: var(--cny-bg); color: var(--cny); }
.warning-text { color: var(--warning) !important; }

/* Forms */
.field {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 7px;
}

.field label,
.label-row label {
  color: var(--ink-soft);
  font-size: 0.78rem;
  font-weight: 800;
}

.field small {
  color: var(--muted);
  font-size: 0.73rem;
}

.field input,
.field select,
.field textarea,
.search-field input,
.compact-field input,
.compact-field select {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  background: #fff;
  transition: border-color 140ms ease, box-shadow 140ms ease;
}

.field textarea {
  min-height: 90px;
  resize: vertical;
}

.field input:hover,
.field select:hover,
.field textarea:hover,
.search-field input:hover {
  border-color: #b5c3d5;
}

.field input:focus,
.field select:focus,
.field textarea:focus,
.search-field input:focus {
  border-color: var(--blue-600);
  box-shadow: 0 0 0 3px rgba(43, 103, 163, 0.13);
}

.field input[type="file"] {
  padding: 7px;
  background: var(--blue-50);
}

.field input[type="file"]::file-selector-button {
  min-height: 34px;
  margin-right: 10px;
  border: 0;
  border-radius: 8px;
  padding: 7px 12px;
  background: var(--navy-800);
  color: #fff;
  font-weight: 800;
}

.input-with-action {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.input-with-action .button {
  min-height: 44px;
  white-space: nowrap;
}

.form-grid {
  display: grid;
  gap: 15px;
}

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

.full-width {
  grid-column: 1 / -1;
}

.filter-bar {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(150px, 210px) minmax(150px, 210px);
  gap: 12px;
  margin-bottom: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 13px;
  background: rgba(255, 255, 255, 0.75);
}

.filter-bar .field {
  gap: 4px;
}

.compact-field label {
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 800;
}

.search-field {
  display: flex;
  align-items: flex-end;
}

.history-filters {
  grid-template-columns: minmax(240px, 1fr) minmax(160px, 210px) minmax(160px, 210px);
}

.customer-filters {
  grid-template-columns: minmax(260px, 1fr) minmax(160px, 210px) minmax(160px, 210px);
}

.import-guide {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 15px;
  background: var(--blue-50);
}

.import-guide strong {
  font-size: 0.88rem;
}

.import-guide p {
  max-width: 650px;
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 0.76rem;
  line-height: 1.55;
}

.import-guide .button {
  flex: 0 0 auto;
}

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

.import-summary > div {
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-sm);
  padding: 14px;
  background: #f8fafc;
}

.import-summary span,
.import-summary strong {
  display: block;
}

.import-summary span {
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 800;
}

.import-summary strong {
  margin-top: 5px;
  font-size: 1.45rem;
  letter-spacing: -0.035em;
}

.import-summary .success {
  border-color: #b9dfcc;
  background: var(--success-bg);
  color: var(--success);
}

.import-summary .danger {
  border-color: #efc0c0;
  background: var(--danger-bg);
  color: var(--danger);
}

.import-error-list {
  margin-top: 20px;
}

.import-error-list h3 {
  margin: 0 0 10px;
  font-size: 0.92rem;
}

.import-error-table {
  max-height: 330px;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-sm);
}

.import-error-table th {
  position: sticky;
  z-index: 1;
  top: 0;
}

.import-success-state {
  margin-top: 16px;
  border: 1px solid #b9dfcc;
  background: var(--success-bg);
  color: var(--success);
}

.money-input {
  position: relative;
}

.money-input input {
  padding-right: 57px;
}

.money-input span {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 900;
  letter-spacing: 0.06em;
}

.check-row {
  display: flex;
  align-items: flex-start;
  gap: 11px;
  margin-top: 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
  background: var(--blue-50);
}

.check-row input {
  width: 19px;
  height: 19px;
  flex: 0 0 19px;
  margin: 2px 0 0;
  accent-color: var(--navy-800);
}

.check-row span {
  display: flex;
  flex-direction: column;
}

.check-row strong {
  font-size: 0.83rem;
}

.check-row small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.72rem;
}

.inset-fields {
  margin-top: 10px;
  border-left: 3px solid var(--blue-600);
  padding: 13px;
  background: #f8fafc;
}

.customer-search-area {
  max-width: 620px;
}

.customer-code-search {
  position: relative;
}

.customer-code-search > input {
  border-color: #9fb1c7;
  padding: 14px 15px;
  background: linear-gradient(180deg, #fff, #fbfdff);
  font-size: 1rem;
  font-weight: 800;
  letter-spacing: 0.04em;
}

.customer-code-search > input:focus {
  border-color: var(--blue-600);
  box-shadow: 0 0 0 4px rgba(40, 103, 177, 0.12);
}

.customer-search-results {
  position: absolute;
  z-index: 20;
  top: calc(100% - 23px);
  right: 0;
  left: 0;
  max-height: 300px;
  overflow-y: auto;
  border: 1px solid #aab9ca;
  border-radius: 13px;
  padding: 6px;
  background: #fff;
  box-shadow: 0 18px 44px rgba(24, 47, 78, 0.18);
}

.customer-search-option {
  display: flex;
  width: 100%;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  border: 0;
  border-radius: 9px;
  padding: 11px 12px;
  background: transparent;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
}

.customer-search-option:hover,
.customer-search-option:focus-visible {
  outline: 0;
  background: var(--blue-50);
}

.customer-search-option > span {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 2px;
}

.customer-search-option strong {
  color: var(--navy-800);
  font-size: 0.86rem;
  letter-spacing: 0.04em;
}

.customer-search-option span span,
.customer-search-option small {
  overflow: hidden;
  color: var(--muted);
  font-size: 0.75rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.field-status {
  min-height: 18px;
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 0.73rem;
}

.selected-customer-card {
  margin-top: 18px;
  border: 1px solid #b9cce1;
  border-radius: 15px;
  padding: 16px;
  background: linear-gradient(135deg, #f4f8fd, #fff);
}

.selected-customer-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.selected-customer-heading > div {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 3px;
}

.selected-customer-heading strong {
  overflow-wrap: anywhere;
  font-size: 1rem;
}

.customer-code {
  color: var(--blue-700);
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 0.08em;
}

.customer-facts {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin: 14px 0 0;
}

.customer-facts div {
  border-top: 1px solid rgba(112, 139, 169, 0.2);
  padding-top: 9px;
}

.customer-facts dt {
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 800;
}

.customer-facts dd {
  margin: 3px 0 0;
  overflow-wrap: anywhere;
  font-size: 0.8rem;
  font-weight: 750;
}

.pending-cargo-section {
  margin-top: 24px;
  border-top: 1px solid var(--line);
  padding-top: 22px;
}

.pending-cargo-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 13px;
}

.pending-cargo-heading h3 {
  margin: 0;
  font-size: 0.95rem;
}

.pending-cargo-heading p {
  max-width: 660px;
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.75rem;
}

.selection-actions {
  display: flex;
  flex: 0 0 auto;
  gap: 12px;
}

.text-button:disabled {
  opacity: 0.42;
  cursor: not-allowed;
}

.inline-loading,
.compact-empty {
  border: 1px dashed #b8c5d4;
  border-radius: 13px;
  padding: 20px;
  background: #fafcff;
  color: var(--muted);
  font-size: 0.78rem;
  text-align: center;
}

.compact-empty {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.compact-empty strong {
  color: var(--ink-soft);
}

.compact-empty.error-state {
  border-style: solid;
  border-color: #e2b2b2;
  background: #fff8f8;
}

.compact-empty.error-state .button {
  align-self: center;
  margin-top: 7px;
}

.pending-cargo-list {
  display: grid;
  gap: 11px;
}

.pending-cargo-card {
  border: 1px solid var(--line);
  border-radius: 15px;
  padding: 15px;
  background: #fff;
  transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.pending-cargo-card.selected {
  border-color: #7fa5d1;
  background: linear-gradient(145deg, #f8fbff, #fff);
  box-shadow: 0 7px 20px rgba(37, 82, 133, 0.09);
}

.pending-cargo-card.invalid {
  border-color: #d77575;
}

.pending-cargo-card-header,
.pending-cargo-choice,
.pickup-order-line,
.pickup-controls {
  display: flex;
  align-items: center;
}

.pending-cargo-card-header {
  justify-content: space-between;
  gap: 14px;
}

.pending-cargo-choice {
  min-width: 0;
  gap: 11px;
  cursor: pointer;
}

.pending-cargo-choice input,
.pickup-partial-toggle input {
  width: 19px;
  height: 19px;
  flex: 0 0 19px;
  accent-color: var(--navy-800);
}

.pending-cargo-choice > span {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 2px;
}

.pending-cargo-choice strong {
  overflow-wrap: anywhere;
  color: var(--navy-800);
  font-size: 0.88rem;
}

.pending-cargo-choice small {
  color: var(--muted);
  font-size: 0.72rem;
}

.pickup-order-line {
  justify-content: space-between;
  gap: 14px;
  margin-top: 11px;
  border-top: 1px solid var(--line-soft);
  padding-top: 10px;
}

.pickup-order-line span {
  color: var(--muted);
  font-size: 0.7rem;
}

.pickup-order-line strong {
  overflow-wrap: anywhere;
  font-size: 0.78rem;
  text-align: right;
}

.pickup-amounts {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 9px;
  margin-top: 10px;
}

.pickup-amount {
  display: grid;
  gap: 2px;
  border: 1px solid var(--line-soft);
  border-radius: 11px;
  padding: 10px 11px;
}

.pickup-amount-rub { background: var(--rub-bg); }
.pickup-amount-cny { background: var(--cny-bg); }

.pickup-amount > span,
.pickup-amount small {
  color: var(--muted);
  font-size: 0.66rem;
}

.pickup-amount strong {
  font-size: 0.8rem;
}

.pickup-controls {
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 11px;
  border-top: 1px solid var(--line-soft);
  padding-top: 11px;
}

.pickup-partial-toggle,
.pickup-quantity-field {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--ink-soft);
  font-size: 0.74rem;
  font-weight: 750;
}

.pickup-quantity-field input {
  width: 84px;
  padding: 8px 9px;
}

.pickup-remaining-after {
  min-width: 98px;
  color: var(--muted);
  font-size: 0.7rem;
  text-align: right;
}

.handoff-layout {
  display: grid;
  align-items: start;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 17px;
}

.form-main {
  display: grid;
  min-width: 0;
  gap: 15px;
}

.form-card {
  padding: clamp(18px, 2.4vw, 27px);
}

.section-heading {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 19px;
}

.section-heading > span {
  display: grid;
  width: 30px;
  height: 30px;
  flex: 0 0 30px;
  place-items: center;
  border-radius: 9px;
  background: var(--blue-100);
  color: var(--navy-800);
  font-size: 0.67rem;
  font-weight: 900;
}

.section-heading p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 0.78rem;
}

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

.currency-fieldset {
  min-width: 0;
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px;
}

.currency-fieldset legend {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 0 7px;
  color: var(--ink-soft);
  font-size: 0.8rem;
}

.currency-fieldset legend > span {
  display: grid;
  width: 25px;
  height: 25px;
  place-items: center;
  border-radius: 50%;
  font-weight: 900;
}

.currency-rub-panel { background: linear-gradient(150deg, #fff, var(--rub-bg)); }
.currency-rub-panel legend > span { background: var(--rub-bg); color: var(--rub); }
.currency-cny-panel { background: linear-gradient(150deg, #fff, var(--cny-bg)); }
.currency-cny-panel legend > span { background: var(--cny-bg); color: var(--cny); }

.file-field,
.signature-field {
  margin-top: 17px;
}

.image-preview {
  position: relative;
  width: min(100%, 260px);
  margin-top: 7px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #f7f9fc;
}

.image-preview img {
  display: block;
  width: 100%;
  max-height: 190px;
  object-fit: cover;
}

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

.signature-wrap {
  position: relative;
  overflow: hidden;
  border: 1px dashed #91a4bb;
  border-radius: 13px;
  background: #fff;
}

.signature-wrap canvas {
  display: block;
  width: 100%;
  height: 190px;
  cursor: crosshair;
  touch-action: none;
}

.signature-wrap > span {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: #a2adbb;
  font-size: 0.85rem;
  pointer-events: none;
}

.signature-wrap.signed > span {
  display: none;
}

.submit-panel {
  position: sticky;
  top: calc(var(--header-height) + 20px);
  display: flex;
  min-height: 370px;
  flex-direction: column;
  justify-content: space-between;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 21px;
  background: #fff;
  box-shadow: var(--shadow-sm);
}

.submit-panel h2 {
  margin: 0;
  font-size: 1.16rem;
}

.summary-list {
  margin: 17px 0;
}

.summary-list div {
  display: flex;
  justify-content: space-between;
  gap: 13px;
  border-top: 1px solid var(--line-soft);
  padding: 10px 0;
}

.summary-list dt {
  color: var(--muted);
  font-size: 0.76rem;
}

.summary-list dd {
  margin: 0;
  max-width: 150px;
  font-size: 0.78rem;
  font-weight: 850;
  text-align: right;
  overflow-wrap: anywhere;
}

.summary-selection-list {
  display: grid;
  gap: 6px;
  margin: -5px 0 18px;
}

.summary-selection-list div {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 9px;
  border-radius: 9px;
  padding: 8px 9px;
  background: #f7f9fc;
}

.summary-selection-list strong {
  min-width: 0;
  overflow-wrap: anywhere;
  color: var(--ink-soft);
  font-size: 0.68rem;
  line-height: 1.35;
}

.summary-selection-list span {
  flex: 0 0 auto;
  color: var(--blue-700);
  font-size: 0.68rem;
  font-weight: 850;
}

.submit-panel .button {
  width: 100%;
}

.submission-status {
  display: grid;
  gap: 8px;
  margin: 12px 0;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 11px 12px;
  background: #f7faff;
  color: var(--ink-soft);
}

.submission-status-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 0.76rem;
}

.submission-status-row strong {
  min-width: 0;
  overflow-wrap: anywhere;
}

.submission-status-row span {
  flex: 0 0 auto;
}

.submission-status progress {
  width: 100%;
  height: 8px;
  accent-color: var(--blue-700);
}

.submission-status small {
  color: var(--muted);
  font-size: 0.7rem;
  line-height: 1.45;
}

.submission-status.uncertain {
  border-color: #e8cf92;
  background: #fff9e9;
}

#handoffForm.submission-locked .signature-wrap {
  pointer-events: none;
  opacity: 0.78;
}

.submit-panel .privacy-note {
  margin-top: 9px;
  text-align: center;
}

/* Tables and lists */
.table-card {
  overflow: hidden;
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
}

.table-pagination {
  display: flex;
  justify-content: center;
  border-top: 1px solid var(--line-soft);
  padding: 14px 18px;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  border-bottom: 1px solid var(--line-soft);
  padding: 13px 15px;
  font-size: 0.78rem;
  text-align: left;
  vertical-align: middle;
}

th {
  background: #f8fafc;
  color: var(--muted);
  font-size: 0.69rem;
  font-weight: 850;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

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

tbody tr:hover {
  background: #fbfcfe;
}

.cell-title {
  font-weight: 850;
}

.cell-subtitle {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.69rem;
}

.badge {
  display: inline-flex;
  min-height: 25px;
  align-items: center;
  border-radius: 999px;
  padding: 4px 9px;
  font-size: 0.68rem;
  font-weight: 850;
  white-space: nowrap;
}

.badge-success { background: var(--success-bg); color: var(--success); }
.badge-warning { background: var(--warning-bg); color: var(--warning); }
.badge-danger { background: var(--danger-bg); color: var(--danger); }
.badge-neutral { background: #edf1f5; color: var(--ink-soft); }
.badge-blue { background: var(--blue-100); color: var(--navy-800); }

.record-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 9px;
}

.customer-actions-cell {
  min-width: 150px;
  white-space: nowrap;
}

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

.mobile-card-list {
  display: none;
}

.mobile-record-card {
  border-bottom: 1px solid var(--line-soft);
  padding: 15px;
}

.mobile-record-card:last-child {
  border-bottom: 0;
}

.mobile-record-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.mobile-record-card h3 {
  margin: 0;
  font-size: 0.9rem;
}

.mobile-record-card p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.75rem;
}

.mobile-record-meta {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 9px;
  margin-top: 13px;
}

.mobile-record-meta div {
  border-radius: 9px;
  padding: 8px 9px;
  background: #f7f9fc;
}

.mobile-record-meta span,
.mobile-record-meta strong {
  display: block;
}

.mobile-record-meta span {
  color: var(--muted);
  font-size: 0.64rem;
}

.mobile-record-meta strong {
  margin-top: 2px;
  font-size: 0.74rem;
}

.mobile-record-card .button {
  width: 100%;
  margin-top: 12px;
}

.mobile-record-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-top: 12px;
}

.mobile-record-card .mobile-record-actions .button {
  width: auto;
  margin-top: 0;
}

.import-error-card .mobile-record-meta {
  grid-template-columns: minmax(120px, 0.35fr) minmax(0, 1fr);
}

.import-error-card .mobile-record-meta strong {
  overflow-wrap: anywhere;
}

.empty-state {
  min-height: 220px;
  place-content: center;
  padding: 35px 18px;
  color: var(--muted);
  text-align: center;
}

.empty-state::before {
  display: grid;
  width: 48px;
  height: 48px;
  place-items: center;
  margin: 0 auto 12px;
  border-radius: 50%;
  background: var(--blue-100);
  color: var(--navy-800);
  content: "—";
  font-weight: 900;
}

.empty-state h3 {
  margin: 0 0 5px;
  color: var(--ink);
  font-size: 0.98rem;
}

.empty-state p {
  margin: 0;
  font-size: 0.8rem;
}

.loading-row td {
  height: 62px;
}

.skeleton {
  display: block;
  height: 11px;
  overflow: hidden;
  border-radius: 999px;
  background: linear-gradient(90deg, #edf1f5, #f7f9fc, #edf1f5);
  background-size: 200% 100%;
  animation: shimmer 1.2s infinite;
}

@keyframes shimmer {
  to { background-position: -200% 0; }
}

/* Dialogs */
.modal {
  width: min(720px, calc(100vw - 28px));
  max-height: calc(100vh - 28px);
  margin: auto;
  overflow: hidden;
  border: 0;
  border-radius: var(--radius-lg);
  padding: 0;
  background: #fff;
  color: var(--ink);
  box-shadow: 0 28px 80px rgba(8, 27, 52, 0.28);
}

.modal-wide {
  width: min(1040px, calc(100vw - 28px));
}

.modal::backdrop {
  background: rgba(11, 28, 50, 0.62);
  backdrop-filter: blur(4px);
}

.modal-card {
  display: flex;
  max-height: calc(100vh - 28px);
  flex-direction: column;
  margin: 0;
}

.modal-header,
.modal-footer {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: space-between;
  gap: 15px;
  padding: 18px 22px;
  background: #fff;
}

.modal-header {
  border-bottom: 1px solid var(--line-soft);
}

.modal-header h2 {
  margin: 0;
  font-size: 1.3rem;
  letter-spacing: -0.025em;
}

.modal-body {
  overflow-y: auto;
  padding: 22px;
}

.modal-footer {
  justify-content: flex-end;
  border-top: 1px solid var(--line-soft);
}

.section-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 24px 0 6px;
  color: var(--ink-soft);
  font-size: 0.78rem;
  font-weight: 900;
}

.section-divider::after {
  height: 1px;
  flex: 1;
  background: var(--line-soft);
  content: "";
}

.rule-panel {
  margin-top: 16px;
  border: 1px solid #cad9ea;
  border-radius: 12px;
  padding: 13px 14px;
  background: var(--blue-50);
  color: var(--navy-800);
  font-size: 0.8rem;
}

.rule-panel.warning {
  border-color: #ecd29b;
  background: var(--warning-bg);
  color: var(--warning);
}

.rule-panel strong {
  display: block;
  margin-bottom: 3px;
}

.rule-panel ul {
  margin: 6px 0 0;
  padding-left: 20px;
}

.detail-body {
  display: grid;
  gap: 17px;
}

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

.detail-fact {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
  background: #f9fbfd;
}

.detail-fact span,
.detail-fact strong {
  display: block;
}

.detail-fact span {
  color: var(--muted);
  font-size: 0.67rem;
}

.detail-fact strong {
  margin-top: 4px;
  font-size: 0.82rem;
}

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

.financial-card {
  border: 1px solid var(--line);
  border-radius: 15px;
  padding: 16px;
}

.financial-card.rub { background: var(--rub-bg); }
.financial-card.cny { background: var(--cny-bg); }

.financial-card h3 {
  margin: 0 0 12px;
  font-size: 0.9rem;
}

.financial-card dl {
  margin: 0;
}

.financial-card dl div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  border-top: 1px solid rgba(70, 90, 120, 0.12);
  padding: 9px 0;
}

.financial-card dl div:first-child {
  border-top: 0;
}

.financial-card dt {
  color: var(--muted);
  font-size: 0.74rem;
}

.financial-card dd {
  margin: 0;
  font-size: 0.82rem;
  font-weight: 900;
}

.detail-section {
  border-top: 1px solid var(--line-soft);
  padding-top: 16px;
}

.detail-section h3 {
  margin: 0 0 10px;
  font-size: 0.95rem;
}

.detail-note {
  border-radius: 11px;
  padding: 12px;
  background: #f7f9fc;
  color: var(--ink-soft);
  font-size: 0.8rem;
  white-space: pre-wrap;
}

.detail-note.warning {
  border: 1px solid #efd59e;
  background: var(--warning-bg);
  color: var(--warning);
  font-weight: 700;
}

.toast {
  position: fixed;
  z-index: 300;
  right: 20px;
  bottom: 20px;
  max-width: min(390px, calc(100vw - 28px));
  border-radius: 12px;
  padding: 12px 15px;
  background: var(--navy-950);
  color: #fff;
  box-shadow: var(--shadow);
  font-size: 0.84rem;
  font-weight: 750;
}

.toast.error {
  background: var(--danger);
}

.toast.success {
  background: var(--success);
}

body.role-worker .manager-only,
body.role-read-only .manager-only,
body:not(.role-admin) .admin-only {
  display: none !important;
}

body.role-read-only .write-only,
body.role-read-only [data-go="handoff"],
body.role-read-only .nav-item[data-view="handoff"] {
  display: none !important;
}

/* Suifenhe shipment workflow */
.shipment-filters {
  grid-template-columns: minmax(260px, 1fr) minmax(170px, 230px);
}

.modal-extra-wide {
  width: min(1380px, calc(100vw - 28px));
}

.shipment-detail-body {
  display: grid;
  gap: 17px;
  background: #f7f9fc;
}

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

.shipment-summary-item {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
  background: #fff;
}

.shipment-summary-item span,
.shipment-summary-item strong {
  display: block;
}

.shipment-summary-item span {
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 800;
}

.shipment-summary-item strong {
  overflow: hidden;
  margin-top: 4px;
  font-size: 0.9rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.shipment-summary-item.summary-success { border-color: #b9dfcc; background: var(--success-bg); color: var(--success); }
.shipment-summary-item.summary-warning { border-color: #ecd29b; background: var(--warning-bg); color: var(--warning); }
.shipment-summary-item.summary-danger { border-color: #efc0c0; background: var(--danger-bg); color: var(--danger); }
.shipment-summary-item.summary-blue { border-color: #bdd0e7; background: var(--blue-50); color: var(--navy-800); }

.exchange-rate-layout {
  align-items: start;
}

.exchange-rate-help {
  margin: -4px 0 14px;
}

.exchange-rate-equation,
.rate-fixed-input {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 9px;
}

.rate-fixed-input {
  grid-template-columns: minmax(0, 1fr) auto;
}

.exchange-rate-equation strong,
.rate-fixed-input strong,
.rate-fixed-currency {
  color: var(--navy-800);
  font-size: .79rem;
  white-space: nowrap;
}

.exchange-rate-form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 13px;
}

.exchange-rate-history .card-heading {
  margin-bottom: 13px;
}

.exchange-rate-history .card-heading p {
  margin: 4px 0 0;
}

.customer-rate-reference {
  margin-top: 20px;
}

.customer-rate-reference-list {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.customer-rate-reference-card {
  display: grid;
  grid-template-columns: minmax(170px, .8fr) minmax(0, 1.4fr);
  gap: 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 13px;
  background: #fff;
}

.customer-rate-reference-heading {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 3px;
}

.customer-rate-reference-heading strong {
  font-size: .8rem;
}

.customer-rate-reference-heading span {
  color: var(--muted);
  font-size: .7rem;
}

.customer-rate-reference-facts {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px 14px;
  margin: 0;
}

.customer-rate-reference-facts div {
  min-width: 0;
}

.customer-rate-reference-facts dt {
  color: var(--muted);
  font-size: .66rem;
}

.customer-rate-reference-facts dd {
  margin: 2px 0 0;
  font-size: .74rem;
  font-weight: 800;
  overflow-wrap: anywhere;
}

.detail-section {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  background: #fff;
}

.detail-section-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 15px;
  margin-bottom: 14px;
}

.detail-section-heading h3,
.catalog-panel h3,
.rate-layout h3 {
  margin: 0;
  font-size: 0.98rem;
}

.detail-section-heading p {
  margin-top: 4px;
}

.shipment-upload-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 12px;
}

.shipment-preview-heading .compact-field {
  width: min(360px, 42vw);
}

.shipment-preview-summary {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin: 0 0 13px;
}

.shipment-preview-notice {
  margin-bottom: 12px;
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 0.76rem;
  font-weight: 750;
}

.shipment-preview-notice.warning { background: var(--warning-bg); color: var(--warning); }
.shipment-preview-notice.success { background: var(--success-bg); color: var(--success); }

.shipment-preview-table {
  max-height: min(58vh, 620px);
  border: 1px solid var(--line-soft);
  border-radius: 12px;
}

.shipment-preview-table table {
  min-width: 1260px;
}

.shipment-preview-table th {
  position: sticky;
  z-index: 2;
  top: 0;
}

.shipment-row-action-cell {
  min-width: 360px;
}

.shipment-row-reasons {
  display: grid;
  gap: 5px;
}

.shipment-row-reasons > p {
  margin: 0;
  color: var(--danger);
  font-size: 0.69rem;
  line-height: 1.45;
}

.shipment-row-editor {
  display: grid;
  grid-template-columns: minmax(180px, 1.3fr) minmax(100px, .6fr) minmax(170px, 1fr) auto;
  align-items: start;
  gap: 6px;
  margin-top: 6px;
  border-top: 1px solid var(--line-soft);
  padding-top: 8px;
}

.shipment-row-editor input,
.shipment-row-editor select,
.catalog-record input,
.inline-create-form input,
.inline-create-form select,
.shipment-rate-override input,
.shipment-rate-override select {
  width: 100%;
  min-height: 37px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px 9px;
  background: #fff;
  font-size: 0.73rem;
}

.shipment-row-editor .field-error {
  grid-column: 1 / -1;
  margin: 0;
}

.shipment-customer-search {
  position: relative;
  min-width: 0;
}

.shipment-customer-results {
  position: absolute;
  z-index: 20;
  top: calc(100% + 4px);
  right: 0;
  left: 0;
  max-height: 220px;
  overflow-y: auto;
  border: 1px solid #aab9ca;
  border-radius: 9px;
  padding: 4px;
  background: #fff;
  box-shadow: var(--shadow);
}

.shipment-customer-option {
  display: flex;
  width: 100%;
  flex-direction: column;
  gap: 1px;
  border: 0;
  border-radius: 7px;
  padding: 7px 8px;
  background: transparent;
  text-align: left;
}

.shipment-customer-option:hover { background: var(--blue-50); }
.shipment-customer-option strong { font-size: .72rem; }
.shipment-customer-option span,
.shipment-search-message { color: var(--muted); font-size: .68rem; }
.shipment-search-message { display: block; padding: 7px; }

.shipment-confirm-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 15px;
  margin-top: 14px;
}

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

.arrival-confirmation-grid > .button {
  justify-self: start;
}

.shipment-arrival-record {
  border-color: #b9dfcc;
  background: linear-gradient(135deg, #fff, var(--success-bg));
}

.arrival-difference {
  margin-top: 12px;
  border-top: 1px solid var(--line-soft);
  padding-top: 11px;
}

.arrival-difference strong {
  font-size: .72rem;
}

.arrival-difference p {
  margin: 4px 0 0;
  color: var(--muted);
  white-space: pre-wrap;
}

.shipment-item-toolbar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.shipment-item-toolbar input {
  width: min(270px, 34vw);
  min-height: 39px;
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 8px 10px;
  background: #fff;
}

.compact-data-table {
  max-height: 360px;
  border: 1px solid var(--line-soft);
  border-radius: 10px;
}

.receivable-chip-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 9px;
  margin-top: 12px;
}

.receivable-chip {
  display: grid;
  gap: 3px;
  border: 1px solid #b9dfcc;
  border-radius: 11px;
  padding: 11px;
  background: var(--success-bg);
}

.receivable-chip.pending {
  border-color: #ecd29b;
  background: var(--warning-bg);
}

.receivable-chip strong { font-size: .78rem; }
.receivable-chip > span { color: var(--muted); font-size: .69rem; }

.pricing-snapshot-table {
  margin-top: 12px;
  max-height: 480px;
}

.pricing-snapshot-table table {
  min-width: 1320px;
}

.pricing-status-cell {
  min-width: 230px;
}

.pricing-status-cell > * {
  display: block;
  width: fit-content;
}

.pricing-model-label,
.pricing-status-detail {
  margin-top: 5px;
  color: var(--muted);
  font-size: .67rem;
  line-height: 1.45;
}

.pricing-status-cell .text-button {
  margin-top: 6px;
}

.pricing-override-row td {
  padding-top: 8px;
  background: #fbfcfe;
}

.pricing-override-title {
  display: block;
  margin-bottom: 7px;
  font-size: .72rem;
}

.legacy-override-list {
  display: grid;
  gap: 9px;
  margin: 12px 0;
}

.legacy-override-review {
  margin: 0;
}

.legacy-override-void-form {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto;
  align-items: start;
  gap: 8px;
  margin-top: 10px;
}

.legacy-override-void-form input {
  width: 100%;
  min-height: 39px;
  border: 1px solid #d0aa62;
  border-radius: 9px;
  padding: 8px 10px;
  background: #fff;
}

.legacy-override-void-form .field-error {
  grid-column: 1 / -1;
  margin: 0;
}

.shipment-rate-override {
  display: grid;
  grid-template-columns: .6fr .55fr .6fr minmax(140px, 1fr) auto;
  gap: 6px;
  margin-top: 8px;
}

.shipment-rate-override .rate-fixed-currency {
  display: flex;
  min-height: 37px;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--cny-bg);
  color: var(--cny);
}

.shipment-rate-override .field-error { grid-column: 1 / -1; margin: 0; }

.catalog-layout,
.rate-layout {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  background: #f7f9fc;
}

.catalog-panel,
.rate-history,
.inset-form {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  background: #fff;
}

.inline-create-form {
  display: grid;
  grid-template-columns: minmax(100px, .7fr) minmax(130px, 1fr) auto;
  gap: 7px;
  margin: 12px 0;
}

#channelCreateForm {
  grid-template-columns: minmax(130px, 1fr) minmax(100px, .65fr) minmax(130px, 1fr) auto;
}

.catalog-list {
  display: grid;
  gap: 7px;
  max-height: 480px;
  overflow-y: auto;
}

.catalog-record {
  display: grid;
  grid-template-columns: minmax(135px, .9fr) minmax(150px, 1fr) auto auto auto;
  align-items: center;
  gap: 7px;
  border-top: 1px solid var(--line-soft);
  padding-top: 8px;
}

.catalog-identity {
  display: flex;
  min-width: 0;
  flex-direction: column;
}

.catalog-identity strong { font-size: .76rem; }
.catalog-identity small { color: var(--muted); font-size: .62rem; }

.inset-form {
  align-self: start;
}

.inset-form > h3,
.rate-history > h3 {
  margin-bottom: 13px;
}

.inset-form > .button {
  margin-top: 13px;
}

.rate-history .table-wrap {
  max-height: 560px;
  border: 1px solid var(--line-soft);
  border-radius: 10px;
}

.handoff-history {
  margin-top: 22px;
}

.history-timeline {
  display: grid;
  gap: 10px;
}

.handoff-scope-correction {
  min-width: 0;
  margin: 2px 0;
  border: 1px solid #c8d7e7;
  border-radius: 12px;
  padding: 14px;
  background: var(--blue-50);
}

.handoff-scope-correction legend {
  padding: 0 6px;
  color: var(--navy-800);
  font-size: .8rem;
  font-weight: 850;
}

.handoff-scope-correction > .section-help {
  margin: 0 0 11px;
}

.handoff-scope-correction:disabled {
  opacity: .78;
}

.handoff-scope-customer {
  position: relative;
}

.handoff-scope-customer .customer-search-results {
  top: calc(100% - 18px);
}

.history-event {
  border-left: 3px solid var(--blue-600);
  border-radius: 0 10px 10px 0;
  padding: 11px 13px;
  background: var(--blue-50);
}

.history-event-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: .76rem;
}

.history-event-header time { color: var(--muted); }
.history-event-reason { margin: 5px 0; font-size: .74rem; }
.history-event details { font-size: .7rem; }
.history-comparison { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px; margin-top: 7px; }
.history-comparison pre { max-height: 230px; overflow: auto; margin: 0; border: 1px solid var(--line); border-radius: 8px; padding: 8px; background: #fff; white-space: pre-wrap; overflow-wrap: anywhere; }

@media (max-width: 1120px) {
  .metric-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .handoff-layout {
    grid-template-columns: minmax(0, 1fr);
  }

  .submit-panel {
    position: static;
    min-height: auto;
  }

  .submit-panel > div:first-child {
    width: 100%;
  }

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

  .summary-list div {
    display: block;
    border: 0;
    border-radius: 10px;
    padding: 9px;
    background: #f7f9fc;
  }

  .summary-list dd {
    max-width: none;
    margin-top: 3px;
    text-align: left;
  }

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

  .catalog-layout,
  .rate-layout {
    grid-template-columns: 1fr;
  }

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

@media (max-width: 900px) {
  :root {
    --sidebar-width: 215px;
  }

  .login-shell {
    grid-template-columns: minmax(0, 0.82fr) minmax(360px, 1fr);
  }

  .login-story {
    padding: 36px;
  }

  .login-features {
    grid-template-columns: 1fr;
    gap: 9px;
  }

  .login-features div {
    display: flex;
    align-items: center;
    gap: 8px;
    padding-top: 8px;
  }

  .login-features p {
    margin: 0;
  }

  .dashboard-grid,
  .currency-sections {
    grid-template-columns: 1fr;
  }

  .filter-bar,
  .history-filters {
    grid-template-columns: minmax(0, 1fr) repeat(2, minmax(130px, 180px));
  }

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

@media (max-width: 760px) {
  :root {
    --header-height: 68px;
  }

  .login-shell {
    display: block;
  }

  .login-story {
    min-height: 300px;
    padding: 28px;
  }

  .login-story-copy {
    margin: 42px 0 0;
    padding: 0;
  }

  .login-story-copy h1 {
    max-width: 520px;
    font-size: clamp(2rem, 9vw, 3.25rem);
  }

  .login-story-copy > p:last-child,
  .login-features {
    display: none;
  }

  .login-panel {
    min-height: calc(100vh - 300px);
    padding: 58px 24px 34px;
  }

  .login-language {
    top: 15px;
    right: 21px;
  }

  .menu-toggle {
    display: inline-grid;
    place-items: center;
  }

  .header-inner {
    padding: 0 13px;
  }

  .header-inner > .brand-lockup {
    margin-right: auto;
  }

  .header-inner > .brand-lockup .brand-mark {
    width: 34px;
    height: 34px;
  }

  .header-inner > .brand-lockup .brand-subtitle {
    display: none;
  }

  .user-summary,
  .header-language {
    display: none;
  }

  .button-ghost {
    min-height: 40px;
    padding: 8px 11px;
  }

  .app-layout {
    display: block;
  }

  .sidebar {
    position: fixed;
    z-index: 100;
    top: var(--header-height);
    bottom: 0;
    left: 0;
    width: min(82vw, 290px);
    height: auto;
    transform: translateX(-105%);
    box-shadow: 18px 0 40px rgba(8, 27, 52, 0.22);
    transition: transform 180ms ease;
  }

  body.sidebar-open .sidebar {
    transform: translateX(0);
  }

  body.sidebar-open::after {
    position: fixed;
    z-index: 90;
    inset: var(--header-height) 0 0;
    background: rgba(11, 28, 50, 0.5);
    content: "";
  }

  .workspace {
    padding: 22px 14px 32px;
  }

  .page-heading {
    min-height: 65px;
    margin-bottom: 16px;
  }

  .page-heading .muted {
    display: none;
  }

  .page-actions .button {
    min-height: 42px;
    padding: 9px 12px;
  }

  .import-guide {
    align-items: stretch;
    flex-direction: column;
  }

  .import-guide .button {
    width: 100%;
  }

  .welcome-strip {
    min-height: 156px;
    padding: 25px;
  }

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

  .metric-card {
    min-height: 126px;
    padding: 15px;
  }

  .dashboard-grid {
    gap: 12px;
  }

  .filter-bar,
  .history-filters {
    grid-template-columns: 1fr 1fr;
  }

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

  .table-wrap {
    display: none;
  }

  .mobile-card-list {
    display: block;
  }

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

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

  .pending-cargo-heading {
    flex-direction: column;
  }

  .selection-actions {
    width: 100%;
    justify-content: flex-end;
  }

  .pickup-controls {
    justify-content: flex-start;
  }

  .modal,
  .modal-wide,
  .modal-extra-wide {
    width: 100vw;
    max-width: none;
    max-height: 100vh;
    border-radius: 0;
  }

  .modal-card {
    min-height: 100vh;
    max-height: 100vh;
  }

  .modal-header,
  .modal-footer {
    padding: 15px;
  }

  .modal-body {
    padding: 16px;
  }

  .modal-footer .button {
    flex: 1;
  }

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

  .shipment-upload-row,
  .arrival-confirmation-grid,
  .inline-create-form,
  #channelCreateForm,
  .catalog-record,
  .shipment-row-editor {
    grid-template-columns: 1fr;
  }

  .shipment-preview-heading,
  .shipment-confirm-bar,
  .shipment-items-heading,
  .dashboard-rate-alert {
    align-items: stretch;
    flex-direction: column;
  }

  .dashboard-rate-alert .button {
    align-self: flex-start;
  }

  .customer-rate-reference-card,
  .customer-rate-reference-facts,
  .legacy-override-void-form {
    grid-template-columns: 1fr;
  }

  .legacy-override-void-form .field-error {
    grid-column: 1;
  }

  .shipment-item-toolbar {
    justify-content: stretch;
  }

  .shipment-item-toolbar input {
    width: 100%;
  }

  .shipment-preview-heading .compact-field {
    width: 100%;
  }

  .shipment-preview-card .shipment-row-reasons {
    margin-top: 12px;
  }

  .rate-history .table-wrap,
  .compact-data-table {
    display: block;
  }
}

@media (max-width: 480px) {
  .brand-name {
    font-size: 0.93rem;
  }

  .welcome-strip {
    align-items: flex-start;
    flex-direction: column;
  }

  .page-heading {
    align-items: stretch;
    flex-direction: column;
    gap: 12px;
  }

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

  .page-actions .button {
    flex: 1 1 calc(50% - 9px);
  }

  .input-with-action,
  .import-summary {
    grid-template-columns: 1fr;
  }

  .input-with-action .button {
    width: 100%;
  }

  .welcome-strip .button {
    width: 100%;
  }

  .metric-card strong {
    font-size: 1.45rem;
  }

  .card-heading {
    align-items: center;
  }

  .filter-bar,
  .history-filters {
    grid-template-columns: 1fr;
  }

  .filter-bar > *,
  .history-filters > *,
  .search-field {
    grid-column: 1;
  }

  .mobile-record-meta,
  .summary-list,
  .detail-hero,
  .customer-facts,
  .pickup-amounts {
    grid-template-columns: 1fr;
  }

  .selected-customer-heading,
  .pending-cargo-card-header,
  .pickup-order-line {
    align-items: flex-start;
  }

  .selection-actions .text-button,
  .selected-customer-heading .text-button,
  .label-row .text-button {
    min-height: 42px;
    padding: 8px 10px;
  }

  .pickup-controls {
    align-items: flex-start;
    flex-direction: column;
  }

  .pickup-remaining-after {
    text-align: left;
  }

  .stack-item {
    align-items: flex-start;
    flex-direction: column;
  }

  .money-pair {
    justify-content: flex-start;
  }

  html[lang="ru"] .submission-status-row {
    align-items: flex-start;
    flex-direction: column;
    gap: 4px;
  }

  html[lang="ru"] #handoffSubmit {
    height: auto;
    white-space: normal;
    overflow-wrap: anywhere;
    line-height: 1.35;
  }

  .shipment-filters,
  .shipment-summary-grid,
  .shipment-preview-summary,
  .receivable-chip-list,
  .shipment-rate-override,
  .history-comparison {
    grid-template-columns: 1fr;
  }

  .shipment-item-toolbar {
    align-items: stretch;
    flex-direction: column;
  }
}

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

@media print {
  .app-header,
  .sidebar,
  .page-heading,
  .page-actions,
  .button,
  .filter-bar,
  .toast {
    display: none !important;
  }

  .app-layout {
    display: block;
  }

  .workspace {
    max-width: none;
    padding: 0;
  }

  .card {
    box-shadow: none;
  }
}
