/* =====================================================================
   ROSA Visit · Roto Rooter Indonesia
   Mobile-first app shell. Built like a native field-ops mini app.
   Stack: Bootstrap 5 base + custom system. Mobile-first; desktop is the
   media query (not the other way around).
===================================================================== */

/* ---------- 1. Root tokens ---------- */
:root {
    /* Brand */
    --rv-primary:        #0d4ea6;
    --rv-primary-700:    #0a3d80;
    --rv-primary-800:    #073061;
    --rv-primary-50:     #e8f0fb;
    --rv-primary-tint:   #f3f7fd;

    --rv-accent:         #ff7a1a;
    --rv-accent-600:     #e96a0d;
    --rv-accent-50:      #fff1e3;

    /* Neutral */
    --rv-bg:             #f1f4f9;
    --rv-bg-soft:        #f6f8fc;
    --rv-surface:        #ffffff;
    --rv-surface-alt:    #fafbfd;
    --rv-border:         #e6ebf3;
    --rv-border-strong:  #d4dbe6;

    --rv-ink:            #0e1a30;
    --rv-text:           #2c3852;
    --rv-muted:          #6b7691;
    --rv-faint:          #9aa4b8;

    /* Status */
    --rv-success:        #16a34a;
    --rv-success-50:     #e7f7ee;
    --rv-warning:        #d97706;
    --rv-warning-50:     #fef3e2;
    --rv-danger:         #dc2626;
    --rv-danger-50:      #fde8e8;
    --rv-info:           #2563eb;
    --rv-info-50:        #e6efff;

    /* Radius */
    --rv-r-sm: 10px;
    --rv-r-md: 14px;
    --rv-r-lg: 18px;
    --rv-r-xl: 22px;
    --rv-r-pill: 999px;

    /* Shadow */
    --rv-shadow-sm: 0 1px 2px rgba(14, 26, 48, 0.04), 0 1px 3px rgba(14, 26, 48, 0.06);
    --rv-shadow-md: 0 4px 12px rgba(14, 26, 48, 0.06), 0 2px 4px rgba(14, 26, 48, 0.04);
    --rv-shadow-lg: 0 12px 28px rgba(14, 26, 48, 0.10), 0 4px 10px rgba(14, 26, 48, 0.05);
    --rv-shadow-nav: 0 -2px 14px rgba(14, 26, 48, 0.08);

    /* Layout */
    --rv-app-max: 520px;
    --rv-header-h: 64px;
    --rv-bottom-nav-h: 68px;

    /* Type */
    --rv-font: "Plus Jakarta Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
}

/* ---------- 2. Reset & base ---------- */
* {
    -webkit-tap-highlight-color: transparent;
}

html, body {
    background: var(--rv-bg);
    color: var(--rv-text);
    font-family: var(--rv-font);
    font-size: 15px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: hidden;
}

body {
    padding-bottom: calc(var(--rv-bottom-nav-h) + env(safe-area-inset-bottom, 0px) + 12px);
}

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

a:hover {
    color: var(--rv-primary-700);
}

h1, h2, h3, h4, h5, h6 {
    color: var(--rv-ink);
    font-weight: 700;
    letter-spacing: -0.01em;
    margin: 0;
}

img {
    max-width: 100%;
    height: auto;
    display: block;
}

/* ---------- 3. App shell ---------- */
.app-shell {
    width: 100%;
    max-width: var(--rv-app-max);
    margin: 0 auto;
    padding: 16px;
    padding-top: calc(var(--rv-header-h) + 16px);
}

.app-shell--wide {
    max-width: 720px;
}

/* ---------- 4. App header (sticky top) ---------- */
.app-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1030;
    background: var(--rv-surface);
    border-bottom: 1px solid var(--rv-border);
    box-shadow: var(--rv-shadow-sm);
    padding-top: env(safe-area-inset-top, 0);
}

.app-header__inner {
    max-width: var(--rv-app-max);
    margin: 0 auto;
    height: var(--rv-header-h);
    padding: 0 16px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.app-header--wide .app-header__inner {
    max-width: 720px;
}

.app-header__back {
    width: 38px;
    height: 38px;
    border-radius: 12px;
    background: var(--rv-primary-50);
    color: var(--rv-primary);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
    transition: background 0.15s;
    border: none;
}

.app-header__back:hover,
.app-header__back:active {
    background: var(--rv-primary);
    color: #fff;
}

.app-header__brand {
    width: 38px;
    height: 38px;
    border-radius: 12px;
    background: linear-gradient(135deg, var(--rv-primary), var(--rv-primary-700));
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 14px;
    letter-spacing: -0.02em;
    flex-shrink: 0;
    box-shadow: 0 2px 6px rgba(13, 78, 166, 0.25);
}

.app-header__title-wrap {
    flex: 1;
    min-width: 0;
}

.app-header__title {
    font-size: 16px;
    font-weight: 700;
    color: var(--rv-ink);
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.app-header__subtitle {
    font-size: 11px;
    color: var(--rv-muted);
    line-height: 1.2;
    margin-top: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.app-header__action {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border-radius: 12px;
    background: var(--rv-bg-soft);
    color: var(--rv-text);
    border: none;
    font-size: 18px;
}

/* ---------- 5. Page hero (dashboard) ---------- */
.page-hero {
    background: linear-gradient(135deg, var(--rv-primary) 0%, var(--rv-primary-800) 100%);
    color: #fff;
    border-radius: var(--rv-r-xl);
    padding: 22px;
    margin-bottom: 18px;
    position: relative;
    overflow: hidden;
    box-shadow: 0 10px 24px rgba(13, 78, 166, 0.18);
}

.page-hero::before {
    content: "";
    position: absolute;
    top: -40px;
    right: -40px;
    width: 180px;
    height: 180px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.08);
}

.page-hero::after {
    content: "";
    position: absolute;
    bottom: -60px;
    right: 30px;
    width: 120px;
    height: 120px;
    border-radius: 50%;
    background: rgba(255, 122, 26, 0.18);
}

.page-hero__greeting {
    font-size: 12px;
    font-weight: 500;
    opacity: 0.85;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    margin-bottom: 4px;
    position: relative;
    z-index: 1;
}

.page-hero__title {
    font-size: 22px;
    font-weight: 700;
    line-height: 1.25;
    color: #fff;
    margin: 0;
    position: relative;
    z-index: 1;
}

.page-hero__sub {
    font-size: 13px;
    opacity: 0.85;
    margin-top: 6px;
    position: relative;
    z-index: 1;
}

/* ---------- 6. Section headings ---------- */
.section-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin: 22px 0 12px;
    padding: 0 4px;
}

.section-head__title {
    font-size: 13px;
    font-weight: 700;
    color: var(--rv-ink);
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.section-head__link {
    font-size: 12px;
    font-weight: 600;
    color: var(--rv-primary);
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

/* ---------- 7. Mobile card / form card ---------- */
.mobile-card,
.form-card {
    background: var(--rv-surface);
    border-radius: var(--rv-r-lg);
    padding: 18px;
    box-shadow: var(--rv-shadow-sm);
    border: 1px solid var(--rv-border);
    margin-bottom: 14px;
}

.form-card {
    padding: 20px;
}

.form-card__title {
    font-size: 14px;
    font-weight: 700;
    color: var(--rv-ink);
    margin-bottom: 4px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.form-card__title i {
    color: var(--rv-primary);
}

.form-card__hint {
    font-size: 12px;
    color: var(--rv-muted);
    margin-bottom: 16px;
}

/* ---------- 8. Stat cards ---------- */
.stat-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
    margin-bottom: 8px;
}

.stat-card {
    background: var(--rv-surface);
    border-radius: var(--rv-r-lg);
    padding: 18px;
    box-shadow: var(--rv-shadow-sm);
    border: 1px solid var(--rv-border);
    display: flex;
    align-items: center;
    gap: 14px;
}

.stat-card__icon {
    width: 50px;
    height: 50px;
    border-radius: var(--rv-r-md);
    background: var(--rv-primary-50);
    color: var(--rv-primary);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    flex-shrink: 0;
}

.stat-card__icon--accent {
    background: var(--rv-accent-50);
    color: var(--rv-accent-600);
}

.stat-card__icon--success {
    background: var(--rv-success-50);
    color: var(--rv-success);
}

.stat-card__body {
    flex: 1;
    min-width: 0;
}

.stat-card__label {
    font-size: 12px;
    color: var(--rv-muted);
    font-weight: 500;
    margin-bottom: 2px;
}

.stat-card__value {
    font-size: 24px;
    font-weight: 800;
    color: var(--rv-ink);
    line-height: 1.1;
    letter-spacing: -0.02em;
}

.stat-card__trend {
    font-size: 11px;
    color: var(--rv-faint);
    margin-top: 2px;
}

/* ---------- 9. Quick actions ---------- */
.quick-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 8px;
}

.quick-action {
    background: var(--rv-surface);
    border-radius: var(--rv-r-lg);
    padding: 18px 14px;
    text-align: left;
    border: 1px solid var(--rv-border);
    box-shadow: var(--rv-shadow-sm);
    color: var(--rv-ink);
    display: flex;
    flex-direction: column;
    gap: 10px;
    transition: transform 0.12s, box-shadow 0.12s;
}

.quick-action:hover,
.quick-action:active {
    transform: translateY(-1px);
    box-shadow: var(--rv-shadow-md);
    color: var(--rv-ink);
}

.quick-action--primary {
    background: linear-gradient(135deg, var(--rv-primary), var(--rv-primary-700));
    color: #fff;
    border-color: transparent;
    box-shadow: 0 6px 14px rgba(13, 78, 166, 0.22);
}

.quick-action--primary:hover,
.quick-action--primary:active {
    color: #fff;
}

.quick-action__icon {
    width: 38px;
    height: 38px;
    border-radius: 12px;
    background: var(--rv-primary-50);
    color: var(--rv-primary);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
}

.quick-action--primary .quick-action__icon {
    background: rgba(255, 255, 255, 0.18);
    color: #fff;
}

.quick-action__label {
    font-size: 14px;
    font-weight: 700;
    line-height: 1.2;
}

.quick-action__sub {
    font-size: 11px;
    color: var(--rv-muted);
    line-height: 1.3;
}

.quick-action--primary .quick-action__sub {
    color: rgba(255, 255, 255, 0.85);
}

/* ---------- 10. Per-head breakdown ---------- */
.head-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid var(--rv-border);
}

.head-row:last-child {
    border-bottom: none;
}

.head-row__avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--rv-primary-50);
    color: var(--rv-primary);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 13px;
    flex-shrink: 0;
}

