:root {
  --ink: #1b3e51;
  --ink-soft: #2a5266;
  --nav: #0f2c3c;
  --nav-deep: #0a2130;
  --sky: #2f6f8f;
  --sky-50: #eef5f8;
  --brand-red: #c1272d;
  --brand-red-deep: #a51f24;
  --red-50: #fdf0f0;
  --green: #1c7c4a;
  --green-50: #e8f6ee;
  --amber: #9a5b00;
  --amber-50: #fff4e0;
  --text: #15222e;
  --text-soft: #3d5261;
  --muted: #687b8a;
  --faint: #a7b5bf;
  --line: #e1e8ed;
  --line-soft: #edf2f5;
  --bg: #f3f6f8;
  --surface: #ffffff;
  --surface-soft: #f7f9fb;
  --row-hover: #f5f9fb;
  --radius: 10px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 2px rgba(16, 47, 64, 0.05);
  --shadow: 0 8px 24px rgba(16, 47, 64, 0.06);
  --shadow-float: 0 24px 64px rgba(10, 33, 48, 0.2);
  --ring: 0 0 0 3px rgba(47, 111, 143, 0.18);
  --font: "PingFang SC", "Microsoft YaHei", "Noto Sans SC", -apple-system, "Segoe UI", sans-serif;
  --font-num: -apple-system, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

.password-control { position: relative; display: flex; width: 100%; }
.password-control input { width: 100%; padding-right: 58px !important; }
.password-toggle { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); border: 0; background: transparent; color: var(--sky); cursor: pointer; padding: 6px; font: inherit; }
.business-modal { max-height: 90vh; overflow-y: auto; }
.modal.wide.business-modal { width: 1040px; }
.data-table.invoice-lines { min-width: 620px; table-layout: fixed; }
.invoice-lines th:first-child { width: 34%; }
.invoice-lines th:last-child { width: 64px; }
.business-modal input, .business-modal textarea { font: inherit; }
.invoice-lines input { width: 100%; min-width: 80px; border: 1px solid var(--line); border-radius: 6px; padding: 8px; }
.invoice-quota-banner { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; padding: 16px; margin-bottom: 16px; border-radius: 10px; background: var(--sky-50); }
.invoice-quota-banner p { margin: 4px 0 0; }
.invoice-images { margin: 12px 0; }
.invoice-images-title { display: block; margin-bottom: 4px; color: var(--muted); font-size: 13px; }
.invoice-images p { margin: 0; font-size: 13px; overflow-wrap: anywhere; }
.invoice-images p .link.danger { margin-left: 8px; }

* { box-sizing: border-box; }

html { background: var(--bg); }

body {
  margin: 0;
  min-width: 320px;
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

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

button,
.menu-item,
.link { -webkit-tap-highlight-color: transparent; }

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: none;
  box-shadow: var(--ring);
}

input[type="checkbox"] {
  width: 15px;
  height: 15px;
  margin: 0;
  vertical-align: middle;
  accent-color: var(--brand-red);
  cursor: pointer;
}

svg.i {
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ---------- Login (ys-agent style characters + right panel) ---------- */

.login-page {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(420px, 0.8fr);
  background: #000;
}

.login-page__hero {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  overflow: hidden;
  padding: 40px 48px;
  color: #fff;
  background: #000;
}

.login-page__hero::after {
  content: '';
  position: absolute;
  inset: auto auto 10% 15%;
  width: 320px;
  height: 320px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
  filter: blur(70px);
  pointer-events: none;
}

.login-page__brand {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 12px;
}

.login-page__brand-badge {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.18);
}

.login-page__brand-logo {
  display: block;
  width: 28px;
  height: 28px;
  object-fit: contain;
}

.login-page__brand-name {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
}

.login-page__brand-subtitle {
  margin: 4px 0 0;
  font-size: 13px;
  color: rgba(255, 255, 255, 0.68);
}

.login-page__characters,
.login-page__hero-copy,
.login-page__hero-footer {
  position: relative;
  z-index: 1;
}

.login-page__characters {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  min-height: 500px;
}

.character-stage {
  position: relative;
  width: min(550px, 100%);
  height: 420px;
}

.character {
  position: absolute;
  bottom: 0;
  transform-origin: bottom center;
  transition: transform 0.7s ease, height 0.7s ease;
}

