/* ===================================================================
   Arcuity Fax Tool — design tokens & shared styles
   Built on top of Bootstrap 5.3.3.  Override + extend, don't replace.
   =================================================================== */

:root {
    /* Brand */
    --brand-50:  #eef4ff;
    --brand-100: #dde7ff;
    --brand-200: #b8ccff;
    --brand-500: #2563eb;
    --brand-600: #1d4ed8;
    --brand-700: #1e40af;
    --brand-900: #1e293b;

    /* Neutrals */
    --ink-900: #0f172a;
    --ink-800: #1e293b;
    --ink-700: #334155;
    --ink-600: #475569;
    --ink-500: #64748b;
    --ink-400: #94a3b8;
    --ink-300: #cbd5e1;
    --ink-200: #e2e8f0;
    --ink-100: #f1f5f9;
    --ink-50:  #f8fafc;

    /* Semantic */
    --success-50:  #ecfdf5;
    --success-600: #059669;
    --warning-50:  #fffbeb;
    --warning-600: #d97706;
    --danger-50:   #fef2f2;
    --danger-600:  #dc2626;
    --info-50:     #eff6ff;
    --info-600:    #2563eb;

    /* Surfaces & radius & shadow */
    --surface:        #ffffff;
    --surface-muted:  var(--ink-50);
    --border:         var(--ink-200);
    --radius-sm: 6px;
    --radius:    10px;
    --radius-lg: 16px;
    --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
    --shadow:    0 4px 12px rgba(15, 23, 42, 0.08);
    --shadow-lg: 0 20px 40px -12px rgba(15, 23, 42, 0.18);

    /* Type */
    --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
    --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
}

html { scroll-behavior: smooth; }

body {
    font-family: var(--font-sans);
    background: var(--surface-muted);
    color: var(--ink-800);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    line-height: 1.55;
}

a { color: var(--brand-600); text-decoration: none; }
a:hover { color: var(--brand-700); text-decoration: underline; }

h1, h2, h3, h4, h5, h6 {
    color: var(--ink-900);
    letter-spacing: -0.01em;
    font-weight: 600;
}
h1 { font-size: clamp(1.75rem, 1.4rem + 1.6vw, 2.5rem); }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.25rem; }

.text-muted, .text-secondary { color: var(--ink-500) !important; }

/* ----- App shell ----- */
.app-navbar {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    padding: 0.75rem 0;
}
.app-navbar .brand img { height: 32px; width: auto; display: block; }
.app-navbar .nav-user {
    display: flex; align-items: center; gap: 1rem;
}
.app-navbar .user-pill {
    display: inline-flex; align-items: center; gap: 0.5rem;
    padding: 0.4rem 0.9rem;
    background: var(--ink-100);
    border-radius: 999px;
    font-weight: 500;
    font-size: 0.9rem;
    color: var(--ink-700);
}
.app-navbar .user-pill::before {
    content: "";
    width: 8px; height: 8px; border-radius: 50%;
    background: var(--success-600);
}

.app-main {
    padding: 2rem 0 4rem;
    min-height: calc(100vh - 80px);
}

/* ----- Cards ----- */
.card-modern {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    padding: 1.75rem;
    transition: box-shadow 0.2s ease;
}
.card-modern:hover { box-shadow: var(--shadow); }
.card-modern .card-title {
    font-weight: 600; margin: 0 0 0.5rem; color: var(--ink-900);
}
.card-modern .card-sub {
    color: var(--ink-500); margin-bottom: 1.25rem; font-size: 0.95rem;
}

/* ----- Buttons ----- */
.btn {
    font-weight: 500;
    border-radius: var(--radius-sm);
    padding: 0.55rem 1.1rem;
    transition: all 0.15s ease;
    box-shadow: none;
}
.btn:focus { box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.25); }

.btn-primary {
    background: var(--brand-600);
    border-color: var(--brand-600);
}
.btn-primary:hover { background: var(--brand-700); border-color: var(--brand-700); transform: translateY(-1px); box-shadow: var(--shadow); }

.btn-outline-primary {
    color: var(--brand-600);
    border-color: var(--brand-200);
    background: transparent;
}
.btn-outline-primary:hover { background: var(--brand-50); color: var(--brand-700); border-color: var(--brand-500); }

.btn-secondary {
    background: var(--ink-100); border-color: var(--ink-200); color: var(--ink-700);
}
.btn-secondary:hover { background: var(--ink-200); color: var(--ink-900); }

