/* =========================================================
   供应商台账 — design tokens
   ========================================================= */
:root {
  color-scheme: light;
  --bg: #f3f4f0;
  --bg-soft: #e9ece5;
  --surface: #ffffff;
  --surface-2: #f7f8f5;
  --surface-3: #eef1eb;
  --ink: #17211b;
  --ink-2: #34433b;
  --muted: #69776f;
  --faint: #8c9890;
  --line: #e3e7df;
  --line-strong: #ced6cc;
  --primary: #176b52;
  --primary-strong: #0e523e;
  --primary-soft: #e2f2ea;
  --on-primary: #ffffff;
  --action: #1d2a22;
  --action-hover: #0f1a14;
  --on-action: #f7faf7;
  --credit: #9a5b16;
  --credit-soft: #fbf0df;
  --credit-line: #eed7b4;
  --prepaid: #0e6b5d;
  --prepaid-soft: #e0f2ee;
  --danger: #b23b35;
  --danger-soft: #fdecea;
  --danger-line: #f2ccc8;
  --radius-lg: 22px;
  --radius: 16px;
  --radius-sm: 11px;
  --radius-xs: 8px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: "SFMono-Regular", "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --duration: 160ms;
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #0d1310;
    --bg-soft: #111915;
    --surface: #141c18;
    --surface-2: #18221d;
    --surface-3: #1d2922;
    --ink: #e9f0eb;
    --ink-2: #c4d0c8;
    --muted: #94a299;
    --faint: #748179;
    --line: #243129;
    --line-strong: #35453b;
    --primary: #68cba7;
    --primary-strong: #94e2c3;
    --primary-soft: #173128;
    --on-primary: #092018;
    --action: #e3ebe5;
    --action-hover: #ccd8cf;
    --on-action: #0d1711;
    --credit: #e7b66d;
    --credit-soft: #322718;
    --credit-line: #4d3b21;
    --prepaid: #67cabc;
    --prepaid-soft: #112d29;
    --danger: #f08a83;
    --danger-soft: #371e1c;
    --danger-line: #52302d;
  }
}

/* =========================================================
   Reset & base
   ========================================================= */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

body.no-scroll {
  overflow: hidden;
}

h1, h2, h3, h4, p {
  margin: 0;
}

h1, h2, h3, h4 {
  line-height: 1.25;
  letter-spacing: -0.015em;
}

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

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
}

