:root {
  --sidebar-w: 240px;
  --app-bg: #f6f8fa;
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --bg-side: #ffffff;
  --border: #e2e6ea;
  --muted: #4b5563;
  --muted-2: #6b7280;
  --brand-green: #17963a;
  --brand-blue: #263f98;
  --brand-red: #e1251b;
  --brand-yellow: #f2b718;
  --brand-purple: #843c9b;
  --ink: #111827;
  --shadow-soft: rgba(17, 24, 39, .04);
}

:root[data-bs-theme="dark"] {
  --app-bg: #0f172a;
  --surface: #111827;
  --surface-soft: #1f2937;
  --bg-side: #0b1220;
  --border: #263244;
  --muted: #cbd5e1;
  --muted-2: #94a3b8;
  --ink: #f8fafc;
  --shadow-soft: rgba(0, 0, 0, .28);
}

html, body { height: 100%; }
body { background: var(--app-bg); color: var(--ink); }
#view-root,
.card,
.table-responsive {
  min-width: 0;
}

.welcome-screen {
  position: fixed;
  inset: 0;
  z-index: 1080;
  display: grid;
  place-items: center;
  overflow: hidden;
  background: var(--surface);
  opacity: 1;
  visibility: visible;
  transition: opacity .2s ease, visibility .2s ease;
}
:root[data-bs-theme="dark"] .welcome-screen {
  background:
    radial-gradient(ellipse at center, rgba(17, 24, 39, .76) 0%, rgba(5, 9, 20, .98) 72%),
    #050914;
}
:root[data-bs-theme="dark"] .welcome-screen::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background:
    radial-gradient(ellipse at center, transparent 38%, rgba(5, 9, 20, .48) 68%, rgba(5, 9, 20, .92) 100%),
    linear-gradient(180deg, rgba(5, 9, 20, .34), transparent 34%, transparent 66%, rgba(5, 9, 20, .42));
}
.welcome-screen.is-hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}
.welcome-video {
  position: relative;
  z-index: 0;
  width: min(96vw, 1180px);
  height: min(88vh, 720px);
  object-fit: contain;
}
:root[data-bs-theme="dark"] .welcome-video {
  z-index: 0;
  opacity: .9;
  mix-blend-mode: multiply;
  filter:
    brightness(.86)
    contrast(1.12)
    saturate(1.16)
    drop-shadow(0 30px 76px rgba(0, 0, 0, .62));
  -webkit-mask-image: radial-gradient(ellipse at center, #000 50%, rgba(0, 0, 0, .74) 68%, transparent 94%);
  mask-image: radial-gradient(ellipse at center, #000 50%, rgba(0, 0, 0, .74) 68%, transparent 94%);
}
.welcome-actions {
  position: absolute;
  z-index: 2;
  right: 1.5rem;
  bottom: 1.5rem;
}
.welcome-skip {
  border: 1px solid var(--border);
  border-radius: .375rem;
  background: #ffffff;
  color: var(--ink);
  font-weight: 600;
  box-shadow: 0 10px 24px rgba(17, 24, 39, .12);
}
:root[data-bs-theme="dark"] .welcome-skip {
  background: #ffffff;
  border-color: #ffffff;
  color: #111827;
}

.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  min-height: 100vh;
}
body.sidebar-collapsed .app-shell {
  grid-template-columns: 88px minmax(0, 1fr);
}

.sidebar {
  position: relative;
  background: var(--bg-side);
  border-right: 1px solid var(--border);
  padding: 1rem 1rem 3.6rem;
  box-shadow: 8px 0 24px var(--shadow-soft);
  transition: padding .16s ease;
}

.brand-row {
  display: flex;
  align-items: center;
  gap: .45rem;
  padding-bottom: .85rem;
  border-bottom: 1px solid var(--border);
}
.sidebar .brand {
  min-width: 0;
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .45rem 0;
  color: var(--ink);
  text-decoration: none;
}
.sidebar .brand:hover { color: var(--ink); }
.sidebar .brand strong {
  font-size: 1.08rem;
  letter-spacing: 0;
}
.sidebar-toggle {
  position: absolute;
  left: 1rem;
  right: 1rem;
  bottom: 1rem;
  width: auto;
  min-width: 0;
  height: 2rem;
  display: inline-grid;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: .375rem;
  background: var(--surface);
  color: var(--muted-2);
  padding: 0;
  opacity: .72;
}
.sidebar-toggle:hover {
  background: var(--surface-soft);
  color: var(--ink);
  opacity: 1;
}
.brand-logo {
  display: block;
  width: 72px;
  height: auto;
  flex: 0 0 auto;
}
:root[data-bs-theme="dark"] .brand-logo,
:root[data-bs-theme="dark"] .login-brand img {
  padding: .2rem;
  border-radius: .375rem;
  background: #ffffff;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, .12);
}
.sidebar .nav-link { color: var(--muted); border-radius: .375rem; padding: .5rem .75rem; font-weight: 500; }
.sidebar .nav-link:hover { background: var(--surface-soft); color: var(--ink); }
.sidebar .nav-link.active { background: var(--brand-green); color: #fff; }
.sidebar .nav-link i { margin-right: .5rem; }
body.sidebar-collapsed .sidebar {
  padding-left: .65rem;
  padding-right: .65rem;
}
body.sidebar-collapsed .sidebar-toggle {
  left: 50%;
  right: auto;
  width: 2.6rem;
  min-width: 2.6rem;
  height: 2.6rem;
  transform: translateX(-50%);
}
body.sidebar-collapsed .brand-row {
  justify-content: center;
  gap: .25rem;
}
body.sidebar-collapsed .sidebar .brand {
  flex: 0 0 auto;
}
body.sidebar-collapsed .sidebar .brand strong {
  display: none;
}
body.sidebar-collapsed .brand-logo {
  width: 48px;
}
body.sidebar-collapsed .sidebar .nav-link {
  width: 2.6rem;
  min-height: 2.6rem;
  display: grid;
  place-items: center;
  margin-left: auto;
  margin-right: auto;
  padding: 0;
  overflow: hidden;
  white-space: nowrap;
  font-size: 0;
}
body.sidebar-collapsed .sidebar .nav-link i {
  margin-right: 0;
  font-size: 1.05rem;
}

.content {
  min-width: 0;
  display: flex;
  flex-direction: column;
  padding: 1.25rem 1.5rem;
  background: var(--surface);
}
#view-root {
  flex: 1 0 auto;
}
.app-footer {
  flex: 0 0 auto;
  margin-top: 1.25rem;
  padding-top: .75rem;
  color: var(--muted-2);
  text-align: center;
}
.app-footer small {
  font-size: .8125rem;
}
.app-footer a {
  color: inherit;
  text-decoration-color: color-mix(in srgb, currentColor 35%, transparent);
  text-underline-offset: .16em;
  transition: color .16s ease, text-decoration-color .16s ease;
}
.app-footer a:hover {
  color: var(--brand-green);
  text-decoration-color: currentColor;
}
:root[data-bs-theme="dark"] .app-footer a:hover {
  color: #86efac;
}
.topbar { border-bottom: 1px solid var(--border); padding-bottom: .75rem; }
.theme-toggle-btn {
  width: 2.4rem;
  min-width: 2.4rem;
  height: 2.4rem;
  display: inline-grid;
  place-items: center;
  padding: 0;
}
.theme-toggle-btn .bi {
  font-size: 1.05rem;
}
.user-menu-btn {
  min-height: 2.4rem;
  display: inline-flex;
  align-items: center;
  gap: .45rem;
  font-weight: 600;
}
.user-menu-btn .bi {
  font-size: 1.05rem;
}
.user-menu-btn span {
  max-width: 9rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.btn-primary {
  --bs-btn-bg: var(--brand-green);
  --bs-btn-border-color: var(--brand-green);
  --bs-btn-hover-bg: #117c30;
  --bs-btn-hover-border-color: #117c30;
  --bs-btn-active-bg: #0f6d2a;
  --bs-btn-active-border-color: #0f6d2a;
}

body.auth-screen {
  background: var(--surface);
}
body.auth-screen .app-shell {
  display: block;
  min-height: 100vh;
}
body.auth-screen .sidebar,
body.auth-screen .topbar {
  display: none !important;
}
body.auth-screen .content {
  min-height: 100vh;
  padding: 0;
  background:
    linear-gradient(135deg, rgba(23, 150, 58, .08), transparent 38%),
    linear-gradient(315deg, rgba(38, 63, 152, .08), transparent 42%),
    var(--surface);
}
body.auth-screen #view-root {
  display: flex;
  flex-direction: column;
}
body.auth-screen .login-page {
  flex: 1;
  min-height: 0;
}
body.auth-screen .app-footer {
  margin-top: 0;
  padding: 0 1rem 1rem;
}
.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 2rem;
}
.login-panel {
  width: min(100%, 420px);
  padding: 2rem;
  border: 1px solid var(--border);
  border-radius: .5rem;
  background: color-mix(in srgb, var(--surface) 96%, transparent);
  box-shadow: 0 24px 60px rgba(17, 24, 39, .12);
}
.login-brand {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.75rem;
  color: inherit;
  text-decoration: none;
}
.login-brand img {
  width: 104px;
  height: auto;
  flex: 0 0 auto;
}
.login-brand h1 {
  margin: 0;
  font-size: 1.45rem;
  line-height: 1.1;
  color: var(--ink);
}
.login-brand p {
  margin: .2rem 0 0;
  color: var(--muted-2);
  font-size: .95rem;
}
.login-form .form-label {
  color: var(--muted);
  font-weight: 600;
}
.login-form .form-control {
  min-height: 2.75rem;
}
.login-form .btn {
  min-height: 2.75rem;
  font-weight: 700;
}