.btn-danger {
    background: var(--danger-600); border-color: var(--danger-600);
}
.btn-success {
    background: var(--success-600); border-color: var(--success-600);
}

.btn-lg { padding: 0.8rem 1.6rem; font-size: 1.05rem; }
.btn-icon { display: inline-flex; align-items: center; gap: 0.5rem; }

/* ----- Forms ----- */
.form-label {
    font-weight: 500;
    color: var(--ink-700);
    margin-bottom: 0.4rem;
    font-size: 0.92rem;
}
.form-control, .form-select {
    border-radius: var(--radius-sm);
    border: 1px solid var(--ink-300);
    padding: 0.55rem 0.85rem;
    font-size: 0.95rem;
    background: var(--surface);
    transition: border 0.15s ease, box-shadow 0.15s ease;
}
.form-control:focus, .form-select:focus {
    border-color: var(--brand-500);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.18);
    outline: none;
}
.form-control:disabled, .form-control[readonly] {
    background: var(--ink-100);
    color: var(--ink-600);
}
.form-group { margin-bottom: 1rem; }

/* ----- Tables ----- */
.table-modern {
    background: var(--surface);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
}
.table-modern thead th {
    background: var(--ink-100);
    color: var(--ink-700);
    font-weight: 600;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    border-bottom: 1px solid var(--border);
    padding: 0.85rem 1rem;
}
.table-modern tbody td {
    padding: 0.85rem 1rem;
    border-bottom: 1px solid var(--ink-100);
    color: var(--ink-700);
    vertical-align: middle;
}
.table-modern tbody tr:last-child td { border-bottom: 0; }
.table-modern tbody tr:hover { background: var(--brand-50); }

/* ----- Badges / pills ----- */
.pill {
    display: inline-flex; align-items: center; gap: 0.35rem;
    padding: 0.2rem 0.65rem;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.pill-pending  { background: var(--warning-50); color: var(--warning-600); }
.pill-complete { background: var(--success-50); color: var(--success-600); }
.pill-error    { background: var(--danger-50);  color: var(--danger-600); }
.pill-info     { background: var(--info-50);    color: var(--info-600); }

/* ----- Alerts ----- */
.alert-modern {
    border: 0; border-left: 4px solid;
    border-radius: var(--radius-sm);
    padding: 0.9rem 1.1rem;
    background: var(--surface);
    box-shadow: var(--shadow-sm);
    display: flex; align-items: flex-start; gap: 0.75rem;
}
.alert-modern.alert-danger  { border-color: var(--danger-600);  background: var(--danger-50); color: var(--danger-600); }
.alert-modern.alert-success { border-color: var(--success-600); background: var(--success-50); color: var(--success-600); }
.alert-modern.alert-warning { border-color: var(--warning-600); background: var(--warning-50); color: var(--warning-600); }
.alert-modern.alert-info    { border-color: var(--info-600);    background: var(--info-50);    color: var(--info-600); }

/* ----- Hero / empty state ----- */
.hero {
    text-align: center;
    padding: 3rem 1rem;
    background: linear-gradient(135deg, var(--brand-50), var(--surface));
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
}
.hero h1 { margin-bottom: 0.75rem; }
.hero p.lead { color: var(--ink-500); max-width: 640px; margin: 0 auto 1.75rem; font-size: 1.1rem; }

.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--ink-500);
}
.empty-state .empty-icon {
    font-size: 3rem; margin-bottom: 1rem; opacity: 0.5;
}

/* ----- Loader ----- */
.loader-modern {
    display: inline-block;
    width: 48px; height: 48px;
    border: 3px solid var(--ink-200);
    border-top-color: var(--brand-600);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}
.loader-overlay {
    position: fixed; inset: 0;
    background: rgba(248, 250, 252, 0.85);
    backdrop-filter: blur(2px);
    display: none;
    align-items: center; justify-content: center;
    z-index: 1080;
}
.loader-overlay.visible { display: flex; }
.loader-overlay .loader-text {
    margin-top: 1rem; color: var(--ink-700); font-weight: 500;
}
.loader-overlay .loader-stack { text-align: center; }

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

