/**
 * Salesman theme v2 — calmer surfaces, orange accent retained for field use.
 * Loaded after salesman.css.
 */

:root {
    --sm-surface: #ffffff;
    --sm-bg: #f1f5f9;
    --sm-border: #e2e8f0;
    --sm-muted: #64748b;
    --sm-text: #1e293b;
    --sm-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
    --sm-shadow-lg: 0 8px 24px rgba(15, 23, 42, 0.08);
    --sm-primary-soft: #fff7ed;
}

body {
    background: var(--sm-bg);
}

.sm-login-page {
    background: linear-gradient(160deg, #f8fafc 0%, #f1f5f9 50%, #fff7ed 100%);
}

.sm-login-logo {
    box-shadow: 0 6px 18px rgba(234, 88, 12, 0.22);
}

.sm-login-card {
    border-radius: 16px;
    box-shadow: var(--sm-shadow-lg);
}

.sm-btn--primary {
    background: linear-gradient(135deg, #fb923c, var(--sm-primary));
    box-shadow: 0 4px 14px rgba(234, 88, 12, 0.22);
}

.sm-topbar {
    background: rgba(255, 255, 255, 0.94);
    border-bottom: 1px solid var(--sm-border);
    box-shadow: none;
}

.sm-hero__name {
    font-size: 1.35rem;
    font-weight: 700;
}

.sm-stat {
    border-radius: 14px;
    box-shadow: var(--sm-shadow);
}

.sm-stat__label {
    text-transform: none;
    letter-spacing: 0;
    font-weight: 500;
}

.sm-section-title {
    text-transform: none;
    letter-spacing: 0;
    font-weight: 600;
    color: var(--sm-text);
}

.sm-action-tile {
    box-shadow: var(--sm-shadow);
}

.sm-card {
    box-shadow: var(--sm-shadow);
}

.sm-tabbar {
    background: rgba(255, 255, 255, 0.98);
    border-top-color: var(--sm-border);
}

.sm-tabbar__item--active {
    color: var(--sm-primary-dark);
}

.sm-input:focus,
.sm-select:focus {
    border-color: #fdba74;
    box-shadow: 0 0 0 3px rgba(251, 146, 60, 0.2);
    background: #fff;
}

.sm-badge {
    background: var(--sm-primary-soft);
    color: var(--sm-primary-dark);
}

/* Phase 2 — dashboard KPI links, due banner, reminder badges */
.sm-stat--link {
    display: block;
    text-decoration: none;
    color: inherit;
    transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.sm-stat--link:active {
    transform: scale(0.98);
}

.sm-stat--due .sm-stat__value { color: #dc2626; }
.sm-stat--coverage .sm-stat__value { color: #2563eb; font-size: 1.25rem; }
.sm-stat--outstanding .sm-stat__value { color: #b45309; font-size: 1.25rem; }

.sm-banner {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 14px;
    padding: 12px 14px;
    border-radius: 14px;
    text-decoration: none;
    color: inherit;
    border: 1px solid #fecaca;
    background: linear-gradient(135deg, #fff1f2, #fff7ed);
}

.sm-banner--due .sm-banner__icon { font-size: 1.25rem; }
.sm-banner__text { flex: 1; font-size: 13px; font-weight: 600; color: #9a3412; line-height: 1.35; }
.sm-banner__cta {
    font-size: 12px;
    font-weight: 700;
    color: var(--sm-primary-dark);
    background: #fff;
    border: 1px solid #fed7aa;
    padding: 6px 10px;
    border-radius: 999px;
}

.sm-reminder-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 6px;
}

.sm-reminder-badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 8px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 700;
    line-height: 1.2;
}

.sm-reminder-badge--due { background: #fee2e2; color: #b91c1c; }
.sm-reminder-badge--done { background: #dcfce7; color: #166534; }
.sm-reminder-badge--schedule { background: #eff6ff; color: #1d4ed8; }
.sm-reminder-badge--due-amt { background: #fff7ed; color: #c2410c; }

.sm-followup-tabs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-bottom: 12px;
}

.sm-followup-tab {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 10px 12px;
    border-radius: 12px;
    text-decoration: none;
    color: inherit;
    background: #fff;
    border: 1px solid var(--sm-border);
    box-shadow: var(--sm-shadow);
}

.sm-followup-tab--active {
    border-color: #fdba74;
    background: var(--sm-primary-soft);
}

.sm-followup-tab__label {
    font-size: 12px;
    font-weight: 600;
    color: var(--sm-muted);
}

.sm-followup-tab__count {
    font-size: 1.15rem;
    font-weight: 800;
    color: var(--sm-text);
}

.sm-followup-tab--active .sm-followup-tab__count { color: var(--sm-primary-dark); }

.customer-pick__main {
    flex: 1;
    min-width: 0;
}

.sm-order-card .sm-order-status { margin-top: 6px; }

/* Outstanding page polish */
.sm-out-route-summary {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 12px;
    margin-bottom: 12px;
    padding: 14px 16px;
    border-radius: 14px;
    background: linear-gradient(135deg, #fff7ed, #fff);
    border: 1px solid #fed7aa;
}

.sm-out-route-summary__label {
    font-size: 12px;
    font-weight: 600;
    color: var(--sm-muted);
}

.sm-out-route-summary__value {
    font-size: 1.35rem;
    font-weight: 800;
    color: #c2410c;
    margin-top: 2px;
}

.sm-out-route-summary__meta {
    font-size: 12px;
    font-weight: 600;
    color: var(--sm-muted);
    text-align: right;
}

.sm-out-search { margin-bottom: 10px; }

.sm-customer-pick--active {
    border-color: #fdba74;
    background: #fffaf5;
    box-shadow: 0 0 0 2px rgba(251, 146, 60, 0.15);
}

.sm-customer-pick--clear { opacity: 0.72; }

.sm-customer-pick__mobile {
    display: block;
    font-size: 12px;
    color: var(--sm-muted);
    margin-top: 2px;
}

.sm-customer-pick__due--zero {
    color: var(--sm-muted);
    font-size: 12px;
    font-weight: 700;
}

.sm-out-detail {
    margin-top: 16px;
    padding-top: 4px;
    border-top: 1px solid var(--sm-border);
}

.sm-out-detail__head {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: flex-start;
    margin-bottom: 12px;
}

.sm-out-detail__name {
    margin: 4px 0 0;
    font-size: 1.15rem;
    font-weight: 800;
}

.sm-out-detail__meta {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 10px;
    margin-top: 6px;
    font-size: 12px;
    color: var(--sm-muted);
}

.sm-out-detail__total {
    font-size: 1.25rem;
    font-weight: 800;
    color: #dc2626;
    white-space: nowrap;
}

.sm-out-share-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 12px;
}

.sm-out-share-bar .sm-btn { flex: 1; min-width: 72px; }

.sm-btn--pdf {
    background: #eff6ff;
    color: #1d4ed8;
    border-color: #bfdbfe;
}

.sm-out-detail__totals {
    display: grid;
    gap: 6px;
    margin-top: 8px;
    font-size: 0.92rem;
}
.sm-out-detail__totals div {
    display: flex;
    justify-content: space-between;
    gap: 12px;
}
.sm-doc-row__type {
    color: #64748b;
    font-weight: 500;
}

.sm-total-bar__amt { color: #dc2626; }

.sm-out-empty { margin-top: 8px; }

.sm-share-sheet {
    position: fixed;
    inset: 0;
    z-index: 500;
    display: none;
    align-items: flex-end;
    justify-content: center;
}

.sm-share-sheet.is-open { display: flex; }

.sm-share-sheet__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.45);
}

.sm-share-sheet__panel {
    position: relative;
    width: 100%;
    max-width: 420px;
    background: #fff;
    border-radius: 20px 20px 0 0;
    padding: 20px 16px calc(20px + env(safe-area-inset-bottom));
    box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.12);
}

.sm-share-sheet__title {
    margin: 0 0 10px;
    font-size: 1.05rem;
    font-weight: 800;
    text-align: center;
}

.sm-share-sheet__preview {
    margin: 0 0 12px;
    padding: 10px 12px;
    background: #f8fafc;
    border: 1px solid var(--sm-border);
    border-radius: 10px;
    font-size: 11px;
    line-height: 1.45;
    white-space: pre-wrap;
    color: var(--sm-muted);
    max-height: 88px;
    overflow: hidden;
}

.sm-share-sheet__note {
    margin: 0 0 10px;
    font-size: 12px;
    color: #b45309;
    text-align: center;
}

.sm-share-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin-bottom: 12px;
}

.sm-share-opt {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    min-height: 72px;
    padding: 8px 6px;
    border-radius: 12px;
    border: 1px solid var(--sm-border);
    background: #fff;
    text-decoration: none;
    color: inherit;
    font-size: 11px;
    font-weight: 700;
    cursor: pointer;
}

.sm-share-opt__icon { font-size: 1.2rem; line-height: 1; }

.sm-share-opt--wa { background: #f0fdf4; border-color: #bbf7d0; color: #15803d; }
.sm-share-opt--biz { background: #ecfdf5; border-color: #86efac; color: #166534; }
.sm-share-opt--copy { background: #f8fafc; }
.sm-share-opt--native { background: #eff6ff; border-color: #bfdbfe; color: #1d4ed8; }
.sm-share-opt--pdf { background: #eff6ff; border-color: #bfdbfe; color: #1d4ed8; }
.sm-share-opt--print { background: #fff7ed; border-color: #fed7aa; color: #c2410c; }

.sm-share-opt.is-disabled {
    opacity: 0.45;
    pointer-events: none;
}

.sm-share-toast {
    position: fixed;
    left: 50%;
    bottom: calc(80px + env(safe-area-inset-bottom));
    transform: translateX(-50%) translateY(12px);
    background: #0f172a;
    color: #fff;
    padding: 10px 16px;
    border-radius: 999px;
    font-size: 13px;
    font-weight: 600;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s, transform 0.2s;
    z-index: 600;
}

.sm-share-toast.is-visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* Purchase history */
.sm-purchase-history-btn.is-disabled {
    opacity: 0.45;
    pointer-events: none;
}

.sm-order-setup .sm-purchase-history-btn {
    margin-top: 10px;
}

.sm-customer-search-results {
    margin-top: 6px;
    border: 1px solid var(--sm-border);
    border-radius: 10px;
    background: #fff;
    max-height: 220px;
    overflow-y: auto;
    box-shadow: var(--sm-shadow);
}

.sm-customer-search-results__item {
    display: block;
    width: 100%;
    padding: 10px 12px;
    border: 0;
    border-bottom: 1px solid var(--sm-border);
    background: transparent;
    text-align: left;
    cursor: pointer;
}

.sm-customer-search-results__item:last-child {
    border-bottom: 0;
}

.sm-customer-search-results__item:active {
    background: var(--sm-blue-soft, #eff6ff);
}

.sm-customer-search-results__name {
    display: block;
    font-weight: 700;
    font-size: 14px;
    color: var(--sm-text, #1c1917);
}

.sm-customer-search-results__meta {
    display: block;
    margin-top: 2px;
    font-size: 12px;
    color: var(--sm-muted, #78716c);
}

.sm-customer-search-results__empty {
    padding: 12px;
    font-size: 13px;
    color: var(--sm-muted, #78716c);
    text-align: center;
}

.sm-purchase-head {
    margin-bottom: 12px;
}

.sm-purchase-ranges {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 12px;
}

.sm-purchase-range {
    padding: 8px 12px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
    text-decoration: none;
    color: var(--sm-muted);
    background: #fff;
    border: 1px solid var(--sm-border);
}

.sm-purchase-range--active {
    background: var(--sm-primary-soft);
    border-color: #fdba74;
    color: var(--sm-primary-dark);
}

.sm-stats--purchase {
    margin-bottom: 14px;
}

.sm-purchase-tabs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-bottom: 12px;
}

.sm-purchase-tab {
    padding: 10px;
    text-align: center;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 700;
    text-decoration: none;
    color: inherit;
    background: #fff;
    border: 1px solid var(--sm-border);
}

.sm-purchase-tab--active {
    background: var(--sm-primary-soft);
    border-color: #fdba74;
    color: var(--sm-primary-dark);
}

.sm-purchase-product { margin-bottom: 10px; }

.sm-purchase-product__row {
    display: flex;
    gap: 12px;
    align-items: flex-start;
}

.sm-purchase-product__body {
    flex: 1;
    min-width: 0;
}

.sm-purchase-thumb {
    flex-shrink: 0;
    width: 56px;
    height: 56px;
    padding: 0;
    border: 1px solid var(--sm-border);
    border-radius: 12px;
    overflow: hidden;
    background: #f8fafc;
    cursor: pointer;
}

.sm-purchase-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.sm-purchase-line--with-thumb {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    padding: 12px 0;
}

.sm-purchase-line__body {
    flex: 1;
    min-width: 0;
}

.sm-image-lightbox {
    position: fixed;
    inset: 0;
    z-index: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.sm-image-lightbox[hidden] {
    display: none !important;
}

.sm-image-lightbox__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.82);
}

.sm-image-lightbox__sheet {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 420px;
    max-height: 90vh;
    background: #fff;
    border-radius: 16px;
    padding: 12px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.28);
}

.sm-image-lightbox__title {
    margin: 0 36px 10px 4px;
    font-size: 14px;
    font-weight: 700;
    line-height: 1.35;
    color: var(--sm-text);
}

.sm-image-lightbox__sheet img {
    display: block;
    width: 100%;
    max-height: calc(90vh - 80px);
    object-fit: contain;
    border-radius: 10px;
    background: #f8fafc;
}

.sm-image-lightbox__close {
    position: absolute;
    top: 8px;
    right: 10px;
    width: 36px;
    height: 36px;
    border: none;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 50%;
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
    z-index: 2;
}

.sm-purchase-line {
    padding: 10px 0;
    border-bottom: 1px solid var(--sm-border);
}

.sm-purchase-line:last-child { border-bottom: 0; }

.sm-purchase-line__name {
    font-weight: 800;
    font-size: 14px;
}

.sm-purchase-line__meta {
    font-size: 12px;
    color: var(--sm-muted);
    margin-top: 2px;
}

.sm-purchase-line__row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 6px;
    font-size: 13px;
    font-weight: 600;
}

.sm-purchase-bill { margin-bottom: 8px; }

.sm-purchase-back {
    display: inline-block;
    margin-bottom: 10px;
    font-size: 13px;
    font-weight: 700;
    color: var(--sm-primary-dark);
    text-decoration: none;
}
