:root {
  --bg: #f8fafc;
  --card: #ffffff;
  --text: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --accent-light: #eff6ff;
  --green: #10b981;
  --green-light: #ecfdf5;
  --red: #ef4444;
  --red-light: #fff1f2;
  --amber: #f59e0b;
  --amber-light: #fffbeb;
  --chip: #f1f5f9;
  --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.05);
  --shadow-md: 0 4px 14px rgba(15, 23, 42, 0.06);
  --shadow-lg: 0 10px 30px rgba(15, 23, 42, 0.1);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b0f17;
    --card: #151c24;
    --text: #f1f5f9;
    --muted: #94a3b8;
    --line: #1e293b;
    --accent: #3b82f6;
    --accent-hover: #60a5fa;
    --accent-light: rgba(59, 130, 246, 0.12);
    --green: #34d399;
    --green-light: rgba(52, 211, 153, 0.12);
    --red: #f87171;
    --red-light: rgba(248, 113, 113, 0.12);
    --amber: #fbbf24;
    --amber-light: rgba(251, 191, 36, 0.12);
    --chip: #1e293b;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.2);
    --shadow-md: 0 4px 14px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.4);
  }
}

:root[data-theme="dark"] {
  --bg: #0b0f17;
  --card: #151c24;
  --text: #f1f5f9;
  --muted: #94a3b8;
  --line: #1e293b;
  --accent: #3b82f6;
  --accent-hover: #60a5fa;
  --accent-light: rgba(59, 130, 246, 0.12);
  --green: #34d399;
  --green-light: rgba(52, 211, 153, 0.12);
  --red: #f87171;
  --red-light: rgba(248, 113, 113, 0.12);
  --amber: #fbbf24;
  --amber-light: rgba(251, 191, 36, 0.12);
  --chip: #1e293b;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.2);
  --shadow-md: 0 4px 14px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.4);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

.wrap {
  max-width: 1260px;
  margin: 0 auto;
  padding: 20px 16px 60px;
}

/* Login Overlay */
.login-overlay {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 85vh;
  padding: 16px;
}

.login-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 32px 28px;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(10px);
}

.login-card h2 {
  margin-top: 0;
  margin-bottom: 6px;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text);
  text-align: center;
}

.login-card p {
  color: var(--muted);
  font-size: 0.9rem;
  text-align: center;
  margin-bottom: 24px;
}

.form-group {
  margin-bottom: 18px;
}

.form-group label {
  display: block;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  margin-bottom: 6px;
}

.password-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.password-wrapper input {
  padding-right: 44px;
}

.toggle-password {
  position: absolute;
  right: 8px;
  background: transparent;
  border: none;
  cursor: pointer;
  font-size: 1.1rem;
  padding: 6px 8px;
  border-radius: 6px;
  color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: center;
}

.toggle-password:hover {
  background: var(--chip);
}

.btn-primary {
  width: 100%;
  background: var(--accent);
  color: white;
  border: none;
  padding: 12px 16px;
  border-radius: 10px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  margin-top: 8px;
  transition: all 0.2s ease;
  box-shadow: 0 4px 12px color-mix(in srgb, var(--accent) 30%, transparent);
}

.btn-primary:hover {
  background: var(--accent-hover);
}

.btn-primary:active {
  transform: scale(0.98);
}

.login-error {
  background: var(--red-light);
  border: 1px solid var(--red);
  color: var(--red);
  padding: 12px 14px;
  border-radius: 10px;
  font-size: 0.88rem;
  margin-bottom: 18px;
  display: none;
  font-weight: 500;
}

/* Layout Principal con Menú Lateral (Sidebar) */
.app-layout {
  display: flex;
  gap: 24px;
  align-items: flex-start;
}

.app-sidebar {
  width: 260px;
  flex-shrink: 0;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  position: sticky;
  top: 20px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.2s ease;
}

.sidebar-header {
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-icon {
  font-size: 1.6rem;
  background: var(--accent-light);
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
}

.brand-text h2 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.25;
}

.brand-sub {
  font-size: 0.72rem;
  color: var(--accent);
  font-weight: 700;
  letter-spacing: 0.06em;
}

.sidebar-user {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg);
  border: 1px solid var(--line);
  padding: 10px 12px;
  border-radius: 12px;
  gap: 8px;
}

.sidebar-user .user-badge {
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text);
  font-weight: 600;
}