/* ----- Toast ----- */
.toast-stack {
    position: fixed; top: 1rem; right: 1rem;
    z-index: 1090; display: flex; flex-direction: column; gap: 0.6rem;
    max-width: min(380px, calc(100vw - 2rem));
}
.toast-item {
    display: flex; align-items: flex-start; gap: 0.7rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-left: 4px solid var(--brand-600);
    border-radius: var(--radius);
    padding: 0.85rem 0.95rem;
    box-shadow: var(--shadow-lg);
    min-width: 280px;
    animation: toast-in 0.28s cubic-bezier(0.16, 1, 0.3, 1);
}
.toast-item.toast-out { animation: toast-out 0.25s ease forwards; }
.toast-icon {
    font-size: 1.15rem; line-height: 1.4;
    color: var(--brand-600); flex-shrink: 0;
}
.toast-msg {
    flex: 1; font-size: 0.9rem; line-height: 1.45;
    color: var(--ink-800); word-break: break-word;
}
.toast-close {
    border: 0; background: transparent; color: var(--ink-400);
    font-size: 1.25rem; line-height: 1; cursor: pointer;
    padding: 0 0.15rem; flex-shrink: 0; transition: color 0.15s;
}
.toast-close:hover { color: var(--ink-700); }
.toast-item.toast-success { border-left-color: var(--success-600); }
.toast-item.toast-success .toast-icon { color: var(--success-600); }
.toast-item.toast-danger  { border-left-color: var(--danger-600); }
.toast-item.toast-danger .toast-icon { color: var(--danger-600); }
.toast-item.toast-warning { border-left-color: var(--warning-600); }
.toast-item.toast-warning .toast-icon { color: var(--warning-600); }
@keyframes toast-in {
    from { opacity: 0; transform: translateX(20px); }
    to   { opacity: 1; transform: translateX(0); }
}
@keyframes toast-out {
    from { opacity: 1; transform: translateX(0); }
    to   { opacity: 0; transform: translateX(20px); }
}

/* ----- Modal (modernized to match app surface) ----- */
.modal-content {
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
}
.modal-header {
    background: var(--surface-muted);
    border-bottom: 1px solid var(--border);
    padding: 1rem 1.25rem;
}
.modal-header .modal-title {
    font-weight: 600; font-size: 1.05rem; color: var(--ink-900);
}
.modal-body { padding: 1.25rem; }
.modal-footer {
    border-top: 1px solid var(--border);
    padding: 0.85rem 1.25rem; gap: 0.5rem;
}
.modal-backdrop.show { opacity: 0.5; }
.modal .btn-close:focus { box-shadow: none; }

/* ----- Utility helpers ----- */
.section-title {
    font-size: 0.85rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--ink-500);
    margin-bottom: 1rem;
}
.kbd {
    font-family: var(--font-mono);
    background: var(--ink-100);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 0.1rem 0.35rem;
    font-size: 0.85em;
}
.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
}
.stat-card .stat-label {
    font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.05em;
    color: var(--ink-500); margin-bottom: 0.35rem;
}
.stat-card .stat-value {
    font-size: 1.75rem; font-weight: 600; color: var(--ink-900);
}

/* Smooth focus rings everywhere */
:focus-visible { outline: 3px solid rgba(37, 99, 235, 0.35); outline-offset: 2px; border-radius: 4px; }

/* Selection */
::selection { background: var(--brand-100); color: var(--brand-900); }

/* ===================================================================
   Home dashboard — greeting, stats grid, quick actions
   =================================================================== */
.home-hero {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1.5rem;
    padding: 2rem 2.25rem;
    margin-bottom: 1.75rem;
    border-radius: var(--radius-lg);
    background: linear-gradient(135deg, var(--brand-50) 0%, var(--surface) 60%, var(--info-50) 100%);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    position: relative;
    overflow: hidden;
}
.home-hero::after {
    content: "";
    position: absolute;
    top: -40%; right: -10%;
    width: 320px; height: 320px;
    background: radial-gradient(circle, rgba(37, 99, 235, 0.12), transparent 70%);
    pointer-events: none;
}
.home-eyebrow {
    font-size: 0.78rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--brand-600);
    margin-bottom: 0.4rem;
}
.home-greeting {
    margin: 0 0 0.4rem;
    font-size: clamp(1.75rem, 1.3rem + 1.6vw, 2.4rem);
    color: var(--ink-900);
}
.home-greeting .wave {
    display: inline-block;
    transform-origin: 70% 70%;
    animation: wave 2.4s ease-in-out 0.6s 2;
}
.home-lead { color: var(--ink-600); margin: 0; font-size: 1.05rem; max-width: 56ch; }
.home-hero-meta .pill i { font-size: 0.7rem; }

