/* =========================================================
   Cliente al Día - Soft Task App UI
   ========================================================= */

:root{
    --bg:#f5f7fb;
    --bg-2:#eef2f7;
    --surface:#ffffff;
    --surface-soft:#f8fafc;

    --text:#0f172a;
    --text-soft:#334155;
    --text-muted:#64748b;

    --border:#e7edf5;
    --border-strong:#d9e2ec;

    --primary:#4f46e5;
    --primary-soft:#eef2ff;

    --success:#16a34a;
    --success-soft:#ecfdf5;

    --warning:#d97706;
    --warning-soft:#fff7ed;

    --danger:#dc2626;
    --danger-soft:#fef2f2;

    --purple:#7c3aed;
    --purple-soft:#f5f3ff;

    --shadow-sm:0 2px 10px rgba(15,23,42,.04);
    --shadow-md:0 10px 30px rgba(15,23,42,.06);

    --radius-xl:22px;
    --radius-lg:18px;
    --radius-md:14px;
    --radius-sm:10px;

    --sidebar-width:250px;
}

/* =========================================================
   Reset
   ========================================================= */

*,
*::before,
*::after{
    box-sizing:border-box;
}

html{
    font-size:16px;
}

body{
    margin:0;
    font-family:Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background:linear-gradient(180deg, #f8fafc 0%, #f3f6fb 100%);
    color:var(--text);
    -webkit-font-smoothing:antialiased;
    -moz-osx-font-smoothing:grayscale;
}

a{
    color:var(--primary);
    text-decoration:none;
}

a:hover{
    text-decoration:none;
}

img{
    max-width:100%;
    display:block;
}

button,
input,
select,
textarea{
    font:inherit;
}

/* =========================================================
   Layout
   ========================================================= */

.app-shell{
    min-height:100vh;
    background:transparent;
}

.app-sidebar{
    position:fixed;
    top:0;
    left:0;
    width:var(--sidebar-width);
    height:100vh;
    background:rgba(255,255,255,.86);
    backdrop-filter:blur(10px);
    border-right:1px solid var(--border);
    padding:22px 16px;
    overflow-y:auto;
    z-index:1000;
}

.app-logo{
    font-size:21px;
    font-weight:800;
    letter-spacing:-.03em;
    color:var(--text);
    margin-bottom:22px;
    padding:0 8px;
}

.app-sidebar nav{
    display:flex;
    flex-direction:column;
    gap:8px;
}

.app-sidebar nav a{
    display:flex;
    align-items:center;
    min-height:44px;
    padding:0 14px;
    border-radius:14px;
    color:var(--text-soft);
    font-weight:600;
    transition:.2s ease;
}

.app-sidebar nav a:hover{
    background:var(--primary-soft);
    color:var(--primary);
}

.app-main{
    margin-left:var(--sidebar-width);
    min-height:100vh;
    padding:24px;
}

.app-topbar{
    display:flex;
    justify-content:space-between;
    align-items:center;
    gap:16px;
    margin-bottom:22px;
    padding:14px 18px;
    background:rgba(255,255,255,.72);
    backdrop-filter:blur(8px);
    border:1px solid var(--border);
    border-radius:18px;
    box-shadow:var(--shadow-sm);
}

.app-topbar strong{
    font-size:18px;
    font-weight:700;
    color:var(--text);
}

/* =========================================================
   Headings
   ========================================================= */

.page-section{
    margin-bottom:22px;
}

.page-head{
    display:flex;
    justify-content:space-between;
    align-items:flex-start;
    gap:16px;
    margin-bottom:18px;
}

.page-head h1{
    margin:0 0 6px;
    font-size:32px;
    line-height:1.04;
    letter-spacing:-.04em;
    color:var(--text);
}

.page-head p{
    margin:0;
    color:var(--text-muted);
}

.page-section > h2{
    margin:0 0 14px;
    font-size:22px;
    color:var(--text);
}

/* =========================================================
   Cards
   ========================================================= */

.card{
    background:rgba(255,255,255,.9);
    border:1px solid var(--border);
    border-radius:24px;
    padding:20px;
    box-shadow:var(--shadow-sm);
    color:var(--text);
}

.card h2,
.card h3,
.card h4{
    margin:0 0 14px;
    color:var(--text);
    letter-spacing:-.02em;
    font-weight:700;
}

.card p{
    color:var(--text-soft);
    line-height:1.55;
}

.card small{
    color:var(--text-muted);
    line-height:1.5;
}

.card--full{
    grid-column:1 / -1;
}

.card-head{
    display:flex;
    justify-content:space-between;
    align-items:flex-start;
    gap:14px;
    margin-bottom:14px;
}

.card-head h2{
    margin:0;
    font-size:18px;
}

.card-head a{
    color:var(--text-muted);
    font-size:14px;
    font-weight:600;
}

/* =========================================================
   Buttons
   ========================================================= */

.btn-soft,
button,
input[type="submit"]{
    display:inline-flex;
    align-items:center;
    justify-content:center;
    min-height:42px;
    padding:0 16px;
    border:none;
    border-radius:12px;
    background:var(--primary);
    color:#fff;
    font-weight:700;
    cursor:pointer;
    transition:.2s ease;
}

.btn-soft:hover,
button:hover,
input[type="submit"]:hover{
    opacity:.96;
    transform:translateY(-1px);
}

.btn-outline{
    display:inline-flex;
    align-items:center;
    justify-content:center;
    min-height:42px;
    padding:0 16px;
    border:1px solid var(--border-strong);
    border-radius:12px;
    background:#fff;
    color:var(--text);
    font-weight:700;
}

.today-actions a,
.note-item__actions a,
.item-row a,
.table-row a{
    display:inline-flex;
    align-items:center;
    justify-content:center;
    min-height:36px;
    padding:0 12px;
    border-radius:10px;
    background:var(--primary-soft);
    color:var(--primary);
    font-weight:700;
    font-size:14px;
}

/* =========================================================
   Forms
   ========================================================= */

form > div{
    margin-bottom:14px;
}

label{
    display:block;
    margin-bottom:6px;
    font-size:14px;
    font-weight:700;
    color:var(--text);
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="datetime-local"],
select,
textarea{
    width:100%;
    min-height:46px;
    padding:12px 14px;
    border:1px solid var(--border-strong);
    border-radius:12px;
    background:#fff;
    color:var(--text);
    outline:none;
    transition:border-color .2s ease, box-shadow .2s ease, background .2s ease;
}

textarea{
    min-height:110px;
    resize:vertical;
}

input:focus,
select:focus,
textarea:focus{
    border-color:#c7d2fe;
    box-shadow:0 0 0 4px rgba(79,70,229,.08);
    background:#fff;
}

::placeholder{
    color:#94a3b8;
}

/* =========================================================
   KPI
   ========================================================= */

.kpi-grid{
    display:grid;
    grid-template-columns:repeat(auto-fit, minmax(180px, 1fr));
    gap:16px;
}

.kpi-card{
    background:rgba(255,255,255,.92);
    border:1px solid var(--border);
    border-radius:20px;
    padding:18px;
    box-shadow:var(--shadow-sm);
}

.kpi-card span{
    display:block;
    margin-bottom:8px;
    font-size:14px;
    color:var(--text-muted);
}

.kpi-card strong{
    display:block;
    font-size:28px;
    line-height:1.1;
    color:var(--text);
    letter-spacing:-.04em;
}

/* =========================================================
   Dashboard / Today
   ========================================================= */

.dashboard-grid{
    display:grid;
    grid-template-columns:repeat(2, minmax(0,1fr));
    gap:18px;
}

.item-list{
    display:flex;
    flex-direction:column;
    gap:12px;
}

.item-row{
    display:flex;
    justify-content:space-between;
    align-items:flex-start;
    gap:14px;
    padding:14px;
    border:1px solid var(--border);
    border-radius:16px;
    background:var(--surface-soft);
}

.item-row--danger{
    border-color:#fecaca;
    background:#fff7f7;
}

.item-row strong{
    display:block;
    margin-bottom:4px;
    color:var(--text);
}

.item-row p{
    margin:0;
    color:var(--text-soft);
}

.today-layout{
    display:grid;
    grid-template-columns:minmax(0,2fr) minmax(280px,.95fr);
    gap:18px;
}

.today-main,
.today-side{
    display:flex;
    flex-direction:column;
    gap:18px;
}

.today-list{
    display:flex;
    flex-direction:column;
    gap:12px;
}

.today-item{
    display:flex;
    justify-content:space-between;
    align-items:flex-start;
    gap:14px;
    padding:15px;
    border:1px solid var(--border);
    border-radius:16px;
    background:var(--surface-soft);
}

.today-item--urgent{
    border-color:#fecaca;
    background:#fff7f7;
}

.today-item strong{
    display:block;
    margin-bottom:5px;
    color:var(--text);
}

.today-item p{
    margin:0 0 6px;
    color:var(--text-soft);
}

.today-item small{
    color:var(--text-muted);
}

.today-actions{
    display:flex;
    flex-direction:column;
    gap:8px;
    min-width:120px;
}

.mini-list{
    list-style:none;
    margin:0;
    padding:0;
    display:flex;
    flex-direction:column;
    gap:12px;
}

.mini-list li{
    padding:12px;
    border:1px solid var(--border);
    border-radius:14px;
    background:var(--surface-soft);
    color:var(--text-soft);
}

.mini-list strong{
    display:block;
    margin-bottom:4px;
    color:var(--text);
}

/* =========================================================
   Table / List
   ========================================================= */

.table-list{
    display:flex;
    flex-direction:column;
    gap:12px;
}

.table-row{
    display:grid;
    grid-template-columns:2.2fr 1.2fr .8fr;
    gap:16px;
    align-items:center;
    padding:16px;
    border:1px solid var(--border);
    border-radius:18px;
    background:rgba(255,255,255,.94);
    box-shadow:var(--shadow-sm);
}

.table-row strong{
    color:var(--text);
}

.table-row p{
    margin:4px 0 0;
    color:var(--text-muted);
}

/* =========================================================
   Detail
   ========================================================= */

.detail-grid{
    display:grid;
    grid-template-columns:repeat(2, minmax(0,1fr));
    gap:18px;
    margin-bottom:18px;
}

/* =========================================================
   Notes / Followups / Charges
   ========================================================= */

.notes-list{
    display:flex;
    flex-direction:column;
    gap:12px;
}

.note-item{
    display:flex;
    justify-content:space-between;
    align-items:flex-start;
    gap:16px;
    padding:14px;
    border:1px solid var(--border);
    border-radius:16px;
    background:var(--surface-soft);
}

.note-item__body{
    flex:1;
}

.note-item__body p{
    margin:0 0 8px;
    color:var(--text);
    line-height:1.55;
}

.note-item__body small{
    display:block;
    margin-top:6px;
    color:var(--text-muted);
}

.note-item__actions{
    display:flex;
    flex-direction:column;
    gap:8px;
    min-width:110px;
}

/* =========================================================
   Filters
   ========================================================= */

.filter-row{
    display:flex;
    gap:12px;
    flex-wrap:wrap;
    margin:18px 0;
}

.filter-row input,
.filter-row select{
    width:auto;
    min-width:200px;
}

/* =========================================================
   Badges
   ========================================================= */

.crm-badge{
    display:inline-flex;
    align-items:center;
    justify-content:center;
    min-height:28px;
    padding:0 10px;
    border-radius:999px;
    font-size:12px;
    font-weight:700;
    line-height:1;
    border:1px solid transparent;
    white-space:nowrap;
}

.crm-badge--default{background:#f1f5f9;color:#475569;border-color:#e2e8f0;}
.crm-badge--muted{background:#f8fafc;color:#64748b;border-color:#e2e8f0;}
.crm-badge--info{background:#eef2ff;color:#4338ca;border-color:#c7d2fe;}
.crm-badge--sky{background:#f0f9ff;color:#0369a1;border-color:#bae6fd;}
.crm-badge--success{background:#ecfdf5;color:#15803d;border-color:#bbf7d0;}
.crm-badge--warning{background:#fff7ed;color:#b45309;border-color:#fed7aa;}
.crm-badge--danger{background:#fef2f2;color:#b91c1c;border-color:#fecaca;}
.crm-badge--purple{background:#f5f3ff;color:#6d28d9;border-color:#ddd6fe;}
.crm-badge--whatsapp{background:#ecfdf5;color:#15803d;border-color:#bbf7d0;}
.crm-badge--instagram{background:#fff1f2;color:#be185d;border-color:#fbcfe8;}
.crm-badge--facebook{background:#eff6ff;color:#1d4ed8;border-color:#bfdbfe;}

.crm-badge-row{
    display:flex;
    flex-wrap:wrap;
    gap:8px;
    margin-top:8px;
}

/* =========================================================
   Auth
   ========================================================= */

.auth-wrap{
    min-height:100vh;
    display:flex;
    align-items:center;
    justify-content:center;
    padding:24px;
    background:linear-gradient(180deg, #f8fafc 0%, #eef2f7 100%);
}

.auth-card{
    width:100%;
    max-width:420px;
    background:#fff;
    border:1px solid var(--border);
    border-radius:26px;
    padding:28px;
    box-shadow:var(--shadow-md);
}

.auth-card h1{
    margin:0 0 8px;
    color:var(--text);
}

.auth-card p{
    margin:0 0 18px;
    color:var(--text-soft);
}

.auth-error{
    margin-bottom:14px;
    padding:12px 14px;
    border:1px solid #fecaca;
    background:#fef2f2;
    color:#b91c1c;
    border-radius:12px;
    font-size:14px;
}

/* =========================================================
   Utilities
   ========================================================= */

.text-muted{color:var(--text-muted);}
.text-success{color:var(--success);}
.text-danger{color:var(--danger);}

/* =========================================================
   Responsive
   ========================================================= */

@media (max-width:1100px){
    .dashboard-grid,
    .detail-grid,
    .today-layout{
        grid-template-columns:1fr;
    }
}

@media (max-width:900px){
    .app-sidebar{
        position:static;
        width:100%;
        height:auto;
        border-right:none;
        border-bottom:1px solid var(--border);
        padding:16px;
        background:rgba(255,255,255,.94);
    }

    .app-main{
        margin-left:0;
        padding:16px;
    }

    .app-sidebar nav{
        flex-direction:row;
        flex-wrap:wrap;
    }

    .app-sidebar nav a{
        min-height:40px;
        padding:0 12px;
    }

    .table-row{
        grid-template-columns:1fr;
    }
}

@media (max-width:640px){
    .page-head{
        flex-direction:column;
    }

    .page-head h1{
        font-size:28px;
    }

    .item-row,
    .today-item,
    .note-item{
        flex-direction:column;
    }

    .today-actions,
    .note-item__actions{
        width:100%;
        min-width:0;
        flex-direction:row;
        flex-wrap:wrap;
    }

    .card,
    .kpi-card,
    .table-row{
        border-radius:18px;
    }
}