:root {
  --sidebar: #1a1a2e;
  --sidebar-hover: #2a2a4a;
  --primary: #6c63ff;
  --primary-dark: #554be8;
  --surface: #ffffff;
  --canvas: #f5f5f0;
  --border: #e8e8e4;
  --text: #1a1a1a;
  --muted: #777777;
  --danger: #dc3545;
  --success: #198754;
  --shadow: 0 8px 24px rgba(26, 26, 46, 0.06);
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body { font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; font-size: 15px; line-height: 1.5; color: var(--text); background: var(--canvas); }
a { color: inherit; }
button, input, select { font: inherit; }

.layout { display: flex; min-height: 100vh; }
.sidebar { position: fixed; inset: 0 auto 0 0; z-index: 40; width: 252px; height: 100vh; display: flex; flex-direction: column; overflow-y: auto; color: #bbb; background: var(--sidebar); }
.sidebar-brand { display: flex; align-items: center; gap: 12px; padding: 18px 20px 16px; border-bottom: 1px solid #2a2a4a; }
.brand-mark { width: 42px; height: 42px; display: grid; place-items: center; flex: 0 0 42px; overflow: hidden; border-radius: 10px; background: #fff; }
.brand-mark img { width: 100%; height: 100%; object-fit: contain; }
.brand-title { color: #fff; font-size: 17px; font-weight: 650; line-height: 1.2; }
.brand-subtitle { margin-top: 2px; color: #8298ff; font-size: 12px; }
.sidebar nav { flex: 1; padding: 10px 0; }
.nav-section { padding: 14px 20px 5px; color: #68687f; font-size: 10px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.nav-link { display: flex; align-items: center; gap: 10px; padding: 10px 20px; border-left: 3px solid transparent; color: #aaa; font-size: 14px; text-decoration: none; transition: .15s ease; }
.nav-link:hover { color: #fff; background: var(--sidebar-hover); }
.nav-link.active { color: #fff; border-left-color: var(--primary); background: var(--sidebar-hover); }
.nav-link.disabled { opacity: .65; cursor: default; }
.nav-icon { width: 17px; text-align: center; }
.sidebar-footer { padding: 14px 20px; border-top: 1px solid #2a2a4a; color: #7f7f95; font-size: 11px; }
.status-dot { display: inline-block; width: 7px; height: 7px; margin-right: 6px; border-radius: 50%; background: #31c48d; }

.main { min-width: 0; min-height: 100vh; margin-left: 252px; display: flex; flex: 1; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 25; min-height: 68px; display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 11px 28px; border-bottom: 1px solid var(--border); background: var(--surface); }
.topbar-heading { display: flex; align-items: center; gap: 12px; }
.topbar-title { font-size: 17px; font-weight: 650; }
.topbar-subtitle { margin-top: 1px; color: #999; font-size: 12px; }
.topbar-actions { display: flex; gap: 8px; }
.menu-button { display: none; padding: 5px 8px; border: 1px solid var(--border); border-radius: 7px; background: #fff; cursor: pointer; }
.content { flex: 1; padding: 24px 28px 40px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 8px 14px; border: 1px solid #ddd; border-radius: 7px; color: #333; background: #fff; font-size: 13px; text-decoration: none; cursor: pointer; transition: .15s ease; }
.btn:hover { background: #f5f5f0; }
.btn-primary { border-color: var(--primary); color: #fff; background: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); }
.btn-sm { padding: 6px 10px; font-size: 12px; }
.btn-danger { border-color: #dc3545; color: #fff; background: #dc3545; }
.btn-danger:hover { border-color: #b52a37; color: #fff; background: #b52a37; }

.notice { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 18px; padding: 12px 16px; border: 1px solid #cbd6ff; border-radius: 9px; color: #373083; background: #eef1ff; font-size: 13px; }
.notice-success { border-color: #b8e1c8; color: #146c43; background: #eaf7ee; }
.notice-error { border-color: #f1b8be; color: #8a1c27; background: #fff0f1; }
.badge { display: inline-flex; align-items: center; white-space: nowrap; padding: 3px 9px; border-radius: 999px; font-size: 11px; font-weight: 650; }
.badge-blue { color: #3d35b0; background: #dfe3ff; }
.badge-green { color: #146c43; background: #e5f5eb; }

.metrics-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 18px; }
.metric-card, .card { border: 1px solid var(--border); border-radius: 10px; background: var(--surface); box-shadow: var(--shadow); }
.metric-card { padding: 17px 20px; }
.metric-label { color: #888; font-size: 12px; }
.metric-value { margin-top: 3px; font-size: 28px; font-weight: 600; line-height: 1.25; }
.metric-value.compact { padding: 6px 0 5px; font-size: 18px; }
.metric-value.danger { color: var(--danger); }
.metric-sub { margin-top: 3px; color: #aaa; font-size: 11px; }

.dashboard-grid { display: grid; grid-template-columns: minmax(0, 1.45fr) minmax(280px, .75fr); gap: 16px; }
.card { padding: 20px 24px; }
.card-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 10px; padding-bottom: 14px; border-bottom: 1px solid #f0f0ec; }
.card-title { margin: 0; font-size: 15px; font-weight: 650; }
.card-description { margin: 3px 0 0; color: #999; font-size: 12px; }
.module-list { display: grid; }
.module-row { display: grid; grid-template-columns: 34px 1fr auto; align-items: center; gap: 10px; padding: 12px 2px; border-bottom: 1px solid #f5f5f1; }
.module-row:last-child { border-bottom: 0; }
.module-row strong { display: block; font-size: 13px; font-weight: 600; }
.module-row small { display: block; margin-top: 1px; color: #999; }
.module-icon { width: 32px; height: 32px; display: grid; place-items: center; border-radius: 8px; color: var(--primary); background: #efefff; }
.status-list { margin: 0; }
.status-list > div { display: flex; justify-content: space-between; gap: 16px; padding: 10px 0; border-bottom: 1px solid #f5f5f1; }
.status-list > div:last-child { border: 0; }
.status-list dt { color: #888; font-size: 12px; }
.status-list dd { margin: 0; font-size: 12px; font-weight: 600; text-align: right; }
.status-list a { color: var(--primary); text-decoration: none; }

.search-bar { display: flex; align-items: center; gap: 8px; margin-bottom: 16px; }
.search-bar input { min-width: 180px; flex: 1; }
.search-bar input, .search-bar select { padding: 8px 11px; border: 1px solid #ddd; border-radius: 7px; color: #333; background: #fff; font-size: 13px; }
.search-bar input:focus, .search-bar select:focus { outline: 2px solid rgba(108, 99, 255, .16); border-color: var(--primary); }
.select-search { position: relative; width: 100%; font-weight: 400; }
.select-search-input { width: 100%; min-height: 44px; padding: 10px 42px 10px 15px; border: 1px solid #d7d7d2; border-radius: 9px; color: #222; background: #fff; font-size: 14px; }
.select-search-input:focus { outline: 0; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(108, 99, 255, .14); }
.select-search-native { display: none; }
.select-search-results { position: absolute; top: calc(100% + 5px); right: 0; left: 0; z-index: 80; max-height: 326px; overflow-y: auto; padding: 6px 0; border: 1px solid #e3e3df; border-radius: 10px; background: #fff; box-shadow: 0 12px 28px rgba(26, 26, 46, .18); }
.select-search-option { display: flex; width: 100%; align-items: center; gap: 10px; padding: 10px 14px; border: 0; color: #292929; background: #fff; font-size: 13px; line-height: 1.35; text-align: left; cursor: pointer; }
.select-search-option::before { flex: 0 0 auto; color: #929292; content: "⌕"; font-size: 16px; }
.select-search-option:hover, .select-search-option:focus, .select-search-option.active { outline: 0; color: #242060; background: #f0f1ff; }
.select-search-empty { display: block; padding: 12px 15px; color: #888; font-size: 12px; font-weight: 400; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { padding: 9px 12px; border-bottom: 1px solid #f0f0ec; color: #888; font-size: 11px; font-weight: 650; letter-spacing: .04em; text-align: left; text-transform: uppercase; }
td { padding: 11px 12px; border-bottom: 1px solid #f8f8f5; font-size: 13px; }
tr:hover td { background: #fafaf7; }
.empty-row:hover td { background: transparent; }
.empty-row td { padding: 52px 20px; color: #777; text-align: center; }
.empty-row strong, .empty-row span { display: block; }
.empty-row span { margin-top: 4px; color: #aaa; font-size: 12px; }
.sidebar-backdrop { display: none; }

.report-links { margin-top: 18px; }
.print-heading { display: none; }
.detail-grid { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(300px, .85fr); gap: 16px; }
.stacked-grid { display: grid; grid-template-columns: 1fr; gap: 16px; }
.table-compact th, .table-compact td { padding: 8px 8px; }
.table-compact th { font-size: 10px; }
.table-compact td { font-size: 12.5px; }
.edit-form label { display: flex; flex-direction: column; gap: 5px; color: #666; font-size: 12px; font-weight: 600; }
.field-help { color: #999; font-size: 11px; font-weight: 400; }
.debt-summary { margin: 18px 0; padding: 16px; border: 1px solid #cbd6ff; border-radius: 10px; background: #f7f8ff; }
.debt-summary .card-header { margin-bottom: 10px; padding-bottom: 10px; }
.debt-summary-total { color: #373083; font-size: 20px; }
.debt-summary-clear { margin: 8px 0 0; color: #146c43; font-size: 13px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 13px; }
.form-grid input, .form-grid select, .form-grid textarea { width: 100%; padding: 9px 10px; border: 1px solid #ddd; border-radius: 7px; color: #333; background: #fff; font-size: 13px; font-weight: 400; }
.form-grid input:focus, .form-grid select:focus, .form-grid textarea:focus { outline: 2px solid rgba(108, 99, 255, .16); border-color: var(--primary); }
.form-grid input[readonly] { color: #888; background: #f5f5f0; }
.form-span-2 { grid-column: span 2; }
.checkbox-field { flex-direction: row !important; align-items: center; gap: 9px; min-height: 40px; }
.checkbox-field input[type="checkbox"] { width: 18px; height: 18px; flex: 0 0 18px; margin: 0; accent-color: var(--primary); }
.checkbox-field span { color: #555; font-size: 13px; font-weight: 600; }
.checkbox-list { min-width: 0; border: 1px solid #ddd; border-radius: 7px; padding: 10px 12px 11px; }
.checkbox-list legend { padding: 0 4px; color: #666; font-size: 12px; font-weight: 600; }
.checkbox-list-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px 14px; max-height: 320px; overflow-y: auto; }
.checkbox-list-item { display: flex !important; flex-direction: row !important; align-items: flex-start; gap: 7px !important; color: #444 !important; font-size: 12px !important; font-weight: 400 !important; line-height: 1.3; }
.checkbox-list-item input { width: 16px !important; min-width: 16px; margin-top: 1px; }
.checkbox-list-item strong { color: #555; }
.form-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; padding-top: 16px; border-top: 1px solid #f0f0ec; }
.vehicle-detail { padding: 13px 0; border-bottom: 1px solid #f0f0ec; }
.vehicle-detail:last-child { border-bottom: 0; }
.vehicle-detail-heading { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.vehicle-meta { margin-top: 4px; color: #888; font-size: 12px; }
.driver-list { display: grid; gap: 4px; margin-top: 9px; color: #555; font-size: 12px; }
.badge-muted { color: #666; background: #ededed; }
.payment-summary { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-top: 18px; padding: 14px 16px; border: 1px solid #99f6e4; border-radius: 8px; color: #115e59; background: #f0fdfa; }
.payment-summary-label { display: block; font-size: 12px; }
.payment-summary-total { display: block; margin-top: 2px; font-size: 22px; }
.payment-summary p { margin: 0; color: #0f766e; font-size: 12px; text-align: right; }
.config-preview { display: grid; grid-template-columns: 1fr; gap: 3px; margin-top: 18px; padding: 16px; border: 1px solid #efc4ba; border-radius: 10px; color: #71342b; background: #fff4f1; }
.config-preview-label, .config-preview-help { display: block; color: #9a6b63; font-size: 12px; }
.config-preview-value { display: block; margin-top: 1px; font-size: 24px; line-height: 1.25; }
.config-info { align-self: start; color: #666; }
.config-info p { margin: 10px 0 0; font-size: 13px; line-height: 1.6; }

@media print {
  @page { size: A4; margin: 12mm; }
  .sidebar, .topbar, .no-print { display: none !important; }
  .layout, .main { display: block; min-height: auto; margin-left: 0; }
  .content { padding: 0; }
  .card, .metric-card { border: 0; box-shadow: none; }
  .print-report { padding: 0; }
  .print-heading { display: flex; flex-direction: column; margin-bottom: 16px; color: #000; }
  .print-heading strong { font-size: 18px; }
  .print-heading span { font-size: 14px; }
  .print-heading small { margin-top: 8px; color: #555; }
  table { font-size: 10pt; }
  th, td { padding: 6px 8px; }
}

/* ---------- Tema por programa ----------
   El color principal cambia según el programa activo, para que se note de
   un vistazo en cuál de los dos se está trabajando. */
body[data-programa="remises"] {
  --primary: #0e9488;
  --primary-dark: #0b7d72;
}
body[data-programa="remises"] .brand-subtitle { color: #5fd8cc; }
body[data-programa="remises"] .module-icon { background: #e2f7f4; }
body[data-programa="remises"] .notice { border-color: #b6e6e0; color: #0b5b54; background: #e8f8f6; }
body[data-programa="remises"] .badge-blue { color: #0b5b54; background: #cfeeea; }
body[data-programa="remises"] .search-bar input:focus,
body[data-programa="remises"] .search-bar select:focus { outline-color: rgba(14, 148, 136, .18); }

.brand-initial { color: var(--primary); font-size: 20px; font-weight: 700; }
.badge-amber { color: #8a5a00; background: #fdf0d5; }

/* ---------- Botón para cambiar de programa ---------- */
.switch-program {
  display: flex; align-items: center; gap: 9px;
  margin: 12px 14px 4px; padding: 9px 12px;
  border: 1px solid #33334f; border-radius: 8px;
  color: #cfcfe4; background: #22223c;
  font-size: 12.5px; text-decoration: none;
  transition: .15s ease;
}
.switch-program:hover { color: #fff; border-color: var(--primary); background: #2a2a4a; }
.switch-icon { font-size: 14px; }

/* ---------- Pantalla de selección de programa ---------- */
.selector-body { position: relative; display: grid; place-items: center; min-height: 100vh; padding: 42px 20px 24px; background: var(--canvas); }
.selector-comuna-logo { position: absolute; top: 24px; left: 28px; width: 76px; height: 76px; display: grid; place-items: center; padding: 6px; border: 1px solid #e5e7eb; border-radius: 16px; background: #fff; box-shadow: 0 8px 22px rgba(26, 26, 46, .10); }
.selector-comuna-logo img { width: 100%; height: 100%; object-fit: contain; }
.selector { width: 100%; max-width: 1100px; }
.login-panel { width: 100%; max-width: 400px; padding: 30px 28px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); box-shadow: var(--shadow); }
.login-panel .selector-header { margin-bottom: 22px; }
.login-form { display: grid; gap: 14px; }
.login-form .login-field { display: flex; flex-direction: column; gap: 5px; }
.login-form .login-field > label { color: #666; font-size: 12px; font-weight: 600; }
.login-form input { width: 100%; padding: 10px 11px; border: 1px solid #ddd; border-radius: 7px; color: #333; background: #fff; font-size: 14px; font-weight: 400; }
.login-form input:focus { outline: 2px solid rgba(108, 99, 255, .16); border-color: var(--primary); }
.password-input { position: relative; }
.login-form .password-input input { padding-right: 46px; }
.password-toggle {
  position: absolute; top: 50%; right: 4px; transform: translateY(-50%);
  display: grid; width: 36px; height: 36px; place-items: center; padding: 0;
  border: 0; border-radius: 6px; color: #707784; background: transparent;
  cursor: pointer;
}
.password-toggle:hover { color: var(--primary); background: #f2f1ff; }
.password-toggle:focus-visible { outline: 2px solid rgba(108, 99, 255, .35); outline-offset: 1px; }
.password-eye { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.password-eye-closed { display: none; }
.password-toggle[aria-pressed="true"] .password-eye-open { display: none; }
.password-toggle[aria-pressed="true"] .password-eye-closed { display: block; }
.login-form .btn { width: 100%; }
.logout-form { display: flex; flex-direction: column; gap: 5px; margin-top: 10px; }
.logout-usuario { color: #8298ff; font-size: 11px; font-weight: 600; }
.logout-boton { padding: 6px 10px; border: 1px solid #3a3a5a; border-radius: 6px; color: #bbb; background: transparent; font-size: 11px; cursor: pointer; transition: .15s ease; }
.logout-boton:hover { color: #fff; background: var(--sidebar-hover); }
.selector-header { margin-bottom: 30px; text-align: center; }
.selector-crest {
  width: 82px; height: 82px; display: grid; place-items: center; margin: 0 auto 15px;
  border-radius: 22px; background: #fff; overflow: hidden;
  box-shadow: 0 8px 22px rgba(26, 26, 46, .12); border: 1px solid #e5e7eb;
}
.selector-crest img { width: 100%; height: 100%; object-fit: contain; }
.selector-eyebrow { margin: 0 0 4px; color: #697386; font-size: 12px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; }
.selector-header h1 { margin: 0; font-size: 30px; font-weight: 750; letter-spacing: -.02em; color: #1a1a2e; }
.selector-header p { margin: 7px 0 0; color: var(--muted); font-size: 14px; }

.selector-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; }
.selector-card {
  display: flex; flex-direction: column; padding: 24px;
  border: 1px solid var(--border); border-top: 3px solid var(--primary); border-radius: 12px;
  background: var(--surface); box-shadow: var(--shadow);
  color: inherit; text-decoration: none;
  transition: transform .16s ease, box-shadow .16s ease;
}
.selector-card:hover { transform: translateY(-3px); box-shadow: 0 14px 32px rgba(26, 26, 46, .12); }
.selector-card-remises { --primary: #0e9488; }
.selector-card-libre-multa { --primary: #a44838; }
.inline-edit { display: flex; min-width: 260px; align-items: center; gap: 6px; }
.inline-edit input { min-width: 0; flex: 1; }
.catalog-actions-heading, .catalog-actions-cell { width: 190px; text-align: right; }
.catalog-create-form { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin-bottom: 18px; }
.catalog-create-form input { min-width: 0; width: 100%; padding: 9px 11px; border: 1px solid #ddd; border-radius: 7px; color: #333; background: #fff; font-size: 13px; }
.catalog-create-form input:focus { outline: 2px solid rgba(108, 99, 255, .16); border-color: var(--primary); }
.catalog-create-form .catalog-create-name { grid-column: span 2; }
.catalog-create-form .btn { width: 100%; }
.catalog-actions { display: flex; align-items: flex-start; justify-content: flex-end; gap: 7px; }
.catalog-actions details { position: relative; }
.catalog-actions .catalog-delete { margin: 0; }
.catalog-edit { position: absolute; top: calc(100% + 6px); right: 0; z-index: 15; display: grid; width: min(360px, 75vw); padding: 10px; gap: 7px; border: 1px solid var(--border); border-radius: 8px; background: #fff; box-shadow: 0 12px 28px rgba(26, 26, 46, .16); }
.catalog-edit input, .inline-edit input { width: 100%; padding: 8px 10px; border: 1px solid #ddd; border-radius: 6px; font: inherit; }
details > summary.btn { display: inline-block; list-style: none; cursor: pointer; }
details > summary.btn::-webkit-details-marker { display: none; }
.selector-mark {
  width: 52px; height: 52px; display: grid; place-items: center; margin-bottom: 14px;
  border: 1px solid var(--border); border-radius: 12px; background: #fff; overflow: hidden;
}
.selector-mark img { width: 100%; height: 100%; object-fit: contain; }
.selector-card h2 { margin: 0 0 6px; font-size: 19px; font-weight: 650; }
.selector-card > p { margin: 0 0 14px; color: var(--muted); font-size: 13px; }
.selector-card ul { margin: 0 0 18px; padding: 0; list-style: none; }
.selector-card li { position: relative; padding: 4px 0 4px 18px; color: #555; font-size: 12.5px; }
.selector-card li::before { position: absolute; left: 0; color: var(--primary); content: "▸"; }
.selector-go { margin-top: auto; color: var(--primary); font-size: 13px; font-weight: 650; }
.selector-footer { margin-top: 24px; color: #aaa; font-size: 12px; text-align: center; }

@media (max-width: 1024px) {
  .metrics-grid { grid-template-columns: repeat(2, 1fr); }
  .dashboard-grid { grid-template-columns: 1fr; }
  .detail-grid { grid-template-columns: 1fr; }
  .content { padding-left: 22px; padding-right: 22px; }
  .catalog-create-form { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (min-width: 761px) and (max-width: 1200px) {
  body[data-programa="libre_multa"] .sidebar { width: 210px; }
  body[data-programa="libre_multa"] .main { margin-left: 210px; }
  body[data-programa="libre_multa"] .sidebar-brand { gap: 9px; padding: 15px 14px 13px; }
  body[data-programa="libre_multa"] .brand-mark { width: 36px; height: 36px; flex-basis: 36px; border-radius: 8px; }
  body[data-programa="libre_multa"] .brand-title { font-size: 15px; }
  body[data-programa="libre_multa"] .brand-subtitle { font-size: 11px; }
  body[data-programa="libre_multa"] .switch-program { margin: 9px 10px 2px; padding: 8px 10px; font-size: 12px; }
  body[data-programa="libre_multa"] .nav-section { padding: 11px 14px 4px; font-size: 9px; }
  body[data-programa="libre_multa"] .nav-link { gap: 8px; padding: 8px 14px; font-size: 13px; }
  body[data-programa="libre_multa"] .nav-icon { width: 15px; }
  body[data-programa="libre_multa"] .sidebar-footer { padding: 11px 14px; }
  body[data-programa="libre_multa"] .content { padding-left: 18px; padding-right: 18px; }
  body[data-programa="libre_multa"] .topbar { padding-left: 18px; padding-right: 18px; }
}

@media (max-width: 760px) {
  .selector-grid { grid-template-columns: 1fr; }
  .selector-header h1 { font-size: 22px; }
  .selector-comuna-logo { top: 14px; left: 14px; width: 58px; height: 58px; padding: 4px; }
}

@media (max-width: 760px) {
  body { font-size: 14px; }
    .sidebar { width: min(86vw, 280px); z-index: 30; transform: translateX(-100%); transition: transform .2s ease; }
  .sidebar-open .sidebar { transform: translateX(0); }
  .sidebar-open .sidebar-backdrop { display: block; position: fixed; inset: 0; z-index: 20; background: rgba(0, 0, 0, .38); }
  .menu-button { display: inline-flex; }
  .topbar { min-height: 60px; padding: 9px 12px; }
  .topbar-heading { min-width: 0; gap: 8px; }
  .topbar-title { overflow: hidden; font-size: 16px; text-overflow: ellipsis; white-space: nowrap; }
  .main { margin-left: 0; }
  .topbar-subtitle { display: none; }
  .content { width: 100%; padding: 14px 10px 24px; overflow-x: hidden; }
  .metrics-grid { grid-template-columns: 1fr; }
  .notice, .search-bar { align-items: stretch; flex-direction: column; }
  .payment-summary { align-items: flex-start; flex-direction: column; }
  .payment-summary p { text-align: left; }
  .card, .metric-card { padding: 14px 12px; border-radius: 9px; }
  .card-header { align-items: stretch; flex-direction: column; gap: 7px; padding-bottom: 10px; }
  .card-header > .btn, .card-header > a { align-self: stretch; }
  .card-title { font-size: 14px; }
  .card-description { font-size: 11.5px; }
  .table-wrap { margin-right: -4px; }
  th { padding: 8px 9px; font-size: 10px; }
  td { padding: 9px; font-size: 12px; }
  .form-grid { gap: 11px; }
  .form-grid input, .form-grid select, .form-grid textarea { min-height: 40px; padding: 9px 10px; font-size: 14px; }
  .form-actions { justify-content: stretch; flex-wrap: wrap; }
  .form-actions .btn { flex: 1 1 140px; }
  .inline-edit { min-width: 0; flex-wrap: wrap; }
  .inline-edit input { width: 100%; flex-basis: 100%; }
  .catalog-actions-heading, .catalog-actions-cell { width: auto; }
  .catalog-actions { justify-content: flex-start; }
  .catalog-edit { right: auto; left: 0; width: min(320px, 82vw); }
  .catalog-create-form { grid-template-columns: 1fr; }
  .catalog-create-form .catalog-create-name { grid-column: auto; }
  .config-layout { gap: 12px; }
  .config-preview { margin-top: 14px; }
  .module-row { grid-template-columns: 34px 1fr; }
  .module-row .badge { grid-column: 2; justify-self: start; }
  .form-grid { grid-template-columns: 1fr; }
  .form-span-2 { grid-column: auto; }
  .checkbox-list-grid { grid-template-columns: 1fr; }
}

@media (max-width: 420px) {
  .sidebar-brand { gap: 9px; padding: 14px 15px 12px; }
  .brand-mark { width: 36px; height: 36px; flex-basis: 36px; border-radius: 8px; }
  .brand-title { font-size: 15px; }
  .brand-subtitle { font-size: 11px; }
  .switch-program { margin: 9px 10px 2px; padding: 8px 10px; font-size: 12px; }
  .nav-link { gap: 8px; padding: 9px 14px; font-size: 13px; }
  .nav-section { padding: 11px 14px 4px; font-size: 9px; }
  .sidebar-footer { padding: 11px 14px; }
  .topbar-actions { gap: 4px; }
  .topbar-actions .btn { padding: 7px 9px; font-size: 12px; }
  .metric-value { font-size: 24px; }
}

@media (max-width: 760px) {
  body[data-programa="libre_multa"] .sidebar-brand { gap: 8px; padding: 13px 13px 11px; }
  body[data-programa="libre_multa"] .brand-mark { width: 34px; height: 34px; flex-basis: 34px; border-radius: 7px; }
  body[data-programa="libre_multa"] .brand-title { font-size: 14px; }
  body[data-programa="libre_multa"] .brand-subtitle { font-size: 10px; }
  body[data-programa="libre_multa"] .switch-program { margin: 8px 9px 1px; padding: 7px 9px; font-size: 11px; }
  body[data-programa="libre_multa"] .nav-section { padding: 9px 12px 3px; font-size: 8.5px; }
  body[data-programa="libre_multa"] .nav-link { gap: 7px; padding: 7px 12px; font-size: 12px; }
  body[data-programa="libre_multa"] .nav-icon { width: 15px; }
  body[data-programa="libre_multa"] .sidebar-footer { padding: 10px 12px; font-size: 10px; }
  body[data-programa="libre_multa"] .logout-form { gap: 4px; margin-top: 7px; }
  body[data-programa="libre_multa"] .logout-usuario,
  body[data-programa="libre_multa"] .logout-boton { font-size: 10px; }
}

/* El backend guarda todo el texto en mayúsculas (ver app/db/base.py);
   esto solo adelanta el mismo efecto visualmente mientras se escribe. */