@keyframes wave {
    0%, 60%, 100% { transform: rotate(0deg); }
    10%, 30% { transform: rotate(16deg); }
    20%, 40% { transform: rotate(-10deg); }
}

/* ----- Stat grid ----- */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}
.stat-tile {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1.25rem 1.4rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    color: inherit;
    text-decoration: none;
    transition: transform 0.25s cubic-bezier(0.2, 0.7, 0.2, 1),
                box-shadow 0.25s ease,
                border-color 0.25s ease;
    position: relative;
    overflow: hidden;
}
.stat-tile::before {
    content: "";
    position: absolute;
    inset: auto -30% -50% auto;
    width: 140px; height: 140px;
    background: radial-gradient(circle, rgba(37, 99, 235, 0.08), transparent 70%);
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}
a.stat-tile:hover,
a.stat-tile:focus-visible {
    text-decoration: none;
    transform: translateY(-3px);
    box-shadow: var(--shadow);
    border-color: var(--brand-200);
}
a.stat-tile:hover::before { opacity: 1; }
.stat-tile-icon {
    width: 48px; height: 48px;
    border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.4rem;
    flex-shrink: 0;
    transition: transform 0.25s ease;
}
a.stat-tile:hover .stat-tile-icon { transform: scale(1.08) rotate(-3deg); }
.stat-tile-body { min-width: 0; }
.stat-tile .stat-label {
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-weight: 600;
    color: var(--ink-500);
    margin-bottom: 0.2rem;
}
.stat-tile .stat-value {
    font-size: 1.85rem;
    font-weight: 700;
    color: var(--ink-900);
    line-height: 1.1;
}
.stat-tile .stat-foot {
    font-size: 0.82rem;
    color: var(--ink-500);
    margin-top: 0.2rem;
}

/* ----- Quick actions ----- */
.quick-actions { margin-bottom: 2rem; }
.quick-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 1rem;
}
.quick-tile {
    display: block;
    padding: 1.5rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    color: inherit;
    text-decoration: none;
    transition: transform 0.25s cubic-bezier(0.2, 0.7, 0.2, 1),
                box-shadow 0.25s ease,
                border-color 0.25s ease;
}
.quick-tile:hover,
.quick-tile:focus-visible {
    text-decoration: none;
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
    border-color: var(--brand-200);
}
.quick-tile h3 { margin: 0.1rem 0 0.4rem; font-size: 1.1rem; color: var(--ink-900); }
.quick-tile p { color: var(--ink-600); margin: 0 0 1rem; font-size: 0.95rem; line-height: 1.5; }
.quick-tile-icon {
    width: 44px; height: 44px;
    border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.25rem;
    margin-bottom: 0.85rem;
    transition: transform 0.25s ease;
}
.quick-tile:hover .quick-tile-icon { transform: translateY(-2px) scale(1.05); }
.quick-tile-link {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-weight: 600;
    color: var(--brand-600);
    font-size: 0.9rem;
}
.quick-tile-link i {
    transition: transform 0.2s ease;
}
.quick-tile:hover .quick-tile-link i { transform: translateX(4px); }

/* ----- Tip banner ----- */
.home-tip {
    display: flex;
    align-items: flex-start;
    gap: 0.85rem;
    padding: 1rem 1.25rem;
    background: var(--info-50);
    border: 1px solid var(--brand-100);
    border-left: 4px solid var(--brand-500);
    border-radius: var(--radius);
    color: var(--ink-700);
    font-size: 0.95rem;
}
.home-tip-icon {
    color: var(--brand-600);
    font-size: 1.15rem;
    line-height: 1;
    padding-top: 0.15rem;
}
.home-tip a { font-weight: 600; }

/* ===================================================================
   Reveal-on-load animation (subtle)
   =================================================================== */
.reveal {
    opacity: 0;
    transform: translateY(8px);
    animation: reveal-up 0.5s cubic-bezier(0.2, 0.7, 0.2, 1) forwards;
    animation-delay: var(--reveal-delay, 0ms);
}
@keyframes reveal-up {
    to { opacity: 1; transform: translateY(0); }
}