.character--purple {
  left: 70px;
  width: 180px;
  height: 400px;
  border-radius: 18px 18px 0 0;
  background: linear-gradient(180deg, #7a4cff, #6c3ff5);
  z-index: 1;
}

.character--black {
  left: 240px;
  width: 120px;
  height: 310px;
  border-radius: 12px 12px 0 0;
  background: linear-gradient(180deg, #343434, #2d2d2d);
  z-index: 2;
}

.character--orange {
  left: 0;
  width: 240px;
  height: 200px;
  border-radius: 120px 120px 0 0;
  background: linear-gradient(180deg, #ffa171, #ff9b6b);
  z-index: 3;
}

.character--yellow {
  left: 310px;
  width: 140px;
  height: 230px;
  border-radius: 70px 70px 0 0;
  background: linear-gradient(180deg, #efe06d, #e8d754);
  z-index: 4;
}

.character__eyes,
.pupil-group {
  position: absolute;
  display: flex;
  transition: left 0.25s ease, top 0.25s ease;
}

.character__eyes--purple { gap: 32px; }
.character__eyes--black { gap: 24px; }

.eye-ball {
  width: 18px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border-radius: 50%;
  background: #fff;
  transition: height 0.15s ease;
}

.eye-ball--black { width: 16px; height: 16px; }
.eye-ball--blinking { height: 2px; }

.eye-ball__pupil,
.pupil {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #1a1a1a;
  transition: transform 0.1s ease-out;
}

.eye-ball--black .eye-ball__pupil { width: 6px; height: 6px; }
.pupil-group--orange { gap: 32px; }
.pupil-group--yellow { gap: 24px; }
.pupil { width: 12px; height: 12px; }

.character__mouth {
  position: absolute;
  width: 80px;
  height: 4px;
  border-radius: 999px;
  background: #1a1a1a;
  transition: left 0.25s ease, top 0.25s ease;
}

.login-page__hero-copy {
  max-width: 520px;
}

.login-page__hero-copy h1 {
  margin: 0 0 12px;
  font-size: 42px;
  line-height: 1.12;
  letter-spacing: -0.02em;
  color: #fff;
  text-align: left;
}

.login-page__hero-copy p {
  margin: 0;
  font-size: 15px;
  line-height: 1.7;
  color: rgba(255, 255, 255, 0.72);
}

.login-page__hero-footer {
  display: flex;
  gap: 24px;
  flex-wrap: wrap;
  font-size: 13px;
  color: rgba(255, 255, 255, 0.68);
}

.login-page__panel {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px 32px;
  background:
    radial-gradient(circle at top, rgba(193, 39, 45, 0.08), transparent 42%),
    #f4f7fa;
}

.login-card {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 440px;
  padding: 40px 36px 32px;
  overflow: hidden;
  border: 1px solid var(--line-soft);
  border-radius: 28px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 24px 48px rgba(18, 32, 51, 0.08);
}

.login-card::before {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  bottom: auto;
  left: 0;
  height: 4px;
  background: linear-gradient(90deg, var(--brand-red), #e5676b 50%, var(--sky));
}

.login-brand {
  display: flex;
  justify-content: center;
  margin-bottom: 18px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--line-soft);
}

.login-logo {
  display: block;
  width: auto;
  height: 64px;
  max-width: 220px;
  object-fit: contain;
}

.login-eyebrow {
  margin: 0 0 8px;
  color: var(--brand-red);
  font-size: 10.5px;
  font-weight: 800;
  letter-spacing: 0.2em;
  text-align: center;
}

.login-card h1 {
  margin: 0 0 6px;
  color: var(--ink);
  font-size: 25px;
  letter-spacing: -0.01em;
  text-align: center;
}

.login-card .hint {
  margin: 0 0 22px;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}

.login-card .field {
  position: relative;
  margin-bottom: 16px;
}

.login-card .field > span {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 13px;
}

.login-card .field input {
  width: 100%;
  height: 48px;
  border-radius: 16px;
  background: #f5f7fa;
}

.login-card .field input:focus { background: #fff; }

.login-password-toggle {
  position: absolute;
  right: 12px;
  bottom: 12px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 12px;
  cursor: pointer;
}

.login-password-toggle:hover { color: var(--ink); }

.login-card .btn-block {
  height: 48px;
  margin-top: 8px;
  border-radius: 16px;
}

@media (max-width: 1200px) {
  .login-page { grid-template-columns: 1fr; }
  .login-page__hero { display: none; }
  .login-page__panel { min-height: 100vh; }
}

@media (max-width: 768px) {
  .login-page__panel { padding: 24px; }
  .login-card { padding: 30px 22px 24px; border-radius: 18px; }
}

/* ---------- Layout ---------- */

.layout {
  display: flex;
  align-items: flex-start;
  width: 100%;
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  width: 236px;
  height: 100vh;
  flex-shrink: 0;
  overflow-y: auto;
  padding: 18px 12px 24px;
  background:
    radial-gradient(300px 220px at 0% 0%, rgba(47, 111, 143, 0.28), transparent 70%),
    linear-gradient(180deg, var(--nav) 0%, var(--nav-deep) 100%);
  color: #fff;
}

.brand {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 10px;
  margin: 0 4px 18px;
  padding: 4px 4px 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar-logo {
  display: block;
  width: 132px;
  height: auto;
  padding: 8px 12px;
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 8px 20px rgba(0, 12, 20, 0.25);
}

.brand span {
  display: block;
  padding-left: 2px;
  color: rgba(255, 255, 255, 0.72);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.06em;
}

.menu {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-section-label {
  display: block;
  margin: 14px 12px 6px;
  color: rgba(255, 255, 255, 0.36);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
}

.nav-section-label:first-child { margin-top: 0; }

.menu-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 11px;
  min-height: 42px;
  padding: 0 12px;
  border-radius: 10px;
  color: rgba(255, 255, 255, 0.72);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: color 0.16s ease, background 0.16s ease;
}

.menu-icon.i {
  width: 18px;
  height: 18px;
  color: rgba(255, 255, 255, 0.5);
  stroke-width: 1.8;
  transition: color 0.16s ease;
}

.menu-item:hover {
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
}

.menu-item:hover .menu-icon { color: rgba(255, 255, 255, 0.85); }

.menu-item.active {
  background: linear-gradient(90deg, rgba(193, 39, 45, 0.95), rgba(193, 39, 45, 0.78));
  color: #fff;
  font-weight: 600;
  box-shadow: 0 8px 18px rgba(193, 39, 45, 0.28);
}

.menu-item.active .menu-icon { color: #fff; }

.main {
  flex: 1;
  min-width: 0;
  min-height: 100vh;
  padding: 20px 28px 40px;
  padding: 20px clamp(16px, 2.2vw, 32px) 40px;
}

/* ---------- Top bar ---------- */

.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
  padding: 4px 0 2px;
}

.topbar-heading {
  min-width: 0;
  margin-right: auto;
}

.topbar-kicker {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 2px;
  color: var(--muted);
  font-size: 12.5px;
}

.topbar-kicker i {
  color: var(--faint);
  font-style: normal;
}

.topbar h2 {
  margin: 0;
  color: var(--ink);
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.topbar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 5px 14px 5px 5px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.user-avatar {
  display: grid;
  width: 32px;
  height: 32px;
  flex: 0 0 32px;
  place-items: center;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--ink), var(--sky));
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
}

.user-meta {
  display: flex;
  flex-direction: column;
  line-height: 1.25;
}

.user-meta strong {
  color: var(--ink);
  font-size: 13px;
}

.user-meta small {
  color: var(--muted);
  font-size: 11.5px;
}

.logout-btn { height: 42px; border-radius: 999px; padding: 0 16px; }
.logout-btn:hover:not(:disabled) { border-color: #f0c8ca; background: var(--red-50); color: var(--brand-red); }

/* ---------- Panel & toolbar ---------- */

.panel {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin: 0 0 16px;
}

.toolbar-spacer { flex: 1 1 auto; min-width: 8px; }

.toolbar-hint {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

.toolbar-hint .i { width: 15px; height: 15px; color: var(--faint); }

.batch-bar {
  display: flex;
  flex-wrap: wrap;
  flex-basis: 100%;
  align-items: center;
  gap: 8px;
  padding: 8px 10px 8px 14px;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
}

.batch-hint {
  margin-right: 4px;
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

.batch-hint.is-active {
  color: var(--brand-red);
  font-weight: 700;
}

.toolbar > .batch-hint {
  padding: 0 10px;
  line-height: 28px;
  border-radius: 999px;
  background: var(--red-50);
  color: var(--brand-red);
  font-weight: 700;
}

.hint-inline { color: var(--muted); font-size: 13px; }
.hint-warn { color: var(--amber); font-size: 13px; }
.scope-hint {
  margin: 0 0 12px;
  padding: 9px 12px;
  border-radius: 8px;
  background: var(--amber-50);
  color: var(--amber);
  font-size: 13px;
}

/* ---------- Form controls ---------- */

.input,
.field input,
.field select,
.field textarea {
  height: 38px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface);
  color: var(--text);
  font-size: 14px;
  transition: border-color 0.16s ease, box-shadow 0.16s ease, background 0.16s ease;
}

.input { width: 150px; }
.input.wide,
.toolbar select.wide { width: 190px; }
.toolbar select.input { width: 150px; }
.toolbar input.input.wide { width: 220px; }

select.input,
.field select {
  padding-right: 32px;
  -webkit-appearance: none;
  appearance: none;
  background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23687b8a' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") right 10px center / 14px no-repeat;
  cursor: pointer;
}

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

.input:focus,
.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: none;
  border-color: var(--sky);
  box-shadow: var(--ring);
}

.input::placeholder,
.field input::placeholder,
.field textarea::placeholder { color: var(--faint); }

.field {
  display: flex;
  flex-direction: column;
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 13px;
}

.field > span { margin-bottom: 6px; color: var(--text-soft); font-weight: 600; }
.field input,
.field select { width: 100%; }

.field textarea {
  width: 100%;
  height: auto;
  min-height: 160px;
  padding: 10px 12px;
  line-height: 1.6;
  resize: vertical;
}

.field input[readonly],
.field input:disabled {
  border-color: transparent;
  background: var(--surface-soft);
  color: var(--text);
  font-weight: 600;
  cursor: default;
  box-shadow: none;
}

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

.field.check > span { margin: 0 8px 0 0; }
.field.check input { width: auto; height: auto; }

.combo { position: relative; }

.combo-list {
  margin-top: 6px;
  max-height: 220px;
  overflow: auto;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  box-shadow: 0 12px 28px rgba(16, 47, 64, 0.14);
}

.combo-list button {
  display: block;
  width: 100%;
  padding: 8px 10px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--ink);
  font-size: 14px;
  text-align: left;
  cursor: pointer;
}

.combo-list button:hover { background: var(--sky-50); }
.combo-empty { padding: 8px 10px; color: var(--muted); font-size: 13px; }

/* ---------- New-version banner ---------- */

.update-banner {
  display: flex;
  position: fixed;
  top: 14px;
  left: 50%;
  z-index: 1400;
  align-items: center;
  max-width: calc(100% - 32px);
  padding: 8px 10px 8px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 16px 36px rgba(16, 47, 64, 0.18);
  color: var(--ink);
  font-size: 13px;
  font-weight: 600;
  transform: translateX(-50%);
}

.update-banner > * + * { margin-left: 10px; }
.update-banner .i { flex: none; width: 16px; height: 16px; color: var(--sky); }
.update-banner .btn { height: 30px; padding: 0 12px; font-size: 12.5px; }

/* ---------- Searchable select ---------- */

.search-select { display: inline-block; position: relative; vertical-align: middle; }
.field .search-select { display: block; width: 100%; }

.search-select-trigger {
  display: flex;
  align-items: center;
  box-sizing: border-box;
  width: 100%;
  height: 38px;
  padding: 0 32px 0 12px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background-color: var(--surface);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23687b8a' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-position: right 10px center;
  background-size: 14px;
  background-repeat: no-repeat;
  color: var(--text);
  font-size: 14px;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.16s ease, box-shadow 0.16s ease, background-color 0.16s ease;
}

.search-select-trigger.is-empty { color: var(--muted); }
.search-select-trigger:hover { border-color: #c9d6de; }
.search-select-trigger:focus,
.search-select.is-open .search-select-trigger { outline: none; border-color: var(--sky); box-shadow: var(--ring); }
.search-select-text { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.toolbar .search-select-trigger.input { width: 150px; }
.toolbar .search-select-trigger.input.wide { width: 190px; }
.row-editor .search-select-trigger { height: 36px; }
.row-editor .field.is-dirty .search-select-trigger { border-color: var(--sky); background-color: var(--sky-50); }
.row-editor .field.is-error .search-select-trigger { border-color: var(--brand-red); background-color: var(--red-50); }

.search-select-panel {
  position: fixed;
  z-index: 1300;
  box-sizing: border-box;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 16px 36px rgba(16, 47, 64, 0.18);
}

.search-select-search {
  display: flex;
  align-items: center;
  height: 34px;
  margin-bottom: 6px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
}

.search-select-search .i { flex: none; width: 15px; height: 15px; margin-right: 6px; color: var(--muted); }

.search-select-search input {
  flex: 1;
  min-width: 0;
  height: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--text);
  font-size: 13px;
}

.search-select-search input:focus { outline: none; box-shadow: none; }
.search-select-search:focus-within { border-color: var(--sky); background: #fff; }

.search-select-list { max-height: 240px; overflow-y: auto; overscroll-behavior: contain; }

.search-select-option {
  display: block;
  width: 100%;
  padding: 7px 10px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--ink);
  font-size: 13px;
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
}

.search-select-option.is-active { background: var(--sky-50); }
.search-select-option.is-selected { color: var(--brand-red); font-weight: 700; }
.search-select-option.is-clear { color: var(--muted); }
.search-select-empty { padding: 10px; color: var(--muted); font-size: 13px; text-align: center; }
.search-select-more { padding: 6px 10px 2px; border-top: 1px solid var(--line-soft); color: var(--muted); font-size: 12px; text-align: center; }

/* ---------- Date picker ---------- */

.date-picker { display: inline-block; position: relative; vertical-align: middle; }
/* In dialog fields the date picker fills the field like the other inputs; .field input would
   otherwise drop the calendar icon. */
.field .date-picker { display: block; width: 100%; }
.field .date-picker .date-picker-input {
  width: 100%;
  box-sizing: border-box;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23687b8a' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3' y='4' width='18' height='18' rx='2'/%3E%3Cpath d='M16 2v4M8 2v4M3 10h18'/%3E%3C/svg%3E");
  background-position: right 10px center;
  background-size: 14px;
  background-repeat: no-repeat;
}
.cell-quick .date-picker { display: block; }
.row-draft-fields .date-picker { display: flex; flex: 1; min-width: 132px; }
.row-draft-fields .date-picker .row-draft-input { width: 100%; min-width: 0; }

.date-picker-input {
  padding-right: 26px !important;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23687b8a' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3' y='4' width='18' height='18' rx='2'/%3E%3Cpath d='M16 2v4M8 2v4M3 10h18'/%3E%3C/svg%3E");
  background-position: right 8px center;
  background-size: 14px;
  background-repeat: no-repeat;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
}

.date-picker-panel {
  position: fixed;
  z-index: 1300;
  box-sizing: border-box;
  width: 260px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 16px 36px rgba(16, 47, 64, 0.18);
  user-select: none;
}

.date-picker-head { display: flex; align-items: center; margin-bottom: 6px; }
.date-picker-title { flex: 1; color: var(--ink); font-size: 14px; font-weight: 700; text-align: center; }

.date-picker-nav,
.date-picker-day,
.date-picker-link {
  border: 0;
  background: transparent;
  font: inherit;
  cursor: pointer;
}

.date-picker-nav {
  width: 28px;
  height: 28px;
  border-radius: 7px;
  color: var(--muted);
  font-size: 16px;
  line-height: 1;
}

.date-picker-nav:hover { background: var(--sky-50); color: var(--ink); }

.date-picker-week,
.date-picker-days { display: grid; grid-template-columns: repeat(7, 1fr); }
.date-picker-week span { padding: 4px 0; color: var(--muted); font-size: 12px; text-align: center; }

.date-picker-day {
  height: 32px;
  margin: 1px;
  border-radius: 7px;
  color: var(--text);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

.date-picker-day.is-outside { color: var(--faint); }
.date-picker-day.is-active { background: var(--sky-50); }
.date-picker-day.is-today { box-shadow: inset 0 0 0 1px var(--sky); }
.date-picker-day.is-selected { background: var(--brand-red); color: #fff; font-weight: 700; }

.date-picker-foot {
  display: flex;
  justify-content: space-between;
  margin-top: 6px;
  padding-top: 8px;
  border-top: 1px solid var(--line-soft);
}

.date-picker-link { padding: 4px 6px; border-radius: 6px; color: var(--sky); font-size: 13px; font-weight: 600; }
.date-picker-link:hover { background: var(--sky-50); }

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 38px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface);
  color: var(--text-soft);
  font-size: 13.5px;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  transition: background 0.16s ease, border-color 0.16s ease, color 0.16s ease, box-shadow 0.16s ease;
}

.btn:hover:not(:disabled) { border-color: #c9d6de; background: var(--surface-soft); color: var(--ink); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn .i { width: 15px; height: 15px; }

.btn-sm { height: 30px; padding: 0 10px; border-radius: 8px; font-size: 12.5px; }

.btn-icon { width: 38px; padding: 0; }
.btn-icon .i { width: 16px; height: 16px; }

.btn-primary {
  border-color: transparent;
  background: linear-gradient(135deg, #cf353b, var(--brand-red-deep));
  color: #fff;
  box-shadow: 0 6px 14px rgba(193, 39, 45, 0.22);
}

.btn-primary:hover:not(:disabled) {
  border-color: transparent;
  background: linear-gradient(135deg, #d9434a, var(--brand-red));
  color: #fff;
}

.btn-ink,
.btn-success {
  border-color: transparent;
  background: var(--ink);
  color: #fff;
}

.btn-ink:hover:not(:disabled),
.btn-success:hover:not(:disabled) {
  border-color: transparent;
  background: var(--ink-soft);
  color: #fff;
}

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

.btn-danger:hover:not(:disabled) {
  border-color: transparent;
  background: var(--brand-red-deep);
  color: #fff;
}

.btn-outline-danger { color: var(--brand-red); }
.btn-outline-danger:hover:not(:disabled) { border-color: #efc2c4; background: var(--red-50); color: var(--brand-red-deep); }

.btn-block { width: 100%; margin-top: 8px; }

.link {
  display: inline-flex;
  align-items: center;
  height: 28px;
  padding: 0 7px;
  border: 0;
  border-radius: 6px;
  background: none;
  color: var(--sky);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.16s ease, color 0.16s ease;
}

.link:hover:not(:disabled) { background: var(--sky-50); color: #245a75; }
.link.danger { color: var(--brand-red); }
.link.danger:hover:not(:disabled) { background: var(--red-50); color: var(--brand-red-deep); }
.link:disabled { opacity: 0.45; cursor: not-allowed; }

/* ---------- Tables ---------- */

.table-scroll {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  -webkit-overflow-scrolling: touch;
}

.data-table {
  width: 100%;
  min-width: 1040px;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13px;
}

.data-table th,
.data-table td {
  padding: 11px 8px;
  border-bottom: 1px solid var(--line-soft);
  background: var(--surface);
  text-align: center;
  white-space: nowrap;
  vertical-align: middle;
}

.data-table th {
  padding-top: 10px;
  padding-bottom: 10px;
  border-bottom-color: var(--line);
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table tbody tr:hover td { background: var(--row-hover); }

.data-table .left { max-width: 180px; text-align: left; white-space: normal; }
.data-table .empty,
.data-table tbody tr:hover .empty { padding: 44px 16px; color: var(--muted); background: var(--surface); }

.data-table .code {
  color: var(--ink);
  font-family: var(--font-num);
  font-weight: 700;
  letter-spacing: 0.02em;
}

.code-badge {
  display: inline-block;
  min-width: 30px;
  padding: 2px 6px;
  border-radius: 6px;
  background: var(--sky-50);
  color: var(--ink);
  font-family: var(--font-num);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.03em;
}

.route-text {
  margin-right: 8px;
  color: var(--ink);
  font-family: var(--font-num);
  font-weight: 700;
}

.route-text i {
  margin: 0 5px;
  color: var(--brand-red);
  font-style: normal;
}

.data-table .num {
  color: var(--ink);
  font-family: var(--font-num);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.data-table .remark-cell {
  min-width: 110px;
  max-width: 220px;
  color: var(--muted);
  white-space: normal;
  word-break: break-word;
}

.data-table .ops { white-space: nowrap; }

.data-table:not(.compact) th:last-child,
.data-table:not(.compact) td.ops:last-child {
  position: sticky;
  right: 0;
  z-index: 1;
  box-shadow: -1px 0 0 var(--line-soft);
}

.data-table.compact {
  min-width: 0;
  width: 100%;
  table-layout: fixed;
}

.data-table.compact th,
.data-table.compact td {
  white-space: normal;
  word-break: break-word;
}

.data-table.compact .ops-col { width: 250px; }
.data-table.compact td.ops { white-space: nowrap; }

.check-col {
  width: 44px;
  min-width: 44px;
}

.status-cell { text-align: center; vertical-align: middle; }

.op-content {
  max-width: 420px;
  line-height: 1.5;
  text-align: left;
  white-space: normal;
  word-break: break-word;
}

/* ---------- In-list row editor ---------- */

.editing-pill {
  display: inline-flex;
  align-items: center;
  height: 26px;
  padding: 0 10px;
  border-radius: 999px;
  background: #e4f0f6;
  color: #245a75;
  font-size: 12.5px;
  font-weight: 600;
}

.editing-pill::before {
  content: "";
  width: 6px;
  height: 6px;
  margin-right: 6px;
  border-radius: 50%;
  background: var(--sky);
}

.data-table tbody td { transition: opacity 0.2s ease; }
.data-table tbody.is-editing > tr:not(.row-editing):not(.editor-row):not(.row-draft) > td { opacity: 0.42; }

.data-table tr.row-editing td,
.data-table tbody tr.row-editing:hover td { background: #eef6fa; }
.data-table tr.row-editing td:first-child { box-shadow: inset 3px 0 0 var(--sky); }

.data-table tr.editor-row td,
.data-table tbody tr.editor-row:hover td {
  padding: 0;
  background: #eef6fa;
  text-align: left;
  white-space: normal;
  box-shadow: inset 3px 0 0 var(--sky);
}

/* Sticky with the visible width (set from JS) so horizontal table scroll never hides the card. */
.row-editor {
  position: -webkit-sticky;
  position: sticky;
  left: 0;
  box-sizing: border-box;
  overflow: hidden;
  padding: 2px 14px 14px;
  animation: rowEditorIn 0.28s ease backwards;
}

.row-editor.is-closing { animation: rowEditorOut 0.2s ease forwards; }

@keyframes rowEditorIn {
  from { max-height: 0; opacity: 0; transform: translateY(-8px); }
  to { max-height: 900px; opacity: 1; transform: none; }
}

@keyframes rowEditorOut {
  from { max-height: 900px; opacity: 1; }
  to { max-height: 0; opacity: 0; transform: translateY(-6px); }
}

.row-editor-card {
  padding: 14px 18px 12px;
  border: 1px solid #cfe2eb;
  border-radius: 12px;
  background: var(--surface);
  box-shadow: 0 14px 30px -14px rgba(16, 47, 64, 0.28), 0 1px 3px rgba(16, 47, 64, 0.06);
}

.row-editor-title {
  display: flex;
  align-items: center;
  margin-bottom: 4px;
  color: var(--text-soft);
  font-size: 14px;
}

.row-editor-title > * + * { margin-left: 6px; }
.row-editor-title .i { color: var(--sky); }
.row-editor-title b { color: var(--ink); font-family: var(--font-num); font-weight: 700; }

.tag-mini {
  display: inline-block;
  margin-right: 6px;
  padding: 1px 7px;
  border-radius: 4px;
  background: var(--green-50);
  color: var(--green);
  font-size: 12px;
  font-weight: 700;
}

.row-editor-section {
  margin: 12px 0 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

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

.row-editor-grid.row-editor-prices { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.row-editor-grid.auto { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); margin-top: 10px; }
.row-editor-grid .full { grid-column: 1 / -1; }

.row-editor .field { margin-bottom: 2px; }
.row-editor .field > span { margin-bottom: 4px; }
.row-editor .field input,
.row-editor .field select { height: 36px; }
.row-editor .field input[type="checkbox"] { height: 16px; }

.row-editor .price-input {
  text-align: right;
  font-family: var(--font-num);
  font-variant-numeric: tabular-nums;
}

.row-editor-remark { margin-top: 10px; }
.row-editor .row-editor-remark textarea { min-height: 0; height: 60px; resize: vertical; }

.field-origin {
  display: block;
  min-height: 17px;
  margin-top: 2px;
  color: var(--sky);
  font-size: 12px;
  font-style: normal;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.row-editor .field.is-dirty input,
.row-editor .field.is-dirty select,
.row-editor .field.is-dirty textarea { border-color: var(--sky); background-color: var(--sky-50); }

.row-editor .field.is-error select,
.row-editor .field.is-error input { border-color: var(--brand-red); background-color: var(--red-50); }

.row-editor-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  margin-top: 8px;
  padding-top: 10px;
  border-top: 1px solid var(--line-soft);
}

.row-editor-actions > * + * { margin-left: 8px; }
.row-editor-hint { flex: 1 1 auto; color: var(--muted); font-size: 12px; }

@keyframes rowFlash {
  from { background-color: #dcf2e4; }
  to { background-color: var(--surface); }
}

.data-table tbody tr.row-flash td,
.data-table tbody td.price-flash { animation: rowFlash 1.2s ease; }

.data-table td.price-cell { min-width: 72px; }
.data-table td.price-cell.is-quick { cursor: text; }
.data-table td.price-cell.is-open { padding-left: 0; padding-right: 0; }
.data-table tbody tr:hover td.price-cell.is-quick:hover { background: var(--sky-50); box-shadow: inset 0 0 0 1px #b9cfdb; }

.price-quick-input {
  box-sizing: border-box;
  width: 72px;
  height: 28px;
  margin: -5px 0;
  padding: 0 6px;
  border: 1px solid var(--sky);
  border-radius: 6px;
  background: #fff;
  box-shadow: var(--ring);
  color: var(--ink);
  font-family: var(--font-num);
  font-size: 13px;
  font-weight: 600;
  text-align: center;
  -moz-appearance: textfield;
}

.price-quick-input:focus { outline: none; }
.price-quick-input::-webkit-outer-spin-button,
.price-quick-input::-webkit-inner-spin-button { margin: 0; -webkit-appearance: none; }

.data-table td.cell-quick.is-quick { cursor: text; }
.data-table td.cell-quick.is-open { padding-left: 0; padding-right: 0; }
.data-table tbody tr:hover td.cell-quick.is-quick:hover { background: var(--sky-50); box-shadow: inset 0 0 0 1px #b9cfdb; }
.data-table tbody td.cell-flash { animation: rowFlash 1.2s ease; }

.cell-quick-input {
  box-sizing: border-box;
  width: 100%;
  min-width: 64px;
  height: 28px;
  margin: -5px 0;
  padding: 0 8px;
  text-align: center !important;
  border: 1px solid var(--sky);
  border-radius: 6px;
  background: #fff;
  box-shadow: var(--ring);
  color: var(--ink);
  font: inherit;
  font-size: 13px;
}

.cell-quick-input:focus { outline: none; }
td.num .cell-quick-input {
  font-family: var(--font-num);
  font-weight: 600;
  text-align: right !important;
}
select.cell-quick-input { cursor: pointer; text-align: center; }

/* Inline draft row for adding records (non-rate menus). */
.data-table tbody tr.row-draft td {
  background: #f3faf6 !important;
  opacity: 1 !important;
  box-shadow: inset 0 1px 0 #cfe8d8, inset 0 -1px 0 #cfe8d8;
  vertical-align: middle;
}
.data-table tbody tr.row-draft td:first-child {
  box-shadow: inset 3px 0 0 #3aa76d, inset 0 1px 0 #cfe8d8, inset 0 -1px 0 #cfe8d8;
}
.data-table tbody tr.row-draft:hover td {
  background: #eaf7ef !important;
}
/* 查看协议: a read-only agreement under a company row (blue instead of the green edit tint). */
.data-table tbody tr.row-draft.row-readonly td,
.data-table tbody tr.row-draft.row-readonly:hover td {
  background: var(--sky-50) !important;
  box-shadow: inset 0 1px 0 #d3e3ec, inset 0 -1px 0 #d3e3ec;
}
.data-table tbody tr.row-draft.row-readonly td:first-child {
  box-shadow: inset 3px 0 0 var(--sky), inset 0 1px 0 #d3e3ec, inset 0 -1px 0 #d3e3ec;
}
.row-readonly .row-draft-input:disabled {
  background: #fff;
  color: var(--ink);
  -webkit-text-fill-color: var(--ink);
  opacity: 1;
}
.row-draft-input {
  box-sizing: border-box;
  width: 100%;
  min-width: 72px;
  height: 32px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-size: 13px;
  text-align: center;
}
.row-draft-input:focus {
  outline: none;
  border-color: var(--sky);
  box-shadow: var(--ring);
}
.row-draft-fields {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
.row-draft-fields .row-draft-input { width: auto; min-width: 120px; flex: 1; }
.search-select-trigger.row-draft-input { height: 32px; padding: 0 26px 0 8px; background-position: right 8px center; }
.row-draft td > .search-select { display: block; }
/* Draft rows whose fields need captions (filled values hide placeholders). */
.row-draft-fields.labeled { align-items: flex-end; }
.draft-field { display: flex; flex: 1; flex-direction: column; min-width: 88px; margin: 0; }
.draft-field.is-date { min-width: 116px; }
.draft-caption { margin-bottom: 3px; color: var(--muted); font-size: 11.5px; font-weight: 600; text-align: left; }
.draft-field .row-draft-input,
.draft-field .date-picker { flex: none; width: 100%; min-width: 0; height: 32px; }
.draft-field .date-picker { display: flex; }
.draft-check {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text);
  font-size: 13px;
  white-space: nowrap;
}
.draft-ops {
  white-space: nowrap;
}
.draft-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  margin: 0 1px;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  cursor: pointer;
  transition: background 0.16s ease, color 0.16s ease;
}
.draft-btn .i {
  width: 16px;
  height: 16px;
  stroke-width: 2.25;
}
.draft-btn:disabled { opacity: .45; cursor: not-allowed; }
.draft-btn:not(.draft-ok):not(.draft-cancel) { color: var(--muted); }
.draft-btn:not(.draft-ok):not(.draft-cancel):hover:not(:disabled) { background: var(--sky-50); color: var(--ink); }

/* 客户账号 draft: generated password with a regenerate button (margins, not gap: old 360 kernels). */
.draft-password { display: flex; align-items: center; margin-top: 4px; }
.draft-password .row-draft-input { flex: 1; min-width: 0; font-family: var(--font-num); letter-spacing: 0.04em; }
.draft-password .draft-btn { flex: none; margin-left: 4px; }
.field .draft-password { margin-top: 0; }
.field .draft-password input { flex: 1; min-width: 0; font-family: var(--font-num); letter-spacing: 0.04em; }

/* Credentials shown once after a client account is created. */
.credential-box {
  margin: 4px 0 16px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--sky-50);
  font-size: 13px;
}
.credential-box > div { display: flex; align-items: baseline; }
.credential-box > div + div { margin-top: 8px; }
.credential-box span { flex: none; width: 68px; color: var(--muted); }
.credential-box b { min-width: 0; color: var(--ink); font-weight: 700; word-break: break-all; user-select: all; }
.credential-box .credential-secret { font-family: var(--font-num); font-size: 15px; letter-spacing: 0.06em; }
.draft-btn.draft-ok { color: #2f9b5f; }
.draft-btn.draft-ok:hover:not(:disabled) { background: #eef9f1; color: #217a49; }
.draft-btn.draft-cancel { color: var(--brand-red); }
.draft-btn.draft-cancel:hover:not(:disabled) { background: var(--red-50); color: var(--brand-red-deep); }

.link .i { width: 14px; height: 14px; margin-right: 3px; }

/* An icon-led inline-flex link takes its baseline from the svg bottom; center every op instead. */
.data-table td.ops .link { vertical-align: middle; }

/* ---------- Drag sort ---------- */

.drag-handle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  margin-right: 4px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 7px;
  background: transparent;
  color: var(--faint);
  line-height: 1;
  cursor: grab;
  user-select: none;
  -webkit-user-select: none;
  vertical-align: middle;
  transition: background 0.16s ease, color 0.16s ease, border-color 0.16s ease;
}

.drag-handle .i { width: 16px; height: 16px; }

.drag-handle:hover:not(:disabled) {
  border-color: var(--line);
  background: var(--sky-50);
  color: var(--sky);
}

.drag-handle:active:not(:disabled) { cursor: grabbing; }

.drag-handle:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.sort-ghost td { background: #eaf3f8 !important; opacity: 0.6; }
.sort-chosen td { background: #fff8e8 !important; }

.sort-drag {
  opacity: 0.95;
  box-shadow: 0 10px 24px rgba(16, 47, 64, 0.18);
}

/* ---------- Popover confirm ---------- */

.sort-tip-fixed {
  position: fixed;
  z-index: 1200;
  box-sizing: border-box;
  width: 230px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 16px 36px rgba(16, 47, 64, 0.18);
  text-align: left;
  white-space: normal;
}

.sort-tip-fixed::after {
  content: "";
  position: absolute;
  right: 16px;
  border: 6px solid transparent;
}

.sort-tip--top::after {
  top: 100%;
  border-top-color: #fff;
  filter: drop-shadow(0 1px 0 var(--line));
}

.sort-tip--bottom::after {
  bottom: 100%;
  border-bottom-color: #fff;
  filter: drop-shadow(0 -1px 0 var(--line));
}

.sort-tip-fixed p {
  margin: 0 0 10px;
  color: var(--text-soft);
  font-size: 12.5px;
  line-height: 1.5;
}

.sort-tip-actions {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
}

.sort-tip-cancel,
.sort-tip-ok {
  min-width: 56px;
  height: 28px;
  padding: 0 10px;
  font-size: 12px;
}

/* In-list edit confirm: "field old → new" next to the cell. */
.cell-confirm { width: 260px; }
.sort-tip-fixed p.cell-confirm-title { margin-bottom: 6px; color: var(--ink); font-weight: 600; }
.sort-tip-fixed p.cell-confirm-diff {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 6px;
  margin-bottom: 10px;
  font-size: 13px;
  word-break: break-all;
}
.cell-confirm-diff .i { flex: none; width: 14px; height: 14px; color: var(--muted); }
.cell-confirm-from { color: var(--muted); text-decoration: line-through; }
.cell-confirm-to { color: var(--ink); font-weight: 700; }
.cell-confirm.is-nudged { animation: cellConfirmNudge 0.4s ease; }

@keyframes cellConfirmNudge {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-5px); }
  40% { transform: translateX(5px); }
  60% { transform: translateX(-3px); }
  80% { transform: translateX(3px); }
}

@media (prefers-reduced-motion: reduce) {
  .cell-confirm.is-nudged { animation: none; box-shadow: 0 0 0 3px var(--sky-50), 0 16px 36px rgba(16, 47, 64, 0.18); }
}

/* ---------- Switch & tags ---------- */

.switch {
  position: relative;
  width: 40px;
  height: 22px;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: #cfdae1;
  cursor: pointer;
  vertical-align: middle;
  transition: background 0.18s ease;
}

.switch.on { background: var(--green); }
.switch:disabled { opacity: 0.55; cursor: not-allowed; }
.switch.busy { opacity: 0.7; }

.switch-knob {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.22);
  transition: transform 0.18s ease;
}

.switch.on .switch-knob { transform: translateX(18px); }

.tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 24px;
  padding: 0 9px;
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--text-soft);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.tag::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.tag-on { background: var(--green-50); color: var(--green); }
.tag-off { background: #eef1f4; color: #7a8894; }
.tag-warn { background: var(--amber-50); color: var(--amber); }
.tag-danger { background: var(--red-50); color: var(--brand-red-deep); }

/* 协议额度: 即将超额 / 即将到期 / 已到期 before the company name. */
.agreement-company { white-space: nowrap; }
.agreement-company .tag { margin-right: 6px; vertical-align: 1px; }

/* 运价管理: 中转地 under the transfer mode. */
.transfer-cell { white-space: nowrap; }
.transfer-cell .via-text {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}
.transfer-cell .via-text.is-missing { color: var(--amber); }
.tag-heavy {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 4px;
  background: #fff1e8;
  color: #c45a12;
  font-size: 11px;
  font-weight: 700;
  line-height: 1.4;
  vertical-align: middle;
}

.density-cell {
  white-space: nowrap;
}

.density-cell__badge,
.density-cell__ratio {
  display: inline-block;
  vertical-align: middle;
}

/* Reserve a fixed badge lane so "1:xxx" lines up whether heavy or not. */
.density-cell__badge {
  width: 42px;
  margin-right: 6px;
  text-align: right;
}

.density-cell__badge.is-on { color: inherit; }

.density-cell__ratio {
  min-width: 3.5em;
  text-align: left;
  font-family: var(--font-num);
  font-variant-numeric: tabular-nums;
}

.segmented {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 3px;
  border-radius: 10px;
  background: #eef2f5;
}

.seg-btn {
  height: 32px;
  padding: 0 14px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #5b6b78;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.seg-btn.active {
  background: #fff;
  color: var(--navy-700);
  box-shadow: 0 1px 2px rgba(16, 47, 64, 0.08);
}

.checkbox-field .check-inline {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
}

.checkbox-field .check-inline input {
  width: 16px;
  height: 16px;
}

/* ---------- Pager ---------- */

.pager {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 14px;
  color: var(--muted);
  font-size: 13px;
}

.pager > span:first-child { margin-right: auto; }
.pager .btn { height: 32px; padding: 0 12px; font-size: 13px; }

/* ---------- Messages ---------- */

.error {
  margin-top: 12px;
  padding: 9px 12px;
  border-radius: 9px;
  background: var(--red-50);
  color: var(--brand-red-deep);
  font-size: 13px;
  text-align: center;
}

.ok { margin-top: 10px; color: var(--green); font-size: 13px; }

.import-result {
  margin: 12px 0 0;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--surface-soft);
  font-size: 13px;
}

.import-result ul { margin: 8px 0 0; padding-left: 18px; }

/* ---------- Modal ---------- */

.modal-mask {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(7, 25, 36, 0.55);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
}

.modal {
  width: 760px;
  max-width: 100%;
  max-height: 90vh;
  overflow: auto;
  padding: 22px 24px 20px;
  border-radius: 18px;
  background: #fff;
  box-shadow: var(--shadow-float);
}

.modal.narrow { width: 440px; }
.modal.wide { width: 760px; max-width: 92vw; }

.modal h3 {
  position: relative;
  margin: -22px -24px 18px;
  padding: 18px 24px 16px 38px;
  border-bottom: 1px solid var(--line-soft);
  color: var(--ink);
  font-size: 17px;
  font-weight: 700;
}

.modal h3::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 24px;
  width: 4px;
  height: 16px;
  border-radius: 4px;
  background: var(--brand-red);
  transform: translateY(-50%);
}

.modal .hint {
  margin: 0 0 14px;
  padding: 9px 12px;
  border-radius: 9px;
  background: var(--surface-soft);
  color: var(--text-soft);
  font-size: 13px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  grid-column-gap: 14px;
  grid-row-gap: 4px;
}

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

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin: 18px -24px -20px;
  padding: 14px 24px;
  border-top: 1px solid var(--line-soft);
  background: var(--surface-soft);
}

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

@media (max-width: 1180px) {
  .toolbar-hint { display: none; }
}

@media (max-width: 900px) {
  .row-editor-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .row-editor-grid.row-editor-prices { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .row-editor-hint { display: none; }
  .layout { display: block; }

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 20;
    width: 100%;
    height: auto;
    flex-direction: row;
    align-items: center;
    gap: 6px;
    padding: 8px 10px;
    overflow-x: auto;
  }

  .brand {
    flex: 0 0 auto;
    margin: 0 6px 0 0;
    padding: 0 12px 0 0;
    border: 0;
    border-right: 1px solid rgba(255, 255, 255, 0.12);
  }

  .sidebar-logo { width: 92px; padding: 5px 8px; border-radius: 9px; }

  .brand span,
  .nav-section-label { display: none; }

  .menu { flex-direction: row; gap: 4px; }

  .menu-item {
    flex: 0 0 auto;
    min-height: 38px;
    padding: 0 12px;
    white-space: nowrap;
  }

  .menu-icon.i { display: none; }

  .main { min-height: auto; padding: 14px 12px 28px; }
  .data-table:not(.compact) th:last-child,
  .data-table:not(.compact) td.ops:last-child { position: static; box-shadow: none; }
  .form-grid { grid-template-columns: 1fr 1fr; }
  .panel { padding: 12px; border-radius: 14px; }
}

@media (max-width: 620px) {
  .login-card { padding: 30px 22px 24px; border-radius: 18px; }
  .topbar { flex-wrap: wrap; }
  .topbar-heading { width: 100%; }
  .topbar-user { margin-right: auto; }
  .logout-btn span { display: none; }
  .logout-btn { width: 42px; padding: 0; }
  .toolbar .input,
  .toolbar .input.wide,
  .toolbar select.input,
  .toolbar select.wide,
  .toolbar input.input.wide,
  .toolbar .search-select { width: calc(50% - 5px); }
  .toolbar .search-select-trigger.input,
  .toolbar .search-select-trigger.input.wide { width: 100%; }
  .toolbar-spacer { display: none; }
  .form-grid { grid-template-columns: 1fr; }
  .modal { padding: 20px 18px 18px; }
  .modal h3 { margin: -20px -18px 16px; padding-left: 32px; }
  .modal h3::before { left: 18px; }
  .modal-actions { margin: 16px -18px -18px; padding: 12px 18px; }
}

/* 新增线下订舱: the picked company has no agreement. */
.form-warn {
  margin: 0;
  padding: 9px 12px;
  border-radius: 8px;
  background: var(--amber-50);
  color: var(--amber);
  font-size: 13px;
  line-height: 1.5;
}

/* 订舱审核: 业务编码 column. */
.data-table td.business-code { color: var(--ink); font-weight: 700; letter-spacing: 0.04em; white-space: nowrap; }

/* 客户账号 new-account row: the picked company has no agreement in force. */
.draft-warn { display: block; margin-top: 4px; color: var(--amber); font-size: 12px; line-height: 1.4; white-space: normal; }

/* Company groups keep receipt details visually separate from the summary rows. */
.receipt-expand { font-weight: 700; text-align: left; }
.receipt-detail-row > td { padding: 16px 20px 12px; background: var(--slate-50, #f8fafc); }
.receipt-detail-row .data-table { background: #fff; }
.receipt-detail-row .pager { margin-top: 12px; }
