*, *::before, *::after { box-sizing: border-box; }
:root {
    --bg: #f1f5f9;
    --card: #ffffff;
    --text: #0f172a;
    --sub: #64748b;
    --dim: #cbd5e1;
    --accent: #0284c7;
    --accent-dark: #0369a1;
    --accent-darker: #0c4a6e;
    --success: #059669;
    --danger: #dc2626;
    --warn: #d97706;
    --border: #e2e8f0;
}
html, body {
    margin: 0; padding: 0;
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, sans-serif;
    font-size: 15px;
    line-height: 1.5;
}
.wrap {
    max-width: 1100px;
    margin: 0 auto;
    padding: 16px 14px 40px;
}
.wrap-slim { max-width: 460px; }

/* Topbar */
.head {
    background: linear-gradient(135deg, #0284c7, #0c4a6e);
    color: #fff;
    padding: 14px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-radius: 14px;
    margin-bottom: 16px;
    box-shadow: 0 2px 8px rgba(2,132,199,0.25);
}
.head .brand { display: flex; align-items: center; gap: 12px; }
.head .brand-icon {
    width: 40px; height: 40px;
    border-radius: 10px;
    background: rgba(255,255,255,0.2);
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 20px;
}
.head .brand-title { font-size: 1.1rem; font-weight: 700; line-height: 1.1; }
.head .brand-sub { font-size: 0.75rem; opacity: 0.9; }
.head .actions { display: flex; align-items: center; gap: 8px; font-size: 0.85rem; }
.head .actions a {
    color: #fff; opacity: 0.9;
    padding: 6px 12px; border-radius: 8px;
    text-decoration: none; font-weight: 600;
    background: rgba(255,255,255,0.1);
}
.head .actions a:hover { background: rgba(255,255,255,0.2); opacity: 1; }

/* Cards */
.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 16px 18px;
    margin-bottom: 14px;
    box-shadow: 0 1px 2px rgba(15,23,42,0.03);
}
.card h2 { font-size: 1rem; margin: 0 0 12px; color: var(--text); }

/* Grid main 2 columnas en desktop */
.grid-main {
    display: grid;
    grid-template-columns: 1fr;
    gap: 14px;
    margin-bottom: 14px;
}
@media (min-width: 900px) {
    .grid-main { grid-template-columns: 3fr 2fr; align-items: start; }
    .grid-main > .card { margin-bottom: 0; }
}

/* KPIs */
.grid-2 {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin-bottom: 14px;
}
@media (min-width: 700px) { .grid-2 { grid-template-columns: repeat(4, 1fr); } }
.mini { margin: 0; padding: 14px 16px; text-align: center; }
.mini-label {
    font-size: 0.72rem;
    color: var(--sub);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}
.mini-value { font-size: 1.4rem; font-weight: 700; margin-top: 4px; }
.mini-value.warn { color: var(--warn); }
.mini-value.success { color: var(--success); }
.mini-value.accent { color: var(--accent); }