.sidebar-user .btn-logout {
  background: var(--red-light);
  border: 1px solid var(--red);
  color: var(--red);
  padding: 5px 10px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.78rem;
  font-weight: 700;
  transition: all 0.2s ease;
}

.sidebar-user .btn-logout:hover {
  background: var(--red);
  color: white;
}

/* Tarjeta de Reloj Digital y Hora de Ingreso */
.sidebar-clock-card {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.03);
}

.clock-live {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.clock-live strong {
  color: var(--accent);
  font-size: 0.92rem;
  font-weight: 800;
  letter-spacing: 0.02em;
}

.clock-live .clock-icon {
  display: inline-block;
  animation: pulseClock 2s infinite ease-in-out;
}

@keyframes pulseClock {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.15); opacity: 0.8; }
}

.login-timestamp {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.78rem;
  color: var(--muted);
  font-weight: 600;
  border-top: 1px dashed var(--line);
  padding-top: 6px;
  font-variant-numeric: tabular-nums;
}

.login-timestamp strong {
  color: var(--text);
  font-weight: 700;
}

/* Opciones del Menú Lateral */
.nav-section-title {
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin: 4px 0 4px 4px;
}

.sidebar-nav.tabs {
  display: flex;
  flex-direction: column;
  gap: 6px;
  overflow: visible;
  white-space: normal;
  padding-bottom: 0;
  margin-bottom: 0;
}

.sidebar-nav .tab {
  display: flex;
  align-items: center;
  width: 100%;
  text-align: left;
  padding: 11px 14px;
  font-weight: 600;
  font-size: 0.9rem;
  border-radius: 12px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  transition: all 0.2s ease;
  cursor: pointer;
}

.sidebar-nav .tab:hover {
  background: var(--chip);
  color: var(--text);
}

.sidebar-nav .tab.active {
  background: var(--accent);
  color: #ffffff;
  border-color: var(--accent);
  box-shadow: 0 4px 14px color-mix(in srgb, var(--accent) 30%, transparent);
}

.sidebar-footer {
  margin-top: 6px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.btn-sm {
  padding: 8px 12px !important;
  font-size: 0.82rem !important;
  text-align: center;
  font-weight: 600 !important;
  border-radius: 10px !important;
}

.app-main {
  flex: 1;
  min-width: 0;
}

/* Tarjetas KPI */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

#cards {
  grid-template-columns: repeat(auto-fit, minmax(200px, 320px));
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 16px 18px;
  box-shadow: var(--shadow-sm);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.card:hover {
  box-shadow: var(--shadow-md);
}

.card .l {
  font-size: 0.74rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 700;
}

.card .v {
  font-size: 1.45rem;
  font-weight: 800;
  margin-top: 6px;
  letter-spacing: -0.02em;
}

.pos { color: var(--green); }
.neg { color: var(--red); }

/* Barras y Controles */
.monthbar {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 18px;
  background: var(--card);
  border: 1px solid var(--line);
  padding: 12px 16px;
  border-radius: 16px;
  box-shadow: var(--shadow-sm);
}

/* Barra Superior Fija en la Esquina Derecha (Reloj Digital Permanente) */
.top-right-header {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  margin-bottom: 16px;
  width: 100%;
}

.digital-clock-widget {
  display: flex;
  align-items: center;
  gap: 12px;
  background: linear-gradient(135deg, #0b1329 0%, #111c38 100%);
  border: 1.5px solid rgba(56, 189, 248, 0.45);
  padding: 8px 16px;
  border-radius: 14px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3), inset 0 0 10px rgba(56, 189, 248, 0.08);
  font-family: ui-monospace, SFMono-Regular, "Cascadia Code", "Roboto Mono", Consolas, monospace;
}

.digital-clock-screen {
  display: flex;
  align-items: center;
  gap: 8px;
}

.digital-clock-icon {
  font-size: 1.15rem;
  animation: pulseClock 2s infinite ease-in-out;
}

.digital-clock-time {
  font-size: 1.2rem;
  font-weight: 800;
  color: #38bdf8;
  letter-spacing: 0.08em;
  text-shadow: 0 0 10px rgba(56, 189, 248, 0.65);
  font-variant-numeric: tabular-nums;
}

.digital-clock-ampm {
  font-size: 0.75rem;
  font-weight: 800;
  color: #7dd3fc;
  background: rgba(56, 189, 248, 0.2);
  padding: 3px 7px;
  border-radius: 6px;
  border: 1px solid rgba(56, 189, 248, 0.35);
  text-transform: uppercase;
}

.digital-login-tag {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  color: #94a3b8;
  border-left: 1px solid rgba(255, 255, 255, 0.15);
  padding-left: 14px;
  font-weight: 600;
  font-family: Inter, system-ui, sans-serif;
}

.digital-login-tag strong {
  color: #f1f5f9;
  font-family: ui-monospace, Consolas, monospace;
  font-weight: 700;
}

.monthbar label {
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--text);
}