@media (prefers-reduced-motion: reduce) {
    .reveal {
        opacity: 1;
        transform: none;
        animation: none;
    }
    .home-greeting .wave { animation: none; }
    .stat-tile, .quick-tile, .stat-tile-icon, .quick-tile-icon, .quick-tile-link i {
        transition: none;
    }
    a.stat-tile:hover, .quick-tile:hover { transform: none; }
}

@media (max-width: 640px) {
    .home-hero { flex-direction: column; align-items: flex-start; padding: 1.5rem; }
    .home-hero-meta { align-self: flex-end; }
}

/* ===================================================================
   Inbox — view toggle, fax grid, cards, merge bar
   =================================================================== */

/* ----- View toggle ----- */
.view-toggle {
    display: inline-flex;
    background: var(--ink-100);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 3px;
    gap: 2px;
}
.view-toggle-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    border: 0;
    background: transparent;
    color: var(--ink-500);
    font-size: 0.85rem;
    font-weight: 500;
    padding: 0.35rem 0.75rem;
    border-radius: calc(var(--radius-sm) - 2px);
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
}
.view-toggle-btn:hover { color: var(--ink-900); }
.view-toggle-btn.is-active {
    background: var(--surface);
    color: var(--brand-600);
    font-weight: 600;
    box-shadow: var(--shadow-sm);
}

/* ----- Grid toolbar ----- */
.grid-toolbar {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 1rem;
    padding: 0.85rem 1.25rem;
    background: rgba(255, 255, 255, 0.95);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    backdrop-filter: blur(8px);
    margin-bottom: 1.25rem;
}
.grid-toolbar-info {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
    color: var(--ink-700);
    font-weight: 500;
}
/* ----- Fax grid ----- */
.fax-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 1.1rem;
}

/* ----- Fax card ----- */
.fax-card {
    background: var(--surface);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: 0 2px 8px rgba(15, 23, 42, 0.06);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    /* Staggered entrance: --card-i is set inline per card (0–11) */
    opacity: 0;
    transform: translateY(10px);
    animation: fax-card-enter 0.4s cubic-bezier(0.22, 1, 0.36, 1) forwards;
    animation-delay: calc(min(var(--card-i, 0), 8) * 45ms);
    transition: transform 0.28s cubic-bezier(0.22, 1, 0.36, 1),
                box-shadow 0.28s ease,
                border-color 0.2s ease,
                background 0.2s ease;
}
@keyframes fax-card-enter {
    to { opacity: 1; transform: translateY(0); }
}
.fax-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 16px 36px -6px rgba(15, 23, 42, 0.14), 0 4px 10px rgba(15, 23, 42, 0.06);
    border-color: var(--brand-200);
}
/* Selected state */
.fax-card:has(input.merge-check:checked) {
    border-color: var(--brand-500);
    background: #f8faff;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12), 0 4px 12px rgba(15, 23, 42, 0.08);
}

/* Card header */
.fax-card-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.9rem 1rem 0.5rem;
}
.fax-card-meta-info { min-width: 0; flex: 1; }
.fax-card-date {
    font-size: 0.76rem;
    color: var(--ink-400);
    font-weight: 500;
    font-variant-numeric: tabular-nums;
    margin-bottom: 0.18rem;
}
.fax-card-sender {
    font-size: 0.93rem;
    color: var(--ink-900);
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.fax-card-unknown { color: var(--ink-400); font-weight: 400; }

/* Checkbox */
.fax-card-select {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    margin: 0;
    flex-shrink: 0;
}
.fax-card-select input { position: absolute; opacity: 0; pointer-events: none; }
.fax-card-check {
    width: 22px; height: 22px;
    border: 1.5px solid var(--ink-300);
    border-radius: 6px;
    background: var(--surface);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s ease, border-color 0.15s ease, transform 0.15s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.fax-card-check::after {
    content: "\F26E";
    font-family: "bootstrap-icons";
    color: #fff;
    font-size: 0.88rem;
    opacity: 0;
    transform: scale(0.5);
    transition: opacity 0.15s ease, transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.fax-card-select input:checked ~ .fax-card-check {
    background: var(--brand-600);
    border-color: var(--brand-600);
    transform: scale(1.08);
}
.fax-card-select input:checked ~ .fax-card-check::after { opacity: 1; transform: scale(1); }
.fax-card-select input:focus-visible ~ .fax-card-check {
    outline: 3px solid rgba(37, 99, 235, 0.35);
    outline-offset: 2px;
}

/* Tags row: status pill + WO badge */
.fax-card-tags {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    flex-wrap: wrap;
    padding: 0 1rem 0.7rem;
}
.fax-status-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.28rem;
    padding: 0.22rem 0.6rem;
    border-radius: 999px;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}
.fax-status-pill i { font-size: 0.65rem; }
.fax-status-pill.status-complete { background: var(--success-50);  color: var(--success-600); }
.fax-status-pill.status-pending  { background: var(--warning-50);  color: var(--warning-600); }
.fax-status-pill.status-info     { background: var(--info-50);     color: var(--info-600); }
.fax-wo-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.22rem 0.5rem;
    border-radius: 999px;
    font-size: 0.7rem;
    font-weight: 600;
    font-family: var(--font-mono);
    background: var(--ink-100);
    color: var(--ink-600);
    letter-spacing: 0.02em;
}
.fax-seq-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.22rem 0.5rem;
    border-radius: 999px;
    font-size: 0.7rem;
    font-weight: 600;
    font-family: var(--font-mono);
    background: var(--brand-50);
    color: var(--brand-600);
    letter-spacing: 0.02em;
}
/* Grid card: "Work Order ID" label + empty state */
.fax-wo-label {
    font-size: 0.62rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--ink-400);
}
.fax-wo-empty { background: transparent; color: var(--ink-400); }
/* Grid card: status pill floated onto the top-right of the thumbnail */
.fax-card-status-overlay {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    z-index: 2;
    border: 1px solid rgba(255, 255, 255, 0.85);
    box-shadow: var(--shadow-sm);
}