/* Tabla */
.tabla-scroll { overflow-x: auto; margin: 0 -4px; }
.tabla {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}
.tabla th {
    text-align: left;
    padding: 8px 8px;
    font-weight: 600;
    color: var(--sub);
    border-bottom: 1px solid var(--border);
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    white-space: nowrap;
    background: #f8fafc;
}
.tabla td {
    padding: 10px 8px;
    border-bottom: 1px solid #f1f5f9;
    vertical-align: middle;
}
.tabla .r { text-align: right; }
.badge {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 999px;
    font-size: 0.7rem;
    font-weight: 600;
    white-space: nowrap;
}
.badge-pend { background: #fef3c7; color: #92400e; }
.badge-pag { background: #d1fae5; color: #065f46; }
.badge-canc { background: #fee2e2; color: #991b1b; }

/* Botones */
.btn {
    display: inline-block;
    padding: 10px 18px;
    border-radius: 10px;
    font-size: 0.9rem;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    border: 0;
    transition: opacity 0.15s;
}
.btn:hover { opacity: 0.9; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-dark); color: #fff; }
.btn-secondary { background: #e2e8f0; color: var(--text); }
.btn-success { background: var(--success); color: #fff; }
.btn-full { display: block; width: 100%; text-align: center; }
.btn-lg { padding: 14px 24px; font-size: 1rem; }

/* Formulario */
.form-group { margin-bottom: 14px; }
.form-group label {
    display: block;
    font-size: 0.78rem;
    color: var(--sub);
    text-transform: uppercase;
    letter-spacing: 0.03em;
    margin-bottom: 4px;
    font-weight: 600;
}
.form-control {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 10px;
    font-size: 0.95rem;
    background: #fff;
}
.form-control:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(234,88,12,0.1);
}
.form-row { display: flex; gap: 12px; }
.form-row .form-group { flex: 1; }

/* Alertas */
.alert {
    padding: 12px 16px;
    border-radius: 10px;
    font-size: 0.9rem;
    margin-bottom: 14px;
    border: 1px solid transparent;
}
.alert-error { background: #fef2f2; color: #991b1b; border-color: #fecaca; }
.alert-success { background: #ecfdf5; color: #065f46; border-color: #a7f3d0; }
.alert-info { background: #eff6ff; color: #1e3a8a; border-color: #bfdbfe; }
.alert-warn { background: #fef3c7; color: #92400e; border-color: #fde68a; }

/* Login pantalla - background azul con patron de red/wifi */
.login-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background:
        radial-gradient(circle at 20% 30%, rgba(255,255,255,0.08) 0%, transparent 40%),
        radial-gradient(circle at 80% 70%, rgba(255,255,255,0.06) 0%, transparent 40%),
        linear-gradient(135deg, #0369a1 0%, #0c4a6e 50%, #082f49 100%);
    position: relative;
    overflow: hidden;
}
/* Patron sutil de puntos (network vibes) */
.login-wrap::before {
    content: '';
    position: absolute;
    inset: 0;
    background-image:
        radial-gradient(circle, rgba(255,255,255,0.12) 1px, transparent 1px);
    background-size: 32px 32px;
    opacity: 0.4;
    pointer-events: none;
}
/* Ondas WiFi decorativas */
.login-wrap::after {
    content: '';
    position: absolute;
    right: -100px;
    top: -100px;
    width: 400px;
    height: 400px;
    background: radial-gradient(circle, transparent 35%, rgba(56,189,248,0.15) 36%, rgba(56,189,248,0.15) 40%, transparent 41%, transparent 55%, rgba(56,189,248,0.1) 56%, rgba(56,189,248,0.1) 60%, transparent 61%, transparent 75%, rgba(56,189,248,0.08) 76%, rgba(56,189,248,0.08) 80%, transparent 81%);
    border-radius: 50%;
    pointer-events: none;
}
.login-card {
    background: white;
    border-radius: 20px;
    padding: 40px 32px;
    max-width: 400px;
    width: 100%;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    position: relative;
    z-index: 1;
}
.login-brand {
    text-align: center;
    margin-bottom: 24px;
}
.login-brand .brand-icon {
    width: 64px; height: 64px;
    border-radius: 16px;
    background: linear-gradient(135deg, #0284c7, #0c4a6e);
    color: #fff;
    display: inline-flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 28px;
    margin-bottom: 12px;
    box-shadow: 0 6px 16px rgba(2,132,199,0.35);
}
.login-brand h1 { margin: 0; font-size: 1.4rem; color: var(--accent-dark); }
.login-brand p { color: var(--sub); font-size: 0.85rem; margin: 4px 0 0; }

/* Autocomplete cliente */
.autocomplete {
    position: relative;
}
.autocomplete-results {
    position: absolute;
    top: 100%;
    left: 0; right: 0;
    background: white;
    border: 1px solid var(--border);
    border-top: 0;
    border-radius: 0 0 10px 10px;
    max-height: 240px;
    overflow-y: auto;
    z-index: 100;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}
.autocomplete-item {
    padding: 10px 12px;
    cursor: pointer;
    font-size: 0.9rem;
    border-bottom: 1px solid #f1f5f9;
}
.autocomplete-item:hover { background: #eff6ff; }
.autocomplete-item .cli-id { color: var(--sub); font-size: 0.78rem; }

.comision-box {
    text-align: center;
    padding: 20px;
    background: linear-gradient(135deg, #ecfdf5, #d1fae5);
    border-radius: 12px;
    margin: 12px 0;
    border: 2px solid #a7f3d0;
}
.comision-box .lbl {
    font-size: 0.75rem;
    color: #065f46;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    font-weight: 600;
}
.comision-box .val {
    font-size: 2rem;
    font-weight: 800;
    color: var(--success);
    margin-top: 4px;
}

.pie {
    text-align: center;
    color: var(--sub);
    font-size: 0.75rem;
    padding: 20px 10px 0;
    line-height: 1.6;
}