.monthbar select {
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
  font-size: 0.92rem;
  font-weight: 600;
  min-height: 40px;
  cursor: pointer;
}

.bar {
  display: flex;
  height: 16px;
  border-radius: 8px;
  overflow: hidden;
  background: var(--chip);
  margin: 10px 0;
}

.bar div {
  height: 100%;
  transition: width 0.3s ease;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  font-size: 0.8rem;
  color: var(--muted);
  font-weight: 500;
}

.legend i {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 3px;
  margin-right: 6px;
}

.alert {
  background: var(--red-light);
  border: 1px solid var(--red);
  color: var(--red);
  padding: 12px 16px;
  border-radius: 12px;
  margin-bottom: 18px;
  font-size: 0.9rem;
  font-weight: 600;
  display: none;
}

/* Secciones de Gastos */
section {
  background: var(--card);
  border: 1.5px solid var(--line);
  border-radius: 20px;
  padding: 22px 24px;
  margin-bottom: 24px;
  box-shadow: var(--shadow-sm);
}

section header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 16px;
  gap: 10px;
  flex-wrap: wrap;
}

section h2 {
  font-size: 1.15rem;
  font-weight: 700;
  margin: 0;
  color: var(--text);
}

section .tot {
  font-weight: 800;
  font-size: 1.1rem;
}

/* Grillas, Recuadros (Cards) e Inputs de Filas */
.head, .row {
  display: grid;
  grid-template-columns: 28px 1fr 70px 90px 90px 120px 66px;
  gap: 10px;
  align-items: center;
}

.head.noc, .row.noc {
  grid-template-columns: 1fr 70px 100px 100px 66px;
}

.head {
  font-size: 0.72rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 700;
  padding: 10px 12px;
  background: var(--chip);
  border: 1px solid var(--line);
  border-radius: 12px;
  margin-bottom: 10px;
}

.row {
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--bg);
  margin-bottom: 8px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.03);
  transition: all 0.2s ease;
}

.row:hover {
  border-color: var(--accent);
  box-shadow: var(--shadow-sm);
  background: var(--card);
}

.row.done {
  background: color-mix(in srgb, var(--green) 6%, var(--card));
  border-color: color-mix(in srgb, var(--green) 35%, var(--line));
}

.row.done .nm {
  text-decoration: line-through;
  color: var(--muted);
}

/* Ingreso que depende de cobro y aún no se cobra: no suma al total */
.row.pending-income {
  border-style: dashed;
  border-color: color-mix(in srgb, var(--amber) 55%, var(--line));
  background: color-mix(in srgb, var(--amber) 5%, var(--card));
}

.row.pending-income .sb {
  color: var(--muted);
  text-decoration: line-through;
}

/* Ingresos cobrados: no tachar el nombre (es dinero recibido, no un gasto cerrado) */
.row.done[data-s="income"] .nm {
  text-decoration: none;
  color: inherit;
}

.headd, .rowd {
  display: grid;
  grid-template-columns: 28px 130px 1fr 90px 66px;
  gap: 10px;
  align-items: center;
}

.headd {
  font-size: 0.72rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 700;
  padding: 10px 12px;
  background: var(--chip);
  border: 1px solid var(--line);
  border-radius: 12px;
  margin-bottom: 10px;
}

.rowd {
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--bg);
  margin-bottom: 8px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.03);
  transition: all 0.2s ease;
}

.rowd:hover {
  border-color: var(--accent);
  box-shadow: var(--shadow-sm);
  background: var(--card);
}

input[type=text], input[type=number], input[type=date], input[type=password] {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
  font-size: 16px;
  min-height: 40px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

input[type=number] {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-light);
}

input:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.row input[readonly], .rowd input[readonly],
.row input:disabled, .rowd input:disabled {
  opacity: 0.9;
  cursor: default;
  background: var(--bg);
  color: var(--text);
  pointer-events: none;
}