.proyecciones-toolbar {
  padding: .55rem .65rem;
  border: 1px solid var(--border);
  border-radius: .5rem;
  background: var(--surface);
}
.proy-tabs {
  display: flex;
  gap: .5rem;
  flex-wrap: wrap;
}
.proy-filter-grid {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: .42rem;
  align-items: end;
}
.proy-field { grid-column: span 2; min-width: 0; }
.proy-field-year { grid-column: span 2; }
.proy-field-wide { grid-column: span 3; }
.proy-field-short { grid-column: span 1; }
.proy-field .form-label {
  margin-bottom: .15rem;
  font-size: .72rem;
  font-weight: 600;
  color: var(--muted);
}
.proy-field .form-control,
.proy-field .form-select {
  min-height: 1.95rem;
  padding-top: .2rem;
  padding-bottom: .2rem;
  font-size: .82rem;
}
.proy-actions {
  grid-column: span 4;
  display: flex;
  flex-wrap: wrap;
  gap: .35rem;
  align-items: end;
}
.proy-actions .btn {
  min-height: 1.95rem;
  padding: .2rem .5rem;
  font-size: .82rem;
  white-space: nowrap;
}
.proy-table-wrap {
  max-height: 58vh;
  overflow: auto;
}
.proy-table {
  table-layout: fixed;
  min-width: 2360px;
}
.proy-table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--surface-soft);
  border-bottom: 1px solid var(--border);
  font-size: .78rem;
  white-space: nowrap;
}
.proy-table td {
  white-space: nowrap;
  font-size: .82rem;
  overflow: hidden;
  text-overflow: ellipsis;
}
.proy-summary-table {
  table-layout: fixed;
  width: 100%;
}
.proy-summary-table th,
.proy-summary-table td {
  font-size: .86rem;
  padding-top: .45rem;
  padding-bottom: .45rem;
}
.proy-summary-table th:first-child,
.proy-summary-table td:first-child {
  width: 34%;
}
.proy-table th:nth-child(1), .proy-table td:nth-child(1) { width: 96px; }
.proy-table th:nth-child(2), .proy-table td:nth-child(2) { width: 92px; }
.proy-table th:nth-child(3), .proy-table td:nth-child(3) { width: 230px; }
.proy-table th:nth-child(4), .proy-table td:nth-child(4) { width: 180px; }
.proy-table th:nth-child(5), .proy-table td:nth-child(5) { width: 70px; }
.proy-table th:nth-child(6), .proy-table td:nth-child(6) { width: 70px; }
.proy-table th:nth-child(7), .proy-table td:nth-child(7) { width: 160px; }
.proy-table th:nth-child(8), .proy-table td:nth-child(8) { width: 210px; }
.proy-table th:nth-child(9), .proy-table td:nth-child(9),
.proy-table th:nth-child(n+10):nth-child(-n+22),
.proy-table td:nth-child(n+10):nth-child(-n+22) {
  width: 118px;
}
.proy-table th:nth-child(23), .proy-table td:nth-child(23) { width: 120px; }
.proy-grid-wrap {
  max-height: 68vh;
  overflow: auto;
}
.proy-grid-scroll-top {
  overflow-x: auto;
  overflow-y: hidden;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.proy-grid-scroll-top > div {
  height: 1px;
}
.proy-grid-table {
  table-layout: fixed;
  width: max-content;
  min-width: 100%;
}
.proy-grid-table thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--surface-soft);
  border-bottom: 1px solid var(--border);
  font-size: .78rem;
  white-space: nowrap;
}
.proy-grid-table td {
  white-space: nowrap;
  font-size: .82rem;
  overflow: hidden;
  text-overflow: ellipsis;
}
.proy-col-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .25rem;
  min-height: 1.5rem;
}
.proy-column-list {
  display: grid;
  gap: .35rem;
}
.proy-grid-total-row td {
  position: sticky;
  bottom: 0;
  z-index: 1;
  background: var(--surface-soft) !important;
  border-top: 2px solid var(--border);
}
.proy-grid-table th:nth-child(1), .proy-grid-table td:nth-child(1) { width: 96px; }
.proy-grid-table th:nth-child(2), .proy-grid-table td:nth-child(2) { width: 230px; }
.proy-grid-table th:nth-child(3), .proy-grid-table td:nth-child(3) { width: 92px; }
.proy-grid-table th:nth-child(4), .proy-grid-table td:nth-child(4) { width: 180px; }
.proy-grid-table th:nth-child(5), .proy-grid-table td:nth-child(5) { width: 70px; }
.proy-grid-table th:nth-child(6), .proy-grid-table td:nth-child(6) { width: 76px; }
.proy-grid-table th:nth-child(7), .proy-grid-table td:nth-child(7) { width: 160px; }
.proy-grid-table th:nth-child(8), .proy-grid-table td:nth-child(8) { width: 190px; }
.proy-grid-table th:nth-child(9), .proy-grid-table td:nth-child(9),
.proy-grid-table th:nth-child(n+10),
.proy-grid-table td:nth-child(n+10) {
  width: 118px;
}
.proy-month-cell {
  cursor: pointer;
  border-left: 3px solid transparent;
}
.proy-month-cell:hover {
  filter: brightness(.98);
  outline: 1px solid var(--brand-blue);
  outline-offset: -1px;
}
.mode-UF_PROYECTADA { background: rgba(38, 63, 152, .10) !important; border-left-color: #263f98; }
.mode-UF_FIJA { background: rgba(23, 150, 58, .12) !important; border-left-color: #17963a; }
.mode-MANUAL_UF { background: rgba(242, 183, 24, .18) !important; border-left-color: #f2b718; }
.mode-MANUAL_CLP { background: rgba(234, 88, 12, .16) !important; border-left-color: #ea580c; }
.mode-SIN_DATOS { background: rgba(148, 163, 184, .12) !important; border-left-color: #94a3b8; }
.mode-ERROR { background: rgba(225, 37, 27, .14) !important; border-left-color: #e1251b; }
.proy-month-cell.is-pending {
  box-shadow: inset 0 0 0 2px #f59e0b;
}
.proy-goal-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem;
}
.proy-goal-value {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--ink);
}
.proy-goal-bar {
  height: 1.15rem;
  overflow: hidden;
  border-radius: .375rem;
  background: var(--border);
}
.proy-goal-bar > div {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--brand-green), var(--brand-blue));
}
.proy-tooltip {
  position: absolute;
  z-index: 5;
  display: none;
  min-width: 190px;
  padding: .55rem .65rem;
  border: 1px solid var(--border);
  border-radius: .375rem;
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 12px 30px rgba(17, 24, 39, .14);
  font-size: .78rem;
  pointer-events: none;
}

@media (max-width: 1500px) {
  .proy-filter-grid {
    grid-template-columns: repeat(6, minmax(0, 1fr));
  }
  .proy-field,
  .proy-field-year,
  .proy-field-short { grid-column: span 2; }
  .proy-field-wide { grid-column: span 3; }
  .proy-actions { grid-column: span 3; }
}

@media (max-width: 992px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar {
    position: static;
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }
  .content { padding: 1rem; }
  .proy-filter-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .proy-field-wide,
  .proy-actions { grid-column: 1 / -1; }
  .proy-goal-grid { grid-template-columns: 1fr; }
}

@media (max-width: 576px) {
  .content { padding: .75rem; }
  .proyecciones-toolbar { padding: .65rem; }
  .proy-filter-grid { grid-template-columns: 1fr; }
  .proy-actions { align-items: stretch; }
  .proy-actions .btn { flex: 1 1 100%; }
  .card-header {
    align-items: stretch !important;
    flex-direction: column;
    gap: .5rem;
  }
  .dashboard-welcome,
  .dashboard-progress-head,
  .dashboard-progress-foot {
    align-items: stretch;
    flex-direction: column;
  }
  .dashboard-welcome .btn {
    width: 100%;
  }
}

.kpi-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; }
.kpi-grid.uf-summary { grid-template-columns: repeat(5, 1fr); }
@media (max-width: 992px) { .kpi-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 1200px) { .kpi-grid.uf-summary { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 992px) { .kpi-grid.uf-summary { grid-template-columns: repeat(2, 1fr); } }

.card-kpi { border: 1px solid var(--border); border-radius: .5rem; padding: 1rem; background: var(--surface); }
.card-kpi h3 { margin: .25rem 0 0; }

.dashboard-welcome {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 1rem 1.1rem;
  border: 1px solid var(--border);
  border-radius: .5rem;
  background:
    linear-gradient(90deg, color-mix(in srgb, var(--brand-green) 10%, transparent), transparent 46%),
    var(--surface);
}
.dashboard-welcome h4 {
  color: var(--ink);
  font-weight: 750;
}

.dashboard-progress {
  padding: 1rem 1.1rem;
  border: 1px solid var(--border);
  border-radius: .5rem;
  background: var(--surface);
  box-shadow: 0 14px 38px var(--shadow-soft);
}
.dashboard-progress-head,
.dashboard-progress-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
}
.dashboard-progress-head strong {
  color: var(--brand-green);
  font-size: 1.6rem;
  line-height: 1;
}
.dashboard-progress-bar {
  height: 1rem;
  margin: .85rem 0 .55rem;
  border-radius: .375rem;
  background: color-mix(in srgb, var(--border) 82%, var(--surface));
}
.dashboard-progress-bar .progress-bar {
  border-radius: inherit;
  background: linear-gradient(90deg, var(--brand-green), var(--brand-blue), var(--brand-yellow));
}
.dashboard-progress-foot {
  color: var(--muted-2);
  font-size: .9rem;
}
.dashboard-progress-foot span:last-child {
  color: var(--ink);
  font-weight: 700;
  white-space: nowrap;
}

.dashboard-kpis .card-kpi {
  position: relative;
  min-height: 7.1rem;
  overflow: hidden;
}
.dashboard-kpis .card-kpi::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: .28rem;
  background: var(--brand-green);
}
.dashboard-kpis .card-kpi h3 {
  font-size: 1.8rem;
  font-weight: 760;
  color: var(--ink);
}
.kpi-icon {
  float: right;
  width: 2.15rem;
  height: 2.15rem;
  display: grid;
  place-items: center;
  border-radius: .5rem;
  background: color-mix(in srgb, var(--brand-green) 12%, var(--surface));
  color: var(--brand-green);
}
.kpi-ready::before { background: var(--brand-green) !important; }
.kpi-pending::before { background: var(--brand-yellow) !important; }
.kpi-extra::before { background: var(--brand-purple) !important; }
.kpi-total::before { background: var(--brand-blue) !important; }
.kpi-pending .kpi-icon {
  background: color-mix(in srgb, var(--brand-yellow) 18%, var(--surface));
  color: #9a6b00;
}
.kpi-extra .kpi-icon {
  background: color-mix(in srgb, var(--brand-purple) 14%, var(--surface));
  color: var(--brand-purple);
}
.kpi-total .kpi-icon {
  background: color-mix(in srgb, var(--brand-blue) 14%, var(--surface));
  color: var(--brand-blue);
}