/* ----- Preview area ----- */
.fax-card-preview {
    position: relative;
    display: block;
    margin: 0 1rem;
    aspect-ratio: 8.5 / 11;
    border-radius: var(--radius);
    overflow: hidden;
    border: 1px solid var(--ink-200);
    text-decoration: none;
    background: var(--ink-50);
}

/* Shimmer skeleton while thumb is loading */
.fax-card-preview.is-loading {
    background: linear-gradient(90deg,
        var(--ink-100) 0%,
        var(--ink-50)  45%,
        var(--ink-100) 100%);
    background-size: 200% 100%;
    animation: fax-shimmer 1.8s ease-in-out infinite;
}
@keyframes fax-shimmer {
    0%   { background-position:  200% 0; }
    100% { background-position: -200% 0; }
}
.fax-card-preview.is-loading img { opacity: 0; }
.fax-card-preview.is-loading::before { display: none; }

/* Loaded image */
.fax-card-preview img {
    width: 100%; height: 100%;
    object-fit: cover;
    object-position: top center;
    background: #fff;
    display: block;
    position: relative;
    z-index: 1;
    transition: transform 0.38s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.2s ease;
}
.fax-card-preview img.thumb-broken,
.fax-card-preview img:not([src]) { display: none; }
.fax-card:hover .fax-card-preview img { transform: scale(1.04); }

/* PDF placeholder icon (when no thumb and not loading) */
.fax-card-preview::before {
    content: "\F756";
    font-family: "bootstrap-icons";
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--ink-200);
    font-size: 4rem;
    z-index: 0;
}
.fax-card.no-pdf .fax-card-preview::before { display: none; }

/* "Click to download" hint — only on .no-pdf cards */
.fax-no-pdf-hint {
    position: absolute;
    inset: 0;
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.55rem;
    color: var(--ink-400);
    font-size: 0.8rem;
    font-weight: 600;
    z-index: 2;
    background: linear-gradient(180deg, transparent 55%, rgba(248,250,252,0.5) 100%);
}
.fax-no-pdf-hint i {
    font-size: 2rem;
    color: var(--ink-300);
    transition: color 0.2s ease, transform 0.25s cubic-bezier(0.22, 1, 0.36, 1);
}
.fax-card.no-pdf .fax-no-pdf-hint { display: flex; }
.fax-card.no-pdf .fax-card-preview:hover .fax-no-pdf-hint { color: var(--brand-600); }
.fax-card.no-pdf .fax-card-preview:hover .fax-no-pdf-hint i { color: var(--brand-500); transform: translateY(-4px) scale(1.1); }