.head-row__body {
    flex: 1;
    min-width: 0;
}

.head-row__name {
    font-size: 13px;
    font-weight: 600;
    color: var(--rv-ink);
    margin-bottom: 4px;
}

.head-row__bar {
    height: 6px;
    background: var(--rv-bg);
    border-radius: 999px;
    overflow: hidden;
}

.head-row__bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--rv-primary), var(--rv-accent));
    border-radius: 999px;
    transition: width 0.4s;
}

.head-row__count {
    font-size: 14px;
    font-weight: 700;
    color: var(--rv-primary);
    min-width: 28px;
    text-align: right;
}

/* ---------- 11. Visit card (list/recent) ---------- */
.visit-card {
    background: var(--rv-surface);
    border-radius: var(--rv-r-lg);
    box-shadow: var(--rv-shadow-sm);
    border: 1px solid var(--rv-border);
    padding: 16px;
    margin-bottom: 12px;
    transition: box-shadow 0.15s;
}

.visit-card:hover {
    box-shadow: var(--rv-shadow-md);
}

.visit-card__top {
    display: flex;
    gap: 12px;
    margin-bottom: 12px;
}

.visit-card__thumb {
    width: 64px;
    height: 64px;
    border-radius: var(--rv-r-md);
    object-fit: cover;
    flex-shrink: 0;
    background: var(--rv-bg);
    border: 1px solid var(--rv-border);
}

.visit-card__head {
    flex: 1;
    min-width: 0;
}

.visit-card__company {
    font-size: 15px;
    font-weight: 700;
    color: var(--rv-ink);
    line-height: 1.25;
    margin-bottom: 3px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.visit-card__customer {
    font-size: 13px;
    color: var(--rv-text);
    line-height: 1.3;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.visit-card__meta {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 10px;
    font-size: 12px;
    color: var(--rv-muted);
    margin-bottom: 10px;
}

.visit-card__meta-item {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.visit-card__meta-item i {
    font-size: 13px;
    color: var(--rv-faint);
}

.visit-card__excerpt {
    font-size: 12.5px;
    color: var(--rv-text);
    background: var(--rv-bg-soft);
    border-radius: var(--rv-r-sm);
    padding: 8px 10px;
    margin-bottom: 12px;
    line-height: 1.45;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.visit-card__excerpt strong {
    color: var(--rv-ink);
    font-weight: 600;
}

.visit-card__actions {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 8px;
}

.visit-card__action {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    height: 38px;
    border-radius: var(--rv-r-md);
    font-size: 12.5px;
    font-weight: 600;
    border: 1px solid var(--rv-border);
    background: var(--rv-surface);
    color: var(--rv-text);
    transition: background 0.12s;
}

.visit-card__action:hover,
.visit-card__action:active {
    background: var(--rv-bg-soft);
    color: var(--rv-text);
}

.visit-card__action--primary {
    background: var(--rv-primary);
    color: #fff;
    border-color: var(--rv-primary);
}

.visit-card__action--primary:hover,
.visit-card__action--primary:active {
    background: var(--rv-primary-700);
    color: #fff;
}

.visit-card__action--danger {
    color: var(--rv-danger);
    border-color: var(--rv-border);
}

.visit-card__action--danger:hover,
.visit-card__action--danger:active {
    background: var(--rv-danger-50);
    color: var(--rv-danger);
}

.visit-card__action--map {
    background: var(--rv-accent-50);
    color: var(--rv-accent-600);
    border-color: var(--rv-accent-50);
}

.visit-card__action--map:hover,
.visit-card__action--map:active {
    background: var(--rv-accent);
    color: #fff;
    border-color: var(--rv-accent);
}

/* Recent compact (dashboard) */
.recent-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid var(--rv-border);
    color: inherit;
}

.recent-item:last-child {
    border-bottom: none;
}

.recent-item:hover {
    color: inherit;
}

.recent-item__thumb {
    width: 44px;
    height: 44px;
    border-radius: var(--rv-r-sm);
    object-fit: cover;
    flex-shrink: 0;
    background: var(--rv-bg);
}

.recent-item__body {
    flex: 1;
    min-width: 0;
}

.recent-item__title {
    font-size: 13.5px;
    font-weight: 600;
    color: var(--rv-ink);
    line-height: 1.25;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.recent-item__sub {
    font-size: 12px;
    color: var(--rv-muted);
    margin-top: 2px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.recent-item__chev {
    color: var(--rv-faint);
    font-size: 16px;
    flex-shrink: 0;
}

/* ---------- 12. Badges ---------- */
.rv-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 9px;
    border-radius: var(--rv-r-pill);
    font-size: 11px;
    font-weight: 600;
    line-height: 1.2;
    white-space: nowrap;
}

.rv-badge--primary { background: var(--rv-primary-50); color: var(--rv-primary); }
.rv-badge--accent  { background: var(--rv-accent-50);  color: var(--rv-accent-600); }
.rv-badge--success { background: var(--rv-success-50); color: var(--rv-success); }
.rv-badge--warning { background: var(--rv-warning-50); color: var(--rv-warning); }
.rv-badge--danger  { background: var(--rv-danger-50);  color: var(--rv-danger); }
.rv-badge--muted   { background: var(--rv-bg);         color: var(--rv-muted); }

/* ---------- 13. Forms ---------- */
.field {
    margin-bottom: 16px;
}

.field__label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--rv-ink);
    margin-bottom: 7px;
}

.field__label .req {
    color: var(--rv-danger);
    margin-left: 2px;
}

.field__hint {
    font-size: 11.5px;
    color: var(--rv-muted);
    margin-top: 6px;
}

.field__input,
.field__select,
.field__textarea {
    width: 100%;
    background: var(--rv-surface);
    border: 1.5px solid var(--rv-border);
    border-radius: var(--rv-r-md);
    padding: 13px 14px;
    font-size: 15px;
    font-family: inherit;
    color: var(--rv-ink);
    min-height: 48px;
    transition: border-color 0.15s, box-shadow 0.15s;
    -webkit-appearance: none;
    appearance: none;
}

.field__input:focus,
.field__select:focus,
.field__textarea:focus {
    outline: none;
    border-color: var(--rv-primary);
    box-shadow: 0 0 0 3px var(--rv-primary-50);
}

.field__input::placeholder,
.field__textarea::placeholder {
    color: var(--rv-faint);
}

.field__textarea {
    resize: vertical;
    min-height: 96px;
    line-height: 1.5;
}

.field__select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 16 16'%3E%3Cpath fill='%236b7691' d='M4 6l4 4 4-4z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    padding-right: 38px;
}

.field-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

/* ---------- 14. Upload card ---------- */
.upload-card {
    border: 2px dashed var(--rv-border-strong);
    border-radius: var(--rv-r-lg);
    background: var(--rv-bg-soft);
    padding: 22px 16px;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
    display: block;
}

.upload-card:hover,
.upload-card:active {
    border-color: var(--rv-primary);
    background: var(--rv-primary-tint);
}

.upload-card--filled {
    border-style: solid;
    border-color: var(--rv-success);
    background: var(--rv-success-50);
    padding: 0;
    overflow: hidden;
}

.upload-card__icon {
    width: 52px;
    height: 52px;
    margin: 0 auto 10px;
    border-radius: 50%;
    background: var(--rv-primary-50);
    color: var(--rv-primary);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
}

.upload-card__title {
    font-size: 14px;
    font-weight: 600;
    color: var(--rv-ink);
    margin-bottom: 4px;
}

.upload-card__hint {
    font-size: 12px;
    color: var(--rv-muted);
}

.upload-card__input {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
}

.upload-card__preview {
    display: block;
    width: 100%;
    max-height: 280px;
    object-fit: cover;
}

.upload-card__bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    background: rgba(255, 255, 255, 0.95);
    font-size: 12.5px;
    color: var(--rv-text);
}

.upload-card__bar i {
    color: var(--rv-success);
    margin-right: 6px;
}

.upload-card__change {
    color: var(--rv-primary);
    font-weight: 600;
    font-size: 12px;
}

/* ---------- 15. Location status ---------- */
.location-status {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    border-radius: var(--rv-r-md);
    border: 1px solid var(--rv-border);
    background: var(--rv-bg-soft);
    margin-bottom: 12px;
    transition: all 0.2s;
}

.location-status__icon {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--rv-bg);
    color: var(--rv-muted);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    flex-shrink: 0;
}

.location-status__body {
    flex: 1;
    min-width: 0;
}

.location-status__title {
    font-size: 13px;
    font-weight: 600;
    color: var(--rv-ink);
    line-height: 1.2;
}

.location-status__sub {
    font-size: 11.5px;
    color: var(--rv-muted);
    margin-top: 2px;
    word-break: break-all;
}

.location-status--loading {
    border-color: var(--rv-info);
    background: var(--rv-info-50);
}

.location-status--loading .location-status__icon {
    background: var(--rv-info);
    color: #fff;
    animation: rv-pulse 1.4s ease-in-out infinite;
}

.location-status--success {
    border-color: var(--rv-success);
    background: var(--rv-success-50);
}

.location-status--success .location-status__icon {
    background: var(--rv-success);
    color: #fff;
}

.location-status--error {
    border-color: var(--rv-danger);
    background: var(--rv-danger-50);
}

.location-status--error .location-status__icon {
    background: var(--rv-danger);
    color: #fff;
}

@keyframes rv-pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50%      { opacity: 0.7; transform: scale(0.94); }
}

.location-link {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    color: var(--rv-primary);
    font-weight: 600;
    margin-top: 8px;
}

/* ---------- 16. Action buttons ---------- */
.action-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    min-height: 50px;
    padding: 0 18px;
    border-radius: var(--rv-r-md);
    font-size: 15px;
    font-weight: 600;
    font-family: inherit;
    border: 1.5px solid transparent;
    cursor: pointer;
    transition: transform 0.1s, box-shadow 0.15s, background 0.15s;
    text-align: center;
    line-height: 1;
}

.action-button:active {
    transform: scale(0.98);
}

.action-button:disabled {
    opacity: 0.55;
    cursor: not-allowed;
    transform: none;
}

.action-button--primary {
    background: var(--rv-primary);
    color: #fff;
    box-shadow: 0 4px 12px rgba(13, 78, 166, 0.22);
}

.action-button--primary:hover {
    background: var(--rv-primary-700);
    color: #fff;
}

.action-button--accent {
    background: var(--rv-accent);
    color: #fff;
    box-shadow: 0 4px 12px rgba(255, 122, 26, 0.22);
}

