/* =========================================================
   CRM Flow - Base UI
   ========================================================= */

:root{
    --bg-app:#071226;
    --bg-sidebar:#08101f;
    --bg-topbar:#0c1729;
    --bg-card:#ffffff;
    --bg-soft:#f8fafc;
    --bg-soft-2:#f1f5f9;

    --text:#0f172a;
    --text-soft:#475569;
    --text-muted:#64748b;
    --text-white:#f8fafc;

    --border:#e2e8f0;
    --border-soft:#edf2f7;

    --primary:#2563eb;
    --primary-soft:#eff6ff;

    --success:#16a34a;
    --success-soft:#ecfdf5;

    --warning:#d97706;
    --warning-soft:#fffbeb;

    --danger:#dc2626;
    --danger-soft:#fef2f2;

    --purple:#7c3aed;
    --purple-soft:#f5f3ff;

    --shadow:0 10px 30px rgba(2,6,23,.10);
    --radius-lg:18px;
    --radius-md:14px;
    --radius-sm:10px;
    --sidebar-width:260px;
}

/* =========================================================
   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, #030712 0%, #071226 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;
}

.app-sidebar{
    position:fixed;
    top:0;
    left:0;
    width:var(--sidebar-width);
    height:100vh;
    background:linear-gradient(180deg, #06101f 0%, #0b1730 100%);
    border-right:1px solid rgba(255,255,255,.06);
    padding:24px 18px;
    overflow-y:auto;
    z-index:1000;
}

.app-logo{
    color:#fff;
    font-size:22px;
    font-weight:800;
    letter-spacing:-.02em;
    margin-bottom:24px;
}

.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:12px;
    color:rgba(255,255,255,.82);
    font-weight:600;
    transition:.2s ease;
}

.app-sidebar nav a:hover{
    background:rgba(255,255,255,.08);
    color:#fff;
}

.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:16px 20px;
    background:rgba(255,255,255,.04);
    border:1px solid rgba(255,255,255,.08);
    border-radius:18px;
    backdrop-filter:blur(8px);
    color:#fff;
}

.app-topbar strong{
    font-size:18px;
    font-weight:700;
}

/* =========================================================
   Sections / 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.05;
    letter-spacing:-.03em;
    color:#fff;
}

.page-head p{
    margin:0;
    color:rgba(255,255,255,.72);
}

.page-section > h2{
    margin:0 0 14px;
    font-size:22px;
    color:#fff;
}

/* =========================================================
   Cards
   ========================================================= */

.card{
    background:var(--bg-card);
    border:1px solid rgba(255,255,255,.7);
    border-radius:24px;
    padding:20px;
    box-shadow:var(--shadow);
    color:var(--text);
}

.card h2,
.card h3,
.card h4{
    margin:0 0 14px;
    color:var(--text);
    letter-spacing:-.02em;
}

.card p{
    color:var(--text-soft);
}

.card small{
    color:var(--text-muted);
}

.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;
}

/* =========================================================
   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:.95;
    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);
    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:38px;
    padding:0 12px;
    border-radius:10px;
    background:var(--primary-soft);
    color:#1d4ed8;
    font-weight:700;
    font-size:14px;
}

/* =========================================================
   Forms
   ========================================================= */

form{
    display:block;
}

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);
    border-radius:12px;
    background:#fff;
    color:var(--text);
    outline:none;
    transition:border-color .2s ease, box-shadow .2s ease;
}

textarea{
    min-height:110px;
    resize:vertical;
}

input:focus,
select:focus,
textarea:focus{
    border-color:#93c5fd;
    box-shadow:0 0 0 4px rgba(37,99,235,.10);
}

::placeholder{
    color:#94a3b8;
}

/* =========================================================
   KPI cards
   ========================================================= */

.kpi-grid{
    display:grid;
    grid-template-columns:repeat(auto-fit, minmax(180px, 1fr));
    gap:16px;
}

.kpi-card{
    background:#fff;
    border:1px solid rgba(255,255,255,.7);
    border-radius:20px;
    padding:18px;
    box-shadow:var(--shadow);
}

.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:-.03em;
}

/* =========================================================
   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-soft);
    border-radius:14px;
    background:var(--bg-soft);
}

.item-row--danger{
    border-color:#fecaca;
    background:#fff1f2;
}

.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-soft);
    border-radius:16px;
    background:var(--bg-soft);
}

.today-item--urgent{
    border-color:#fca5a5;
    background:#fff1f2;
}

.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-soft);
    border-radius:14px;
    background:var(--bg-soft);
    color:var(--text-soft);
}

.mini-list strong{
    display:block;
    margin-bottom:4px;
    color:var(--text);
}

/* =========================================================
   Tables / lists
   ========================================================= */

.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 rgba(255,255,255,.7);
    border-radius:18px;
    background:#fff;
    box-shadow:var(--shadow);
}

.table-row strong{
    color:var(--text);
}

.table-row p{
    margin:4px 0 0;
    color:var(--text-muted);
}

/* =========================================================
   Detail page
   ========================================================= */

.detail-grid{
    display:grid;
    grid-template-columns:repeat(2, minmax(0,1fr));
    gap:18px;
    margin-bottom:18px;
}

/* =========================================================
   Notes / followups / charges blocks
   ========================================================= */

.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-soft);
    border-radius:14px;
    background:var(--bg-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);
    line-height:1.45;
}

.note-item__actions{
    display:flex;
    flex-direction:column;
    gap:8px;
    min-width:110px;
}

.note-item__actions span{
    font-weight:700;
}

/* =========================================================
   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:#f3f4f6;color:#374151;border-color:#e5e7eb;}
.crm-badge--muted{background:#f8fafc;color:#64748b;border-color:#e2e8f0;}
.crm-badge--info{background:#eff6ff;color:#1d4ed8;border-color:#bfdbfe;}
.crm-badge--sky{background:#f0f9ff;color:#0369a1;border-color:#bae6fd;}
.crm-badge--success{background:#ecfdf5;color:#047857;border-color:#a7f3d0;}
.crm-badge--warning{background:#fffbeb;color:#b45309;border-color:#fde68a;}
.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:radial-gradient(circle at top, #0f172a 0%, #020617 70%);
}

.auth-card{
    width:100%;
    max-width:420px;
    background:#fff;
    border:1px solid rgba(255,255,255,.7);
    border-radius:24px;
    padding:28px;
    box-shadow:0 20px 60px rgba(0,0,0,.20);
}

.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 rgba(255,255,255,.06);
        padding:16px;
    }

    .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;
    }

    .app-topbar{
        padding:14px 16px;
    }

    .card,
    .kpi-card,
    .table-row{
        border-radius:18px;
    }
}