.dashboard-panel {
  box-shadow: 0 10px 30px var(--shadow-soft);
}
.dashboard-panel .card-header {
  background: var(--surface-soft);
  border-bottom-color: var(--border);
  font-weight: 700;
}
.dashboard-state-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: .75rem;
  padding: .45rem 0;
  border-bottom: 1px solid color-mix(in srgb, var(--border) 70%, transparent);
}
.dashboard-state-row:last-child {
  border-bottom: 0;
}
.dashboard-chart-list {
  display: grid;
  gap: .85rem;
}
.dashboard-donut-wrap {
  min-height: 18rem;
}
.dashboard-donut-layout {
  display: grid;
  grid-template-columns: minmax(12rem, 15rem) minmax(0, 1fr);
  gap: 1.25rem;
  align-items: center;
}
.dashboard-donut {
  width: min(100%, 15rem);
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  border-radius: 50%;
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--border) 60%, transparent);
}
.dashboard-donut-hole {
  width: 56%;
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  align-content: center;
  border-radius: 50%;
  background: var(--surface);
  border: 1px solid var(--border);
  text-align: center;
}
.dashboard-donut-hole strong {
  color: var(--ink);
  font-size: 1.75rem;
  line-height: 1;
}
.dashboard-donut-hole span {
  color: var(--muted-2);
  font-size: .78rem;
}
.dashboard-donut-legend {
  display: grid;
  gap: .55rem;
}
.dashboard-donut-item {
  display: grid;
  grid-template-columns: .75rem minmax(0, 1fr) auto;
  gap: .55rem;
  align-items: center;
  color: inherit;
  text-decoration: none;
  font-size: .88rem;
}
.dashboard-donut-item span:nth-child(2) {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.dashboard-donut-item strong {
  color: var(--ink);
}
.dashboard-donut-swatch {
  width: .75rem;
  height: .75rem;
  border-radius: .2rem;
}
.dashboard-bar-row {
  display: block;
  color: inherit;
  text-decoration: none;
}
.dashboard-bar-row:hover {
  color: inherit;
}
.dashboard-bar-label {
  display: flex;
  justify-content: space-between;
  gap: .75rem;
  align-items: baseline;
  margin-bottom: .3rem;
  font-size: .88rem;
}
.dashboard-bar-label span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.dashboard-bar-label strong {
  flex: 0 0 auto;
  font-size: .82rem;
  color: var(--ink);
}
.dashboard-bar-track {
  height: .75rem;
  overflow: hidden;
  border-radius: .375rem;
  background: color-mix(in srgb, var(--border) 78%, var(--surface));
}
.dashboard-bar-fill {
  height: 100%;
  border-radius: inherit;
  transition: width .2s ease;
}
.dashboard-bar-fill-1 { background: var(--brand-green); }
.dashboard-bar-fill-2 { background: var(--brand-blue); }
.dashboard-bar-fill-3 { background: var(--brand-yellow); }
.dashboard-bar-fill-4 { background: var(--brand-purple); }
.dashboard-bar-row:hover .dashboard-bar-fill {
  filter: brightness(.95);
}

:root[data-bs-theme="dark"] .dashboard-welcome {
  background:
    linear-gradient(90deg, rgba(23, 150, 58, .18), transparent 52%),
    var(--surface);
}
:root[data-bs-theme="dark"] .dashboard-progress-head strong {
  color: #4ade80;
}
:root[data-bs-theme="dark"] .kpi-icon {
  background: rgba(74, 222, 128, .12);
  color: #86efac;
}
:root[data-bs-theme="dark"] .kpi-pending .kpi-icon {
  background: rgba(242, 183, 24, .14);
  color: #facc15;
}
:root[data-bs-theme="dark"] .kpi-extra .kpi-icon {
  background: rgba(192, 132, 252, .14);
  color: #d8b4fe;
}
:root[data-bs-theme="dark"] .kpi-total .kpi-icon {
  background: rgba(96, 165, 250, .14);
  color: #93c5fd;
}
:root[data-bs-theme="dark"] .dashboard-bar-fill-3 {
  background: #facc15;
}

@media (max-width: 992px) {
  .dashboard-donut-layout {
    grid-template-columns: 1fr;
    justify-items: center;
  }
  .dashboard-donut-legend {
    width: 100%;
  }
}

.card,
.modal-content,
.dropdown-menu {
  border-color: var(--border);
}

.text-muted {
  color: var(--muted-2) !important;
}

:root[data-bs-theme="dark"] .table {
  --bs-table-color: var(--ink);
  --bs-table-bg: var(--surface);
  --bs-table-border-color: var(--border);
  --bs-table-hover-bg: rgba(148, 163, 184, .08);
}

:root[data-bs-theme="dark"] .form-control,
:root[data-bs-theme="dark"] .form-select {
  border-color: var(--border);
}

:root[data-bs-theme="dark"] .btn-outline-secondary {
  --bs-btn-color: #d1d5db;
  --bs-btn-border-color: #475569;
  --bs-btn-hover-bg: #1f2937;
  --bs-btn-hover-border-color: #64748b;
}

:root[data-bs-theme="dark"] .btn-outline-primary {
  --bs-btn-color: #93c5fd;
  --bs-btn-border-color: #3b82f6;
  --bs-btn-hover-color: #ffffff;
  --bs-btn-hover-bg: #2563eb;
  --bs-btn-hover-border-color: #2563eb;
}

.estado-chip {
  display: inline-block; padding: .15rem .5rem; border-radius: 999px;
  font-size: .75rem; font-weight: 600;
}
.estado-Borrador        { background: #e9ecef; color: #495057; }
.estado-PendienteDatos  { background: #fff3cd; color: #664d03; }
.estado-EnRevision      { background: #cfe2ff; color: #084298; }
.estado-Aprobada        { background: #d1e7dd; color: #0f5132; }
.estado-Rechazada       { background: #f8d7da; color: #842029; }
.estado-Emitida         { background: #cff4fc; color: #055160; }
.estado-Facturada       { background: #d1e7dd; color: #0f5132; }
.estado-Anulada         { background: #f8d7da; color: #842029; }
.estado-Cerrada         { background: #e2e3e5; color: #41464b; }
.estado-PENDIENTE-OC-HES { background: #fff3cd; color: #664d03; }
.estado-FACTURA-SOLICITADA { background: #cfe2ff; color: #084298; }

.resumen-table {
  table-layout: fixed;
}

.resumen-table td:first-child {
  width: 38%;
}

.resumen-table .resumen-value {
  width: 62%;
}

.resumen-table [name="monto_neto_clp_manual"] {
  width: 100%;
  min-width: 0;
}

.cal-months {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: .5rem;
}
.cal-month-btn {
  display: flex;
  justify-content: space-between;
  align-items: center;
  min-height: 2.25rem;
  overflow: hidden;
}
@media (max-width: 1200px) { .cal-months { grid-template-columns: repeat(6, minmax(0, 1fr)); } }
@media (max-width: 576px) { .cal-months { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