.action-button--accent:hover {
    background: var(--rv-accent-600);
    color: #fff;
}

.action-button--ghost {
    background: var(--rv-surface);
    color: var(--rv-text);
    border-color: var(--rv-border);
}

.action-button--ghost:hover {
    background: var(--rv-bg-soft);
    color: var(--rv-text);
}

.action-button--soft {
    background: var(--rv-primary-50);
    color: var(--rv-primary);
}

.action-button--soft:hover {
    background: var(--rv-primary);
    color: #fff;
}

.action-button--danger {
    background: var(--rv-surface);
    color: var(--rv-danger);
    border-color: var(--rv-danger-50);
}

.action-button--danger:hover {
    background: var(--rv-danger);
    color: #fff;
    border-color: var(--rv-danger);
}

.action-button--success {
    background: var(--rv-success);
    color: #fff;
    border-color: var(--rv-success);
}

.action-button--success:hover {
    background: #1a8050;
    color: #fff;
    border-color: #1a8050;
}

.action-button--lg {
    min-height: 54px;
    font-size: 16px;
}

.action-stack > .action-button {
    margin-bottom: 10px;
}

.action-stack > .action-button:last-child {
    margin-bottom: 0;
}

/* Sticky submit area on form */
.submit-sticky {
    margin-top: 18px;
    padding-top: 4px;
}

/* ---------- 17. Filter card ---------- */
.filter-card {
    background: var(--rv-surface);
    border-radius: var(--rv-r-lg);
    padding: 14px;
    box-shadow: var(--rv-shadow-sm);
    border: 1px solid var(--rv-border);
    margin-bottom: 16px;
}

.search-input {
    position: relative;
    margin-bottom: 10px;
}

.search-input__icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--rv-muted);
    font-size: 16px;
    pointer-events: none;
}

.search-input__field {
    width: 100%;
    height: 48px;
    background: var(--rv-bg-soft);
    border: 1.5px solid var(--rv-border);
    border-radius: var(--rv-r-md);
    padding: 0 14px 0 42px;
    font-size: 14px;
    font-family: inherit;
    color: var(--rv-ink);
    -webkit-appearance: none;
    appearance: none;
}

.search-input__field:focus {
    outline: none;
    border-color: var(--rv-primary);
    background: var(--rv-surface);
    box-shadow: 0 0 0 3px var(--rv-primary-50);
}

.filter-row {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 8px;
    align-items: center;
}

.filter-row .field__select {
    height: 44px;
    min-height: 44px;
    padding-top: 0;
    padding-bottom: 0;
    margin: 0;
}

.btn-reset {
    height: 44px;
    padding: 0 14px;
    background: var(--rv-bg-soft);
    border: 1.5px solid var(--rv-border);
    border-radius: var(--rv-r-md);
    color: var(--rv-muted);
    font-size: 13px;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    text-decoration: none;
}

.btn-reset:hover {
    color: var(--rv-text);
    background: var(--rv-bg);
}