.row input[type=checkbox]:disabled,
.rowd input[type=checkbox]:disabled {
  opacity: 1;
  cursor: default;
  pointer-events: none;
}

input[type=checkbox] {
  width: 20px;
  height: 20px;
  accent-color: var(--green);
  cursor: pointer;
  border-radius: 6px;
}

.sb {
  text-align: right;
  font-weight: 700;
  font-size: 0.94rem;
  font-variant-numeric: tabular-nums;
}

.row-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 2px;
}

.btn-edit-item, .btn-edit-daily {
  border: none;
  background: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.95rem;
  border-radius: 8px;
  padding: 4px 6px;
  min-height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.btn-edit-item:hover, .btn-edit-daily:hover {
  color: var(--accent);
  background: var(--accent-light);
  transform: scale(1.1);
}

.x {
  border: none;
  background: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 1.25rem;
  border-radius: 8px;
  padding: 4px 8px;
  min-height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.x:hover {
  color: var(--red);
  background: var(--red-light);
}

.add {
  margin-top: 12px;
  border: 1.5px dashed var(--line);
  background: transparent;
  color: var(--accent);
  padding: 10px 16px;
  border-radius: 12px;
  cursor: pointer;
  font: inherit;
  font-size: 0.9rem;
  font-weight: 700;
  width: 100%;
  transition: all 0.2s ease;
}

.add:hover {
  background: var(--accent-light);
  border-color: var(--accent);
}

.actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 14px;
}

.btn {
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--text);
  padding: 10px 16px;
  border-radius: 10px;
  cursor: pointer;
  font: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  transition: all 0.2s ease;
  box-shadow: var(--shadow-sm);
}

.btn:hover {
  background: var(--chip);
}

.btn:active {
  transform: scale(0.98);
}

.prog {
  font-size: 0.82rem;
  color: var(--muted);
  font-weight: 500;
}

.net {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg);
  margin-bottom: 6px;
  font-size: 0.92rem;
  transition: all 0.2s ease;
}

.net:hover {
  background: var(--card);
  border-color: var(--accent);
}

/* Tablas General y Ledger */
table.gt {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.88rem;
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
  background: var(--card);
}

table.gt th {
  font-size: 0.72rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  text-align: right;
  padding: 12px 14px;
  font-weight: 700;
  background: var(--chip);
  border-bottom: 1px solid var(--line);
}

table.gt td {
  padding: 12px 14px;
  text-align: right;
  border-top: 1px solid var(--line);
  font-variant-numeric: tabular-nums;
  background: var(--bg);
}

table.gt th:first-child, table.gt td:first-child {
  text-align: left;
}

table.gt tfoot td {
  font-weight: 800;
  border-top: 2px solid var(--line);
}

table.ledger td:nth-child(2), table.ledger td:nth-child(4) {
  text-align: left;
  font-variant-numeric: normal;
}

table.ledger tr.ledger-day {
  background: var(--accent-light);
}

table.ledger tr.ledger-day td {
  font-weight: 700;
  color: var(--accent);
}

h3.gt-title {
  margin: 20px 0 10px;
  font-size: 1rem;
  font-weight: 700;
}

/* Modal Rápido de Registro de Gasto Diario */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(15, 23, 42, 0.65);
  backdrop-filter: blur(8px);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
  padding: 16px;
}

