:root {
  --blue: #075eae;
  --blue-dark: #063d70;
  --ink: #111c31;
  --text: #27364a;
  --muted: #617086;
  --line: #cad7e6;
  --soft-line: #e2e9f1;
  --page: #f3f6fa;
  --green: #187a46;
  --amber: #9b5d00;
  --red: #b3261e;
}

* { box-sizing: border-box; }
html, body { min-width: 0; min-height: 100%; margin: 0; overflow-x: hidden; }
body { color: var(--text); background: var(--page); font-family: Inter, "Segoe UI", Arial, sans-serif; }
button, input, select { font: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

.login-view { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-shell { width: min(920px, 100%); display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(320px, .85fr); overflow: hidden; border: 1px solid var(--line); border-radius: 8px; background: #fff; box-shadow: 0 18px 54px rgba(22, 43, 70, .12); }
.login-copy { min-width: 0; padding: 52px; background: #eaf2fa; }
.login-copy img { width: 150px; max-width: 100%; }
.login-copy h1 { margin: 32px 0 12px; color: var(--ink); font-size: 32px; }
.login-copy p { max-width: 430px; margin: 0; color: var(--muted); line-height: 1.6; }
.login-card { min-width: 0; padding: 52px 38px; }
.login-card h2 { margin: 0 0 24px; color: var(--ink); }
.login-card form, .login-card label { display: grid; }
.login-card form { gap: 18px; }
.login-card label { gap: 7px; font-weight: 700; }
.login-card input, select { min-width: 0; max-width: 100%; padding: 10px 12px; border: 1px solid #bacbe0; border-radius: 6px; background: #fff; color: var(--ink); }
.form-message { min-height: 20px; color: var(--red); }

.primary-button, .secondary-button { min-height: 38px; padding: 8px 14px; border-radius: 6px; font-weight: 750; }
.primary-button { border: 1px solid var(--blue); background: var(--blue); color: #fff; }
.secondary-button { border: 1px solid #c1d0e0; background: #fff; color: var(--blue-dark); }
.primary-button:hover, .secondary-button:hover { filter: brightness(.96); }

.topbar { min-width: 0; min-height: 68px; display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 10px 22px; border-bottom: 1px solid var(--line); background: #fff; }
.topbar-brand, .topbar-actions { min-width: 0; display: flex; align-items: center; gap: 14px; }
.topbar-brand img { width: 112px; max-width: 30vw; }
.topbar-brand span { width: 1px; height: 32px; background: var(--line); }
.topbar-brand strong { color: var(--ink); }
.session-pill { max-width: min(300px, 28vw); overflow: hidden; padding: 8px 12px; border-radius: 999px; background: #edf5fd; color: var(--blue); font-weight: 750; text-overflow: ellipsis; white-space: nowrap; }

.dashboard-shell { min-width: 0; display: grid; grid-template-columns: 220px minmax(0, 1fr); min-height: calc(100vh - 68px); }
.side-nav { min-width: 0; display: flex; flex-direction: column; gap: 22px; padding: 18px 10px; border-right: 1px solid var(--line); background: #fff; }
.side-nav nav { min-width: 0; display: grid; gap: 3px; }
.side-nav a { min-width: 0; display: grid; grid-template-columns: 30px minmax(0, 1fr); align-items: center; gap: 8px; padding: 9px 10px; border-left: 3px solid transparent; border-radius: 5px; color: var(--ink); font-size: 13px; font-weight: 650; text-decoration: none; }
.side-nav a > span { color: var(--blue-dark); font-size: 10px; font-weight: 850; }
.side-nav a.active { border-left-color: var(--blue); background: #eaf3fc; color: var(--blue); }
.side-status { margin-top: auto; display: grid; grid-template-columns: 10px 1fr; gap: 2px 8px; align-items: center; padding: 12px; border-top: 1px solid var(--soft-line); }
.side-status > span { grid-row: span 2; width: 8px; height: 8px; border-radius: 50%; background: var(--green); }
.side-status small { color: var(--muted); }
.side-status strong { color: var(--ink); font-size: 12px; }

.content-area { min-width: 0; width: 100%; max-width: 100%; padding: 24px; }
.page-heading { min-width: 0; display: flex; align-items: end; justify-content: space-between; gap: 24px; margin-bottom: 18px; }
.page-heading > div { min-width: 0; }
.eyebrow { margin: 0 0 5px; color: var(--blue); font-size: 11px; font-weight: 850; }
.page-heading h1 { margin: 0; color: var(--ink); font-size: 28px; letter-spacing: 0; }
.page-heading p:not(.eyebrow) { margin: 7px 0 0; color: var(--muted); }
.view-tabs, .executive-tabs { min-width: 0; display: flex; gap: 4px; overflow-x: auto; border-bottom: 1px solid var(--line); }
.view-tabs button, .executive-tabs button { flex: 0 0 auto; min-height: 38px; padding: 8px 14px; border: 0; border-bottom: 3px solid transparent; background: transparent; color: var(--muted); font-weight: 750; }
.view-tabs button.active, .executive-tabs button.active { border-bottom-color: var(--blue); color: var(--blue); }
.view-tabs { border: 1px solid var(--line); border-radius: 6px; background: #fff; }
.view-tabs button { border-bottom: 0; border-left: 3px solid transparent; }
.view-tabs button.active { border-left-color: var(--blue); background: #edf5fd; }

.dashboard-view, .executive-panel { min-width: 0; max-width: 100%; }
.filter-bar { min-width: 0; display: flex; flex-wrap: wrap; align-items: end; gap: 10px; margin-bottom: 14px; padding: 12px; border: 1px solid var(--line); border-radius: 7px; background: #fff; }
.filter-bar label { min-width: 150px; display: grid; flex: 1 1 180px; gap: 5px; color: var(--muted); font-size: 12px; font-weight: 700; }
.filter-bar label:first-child { flex-grow: 0; }
.executive-tabs { margin: 0 0 14px; padding: 0 4px; background: #fff; }

.metric-grid { min-width: 0; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; margin-bottom: 14px; }
.metric-card { min-width: 0; padding: 16px; border: 1px solid var(--line); border-top: 3px solid var(--blue); border-radius: 7px; background: #fff; }
.metric-card.warning { border-top-color: var(--amber); }
.metric-card.danger { border-top-color: var(--red); }
.metric-card.positive { border-top-color: var(--green); }
.metric-card small { display: block; color: var(--muted); font-weight: 650; }
.metric-card strong { display: block; margin-top: 8px; overflow-wrap: anywhere; color: var(--ink); font-size: 23px; }
.metric-card em { display: block; margin-top: 4px; color: var(--muted); font-size: 11px; font-style: normal; line-height: 1.4; }
.economic-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }

.dashboard-grid, .chart-grid { min-width: 0; display: grid; gap: 14px; }
.personal-grid, .executive-summary-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.chart-grid.two-columns { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.chart-grid.three-columns { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.panel { min-width: 0; max-width: 100%; margin-bottom: 14px; padding: 17px; border: 1px solid var(--line); border-radius: 7px; background: #fff; }
.chart-panel { min-height: 250px; }
.panel-heading { min-width: 0; display: flex; align-items: start; justify-content: space-between; gap: 16px; margin-bottom: 16px; }
.panel-heading.compact { margin-bottom: 10px; }
.panel-heading > div { min-width: 0; }
.panel-heading h2, .panel-heading h3 { margin: 0; color: var(--ink); font-size: 17px; letter-spacing: 0; }
.panel-heading h3 { font-size: 14px; }
.panel-heading p { margin: 5px 0 0; color: var(--muted); font-size: 13px; }
.section-divider { margin: 15px 0; border-top: 1px solid var(--soft-line); }
.status-badge, .info-chip, .risk-badge { flex: 0 0 auto; padding: 5px 9px; border-radius: 999px; font-size: 11px; font-weight: 800; }
.status-badge.online, .risk-badge.estable { background: #def5e8; color: var(--green); }
.status-badge.offline { background: #edf1f5; color: var(--muted); }
.info-chip, .risk-badge.atencion { background: #fff2d9; color: #844f00; }
.risk-badge.critico { background: #fde7e5; color: var(--red); }

.personal-summary { min-width: 0; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); overflow: hidden; border: 1px solid var(--soft-line); border-radius: 6px; }
.personal-summary > div { min-width: 0; padding: 13px; border-right: 1px solid var(--soft-line); }
.personal-summary > div:last-child { border-right: 0; }
.personal-summary small, .operation-grid small { display: block; color: var(--muted); font-size: 11px; }
.personal-summary strong, .operation-grid strong { display: block; margin-top: 6px; overflow-wrap: anywhere; color: var(--ink); font-size: 16px; }

.priority-list, .alert-list { display: grid; gap: 8px; }
.priority-item, .alert-item { min-width: 0; display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 11px 12px; border: 1px solid var(--soft-line); border-left: 4px solid #94a5b7; border-radius: 5px; }
.priority-item.vencida, .alert-item.critica { border-left-color: var(--red); background: #fffafa; }
.priority-item.proxima, .alert-item.alta { border-left-color: var(--amber); }
.priority-item > div, .priority-meta { min-width: 0; }
.priority-item strong, .alert-item strong { display: block; overflow-wrap: anywhere; color: var(--ink); font-size: 13px; }
.priority-item small { display: block; margin-top: 3px; color: var(--muted); font-size: 11px; }
.priority-meta { display: grid; justify-items: end; gap: 3px; }
.priority-item time, .priority-meta span { color: var(--muted); font-size: 11px; white-space: nowrap; }
.alert-item { display: block; }
.alert-item p { margin: 5px 0 0; color: var(--muted); font-size: 12px; line-height: 1.45; }

.bar-list { min-width: 0; display: grid; gap: 11px; }
.bar-row { min-width: 0; display: grid; grid-template-columns: minmax(90px, 130px) minmax(70px, 1fr) minmax(45px, auto); align-items: center; gap: 9px; font-size: 12px; }
.bar-row > span { overflow: hidden; color: var(--text); font-weight: 650; text-overflow: ellipsis; white-space: nowrap; }
.bar-track, .progress-track { height: 9px; overflow: hidden; border-radius: 999px; background: #e8eef5; }
.bar-fill, .progress-fill { height: 100%; border-radius: inherit; background: var(--blue); }
.progress-fill.technical { background: #2e9b64; }
.bar-row.warning .bar-fill { background: var(--amber); }
.bar-row strong { color: var(--ink); text-align: right; white-space: nowrap; }
.value-bars .bar-row { grid-template-columns: minmax(90px, 120px) minmax(70px, 1fr) minmax(110px, auto); }

.activity-chart { min-width: 0; min-height: 190px; display: grid; grid-template-columns: repeat(var(--bars, 14), minmax(24px, 1fr)); gap: 7px; align-items: end; overflow-x: auto; padding: 18px 4px 2px; border-top: 1px solid var(--soft-line); }
.activity-day { min-width: 24px; height: 150px; display: grid; grid-template-rows: 1fr auto; gap: 7px; align-items: end; text-align: center; }
.activity-column { height: 100%; display: flex; align-items: end; justify-content: center; }
.activity-bar { width: min(24px, 70%); min-height: 3px; border-radius: 4px 4px 1px 1px; background: var(--blue); }
.activity-day small { color: var(--muted); font-size: 10px; white-space: nowrap; }

.operation-grid { min-width: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.operation-grid > div { min-width: 0; padding: 13px; border: 1px solid var(--soft-line); border-radius: 5px; }
.operation-grid em { display: block; margin-top: 3px; color: var(--muted); font-size: 10px; font-style: normal; }
.data-note { margin: 0 0 14px; padding: 11px 13px; border-left: 3px solid var(--amber); background: #fffaf0; color: #64471b; font-size: 12px; }

.table-scroll { min-width: 0; width: 100%; max-width: 100%; overflow-x: auto; }
.data-table { width: 100%; min-width: 760px; border-collapse: collapse; font-size: 12px; }
.compact-table { min-width: 650px; }
.ranking-table { min-width: 940px; table-layout: auto; }
.executive-project-table { min-width: 1180px; }
.data-table th { padding: 9px 10px; border-bottom: 2px solid #c8d5e4; color: #526174; text-align: left; white-space: nowrap; }
.data-table td { padding: 10px; border-bottom: 1px solid var(--soft-line); vertical-align: middle; }
.data-table tbody tr:hover { background: #f8fafc; }
.current-user-row { background: #eef7ff; }
.project-name, .person-name { min-width: 0; display: grid; gap: 2px; }
.project-name strong, .person-name strong { color: var(--ink); }
.project-name small, .person-name small { color: var(--muted); }
.progress-cell { min-width: 150px; display: grid; grid-template-columns: minmax(80px, 1fr) 42px; gap: 8px; align-items: center; }
.danger-text { color: var(--red); font-weight: 800; }
.rank { color: var(--blue); font-size: 16px; font-weight: 850; }
.score { color: var(--ink); font-size: 15px; font-weight: 850; }
.online-dot { display: inline-block; width: 7px; height: 7px; margin-right: 5px; border-radius: 50%; background: var(--green); }
.method-note { margin: -4px 0 16px; padding: 12px 14px; border-left: 3px solid var(--blue); background: #f1f7fd; color: var(--text); font-size: 12px; line-height: 1.55; }
.task-progress-editor { display: flex; align-items: center; gap: 5px; color: var(--muted); font-size: 10px; }
.task-progress-editor input { width: 60px; padding: 5px; border: 1px solid var(--line); border-radius: 4px; }
.progress-status, .system-status { display: inline-flex; padding: 4px 7px; border-radius: 4px; font-size: 10px; font-weight: 800; }
.progress-status.al_dia, .progress-status.terminado, .system-status.ok { background: #e8f6ee; color: #17693d; }
.progress-status.atencion, .progress-status.sin_planificacion, .system-status.warning { background: #fff4d6; color: #825800; }
.progress-status.retrasado, .system-status.critical { background: #fde8e8; color: #9b2525; }
.system-health-summary { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.system-health-summary p { margin: 0; color: var(--muted); font-size: 12px; }
.system-service-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.system-service { padding: 14px; border: 1px solid var(--soft-line); border-left-width: 4px; border-radius: 5px; }
.system-service.ok { border-left-color: var(--green); }
.system-service.warning { border-left-color: var(--amber); }
.system-service.critical { border-left-color: var(--red); }
.system-service > div { display: flex; justify-content: space-between; gap: 8px; }
.system-service p { margin: 7px 0 0; color: var(--muted); font-size: 12px; }
.empty-state { padding: 18px; color: var(--muted); text-align: center; }
.toast { position: fixed; right: 20px; bottom: 20px; z-index: 50; max-width: min(420px, calc(100vw - 40px)); padding: 12px 16px; border-radius: 6px; background: var(--ink); color: #fff; box-shadow: 0 14px 40px rgba(20, 32, 51, .2); }
.toast.error { background: var(--red); }

@media (max-width: 1380px) {
  .metric-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .chart-grid.three-columns { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .chart-grid.three-columns > :last-child { grid-column: 1 / -1; }
  .personal-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .personal-summary > div:nth-child(2) { border-right: 0; }
  .personal-summary > div:nth-child(-n+2) { border-bottom: 1px solid var(--soft-line); }
}

@media (max-width: 1100px) {
  .dashboard-shell { grid-template-columns: 178px minmax(0, 1fr); }
  .content-area { padding: 18px; }
  .personal-grid, .executive-summary-grid { grid-template-columns: 1fr; }
  .chart-grid.two-columns, .chart-grid.three-columns { grid-template-columns: 1fr; }
  .chart-grid.three-columns > :last-child { grid-column: auto; }
}

@media (max-width: 980px) {
  .dashboard-shell { display: block; }
  .side-nav { position: relative; width: 100%; padding: 8px 12px; border-right: 0; border-bottom: 1px solid var(--line); }
  .side-nav nav { display: flex; overflow-x: auto; gap: 4px; }
  .side-nav a { flex: 0 0 auto; grid-template-columns: 24px auto; }
  .side-status { display: none; }
  .page-heading { align-items: stretch; flex-direction: column; }
  .view-tabs { align-self: start; }
}

@media (max-width: 720px) {
  .topbar { min-height: 64px; flex-wrap: wrap; padding: 10px 14px; }
  .topbar-actions { flex-wrap: wrap; justify-content: flex-end; }
  .session-pill { display: none; }
  .content-area { padding: 14px; }
  .page-heading h1 { font-size: 24px; }
  .metric-grid, .economic-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .metric-card strong { font-size: 19px; }
  .filter-bar label, .filter-bar label:first-child { flex: 1 1 100%; }
  .panel { padding: 14px; }
  .panel-heading { flex-wrap: wrap; }
  .priority-item { align-items: start; }
  .personal-summary { grid-template-columns: 1fr; }
  .personal-summary > div { border-right: 0; border-bottom: 1px solid var(--soft-line); }
  .personal-summary > div:last-child { border-bottom: 0; }
  .bar-row, .value-bars .bar-row { grid-template-columns: minmax(76px, 105px) minmax(55px, 1fr) minmax(40px, auto); }
  .operation-grid { grid-template-columns: 1fr; }
  .system-service-grid { grid-template-columns: 1fr; }
  .login-shell { grid-template-columns: 1fr; }
  .login-copy { display: none; }
  .login-card { padding: 36px 24px; }
}

@media (max-width: 440px) {
  .metric-grid, .economic-grid { grid-template-columns: 1fr; }
  .view-tabs { width: 100%; }
  .view-tabs button { flex: 1 1 50%; }
}