.results-count {
    font-size: 12px;
    color: var(--rv-muted);
    padding: 0 4px;
    margin-bottom: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.results-count strong {
    color: var(--rv-ink);
    font-weight: 700;
}

/* ---------- 18. Detail page ---------- */
.detail-photo {
    width: 100%;
    border-radius: var(--rv-r-lg);
    background: var(--rv-bg);
    overflow: hidden;
    margin-bottom: 14px;
    box-shadow: var(--rv-shadow-sm);
    border: 1px solid var(--rv-border);
    aspect-ratio: 4 / 3;
    display: block;
}

.detail-photo img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.detail-list {
    margin: 0;
    padding: 0;
}

.detail-list__row {
    padding: 12px 0;
    border-bottom: 1px solid var(--rv-border);
}

.detail-list__row:last-child {
    border-bottom: none;
}

.detail-list__row:first-child {
    padding-top: 0;
}

.detail-list__label {
    font-size: 11px;
    font-weight: 600;
    color: var(--rv-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 5px;
}

.detail-list__value {
    font-size: 14px;
    color: var(--rv-ink);
    line-height: 1.5;
    word-wrap: break-word;
}

.detail-list__value a {
    color: var(--rv-primary);
    word-break: break-all;
}

.detail-link-row {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 6px;
}

.contact-pill {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    height: 32px;
    padding: 0 12px;
    background: var(--rv-bg-soft);
    border-radius: var(--rv-r-pill);
    font-size: 12.5px;
    font-weight: 600;
    color: var(--rv-text);
}

.contact-pill--whatsapp { background: #e7f7ee; color: var(--rv-success); }
.contact-pill--call     { background: var(--rv-primary-50); color: var(--rv-primary); }

.contact-pill:hover {
    transform: translateY(-1px);
}

/* ---------- 19. Empty state ---------- */
.empty-state {
    text-align: center;
    padding: 40px 24px;
    background: var(--rv-surface);
    border-radius: var(--rv-r-lg);
    border: 1px solid var(--rv-border);
}

.empty-state__icon {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    background: var(--rv-primary-50);
    color: var(--rv-primary);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 32px;
    margin-bottom: 16px;
}

.empty-state__title {
    font-size: 16px;
    font-weight: 700;
    color: var(--rv-ink);
    margin-bottom: 6px;
}

.empty-state__text {
    font-size: 13px;
    color: var(--rv-muted);
    margin-bottom: 18px;
    line-height: 1.5;
}

/* ---------- 20. Alerts (replace ugly Bootstrap alerts) ---------- */
.alert-card {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 14px 16px;
    border-radius: var(--rv-r-md);
    border: 1px solid;
    background: var(--rv-surface);
    margin-bottom: 14px;
    box-shadow: var(--rv-shadow-sm);
}

.alert-card__icon {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    color: #fff;
}

.alert-card__body {
    flex: 1;
    min-width: 0;
    font-size: 13px;
    color: var(--rv-text);
    line-height: 1.45;
}

.alert-card__body strong {
    color: var(--rv-ink);
    display: block;
    font-size: 13.5px;
    margin-bottom: 2px;
}

.alert-card__close {
    background: transparent;
    border: none;
    color: var(--rv-faint);
    font-size: 18px;
    line-height: 1;
    padding: 0;
    cursor: pointer;
    flex-shrink: 0;
}

.alert-card--success {
    border-color: var(--rv-success);
    background: var(--rv-success-50);
}
.alert-card--success .alert-card__icon { background: var(--rv-success); }

.alert-card--error {
    border-color: var(--rv-danger);
    background: var(--rv-danger-50);
}
.alert-card--error .alert-card__icon { background: var(--rv-danger); }

.alert-card--info {
    border-color: var(--rv-info);
    background: var(--rv-info-50);
}
.alert-card--info .alert-card__icon { background: var(--rv-info); }

/* ---------- 21. Bottom navigation (flat 4-item, role-aware) ---------- */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 1040;
    background: var(--rv-surface);
    border-top: 1px solid var(--rv-border);
    box-shadow: var(--rv-shadow-nav);
    padding-bottom: env(safe-area-inset-bottom, 0px);
}

.bottom-nav__inner {
    max-width: var(--rv-app-max);
    margin: 0 auto;
    height: var(--rv-bottom-nav-h);
    display: grid;
    grid-template-columns: 1fr 1fr 1fr 1fr;
    align-items: center;
    position: relative;
}

.bottom-nav__inner--four {
    grid-template-columns: 1fr 1fr 1fr 1fr;
}

.bottom-nav__item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    height: 100%;
    color: var(--rv-faint);
    font-size: 10.5px;
    font-weight: 600;
    text-decoration: none;
    padding: 6px 4px 0;
    transition: color 0.15s;
    line-height: 1.1;
}

.bottom-nav__item span {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

.bottom-nav__item:hover {
    color: var(--rv-muted);
}

.bottom-nav__item i {
    font-size: 22px;
    line-height: 1;
}

.bottom-nav__item.is-active {
    color: var(--rv-primary);
}

.bottom-nav__item.is-active i {
    color: var(--rv-primary);
}

/* Accent variant for the "Input" entry (subtle warmth, not a FAB) */
.bottom-nav__item--accent i {
    color: var(--rv-accent-600);
}

.bottom-nav__item--accent.is-active,
.bottom-nav__item--accent.is-active i {
    color: var(--rv-accent);
}

/* Logout entry: subtle danger tint to set it apart */
.bottom-nav__item--logout {
    color: var(--rv-faint);
}

.bottom-nav__item--logout:hover,
.bottom-nav__item--logout:hover i {
    color: var(--rv-danger);
}

/* Safe area helper */
.safe-area-bottom {
    padding-bottom: env(safe-area-inset-bottom, 0px);
}

/* ---------- 22. Utility ---------- */
.text-muted-rv { color: var(--rv-muted); }
.text-faint-rv { color: var(--rv-faint); }

.divider {
    height: 1px;
    background: var(--rv-border);
    margin: 14px 0;
}

.spinner-rv {
    width: 18px;
    height: 18px;
    border: 2.5px solid rgba(255, 255, 255, 0.4);
    border-top-color: #fff;
    border-radius: 50%;
    animation: rv-spin 0.7s linear infinite;
    display: inline-block;
}

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

.fade-in {
    animation: rv-fade 0.3s ease-out;
}

@keyframes rv-fade {
    from { opacity: 0; transform: translateY(4px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ---------- 23. Desktop refinement (>=768px) ---------- */
@media (min-width: 768px) {
    .app-shell {
        max-width: 540px;
        padding: 20px;
        padding-top: calc(var(--rv-header-h) + 20px);
    }

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

    .visit-card__top {
        gap: 14px;
    }

    .visit-card__thumb {
        width: 76px;
        height: 76px;
    }

    .page-hero {
        padding: 26px;
    }

    .page-hero__title {
        font-size: 24px;
    }
}

@media (min-width: 992px) {
    .app-shell {
        max-width: 600px;
    }
}

/* Print */
@media print {
    .app-header, .bottom-nav, .submit-sticky, .visit-card__actions, .action-button {
        display: none !important;
    }
    body {
        background: #fff;
        padding: 0;
    }
    .mobile-card, .form-card, .visit-card, .stat-card {
        box-shadow: none;
        border: 1px solid #ccc;
        page-break-inside: avoid;
    }
}

/* =====================================================================
   v3 ADDITIONS — Multi-role auth, login, users, system check
===================================================================== */

/* ---------- 24. Role badge (small pill, used in header & user list) ---------- */
.role-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 1px 7px;
    border-radius: var(--rv-r-pill);
    font-size: 10px;
    font-weight: 700;
    line-height: 1.4;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    white-space: nowrap;
}

.role-badge--sales {
    background: var(--rv-info-50);
    color: var(--rv-info);
}

.role-badge--headsales {
    background: var(--rv-accent-50);
    color: var(--rv-accent-600);
}

.role-badge--management {
    background: var(--rv-primary-50);
    color: var(--rv-primary);
}

/* Header subtitle layout when showing user name + role badge */
.app-header__user-name {
    font-weight: 600;
    color: var(--rv-text);
    margin-right: 6px;
}

.app-header__subtitle {
    display: flex;
    align-items: center;
    gap: 4px;
}

/* ---------- 25. Login page ---------- */
.login-page {
    background:
        radial-gradient(circle at 20% 0%, rgba(13, 78, 166, 0.06) 0%, transparent 50%),
        radial-gradient(circle at 80% 100%, rgba(255, 122, 26, 0.06) 0%, transparent 50%),
        var(--rv-bg);
    padding-bottom: 0;
    min-height: 100vh;
}

.login-shell {
    width: 100%;
    max-width: 420px;
    margin: 0 auto;
    padding: 32px 18px 24px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.login-card {
    background: var(--rv-surface);
    border-radius: var(--rv-r-xl);
    padding: 28px 24px;
    box-shadow: var(--rv-shadow-lg);
    border: 1px solid var(--rv-border);
}

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

.login-brand__logo {
    width: 48px;
    height: 48px;
    border-radius: 14px;
    background: linear-gradient(135deg, var(--rv-primary), var(--rv-primary-700));
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 17px;
    letter-spacing: -0.02em;
    box-shadow: 0 4px 10px rgba(13, 78, 166, 0.25);
    flex-shrink: 0;
}

.login-brand__app {
    font-size: 17px;
    font-weight: 800;
    color: var(--rv-ink);
    letter-spacing: -0.01em;
    line-height: 1.1;
}

.login-brand__company {
    font-size: 12px;
    color: var(--rv-muted);
    margin-top: 1px;
}

.login-title {
    font-size: 20px;
    font-weight: 700;
    color: var(--rv-ink);
    margin-bottom: 6px;
    letter-spacing: -0.01em;
}

.login-sub {
    font-size: 13px;
    color: var(--rv-muted);
    margin-bottom: 18px;
}

.login-foot {
    text-align: center;
    font-size: 12px;
    color: var(--rv-muted);
    margin-top: 22px;
    padding-top: 18px;
    border-top: 1px solid var(--rv-border);
}

/* ---------- 26. User list (users.php) ---------- */
.user-card {
    background: var(--rv-surface);
    border-radius: var(--rv-r-lg);
    border: 1px solid var(--rv-border);
    box-shadow: var(--rv-shadow-sm);
    padding: 14px;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-card__avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--rv-primary-50);
    color: var(--rv-primary);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 14px;
    flex-shrink: 0;
}

.user-card--inactive .user-card__avatar {
    background: var(--rv-bg);
    color: var(--rv-faint);
}

.user-card__body {
    flex: 1;
    min-width: 0;
}

.user-card__name {
    font-size: 14px;
    font-weight: 700;
    color: var(--rv-ink);
    line-height: 1.2;
    margin-bottom: 3px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.user-card__meta {
    font-size: 12px;
    color: var(--rv-muted);
    line-height: 1.3;
    margin-top: 4px;
    display: flex;
    flex-wrap: wrap;
    gap: 4px 8px;
    align-items: center;
}

.user-card__meta i {
    font-size: 13px;
    color: var(--rv-faint);
}

.user-card__actions {
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex-shrink: 0;
}

.user-card__actions .visit-card__action {
    height: 32px;
    padding: 0 10px;
    font-size: 11.5px;
}

.user-card--inactive .user-card__name {
    color: var(--rv-muted);
    text-decoration: line-through;
    text-decoration-thickness: 1px;
    text-decoration-color: var(--rv-faint);
}

/* ---------- 27. Check system list ---------- */
.check-list {
    margin: 0;
    padding: 0;
    list-style: none;
}

.check-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid var(--rv-border);
}

.check-row:last-child { border-bottom: none; }

.check-row__icon {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    color: #fff;
}

.check-row__icon--ok      { background: var(--rv-success); }
.check-row__icon--warn    { background: var(--rv-warning); }
.check-row__icon--error   { background: var(--rv-danger); }

.check-row__body { flex: 1; min-width: 0; }

.check-row__title {
    font-size: 13.5px;
    font-weight: 600;
    color: var(--rv-ink);
    line-height: 1.2;
}

.check-row__detail {
    font-size: 12px;
    color: var(--rv-muted);
    margin-top: 2px;
    word-break: break-word;
}

.check-row__pill {
    flex-shrink: 0;
    font-size: 10px;
    font-weight: 700;
    padding: 3px 9px;
    border-radius: var(--rv-r-pill);
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.check-row__pill--ok    { background: var(--rv-success-50); color: var(--rv-success); }
.check-row__pill--warn  { background: var(--rv-warning-50); color: var(--rv-warning); }
.check-row__pill--error { background: var(--rv-danger-50);  color: var(--rv-danger); }

/* ---------- 28. Sales-info card on form (when role=sales, no head dropdown) ---------- */
.assigned-head {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    background: var(--rv-primary-50);
    border-radius: var(--rv-r-md);
    margin-top: 4px;
}

.assigned-head__icon {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--rv-primary);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 700;
    flex-shrink: 0;
}

.assigned-head__label {
    font-size: 11px;
    color: var(--rv-muted);
    font-weight: 500;
    margin-bottom: 1px;
}

.assigned-head__name {
    font-size: 14px;
    color: var(--rv-ink);
    font-weight: 700;
    line-height: 1.1;
}

.assigned-head--unassigned {
    background: var(--rv-warning-50);
}

.assigned-head--unassigned .assigned-head__icon {
    background: var(--rv-warning);
}

/* =====================================================================
   v4 ADDITIONS — rekap, notifications, WhatsApp queue, 5-col bottom nav
===================================================================== */

/* ---------- 29. Bottom nav 5-column variant ---------- */
.bottom-nav__inner--five {
    grid-template-columns: 1fr 1fr 1fr 1fr 1fr;
}

.bottom-nav__inner--five .bottom-nav__item {
    font-size: 9.5px;
    padding: 6px 2px 0;
}

.bottom-nav__inner--five .bottom-nav__item i {
    font-size: 20px;
}

@media (max-width: 359px) {
    .bottom-nav__inner--five .bottom-nav__item i { font-size: 18px; }
    .bottom-nav__inner--five .bottom-nav__item   { font-size: 9px; }
}

/* Bell badge inside nav item */
.nav-bell-wrap {
    position: relative;
    display: inline-flex;
}

.nav-bell-badge {
    position: absolute;
    top: -4px;
    right: -7px;
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    border-radius: 8px;
    background: var(--rv-danger);
    color: #fff;
    font-size: 9px;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1.5px solid var(--rv-surface);
    line-height: 1;
}

/* ---------- 30. Header bell + logout (right-side cluster) ---------- */
.app-header__actions {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.app-header__action {
    width: 36px;
    height: 36px;
    border-radius: var(--rv-r-md);
    background: transparent;
    color: var(--rv-muted);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    font-size: 18px;
    border: none;
    transition: background 0.15s, color 0.15s;
    position: relative;
    cursor: pointer;
}

.app-header__action:hover {
    background: var(--rv-bg);
    color: var(--rv-ink);
}

.app-header__action--bell:hover { color: var(--rv-primary); }
.app-header__action--logout:hover { color: var(--rv-danger); }

.app-header__action-badge {
    position: absolute;
    top: 2px;
    right: 2px;
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    border-radius: 8px;
    background: var(--rv-danger);
    color: #fff;
    font-size: 9px;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1.5px solid var(--rv-surface);
    line-height: 1;
}

/* ---------- 31. Notification list ---------- */
.notif-tabs {
    display: flex;
    gap: 6px;
    background: var(--rv-bg-soft);
    border-radius: var(--rv-r-md);
    padding: 4px;
    margin-bottom: 14px;
}

.notif-tab {
    flex: 1;
    text-align: center;
    padding: 9px 6px;
    border-radius: calc(var(--rv-r-md) - 4px);
    font-size: 13px;
    font-weight: 600;
    color: var(--rv-muted);
    text-decoration: none;
    transition: background 0.15s, color 0.15s;
}

.notif-tab.is-active {
    background: var(--rv-surface);
    color: var(--rv-primary);
    box-shadow: var(--rv-shadow-sm);
}

.notif-card {
    background: var(--rv-surface);
    border-radius: var(--rv-r-lg);
    border: 1px solid var(--rv-border);
    box-shadow: var(--rv-shadow-sm);
    padding: 12px 14px;
    margin-bottom: 10px;
    display: flex;
    gap: 12px;
    align-items: flex-start;
    text-decoration: none;
    color: inherit;
    transition: border-color 0.15s, transform 0.1s;
}

.notif-card:hover { border-color: var(--rv-primary-200); }
.notif-card:active { transform: scale(0.99); }

.notif-card--unread {
    background: var(--rv-primary-50);
    border-color: var(--rv-primary-200);
}

.notif-card--unread .notif-card__title { color: var(--rv-ink); }

.notif-card__icon {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    color: #fff;
}

.notif-card__icon--visit_created  { background: var(--rv-primary); }
.notif-card__icon--team_visit     { background: var(--rv-accent-600); }
.notif-card__icon--deadline_today { background: var(--rv-warning); }
.notif-card__icon--deadline_overdue { background: var(--rv-danger); }
.notif-card__icon--system         { background: var(--rv-muted); }
.notif-card__icon--user_created   { background: var(--rv-success); }

.notif-card__body {
    flex: 1;
    min-width: 0;
}

.notif-card__title {
    font-size: 14px;
    font-weight: 700;
    color: var(--rv-ink);
    margin-bottom: 3px;
    line-height: 1.3;
    display: flex;
    align-items: center;
    gap: 6px;
}

.notif-card__dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--rv-primary);
    flex-shrink: 0;
}

.notif-card__message {
    font-size: 13px;
    color: var(--rv-text);
    line-height: 1.4;
    word-break: break-word;
}

.notif-card__time {
    font-size: 11px;
    color: var(--rv-faint);
    margin-top: 4px;
}

/* ---------- 32. Rekap summary cards (more compact than dashboard stats) ---------- */
.rekap-summary {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 16px;
}

.rekap-summary__card {
    background: var(--rv-surface);
    border-radius: var(--rv-r-md);
    border: 1px solid var(--rv-border);
    box-shadow: var(--rv-shadow-sm);
    padding: 12px;
    min-height: 78px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.rekap-summary__label {
    font-size: 11px;
    color: var(--rv-muted);
    font-weight: 600;
    line-height: 1.3;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

.rekap-summary__value {
    font-size: 22px;
    font-weight: 800;
    color: var(--rv-ink);
    line-height: 1;
    letter-spacing: -0.02em;
}

.rekap-summary__hint {
    font-size: 10.5px;
    color: var(--rv-faint);
    margin-top: 2px;
}

.rekap-summary__card--warning .rekap-summary__value { color: var(--rv-warning); }
.rekap-summary__card--danger  .rekap-summary__value { color: var(--rv-danger);  }
.rekap-summary__card--success .rekap-summary__value { color: var(--rv-success); }
.rekap-summary__card--accent  .rekap-summary__value { color: var(--rv-accent-600); }

@media (min-width: 480px) {
    .rekap-summary { grid-template-columns: 1fr 1fr 1fr; }
}

@media (min-width: 768px) {
    .rekap-summary { grid-template-columns: 1fr 1fr 1fr 1fr; }
}

/* ---------- 33. Deadline status pills ---------- */
.deadline-pill {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border-radius: var(--rv-r-pill);
    font-size: 10.5px;
    font-weight: 700;
    line-height: 1.4;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    white-space: nowrap;
}

.deadline-pill--no_deadline { background: var(--rv-bg-soft); color: var(--rv-faint); }
.deadline-pill--upcoming    { background: var(--rv-info-50); color: var(--rv-info); }
.deadline-pill--due_today   { background: var(--rv-warning-50); color: var(--rv-warning); }
.deadline-pill--overdue     { background: var(--rv-danger-50); color: var(--rv-danger); }
.deadline-pill--completed   { background: var(--rv-success-50); color: var(--rv-success); }

/* ---------- 34. WhatsApp queue card ---------- */
.wa-card {
    background: var(--rv-surface);
    border-radius: var(--rv-r-lg);
    border: 1px solid var(--rv-border);
    box-shadow: var(--rv-shadow-sm);
    padding: 14px;
    margin-bottom: 10px;
}

.wa-card__head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 10px;
}

.wa-card__user {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
    min-width: 0;
}

.wa-card__avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: #25d36633;
    color: #128c45;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    flex-shrink: 0;
}

.wa-card__name {
    font-size: 14px;
    font-weight: 700;
    color: var(--rv-ink);
    line-height: 1.2;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.wa-card__phone {
    font-size: 12px;
    color: var(--rv-muted);
    margin-top: 2px;
}

.wa-status {
    flex-shrink: 0;
    font-size: 10px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: var(--rv-r-pill);
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

.wa-status--pending     { background: var(--rv-warning-50); color: var(--rv-warning); }
.wa-status--sent        { background: var(--rv-success-50); color: var(--rv-success); }
.wa-status--manual_sent { background: var(--rv-info-50);    color: var(--rv-info); }
.wa-status--failed      { background: var(--rv-danger-50);  color: var(--rv-danger); }

.wa-card__message {
    background: var(--rv-bg-soft);
    border-radius: var(--rv-r-md);
    padding: 10px 12px;
    font-size: 12.5px;
    color: var(--rv-text);
    line-height: 1.5;
    white-space: pre-wrap;
    max-height: 180px;
    overflow: auto;
    word-break: break-word;
    margin-bottom: 10px;
    font-family: var(--rv-font-mono, ui-monospace, SFMono-Regular, "SF Mono", Consolas, monospace);
}

.wa-card__actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.wa-btn {
    height: 40px;
    border-radius: var(--rv-r-md);
    border: none;
    font-size: 13px;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    text-decoration: none;
    cursor: pointer;
    transition: filter 0.15s;
}

.wa-btn--whatsapp {
    background: #25d366;
    color: #fff;
}

.wa-btn--whatsapp:hover {
    background: #20bf5a;
    color: #fff;
}

.wa-btn--mark {
    background: var(--rv-bg);
    color: var(--rv-text);
    border: 1px solid var(--rv-border);
}

.wa-btn--mark:hover {
    background: var(--rv-bg-soft);
}

.wa-card__time {
    font-size: 11px;
    color: var(--rv-faint);
    text-align: right;
    margin-top: 8px;
}

/* ---------- 35. Print rekap (only loaded when explicitly used) ---------- */
@media print {
    .no-print, .app-header, .bottom-nav, .filter-card, .submit-sticky,
    .quick-actions, .action-stack, .action-button {
        display: none !important;
    }
    body { background: #fff; }
    .app-shell { padding: 0 !important; max-width: 100% !important; }
    .print-shell { padding: 24px; }
    .print-shell__header { margin-bottom: 16px; padding-bottom: 16px; border-bottom: 2px solid #333; }
    .print-shell__title { font-size: 22px; font-weight: 800; margin: 0; }
    .print-shell__sub   { font-size: 13px; color: #555; margin-top: 4px; }
    .print-shell__meta  { font-size: 12px; color: #777; margin-top: 6px; }
    .print-table {
        width: 100%;
        border-collapse: collapse;
        font-size: 11px;
        margin-top: 16px;
    }
    .print-table th, .print-table td {
        border: 1px solid #888;
        padding: 6px 8px;
        text-align: left;
        vertical-align: top;
    }
    .print-table th { background: #f0f0f0; font-weight: 700; }
    .print-table tr { page-break-inside: avoid; }
    .print-summary { margin: 16px 0; }
    .print-summary li { font-size: 12px; padding: 2px 0; }
}

/* On-screen print page (before user clicks Print) */
.print-shell {
    background: #fff;
    padding: 20px;
    border-radius: var(--rv-r-lg);
    box-shadow: var(--rv-shadow-sm);
    margin-bottom: 16px;
}

.print-shell__header {
    border-bottom: 2px solid var(--rv-border);
    padding-bottom: 14px;
    margin-bottom: 14px;
}

.print-shell__title {
    font-size: 20px;
    font-weight: 800;
    margin: 0;
    color: var(--rv-ink);
}

.print-shell__sub {
    font-size: 13px;
    color: var(--rv-muted);
    margin-top: 4px;
}

.print-shell__meta {
    font-size: 11.5px;
    color: var(--rv-faint);
    margin-top: 6px;
}

.print-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 11.5px;
}

.print-table th, .print-table td {
    border: 1px solid var(--rv-border);
    padding: 6px 8px;
    text-align: left;
    vertical-align: top;
    word-break: break-word;
}

.print-table th {
    background: var(--rv-bg-soft);
    font-weight: 700;
    color: var(--rv-ink);
}

/* Make print page horizontally scrollable on phone (table is wide by nature) */
.print-table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin-top: 12px;
}

/* ---------- 36. Photo compression status indicator (v6) ---------- */
.photo-compress-status {
    margin-top: 8px;
    font-size: 12px;
    line-height: 1.4;
    color: var(--rv-muted);
    text-align: center;
    min-height: 18px;
    transition: color 0.15s;
}

.photo-compress-status:empty {
    margin-top: 0;
    min-height: 0;
}

.photo-compress-status--working {
    color: var(--rv-warning);
    font-weight: 600;
}

.photo-compress-status--ok {
    color: var(--rv-success);
    font-weight: 600;
}

/* =====================================================================
   v6 · Multi-media upload UI (replaces single foto card)
===================================================================== */
.media-picker-group {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
    margin-bottom: 12px;
}

@media (min-width: 380px) {
    .media-picker-group {
        grid-template-columns: 1fr 1fr;
    }
}

.media-picker-card {
    border: 2px dashed var(--rv-border-strong);
    border-radius: var(--rv-r-lg);
    background: var(--rv-bg-soft);
    padding: 18px 14px;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
    display: block;
    position: relative;
    min-height: 96px;
}

.media-picker-card:hover,
.media-picker-card:active {
    border-color: var(--rv-primary);
    background: var(--rv-primary-tint);
}

.media-picker-card--accent {
    border-color: var(--rv-accent);
    background: var(--rv-accent-50);
}

.media-picker-card--accent:hover,
.media-picker-card--accent:active {
    border-color: var(--rv-accent-600);
    background: #ffe6cd;
}

.media-picker-card__icon {
    width: 44px;
    height: 44px;
    margin: 0 auto 8px;
    border-radius: 50%;
    background: var(--rv-primary-50);
    color: var(--rv-primary);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
}

.media-picker-card--accent .media-picker-card__icon {
    background: #fff;
    color: var(--rv-accent-600);
}

.media-picker-card__title {
    font-size: 13.5px;
    font-weight: 700;
    color: var(--rv-ink);
    margin-bottom: 2px;
}

.media-picker-card__hint {
    font-size: 11.5px;
    color: var(--rv-muted);
    line-height: 1.35;
}

.media-picker-card__input {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
}

.media-totals {
    text-align: center;
    font-size: 12px;
    color: var(--rv-muted);
    padding: 6px 0 2px;
    min-height: 18px;
}

.media-totals:empty { min-height: 0; padding: 0; }

.media-empty {
    text-align: center;
    font-size: 12px;
    color: var(--rv-faint);
    padding: 14px 8px;
    border: 1px dashed var(--rv-border);
    border-radius: var(--rv-r-md);
    background: var(--rv-bg-soft);
}

.media-preview-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    margin-top: 10px;
}

@media (min-width: 480px) {
    .media-preview-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

.media-preview__card {
    position: relative;
    background: var(--rv-surface);
    border: 1px solid var(--rv-border);
    border-radius: var(--rv-r-md);
    padding: 8px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    box-shadow: var(--rv-shadow-sm);
}

.media-preview__thumb {
    width: 100%;
    aspect-ratio: 4 / 3;
    border-radius: var(--rv-r-sm);
    overflow: hidden;
    background: var(--rv-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 32px;
    color: var(--rv-faint);
    border: 1px solid var(--rv-border);
}

.media-preview__thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.media-preview__card--video .media-preview__thumb {
    background: linear-gradient(135deg, #1f2937, #0e1a30);
    color: #fff;
    font-size: 36px;
}

.media-preview__card--heic .media-preview__thumb {
    background: var(--rv-warning-50);
    color: var(--rv-warning);
}

.media-preview__info {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.media-preview__name {
    font-size: 11.5px;
    font-weight: 600;
    color: var(--rv-ink);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.3;
}

.media-preview__meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    font-size: 11px;
    color: var(--rv-muted);
}

.media-preview__badge {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 2px 6px;
    border-radius: var(--rv-r-pill);
    font-weight: 600;
    font-size: 10px;
    line-height: 1;
}

.media-preview__badge--image {
    background: var(--rv-primary-50);
    color: var(--rv-primary);
}

.media-preview__badge--video {
    background: var(--rv-accent-50);
    color: var(--rv-accent-600);
}

.media-preview__status {
    font-size: 10.5px;
    line-height: 1.35;
    color: var(--rv-muted);
    min-height: 14px;
}

.media-preview__status--working {
    color: var(--rv-warning);
    font-weight: 600;
}

.media-preview__status--ok {
    color: var(--rv-success);
    font-weight: 600;
}

.media-preview__status--warning {
    color: var(--rv-warning);
}

.media-preview__remove {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 24px;
    height: 24px;
    border: none;
    background: rgba(255, 255, 255, 0.95);
    color: var(--rv-danger);
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    cursor: pointer;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.18);
    padding: 0;
}

.media-preview__remove:hover { background: var(--rv-danger-50); }

/* =====================================================================
   v6 · Detail multi-media gallery + lightbox
===================================================================== */
.detail-media-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    margin-bottom: 14px;
}

@media (min-width: 480px) {
    .detail-media-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

.detail-media-grid__item {
    aspect-ratio: 1 / 1;
    border-radius: var(--rv-r-md);
    overflow: hidden;
    background: var(--rv-bg);
    border: 1px solid var(--rv-border);
    display: block;
    position: relative;
}

.detail-media-grid__item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.detail-media-grid__item--video {
    background: linear-gradient(135deg, #1f2937, #0e1a30);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 32px;
}

.detail-media-grid__item video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    background: #000;
}

.detail-media-grid__badge {
    position: absolute;
    top: 6px;
    left: 6px;
    background: rgba(14, 26, 48, 0.78);
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    padding: 3px 7px;
    border-radius: var(--rv-r-pill);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    backdrop-filter: blur(2px);
}

.detail-media-grid__delete {
    position: absolute;
    bottom: 6px;
    right: 6px;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: rgba(220, 38, 38, 0.92);
    color: #fff;
    border: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    cursor: pointer;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
}

.detail-media-grid__delete:hover { background: var(--rv-danger); }

.detail-media-empty {
    text-align: center;
    padding: 40px 16px;
    color: var(--rv-faint);
    font-size: 13px;
    border: 1px dashed var(--rv-border);
    border-radius: var(--rv-r-md);
    margin-bottom: 14px;
    background: var(--rv-bg-soft);
}

.detail-media-empty i {
    font-size: 36px;
    display: block;
    margin-bottom: 6px;
}

/* Card thumbnail badge: "+N" overlay for multi-media */
.card-thumb-wrap {
    position: relative;
    flex-shrink: 0;
}

.card-thumb-overlay {
    position: absolute;
    top: 4px;
    right: 4px;
    background: rgba(14, 26, 48, 0.85);
    color: #fff;
    font-size: 9.5px;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: var(--rv-r-pill);
    line-height: 1.3;
    pointer-events: none;
    backdrop-filter: blur(2px);
}

.card-thumb-overlay i {
    font-size: 9px;
    margin-right: 2px;
}

/* =====================================================================
   v6 · Edit shortcut button (small, on card)
===================================================================== */
.visit-card__action--edit {
    color: var(--rv-warning);
}

.visit-card__action--edit:hover {
    background: var(--rv-warning-50);
}

/* =====================================================================
   v6 · Reset / cleanup confirmation panel
===================================================================== */
.danger-panel {
    border: 1px solid var(--rv-danger);
    background: var(--rv-danger-50);
    border-radius: var(--rv-r-lg);
    padding: 14px 16px;
    margin-bottom: 14px;
}

.danger-panel__title {
    color: var(--rv-danger);
    font-weight: 700;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 6px;
}

.danger-panel__body {
    font-size: 13px;
    color: var(--rv-text);
    line-height: 1.5;
}

.danger-panel ul {
    margin: 8px 0 0 18px;
    padding: 0;
    font-size: 12.5px;
}

/* ---------- v7: Target Management ---------- */
.target-card {
    background: var(--rv-surface);
    border: 1px solid var(--rv-border);
    border-radius: var(--rv-r-lg);
    padding: 14px;
    margin-bottom: 12px;
    box-shadow: var(--rv-shadow-sm);
    transition: box-shadow 0.15s ease, transform 0.15s ease;
}

.target-card:hover {
    box-shadow: var(--rv-shadow-md);
}

.target-card__head {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.target-card__avatar {
    flex-shrink: 0;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--rv-primary-50);
    color: var(--rv-primary);
    font-weight: 700;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.target-card__info {
    flex: 1;
    min-width: 0;
}

.target-card__name {
    font-size: 15px;
    font-weight: 700;
    color: var(--rv-ink);
    line-height: 1.25;
    word-break: break-word;
    margin-bottom: 4px;
}

.target-card__meta {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
    font-size: 12px;
    color: var(--rv-muted);
}

.target-card__meta i {
    margin-right: 3px;
}

.target-card__pct {
    flex-shrink: 0;
    text-align: right;
    min-width: 64px;
}

.target-card__pct-value {
    font-size: 22px;
    font-weight: 800;
    color: var(--rv-ink);
    line-height: 1;
    letter-spacing: -0.02em;
}

.target-card__pct-label {
    font-size: 10.5px;
    color: var(--rv-faint);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-top: 2px;
    font-weight: 600;
}

.target-card__bar {
    width: 100%;
    height: 8px;
    background: var(--rv-border);
    border-radius: 999px;
    overflow: hidden;
    margin-bottom: 12px;
}

.target-card__bar-fill {
    height: 100%;
    border-radius: 999px;
    background: var(--rv-primary);
    transition: width 0.4s ease;
    min-width: 2px;
}

.target-card__metrics {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 10px;
}

.target-card__metric {
    background: var(--rv-bg-soft);
    border: 1px solid var(--rv-border);
    border-radius: var(--rv-r-md);
    padding: 10px;
}

.target-card__metric-label {
    font-size: 11px;
    color: var(--rv-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-weight: 600;
    margin-bottom: 4px;
}

.target-card__metric-value {
    font-size: 17px;
    font-weight: 800;
    color: var(--rv-ink);
    line-height: 1.2;
    letter-spacing: -0.01em;
}

.target-card__metric-target {
    font-size: 13px;
    font-weight: 500;
    color: var(--rv-faint);
    margin-left: 2px;
}

.target-card__metric-pct {
    font-size: 11.5px;
    color: var(--rv-muted);
    font-weight: 600;
    margin-top: 2px;
}

.target-card__notes {
    background: var(--rv-primary-tint);
    border: 1px solid var(--rv-primary-50);
    border-radius: var(--rv-r-md);
    padding: 8px 10px;
    font-size: 12.5px;
    color: var(--rv-text);
    line-height: 1.45;
    margin-bottom: 10px;
}

.target-card__notes i {
    color: var(--rv-primary);
    margin-right: 4px;
}

.target-card__no-target {
    background: var(--rv-bg-soft);
    border: 1px dashed var(--rv-border-strong);
    border-radius: var(--rv-r-md);
    padding: 12px;
    font-size: 12.5px;
    color: var(--rv-muted);
    line-height: 1.5;
    margin-bottom: 10px;
}

.target-card__no-target i {
    color: var(--rv-info);
    margin-right: 4px;
}

.target-card__no-target strong {
    color: var(--rv-text);
}

.target-card__actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.target-card__actions:has(form:only-child),
.target-card__actions:has(a:only-child) {
    grid-template-columns: 1fr;
}

/* Compact target progress for dashboard preview card */
.target-mini {
    background: var(--rv-surface);
    border: 1px solid var(--rv-border);
    border-radius: var(--rv-r-lg);
    padding: 14px;
    margin-bottom: 14px;
    box-shadow: var(--rv-shadow-sm);
}

.target-mini__head {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}

.target-mini__icon {
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--rv-primary-50);
    color: var(--rv-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 17px;
}

.target-mini__title {
    flex: 1;
    font-size: 13.5px;
    font-weight: 700;
    color: var(--rv-ink);
    line-height: 1.3;
}

.target-mini__title-sub {
    font-size: 11.5px;
    color: var(--rv-muted);
    font-weight: 500;
    margin-top: 1px;
}

.target-mini__pct {
    font-size: 18px;
    font-weight: 800;
    color: var(--rv-ink);
    flex-shrink: 0;
    letter-spacing: -0.02em;
}

.target-mini__bar {
    width: 100%;
    height: 6px;
    background: var(--rv-border);
    border-radius: 999px;
    overflow: hidden;
    margin-bottom: 8px;
}

.target-mini__bar-fill {
    height: 100%;
    border-radius: 999px;
    background: var(--rv-primary);
    transition: width 0.4s ease;
    min-width: 2px;
}

.target-mini__row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 12px;
    color: var(--rv-muted);
}

.target-mini__row strong {
    color: var(--rv-text);
    font-weight: 700;
}

.target-mini__cta {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    color: var(--rv-primary);
    font-size: 12px;
    font-weight: 600;
    text-decoration: none;
}

/* =====================================================================
   v8 — DESKTOP LAYOUT SYSTEM
   ---------------------------------------------------------------------
   Until 1023px the existing mobile/tablet shell stays.
   At 1024px+ we switch to an admin-style layout:
       [ sidebar ][ topbar           ]
       [        ][ content area      ]

   Mobile keeps bottom-nav, hides sidebar.
   Desktop hides bottom-nav + mobile header, shows sidebar + topbar.

   Breakpoints:
     - Mobile:  <= 767px
     - Tablet:  768px - 1023px
     - Desktop: >= 1024px
===================================================================== */

:root {
    --rv-sidebar-w: 248px;
    --rv-topbar-h: 64px;
    --rv-desktop-max: 1320px;
}

/* ---------- Desktop sidebar — hidden on mobile ---------- */
.app-sidebar {
    display: none;
}

/* ---------- Desktop topbar — hidden on mobile ---------- */
.app-topbar {
    display: none;
}

/* ---------- Desktop active filter chips ---------- */
.filter-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
}

.filter-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    background: var(--rv-primary-50);
    color: var(--rv-primary);
    border-radius: var(--rv-r-pill);
    font-size: 12px;
    font-weight: 600;
    text-decoration: none;
}

.filter-chip__close {
    color: var(--rv-primary);
    text-decoration: none;
    font-size: 14px;
    line-height: 1;
    margin-left: 2px;
    opacity: 0.7;
}
.filter-chip__close:hover { opacity: 1; }

/* ---------- v8: Quick period buttons ---------- */
.quick-period-row {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 10px;
}

.quick-period-btn {
    flex: 0 0 auto;
    padding: 6px 12px;
    border: 1px solid var(--rv-border-strong);
    background: var(--rv-surface);
    color: var(--rv-text);
    border-radius: var(--rv-r-pill);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.15s ease;
}

.quick-period-btn:hover {
    border-color: var(--rv-primary);
    color: var(--rv-primary);
}

.quick-period-btn.is-active {
    background: var(--rv-primary);
    color: #fff;
    border-color: var(--rv-primary);
}
.quick-period-btn.is-active:hover {
    color: #fff;
}

/* ---------- v8: Desktop-only data table ---------- */
.dt-wrap {
    display: none;
}

/* ---------- v8: Mobile-only block ---------- */
.dt-mobile-only {
    display: block;
}

/* ---------- v8: Filter toggle (mobile only) ---------- */
.filter-toggle {
    display: none;
}

/* ---------- v8: Section grid (used by management dashboard) ---------- */
.dash-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 14px;
}

/* ---------- v8: Compact stat tile (executive summary) ---------- */
.kpi-tile {
    background: var(--rv-surface);
    border: 1px solid var(--rv-border);
    border-radius: var(--rv-r-md);
    padding: 14px 16px;
    box-shadow: var(--rv-shadow-sm);
}
.kpi-tile__label {
    color: var(--rv-muted);
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 4px;
}
.kpi-tile__value {
    color: var(--rv-ink);
    font-size: 26px;
    font-weight: 800;
    line-height: 1.1;
}
.kpi-tile__sub {
    color: var(--rv-muted);
    font-size: 12px;
    margin-top: 4px;
}
.kpi-tile--warning .kpi-tile__value { color: var(--rv-warning); }
.kpi-tile--danger  .kpi-tile__value { color: var(--rv-danger); }
.kpi-tile--success .kpi-tile__value { color: var(--rv-success); }

/* ---------- v8: Panel (boxed content area) ---------- */
.panel {
    background: var(--rv-surface);
    border: 1px solid var(--rv-border);
    border-radius: var(--rv-r-md);
    box-shadow: var(--rv-shadow-sm);
    margin-bottom: 14px;
}
.panel__head {
    padding: 14px 18px;
    border-bottom: 1px solid var(--rv-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.panel__title {
    font-size: 15px;
    font-weight: 700;
    color: var(--rv-ink);
}
.panel__sub {
    font-size: 12px;
    color: var(--rv-muted);
    font-weight: 500;
    margin-top: 2px;
}
.panel__body {
    padding: 14px 18px;
}
.panel__body--flush {
    padding: 0;
}

/* ---------- v8: Section title ---------- */
.dash-section-title {
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--rv-muted);
    margin: 14px 0 8px;
}

/* ---------- v8: Action greeting (sales dashboard hero) ---------- */
.action-hero {
    background: linear-gradient(135deg, var(--rv-primary) 0%, var(--rv-primary-700) 100%);
    color: #fff;
    border-radius: var(--rv-r-lg);
    padding: 18px 20px;
    margin-bottom: 14px;
    box-shadow: var(--rv-shadow-md);
}
.action-hero__greeting {
    font-size: 13px;
    font-weight: 600;
    opacity: 0.9;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}
.action-hero__title {
    font-size: 22px;
    font-weight: 800;
    margin-top: 4px;
    color: #fff;
}
.action-hero__sub {
    margin-top: 4px;
    font-size: 13px;
    opacity: 0.92;
}

/* ---------- v8: Insight callout (e.g. who hasn't input today) ---------- */
.insight-callout {
    background: var(--rv-warning-50);
    border: 1px solid color-mix(in srgb, var(--rv-warning) 30%, transparent);
    border-radius: var(--rv-r-md);
    padding: 12px 14px;
    margin-bottom: 12px;
    display: flex;
    gap: 12px;
    align-items: flex-start;
}
.insight-callout--danger {
    background: var(--rv-danger-50);
    border-color: color-mix(in srgb, var(--rv-danger) 30%, transparent);
}
.insight-callout--success {
    background: var(--rv-success-50);
    border-color: color-mix(in srgb, var(--rv-success) 30%, transparent);
}
.insight-callout__icon {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--rv-warning);
    color: #fff;
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.insight-callout--danger  .insight-callout__icon { background: var(--rv-danger); }
.insight-callout--success .insight-callout__icon { background: var(--rv-success); }
.insight-callout__body { flex: 1; min-width: 0; }
.insight-callout__title {
    font-weight: 700;
    color: var(--rv-ink);
    font-size: 14px;
}
.insight-callout__text {
    color: var(--rv-text);
    font-size: 13px;
    margin-top: 2px;
}

/* ---------- v8: User table (desktop) ---------- */
.user-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    background: var(--rv-surface);
    font-size: 13.5px;
}
.user-table th,
.user-table td {
    padding: 12px 14px;
    border-bottom: 1px solid var(--rv-border);
    text-align: left;
    vertical-align: middle;
}
.user-table th {
    background: var(--rv-bg-soft);
    color: var(--rv-muted);
    font-size: 11.5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.user-table tbody tr:hover {
    background: var(--rv-primary-tint);
}
.user-table tbody tr.is-self {
    background: var(--rv-accent-50);
}
.user-table tbody tr.is-inactive td {
    color: var(--rv-faint);
}
.user-table .ut-actions {
    text-align: right;
    white-space: nowrap;
}
.user-table .ut-actions .visit-card__action {
    display: inline-flex;
    width: auto;
    padding: 6px 12px;
    margin-left: 4px;
}

/* ---------- v8: Visit table (desktop, used in list.php) ---------- */
.visit-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    background: var(--rv-surface);
    font-size: 13.5px;
}
.visit-table th,
.visit-table td {
    padding: 12px 14px;
    border-bottom: 1px solid var(--rv-border);
    text-align: left;
    vertical-align: middle;
}
.visit-table th {
    background: var(--rv-bg-soft);
    color: var(--rv-muted);
    font-size: 11.5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    position: sticky;
    top: 0;
    z-index: 1;
}
.visit-table tbody tr:hover {
    background: var(--rv-primary-tint);
}
.visit-table .vt-actions {
    text-align: right;
    white-space: nowrap;
}
.visit-table .vt-thumb {
    width: 48px;
    height: 48px;
    border-radius: 8px;
    object-fit: cover;
    background: var(--rv-bg);
}

/* ---------- v8: Self badge highlight ---------- */
.self-badge-row {
    background: linear-gradient(90deg, var(--rv-accent-50) 0%, transparent 100%);
}

/* =====================================================================
   DESKTOP — 1024px and up
===================================================================== */
@media (min-width: 1024px) {

    body {
        padding-bottom: 0;
        background: var(--rv-bg);
    }

    /* Hide mobile header on desktop */
    .app-header {
        display: none;
    }

    /* Hide bottom nav on desktop */
    .bottom-nav {
        display: none !important;
    }

    /* === Sidebar (left) === */
    .app-sidebar {
        display: flex;
        flex-direction: column;
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        width: var(--rv-sidebar-w);
        background: linear-gradient(180deg, #0a3d80 0%, #0d4ea6 100%);
        color: rgba(255, 255, 255, 0.92);
        z-index: 100;
        box-shadow: var(--rv-shadow-md);
        overflow-y: auto;
    }

    .app-sidebar__brand {
        display: flex;
        align-items: center;
        gap: 10px;
        padding: 18px 20px;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    }
    .app-sidebar__brand-logo {
        width: 38px;
        height: 38px;
        border-radius: 10px;
        background: var(--rv-accent);
        color: #fff;
        font-weight: 800;
        font-size: 14px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        flex-shrink: 0;
    }
    .app-sidebar__brand-text {
        line-height: 1.2;
    }
    .app-sidebar__brand-name {
        font-weight: 800;
        font-size: 16px;
        color: #fff;
    }
    .app-sidebar__brand-sub {
        font-size: 11px;
        opacity: 0.7;
    }

    .app-sidebar__nav {
        padding: 12px 10px;
        flex: 1;
        overflow-y: auto;
    }

    .app-sidebar__group {
        margin-top: 14px;
    }
    .app-sidebar__group-title {
        font-size: 10.5px;
        text-transform: uppercase;
        letter-spacing: 0.1em;
        font-weight: 700;
        color: rgba(255, 255, 255, 0.45);
        padding: 4px 12px 6px;
    }

    .app-sidebar__item {
        display: flex;
        align-items: center;
        gap: 10px;
        padding: 9px 12px;
        margin: 1px 0;
        color: rgba(255, 255, 255, 0.82);
        border-radius: 8px;
        font-size: 13.5px;
        font-weight: 500;
        text-decoration: none;
        position: relative;
    }
    .app-sidebar__item i {
        font-size: 17px;
        flex-shrink: 0;
        width: 20px;
        text-align: center;
    }
    .app-sidebar__item:hover {
        background: rgba(255, 255, 255, 0.08);
        color: #fff;
    }
    .app-sidebar__item.is-active {
        background: var(--rv-accent);
        color: #fff;
        font-weight: 700;
    }
    .app-sidebar__item.is-active:hover {
        background: var(--rv-accent-600);
    }
    .app-sidebar__item-badge {
        margin-left: auto;
        background: var(--rv-accent);
        color: #fff;
        font-size: 10px;
        font-weight: 700;
        padding: 1px 7px;
        border-radius: var(--rv-r-pill);
    }
    .app-sidebar__item.is-active .app-sidebar__item-badge {
        background: rgba(0, 0, 0, 0.28);
    }

    .app-sidebar__footer {
        padding: 12px 14px;
        border-top: 1px solid rgba(255, 255, 255, 0.1);
        font-size: 11.5px;
        opacity: 0.68;
    }

    /* === Topbar === */
    .app-topbar {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 14px;
        position: fixed;
        top: 0;
        left: var(--rv-sidebar-w);
        right: 0;
        height: var(--rv-topbar-h);
        background: var(--rv-surface);
        border-bottom: 1px solid var(--rv-border);
        padding: 0 28px;
        z-index: 90;
    }
    .app-topbar__left {
        flex: 1;
        min-width: 0;
    }
    .app-topbar__title {
        font-size: 18px;
        font-weight: 800;
        color: var(--rv-ink);
        line-height: 1.1;
    }
    .app-topbar__sub {
        font-size: 12px;
        color: var(--rv-muted);
        margin-top: 2px;
    }
    .app-topbar__right {
        display: flex;
        align-items: center;
        gap: 14px;
    }
    .app-topbar__userblock {
        display: flex;
        align-items: center;
        gap: 10px;
        padding: 6px 12px;
        background: var(--rv-bg-soft);
        border: 1px solid var(--rv-border);
        border-radius: var(--rv-r-pill);
    }
    .app-topbar__avatar {
        width: 28px;
        height: 28px;
        border-radius: 50%;
        background: var(--rv-primary);
        color: #fff;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        font-size: 11px;
        font-weight: 700;
    }
    .app-topbar__name {
        font-size: 13px;
        font-weight: 700;
        color: var(--rv-ink);
        line-height: 1.1;
    }
    .app-topbar__role {
        font-size: 11px;
        color: var(--rv-muted);
    }
    .app-topbar__icon-btn {
        width: 38px;
        height: 38px;
        border-radius: 50%;
        background: var(--rv-bg-soft);
        border: 1px solid var(--rv-border);
        color: var(--rv-text);
        display: inline-flex;
        align-items: center;
        justify-content: center;
        position: relative;
        font-size: 17px;
        text-decoration: none;
    }
    .app-topbar__icon-btn:hover {
        background: var(--rv-primary-50);
        color: var(--rv-primary);
    }
    .app-topbar__icon-btn--logout:hover {
        color: var(--rv-danger);
        background: var(--rv-danger-50);
    }
    .app-topbar__icon-btn-badge {
        position: absolute;
        top: -2px;
        right: -2px;
        background: var(--rv-danger);
        color: #fff;
        border-radius: var(--rv-r-pill);
        font-size: 10px;
        font-weight: 700;
        padding: 1px 5px;
        min-width: 16px;
        text-align: center;
    }

    /* === Content area === */
    .app-shell {
        max-width: 100% !important;
        margin: 0 0 0 var(--rv-sidebar-w);
        padding: calc(var(--rv-topbar-h) + 24px) 28px 36px;
    }
    .app-shell--wide {
        max-width: 100% !important;
    }
    .app-shell-inner {
        max-width: var(--rv-desktop-max);
        margin: 0 auto;
    }

    /* Adjust hero */
    .page-hero {
        padding: 22px 26px;
    }
    .page-hero__title {
        font-size: 26px;
    }

    /* Stat grid: more columns on desktop */
    .stat-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 14px;
    }

    /* Quick actions: more columns */
    .quick-actions {
        grid-template-columns: repeat(3, 1fr);
        gap: 14px;
    }

    /* Filter card: horizontal layout */
    .filter-card {
        padding: 18px 22px;
    }
    .filter-card .field-row,
    .filter-card .field {
        margin-bottom: 0 !important;
    }
    .filter-card-grid {
        display: grid;
        grid-template-columns: 1.5fr 1fr 1fr 1fr 1fr;
        gap: 10px;
        align-items: end;
    }

    /* Show desktop tables, hide mobile cards */
    .dt-wrap {
        display: block;
        background: var(--rv-surface);
        border: 1px solid var(--rv-border);
        border-radius: var(--rv-r-md);
        overflow: hidden;
        box-shadow: var(--rv-shadow-sm);
    }
    .dt-mobile-only {
        display: none;
    }

    /* Visit cards layout */
    .visit-card {
        padding: 16px 18px;
    }

    /* User cards: 2-up grid (fallback if table not used) */
    .user-card {
        padding: 16px 18px;
    }

    /* Recent items: keep card style on desktop */
    .recent-item {
        padding: 14px 18px;
    }

    /* Form pages: use centered narrow column on desktop */
    form .form-card {
        max-width: 720px;
    }
    .submit-sticky {
        max-width: 720px;
        position: relative;
        bottom: auto;
        left: auto;
        right: auto;
        background: transparent;
        padding: 14px 0 0;
        box-shadow: none;
        border-top: none;
    }

    /* Dashboard 12-col pattern (used by dashboard.php) */
    .dash-grid--12 {
        display: grid;
        grid-template-columns: repeat(12, 1fr);
        gap: 14px;
    }
    .dash-grid--12 .col-12 { grid-column: span 12; }
    .dash-grid--12 .col-8  { grid-column: span 8;  }
    .dash-grid--12 .col-6  { grid-column: span 6;  }
    .dash-grid--12 .col-4  { grid-column: span 4;  }
    .dash-grid--12 .col-3  { grid-column: span 3;  }

    /* Hide assigned-head (sales-only pretty card) on desktop in favor of compact */
    .assigned-head { padding: 14px 18px; }
}

/* =====================================================================
   TABLET — 768px to 1023px
===================================================================== */
@media (min-width: 768px) and (max-width: 1023px) {
    .app-shell {
        max-width: 720px;
    }
    .stat-grid {
        grid-template-columns: repeat(3, 1fr);
    }
    .quick-actions {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* =====================================================================
   MOBILE only (below 1024px) — collapsible filter
===================================================================== */
@media (max-width: 1023px) {

    .filter-toggle {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 10px;
        width: 100%;
        background: var(--rv-surface);
        border: 1px solid var(--rv-border);
        border-radius: var(--rv-r-md);
        padding: 12px 14px;
        margin-bottom: 10px;
        font-weight: 600;
        color: var(--rv-text);
        font-size: 13px;
        box-shadow: var(--rv-shadow-sm);
        cursor: pointer;
    }
    .filter-toggle__label {
        display: inline-flex;
        align-items: center;
        gap: 8px;
        color: var(--rv-primary);
    }
    .filter-toggle__count {
        background: var(--rv-primary);
        color: #fff;
        font-size: 11px;
        font-weight: 700;
        padding: 2px 8px;
        border-radius: var(--rv-r-pill);
    }
    .filter-toggle__chevron {
        color: var(--rv-muted);
        font-size: 14px;
        transition: transform 0.2s;
    }
    .filter-toggle.is-open .filter-toggle__chevron {
        transform: rotate(180deg);
    }

    .filter-card.is-collapsed {
        display: none;
    }
}

/* Ensure no horizontal scroll anywhere */
@media (max-width: 1023px) {
    body, .app-shell {
        overflow-x: hidden;
    }
    table.visit-table, table.user-table {
        display: none;
    }
}

/* End of v8 desktop layout */

/* ============================================================
 * v8.1 — Logo image support (overrides text fallback)
 * ============================================================ */

/* Sidebar brand logo (image variant) */
.app-sidebar__brand-logo--image {
    background: #fff !important;
    color: inherit;
    padding: 4px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}
.app-sidebar__brand-logo--image img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    display: block;
}

/* Mobile header brand (image variant) */
.app-header__brand--image {
    background: #fff !important;
    padding: 3px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}
.app-header__brand--image img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    display: block;
}

/* Login brand logo (image variant) */
.login-brand__logo--image {
    background: #fff !important;
    padding: 6px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--rv-border, #e5e7eb);
}
.login-brand__logo--image img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    display: block;
}

/* ============================================================
 * v8.1 — App Settings page
 * ============================================================ */
.settings-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 14px;
}

.settings-card {
    background: var(--rv-surface, #ffffff);
    border: 1px solid var(--rv-border, #e5e7eb);
    border-radius: 14px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.04);
}

.settings-card__head {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    padding: 18px 18px 14px;
    border-bottom: 1px solid var(--rv-border, #e5e7eb);
    background: linear-gradient(180deg, rgba(13, 78, 166, 0.025), transparent);
}

.settings-card__icon {
    width: 44px;
    height: 44px;
    border-radius: 11px;
    background: var(--rv-primary-50, #e7eefb);
    color: var(--rv-primary, #0d4ea6);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    flex-shrink: 0;
}

.settings-card__title {
    font-size: 17px;
    font-weight: 700;
    color: var(--rv-ink, #0f172a);
    margin: 0 0 2px;
    line-height: 1.3;
}

.settings-card__sub {
    font-size: 13px;
    color: var(--rv-muted, #64748b);
    margin: 0;
    line-height: 1.4;
}

.settings-card__body {
    padding: 18px;
}

.logo-preview-wrap {
    margin-bottom: 18px;
}

.logo-preview-label {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--rv-muted, #64748b);
    margin-bottom: 8px;
}

.logo-preview {
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    border: 1px dashed var(--rv-border, #cbd5e1);
    border-radius: 12px;
    padding: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 140px;
}

.logo-preview img {
    max-width: 220px;
    max-height: 100px;
    object-fit: contain;
    display: block;
    border-radius: 8px;
}

.logo-preview-default {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.logo-preview-initials {
    width: 72px;
    height: 72px;
    border-radius: 16px;
    background: linear-gradient(135deg, var(--rv-primary, #0d4ea6) 0%, #1e60c4 100%);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    font-weight: 800;
    letter-spacing: -1px;
}

.logo-preview-default-label {
    font-size: 12px;
    color: var(--rv-muted, #64748b);
    font-style: italic;
}

.field__help {
    font-size: 12px;
    color: var(--rv-muted, #64748b);
    margin-top: 6px;
    line-height: 1.5;
}

/* Tablet+ layout for settings */
@media (min-width: 768px) {
    .settings-grid {
        grid-template-columns: 1fr 1fr;
    }
}

/* ============================================================
 * v8.1 — Layout polish & sidebar refinements
 * ============================================================ */
@media (min-width: 1024px) {
    /* Sidebar brand area: cleaner spacing */
    .app-sidebar__brand {
        padding: 18px 20px 20px !important;
    }
    .app-sidebar__brand-logo {
        width: 44px !important;
        height: 44px !important;
        border-radius: 11px !important;
        font-size: 16px !important;
    }
    .app-sidebar__brand-name {
        font-size: 15px !important;
        line-height: 1.25 !important;
    }
    .app-sidebar__brand-sub {
        font-size: 11px !important;
        opacity: 0.7;
    }

    /* Topbar: tighter, more refined */
    .app-topbar__title {
        font-size: 18px !important;
        letter-spacing: -0.01em;
    }
    .app-topbar__sub {
        font-size: 12px !important;
    }
}

/* Mobile header: refined logo box */
.app-header__brand--image {
    width: 36px;
    height: 36px;
    border-radius: 9px;
}

/* Login brand: slightly larger when image */
.login-brand__logo--image {
    width: 56px;
    height: 56px;
    border-radius: 14px;
}

/* End v8.1 */