/* Fullscreen icon (appears on hover, hidden on no-pdf cards) */
.fax-preview-open {
    position: absolute;
    bottom: 0.6rem;
    right: 0.6rem;
    width: 30px; height: 30px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--surface);
    border-radius: 8px;
    color: var(--brand-600);
    font-size: 0.88rem;
    box-shadow: var(--shadow);
    opacity: 0;
    transform: scale(0.8);
    transition: opacity 0.2s ease, transform 0.22s cubic-bezier(0.22, 1, 0.36, 1);
    pointer-events: none;
    z-index: 3;
}
.fax-card:hover .fax-preview-open { opacity: 1; transform: scale(1); }
.fax-card.no-pdf .fax-preview-open { display: none; }

/* ----- Card footer ----- */
.fax-card-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.6rem 1rem 0.85rem;
    margin-top: auto;
    border-top: 1px solid var(--ink-100);
}
.fax-card-from {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.8rem;
    color: var(--ink-500);
    font-variant-numeric: tabular-nums;
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.fax-card-from i { color: var(--ink-300); font-size: 0.72rem; flex-shrink: 0; }
.fax-card-actions { display: inline-flex; align-items: center; gap: 0.3rem; flex-shrink: 0; }

/* Ghost icon button (status codes) */
.fax-btn-ghost {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px; height: 30px;
    border: 1px solid var(--ink-200);
    background: transparent;
    border-radius: var(--radius-sm);
    color: var(--ink-500);
    font-size: 0.88rem;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.fax-btn-ghost:hover { background: var(--brand-50); color: var(--brand-600); border-color: var(--brand-200); }

/* View button */
.fax-btn-view {
    display: inline-flex;
    align-items: center;
    gap: 0.2rem;
    padding: 0.28rem 0.7rem;
    background: var(--brand-600);
    color: #fff;
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    font-weight: 600;
    text-decoration: none;
    transition: background 0.15s ease, transform 0.15s ease;
}
.fax-btn-view:hover { background: var(--brand-700); color: #fff; text-decoration: none; transform: translateX(1px); }
.fax-btn-view i { font-size: 1.05rem; transition: transform 0.15s ease; }
.fax-btn-view:hover i { transform: translateX(2px); }

/* ----- Merge bar (sticky bottom) ----- */
.merge-bar {
    position: sticky;
    bottom: 1rem;
    z-index: 20;
    margin-top: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.9rem 1.4rem;
    background: rgba(255, 255, 255, 0.93);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: 0 8px 24px -4px rgba(15, 23, 42, 0.1);
    backdrop-filter: blur(10px);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.merge-bar.has-selection {
    border-color: var(--brand-300);
    box-shadow: 0 8px 28px -4px rgba(37, 99, 235, 0.18);
}
.merge-bar #mergeCount {
    font-weight: 500;
    color: var(--ink-500);
    font-size: 0.92rem;
    transition: color 0.2s ease;
}
.merge-bar.has-selection #mergeCount { color: var(--brand-600); font-weight: 600; }
.merge-bar #mergeButton:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none !important;
    box-shadow: none !important;
}

/* ===================================================================
   Inbox — tbl-inbox (DataTable view)
   =================================================================== */
.tbl-inbox {
    border-collapse: collapse;
    width: 100%;
    table-layout: fixed;
}

/* Column widths — explicit so headers and cells always align */
.tbl-inbox th:nth-child(1), .tbl-inbox td:nth-child(1) { width: 44px; }
.tbl-inbox th:nth-child(2), .tbl-inbox td:nth-child(2) { width: 128px; }
.tbl-inbox th:nth-child(3), .tbl-inbox td:nth-child(3) { width: 190px; }
.tbl-inbox th:nth-child(4), .tbl-inbox td:nth-child(4) { width: 164px; }
.tbl-inbox th:nth-child(5), .tbl-inbox td:nth-child(5) { width: 118px; }
.tbl-inbox th:nth-child(6), .tbl-inbox td:nth-child(6) { width: 112px; }
.tbl-inbox th:nth-child(7), .tbl-inbox td:nth-child(7) { width: 112px; }
.tbl-inbox th:nth-child(8), .tbl-inbox td:nth-child(8) { width: 112px; }
.tbl-inbox th:nth-child(9), .tbl-inbox td:nth-child(9) { width: 128px; }

.tbl-inbox thead th {
    background: var(--surface);
    color: var(--ink-400);
    font-size: 0.71rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.09em;
    padding: 0.6rem 1rem;
    border-bottom: 1.5px solid var(--border);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    user-select: none;
}
.tbl-inbox tbody tr {
    border-bottom: 1px solid var(--ink-100);
    transition: background 0.18s ease, box-shadow 0.18s ease;
}
.tbl-inbox tbody tr:last-child { border-bottom: 0; }
.tbl-inbox tbody tr:hover {
    background: var(--brand-50);
    box-shadow: inset 3px 0 0 var(--brand-400);
}
.tbl-inbox tbody tr:has(input.merge-check:checked) {
    background: #f0f5ff;
    border-color: var(--brand-100);
    box-shadow: inset 3px 0 0 var(--brand-500);
}
.tbl-inbox tbody td {
    padding: 0.5rem 1rem;
    color: var(--ink-700);
    vertical-align: middle;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 0.875rem;
    line-height: 1.4;
}

/* Checkbox column */
.tbl-col-check {
    width: 44px;
    padding-left: 0 !important;
    padding-right: 0 !important;
    text-align: center !important;
}
.tbl-check {
    width: 15px; height: 15px;
    accent-color: var(--brand-600);
    cursor: pointer;
    display: block;
    margin: 0 auto;
}

/* Fax ID badge */
.tbl-fax-id {
    font-family: var(--font-mono);
    font-size: 0.79rem;
    color: var(--ink-600);
    background: var(--ink-100);
    padding: 0.14rem 0.45rem;
    border-radius: 4px;
    display: inline-block;
    line-height: 1.5;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Sender cell: name + phone stacked, tight */
.tbl-sender { display: flex; flex-direction: column; gap: 0.04rem; }
.tbl-sender-name {
    font-weight: 600;
    color: var(--ink-900);
    font-size: 0.875rem;
    line-height: 1.3;
    overflow: hidden;
    text-overflow: ellipsis;
}
.tbl-sender-num {
    font-size: 0.73rem;
    color: var(--ink-400);
    display: inline-flex;
    align-items: center;
    gap: 0.2rem;
    font-variant-numeric: tabular-nums;
    line-height: 1.3;
}
.tbl-sender-num i { font-size: 0.63rem; }

/* Date */
.tbl-date {
    font-variant-numeric: tabular-nums;
    color: var(--ink-500);
    font-size: 0.84rem;
    white-space: nowrap;
}

/* Check cells (ROI / Witness) */
.tbl-check-cell { display: flex; flex-direction: column; gap: 0.04rem; }
.tbl-ck-num {
    font-family: var(--font-mono);
    font-size: 0.79rem;
    color: var(--ink-700);
    font-weight: 600;
    line-height: 1.3;
}
.tbl-ck-amt {
    font-size: 0.73rem;
    color: var(--success-600);
    font-weight: 600;
    line-height: 1.3;
}

/* Actions column */
.tbl-col-actions { width: 128px; }
.tbl-actions {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
}

/* Table-view checkbox */
#invoiceTable input.merge-check { accent-color: var(--brand-600); }

/* Rows hidden by infinite-scroll reveal */
.tbl-inbox tbody tr.tbl-hidden { display: none; }

/* Footer "Showing X of Y" count */
.tbl-shown {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--ink-500);
    font-variant-numeric: tabular-nums;
}

/* ===================================================================
   Infinite-scroll sentinel + spinner (grid + table)
   =================================================================== */
.infinite-sentinel {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.1rem;
    min-height: 40px;
}
.infinite-spinner {
    width: 24px; height: 24px;
    border: 3px solid var(--ink-200);
    border-top-color: var(--brand-500);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

/* Grid toolbar: scroll hint on the right */
.grid-scroll-hint {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.8rem;
    color: var(--ink-400);
    font-weight: 500;
}
.grid-toolbar-info i { color: var(--brand-500); }

@media (prefers-reduced-motion: reduce) {
    .infinite-spinner { animation: none; }
}

/* Empty state */
#gridView .empty-state { padding: 4rem 1rem; }

@media (max-width: 768px) {
    .fax-grid { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 0.85rem; }
    .grid-toolbar { padding: 0.75rem 1rem; }
    .merge-bar { flex-direction: column; align-items: stretch; }
}
@media (max-width: 480px) {
    .fax-grid { grid-template-columns: 1fr 1fr; gap: 0.65rem; }
}
@media (prefers-reduced-motion: reduce) {
    .fax-card { animation: none; opacity: 1; transform: none; }
    .fax-card, .fax-preview-open, .fax-btn-view, .fax-btn-view i { transition: none; }
    .fax-card:hover { transform: none; }
    .fax-card-preview.is-loading { animation: none; }
}
