/* ===========================================================
   Portafolio TI — UI moderna, sobria y ejecutiva
   =========================================================== */
:root {
  --bg:        #f4f6fb;
  --surface:   #ffffff;
  --surface-2: #f8fafc;
  --border:    #e5e7eb;
  --text:      #0f172a;
  --muted:     #64748b;
  --primary:   #2563eb;
  --primary-2: #1d4ed8;
  --accent:    #0ea5e9;
  --green:     #10b981;
  --amber:     #f59e0b;
  --red:       #ef4444;
  --shadow:    0 1px 2px rgba(15,23,42,.04), 0 4px 12px rgba(15,23,42,.06);
  --radius:    12px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto,
               'Helvetica Neue', Arial, sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-2); }

/* ----------- Layout ----------- */
.app {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 100vh;
}
.sidebar {
  background: #0b1120;
  color: #cbd5e1;
  padding: 20px 16px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
.brand {
  display: flex; align-items: center; gap: 10px;
  font-weight: 700; color: #fff; font-size: 16px;
  margin-bottom: 28px;
  letter-spacing: 0.2px;
}
.brand .dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: linear-gradient(135deg, #38bdf8, #6366f1);
  box-shadow: 0 0 12px #38bdf899;
}
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a {
  color: #cbd5e1;
  padding: 9px 12px;
  border-radius: 8px;
  display: flex; align-items: center; gap: 10px;
  transition: background .15s ease;
  font-size: 13.5px;
}
.nav a:hover { background: #1e293b; color: #fff; }
.nav a.active { background: #1e293b; color: #fff; font-weight: 600; }
.nav .group {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: #475569;
  margin: 16px 12px 6px;
}

.main { display: flex; flex-direction: column; min-width: 0; }

.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 14px 28px;
  display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; z-index: 5;
}
.topbar h1 { font-size: 18px; margin: 0; font-weight: 600; }
.user-pill {
  display: flex; align-items: center; gap: 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 13px;
}
.user-pill .role {
  font-size: 11px; padding: 2px 8px; border-radius: 999px;
  background: #dbeafe; color: #1e40af; text-transform: uppercase; letter-spacing: .4px;
}

.content { padding: 24px 28px; }

/* ----------- Cards y KPIs ----------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
}
.card h2 { font-size: 15px; margin: 0 0 12px; font-weight: 600; }
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 14px;
}
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  margin-bottom: 22px;
}
.kpi {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 6px;
  position: relative; overflow: hidden;
}
.kpi::after {
  content: ''; position: absolute; right: -20px; top: -20px;
  width: 80px; height: 80px; border-radius: 50%;
  background: var(--kpi-color, #dbeafe); opacity: 0.18;
}
.kpi .label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .6px; }
.kpi .value { font-size: 28px; font-weight: 700; color: var(--text); }
.kpi .sub   { color: var(--muted); font-size: 12px; }

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

/* ----------- Tablas ----------- */
.table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}
table.table {
  width: 100%; border-collapse: collapse; font-size: 13.5px;
}
.table th, .table td {
  padding: 11px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.table thead th {
  background: var(--surface-2);
  font-weight: 600; color: var(--muted);
  text-transform: uppercase; font-size: 11px; letter-spacing: .5px;
  white-space: nowrap;
}
.table tbody tr:hover { background: #f8fafc; }
.table .muted { color: var(--muted); }

/* ----------- Botones ----------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 14px;
  border-radius: 8px;
  border: 1px solid transparent;
  background: var(--primary);
  color: #fff; cursor: pointer;
  font-size: 13px; font-weight: 500;
  transition: background .15s ease, transform .05s ease;
}
.btn:hover { background: var(--primary-2); }
.btn:active { transform: translateY(1px); }
.btn.secondary { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn.secondary:hover { background: var(--surface-2); }
.btn.danger { background: #dc2626; }
.btn.danger:hover { background: #b91c1c; }
.btn.ghost { background: transparent; color: var(--text); border-color: var(--border); }
.btn.sm { padding: 5px 10px; font-size: 12px; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }

/* ----------- Forms ----------- */
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
}
@media (max-width: 800px) { .form-grid { grid-template-columns: 1fr; } }
.form-row { display: flex; flex-direction: column; gap: 6px; }
.form-row.full { grid-column: 1 / -1; }
label {
  font-size: 12px; font-weight: 500; color: var(--muted);
  text-transform: uppercase; letter-spacing: .4px;
}
input[type=text], input[type=email], input[type=password],
input[type=number], input[type=date], select, textarea {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 12px;
  font-size: 13.5px;
  color: var(--text);
  width: 100%;
  font-family: inherit;
  transition: border .15s ease, box-shadow .15s ease;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .15);
}
textarea { min-height: 90px; resize: vertical; }

/* ----------- Badges, semáforos, prioridades ----------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px; border-radius: 999px;
  font-size: 11.5px; font-weight: 600;
  background: #e2e8f0; color: #1e293b;
  text-transform: none; letter-spacing: 0;
  white-space: nowrap;
}
.badge.dot::before {
  content: ''; width: 7px; height: 7px; border-radius: 50%;
  background: currentColor; display: inline-block;
}
.semaforo {
  display: inline-block; width: 12px; height: 12px; border-radius: 50%;
  box-shadow: 0 0 0 2px rgba(0,0,0,.05);
}

/* ----------- Progress bars ----------- */
.progress {
  background: #e2e8f0; border-radius: 999px;
  height: 8px; overflow: hidden; min-width: 80px;
  position: relative;
}
.progress > span {
  display: block; height: 100%;
  background: linear-gradient(90deg, #3b82f6, #06b6d4);
  border-radius: 999px;
  transition: width .35s ease;
}
.progress.lg { height: 12px; }

/* ----------- Filtros ----------- */
.filters {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 18px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 10px;
}
.filters .form-row label { font-size: 11px; }

/* ----------- Flash ----------- */
.flash {
  padding: 10px 14px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #ecfdf5; color: #065f46;
  margin-bottom: 14px;
}
.flash.error { background: #fef2f2; color: #991b1b; border-color: #fecaca; }

/* ----------- Login ----------- */
.login-page {
  min-height: 100vh;
  display: grid; place-items: center;
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
  padding: 24px;
}
.login-card {
  width: 100%; max-width: 380px;
  background: #fff;
  border-radius: 14px;
  padding: 32px;
  box-shadow: 0 20px 50px rgba(0,0,0,.25);
}
.login-card h1 {
  font-size: 22px; margin: 0 0 4px;
}
.login-card .subtitle { color: var(--muted); margin: 0 0 22px; font-size: 13px; }
.login-card .btn { width: 100%; justify-content: center; padding: 11px; }
.login-card label { margin-top: 10px; display: block; }

/* ----------- Sections ----------- */
.section { margin-top: 22px; }
.section h2 { font-size: 16px; margin: 0 0 12px; font-weight: 600; }
.section .head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 12px;
}
.empty {
  text-align: center; color: var(--muted); padding: 32px; font-style: italic;
}

/* ----------- Project header ----------- */
.project-header {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px 24px;
  display: flex; flex-direction: column; gap: 14px;
  box-shadow: var(--shadow);
}
.project-header .title { display: flex; align-items: center; gap: 12px; }
.project-header h1 { font-size: 22px; margin: 0; }
.project-meta {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 12px;
}
.project-meta .meta { display: flex; flex-direction: column; gap: 2px; }
.project-meta .meta .lbl { font-size: 11px; text-transform: uppercase; color: var(--muted); letter-spacing: .5px; }
.project-meta .meta .val { font-weight: 500; }

/* ----------- Milestone star ----------- */
.milestone-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 22px; border-radius: 50%;
  background: linear-gradient(135deg, #fbbf24, #f59e0b);
  color: #fff; font-size: 12px; box-shadow: 0 2px 6px rgba(245,158,11,.4);
}

/* ----------- Workload ----------- */
.workload-bar {
  position: relative;
  background: #e2e8f0;
  height: 14px; border-radius: 999px; overflow: hidden;
  min-width: 160px;
}
.workload-bar > span {
  display: block; height: 100%;
}
.workload-bar.ok > span        { background: linear-gradient(90deg, #34d399, #10b981); }
.workload-bar.warning > span   { background: linear-gradient(90deg, #fbbf24, #f59e0b); }
.workload-bar.over > span      { background: linear-gradient(90deg, #f87171, #ef4444); }

/* ===========================================================
   Gantt / Timeline
   =========================================================== */
.gantt-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}
.gantt-toolbar {
  padding: 10px 16px;
  display: flex; gap: 10px; align-items: center;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
}
.gantt-scroll {
  overflow-x: auto;
}
.gantt {
  position: relative;
  min-width: 1200px;
}
.gantt-row {
  display: grid;
  grid-template-columns: 260px 1fr;
  border-bottom: 1px solid var(--border);
  min-height: 40px;
}
.gantt-row.header {
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  font-size: 11px; color: var(--muted); text-transform: uppercase;
  letter-spacing: .5px; font-weight: 600;
}
.gantt-label {
  padding: 9px 14px; border-right: 1px solid var(--border);
  display: flex; flex-direction: column; gap: 2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.gantt-label.activity { padding-left: 32px; font-size: 12.5px; color: var(--muted); }
.gantt-track { position: relative; padding: 6px 0; }
.gantt-grid {
  position: absolute; inset: 0;
  display: flex;
  pointer-events: none;
}
.gantt-grid .col {
  flex: 1;
  border-right: 1px dashed #eef2f7;
}
.gantt-bar {
  position: absolute; top: 9px; height: 22px;
  background: linear-gradient(90deg, #3b82f6, #6366f1);
  border-radius: 6px;
  color: #fff; font-size: 11px;
  display: flex; align-items: center; padding: 0 8px;
  box-shadow: 0 1px 3px rgba(15,23,42,.2);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.gantt-bar.activity { height: 16px; top: 12px; opacity: 0.9; }
.gantt-bar.status-Finalizado { background: linear-gradient(90deg, #10b981, #059669); }
.gantt-bar.status-En\ riesgo  { background: linear-gradient(90deg, #ef4444, #b91c1c); }
.gantt-bar.status-En\ pausa   { background: linear-gradient(90deg, #f59e0b, #d97706); }
.gantt-bar.status-Cancelado   { background: linear-gradient(90deg, #64748b, #475569); }
.gantt-bar.status-No\ iniciado{ background: linear-gradient(90deg, #94a3b8, #64748b); }

.gantt-milestone {
  position: absolute; top: 8px;
  width: 22px; height: 22px;
  display: grid; place-items: center;
  font-size: 14px;
  color: #f59e0b;
  filter: drop-shadow(0 2px 3px rgba(245,158,11,.5));
  transform: translateX(-11px);
  z-index: 2;
}
.gantt-month-header {
  display: flex;
}
.gantt-month-header .m {
  flex: 1;
  text-align: center;
  font-size: 11px; padding: 9px 0;
  color: var(--muted); text-transform: uppercase; letter-spacing: .5px;
  border-right: 1px solid var(--border);
}

/* Risk matrix */
.risk-matrix {
  display: grid; grid-template-columns: 110px repeat(3, 1fr);
  gap: 6px;
  margin-bottom: 16px;
}
.risk-matrix .cell {
  padding: 10px; border-radius: 8px; font-size: 12px;
  background: var(--surface-2); text-align: center;
}
.risk-matrix .cell.h { background: transparent; font-weight: 600; color: var(--muted); }
.risk-matrix .cell.bajo    { background: #dcfce7; color: #166534; }
.risk-matrix .cell.medio   { background: #fef9c3; color: #854d0e; }
.risk-matrix .cell.alto    { background: #fee2e2; color: #991b1b; }
.risk-matrix .cell.critico { background: #7f1d1d; color: #fff; }

/* Mobile / responsive */
@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: relative; height: auto;
    display: flex; gap: 8px; overflow-x: auto;
    padding: 12px;
  }
  .nav { flex-direction: row; gap: 6px; }
  .nav .group { display: none; }
  .topbar { padding: 12px 16px; }
  .content { padding: 16px; }
}
