/* PayLoop — Mobile-first responsive dashboard */
:root {
    --color-bg: #f8f9fa;
    --color-surface: #ffffff;
    --color-primary: #2563eb;
    --color-primary-hover: #1d4ed8;
    --color-danger: #dc2626;
    --color-warning: #f59e0b;
    --color-success: #16a34a;
    --color-muted: #6b7280;
    --color-text: #111827;
    --color-border: #e5e7eb;
    --radius: 8px;
    --shadow: 0 1px 3px rgba(0,0,0,0.1);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.1);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--color-bg);
    color: var(--color-text);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

.container {
    max-width: 960px;
    margin: 0 auto;
    padding: 16px;
}

/* Header */
.header {
    background: var(--color-primary);
    color: white;
    padding: 16px;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow-md);
}

.header h1 {
    font-size: 1.25rem;
    font-weight: 600;
}

.header .subtitle {
    font-size: 0.75rem;
    opacity: 0.8;
}

/* Navigation tabs */
.nav-tabs {
    display: flex;
    gap: 0;
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.nav-tab {
    flex: 1;
    min-width: 0;
    padding: 12px 8px;
    text-align: center;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--color-muted);
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    white-space: nowrap;
    transition: color 0.2s, border-color 0.2s;
}

.nav-tab.active {
    color: var(--color-primary);
    border-bottom-color: var(--color-primary);
}

/* Recovery widget */
.recovery-widget {
    background: var(--color-success);
    color: white;
    border-radius: var(--radius);
    padding: 24px 16px;
    margin: 16px 0;
    text-align: center;
    box-shadow: var(--shadow-md);
}

.recovery-label {
    font-size: 0.8rem;
    font-weight: 500;
    opacity: 0.9;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 8px;
}

.recovery-amount {
    font-size: 2rem;
    font-weight: 700;
    line-height: 1.1;
    margin-bottom: 4px;
}

.recovery-month-label {
    font-size: 0.8rem;
    opacity: 0.85;
    margin-bottom: 12px;
}

.recovery-alltime {
    font-size: 0.75rem;
    opacity: 0.75;
    border-top: 1px solid rgba(255,255,255,0.3);
    padding-top: 10px;
    margin-top: 4px;
}

/* Summary cards */
.summary-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin: 16px 0;
}

.summary-card {
    background: var(--color-surface);
    border-radius: var(--radius);
    padding: 16px;
    box-shadow: var(--shadow);
}

