
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; font-size: 14px; color: #1e293b; background: #f1f5f9; min-height: 100vh; }
a { color: #4f46e5; text-decoration: none; }
a:hover { text-decoration: underline; }

/* Login */
#saas-login { display:flex; align-items:center; justify-content:center; min-height:100vh; background:#1e1b4b; }
.login-box { background:#fff; border-radius:16px; padding:2.5rem; width:100%; max-width:380px; box-shadow:0 20px 60px rgba(0,0,0,.3); }
.login-logo { display:flex; align-items:center; gap:12px; margin-bottom:2rem; }
.login-logo-icon { width:44px; height:44px; background:#4f46e5; border-radius:12px; display:flex; align-items:center; justify-content:center; color:#fff; font-size:22px; }
.login-logo-text { font-size:18px; font-weight:600; color:#1e293b; }
.login-logo-sub { font-size:12px; color:#64748b; }
.login-title { font-size:20px; font-weight:600; margin-bottom:.25rem; }
.login-sub { color:#64748b; font-size:13px; margin-bottom:1.5rem; }
.form-group { margin-bottom:1rem; }
.form-label { display:block; font-size:12px; font-weight:500; color:#475569; margin-bottom:6px; }
.form-input { width:100%; padding:10px 12px; border:1px solid #e2e8f0; border-radius:8px; font-size:14px; outline:none; transition:border-color .15s; color:#1e293b; background:#fff; }
.form-input:focus { border-color:#4f46e5; box-shadow:0 0 0 3px rgba(79,70,229,.12); }
.form-select { padding:9px 12px; border:1px solid #e2e8f0; border-radius:8px; font-size:13px; outline:none; background:#fff; color:#1e293b; cursor:pointer; }
.form-select:focus { border-color:#4f46e5; }
.login-btn { width:100%; padding:11px; background:#4f46e5; color:#fff; border:none; border-radius:8px; font-size:15px; font-weight:500; cursor:pointer; transition:background .15s; }
.login-btn:hover { background:#4338ca; }
.login-err { color:#dc2626; font-size:12px; margin-top:.5rem; min-height:18px; }
.login-hint { font-size:12px; color:#94a3b8; margin-top:1rem; text-align:center; }
.login-hint code { background:#f1f5f9; padding:2px 6px; border-radius:4px; }

/* App shell */
#saas-app { display:none; height:100vh; flex-direction:column; }

/* Top bar */
.saas-topbar { display:none; align-items:center; justify-content:space-between; padding:0 1rem; height:56px; background:#1e1b4b; color:#fff; flex-shrink:0; }
@media(max-width:1023px){ .saas-topbar { display:flex; } }
.topbar-menu-btn { background:none; border:none; color:#fff; font-size:22px; cursor:pointer; padding:8px; border-radius:8px; line-height:1; }
.topbar-menu-btn:hover { background:rgba(255,255,255,.1); }
#saas-top-title { font-size:15px; font-weight:500; }
.topbar-av { width:32px; height:32px; background:#4f46e5; border-radius:50%; display:flex; align-items:center; justify-content:center; color:#fff; font-size:13px; font-weight:500; }

/* Layout */
.app-body { display:flex; flex:1; overflow:hidden; }

/* Sidebar */
#saas-sidebar { width:240px; background:#1e1b4b; display:flex; flex-direction:column; flex-shrink:0; overflow-y:auto; transition:transform .3s ease; }
@media(max-width:1023px){
  #saas-sidebar { position:fixed; top:0; left:0; height:100%; z-index:200; transform:translateX(-100%); }
  #saas-sidebar.open { transform:translateX(0); }
  #saas-sidebar.-translate-x-full { transform:translateX(-100%); }
}
.sidebar-brand { padding:1.25rem 1rem 1rem; border-bottom:1px solid rgba(255,255,255,.08); }
.brand-logo { display:flex; align-items:center; gap:10px; }
.brand-icon { width:36px; height:36px; background:#4f46e5; border-radius:10px; display:flex; align-items:center; justify-content:center; color:#fff; font-size:18px; }
.brand-name { color:#fff; font-size:14px; font-weight:600; line-height:1.2; }
.brand-tagline { color:rgba(255,255,255,.4); font-size:11px; }
.sidebar-nav { padding:.75rem .625rem; flex:1; }
.nav-link { display:flex; align-items:center; gap:10px; padding:9px 10px; border-radius:8px; color:rgba(255,255,255,.65); cursor:pointer; margin-bottom:2px; border:none; background:none; width:100%; text-align:left; font-size:13.5px; transition:background .15s,color .15s; }
.nav-link i { font-size:18px; }
.nav-link:hover { background:rgba(255,255,255,.08); color:rgba(255,255,255,.9); }
.nav-link.active { background:rgba(79,70,229,.7); color:#fff; }
.nav-sep { height:1px; background:rgba(255,255,255,.1); margin:10px 6px; }
.nav-link.nav-ext { text-decoration:none; }
.nav-ext-ic { font-size:13px !important; margin-left:auto; opacity:.5; }
.sidebar-footer { padding:1rem; border-top:1px solid rgba(255,255,255,.08); }
.sidebar-mrr { background:rgba(255,255,255,.07); border-radius:8px; padding:10px 12px; }
.sidebar-mrr-label { font-size:10px; color:rgba(255,255,255,.45); text-transform:uppercase; letter-spacing:.5px; }
.sidebar-mrr-val { font-size:20px; font-weight:600; color:#fff; margin-top:2px; }
.sidebar-mrr-sub { font-size:11px; color:rgba(255,255,255,.4); margin-top:2px; }

#saas-backdrop { position:fixed; inset:0; background:rgba(0,0,0,.5); z-index:199; }
.hidden { display:none !important; }

/* Main content */
#main-content { flex:1; overflow-y:auto; }
.page-content { padding:1.5rem; max-width:1200px; }
@media(max-width:768px){ .page-content { padding:1rem; } }
.page-header { margin-bottom:1.5rem; }
.page-title { font-size:22px; font-weight:600; color:#0f172a; }
.page-subtitle { font-size:13px; color:#64748b; margin-top:4px; display:block; }

/* KPI cards */
.kpi-grid { display:grid; grid-template-columns:repeat(4,1fr); gap:12px; margin-bottom:1.5rem; }
@media(max-width:900px){ .kpi-grid { grid-template-columns:repeat(2,1fr); } }
@media(max-width:500px){ .kpi-grid { grid-template-columns:1fr 1fr; } }
.kpi-card { background:#fff; border-radius:12px; border:1px solid #e2e8f0; padding:1rem 1.25rem; display:flex; align-items:flex-start; gap:12px; }
.kpi-icon { width:40px; height:40px; border-radius:10px; display:flex; align-items:center; justify-content:center; flex-shrink:0; font-size:20px; }
.kpi-purple { background:#ede9fe; color:#4f46e5; }
.kpi-blue   { background:#dbeafe; color:#1d4ed8; }
.kpi-green  { background:#dcfce7; color:#16a34a; }
.kpi-amber  { background:#fef9c3; color:#ca8a04; }
.kpi-label  { font-size:11px; color:#64748b; font-weight:500; text-transform:uppercase; letter-spacing:.3px; }
.kpi-value  { font-size:24px; font-weight:600; color:#0f172a; line-height:1.2; margin-top:2px; }
.kpi-delta  { font-size:11px; margin-top:4px; }
.kpi-delta.up   { color:#16a34a; }
.kpi-delta.down { color:#dc2626; }

/* Cards */
.card { background:#fff; border-radius:12px; border:1px solid #e2e8f0; }
.card-header { display:flex; align-items:center; justify-content:space-between; padding:1rem 1.25rem; border-bottom:1px solid #f1f5f9; }
.card-title { font-size:14px; font-weight:600; color:#0f172a; }
.card-sub { font-size:12px; color:#94a3b8; }
.table-card { overflow:hidden; }

/* Dash grids */
.dash-grid   { display:grid; grid-template-columns:1fr 1fr; gap:1rem; margin-bottom:1rem; }
.dash-grid-2 { display:grid; grid-template-columns:3fr 2fr; gap:1rem; margin-bottom:1rem; }
@media(max-width:900px){ .dash-grid, .dash-grid-2 { grid-template-columns:1fr; } }

/* Chart */
.chart-area { display:flex; align-items:flex-end; gap:6px; padding:1.25rem 1.25rem .5rem; height:160px; }
.bar-col { display:flex; flex-direction:column; align-items:center; flex:1; height:100%; }
.bar-val { font-size:10px; font-weight:600; color:#4f46e5; height:16px; }
.bar-wrap { flex:1; width:100%; display:flex; align-items:flex-end; }
.bar-fill { width:100%; background:#c7d2fe; border-radius:4px 4px 0 0; min-height:4px; transition:height .3s; }
.bar-last { background:#4f46e5; }
.bar-label { font-size:10px; color:#94a3b8; margin-top:4px; text-align:center; }

/* Plan distribution */
.plan-dist { padding:1rem 1.25rem; }
.plan-dist-row { display:grid; grid-template-columns:12px 1fr auto auto 80px; align-items:center; gap:8px; margin-bottom:.75rem; }
.plan-dist-color { width:10px; height:10px; border-radius:50%; }
.plan-dist-name { font-size:12px; color:#475569; }
.plan-dist-count { font-size:12px; color:#64748b; white-space:nowrap; }
.plan-dist-mrr { font-size:12px; font-weight:600; color:#0f172a; white-space:nowrap; text-align:right; }
.plan-dist-bar-wrap { height:6px; background:#f1f5f9; border-radius:99px; overflow:hidden; }
.plan-dist-bar { height:100%; border-radius:99px; }
.plan-dist-trials { padding:.75rem 1.25rem; background:#f8fafc; border-top:1px solid #f1f5f9; font-size:12px; color:#64748b; display:flex; align-items:center; gap:8px; border-radius:0 0 12px 12px; }

/* Pipeline dashboard items */
.pipeline-item { display:flex; align-items:center; gap:10px; padding:10px 1.25rem; border-bottom:1px solid #f8fafc; cursor:pointer; transition:background .1s; }
.pipeline-item:last-child { border-bottom:none; }
.pipeline-item:hover { background:#f8fafc; }
.pipeline-body { flex:1; min-width:0; }
.pipeline-name { font-size:13px; font-weight:500; color:#0f172a; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.pipeline-meta { font-size:11px; color:#94a3b8; margin-top:2px; }
.pipeline-right { display:flex; flex-direction:column; align-items:flex-end; gap:4px; flex-shrink:0; }
.pipeline-dias { font-size:11px; color:#64748b; }
.pipeline-dias.urgent { color:#dc2626; font-weight:600; }

/* Tables */
.data-table { width:100%; border-collapse:collapse; font-size:13px; }
.data-table th { padding:10px 1.25rem; text-align:left; font-size:11px; color:#64748b; font-weight:500; text-transform:uppercase; letter-spacing:.3px; background:#f8fafc; border-bottom:1px solid #e2e8f0; }
.data-table td { padding:12px 1.25rem; border-bottom:1px solid #f8fafc; vertical-align:middle; color:#1e293b; }
.data-table tbody tr:last-child td { border-bottom:none; }
.row-clickable { cursor:pointer; transition:background .1s; }
.row-clickable:hover { background:#f8fafc; }
.cell-name { display:flex; align-items:center; gap:10px; }
.cell-sub { font-size:11px; color:#94a3b8; margin-top:2px; }
.text-muted { color:#64748b; }
.font-mono { font-family:monospace; }
.desktop-only { display:table; }
@media(max-width:768px){ .desktop-only { display:none; } }

/* Mobile cards for client list */
.mobile-cards { display:none; }
@media(max-width:767px){ .mobile-cards { display:block; } }
.md-hidden { }
.mobile-client-card { display:flex; align-items:center; gap:12px; padding:12px 1rem; border-bottom:1px solid #f1f5f9; cursor:pointer; }
.mobile-client-card:hover { background:#f8fafc; }
.mobile-card-body { flex:1; min-width:0; }
.mobile-card-name { font-size:14px; font-weight:500; color:#0f172a; }
.mobile-card-meta { font-size:12px; color:#64748b; margin-top:2px; }
.mobile-card-badges { display:flex; gap:4px; margin-top:6px; flex-wrap:wrap; }
.mobile-card-mrr { font-size:13px; font-weight:600; color:#4f46e5; flex-shrink:0; font-family:monospace; }

/* Toolbar */
.toolbar { display:flex; align-items:center; gap:10px; flex-wrap:wrap; }
.search-wrap { position:relative; flex:1; min-width:200px; }
.search-icon { position:absolute; left:10px; top:50%; transform:translateY(-50%); color:#94a3b8; font-size:16px; pointer-events:none; }
.search-input { width:100%; padding:9px 12px 9px 34px; border:1px solid #e2e8f0; border-radius:8px; font-size:13px; outline:none; color:#1e293b; background:#fff; }
.search-input:focus { border-color:#4f46e5; box-shadow:0 0 0 3px rgba(79,70,229,.1); }
.filter-tabs { display:flex; gap:4px; }
.filter-tab { padding:8px 14px; border:1px solid #e2e8f0; border-radius:8px; background:#fff; font-size:13px; color:#64748b; cursor:pointer; transition:all .15s; }
.filter-tab:hover { border-color:#c7d2fe; color:#4f46e5; }
.filter-tab.active { background:#4f46e5; border-color:#4f46e5; color:#fff; }

/* Badges */
.badge { display:inline-block; padding:3px 8px; border-radius:99px; font-size:11px; font-weight:500; }
.b-ok      { background:#dcfce7; color:#16a34a; }
.b-warn    { background:#fef9c3; color:#854d0e; }
.b-danger  { background:#fee2e2; color:#dc2626; }
.b-info    { background:#dbeafe; color:#1d4ed8; }
.b-purple  { background:#ede9fe; color:#4f46e5; }
.b-green   { background:#dcfce7; color:#15803d; }
.b-amber   { background:#fef3c7; color:#b45309; }

/* Avatars */
.av { width:32px; height:32px; border-radius:8px; display:flex; align-items:center; justify-content:center; font-size:13px; font-weight:600; flex-shrink:0; }
.av-lg { width:44px; height:44px; font-size:18px; border-radius:12px; }
.av-purple { background:#ede9fe; color:#4f46e5; }
.av-green  { background:#dcfce7; color:#15803d; }
.av-amber  { background:#fef3c7; color:#b45309; }
.av-gray   { background:#f1f5f9; color:#64748b; }

/* Pipeline kanban */
.pipeline-columns { display:grid; grid-template-columns:repeat(3,1fr); gap:1rem; }
@media(max-width:900px){ .pipeline-columns { grid-template-columns:1fr; } }
.pipeline-col { background:#f8fafc; border-radius:12px; padding:1rem; min-height:300px; }
.pipeline-col-header { display:flex; align-items:center; justify-content:space-between; margin-bottom:.75rem; }
.pipeline-col-title { font-size:13px; font-weight:600; color:#475569; }
.pipeline-kanban-card { background:#fff; border-radius:10px; border:1px solid #e2e8f0; padding:.875rem 1rem; margin-bottom:.625rem; cursor:pointer; transition:box-shadow .15s; }
.pipeline-kanban-card:hover { box-shadow:0 2px 8px rgba(0,0,0,.08); }
.urgent-card { border-left:3px solid #dc2626; }
.pipeline-kanban-top { display:flex; align-items:center; gap:10px; margin-bottom:.625rem; }
.pipeline-kanban-body { flex:1; min-width:0; }
.pipeline-kanban-name { font-size:13px; font-weight:500; color:#0f172a; }
.pipeline-kanban-meta { font-size:11px; color:#94a3b8; margin-top:2px; }
.pipeline-kanban-footer { display:flex; align-items:center; justify-content:space-between; margin-bottom:.5rem; }
.pipeline-nota { font-size:11px; color:#94a3b8; line-height:1.5; padding-top:.5rem; border-top:1px solid #f1f5f9; }
.dias-badge { font-size:11px; padding:2px 8px; border-radius:99px; background:#f1f5f9; color:#64748b; }
.dias-badge.urgent { background:#fee2e2; color:#dc2626; }
.dias-badge.expired { background:#fef9c3; color:#854d0e; }

/* Planes */
.planes-grid { display:grid; grid-template-columns:repeat(3,1fr); gap:1rem; }
@media(max-width:900px){ .planes-grid { grid-template-columns:1fr; } }
.plan-card { background:#fff; border-radius:12px; border:1px solid #e2e8f0; overflow:hidden; }
.plan-card-green  { border-top:4px solid #16a34a; }
.plan-card-purple { border-top:4px solid #4f46e5; }
.plan-card-amber  { border-top:4px solid #d97706; }
.plan-card-header { padding:1.25rem; display:flex; justify-content:space-between; align-items:flex-start; border-bottom:1px solid #f1f5f9; }
.plan-card-name  { font-size:16px; font-weight:600; color:#0f172a; }
.plan-card-price { font-size:28px; font-weight:700; color:#0f172a; margin-top:4px; }
.plan-card-price span { font-size:14px; font-weight:400; color:#64748b; }
.plan-card-stats { display:flex; flex-direction:column; align-items:flex-end; gap:4px; }
.plan-stat { text-align:right; }
.plan-stat-val { font-size:15px; font-weight:600; color:#0f172a; }
.plan-stat-lbl { font-size:10px; color:#94a3b8; display:block; }
.plan-card-limits { padding:.75rem 1.25rem; background:#f8fafc; border-bottom:1px solid #f1f5f9; }
.plan-limit { font-size:12px; color:#64748b; display:flex; align-items:center; gap:6px; margin-bottom:4px; }
.plan-limit i { font-size:14px; }
.plan-features { list-style:none; padding:1rem 1.25rem; flex:1; }
.plan-features li { display:flex; align-items:center; gap:8px; font-size:13px; color:#475569; margin-bottom:.5rem; }
.plan-features li i { color:#16a34a; font-size:15px; flex-shrink:0; }
.plan-card-actions { padding:1rem 1.25rem; border-top:1px solid #f1f5f9; display:flex; gap:8px; }

/* Revenue compare */
.revenue-compare { padding:1.25rem; }
.rev-row { display:grid; grid-template-columns:80px 1fr 40px 80px; align-items:center; gap:10px; margin-bottom:.875rem; }
.rev-plan { font-size:12px; font-weight:500; color:#475569; }
.rev-bar-wrap { height:8px; background:#f1f5f9; border-radius:99px; overflow:hidden; }
.rev-bar { height:100%; border-radius:99px; transition:width .4s; }
.rev-pct { font-size:12px; color:#64748b; text-align:right; }
.rev-mrr { font-size:12px; font-weight:600; color:#0f172a; text-align:right; font-family:monospace; }
.bg-purple { background:#4f46e5; }
.bg-amber  { background:#d97706; }
.bg-green  { background:#16a34a; }

/* Modals */
.modal-overlay { position:fixed; inset:0; background:rgba(0,0,0,.5); z-index:500; display:flex; align-items:flex-end; justify-content:center; }
@media(min-width:640px){ .modal-overlay { align-items:center; } }
.modal-panel { background:#fff; border-radius:16px 16px 0 0; width:100%; max-width:560px; max-height:92vh; overflow-y:auto; padding:1.5rem; }
@media(min-width:640px){ .modal-panel { border-radius:16px; } }
.modal-sm { max-width:420px; }
.modal-header { display:flex; align-items:flex-start; gap:12px; margin-bottom:1.25rem; }
.modal-title-block { flex:1; }
.modal-title { font-size:18px; font-weight:600; color:#0f172a; }
.modal-meta { font-size:12px; color:#64748b; margin-top:4px; display:flex; align-items:center; gap:6px; flex-wrap:wrap; }
.modal-close { margin-left:auto; background:none; border:none; cursor:pointer; color:#94a3b8; font-size:20px; padding:4px; border-radius:8px; flex-shrink:0; }
.modal-close:hover { background:#f1f5f9; color:#475569; }
.modal-kpis { display:grid; grid-template-columns:repeat(4,1fr); gap:8px; background:#f8fafc; border-radius:10px; padding:.875rem; margin-bottom:1.25rem; }
.modal-kpi { text-align:center; }
.modal-kpi-label { font-size:10px; color:#94a3b8; font-weight:500; text-transform:uppercase; letter-spacing:.3px; }
.modal-kpi-val { font-size:16px; font-weight:600; color:#0f172a; margin-top:4px; }
.modal-section { margin-bottom:1.25rem; }
.modal-section-title { font-size:11px; color:#94a3b8; font-weight:500; text-transform:uppercase; letter-spacing:.4px; margin-bottom:.625rem; }
.detail-row { display:flex; align-items:center; gap:8px; font-size:13px; color:#475569; margin-bottom:.5rem; }
.detail-row i { font-size:16px; color:#94a3b8; }
.modal-actions { display:flex; gap:8px; justify-content:flex-end; padding-top:1rem; border-top:1px solid #f1f5f9; flex-wrap:wrap; }
.pipeline-notas-text { font-size:13px; color:#475569; line-height:1.6; background:#f8fafc; padding:.875rem; border-radius:8px; }

/* Plan upgrade in modal */
.plan-upgrade { display:flex; flex-direction:column; gap:8px; }
.plan-option { display:flex; align-items:center; gap:12px; padding:10px 12px; border:1px solid #e2e8f0; border-radius:8px; }
.plan-option.active { border-color:#4f46e5; background:#f5f3ff; }
.plan-option-name { font-size:13px; font-weight:500; color:#0f172a; flex:1; }
.plan-option-price { font-size:12px; color:#64748b; font-family:monospace; }
.plan-current { font-size:11px; color:#4f46e5; font-weight:500; }
.plan-change-btn { padding:5px 12px; background:#4f46e5; color:#fff; border:none; border-radius:6px; font-size:12px; cursor:pointer; }
.plan-change-btn:hover { background:#4338ca; }

/* Factura rows */
.factura-row { display:flex; align-items:center; gap:10px; padding:8px 0; border-bottom:1px solid #f8fafc; font-size:13px; }
.factura-row:last-child { border-bottom:none; }
.factura-id { font-family:monospace; color:#94a3b8; font-size:11px; min-width:120px; }
.factura-mes { flex:1; color:#475569; }
.factura-importe { font-family:monospace; font-weight:500; color:#0f172a; }

/* Buttons */
.btn-primary   { padding:9px 18px; background:#4f46e5; color:#fff; border:none; border-radius:8px; font-size:13px; font-weight:500; cursor:pointer; display:inline-flex; align-items:center; gap:6px; transition:background .15s; }
.btn-primary:hover { background:#4338ca; }
.btn-secondary { padding:9px 18px; background:#fff; color:#475569; border:1px solid #e2e8f0; border-radius:8px; font-size:13px; cursor:pointer; transition:all .15s; }
.btn-secondary:hover { background:#f8fafc; }
.btn-danger    { padding:9px 18px; background:#dc2626; color:#fff; border:none; border-radius:8px; font-size:13px; cursor:pointer; }
.btn-danger:hover { background:#b91c1c; }
.btn-outline   { padding:8px 14px; background:#fff; border:1px solid #e2e8f0; border-radius:8px; font-size:13px; color:#475569; cursor:pointer; display:inline-flex; align-items:center; gap:6px; transition:all .15s; }
.btn-outline:hover { border-color:#c7d2fe; color:#4f46e5; }
.btn-xs        { padding:4px 10px; background:#4f46e5; color:#fff; border:none; border-radius:6px; font-size:12px; cursor:pointer; }
.btn-xs:hover  { background:#4338ca; }
.icon-btn      { background:none; border:none; cursor:pointer; color:#94a3b8; padding:4px; border-radius:6px; font-size:16px; }
.icon-btn:hover { background:#f1f5f9; color:#475569; }
.link-btn      { background:none; border:none; cursor:pointer; color:#4f46e5; font-size:12px; padding:0; }
.link-btn:hover { text-decoration:underline; }
.text-danger   { color:#dc2626; }

/* Empty state */
.empty-state { text-align:center; padding:3rem 1rem; color:#94a3b8; }
.empty-state i { font-size:40px; display:block; margin-bottom:.75rem; }
.empty-state p { font-size:14px; }

/* Toast */
.saas-toast { position:fixed; bottom:1.5rem; right:1.5rem; background:#0f172a; color:#fff; padding:12px 20px; border-radius:10px; font-size:13px; z-index:9999; transform:translateY(80px); opacity:0; transition:all .3s; max-width:300px; }
.saas-toast.show { transform:translateY(0); opacity:1; }
.saas-toast.error { background:#dc2626; }
