/* Diseño del prototipo: negro puro y superficies neutras. */
:root {
  color-scheme: dark;
  --bg-main: #000000; --bg-card: #19191E; --bg-input: #101014;
  --bg-card-hover: #28262E; --border-color: #37343E; --border-focus: #B7A4D7;
  --text-main: #F1EFF4; --text-muted: #B3ACBC; --text-dim: #96909E;
  --color-green: #B7A4D7; --color-green-hover: #CBBBE4;
  --color-green-glow: transparent; --color-blue: #C8BDDB;
  --radius-sm: 9px; --radius-md: 13px; --radius-lg: 16px;
}
html, body { background: #000000; user-select: auto; -webkit-user-select: auto; }
button, input, select, textarea { font: inherit; }
button { touch-action: manipulation; }
button:disabled { opacity: .4; cursor: default; transform: none !important; }
button:focus-visible, summary:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 2px solid #B7A4D7; outline-offset: 3px;
}
.top-nav { background: #101014; padding: calc(16px + var(--safe-top)) max(18px, calc((100vw - 1040px) / 2)) 16px; backdrop-filter: none; }
.brand { gap: 11px; }
.brand-mark { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 12px; background: #231D2C; border: 1px solid #716184; color: #B7A4D7; font-size: 25px; font-weight: 700; flex-shrink: 0; }
.brand-title { background: none; -webkit-text-fill-color: #F1EFF4; font-size: 18px; font-weight: 700; letter-spacing: -.4px; }
.brand-subtitle { color: #AAA4B5; text-transform: none; letter-spacing: 0; font-size: 13px; font-weight: 400; }
.estado-conexion { font-size: 11px; color: #B2A2C7; white-space: nowrap; }
.estado-conexion::before { content: ''; display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: currentColor; margin-right: 5px; }
.estado-conexion.sin-conexion { color: #B7A4D7; }
.btn-nav { min-height: 40px; border-radius: 9px; padding: 8px 11px; font-size: 13px; font-weight: 500; background: #24222A; }
.btn-secondary, .btn-chip-hoy { background: #25232C; color: #DAD4DF; border: 1px solid #3D3945; }
.btn-accent { background: #261E31; border-color: #5E4F73; color: #D1C0EA; }
.app-view { padding: 22px 18px calc(32px + var(--safe-bottom)); }
.admin-container { max-width: 1040px; gap: 14px; }
.page-heading { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 10px; }
.page-heading h1 { font-size: 25px; font-weight: 730; letter-spacing: -.7px; }
.page-heading p { color: var(--text-dim); font-size: 14px; margin-top: 5px; }
.btn-main { background: #B7A4D7; border: 0; border-radius: 10px; color: #17111F; font-size: 14px; font-weight: 700; padding: 13px 16px; min-height: 44px; cursor: pointer; white-space: nowrap; }
.admin-toolbar { display: grid; grid-template-columns: 1fr auto; gap: 14px; padding: 16px; background: #19191E; }
.filtro-tipo-container { display: flex; align-items: center; gap: 12px; }
.tipo-filtro-tabs { padding: 3px; border-radius: 11px; background: #0c0c0f; }
.btn-tab-filtro { min-width: 65px; min-height: 40px; border-radius: 8px; font-size: 15px; font-weight: 650; padding: 8px 15px; color: #B1AABA; }
.btn-tab-filtro.active { background: #34313B; color: #f6f6f6; box-shadow: none; }
.selector-controls { gap: 8px; }
.btn-arrow { min-width: 40px; width: 40px; height: 42px; border-radius: 9px; background: #25232C; color: #EAE5F0; font-size: 18px; }
.periodo-picker { position: relative; display: flex; align-items: center; justify-content: center; min-height: 42px; min-width: 155px; color: #eee; font-weight: 650; font-size: 15px; cursor: pointer; text-align: center; }
.periodo-picker input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.periodo-picker:focus-within { outline: 2px solid #B7A4D7; outline-offset: 2px; border-radius: 5px; }
.periodo-picker input::-webkit-calendar-picker-indicator { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.btn-chip-hoy { padding: 8px 12px; min-height: 42px; font-size: 13px; font-weight: 400; border-radius: 9px; }
.periodo-descripcion { grid-column: 1 / -1; color: #B1AABA; font-size: 13px; order: 3; }
.toolbar-actions { justify-content: flex-end; }
.btn-toolbar { background: #25232C; color: #DAD4DF; font-weight: 500; min-height: 40px; font-size: 13px; padding: 9px 12px; }
.btn-csv { background: #28212F; color: #D1C0EA; border-color: #635477; }
.metricas-grid { grid-template-columns: 1.4fr 1fr 1fr; gap: 12px; }
.metric-card { padding: 20px; border-color: #37343E; background: #19191E; gap: 12px; box-shadow: none; }
.metric-principal { background: #211B29; border-color: #554762; }
.metric-badge { color: #B1AABA; font-size: 11px; letter-spacing: 1px; font-weight: 700; }
.metric-icon { display: none; }
.metric-value { font-size: clamp(19px, 2.4vw, 28px); font-weight: 730; line-height: 1.2; letter-spacing: -.7px; overflow-wrap: anywhere; }
.metric-principal .metric-value { color: #C8B5E8; }
.metric-semana .metric-value, .metric-secundaria .metric-value { color: #eee; }
.metric-footer { color: #B1AABA; font-size: 13px; }
.charts-grid { grid-template-columns: 1fr 1fr; gap: 14px; }
.chart-card { padding: 16px; gap: 14px; background: #19191E; }
.chart-title, .historial-title { font-size: 16px; font-weight: 500; letter-spacing: -.2px; }
.chart-subtitle, .historial-subtitle { font-size: 13px; color: #B1AABA; margin-top: 4px; }
.chart-wrapper { height: 220px; }
.distribucion-layout { display: flex; align-items: center; gap: 20px; min-height: 200px; }
.donut-wrapper { width: 36%; max-width: 160px; flex-shrink: 0; }
.donut-visual { width: 100%; aspect-ratio: 1; border-radius: 50%; position: relative; background: #34313B; }
.donut-centro { position: absolute; inset: 22%; border-radius: 50%; background: #19191E; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.donut-centro strong { font-size: 20px; line-height: 1.3; }
.donut-centro span { font-size: 11px; color: #B1AABA; }
.categorias-leyenda { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 13px; }
.leyenda-item { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.leyenda-dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.leyenda-label { min-width: 0; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.leyenda-item strong { font-size: 12px; }
.historial-section { padding: 16px; gap: 16px; }
.historial-filtros { display: grid; grid-template-columns: 1.8fr 1fr 1fr auto; gap: 8px; }
.input-buscar { min-width: 0; width: 100%; padding: 12px 14px; min-height: 44px; font-size: 14px; }
.historial-filtros .input-text { min-width: 0; font-size: 12px; padding: 10px; }
.transacciones-list { gap: 0; transition: opacity .12s; }
.transacciones-list.cargando { opacity: .4; pointer-events: none; }
.item-transaccion { width: 100%; text-align: left; background: transparent; border: 0; border-bottom: 1px solid #34313B; border-radius: 0; padding: 15px 0; gap: 10px; cursor: pointer; min-height: 76px; }
.item-transaccion:last-child { border-bottom: 0; }
.item-transaccion:hover { background: #25232C; border-color: #34313B; }
.item-info { gap: 12px; }
.item-emoji { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 11px; background: #292630; font-size: 26px; flex-shrink: 0; }
.item-categoria { font-size: 14px; font-weight: 650; }
.item-nota { font-size: 12px; color: #B1AABA; margin-top: 4px; }
.item-valores { flex-direction: column; align-items: flex-end; gap: 4px; flex-shrink: 0; }
.item-monto { font-size: 16px; font-weight: 700; color: #eee; }
.item-fecha { font-size: 11px; white-space: nowrap; color: #B1AABA; }
.paginacion { border-top: 1px solid #34313B; display: flex; align-items: center; justify-content: space-between; padding-top: 16px; gap: 12px; color: #B1AABA; font-size: 13px; }
.paginacion-info, .paginacion-info label, .paginacion-nav { display: flex; align-items: center; gap: 8px; }
.paginacion-info .input-text { width: 60px; min-height: 42px; padding: 8px; font-size: 13px; }
.paginacion-nav { flex-shrink: 0; }
.referencias-actuales { color: #B1AABA; font-size: 12px; padding: 8px 0; }
summary { cursor: pointer; min-height: 32px; padding: 6px 0; }
.referencias-actuales > div { display: flex; flex-wrap: wrap; gap: 12px; padding: 10px 0; }
.carga-container { gap: 16px; max-width: 620px; }
.monto-card { background: #19191E; border: 1px solid #34313B; box-shadow: none; padding: 22px 16px; }
.monto-card:focus-within { box-shadow: none; border-color: #9480B6; }
.label-gigante { font-size: 12px; color: #B1AABA; }
.input-monto-gigante { font-size: 44px; }
.input-monto-gigante::placeholder { color: #68636a; }
.btn-chip { min-height: 40px; background: #25232C; border-color: #3D3945; color: #ded6d0; padding: 8px 12px; font-size: 13px; }
.btn-chip-clear { color: #eba5a5; background: #261818; border-color: #513131; }
.section-title { font-size: 12px; font-weight: 600; letter-spacing: .8px; }
.categorias-grid { grid-template-columns: 1fr 1fr; gap: 9px; }
.cat-btn { border-width: 1px; border-radius: 11px; min-height: 84px; padding: 12px 8px; gap: 8px; box-shadow: none; }
.cat-btn.selected { background: #2E253B; border-color: #9480B6; box-shadow: none; }
.cat-emoji { font-size: 26px; filter: none; }
.cat-label { font-size: 13px; font-weight: 600; }
.cat-check { width: 17px; height: 17px; font-size: 10px; }
.input-fecha-gasto { min-height: 44px; background: #090a0a; border-color: #3D3945; color: #eee; font-size: 14px; }
.input-detalle, .input-text { border-color: #3D3945; background: #090a0a; font-size: 15px; min-height: 44px; }
.input-detalle:focus, .input-text:focus, .input-fecha-gasto:focus { border-color: #B7A4D7; }
.form-actions-inline .btn-secondary { padding: 10px 14px; min-height: 44px; border-radius: 9px; cursor: pointer; }
.label-detalle { font-size: 13px; font-weight: 500; }
.btn-guardar-gigante { min-height: 54px; background: #B7A4D7; color: #17111F; font-size: 16px; font-weight: 700; letter-spacing: 0; box-shadow: none; border-radius: 11px; }
.guardar-icon { font-size: 20px; }
.sound-helper { padding: 4px; }
.btn-link { font-size: 12px; color: #B1AABA; }
.ultima-carga { background: #2E253B; border: 1px solid #554762; border-radius: 10px; padding: 12px; color: #E1D5F0; font-size: 13px; overflow-wrap: anywhere; }
.modal-overlay { background: rgba(0,0,0,.8); padding: 16px; }
.modal-card { background: #19191E; max-height: calc(100dvh - 32px); }
.modal-detalle-card { max-width: 540px; }
.modal-title { font-size: 18px; font-weight: 650; }
.modal-header { flex-shrink: 0; }
.modal-footer { background: #17151B; flex-shrink: 0; }
.btn-close { min-width: 36px; min-height: 36px; }
.detalle-body { overflow-y: auto; overscroll-behavior: contain; }
.detalle-importe { font-size: 32px; color: #C8B5E8; font-weight: 700; margin-bottom: 20px; }
.detalle-datos { display: flex; flex-direction: column; gap: 5px; }
.detalle-datos dt { color: #B1AABA; font-size: 12px; margin-top: 10px; }
.detalle-datos dd { color: #eee; font-size: 15px; overflow-wrap: anywhere; }
.detalle-nota { white-space: pre-wrap; }
#formEditarGasto { display: flex; flex-direction: column; gap: 16px; }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; }
.modal-actions-dual { flex-shrink: 0; padding: 14px 16px; }
.modal-actions-dual button { min-height: 44px; font-size: 13px; }
.modal-abierto { overflow: hidden; }
.historial-cambios { border-top: 1px solid #34313B; margin-top: 12px; padding-top: 6px; color: #B1AABA; font-size: 13px; }
.cambio-item { display: flex; flex-direction: column; gap: 5px; padding: 12px 0; border-bottom: 1px solid #34313B; }
.cambio-item span { font-size: 11px; }
.cambio-item p { overflow-wrap: anywhere; white-space: pre-wrap; }
.load-error { color: #f3a6a6; font-size: 13px; padding: 8px 0; }
.presets-montos { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.presets-montos input { min-width: 0; padding: 10px 8px; }
.config-body { max-height: none; min-height: 0; }
.config-section-title { font-size: 15px; font-weight: 650; }
.pin-dots .dot { border-color: #6C6275; }
.pin-dots .dot.filled { background: #B7A4D7; border-color: #B7A4D7; box-shadow: none; }
.key-btn:active { background: #34313B; }
.toast-notification { max-width: calc(100vw - 24px); border-radius: 12px; padding: 12px 16px; }
.toast-message { font-size: 13px; }
.toast-notification.toast-info { background: #292630; border-color: #6C6275; }
@media (max-width: 740px) {
  .top-nav { padding-left: 16px; padding-right: 16px; }
  .admin-toolbar { grid-template-columns: 1fr; }
  .filtro-tipo-container { align-items: flex-start; flex-direction: column; gap: 10px; }
  .toolbar-actions { justify-content: flex-start; }
  .periodo-descripcion { order: initial; }
  .metricas-grid { grid-template-columns: 1fr 1fr; }
  .metric-principal { grid-column: 1 / -1; }
  .metric-value { font-size: 22px; }
  .charts-grid { grid-template-columns: 1fr; }
  .historial-filtros { grid-template-columns: 1fr 1fr; }
  .input-buscar { grid-column: 1 / -1; }
  .distribucion-layout { min-height: 176px; gap: 18px; }
  .donut-wrapper { max-width: 140px; }
  .item-transaccion { padding: 14px 0; }
  .paginacion { flex-wrap: wrap; }
}
@media (max-width: 480px) {
  .nav-actions { gap: 4px; flex-wrap: wrap; justify-content: flex-end; }
  .estado-conexion { width: 100%; text-align: right; font-size: 10px; order: 2; }
  .admin-nav-controls { gap: 5px; }
  .admin-nav-controls .btn-nav { padding: 7px 9px; }
  #btnVolverCarga { display: none; }
  #btnCerrarSesion .btn-icon { font-size: 14px; }
  .brand-title { font-size: 17px; }
  .brand-subtitle { font-size: 12px; }
  .app-view { padding: 20px 14px calc(24px + var(--safe-bottom)); }
  .page-heading h1 { font-size: 22px; }
  .page-heading p { font-size: 12px; }
  .page-heading .btn-main { padding: 11px 12px; font-size: 13px; }
  .admin-toolbar, .chart-card, .historial-section { padding: 14px; }
  .selector-controls { justify-content: flex-start; width: auto; max-width: 100%; gap: 7px; }
  .periodo-picker { min-width: 134px; font-size: 14px; }
  .btn-arrow { width: 36px; min-width: 36px; }
  .btn-chip-hoy { font-size: 12px; padding: 8px 9px; }
  .toolbar-actions { justify-content: flex-start; }
  .toolbar-actions .btn-toolbar { flex: initial; font-size: 12px; }
  .metric-card { padding: 18px; min-height: 128px; }
  .metric-badge { font-size: 10px; }
  .metric-footer { font-size: 12px; }
  .item-info { gap: 10px; }
  .item-emoji { width: 40px; height: 40px; font-size: 23px; border-radius: 10px; }
  .item-categoria { font-size: 12px; }
  .item-nota { font-size: 11px; }
  .item-monto { font-size: 14px; }
  .item-fecha { font-size: 10px; }
  .paginacion { font-size: 11px; }
  .paginacion-info { gap: 6px; }
  .paginacion-info .input-text { width: 53px; }
  .paginacion-nav { gap: 6px; margin-left: auto; }
  .categorias-grid { grid-template-columns: 1fr 1fr; }
  .cat-btn { flex-direction: column; justify-content: center; padding: 12px 8px; min-height: 94px; }
  .cat-label { text-align: center; font-size: 12px; }
  .modal-actions-dual { gap: 6px; }
  .modal-actions-dual button { font-size: 12px; padding: 10px 6px; }
}
@media (max-width: 350px) {
  .brand-mark { width: 32px; height: 36px; }
  .brand { gap: 6px; }
  .brand-title { font-size: 15px; }
  .page-heading { flex-wrap: wrap; }
  .selector-controls { flex-wrap: wrap; }
  .metric-card { padding: 14px; }
  .metric-value { font-size: 20px; }
  .item-emoji { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}


/* AVERNO · grafito + lavanda: overrides sobre style.css sin alterar layout ni lógica. */
:root { --color-amber: #B7A4D7; --color-purple: #9D8ABF; }
body, html { background-color: #000000; }
.top-nav { background-color: #101014; border-bottom-color: #312E37; }
.admin-toolbar, .chart-card, .historial-section, .modal-card, .monto-card, .metric-card {
  border-color: #37343E;
}
.btn-main:hover, .btn-guardar-gigante:hover { background: #CBBBE4; }
.btn-main:focus-visible, .btn-guardar-gigante:focus-visible { outline: 2px solid #E4D8F6; outline-offset: 3px; }
.btn-nav:hover, .btn-toolbar:hover, .btn-arrow:hover, .btn-chip:hover { border-color: #716184; }
.btn-tab-filtro.active { border-color: #5E4F73; }
.btn-csv:hover, .btn-accent:hover { background: #33283F; border-color: #817096; }
.input-monto-gigante, .item-monto { color: #F1EFF4; }
.simbolo-pesos { color: #B7A4D7; }
.label-gigante, .input-fecha-gasto { color: #B7A4D7; }
.categorias-grid .cat-btn.selected .cat-check { background: #B7A4D7; color: #17111F; }
.cat-btn:focus-visible, .item-transaccion:focus-visible { outline: 2px solid #B7A4D7; outline-offset: 2px; }
.btn-guardar-gigante:disabled, .btn-main:disabled { filter: saturate(.4); }
.detalle-importe, .metric-principal .metric-value { color: #C8B5E8; }
.pin-dots .dot.filled { background: #B7A4D7; border-color: #B7A4D7; }
.key-submit, .config-tag.active { background: #2A2136; color: #D1C0EA; border-color: #6E5989; }
.key-submit:active { background: #3D2E4C; }
.toast-notification:not(.toast-error):not(.toast-info) { background: #2A2236; border-color: #78638E; color: #EEE6F7; }
.btn-toggle-eye:focus-visible { outline: 2px solid #B7A4D7; }
/* El azul y verde del CSS heredado se conservan solo en su archivo de base;
   esta última capa controla todos los estados visibles, incluidos modales y PIN. */