.summary-card .label {
    font-size: 0.75rem;
    color: var(--color-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.summary-card .value {
    font-size: 1.5rem;
    font-weight: 700;
    margin-top: 4px;
}

.summary-card .value.danger { color: var(--color-danger); }
.summary-card .value.success { color: var(--color-success); }
.summary-card .value.warning { color: var(--color-warning); }

.summary-card.full-width {
    grid-column: 1 / -1;
}

/* Lists */
.list-section {
    margin: 16px 0;
}

.list-section h2 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 8px;
    padding: 0 4px;
}

.list-item {
    background: var(--color-surface);
    border-radius: var(--radius);
    padding: 12px 16px;
    margin-bottom: 8px;
    box-shadow: var(--shadow);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.list-item .name {
    font-weight: 500;
    font-size: 0.9rem;
}

.list-item .detail {
    font-size: 0.75rem;
    color: var(--color-muted);
    margin-top: 2px;
}

.list-item .amount {
    font-weight: 600;
    text-align: right;
    white-space: nowrap;
}

.list-item .amount.overdue {
    color: var(--color-danger);
}

/* Badges */
.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
}

.badge-danger { background: #fef2f2; color: var(--color-danger); }
.badge-warning { background: #fffbeb; color: #b45309; }
.badge-success { background: #f0fdf4; color: var(--color-success); }
.badge-info { background: #eff6ff; color: var(--color-primary); }

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 16px;
    border-radius: var(--radius);
    font-size: 0.875rem;
    font-weight: 500;
    border: none;
    cursor: pointer;
    transition: background 0.2s;
}

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

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

.btn-danger {
    background: var(--color-danger);
    color: white;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 0.75rem;
}

.btn-group {
    display: flex;
    gap: 8px;
}

/* Approval batch */
.approval-batch {
    background: var(--color-surface);
    border-radius: var(--radius);
    margin-bottom: 16px;
    box-shadow: var(--shadow);
    overflow: hidden;
}

.approval-batch-header {
    padding: 12px 16px;
    background: #f9fafb;
    border-bottom: 1px solid var(--color-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.approval-batch-header .batch-info {
    font-size: 0.8rem;
    color: var(--color-muted);
}

.approval-item {
    padding: 12px 16px;
    border-bottom: 1px solid var(--color-border);
}

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

.approval-item .preview {
    font-size: 0.8rem;
    color: var(--color-muted);
    margin-top: 4px;
    white-space: pre-line;
    max-height: 60px;
    overflow: hidden;
}

/* Settings */
.setting-row {
    background: var(--color-surface);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 8px;
    box-shadow: var(--shadow);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.setting-row .setting-label {
    font-weight: 500;
}

.setting-row .setting-desc {
    font-size: 0.75rem;
    color: var(--color-muted);
    margin-top: 2px;
}

/* Mode selector */
select.mode-select {
    padding: 8px 12px;
    border-radius: var(--radius);
    border: 1px solid var(--color-border);
    font-size: 0.875rem;
    background: var(--color-surface);
}

/* Customer health map */
.list-item-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.health-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    flex-shrink: 0;
}

.health-green { background: var(--color-success); }
.health-yellow { background: var(--color-warning); }
.health-red { background: var(--color-danger); }
.health-grey { background: #9ca3af; }

.health-badge {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    padding: 2px 8px;
    border-radius: 12px;
    white-space: nowrap;
}

.health-badge-green { background: #f0fdf4; color: var(--color-success); }
.health-badge-yellow { background: #fffbeb; color: #b45309; }
.health-badge-red { background: #fef2f2; color: var(--color-danger); }
.health-badge-grey { background: #f3f4f6; color: #6b7280; }

/* Health score widget */
.health-score-widget {
    border-radius: var(--radius);
    padding: 24px 16px;
    margin: 16px 0;
    text-align: center;
    box-shadow: var(--shadow-md);
    color: white;
    background: #6b7280; /* default/unknown */
}

.health-score-healthy { background: var(--color-success); }
.health-score-ok { background: #2563eb; }
.health-score-warning { background: var(--color-warning); }
.health-score-critical { background: var(--color-danger); }

.health-score-label {
    font-size: 0.8rem;
    font-weight: 500;
    opacity: 0.9;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 8px;
}

.health-score-number {
    font-size: 3rem;
    font-weight: 700;
    line-height: 1;
    margin-bottom: 4px;
}

.health-score-status {
    font-size: 1rem;
    font-weight: 600;
    opacity: 0.9;
}

/* Loading / empty states */
.loading, .empty-state {
    text-align: center;
    padding: 40px 16px;
    color: var(--color-muted);
}

.loading::after {
    content: '';
    display: block;
    width: 24px;
    height: 24px;
    margin: 12px auto 0;
    border: 2px solid var(--color-border);
    border-top-color: var(--color-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* Tenant ID input */
.tenant-bar {
    background: var(--color-surface);
    padding: 8px 16px;
    border-bottom: 1px solid var(--color-border);
    display: flex;
    gap: 8px;
    align-items: center;
}

.tenant-bar input {
    flex: 1;
    padding: 6px 10px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    font-size: 0.8rem;
    font-family: monospace;
}

.tenant-bar button {
    padding: 6px 12px;
    font-size: 0.8rem;
}

/* Page sections */
.page { display: none; }
.page.active { display: block; }

/* Setup / Onboarding forms */
.form-card {
    background: var(--color-surface);
    border-radius: var(--radius);
    padding: 16px;
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.form-input {
    padding: 10px 12px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    font-size: 0.875rem;
    width: 100%;
}

.form-input:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.15);
}

.form-result {
    padding: 10px 12px;
    border-radius: var(--radius);
    background: #f9fafb;
    font-size: 0.8rem;
    line-height: 1.6;
}

.form-result code {
    background: #e5e7eb;
    padding: 1px 5px;
    border-radius: 3px;
    font-size: 0.75rem;
    word-break: break-all;
}

/* Desktop breakpoint */
@media (min-width: 768px) {
    .recovery-amount {
        font-size: 3rem;
    }

    .summary-grid {
        grid-template-columns: repeat(4, 1fr);
    }

    .summary-card.full-width {
        grid-column: span 2;
    }

    .container {
        padding: 24px;
    }

    .nav-tab {
        font-size: 0.875rem;
        padding: 14px 16px;
    }
}