a {
  color: var(--primary);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

svg {
  display: block;
}

[hidden] {
  display: none !important;
}

::selection {
  background: var(--primary-soft);
  color: var(--primary-strong);
}

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

.shell {
  width: 100%;
  max-width: 1180px;
  margin: 0 auto;
  padding-left: 28px;
  padding-right: 28px;
}

.page {
  padding-top: 30px;
  padding-bottom: 80px;
  min-height: calc(100dvh - 64px);
}

.muted { color: var(--muted); }
.faint { color: var(--faint); }
.tnum { font-variant-numeric: tabular-nums; }
.nowrap { white-space: nowrap; }
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

.eyebrow {
  margin: 0 0 7px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

/* =========================================================
   Brand
   ========================================================= */
.brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  color: inherit;
  text-decoration: none;
}

.brand:hover {
  text-decoration: none;
}

.brand-mark {
  display: inline-flex;
  width: 36px;
  height: 36px;
  flex: 0 0 36px;
  align-items: center;
  justify-content: center;
  border-radius: 11px;
  background: var(--primary);
  color: var(--on-primary);
}

.brand-mark svg {
  width: 24px;
  height: 24px;
}

.brand-mark-lg {
  width: 46px;
  height: 46px;
  flex-basis: 46px;
  border-radius: 14px;
}

.brand-mark-lg svg {
  width: 30px;
  height: 30px;
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}

.brand-name {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.brand-kicker {
  margin-top: 3px;
  color: var(--faint);
  font-size: 9px;
  font-weight: 650;
  letter-spacing: 0.16em;
}

/* =========================================================
   Buttons
   ========================================================= */
.btn {
  display: inline-flex;
  min-height: 40px;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 0 15px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--ink);
  font-size: 14px;
  font-weight: 600;
  line-height: 1;
  text-decoration: none;
  white-space: nowrap;
  transition: background var(--duration) ease, border-color var(--duration) ease,
    color var(--duration) ease, transform var(--duration) ease;
}

.btn:hover {
  text-decoration: none;
}

.btn:active {
  transform: translateY(1px);
}

.btn svg {
  width: 17px;
  height: 17px;
}

.btn-primary {
  background: var(--action);
  color: var(--on-action);
}

.btn-primary:hover {
  background: var(--action-hover);
}

.btn-secondary {
  border-color: var(--line-strong);
  background: var(--surface);
  color: var(--ink-2);
}

.btn-secondary:hover {
  border-color: var(--faint);
  background: var(--surface-2);
}

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

.btn-ghost:hover {
  background: var(--surface-3);
  color: var(--ink);
}

.btn-danger {
  border-color: var(--danger-line);
  background: var(--danger-soft);
  color: var(--danger);
}

.btn-danger:hover {
  border-color: var(--danger);
}

.btn-solid-danger {
  background: var(--danger);
  color: #fff;
}

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

.btn-sm svg {
  width: 15px;
  height: 15px;
}

.btn-lg {
  min-height: 48px;
  padding: 0 20px;
  border-radius: 13px;
  font-size: 15px;
}

.btn-block {
  width: 100%;
}

.btn[aria-busy="true"] {
  pointer-events: none;
  opacity: 0.72;
}

.btn-spinner {
  width: 16px;
  height: 16px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

.icon-btn {
  display: inline-flex;
  width: 36px;
  height: 36px;
  flex: 0 0 36px;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  transition: background var(--duration) ease, color var(--duration) ease,
    border-color var(--duration) ease;
}

.icon-btn svg {
  width: 18px;
  height: 18px;
}

.icon-btn:hover {
  background: var(--surface-3);
  color: var(--ink);
}

.icon-btn.is-danger:hover {
  background: var(--danger-soft);
  color: var(--danger);
}

.icon-btn.sm {
  width: 31px;
  height: 31px;
  flex-basis: 31px;
  border-radius: 8px;
}

.icon-btn.sm svg {
  width: 16px;
  height: 16px;
}

.link-btn {
  padding: 0;
  border: 0;
  background: none;
  color: var(--primary);
  font-size: inherit;
  font-weight: 600;
}

.link-btn:hover {
  text-decoration: underline;
}

/* =========================================================
   Badges, avatars & money
   ========================================================= */
.badge {
  display: inline-flex;
  height: 24px;
  align-items: center;
  gap: 6px;
  padding: 0 9px;
  border-radius: 999px;
  background: var(--surface-3);
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 650;
  line-height: 1;
  white-space: nowrap;
}

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

.badge.no-dot::before {
  display: none;
}

.badge-credit {
  background: var(--credit-soft);
  color: var(--credit);
}

.badge-prepaid {
  background: var(--prepaid-soft);
  color: var(--prepaid);
}

.badge-ghost {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
}

.badge-ghost::before {
  display: none;
}

.account-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.avatar {
  display: inline-flex;
  width: 36px;
  height: 36px;
  flex: 0 0 36px;
  align-items: center;
  justify-content: center;
  border-radius: 11px;
  font-size: 14px;
  font-weight: 700;
}

.avatar-sm {
  width: 29px;
  height: 29px;
  flex-basis: 29px;
  border-radius: 9px;
  font-size: 12px;
}

.avatar.tone-0 { background: #e4f2ea; color: #176b52; }
.avatar.tone-1 { background: #f6eddd; color: #916020; }
.avatar.tone-2 { background: #e6edf7; color: #375d92; }
.avatar.tone-3 { background: #f1e7f4; color: #77518a; }
.avatar.tone-4 { background: #f7e8e4; color: #975248; }

@media (prefers-color-scheme: dark) {
  .avatar.tone-0 { background: #183229; color: #7ed8b3; }
  .avatar.tone-1 { background: #332819; color: #ebbd78; }
  .avatar.tone-2 { background: #1b2937; color: #8bb7eb; }
  .avatar.tone-3 { background: #2b2232; color: #c6a1d8; }
  .avatar.tone-4 { background: #332320; color: #e6a096; }
}

.money {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.money-large {
  font-size: 30px;
  font-weight: 700;
  letter-spacing: -0.03em;
}

.money-due { color: var(--credit); }
.money-positive { color: var(--prepaid); }
.money-negative { color: var(--danger); }
.money-neutral { color: var(--ink); }

.delta-positive { color: var(--prepaid); }
.delta-negative { color: var(--credit); }

/* =========================================================
   Boot screen
   ========================================================= */
.boot-screen {
  display: flex;
  min-height: 100vh;
  min-height: 100dvh;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 28px;
  background: var(--bg);
}

.boot-brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.boot-title {
  font-size: 18px;
  font-weight: 700;
}

.boot-sub {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

.boot-loader {
  width: 22px;
  height: 22px;
  padding: 3px;
  border: 2px solid var(--line-strong);
  border-radius: 50%;
}

.boot-loader span {
  display: block;
  width: 100%;
  height: 100%;
  border: 2px solid transparent;
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.noscript {
  position: fixed;
  inset: 0;
  z-index: 999;
  display: grid;
  place-items: center;
  background: var(--bg);
  color: var(--ink);
  font-size: 16px;
}

/* =========================================================
   Authentication
   ========================================================= */
.auth-page {
  position: relative;
  display: flex;
  min-height: 100vh;
  min-height: 100dvh;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 22px;
  padding: 42px 20px calc(28px + env(safe-area-inset-bottom));
  overflow: hidden;
  background: var(--bg);
}

.auth-bg {
  display: none;
}

.auth-card {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 430px;
  padding: 34px;
  border: 1px solid var(--line);
  border-radius: 26px;
  background: var(--surface);
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 30px;
}

.auth-head h1 {
  margin-bottom: 8px;
  font-size: 27px;
  font-weight: 720;
  letter-spacing: -0.03em;
}

.auth-head p {
  color: var(--muted);
  font-size: 13.5px;
  line-height: 1.6;
}

.auth-form {
  margin-top: 25px;
}

.auth-form .field + .field {
  margin-top: 15px;
}

.auth-form .btn-block {
  margin-top: 22px;
}

.auth-note {
  margin-top: 18px;
  padding-top: 17px;
  border-top: 1px solid var(--line);
  color: var(--faint);
  font-size: 12px;
  line-height: 1.6;
}

.auth-footer {
  position: relative;
  z-index: 1;
  color: var(--faint);
  font-size: 11.5px;
  letter-spacing: 0.02em;
  text-align: center;
}

.password-wrap {
  position: relative;
}

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

.password-toggle {
  position: absolute;
  top: 50%;
  right: 6px;
  transform: translateY(-50%);
}

/* =========================================================
   Forms
   ========================================================= */
.field {
  min-width: 0;
}

.field-label {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-bottom: 7px;
  color: var(--ink-2);
  font-size: 12.5px;
  font-weight: 650;
}

.req {
  color: var(--danger);
  font-weight: 600;
}

.field-hint {
  margin-top: 6px;
  color: var(--faint);
  font-size: 11.5px;
  line-height: 1.5;
}

.input,
.select,
.textarea {
  display: block;
  width: 100%;
  min-height: 44px;
  padding: 9px 12px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  outline: none;
  background: var(--surface);
  color: var(--ink);
  font-size: 16px;
  line-height: 1.4;
  transition: border-color var(--duration) ease,
    background var(--duration) ease;
}

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

.input:hover,
.select:hover,
.textarea:hover {
  border-color: var(--faint);
}

.input:focus,
.select:focus,
.textarea:focus {
  border-color: var(--primary);
  outline: 2px solid var(--primary);
  outline-offset: 1px;
}

.input:disabled,
.select:disabled,
.textarea:disabled {
  background: var(--surface-3);
  color: var(--muted);
}

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

.select {
  appearance: none;
  padding-right: 38px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2369776f' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
}

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

.form-grid .span-2 {
  grid-column: span 2;
}

.form-section {
  padding: 21px 0;
  border-top: 1px solid var(--line);
}

.form-section:first-child {
  padding-top: 0;
  border-top: 0;
}

.form-section:last-child {
  padding-bottom: 0;
}

.form-section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 15px;
}

.form-section-head h3 {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.form-section-head p {
  color: var(--faint);
  font-size: 11.5px;
}

.form-alert {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 16px;
  padding: 10px 12px;
  border: 1px solid var(--danger-line);
  border-radius: var(--radius-sm);
  background: var(--danger-soft);
  color: var(--danger);
  font-size: 12.5px;
  line-height: 1.5;
}

.form-alert svg {
  width: 16px;
  height: 16px;
  flex: 0 0 16px;
  margin-top: 1px;
}

.form-spacer { margin-top: 15px; }
.form-spacer-sm { margin-top: 13px; }
.fatal-action { margin-top: 22px; }

.form-note {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--muted);
  font-size: 11.5px;
  line-height: 1.55;
}

.form-note svg {
  width: 15px;
  height: 15px;
  flex: 0 0 15px;
  margin-top: 1px;
  color: var(--primary);
}

.input-affix {
  position: relative;
}

.input-affix .input {
  padding-left: 31px;
  font-variant-numeric: tabular-nums;
}

.input-affix-prefix {
  position: absolute;
  top: 50%;
  left: 12px;
  z-index: 1;
  transform: translateY(-50%);
  color: var(--faint);
  font-size: 13px;
  font-weight: 600;
  pointer-events: none;
}

.choice-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(92px, 1fr));
  gap: 8px;
}

.choice-option {
  position: relative;
  display: block;
}

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

.choice-option span {
  display: flex;
  min-height: 43px;
  align-items: center;
  justify-content: center;
  padding: 7px 11px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  text-align: center;
  transition: all var(--duration) ease;
}

.choice-option span:hover {
  border-color: var(--faint);
  color: var(--ink-2);
}

.choice-option input:checked + span {
  border-color: var(--primary);
  background: var(--primary-soft);
  color: var(--primary-strong);
}

.choice-option input:focus-visible + span {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

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

.choice-card {
  position: relative;
  display: block;
}

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

.choice-card > span {
  display: flex;
  min-height: 70px;
  flex-direction: column;
  justify-content: center;
  padding: 12px 13px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  transition: all var(--duration) ease;
}

.choice-card b {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--ink-2);
  font-size: 13px;
  font-weight: 700;
}

.choice-card small {
  margin-top: 3px;
  color: var(--faint);
  font-size: 11px;
  line-height: 1.4;
}

.choice-card input:checked + span {
  border-color: var(--primary);
  background: var(--primary-soft);
}

.choice-card input:checked + span b {
  color: var(--primary-strong);
}

.choice-card input:focus-visible + span {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.method-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(88px, 1fr));
  gap: 8px;
}

.method-option {
  position: relative;
  display: block;
}

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

.method-option span {
  display: flex;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  padding: 7px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 600;
  transition: all var(--duration) ease;
}

.method-option input:checked + span {
  border-color: var(--primary);
  background: var(--primary-soft);
  color: var(--primary-strong);
}

.method-option input:focus-visible + span {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.credential-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.credential-row {
  display: grid;
  grid-template-columns: 0.8fr 1.1fr 1.1fr 32px;
  gap: 9px;
  align-items: end;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}

.credential-row .field-label {
  font-size: 11.5px;
}

.credential-row .input {
  min-height: 40px;
  background: var(--surface);
  font-size: 15px;
}

.credential-row .icon-btn {
  margin-bottom: 2px;
}

.credential-add {
  margin-top: 10px;
}

.balance-preview {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 13px;
  padding: 12px 14px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}

.balance-preview div {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.balance-preview span {
  color: var(--faint);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.03em;
}

.balance-preview strong {
  font-size: 16px;
  font-variant-numeric: tabular-nums;
}

/* =========================================================
   Topbar
   ========================================================= */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  border-bottom: 1px solid var(--line);
  background: var(--bg);
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  padding-top: env(safe-area-inset-top);
  backdrop-filter: blur(18px) saturate(1.25);
  -webkit-backdrop-filter: blur(18px) saturate(1.25);
}

.topbar-inner {
  display: flex;
  height: 64px;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 7px;
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 3px 9px 3px 4px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
}

.user-avatar {
  display: inline-flex;
  width: 26px;
  height: 26px;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--primary-soft);
  color: var(--primary-strong);
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
}

.user-name {
  max-width: 130px;
  overflow: hidden;
  color: var(--ink-2);
  font-size: 12.5px;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* =========================================================
   Page head & stats
   ========================================================= */
.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 22px;
  margin-bottom: 24px;
}

.page-head h1 {
  font-size: 27px;
  font-weight: 720;
  letter-spacing: -0.035em;
}

.page-sub {
  margin-top: 6px;
  color: var(--muted);
  font-size: 13px;
}

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

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

.stat-card {
  position: relative;
  min-width: 0;
  padding: 17px 17px 15px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.stat-card::after {
  position: absolute;
  top: -38px;
  right: -28px;
  width: 102px;
  height: 102px;
  border-radius: 50%;
  background: var(--stat-soft, var(--surface-3));
  opacity: 0.6;
  content: "";
  pointer-events: none;
}

.stat-icon {
  position: absolute;
  top: 15px;
  right: 15px;
  z-index: 1;
  display: flex;
  width: 30px;
  height: 30px;
  align-items: center;
  justify-content: center;
  border-radius: 9px;
  background: var(--stat-soft, var(--surface-3));
  color: var(--stat-accent, var(--muted));
}

.stat-icon svg {
  width: 16px;
  height: 16px;
}

.stat-label {
  position: relative;
  z-index: 1;
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.stat-value {
  position: relative;
  z-index: 1;
  margin-top: 8px;
  overflow: hidden;
  font-size: 22px;
  font-weight: 720;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.03em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stat-foot {
  position: relative;
  z-index: 1;
  margin-top: 4px;
  color: var(--faint);
  font-size: 10.5px;
}

.stat-suppliers {
  --stat-accent: var(--primary);
  --stat-soft: var(--primary-soft);
}

.stat-credit {
  --stat-accent: var(--credit);
  --stat-soft: var(--credit-soft);
}

.stat-prepaid {
  --stat-accent: var(--prepaid);
  --stat-soft: var(--prepaid-soft);
}

.stat-settled {
  --stat-accent: var(--muted);
  --stat-soft: var(--surface-3);
}

/* =========================================================
   Toolbar
   ========================================================= */
.toolbar {
  display: flex;
  align-items: center;
  gap: 11px;
  margin: 22px 0 13px;
}

.search-box {
  position: relative;
  flex: 1 1 260px;
  max-width: 390px;
}

.search-box > svg {
  position: absolute;
  top: 50%;
  left: 13px;
  z-index: 1;
  width: 16px;
  height: 16px;
  transform: translateY(-50%);
  color: var(--faint);
  pointer-events: none;
}

.search-box .input {
  min-height: 40px;
  padding-left: 39px;
  padding-right: 38px;
  border-color: var(--line);
  background: var(--surface);
  font-size: 14px;
}

.search-box input[type="search"]::-webkit-search-cancel-button,
.search-box input[type="search"]::-webkit-search-decoration {
  -webkit-appearance: none;
  appearance: none;
}

.search-clear {
  position: absolute;
  top: 50%;
  right: 5px;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 0;
  border-radius: 7px;
  transform: translateY(-50%);
  background: transparent;
  color: var(--faint);
}

.search-clear:hover {
  background: var(--surface-3);
  color: var(--ink);
}

.search-clear svg {
  width: 14px;
  height: 14px;
}

.segmented {
  display: inline-flex;
  gap: 2px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--surface-2);
}

.segmented button {
  display: inline-flex;
  min-height: 32px;
  align-items: center;
  gap: 5px;
  padding: 0 12px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 600;
  white-space: nowrap;
  transition: all var(--duration) ease;
}

.segmented button:hover {
  color: var(--ink);
}

.segmented button.active {
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink);
}

.toolbar-spacer {
  flex: 1;
}

.result-note {
  color: var(--faint);
  font-size: 11.5px;
  white-space: nowrap;
}

/* =========================================================
   Supplier list
   ========================================================= */
.table-card {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

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

.data-table th {
  padding: 11px 18px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--muted);
  font-size: 11px;
  font-weight: 650;
  letter-spacing: 0.04em;
  text-align: left;
  white-space: nowrap;
}

.data-table td {
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  color: var(--ink-2);
  font-size: 13px;
  vertical-align: middle;
}

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

.data-table tbody tr.clickable {
  cursor: pointer;
  transition: background var(--duration) ease;
}

.data-table tbody tr.clickable:hover {
  background: var(--surface-2);
}

.data-table tbody tr.clickable:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: -2px;
}

.data-table .align-right {
  text-align: right;
}

.supplier-cell {
  display: flex;
  min-width: 190px;
  align-items: center;
  gap: 11px;
}

.supplier-cell-text {
  min-width: 0;
}

.supplier-name {
  overflow: hidden;
  color: var(--ink);
  font-size: 13.5px;
  font-weight: 650;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.supplier-sub {
  display: flex;
  align-items: center;
  gap: 5px;
  max-width: 260px;
  margin-top: 2px;
  overflow: hidden;
  color: var(--faint);
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.supplier-sub svg {
  width: 11px;
  height: 11px;
  flex: 0 0 11px;
}

.cell-money {
  color: var(--ink);
  font-size: 13.5px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.cell-money.zero {
  color: var(--faint);
  font-weight: 500;
}

.cell-sub {
  margin-top: 2px;
  color: var(--faint);
  font-size: 10.5px;
  font-variant-numeric: tabular-nums;
}

.row-arrow {
  color: var(--faint);
}

.row-arrow svg {
  width: 16px;
  height: 16px;
}

.supplier-mobile-list {
  display: none;
  flex-direction: column;
  gap: 10px;
}

.supplier-mobile-card {
  padding: 15px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  cursor: pointer;
  transition: border-color var(--duration) ease, transform var(--duration) ease;
}

.supplier-mobile-card:active {
  border-color: var(--line-strong);
  transform: scale(0.995);
}

.supplier-mobile-card:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.smc-head {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.smc-head .supplier-cell {
  min-width: 0;
  flex: 1;
}

.smc-head .supplier-sub {
  max-width: none;
}

.smc-head .badge {
  flex: 0 0 auto;
}

.smc-metrics {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 13px;
  padding: 11px 12px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}

.smc-metrics div {
  min-width: 0;
}

.smc-metrics span {
  display: block;
  color: var(--faint);
  font-size: 10.5px;
}

.smc-metrics strong {
  display: block;
  margin-top: 2px;
  overflow: hidden;
  font-size: 15px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.smc-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 11px;
  color: var(--faint);
  font-size: 10.5px;
}

.smc-foot span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* =========================================================
   Empty / error / loading
   ========================================================= */
.detail-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 320px;
  color: var(--muted);
  font-size: 13px;
}
.empty-state {
  display: flex;
  align-items: center;
  flex-direction: column;
  padding: 64px 24px;
  text-align: center;
}

.empty-icon {
  display: flex;
  width: 54px;
  height: 54px;
  align-items: center;
  justify-content: center;
  margin-bottom: 16px;
  border: 1px solid var(--line);
  border-radius: 17px;
  background: var(--surface-2);
  color: var(--muted);
}

.empty-icon svg {
  width: 24px;
  height: 24px;
}

.empty-state h3 {
  margin-bottom: 6px;
  font-size: 16px;
  font-weight: 680;
}

.empty-state p {
  max-width: 360px;
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.65;
}

.empty-state .btn {
  margin-top: 18px;
}

.empty-state.compact {
  padding: 42px 20px;
}

.empty-state.compact .empty-icon {
  width: 44px;
  height: 44px;
  border-radius: 13px;
}

.empty-state.compact .empty-icon svg {
  width: 20px;
  height: 20px;
}

.empty-state.compact h3 {
  font-size: 14px;
}

.error-state {
  display: flex;
  align-items: center;
  flex-direction: column;
  padding: 70px 24px;
  text-align: center;
}

.error-state .empty-icon {
  color: var(--danger);
  background: var(--danger-soft);
  border-color: var(--danger-line);
}

.error-state h2 {
  margin-bottom: 6px;
  font-size: 18px;
}

.error-state p {
  color: var(--muted);
  font-size: 13px;
}

.error-state .btn {
  margin-top: 18px;
}

.skeleton-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 18px;
  border-bottom: 1px solid var(--line);
}

.skeleton-row:last-child {
  border-bottom: 0;
}

.skeleton {
  border-radius: 6px;
  background: var(--surface-3);
  animation: skeleton-pulse 1.5s ease-in-out infinite;
}

.skeleton-circle {
  width: 36px;
  height: 36px;
  flex: 0 0 36px;
  border-radius: 11px;
}

.skeleton-line {
  height: 10px;
}

.skeleton-lines {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 7px;
}

@keyframes skeleton-pulse {
  0%, 100% { opacity: 0.55; }
  50% { opacity: 1; }
}

.inline-spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid var(--line-strong);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

/* =========================================================
   Detail
   ========================================================= */
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-bottom: 18px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  text-decoration: none;
}

.back-link:hover {
  color: var(--ink);
  text-decoration: none;
}

.back-link svg {
  width: 15px;
  height: 15px;
}

.detail-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 24px;
}

.detail-title-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 9px;
}

.detail-head h1 {
  font-size: 28px;
  font-weight: 720;
  letter-spacing: -0.035em;
}

.detail-sub {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 14px;
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
}

.detail-sub-item {
  display: inline-flex;
  min-width: 0;
  max-width: 100%;
  align-items: center;
  gap: 5px;
  overflow-wrap: anywhere;
}

.detail-sub-item svg {
  width: 14px;
  height: 14px;
  color: var(--faint);
}

.detail-sub a {
  display: inline-flex;
  min-width: 0;
  align-items: center;
  gap: 4px;
  color: var(--muted);
  overflow-wrap: anywhere;
  text-decoration: none;
}

.detail-sub a:hover {
  color: var(--primary);
  text-decoration: none;
}

.detail-sub a svg {
  width: 12px;
  height: 12px;
}

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

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

.balance-card {
  position: relative;
  min-width: 0;
  padding: 21px 22px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
}

.balance-card::after {
  position: absolute;
  top: -70px;
  right: -50px;
  width: 180px;
  height: 180px;
  border-radius: 50%;
  background: var(--balance-soft, var(--surface-2));
  opacity: 0.65;
  content: "";
  pointer-events: none;
}

.balance-card.credit {
  --balance-accent: var(--credit);
  --balance-soft: var(--credit-soft);
}

.balance-card.prepaid {
  --balance-accent: var(--prepaid);
  --balance-soft: var(--prepaid-soft);
}

.balance-head {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.balance-label {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

.balance-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--balance-accent);
}

.balance-hint {
  color: var(--faint);
  font-size: 10.5px;
}

.balance-value {
  position: relative;
  z-index: 1;
  margin-top: 13px;
  overflow: hidden;
  color: var(--balance-accent);
  font-size: 32px;
  font-weight: 730;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.045em;
  line-height: 1.1;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.balance-value.is-negative {
  color: var(--muted);
}

.balance-note {
  position: relative;
  z-index: 1;
  margin-top: 10px;
  color: var(--faint);
  font-size: 10.5px;
  line-height: 1.6;
}

.balance-value.is-zero {
  color: var(--faint);
}

.balance-secondary {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-top: 9px;
  padding: 7px 10px;
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 11px;
}

.balance-secondary b {
  color: var(--ink-2);
  font-size: 13.5px;
  font-variant-numeric: tabular-nums;
  font-weight: 650;
  white-space: nowrap;
}

.overview-bar {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-bottom: 13px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.overview-item {
  min-width: 0;
  padding: 14px 18px;
  border-left: 1px solid var(--line);
}

.overview-item:first-child {
  border-left: 0;
}

.overview-item > span {
  display: block;
  color: var(--faint);
  font-size: 10.5px;
  font-weight: 600;
}

.overview-item strong {
  display: block;
  margin-top: 4px;
  overflow: hidden;
  color: var(--ink);
  font-size: 18px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.overview-item small {
  display: block;
  margin-top: 3px;
  color: var(--faint);
  font-size: 10px;
  overflow-wrap: anywhere;
}

.balance-breakdown {
  position: relative;
  z-index: 1;
  display: flex;
  flex-wrap: wrap;
  gap: 5px 12px;
  margin-top: 11px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 10.5px;
}

.balance-breakdown span {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.balance-breakdown b {
  color: var(--ink-2);
  font-weight: 600;
}

.detail-grid {
  --detail-panel-height: 360px;
  display: grid;
  align-items: stretch;
  grid-template-columns: minmax(0, 0.95fr) minmax(0, 1.05fr);
  gap: 13px;
  margin-bottom: 13px;
}

.detail-grid > .panel {
  display: flex;
  min-height: 0;
  height: var(--detail-panel-height);
  flex-direction: column;
  overflow: hidden;
}

.detail-grid > .panel .panel-head {
  flex: 0 0 auto;
}

.detail-grid > .panel .panel-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: var(--line-strong) transparent;
}

.detail-grid > .panel .panel-body::-webkit-scrollbar {
  width: 6px;
}

.detail-grid > .panel .panel-body::-webkit-scrollbar-thumb {
  border-radius: 3px;
  background: var(--line-strong);
}

.detail-grid > .panel .panel-body::-webkit-scrollbar-track {
  background: transparent;
}

.quick-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 13px;
}

.quick-actions .btn {
  min-width: 148px;
}

.panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 20px 0;
}

.panel-head h2 {
  font-size: 14px;
  font-weight: 700;
}

.panel-head p {
  margin-top: 3px;
  color: var(--faint);
  font-size: 10.5px;
}

.panel-body {
  padding: 17px 20px 20px;
}

.info-list {
  display: flex;
  flex-direction: column;
}

.info-row {
  display: grid;
  grid-template-columns: 82px minmax(0, 1fr);
  gap: 12px;
  padding: 9px 0;
  border-top: 1px solid var(--line);
  font-size: 12.5px;
}

.info-row:first-child {
  padding-top: 0;
  border-top: 0;
}

.info-row dt {
  color: var(--faint);
}

.info-row dd {
  margin: 0;
  color: var(--ink-2);
  overflow-wrap: anywhere;
}

.info-row dd a {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--primary);
}

.info-row dd a svg {
  width: 12px;
  height: 12px;
}

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

.contact-chip {
  display: inline-flex;
  min-width: 0;
  max-width: 100%;
  align-items: center;
  gap: 5px;
  padding: 4px 8px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface-2);
  color: var(--ink-2);
  font-size: 11px;
  overflow-wrap: anywhere;
}

.contact-chip svg {
  width: 12px;
  height: 12px;
  flex: 0 0 12px;
  color: var(--faint);
}

.contact-chip.empty {
  color: var(--faint);
  background: transparent;
}

.credential-items {
  display: flex;
  flex-direction: column;
}

.credential-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 0;
  border-top: 1px solid var(--line);
}

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

.credential-avatar {
  display: flex;
  width: 32px;
  height: 32px;
  flex: 0 0 32px;
  align-items: center;
  justify-content: center;
  border-radius: 9px;
  background: var(--surface-2);
  color: var(--muted);
}

.credential-avatar svg {
  width: 15px;
  height: 15px;
}

.credential-info {
  min-width: 0;
  flex: 1;
}

.credential-label {
  display: flex;
  align-items: center;
  gap: 6px;
  overflow: hidden;
  color: var(--ink);
  font-size: 12.5px;
  font-weight: 650;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.credential-username {
  margin-top: 1px;
  overflow-wrap: anywhere;
  color: var(--faint);
  font-size: 11px;
  line-height: 1.45;
}

.credential-secret {
  display: flex;
  min-width: 0;
  max-width: 180px;
  align-items: center;
  gap: 5px;
}

.secret-value {
  min-width: 0;
  overflow: hidden;
  padding: 3px 7px;
  border-radius: 6px;
  background: var(--surface-2);
  color: var(--muted);
  font-family: var(--mono);
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.secret-value.revealed {
  max-width: 100%;
  background: var(--primary-soft);
  color: var(--primary-strong);
  overflow-wrap: anywhere;
  white-space: normal;
}

.credential-actions {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 1px;
}

.credential-actions .icon-btn {
  width: 29px;
  height: 29px;
  flex-basis: 29px;
  border-radius: 7px;
}

.credential-actions .icon-btn svg {
  width: 15px;
  height: 15px;
}

.panel-empty {
  padding: 25px 10px;
  color: var(--faint);
  font-size: 12px;
  text-align: center;
}

/* =========================================================
   Ledger
   ========================================================= */
.ledger-panel {
  overflow: hidden;
}

.ledger-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 18px 20px 14px;
}

.ledger-head h2 {
  font-size: 14px;
  font-weight: 700;
}

.ledger-head p {
  margin-top: 3px;
  color: var(--faint);
  font-size: 10.5px;
}

.ledger-body {
  padding: 0 20px 20px;
}

.ledger-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 0 13px;
  border-top: 1px solid var(--line);
}

.ledger-toolbar .segmented button {
  min-height: 30px;
  padding: 0 10px;
  font-size: 11.5px;
}

.tab-count {
  display: inline-flex;
  min-width: 18px;
  height: 18px;
  align-items: center;
  justify-content: center;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--surface-3);
  color: var(--faint);
  font-size: 10px;
  font-variant-numeric: tabular-nums;
  font-weight: 650;
}

.segmented button.active .tab-count {
  background: var(--primary-soft);
  color: var(--primary-strong);
}

.note-cell {
  display: inline-block;
  max-width: 150px;
  overflow: hidden;
  text-overflow: ellipsis;
  vertical-align: middle;
  white-space: nowrap;
}

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

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

.ledger-table {
  width: 100%;
  min-width: 690px;
  border-collapse: collapse;
}

.ledger-table-wide {
  min-width: 900px;
}

.ledger-table th {
  padding: 9px 12px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--faint);
  font-size: 10px;
  font-weight: 650;
  letter-spacing: 0.04em;
  text-align: left;
  white-space: nowrap;
}

.ledger-table td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--line);
  color: var(--ink-2);
  font-size: 11.5px;
  vertical-align: middle;
}

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

.ledger-table .align-right {
  text-align: right;
}

.ledger-table .amount {
  color: var(--ink);
  font-size: 12px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.ledger-table .muted-cell {
  color: var(--faint);
  font-size: 10.5px;
}

.ledger-mobile-list {
  display: none;
  flex-direction: column;
  gap: 8px;
}

.ledger-mobile-item {
  padding: 12px 13px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
}

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

.lmi-amount {
  font-size: 14px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.lmi-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
  margin-top: 6px;
  color: var(--faint);
  font-size: 10.5px;
  overflow-wrap: anywhere;
}

.lmi-meta b {
  color: var(--ink-2);
  font-weight: 600;
}

.lmi-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  margin-top: 4px;
}

.ledger-note {
  margin-top: 12px;
  color: var(--faint);
  font-size: 10.5px;
  line-height: 1.6;
}

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

.file-pick {
  display: flex;
  width: 100%;
  align-items: center;
  gap: 11px;
  padding: 12px 13px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--muted);
  text-align: left;
  transition: border-color var(--duration) ease, color var(--duration) ease;
}

.file-pick:hover {
  border-color: var(--primary);
  color: var(--ink);
}

.file-pick > svg {
  flex: 0 0 auto;
  color: var(--primary);
}

.file-pick span {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 2px;
}

.file-pick b {
  overflow: hidden;
  color: var(--ink-2);
  font-size: 12.5px;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-pick small {
  color: var(--faint);
  font-size: 10.5px;
}

.file-preview {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 9px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-2);
}

.file-preview img {
  width: 58px;
  height: 58px;
  flex: 0 0 58px;
  border-radius: 7px;
  border: 1px solid var(--line);
  object-fit: cover;
}

.file-preview span {
  min-width: 0;
  color: var(--muted);
  font-size: 10.5px;
  overflow-wrap: anywhere;
}

.screenshot-summary {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 14px;
  padding: 13px 15px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--muted);
  font-size: 11.5px;
}

.screenshot-amount {
  color: var(--ink);
  font-size: 20px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}

.screenshot-frame {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  text-align: center;
}

.receipt-image {
  display: block;
  width: auto;
  max-width: 100%;
  max-height: 62vh;
  height: auto;
  margin: 0 auto;
  object-fit: contain;
}

.screenshot-error {
  padding: 46px 20px;
  color: var(--danger);
  font-size: 13px;
  text-align: center;
}

/* =========================================================
   Modal
   ========================================================= */
dialog.modal {
  max-width: 680px;
  width: calc(100% - 36px);
  max-height: min(88vh, 900px);
  max-height: min(88dvh, 900px);
  margin: auto;
  padding: 0;
  overflow: hidden;
  border: 0;
  border-radius: 22px;
  background: transparent;
  color: var(--ink);
}

dialog.modal.wide {
  max-width: 790px;
}

dialog.modal::backdrop {
  background: rgba(7, 15, 11, 0.56);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
}

dialog.modal[open] {
  animation: modal-in 180ms ease-out;
}

@keyframes modal-in {
  from { opacity: 0; transform: translateY(8px) scale(0.985); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-card {
  display: flex;
  max-height: min(88vh, 900px);
  max-height: min(88dvh, 900px);
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--surface);
}

.modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  padding: 21px 23px 16px;
  border-bottom: 1px solid var(--line);
}

.modal-head h2 {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.modal-head p {
  margin-top: 4px;
  color: var(--muted);
  font-size: 11.5px;
  line-height: 1.55;
}

.modal-close {
  margin: -4px -6px 0 0;
  flex: 0 0 34px;
  width: 34px;
  height: 34px;
}

.modal-scroll {
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 20px 23px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 15px 23px calc(17px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: var(--surface);
}

.modal-actions .btn {
  min-width: 88px;
}

.modal-lead {
  display: flex;
  align-items: center;
  gap: 11px;
  margin-bottom: 19px;
  padding: 13px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}

.modal-lead .supplier-name {
  font-size: 13px;
}

.modal-lead .supplier-sub {
  max-width: none;
  margin-top: 1px;
  overflow: visible;
  white-space: normal;
}

.confirm-icon {
  display: flex;
  width: 44px;
  height: 44px;
  align-items: center;
  justify-content: center;
  margin-bottom: 14px;
  border-radius: 13px;
  background: var(--danger-soft);
  color: var(--danger);
}

.confirm-icon svg {
  width: 21px;
  height: 21px;
}

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

.confirm-text strong {
  color: var(--ink);
}

.auto-time {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--faint);
  font-size: 10.5px;
}

.auto-time svg {
  width: 12px;
  height: 12px;
}

/* =========================================================
   Toasts
   ========================================================= */
.toast-region {
  position: fixed;
  top: calc(74px + env(safe-area-inset-top));
  right: 22px;
  z-index: 120;
  display: flex;
  width: min(360px, calc(100vw - 32px));
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  padding: 11px 13px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  color: var(--ink-2);
  font-size: 12px;
  line-height: 1.5;
  animation: toast-in 180ms ease-out;
}

.toast svg {
  width: 16px;
  height: 16px;
  flex: 0 0 16px;
  margin-top: 1px;
}

.toast.success svg { color: var(--prepaid); }
.toast.error svg { color: var(--danger); }
.toast.info svg { color: var(--primary); }

.toast.leaving {
  animation: toast-out 160ms ease-in forwards;
}

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

@keyframes toast-out {
  to { opacity: 0; transform: translateY(-4px); }
}

/* =========================================================
   Responsive
   ========================================================= */
@media (max-width: 1000px) {
  .stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .detail-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 860px) {
  .detail-grid {
    --detail-panel-height: 400px;
  }

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

  .quick-actions .btn {
    width: 100%;
    min-width: 0;
  }

  .quick-actions .btn:last-child {
    grid-column: span 2;
  }
}

@media (max-width: 860px) {
  .shell {
    padding-left: 16px;
    padding-right: 16px;
  }

  .page {
    padding-top: 22px;
    padding-bottom: calc(56px + env(safe-area-inset-bottom));
  }

  .btn {
    min-height: 44px;
  }

  .btn-sm {
    min-height: 38px;
  }

  .icon-btn {
    width: 40px;
    height: 40px;
    flex-basis: 40px;
  }

  .icon-btn.sm {
    width: 36px;
    height: 36px;
    flex-basis: 36px;
  }

  .segmented button {
    min-height: 38px;
  }

  .ledger-toolbar .segmented button {
    min-height: 34px;
  }

  .search-clear {
    width: 32px;
    height: 32px;
  }

  .credential-actions .icon-btn {
    width: 36px;
    height: 36px;
    flex-basis: 36px;
  }

  .topbar-inner {
    height: 58px;
  }

  .page-head {
    align-items: stretch;
    flex-direction: column;
    gap: 15px;
    margin-bottom: 19px;
  }

  .page-head h1 {
    font-size: 24px;
  }

  .page-actions {
    width: 100%;
  }

  .page-actions .btn {
    flex: 1;
  }

  .toolbar {
    flex-wrap: wrap;
    gap: 9px;
    margin-top: 18px;
  }

  .search-box {
    max-width: none;
    flex-basis: 100%;
  }

  .search-box .input {
    min-height: 44px;
  }

  .toolbar-spacer {
    display: none;
  }

  .result-note {
    margin-left: auto;
    align-self: center;
  }

  .desktop-only {
    display: none !important;
  }

  .table-card {
    border: 0;
    background: transparent;
  }

  .supplier-mobile-list {
    display: flex;
  }

  .balance-grid {
    grid-template-columns: 1fr;
  }

  .overview-bar {
    grid-template-columns: 1fr;
  }

  .overview-item {
    border-top: 1px solid var(--line);
    border-left: 0;
  }

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

  .balance-value {
    font-size: 30px;
  }

  .detail-head {
    flex-direction: column;
    gap: 14px;
    margin-bottom: 19px;
  }

  .detail-head h1 {
    font-size: 24px;
  }

  .detail-actions {
    width: 100%;
  }

  .detail-actions .btn {
    flex: 1;
  }

  .detail-sub {
    margin-top: 7px;
  }

  .ledger-head {
    padding: 16px 16px 12px;
  }

  .ledger-body {
    padding: 0 16px 16px;
  }

  .ledger-toolbar {
    align-items: stretch;
    flex-direction: column;
    gap: 9px;
  }

  .ledger-toolbar .segmented {
    align-self: flex-start;
  }

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

  .ledger-table-wrap {
    display: none;
  }

  .ledger-mobile-list {
    display: flex;
  }

  .panel-head {
    padding: 16px 16px 0;
  }

  .panel-body {
    padding: 14px 16px 17px;
  }

  .credential-item {
    flex-wrap: wrap;
  }

  .credential-secret {
    order: 4;
    max-width: calc(100% - 42px);
    margin-left: 42px;
  }

  .credential-actions {
    margin-left: auto;
  }

  .toast-region {
    top: auto;
    right: 16px;
    bottom: calc(18px + env(safe-area-inset-bottom));
    left: 16px;
    width: auto;
    align-items: center;
  }

  .toast {
    width: 100%;
    max-width: 430px;
  }

  dialog.modal,
  dialog.modal.wide {
    width: 100%;
    max-width: none;
    max-height: 92vh;
    max-height: 92dvh;
    margin: auto 0 0;
    border-radius: 22px 22px 0 0;
  }

  dialog.modal[open] {
    animation: sheet-in 220ms ease-out;
  }

  @keyframes sheet-in {
    from { opacity: 0.7; transform: translateY(36px); }
    to { opacity: 1; transform: translateY(0); }
  }

  .modal-card {
    max-height: 92vh;
    max-height: 92dvh;
    border-radius: 22px 22px 0 0;
  }

  .modal-head {
    padding: 18px 18px 14px;
  }

  .modal-scroll {
    padding: 17px 18px;
  }

  .modal-actions {
    padding: 12px 18px calc(14px + env(safe-area-inset-bottom));
  }

  .modal-actions .btn {
    flex: 1;
  }

  .form-grid {
    grid-template-columns: 1fr;
    gap: 13px;
  }

  /* Keep every form control at 16px on phones: iOS Safari zooms otherwise. */
  .input,
  .select,
  .textarea,
  .search-box .input,
  .credential-row .input {
    font-size: 16px;
  }

  .form-grid .span-2 {
    grid-column: auto;
  }

  .credential-row {
    grid-template-columns: 1fr 1fr;
    align-items: start;
  }

  .credential-row .field:first-child {
    grid-column: span 2;
  }

  .credential-row .icon-btn {
    grid-column: span 2;
    justify-self: end;
    margin-top: -2px;
  }

  .form-section {
    padding: 18px 0;
  }

  .form-section-head {
    align-items: flex-start;
    flex-direction: column;
    gap: 3px;
  }

  .auth-card {
    padding: 26px 22px;
    border-radius: 22px;
  }

  .auth-head h1 {
    font-size: 24px;
  }

  .stat-value {
    font-size: 20px;
  }

  .info-row {
    grid-template-columns: 76px minmax(0, 1fr);
  }

  .balance-card {
    padding: 19px 18px;
  }
}

@media (max-width: 560px) {
  .brand-kicker {
    display: none;
  }

  .brand-name {
    font-size: 14px;
  }

  .user-name {
    display: none;
  }

  .user-chip {
    padding-right: 4px;
    border: 0;
    background: transparent;
  }

  .stats-grid {
    gap: 9px;
  }

  .stat-card {
    padding: 14px 13px 12px;
    border-radius: 14px;
  }

  .stat-icon {
    top: 12px;
    right: 11px;
    width: 26px;
    height: 26px;
    border-radius: 8px;
  }

  .stat-icon svg {
    width: 14px;
    height: 14px;
  }

  .stat-label {
    padding-right: 24px;
    font-size: 10.5px;
  }

  .stat-value {
    margin-top: 6px;
    font-size: clamp(13.5px, 4.5vw, 18px);
  }

  .smc-metrics strong {
    font-size: clamp(12.5px, 3.9vw, 15px);
  }

  .stat-foot {
    font-size: 9.5px;
  }

  .segmented {
    width: 100%;
  }

  .segmented button {
    flex: 1;
    justify-content: center;
    padding: 0 8px;
  }

  .result-note {
    display: none;
  }

  .balance-value {
    font-size: clamp(21px, 7vw, 27px);
  }

  .balance-breakdown {
    gap: 4px 9px;
  }

  .detail-actions {
    flex-wrap: wrap;
  }

  .empty-state {
    padding: 46px 16px;
  }

  .toast-region {
    right: 12px;
    left: 12px;
  }

  .modal-head h2 {
    font-size: 17px;
  }

  .modal-head p {
    font-size: 11px;
  }

  .choice-cards {
    grid-template-columns: 1fr;
  }

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

  .balance-preview {
    grid-template-columns: 1fr;
    gap: 7px;
  }

  .info-row {
    grid-template-columns: 1fr;
    gap: 2px;
    padding: 8px 0;
  }

  .credential-secret {
    margin-left: 0;
    max-width: 100%;
    order: 5;
    width: 100%;
  }

  .credential-actions {
    order: 4;
  }

  .ledger-actions .btn {
    flex: 1;
  }

  .ledger-toolbar .segmented button {
    padding: 0 6px;
  }

  .auth-page {
    padding-top: 28px;
  }

  .auth-card {
    padding: 24px 18px;
  }
}

@media (hover: none) {
  .supplier-mobile-card:hover {
    transform: none;
  }
}

@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;
  }
}
