:root {
    --primary: #007AFF;
    --primary-dark: #0056b3;
    --success: #34C759;
    --warning: #FF9500;
    --danger: #FF3B30;
    --background: #F2F2F7;
    --surface: #FFFFFF;
    --text-primary: #000000;
    --text-secondary: #8E8E93;
    --border: #C6C6C8;
    --radius: 12px;
    --shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    --font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
    :root {
        --background: #000000;
        --surface: #1C1C1E;
        --text-primary: #FFFFFF;
        --text-secondary: #8E8E93;
        --border: #38383A;
        --shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    }
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: var(--font-family);
    background-color: var(--background);
    color: var(--text-primary);
    line-height: 1.5;
    padding-bottom: 40px;
    /* Safe area */
}

/* Typography */
h1 {
    font-size: 28px;
    font-weight: 700;
    margin: 20px 0 10px;
    letter-spacing: -0.5px;
}

h2 {
    font-size: 22px;
    font-weight: 600;
    margin-bottom: 15px;
    letter-spacing: -0.3px;
}

h3 {
    font-size: 17px;
    font-weight: 600;
    margin-bottom: 10px;
}

p {
    font-size: 16px;
    margin-bottom: 10px;
    color: var(--text-secondary);
}

/* Layout & Cards */
.container {
    max-width: 600px;
    margin: 0 auto;
    padding: 0 16px;
}

.card {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: var(--shadow);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

/* Forms */
.form-group {
    margin-bottom: 16px;
}

label {
    display: block;
    margin-bottom: 8px;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

input,
select,
textarea {
    width: 100%;
    padding: 12px;
    background: var(--background);
    border: 1px solid transparent;
    border-radius: 8px;
    font-size: 17px;
    color: var(--text-primary);
    transition: all 0.2s;
    font-family: inherit;
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    background: var(--surface);
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.1);
}

/* Buttons */
.btn {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    padding: 14px;
    border-radius: var(--radius);
    border: none;
    font-size: 17px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    position: relative;
    overflow: hidden;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:active {
    background: var(--primary-dark);
    transform: scale(0.98);
}

.btn-secondary {
    background: var(--surface);
    color: var(--text-primary);
    border: 1px solid var(--border);
}

@media (prefers-color-scheme: dark) {
    .btn-secondary {
        background: #2C2C2E;
        border-color: #48484A;
    }
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Status Indicators */
.status-badge {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
}

.status-pending {
    background: var(--warning);
    color: black;
}

.status-sent {
    background: var(--success);
    color: white;
}

.status-error {
    background: var(--danger);
    color: white;
}

/* Utilities */
.hidden {
    display: none !important;
}

.fade-in {
    animation: fadeIn 0.3s ease-in;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Install Prompt */
.install-banner {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--surface);
    padding: 15px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    z-index: 1000;
    display: flex;
    align-items: center;
    gap: 15px;
    width: 90%;
    max-width: 400px;
}

/* Loading Screen */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--background);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--border);
    border-top: 4px solid var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 20px;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

.loading-text {
    font-weight: 600;
    color: var(--primary);
    font-size: 18px;
    margin-bottom: 8px;
    text-align: center;
}

.loading-subtext {
    font-size: 14px;
    color: var(--text-secondary);
    text-align: center;
    max-width: 80%;
}

/* Password Toggle */
.password-wrapper {
    position: relative;
}

.password-wrapper input {
    padding-right: 48px;
}

.toggle-password {
    position: absolute;
    right: 4px;
    top: 50%;
    transform: translateY(-50%);
    background: transparent;
    border: none;
    cursor: pointer;
    font-size: 18px;
    padding: 8px;
    line-height: 1;
    color: var(--text-primary);
    opacity: 0.7;
    transition: opacity 0.2s;
}

.toggle-password:hover,
.toggle-password:active {
    opacity: 1;
}

/* Forgot Password Link */
.forgot-password-link {
    display: block;
    width: 100%;
    text-align: center;
    margin-top: 12px;
    font-size: 14px;
    color: var(--primary);
    cursor: pointer;
    background: transparent;
    border: none;
    font-family: inherit;
    text-decoration: none;
    padding: 8px 4px;
}


/* Clone Button & Long Press */
.clone-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: auto;
    height: 24px;
    padding: 0 8px;
    border-radius: 20px;
    background: var(--background);
    color: var(--primary);
    border: 1px solid var(--border);
    cursor: pointer;
    font-size: 10px;
    font-weight: 700;
    margin-left: 10px;
    vertical-align: middle;
    transition: all 0.2s;
    user-select: none;
    -webkit-user-select: none;
    letter-spacing: 0.5px;
}

.clone-btn:active {
    transform: scale(0.95);
}

.clone-btn.pressing {
    animation: clone-pulse 2s linear forwards;
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

@keyframes clone-pulse {
    0% { transform: scale(1); opacity: 0.8; }
    50% { transform: scale(1.1); opacity: 1; }
    100% { transform: scale(1); opacity: 1; box-shadow: 0 0 0 4px rgba(0, 122, 255, 0.3); }
}

/* --- Gestión Inteligente de Clientes --- */
.client-found-badge {
    display: inline-block;
    background: #d4edda;
    color: #155724;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
}

.mv-select {
    width: 100%;
    padding: 10px;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 6px;
    font-size: 14px;
    background: var(--background);
    color: var(--text);
    appearance: auto;
}

/* Campo nombre: estados */
.nombre-locked {
    opacity: 0.85;
    cursor: default !important;
}

.nombre-editable {
    border-color: var(--primary) !important;
}