@import url('https://fonts.googleapis.com/css2?family=Sora:wght@400;500;600;700;800&family=Inter:wght@400;500;600;700&family=IBM+Plex+Mono:wght@400;500;600&display=swap');

  :root{
    --purple-900:#241540;
    --purple-800:#331D5C;
    --purple-700:#4D2D81;
    --purple-600:#6242A0;
    --purple-500:#8560B7;
    --slate-700:#4B4253;
    --lavender-200:#B3AABC;
    --lavender-100:#DCD7E3;
    --bg:#F6F4FA;
    --surface:#FFFFFF;
    --border:#E6E1EE;
    --success:#2F9E5B;
    --success-bg:#E8F6EE;
    --warning:#C08A2E;
    --warning-bg:#FBF1E1;
    --danger:#C0392B;
    --danger-bg:#FBE9E7;
    --text:#241C33;
    --text-muted:#77708A;
    --radius:14px;
    --radius-sm:8px;
    --shadow: 0 1px 2px rgba(36,21,64,.04), 0 8px 24px -12px rgba(36,21,64,.18);
  }
  *{box-sizing:border-box;}
  html,body{margin:0;padding:0;}
  body{
    font-family:'Inter',system-ui,sans-serif;
    background:var(--bg);
    color:var(--text);
    -webkit-font-smoothing:antialiased;
  }
  h1,h2,h3,h4{font-family:'Sora',sans-serif; margin:0; letter-spacing:-0.01em;}
  .mono{font-family:'IBM Plex Mono',monospace;}
  button{font-family:inherit;cursor:pointer;}
  input,select,textarea{font-family:inherit;}

  /* ---- App shell ---- */
  #app{display:flex; min-height:100vh;}

  .sidebar{
    width:236px; flex-shrink:0;
    background:linear-gradient(180deg,var(--purple-900), #1a0f30 100%);
    color:#fff; display:flex; flex-direction:column;
    position:sticky; top:0; height:100vh; overflow-y:auto;
  }
  .sidebar-brand{
    display:flex; align-items:center; gap:10px;
    padding:22px 20px 18px 20px;
    border-bottom:1px solid rgba(255,255,255,.08);
  }
  .sidebar-brand img{height:26px; width:auto; display:block;}
  .sidebar-nav{padding:14px 10px; display:flex; flex-direction:column; gap:2px; flex:1;}
  .nav-btn{
    display:flex; align-items:center; gap:11px;
    padding:10px 12px; border-radius:10px; border:none;
    background:transparent; color:rgba(255,255,255,.72);
    font-size:13.5px; font-weight:500; text-align:left; width:100%;
    transition:background .15s, color .15s;
  }
  .nav-btn .ic{width:18px; height:18px; flex-shrink:0; opacity:.85;}
  .nav-btn:hover{background:rgba(255,255,255,.06); color:#fff;}
  .nav-btn.active{background:rgba(255,255,255,.12); color:#fff;}
  .nav-btn.active .ic{opacity:1;}
  .nav-section-label{
    font-size:10.5px; text-transform:uppercase; letter-spacing:.08em;
    color:rgba(255,255,255,.35); padding:16px 12px 6px 12px; font-weight:600;
  }
  .sidebar-foot{
    padding:14px 18px; border-top:1px solid rgba(255,255,255,.08);
    font-size:11px; color:rgba(255,255,255,.4); line-height:1.5;
  }

  .main{flex:1; min-width:0; display:flex; flex-direction:column;}
  .topbar{
    display:flex; align-items:center; justify-content:space-between;
    padding:18px 28px; background:var(--surface); border-bottom:1px solid var(--border);
    position:sticky; top:0; z-index:5;
  }
  .topbar h1{font-size:20px; font-weight:700; color:var(--purple-900);}
  .topbar .sub{font-size:12.5px; color:var(--text-muted); margin-top:2px;}
  .content{padding:26px 28px 60px 28px;}
  .panel{display:none;}
  .panel.active{display:block; animation:fadein .25s ease;}
  @keyframes fadein{from{opacity:0; transform:translateY(4px);} to{opacity:1; transform:none;}}

  /* ---- Cards / KPIs ---- */
  .kpi-grid{display:grid; grid-template-columns:repeat(auto-fit,minmax(190px,1fr)); gap:14px; margin-bottom:22px;}
  .kpi-card{
    background:var(--surface); border:1px solid var(--border); border-radius:var(--radius);
    padding:16px 18px; box-shadow:var(--shadow); position:relative; overflow:hidden;
  }
  .kpi-card .lens{
    position:absolute; right:-14px; top:-14px; width:64px; height:64px; opacity:.06;
  }
  .kpi-label{font-size:11.5px; color:var(--text-muted); font-weight:600; text-transform:uppercase; letter-spacing:.04em;}
  .kpi-value{font-family:'IBM Plex Mono',monospace; font-size:24px; font-weight:600; color:var(--purple-900); margin-top:6px;}
  .kpi-value.small{font-size:19px;}
  .kpi-delta{font-size:11.5px; margin-top:4px; color:var(--text-muted);}

  .card{
    background:var(--surface); border:1px solid var(--border); border-radius:var(--radius);
    box-shadow:var(--shadow); padding:20px 22px; margin-bottom:18px;
  }
  .card-head{display:flex; align-items:center; justify-content:space-between; margin-bottom:14px; gap:10px; flex-wrap:wrap;}
  .card-head h3{font-size:15px; font-weight:700; color:var(--purple-900);}
  .card-head .hint{font-size:12px; color:var(--text-muted);}

  .grid-2{display:grid; grid-template-columns:1fr 1fr; gap:18px;}
  .grid-3{display:grid; grid-template-columns:repeat(3,1fr); gap:18px;}
  @media(max-width:980px){.grid-2,.grid-3{grid-template-columns:1fr;}}

  label{font-size:12px; font-weight:600; color:var(--slate-700); display:block; margin-bottom:5px;}
  .field{margin-bottom:12px;}
  input[type=text],input[type=number],input[type=date],input[type=email],input[type=tel],select,textarea{
    width:100%; padding:9px 11px; border:1px solid var(--border); border-radius:var(--radius-sm);
    font-size:13.5px; color:var(--text); background:#fff; outline:none; transition:border-color .15s;
  }
  input:focus,select:focus,textarea:focus{border-color:var(--purple-500); box-shadow:0 0 0 3px rgba(133,96,183,.15);}
  textarea{resize:vertical; min-height:60px;}

  .btn{
    display:inline-flex; align-items:center; gap:6px; padding:9px 16px; border-radius:10px;
    font-size:13px; font-weight:600; border:1px solid transparent; transition:filter .15s, transform .1s;
  }
  .btn:active{transform:scale(.98);}
  .btn-primary{background:var(--purple-700); color:#fff;}
  .btn-primary:hover{filter:brightness(1.08);}
  .btn-ghost{background:transparent; border-color:var(--border); color:var(--slate-700);}
  .btn-ghost:hover{background:var(--bg);}
  .btn-danger{background:var(--danger-bg); color:var(--danger);}
  .btn-sm{padding:6px 11px; font-size:12px; border-radius:8px;}
  .btn-icon{padding:7px 9px;}

  table{width:100%; border-collapse:collapse; font-size:13px;}
  th{
    text-align:left; font-size:11px; text-transform:uppercase; letter-spacing:.03em; color:var(--text-muted);
    font-weight:700; padding:9px 10px; border-bottom:1px solid var(--border); white-space:nowrap;
  }
  td{padding:9px 10px; border-bottom:1px solid var(--border); vertical-align:middle;}
  tr:last-child td{border-bottom:none;}
  tbody tr:hover{background:var(--bg);}
  .num{font-family:'IBM Plex Mono',monospace; text-align:right;}

  .badge{display:inline-flex; align-items:center; padding:3px 9px; border-radius:100px; font-size:11px; font-weight:600;}
  .badge-purple{background:#EFE9F7; color:var(--purple-700);}
  .badge-green{background:var(--success-bg); color:var(--success);}
  .badge-amber{background:var(--warning-bg); color:var(--warning);}
  .badge-red{background:var(--danger-bg); color:var(--danger);}
  .badge-gray{background:var(--lavender-100); color:var(--slate-700);}

  .tabs{display:flex; gap:4px; border-bottom:1px solid var(--border); margin-bottom:16px; flex-wrap:wrap;}
  .tab-btn{padding:9px 14px; font-size:12.5px; font-weight:600; color:var(--text-muted); border-bottom:2px solid transparent; background:none; border-top:none;border-left:none;border-right:none;}
  .tab-btn.active{color:var(--purple-700); border-bottom-color:var(--purple-700);}

  .search-row{display:flex; gap:10px; margin-bottom:14px; flex-wrap:wrap;}
  .search-row input,.search-row select{width:auto; min-width:160px;}
  .search-row input[type=text]{flex:1; min-width:200px;}

  .empty{
    text-align:center; padding:36px 20px; color:var(--text-muted); font-size:13px;
  }
  .empty .lens-big{width:44px; height:44px; opacity:.25; margin:0 auto 10px auto; display:block;}

  /* Equipment picker */
  .equip-cat{margin-bottom:6px;}
  .equip-cat-head{
    display:flex; align-items:center; justify-content:space-between; padding:9px 4px;
    cursor:pointer; user-select:none;
  }
  .equip-cat-head h4{font-size:12.5px; font-weight:700; color:var(--purple-700);}
  .equip-cat-head .chev{transition:transform .15s; color:var(--text-muted); font-size:11px;}
  .equip-cat-head.open .chev{transform:rotate(90deg);}
  .equip-list{display:none; padding:2px 0 10px 0;}
  .equip-list.open{display:block;}
  .equip-row{
    display:grid; grid-template-columns:22px 1fr 78px 108px 90px; gap:10px; align-items:center;
    padding:7px 4px; border-bottom:1px dashed var(--border); font-size:12.5px;
  }
  .equip-row:last-child{border-bottom:none;}
  .equip-row .nm{color:var(--text); font-weight:500;}
  .equip-row .meta{color:var(--text-muted); font-size:11px;}
  .equip-row input[type=number]{padding:5px 7px; font-size:12px;}
  .equip-row input[type=checkbox]{width:16px; height:16px; accent-color:var(--purple-700);}

  .totals-box{
    background:var(--purple-900); color:#fff; border-radius:var(--radius); padding:18px 20px;
    background-image: radial-gradient(circle at 100% 0%, rgba(133,96,183,.35), transparent 55%);
  }
  .totals-row{display:flex; justify-content:space-between; padding:6px 0; font-size:13px; color:rgba(255,255,255,.75);}
  .totals-row.strong{color:#fff; font-weight:700; font-size:16px; border-top:1px solid rgba(255,255,255,.15); margin-top:6px; padding-top:12px;}
  .totals-row .v{font-family:'IBM Plex Mono',monospace;}

  .line-items{margin-top:8px;}
  .line-item{display:grid; grid-template-columns:1fr 90px 90px 30px; gap:8px; align-items:center; margin-bottom:6px;}

  .modal-bg{
    display:none; position:fixed; inset:0; background:rgba(36,21,64,.45); z-index:50;
    align-items:center; justify-content:center; padding:20px;
  }
  .modal-bg.open{display:flex;}
  .modal{background:#fff; border-radius:16px; max-width:640px; width:100%; max-height:88vh; overflow-y:auto; padding:24px 26px; box-shadow:0 24px 60px -20px rgba(36,21,64,.4);}
  .modal-head{display:flex; justify-content:space-between; align-items:center; margin-bottom:16px;}
  .close-x{background:none; border:none; font-size:20px; color:var(--text-muted); line-height:1;}

  .toast{
    position:fixed; bottom:20px; right:20px; background:var(--purple-900); color:#fff;
    padding:12px 18px; border-radius:10px; font-size:13px; box-shadow:var(--shadow); z-index:100;
    display:flex; align-items:center; gap:8px; opacity:0; transform:translateY(8px); transition:all .25s;
    pointer-events:none;
  }
  .toast.show{opacity:1; transform:none;}

  .project-card{border:1px solid var(--border); border-radius:var(--radius); padding:16px 18px; margin-bottom:12px; background:#fff;}
  .project-card-head{display:flex; justify-content:space-between; align-items:flex-start; gap:10px;}
  .project-code{font-family:'IBM Plex Mono',monospace; font-size:11.5px; color:var(--purple-600); font-weight:600;}
  .subtask{display:flex; align-items:center; gap:8px; font-size:12.5px; padding:4px 0;}
  .subtask input{width:15px; height:15px; accent-color:var(--purple-700);}

  .lead-col{background:var(--bg); border-radius:var(--radius); padding:10px; min-height:80px;}
  .lead-col h4{font-size:11.5px; text-transform:uppercase; letter-spacing:.03em; color:var(--text-muted); padding:4px 4px 8px 4px;}
  .lead-card{background:#fff; border:1px solid var(--border); border-radius:10px; padding:10px 11px; margin-bottom:8px; font-size:12.5px; box-shadow:var(--shadow);}
  .lead-card .nm{font-weight:700; color:var(--purple-900); margin-bottom:2px;}
  .lead-board{display:grid; grid-template-columns:repeat(9,minmax(150px,1fr)); gap:10px; overflow-x:auto; padding-bottom:8px;}
  .crm-view-btn.active{background:var(--purple-700); color:#fff; border-color:var(--purple-700);}

  ::-webkit-scrollbar{width:9px; height:9px;}
  ::-webkit-scrollbar-thumb{background:var(--lavender-200); border-radius:10px;}

  .print-only{display:none;}
  @media print{
    .sidebar,.topbar,.no-print{display:none !important;}
    .content{padding:0;}
    .print-only{display:block;}
    body{background:#fff;}
  }

/* ═══════════════════════════════════════════
   LOGIN SCREEN
═══════════════════════════════════════════ */
.login-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: linear-gradient(135deg, #1a0a2e 0%, #2d1459 50%, #4D2D81 100%);
  padding: 1rem;
}

.login-card {
  background: #fff;
  border-radius: 16px;
  padding: 2.5rem 2rem;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
}

.login-logo {
  width: 180px;
  margin-bottom: .5rem;
}

.login-title {
  font-size: 1.3rem;
  font-weight: 700;
  color: #1a0a2e;
  margin: 0;
  text-align: center;
}

.login-sub {
  font-size: .82rem;
  color: #888;
  margin: 0;
  text-align: center;
}

.login-error {
  background: #fff0f0;
  border: 1px solid #ffcccc;
  color: #c0392b;
  border-radius: 8px;
  padding: .6rem 1rem;
  font-size: .82rem;
  width: 100%;
  text-align: center;
}

.login-field {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: .35rem;
}

.login-field label {
  font-size: .8rem;
  font-weight: 600;
  color: #4B4253;
}

.login-field input {
  padding: .7rem 1rem;
  border: 1.5px solid #ddd;
  border-radius: 8px;
  font-size: .95rem;
  outline: none;
  transition: border-color .2s;
  width: 100%;
  box-sizing: border-box;
}

.login-field input:focus {
  border-color: #4D2D81;
}

.login-btn {
  width: 100%;
  padding: .85rem;
  background: #4D2D81;
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  margin-top: .5rem;
  transition: background .2s, transform .1s;
}

.login-btn:hover { background: #3a1f6b; }
.login-btn:active { transform: scale(.98); }
.login-btn:disabled { background: #999; cursor: not-allowed; }

.logout-btn {
  background: rgba(255,255,255,.15);
  border: 1px solid rgba(255,255,255,.3);
  color: rgba(255,255,255,.8);
  border-radius: 6px;
  padding: .4rem .8rem;
  font-size: .75rem;
  cursor: pointer;
  margin-top: .5rem;
  width: 100%;
  transition: background .2s;
}

.logout-btn:hover { background: rgba(255,255,255,.25); }

#loginScreen {
  position: fixed;
  inset: 0;
  z-index: 9999;
}

/* ═══ Finanzas — tabs y tabla ═══ */
.tab-bar {
  display: flex;
  gap: 4px;
  border-bottom: 2px solid var(--border);
  margin-bottom: 1rem;
  flex-wrap: wrap;
}
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.data-table th {
  background: var(--bg-alt);
  padding: 8px 10px;
  text-align: left;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
}
.data-table td {
  padding: 9px 10px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: var(--bg-alt); }
.badge-yellow { background: #fef9c3; color: #92400e; }
.badge-green  { background: #dcfce7; color: #166534; }

/* ═══════════════════════════════════════════════
   AGENDA / CALENDARIO
═══════════════════════════════════════════════ */
.agenda-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  flex-wrap: wrap;
  gap: 8px;
}
.agenda-nav {
  display: flex;
  align-items: center;
  gap: 6px;
}
.agenda-leyenda {
  display: flex;
  gap: 14px;
  align-items: center;
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 10px;
  flex-wrap: wrap;
}
.ev-dot {
  display: inline-block;
  width: 10px; height: 10px;
  border-radius: 50%;
  margin-right: 3px;
}
.ev-trabajo  { background: #4D2D81; }
.ev-pago     { background: #e67e22; }
.ev-tarea    { background: #27ae60; }
.ev-proyecto { background: #2980b9; }
.ev-personal { background: #8e44ad; }

/* Grilla mensual */
.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
  background: var(--border);
  border-radius: 10px;
  overflow: hidden;
}
.cal-header-day {
  background: var(--bg-alt);
  text-align: center;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  padding: 6px 0;
  text-transform: uppercase;
}
.cal-cell {
  background: var(--bg);
  min-height: 90px;
  padding: 4px 5px;
  cursor: pointer;
  transition: background .15s;
  position: relative;
}
.cal-cell:hover { background: var(--bg-alt); }
.cal-cell.today { background: #f0ebff; }
.cal-cell.otro-mes .cal-day-num { color: var(--text-muted); opacity: .4; }
.cal-day-num {
  font-size: 12px;
  font-weight: 700;
  margin-bottom: 3px;
  width: 22px; height: 22px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%;
}
.cal-cell.today .cal-day-num {
  background: #4D2D81;
  color: #fff;
}
.cal-ev {
  font-size: 10.5px;
  border-radius: 4px;
  padding: 1px 5px;
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
  color: #fff;
  font-weight: 500;
}
.cal-ev.ev-trabajo  { background: #4D2D81; }
.cal-ev.ev-pago     { background: #e67e22; }
.cal-ev.ev-tarea    { background: #27ae60; }
.cal-ev.ev-proyecto { background: #2980b9; }
.cal-ev.ev-personal { background: #8e44ad; }
.cal-ev-mas { font-size: 10px; color: var(--text-muted); }

/* Vista semanal */
.semana-grid {
  display: grid;
  grid-template-columns: 50px repeat(7, 1fr);
  gap: 1px;
  background: var(--border);
  border-radius: 10px;
  overflow: hidden;
  max-height: 600px;
  overflow-y: auto;
}
.semana-header {
  background: var(--bg-alt);
  text-align: center;
  padding: 8px 4px;
  font-size: 12px;
  font-weight: 700;
  position: sticky;
  top: 0;
  z-index: 2;
}
.semana-hora {
  background: var(--bg-alt);
  font-size: 10px;
  color: var(--text-muted);
  text-align: right;
  padding: 2px 4px;
  border-right: 1px solid var(--border);
}
.semana-cell {
  background: var(--bg);
  min-height: 28px;
  border-bottom: 1px solid var(--border);
  padding: 1px;
  position: relative;
}
.semana-cell:hover { background: var(--bg-alt); }
.semana-cell.today-col { background: #f9f5ff; }

/* Vista lista */
.agenda-lista-dia {
  margin-bottom: 16px;
}
.agenda-lista-fecha {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .06em;
  margin-bottom: 6px;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--border);
}
.agenda-lista-fecha.hoy-label {
  color: #4D2D81;
}
.agenda-lista-ev {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  margin-bottom: 5px;
  background: var(--bg-alt);
  cursor: pointer;
  transition: background .15s;
}
.agenda-lista-ev:hover { background: #f0ebff; }
.agenda-lista-barra {
  width: 4px;
  border-radius: 4px;
  align-self: stretch;
  flex-shrink: 0;
}
.agenda-lista-ev .ev-hora { font-size: 11px; color: var(--text-muted); min-width: 40px; }
.agenda-lista-ev .ev-titulo { font-size: 13px; font-weight: 600; }
.agenda-lista-ev .ev-sub { font-size: 11px; color: var(--text-muted); }
