/* Reference mobile workspace. Loaded last so legacy desktop contracts stay intact. */
:root {
  --primary: #f58220;
  --primary-dark: #d95f02;
  --primary-soft: #fff3e7;
  --reference-orange: #f58220;
  --reference-orange-dark: #e66d0b;
  --reference-ink: #262626;
  --reference-muted: #8a8f99;
  --reference-line: #f0f1f3;
}

.agent-body { color: var(--reference-ink); background: #f7f8fa; }
.agent-main .nav-icon { color: var(--primary); }
.home-wallet-link { display: flex; align-items: center; justify-content: space-between; padding: 13px 16px; color: var(--primary-dark); background: #fff; border: 1px solid var(--line); border-radius: 12px; }
.home-order-workspace { min-width: 0; }
.home-payout-metric small { display: block; }

.profile-card { background: linear-gradient(135deg, #ff9b42, var(--reference-orange) 58%, var(--reference-orange-dark)); }
.profile-avatar { color: var(--primary); background: #fff; border: 3px solid rgba(255, 255, 255, 0.42); border-radius: 50%; }
.profile-card .badge { color: #fff; background: rgba(255, 255, 255, 0.18); }
.profile-main p, .profile-stats span { color: rgba(255, 255, 255, 0.82); }
.profile-stats { border-color: rgba(255, 255, 255, 0.26); }
.profile-balance-main { display: grid; gap: 7px; }
.profile-balance-main > span, .profile-balance-main small { color: var(--text-soft); }
.profile-balance-main > strong { color: var(--primary-dark); font-size: 32px; line-height: 1.2; overflow-wrap: anywhere; }
.profile-profit-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); margin-top: 20px; padding-top: 18px; border-top: 1px solid var(--reference-line); }
.profile-profit-grid > div { display: grid; gap: 7px; }
.profile-profit-grid > div + div { padding-left: 20px; border-left: 1px solid var(--reference-line); }
.profile-profit-grid span { color: var(--text-soft); font-size: 12px; }
.profile-profit-grid strong { color: #333; font-size: 18px; overflow-wrap: anywhere; }
.profile-more-metrics { margin-top: 16px; border-top: 1px solid var(--reference-line); }
.profile-more-metrics summary { padding-top: 14px; color: var(--primary-dark); cursor: pointer; }
.profile-more-metrics .metric-grid { margin-top: 14px; }
.profile-assets > p { margin-bottom: 0; color: var(--text-soft); font-size: 11px; }

.menu-section { overflow: hidden; background: #fff; border: 1px solid var(--reference-line); border-radius: 16px; }
.menu-section > h2 { margin: 0; padding: 16px 16px 8px; color: var(--text-soft); font-size: 12px; }
.menu-section > a { display: grid; min-height: 64px; grid-template-columns: auto 1fr auto; gap: 12px; align-items: center; padding: 13px 16px; color: var(--text); border-bottom: 1px solid var(--reference-line); }
.menu-section > a:last-child { border-bottom: 0; }
.menu-section > a > i, .business-entry-list > a > i { display: inline-flex; width: 40px; height: 40px; align-items: center; justify-content: center; color: var(--primary); background: var(--primary-soft); border-radius: 12px; font-style: normal; }
.menu-section > a > span { display: grid; gap: 4px; font-weight: 600; }
.menu-section small { display: block; color: var(--text-soft); font-size: 11px; font-weight: 400; line-height: 1.5; }
.menu-section > a > b, .business-entry-list > a > b, .record-link-list > a > b { color: #b7bbc2; font-size: 22px; font-weight: 400; }
.profile-secondary-menu { margin-top: 14px; }
.profile-secondary-menu .menu-section > a { grid-template-columns: 1fr auto; }
.profile-secondary-menu .menu-section > a::before { width: 7px; height: 7px; grid-column: 1; content: ""; }

.wallet-reconciliation-details { margin: 16px 0 24px; }
.wallet-reconciliation-details > summary { padding: 16px; color: var(--primary-dark); background: #fff; border: 1px solid var(--line); border-radius: 14px; cursor: pointer; font-weight: 600; }
.wallet-reconciliation-details > summary small { display: block; margin-top: 5px; color: var(--text-soft); font-weight: 400; }
.wallet-reconciliation-details[open] > summary { margin-bottom: 12px; }

.business-entry-list { display: grid; gap: 10px; margin: 18px 0 24px; }
.business-entry-list > a { display: grid; grid-template-columns: auto 1fr auto; gap: 13px; align-items: center; padding: 17px 16px; color: var(--text); background: #fff; border: 1px solid var(--reference-line); border-radius: 16px; }
.business-entry-list > a > span { display: grid; gap: 5px; }
.business-entry-list small { color: var(--text-soft); font-size: 12px; line-height: 1.55; }
.record-link-list { overflow: hidden; background: #fff; border: 1px solid var(--reference-line); border-radius: 16px; }
.record-link-list > a { display: flex; align-items: center; justify-content: space-between; min-height: 56px; padding: 14px 16px; color: var(--text); border-bottom: 1px solid var(--reference-line); }
.record-link-list > a:last-child { border-bottom: 0; }

.pledge-unavailable { display: grid; justify-items: center; padding: 36px 24px; text-align: center; }
.pledge-unavailable > i { display: inline-flex; width: 58px; height: 58px; align-items: center; justify-content: center; color: var(--primary); background: var(--primary-soft); border-radius: 50%; }
.pledge-unavailable > i .nav-icon { width: 30px; height: 30px; }
.pledge-unavailable > span { margin-top: 20px; color: var(--text-soft); }
.pledge-unavailable > strong { margin: 8px 0 20px; color: #333; font-size: 34px; }
.pledge-unavailable > h2 { margin: 0 0 10px; font-size: 18px; }
.pledge-unavailable > p { max-width: 480px; margin: 0; color: var(--text-soft); }

.preview-ledger-boundary { border-color: #f6d4b5; }
.preview-ledger-boundary code { color: #93440d; font-family: inherit; overflow-wrap: anywhere; }
.credit-transfer-create-panel { padding: 20px; }
.credit-transfer-filter { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)) auto; gap: 10px; align-items: end; margin-bottom: 16px; }
.credit-transfer-filter .field { margin: 0; }
.credit-transfer-filter select { width: 100%; min-height: 42px; padding: 8px 10px; color: var(--text); background: #fff; border: 1px solid #d0d5dd; border-radius: 9px; }
.credit-transfer-list { gap: 12px; }
.credit-transfer-record { padding: 16px; border: 1px solid var(--reference-line); border-radius: 14px; box-shadow: none; }
.credit-transfer-record-head { display: flex; gap: 10px; align-items: flex-start; justify-content: space-between; }
.credit-transfer-record-head strong { overflow-wrap: anywhere; }
.credit-transfer-record-amount { margin: 14px 0; color: var(--primary-dark); font-size: 24px; overflow-wrap: anywhere; }
.credit-transfer-record dl { display: grid; gap: 8px; margin: 0; }
.credit-transfer-record dl > div { display: grid; grid-template-columns: 90px minmax(0, 1fr); gap: 10px; }
.credit-transfer-record dt { color: var(--text-soft); }
.credit-transfer-record dd { margin: 0; overflow-wrap: anywhere; }
.credit-transfer-record-note { color: var(--text-soft); white-space: pre-wrap; overflow-wrap: anywhere; }
.credit-transfer-record-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--reference-line); }
.credit-transfer-detail:not(:empty) { margin-top: 16px; padding: 16px; background: var(--primary-soft); border-radius: 14px; }
.credit-transfer-detail dl { display: grid; gap: 8px; }
.credit-transfer-detail dl > div { display: grid; grid-template-columns: 110px minmax(0, 1fr); gap: 10px; }
.credit-transfer-detail dd { margin: 0; overflow-wrap: anywhere; }
#credit-transfer-feedback { margin-top: 14px; }
#credit-transfer-list-retry { margin-left: 8px; }

@media (max-width: 1023px) {
  body[data-page] .agent-main { padding: 16px 16px calc(96px + var(--safe-bottom)); background: #fff; }
  body[data-page="home"] .agent-header,
  body[data-page="profile"] .agent-header { display: none; }
  body[data-page="home"] .agent-main { padding-top: 8px; background: #f7f8fa; }
  body[data-page="profile"] .agent-main { padding: 0 0 calc(94px + var(--safe-bottom)); background: #f7f8fa; }
  body[data-page] .header-notice { display: none; }
  body[data-page] .agent-header-main { min-height: 56px; padding: 8px 14px; }
  body[data-page] .agent-identity .agent-avatar { color: var(--primary-dark); background: var(--primary-soft); }
  body[data-page] .page-heading { margin-bottom: 18px; }
  body[data-page] .page-heading h1 { font-size: 23px; }
  body[data-page] .eyebrow { color: var(--primary-dark); }
  body[data-page] .panel,
  body[data-page] .order-card,
  body[data-page] .notification-item { border-color: var(--reference-line); border-radius: 15px; box-shadow: none; }
  body[data-page] .button-primary { border-radius: 12px; }
  body[data-page] .record-list { gap: 10px; }

  .home-heading { min-height: 34px; justify-content: flex-end; margin-bottom: 6px; }
  .home-heading > div { display: none; }
  #refresh-dashboard { min-height: 32px; color: var(--primary-dark); background: transparent; border: 0; }
  .app-page[data-page="home"] > .direction-switch { margin: 0 0 14px; padding: 0; background: #fff; border-radius: 13px; }
  .app-page[data-page="home"] > .direction-switch button { position: relative; min-height: 46px; color: #777; background: transparent; font-size: 15px; }
  .app-page[data-page="home"] > .direction-switch button.active { color: var(--primary-dark); box-shadow: none; }
  .app-page[data-page="home"] > .direction-switch button.active::after { position: absolute; right: 32%; bottom: 2px; left: 32%; height: 3px; background: var(--primary); border-radius: 2px; content: ""; }
  .home-order-workspace { min-height: calc(100dvh - 260px); }
  .home-order-workspace > .section-heading { margin: 0 2px 12px; }
  .home-order-workspace .section-heading h2 { font-size: 18px; }
  .home-order-workspace .section-heading p { max-width: 280px; margin-top: 5px; color: var(--text-soft); font-size: 11px; }
  #home-order-list { grid-template-columns: minmax(0, 1fr); }
  #home-order-list > .empty-state { display: flex; min-height: 320px; flex-direction: column; align-items: center; justify-content: center; background: transparent; border: 1px dashed #e3e5e8; }
  #home-order-list > .empty-state .empty-state-icon { color: var(--primary); background: var(--primary-soft); }
  #home-order-list .order-card { background: #fff; }
  .home-wallet-link { margin: 12px 0 148px; border: 0; }

  .app-page[data-page="home"] > .balance-card {
    position: fixed;
    z-index: 70;
    right: 14px;
    bottom: calc(78px + var(--safe-bottom));
    left: 14px;
    display: block;
    width: auto;
    max-width: 500px;
    min-height: 108px;
    margin: 0 auto;
    padding: 19px 12px;
    color: #fff;
    background: linear-gradient(120deg, #ff9d45, var(--reference-orange) 62%, #ec730e);
    border: 0;
    border-radius: 22px;
    box-shadow: 0 10px 28px rgba(217, 95, 2, 0.25);
  }
  .balance-card-top, .balance-total, .balance-equivalent, .balance-explanation { display: none; }
  .app-page[data-page="home"] > .balance-card .balance-grid { display: grid; grid-template-columns: minmax(0, 1fr) 92px minmax(0, 1fr); align-items: center; margin: 0; padding: 0; border: 0; }
  .app-page[data-page="home"] > .balance-card .balance-grid > div { padding: 0 4px; text-align: center; border: 0; }
  .app-page[data-page="home"] > .balance-card .balance-grid > div:first-child { grid-column: 1; }
  .app-page[data-page="home"] > .balance-card .balance-grid > div:nth-child(2) { display: none; }
  .app-page[data-page="home"] > .balance-card .balance-grid > div:nth-child(3) { grid-column: 3; }
  .app-page[data-page="home"] > .balance-card .balance-grid span { color: rgba(255, 255, 255, 0.82); font-size: 11px; }
  .app-page[data-page="home"] > .balance-card .balance-grid strong { display: block; margin: 7px 0 4px; color: #fff; font-size: clamp(16px, 4.6vw, 22px); line-height: 1.2; overflow-wrap: anywhere; }
  .app-page[data-page="home"] > .balance-card .balance-grid small { color: rgba(255, 255, 255, 0.72); font-size: 9px; }
  .app-page[data-page="home"] > .accepting-panel { position: fixed; z-index: 72; bottom: calc(91px + var(--safe-bottom)); left: 50%; display: block; width: 84px; margin: 0; padding: 0; background: transparent; border: 0; box-shadow: none; transform: translateX(-50%); }
  .app-page[data-page="home"] > .accepting-panel > div { display: none; }
  .app-page[data-page="home"] > .accepting-panel .switch { display: flex; width: 76px; height: 76px; align-items: center; justify-content: center; margin: 0 auto; padding: 0; color: var(--primary-dark); background: #fff; border: 5px solid rgba(255, 255, 255, 0.34); border-radius: 50%; box-shadow: 0 5px 16px rgba(139, 68, 7, 0.2); }
  .app-page[data-page="home"] > .accepting-panel .switch.is-on { color: var(--primary-dark); background: #fff; }
  .app-page[data-page="home"] > .accepting-panel .switch:disabled { color: #a7a7a7; background: #f2f2f2; opacity: 0.88; }
  .app-page[data-page="home"] > .accepting-panel .switch-thumb { display: none; }
  .app-page[data-page="home"] > .accepting-panel .switch-text { color: inherit; font-size: 13px; font-weight: 700; }
  #forced-stop-warning { position: relative; z-index: 73; margin-bottom: 140px; }

  .app-page[data-page="profile"] > .profile-card { margin: 0; padding: 28px 20px 72px; border-radius: 0 0 28px 28px; }
  .profile-main { gap: 14px; }
  .profile-avatar { width: 62px; height: 62px; font-size: 23px; }
  .profile-main h1 { color: #fff; font-size: 22px; }
  .profile-main .badge { margin-left: auto; }
  .profile-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); margin-top: 24px; padding-top: 20px; }
  .profile-stats > div { text-align: left; }
  .profile-stats > div + div { padding-left: 24px; border-left: 1px solid rgba(255, 255, 255, 0.26); }
  .profile-stats > .profile-payout-stat { display: none; }
  .profile-stats strong { font-size: 23px; }
  .app-page[data-page="profile"] > .profile-assets { position: relative; margin: -44px 16px 14px; padding: 20px; border: 0; border-radius: 18px; box-shadow: 0 8px 28px rgba(38, 38, 38, 0.09); }
  .profile-menu { margin: 12px 16px; }
  .profile-primary-menu .menu-section { border: 0; box-shadow: 0 2px 10px rgba(38, 38, 38, 0.025); }
  .profile-primary-menu .menu-section > a { min-height: 69px; padding: 14px 15px; }
  .profile-secondary-menu .menu-section > a::before { display: none; }
  .app-page[data-page="profile"] > #logout-button { width: calc(100% - 32px); margin: 20px 16px 10px; border: 0; }
  .app-page[data-page="profile"] > .profile-version { margin: 12px 16px; text-align: center; }

  .business-entry-list > a, .record-link-list { border: 0; }
  .business-entry-list { gap: 0; overflow: hidden; border: 1px solid var(--reference-line); border-radius: 16px; }
  .business-entry-list > a { border-bottom: 1px solid var(--reference-line); border-radius: 0; }
  .business-entry-list > a:last-child { border-bottom: 0; }
  .credit-transfer-filter { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .credit-transfer-filter > .button { grid-column: 1 / -1; }
  .credit-transfer-create-panel { padding: 16px; }
  .credit-transfer-record dl > div { grid-template-columns: 78px minmax(0, 1fr); }
  .wallet-reconciliation-details .wallet-grid,
  .wallet-reconciliation-details .reconciliation-grid { grid-template-columns: minmax(0, 1fr); }
  .confirm-dialog { width: calc(100% - 28px); max-width: 480px; max-height: calc(100dvh - 40px); overflow-y: auto; }
}

@media (max-width: 370px) {
  .app-page[data-page="home"] > .balance-card { right: 9px; left: 9px; padding-right: 7px; padding-left: 7px; }
  .app-page[data-page="home"] > .balance-card .balance-grid { grid-template-columns: minmax(0, 1fr) 80px minmax(0, 1fr); }
  .app-page[data-page="home"] > .accepting-panel .switch { width: 68px; height: 68px; }
  .profile-main .badge { display: none; }
}

@media (min-width: 1024px) {
  .app-page[data-page="home"] > .home-order-workspace,
  .app-page[data-page="home"] > .home-wallet-link { grid-column: 1 / -1; }
  .home-order-workspace > .section-heading { margin-top: 26px; }
  .app-page[data-page="home"] > .home-wallet-link { margin-top: 16px; }
  .app-page[data-page="home"] > .balance-card .balance-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .app-page[data-page="home"] > .balance-card .balance-grid > div + div { padding-left: 18px; border-left: 1px solid var(--line); }
  .home-payout-metric strong { font-size: 20px; }
  .wallet-reconciliation-details[open] { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
  .wallet-reconciliation-details > summary { grid-column: 1 / -1; }
  .wallet-reconciliation-details .wallet-card,
  .wallet-reconciliation-details .reconciliation-card { margin: 0; }
  .app-page[data-page="profile"] > .profile-card { background: linear-gradient(135deg, #ff9b42, var(--reference-orange) 58%, var(--reference-orange-dark)); }
  .app-page[data-page="profile"] > .profile-assets { grid-column: 1; grid-row: 2; }
  .app-page[data-page="profile"] > .profile-primary-menu { grid-column: 2; grid-row: 2 / 5; margin: 0; }
  .app-page[data-page="profile"] > .profile-secondary-menu { grid-column: 1; grid-row: 3; margin: 0; }
  .app-page[data-page="profile"] > #logout-button { grid-row: 4; }
  .profile-secondary-menu .menu-section > a::before { display: none; }
  .app-page[data-page="business-center"], .app-page[data-page="pledge"] { max-width: 1000px; }
  .business-entry-list { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .business-entry-list > a { grid-template-columns: auto 1fr; }
  .business-entry-list > a > b { display: none; }
  .app-page[data-page="credit-transfer"] { display: grid; grid-template-columns: minmax(330px, 400px) minmax(0, 1fr); gap: 18px 22px; align-items: start; }
  .app-page[data-page="credit-transfer"] > .page-heading,
  .app-page[data-page="credit-transfer"] > .preview-ledger-boundary { grid-column: 1 / -1; }
  .credit-transfer-create-panel { grid-column: 1; margin: 0; }
  .credit-transfer-records { grid-column: 2; grid-row: 3; }
  .credit-transfer-records > .section-heading { margin-top: 0; }
}

/* UI2: desktop must share the reference orange visual, not the legacy skin. */
.login-view { background: linear-gradient(145deg, #fff8f0 0%, #fff 52%, #f7f8fa 100%); }
.login-brand .brand-mark, .desktop-brand .brand-mark { background: linear-gradient(135deg, #ff9b42, var(--reference-orange)); }
.login-panel { border-color: #f2e5d8; }

@media (max-width: 1023px) {
  .login-view { background: linear-gradient(165deg, #fff0df 0%, #fff 42%, #f7f8fa 100%); }
  .login-hero .eyebrow { color: var(--primary-dark); }
  .login-panel { border: 0; border-radius: 20px; box-shadow: 0 12px 34px rgba(128, 75, 25, 0.08); }
}

@media (min-width: 1024px) {
  .login-view {
    background:
      radial-gradient(circle at 12% 24%, rgba(245, 130, 32, 0.16), transparent 32%),
      linear-gradient(130deg, #fff6eb 0%, #fff 56%, #f7f8fa 100%);
  }
  .login-panel { border: 0; box-shadow: 0 24px 65px rgba(173, 95, 24, 0.13); }
  .desktop-sidebar { background: #fff; border-right: 1px solid #f0e9e2; }
  .desktop-brand { color: var(--reference-ink); }
  .desktop-brand small, .desktop-environment, .desktop-nav > p { color: var(--reference-muted); }
  .desktop-nav > a { color: #545b66; }
  .desktop-nav > a > span { color: #8a8f99; border-color: #e8eaee; }
  .desktop-nav > a:hover { color: var(--primary-dark); background: #fff8f1; }
  .desktop-nav > a.active { color: var(--primary-dark); background: var(--primary-soft); border-color: #f9dfc7; }
  .desktop-nav > a.active > span { color: var(--primary); background: #fff; border-color: #f8d2ae; }
  .desktop-sidebar-foot { background: #fff8f1; border-color: #f4e0ce; }
  .desktop-sidebar-foot p { color: var(--reference-muted); }
  .agent-header { background: #fff; }
  .agent-main { background: #f7f8fa; }
  .app-page[data-page="home"] {
    grid-template-columns: minmax(0, 1.65fr) minmax(280px, 0.85fr);
    gap: 18px 22px;
    align-items: start;
  }
  .app-page[data-page="home"] > .home-order-workspace { grid-column: 1; grid-row: 3 / 6; }
  .home-order-workspace > .section-heading { margin-top: 0; }
  .app-page[data-page="home"] > .balance-card {
    grid-column: 2;
    grid-row: 3;
    min-height: 0;
    padding: 26px;
    color: #fff;
    background: linear-gradient(135deg, #ff9b42, var(--reference-orange) 58%, var(--reference-orange-dark));
    border: 0;
    border-radius: 22px;
    box-shadow: 0 14px 34px rgba(217, 95, 2, 0.2);
  }
  .app-page[data-page="home"] > .balance-card .balance-card-top,
  .app-page[data-page="home"] > .balance-card .balance-rate,
  .app-page[data-page="home"] > .balance-card .balance-total,
  .app-page[data-page="home"] > .balance-card .balance-equivalent,
  .app-page[data-page="home"] > .balance-card .balance-grid span,
  .app-page[data-page="home"] > .balance-card .balance-grid strong,
  .app-page[data-page="home"] > .balance-card .balance-grid small,
  .app-page[data-page="home"] > .balance-card .balance-explanation { color: #fff; }
  .balance-card .balance-total { font-size: 40px; }
  .app-page[data-page="home"] > .balance-card .balance-grid { border-color: rgba(255, 255, 255, 0.28); }
  .app-page[data-page="home"] > .balance-card .balance-grid > div + div { border-color: rgba(255, 255, 255, 0.28); }
  .app-page[data-page="home"] > .balance-card .balance-explanation { opacity: 0.82; }
  .app-page[data-page="home"] > .accepting-panel {
    grid-column: 2;
    grid-row: 4;
    margin: 0;
    padding: 20px;
    border: 1px solid var(--reference-line);
    border-radius: 16px;
    box-shadow: none;
  }
  .app-page[data-page="home"] > .accepting-panel .switch.is-on { background: var(--primary); }
  .app-page[data-page="home"] > .home-wallet-link { grid-column: 2; grid-row: 5; margin: 0; background: #fff8f1; border-color: #f4e0ce; }
  .home-order-workspace .order-card, .panel { border-radius: 16px; }
  .app-page[data-page="profile"] > .profile-card { box-shadow: 0 14px 34px rgba(217, 95, 2, 0.16); }
}