.modal-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 28px 24px;
  width: 100%;
  max-width: 440px;
  box-shadow: var(--shadow-lg);
  animation: modalIn 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modalIn {
  from { opacity: 0; transform: translateY(12px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.modal-header h3 {
  margin: 0;
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text);
}

/* Adaptabilidad Responsiva para Tablets y Dispositivos Móviles (< 850px) */
@media (max-width: 850px) {
  .wrap {
    padding: 12px 10px 40px;
  }

  .app-layout {
    flex-direction: column;
    gap: 16px;
  }

  .app-sidebar {
    width: 100%;
    position: relative;
    top: 0;
    padding: 16px;
    gap: 14px;
    border-radius: 16px;
  }

  .sidebar-user {
    flex-wrap: wrap;
    gap: 8px;
  }

  .sidebar-nav.tabs {
    flex-direction: row;
    overflow-x: auto;
    white-space: nowrap;
    padding-bottom: 8px;
    gap: 8px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
  }

  .sidebar-nav .tab {
    width: auto;
    flex: 0 0 auto;
    padding: 10px 14px;
    font-size: 0.88rem;
    border: 1px solid var(--line);
    background: var(--card);
    border-radius: 10px;
  }

  .sidebar-footer {
    flex-direction: row;
    align-items: center;
    gap: 8px;
  }

  .sidebar-footer .btn-sm {
    flex: 1;
  }

  .top-right-header {
    justify-content: center;
    width: 100%;
    margin-bottom: 14px;
  }

  .digital-clock-widget {
    width: 100%;
    justify-content: space-between;
    padding: 8px 12px;
  }

  .monthbar {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    padding: 14px;
  }

  .monthbar select, .monthbar button {
    width: 100%;
  }

  .cards {
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 10px;
  }

  .card {
    padding: 14px 12px;
  }

  .card .v {
    font-size: 1.25rem;
  }

  /* Filas de Detalle Mensual en Vista Móvil/Tablet */
  .head {
    display: none;
  }

  .row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    padding: 12px 14px;
    background: var(--card);
    border-radius: 14px;
    border: 1px solid var(--line);
    margin-bottom: 10px;
  }

  .row .pd { order: 1; }
  .row .nm { order: 2; flex: 1 1 calc(100% - 90px); font-weight: 600; }
  .row .row-actions { order: 3; margin-left: auto; }
  .row .qt { order: 4; flex: 1 1 25%; }
  .row .am { order: 5; flex: 1 1 30%; }
  .row .sb { order: 6; flex: 1 1 35%; text-align: right; }
  .row .pdate { order: 7; flex: 1 1 100%; }

  /* Filas de Gastos Diarios en Vista Móvil/Tablet */
  .headd {
    display: none;
  }

  .rowd {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    background: var(--card);
    padding: 12px 14px;
    border-radius: 14px;
    border: 1px solid var(--line);
    margin-bottom: 10px;
  }

  .rowd .dp { order: 1; }
  .rowd .dn { order: 2; flex: 1 1 calc(100% - 90px); font-weight: 600; }
  .rowd .row-actions { order: 3; margin-left: auto; }
  .rowd .dd { order: 4; flex: 1 1 45%; }
  .rowd .da { order: 5; flex: 1 1 45%; }

  .actions {
    flex-direction: column;
  }

  .actions .btn {
    width: 100%;
    text-align: center;
  }

  section {
    padding: 16px;
    border-radius: 16px;
  }
}

/* Ajustes Especiales para Pantallas de Celulares Pequeños (< 480px) */
@media (max-width: 480px) {
  .login-card {
    padding: 24px 18px;
    border-radius: 16px;
  }

  .digital-clock-widget {
    flex-direction: column;
    align-items: center;
    gap: 6px;
    text-align: center;
  }

  .digital-login-tag {
    border-left: none;
    padding-left: 0;
    border-top: 1px dashed rgba(255, 255, 255, 0.15);
    padding-top: 4px;
    width: 100%;
    justify-content: center;
  }

  .cards, #cards {
    grid-template-columns: 1fr;
  }

  .modal-card {
    padding: 20px 16px;
    border-radius: 18px;
    max-width: 95%;
  }

  .btn-primary, .btn {
    min-height: 44px;
  }
}

/* Seguridad: CAPTCHA y verificación en dos pasos */
.captcha-box {
  display: flex;
  justify-content: center;
  margin: 4px 0 8px;
  min-height: 65px;
}

.btn-block {
  width: 100%;
  margin-top: 10px;
}

.btn-danger {
  background: var(--red);
  box-shadow: 0 4px 12px color-mix(in srgb, var(--red) 30%, transparent);
}

.btn-danger:hover {
  background: var(--red);
  filter: brightness(0.92);
}

.twofa-qr {
  display: flex;
  justify-content: center;
  align-items: center;
  width: fit-content;
  min-width: 192px;
  min-height: 192px;
  margin: 10px auto 14px;
  padding: 12px;
  background: #ffffff;
  border-radius: 12px;
  border: 1px solid var(--line);
}

.twofa-qr img,
.twofa-qr canvas {
  display: block;
}

.twofa-secret {
  display: block;
  margin: 6px 0 16px;
  padding: 10px 12px;
  background: var(--chip);
  border-radius: 8px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.95rem;
  letter-spacing: 0.08em;
  word-break: break-all;
  user-select: all;
}
