:root {
  --ink: #17363c;
  --ink-soft: #5f7377;
  --line: #dfe8e7;
  --mist: #f4f8f7;
  --paper: #ffffff;
  --teal: #08737b;
  --teal-dark: #07575f;
  --teal-pale: #e4f4f2;
  --blue-pale: #e7f0fa;
  --amber: #b56f0c;
  --amber-pale: #fff4dc;
  --coral: #b74b3c;
  --coral-pale: #fcedea;
  --shadow: 0 12px 36px rgba(29, 66, 68, .08);
  --radius: 16px;
  font-family: "DM Sans", ui-sans-serif, system-ui, sans-serif;
  color: var(--ink);
  background: var(--mist);
}

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--mist); }
body { margin: 0; min-height: 100vh; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 3px solid rgba(8, 115, 123, .22); outline-offset: 2px; }

.app-shell { display: flex; min-height: 100vh; }
.sidebar { width: 264px; min-height: 100vh; background: #103d42; color: #e8f5f3; display: flex; flex-direction: column; padding: 28px 16px 18px; position: fixed; inset: 0 auto 0 0; z-index: 30; }
.brand { color: #fff; text-decoration: none; display: flex; align-items: center; gap: 11px; padding: 0 10px; letter-spacing: -.5px; }
.brand-mark { display: grid; place-items: center; width: 35px; height: 35px; border-radius: 12px 12px 12px 4px; background: #57c6c5; color: #103d42; font-family: Georgia, serif; font-weight: 700; font-size: 27px; line-height: 1; transform: rotate(-22deg); }
.brand strong, .brand em { display: block; font-family: Fraunces, Georgia, serif; font-size: 23px; font-style: normal; line-height: .8; }
.brand em { font-family: "DM Sans", sans-serif; font-size: 10px; letter-spacing: 2.2px; color: #a8ceca; margin-top: 8px; padding-left: 1px; }
.municipality { color: #a8ceca; font-size: 11px; letter-spacing: .2px; margin: 34px 10px 20px; display: flex; align-items: center; gap: 8px; }
.pulse { width: 7px; height: 7px; border-radius: 50%; background: #64d2c7; box-shadow: 0 0 0 4px rgba(100, 210, 199, .13); }
.nav-list { display: grid; gap: 5px; }
.nav-item { width: 100%; border: 0; background: transparent; color: #c0d9d7; text-align: left; padding: 12px 12px; border-radius: 9px; font-size: 14px; font-weight: 500; transition: background .2s, color .2s; }
.nav-item span { display: inline-grid; width: 23px; font-size: 17px; vertical-align: -1px; color: #91bcb7; }
.nav-item:hover { background: rgba(255,255,255,.07); color: #fff; }
.nav-item.active { background: #1d5d62; color: #fff; font-weight: 600; }
.nav-item.active span { color: #74ddd4; }
.sidebar-bottom { margin-top: auto; padding: 17px 10px 0; border-top: 1px solid rgba(255,255,255,.12); }
.current-user { display: flex; align-items: center; gap: 9px; width: 100%; padding: 0; border: 0; background: transparent; color: inherit; text-align: left; }
.current-user:hover strong { color: #fff; }
.avatar { width: 30px; height: 30px; display: grid; place-items: center; border-radius: 50%; font-size: 10px; font-weight: 700; color: #13454a; background: #b9e3de; }
.current-user strong, .current-user small { display: block; font-size: 11px; }
.current-user small { color: #9fc0bd; margin-top: 2px; }
.sidebar-bottom p { color: #83aaa7; font-size: 10px; margin: 15px 0 0; }
.session-link { margin: 10px 0 -3px 39px; padding: 0; border: 0; background: transparent; color: #a8ceca; font-size: 10px; text-decoration: underline; }

.main-content { margin-left: 264px; flex: 1; min-width: 0; }
.topbar { height: 92px; display: flex; align-items: center; justify-content: space-between; padding: 0 clamp(24px, 4vw, 58px); background: rgba(255,255,255,.72); border-bottom: 1px solid var(--line); }
.breadcrumb span { color: var(--teal); font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 1.4px; }
.breadcrumb h1 { margin: 3px 0 0; font: 600 22px/1 Fraunces, Georgia, serif; letter-spacing: -.4px; }
.topbar-actions { display: flex; align-items: center; gap: 14px; color: var(--ink-soft); font-size: 12px; }
.topbar-actions time { white-space: nowrap; }
.icon-button, .menu-toggle, .close-button { width: 34px; height: 34px; border-radius: 50%; border: 1px solid var(--line); background: #fff; color: var(--teal); font-weight: 700; }
.menu-toggle { display: none; border: 0; font-size: 20px; background: transparent; }

.view { display: none; padding: 38px clamp(24px, 4vw, 58px) 60px; max-width: 1600px; margin: auto; }
.view.active { display: block; animation: appear .18s ease-out; }
@keyframes appear { from { opacity: .5; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.overline { color: var(--teal); margin: 0 0 7px; font-size: 10px; text-transform: uppercase; letter-spacing: 1.5px; font-weight: 700; }
.dashboard-intro { display: flex; justify-content: space-between; align-items: flex-end; gap: 20px; margin-bottom: 25px; }
.dashboard-intro h2, .view-heading h2, .panel-heading h2 { margin: 0; font: 600 29px/1.1 Fraunces, Georgia, serif; letter-spacing: -.7px; }
.dashboard-intro > div > p:last-child, .view-heading > div > p:last-child { color: var(--ink-soft); margin: 8px 0 0; font-size: 14px; }
.period-control { display: flex; gap: 9px; align-items: center; white-space: nowrap; color: var(--ink-soft); font-size: 12px; }
.period-control select { padding: 9px 27px 9px 10px; }

.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 15px; }
.metric-card { background: var(--paper); padding: 19px; border: 1px solid var(--line); border-radius: var(--radius); min-height: 134px; display: flex; gap: 13px; box-shadow: 0 3px 10px rgba(27, 67, 67, .025); }
.metric-icon { flex: 0 0 34px; height: 34px; display: grid; place-items: center; border-radius: 10px; background: var(--teal-pale); color: var(--teal); font-size: 19px; font-weight: 700; }
.metric-card.blue .metric-icon { background: var(--blue-pale); color: #356ea9; }
.metric-card.amber .metric-icon { background: var(--amber-pale); color: var(--amber); }
.metric-card.coral .metric-icon { background: var(--coral-pale); color: var(--coral); }
.metric-card p { color: var(--ink-soft); font-size: 12px; margin: 1px 0 6px; }
.metric-card strong { display: block; font-size: 21px; line-height: 1; letter-spacing: -.7px; }
.metric-card small { color: #829396; font-size: 10px; display: block; margin-top: 8px; }
.dashboard-grid { display: grid; grid-template-columns: 1.25fr .9fr; gap: 16px; margin-top: 17px; }
.panel { background: var(--paper); border-radius: var(--radius); border: 1px solid var(--line); box-shadow: 0 3px 10px rgba(27, 67, 67, .025); }
.payments-panel, .attention-panel { min-height: 343px; padding: 22px; }
.panel-heading { display: flex; justify-content: space-between; gap: 15px; align-items: flex-start; margin-bottom: 17px; }
.panel-heading h2 { font-size: 19px; letter-spacing: -.4px; }
.text-button { border: 0; background: transparent; color: var(--teal); font-size: 12px; font-weight: 700; padding: 5px 0; white-space: nowrap; }
.text-button span { font-size: 16px; margin-left: 2px; }
.payment-row { display: grid; grid-template-columns: 31px 1fr auto; align-items: center; gap: 10px; padding: 12px 0; border-top: 1px solid #edf2f1; }
.payment-row:first-child { border-top: 0; }
.payment-method { width: 29px; height: 29px; border-radius: 9px; display: grid; place-items: center; background: var(--teal-pale); font-size: 14px; color: var(--teal); }
.payment-row strong, .payment-row small { display: block; }
.payment-row strong { font-size: 12px; font-weight: 600; }
.payment-row small { color: #7c9092; font-size: 10px; margin-top: 3px; }
.payment-row .amount { text-align: right; color: var(--teal-dark); font-size: 13px; font-weight: 700; }
.payment-row .amount small { font-weight: 400; }
.attention-list { display: grid; gap: 8px; }
.attention-item { border: 1px solid #f0e8dc; border-radius: 10px; padding: 11px 12px; display: grid; grid-template-columns: 1fr auto; gap: 10px; }
.attention-item strong { font-size: 12px; display: block; }
.attention-item small { color: #7d8e90; font-size: 10px; margin-top: 4px; display: block; }
.attention-item .balance { color: var(--coral); font-size: 12px; font-weight: 700; align-self: center; }
.soft-badge, .status-badge { display: inline-flex; align-items: center; justify-content: center; width: fit-content; font-weight: 700; font-size: 10px; letter-spacing: .2px; border-radius: 999px; padding: 5px 9px; }
.soft-badge.warning { color: #966000; background: var(--amber-pale); }

.view-heading { display: flex; justify-content: space-between; gap: 22px; align-items: flex-end; margin-bottom: 24px; }
.view-heading h2 { font-size: 30px; }
.primary-button, .secondary-button { min-height: 39px; border-radius: 9px; padding: 0 15px; border: 1px solid transparent; font-size: 12px; font-weight: 700; transition: transform .15s, background .15s; white-space: nowrap; }
.primary-button { background: var(--teal); color: white; box-shadow: 0 5px 12px rgba(8,115,123,.18); }
.primary-button:hover { background: var(--teal-dark); transform: translateY(-1px); }
.primary-button span { font-size: 17px; vertical-align: -1px; margin-right: 2px; }
.secondary-button { background: #fff; color: var(--ink-soft); border-color: #ccd9d8; }
.secondary-button:hover { background: var(--mist); }
.toolbar { min-height: 65px; display: flex; align-items: center; gap: 11px; margin-bottom: 14px; padding: 11px 13px; background: #edf4f3; border-radius: 12px; }
.toolbar-wide .search-field { max-width: 350px; }
.search-field { background: #fff; border: 1px solid #d4e0df; border-radius: 8px; min-height: 36px; display: flex; align-items: center; gap: 7px; padding: 0 10px; flex: 1; max-width: 420px; color: #759092; }
.search-field span { font-size: 18px; transform: rotate(-15deg); }
.search-field input { color: var(--ink); border: 0; outline: 0; width: 100%; background: transparent; font-size: 12px; }
.search-field input::placeholder { color: #94a7a7; }
.select-field { color: var(--ink-soft); font-size: 11px; font-weight: 700; display: flex; align-items: center; gap: 7px; white-space: nowrap; }
select, input, textarea { border: 1px solid #cedddc; border-radius: 8px; background: #fff; color: var(--ink); }
select { padding: 8px 25px 8px 9px; font-size: 12px; }
.result-count { margin-left: auto; color: #718486; font-size: 11px; white-space: nowrap; }
.table-panel { overflow: hidden; }
.account-history { padding: 22px; margin-top: 18px; }
.account-history .panel-heading { margin-bottom: 15px; }
.account-history .table-wrap { margin: 0 -22px -22px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 820px; }
th { background: #f8fbfa; color: #718688; text-transform: uppercase; letter-spacing: .75px; font-size: 9px; font-weight: 700; padding: 12px 17px; text-align: left; border-bottom: 1px solid var(--line); }
td { padding: 14px 17px; border-bottom: 1px solid #edf2f1; font-size: 12px; vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fbfdfd; }
.main-cell strong, .main-cell small { display: block; }
.main-cell strong { font-weight: 700; color: var(--ink); }
.main-cell small { color: #799093; font-size: 10px; margin-top: 4px; }
.muted-cell { color: #6b8184; font-size: 11px; }
.money-cell { font-weight: 700; white-space: nowrap; }
.amount-due { color: var(--coral); }
.status-badge { text-transform: capitalize; }
.status-ACTIVO, .status-PAGADO { color: #177368; background: #e4f5ef; }
.status-INACTIVO { color: #687b7d; background: #edf1f1; }
.status-SUSPENDIDO, .status-PARCIAL { color: #9d680b; background: #fff4dd; }
.status-BAJA { color: #687b7d; background: #edf1f1; }
.status-PENDIENTE { color: #57778c; background: #eaf2f7; }
.status-VENCIDO { color: #ad473b; background: #fcedea; }
.row-action { color: var(--teal); border: 0; background: transparent; font-size: 11px; font-weight: 700; padding: 7px 4px; }
.row-action + .row-action { margin-left: 8px; }
.empty-state { text-align: center; padding: 52px 20px; }
.empty-state span { display: grid; place-items: center; margin: 0 auto 10px; width: 38px; height: 38px; border-radius: 13px; background: var(--teal-pale); color: var(--teal); font-size: 22px; }
.empty-state h3 { margin: 0; font: 600 18px Fraunces, Georgia, serif; }
.empty-state p { color: var(--ink-soft); font-size: 12px; margin: 7px 0 0; }
.hidden { display: none !important; }

.audit-lock { border: 1px solid #c4dedb; color: var(--teal); background: var(--teal-pale); padding: 8px 10px; border-radius: 8px; font-size: 11px; font-weight: 700; white-space: nowrap; }
.audit-panel { padding: 0 20px; }
.audit-entry { display: grid; grid-template-columns: 35px minmax(140px, .65fr) minmax(250px, 2fr) minmax(130px, .6fr) auto; align-items: center; gap: 15px; padding: 16px 0; border-bottom: 1px solid #e9efee; }
.audit-entry:last-child { border-bottom: 0; }
.audit-icon { width: 33px; height: 33px; border-radius: 10px; display: grid; place-items: center; background: var(--teal-pale); color: var(--teal); font-size: 15px; }
.audit-icon.payment { background: var(--blue-pale); color: #376fa4; }
.audit-icon.edit { background: var(--amber-pale); color: var(--amber); }
.audit-action strong, .audit-action small, .audit-subject strong, .audit-subject small { display: block; }
.audit-action strong, .audit-subject strong { font-size: 11px; }
.audit-action small, .audit-subject small { color: #819394; font-size: 10px; margin-top: 3px; }
.audit-summary { color: #4d666a; font-size: 12px; line-height: 1.45; }
.audit-date { color: #6c8284; text-align: right; font-size: 10px; white-space: nowrap; }

.modal-backdrop { position: fixed; inset: 0; z-index: 50; background: rgba(13, 38, 41, .48); backdrop-filter: blur(2px); }
.modal { position: fixed; z-index: 60; width: min(680px, calc(100vw - 32px)); max-height: calc(100vh - 32px); overflow-y: auto; left: 50%; top: 50%; transform: translate(-50%, -50%); background: #fff; border-radius: 18px; box-shadow: 0 24px 80px rgba(7, 33, 36, .25); padding: 24px; }
.small-modal { width: min(440px, calc(100vw - 32px)); }
.details-modal { width: min(760px, calc(100vw - 32px)); }
.modal-header { display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; padding-bottom: 18px; border-bottom: 1px solid var(--line); margin-bottom: 19px; }
.modal-header h2 { font: 600 23px Fraunces, Georgia, serif; letter-spacing: -.4px; margin: 0; }
.close-button { font-size: 23px; line-height: 1; color: #61797c; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-field { display: grid; gap: 6px; color: #526b6e; font-size: 11px; font-weight: 700; }
.form-field input, .form-field select, .form-field textarea { width: 100%; padding: 10px; color: var(--ink); font-size: 13px; font-weight: 400; }
.form-field textarea { resize: vertical; min-height: 73px; }
.wide { grid-column: 1 / -1; }
.modal-footer { display: flex; justify-content: flex-end; gap: 9px; padding-top: 8px; }
.profile-card { display: flex; align-items: center; gap: 12px; padding: 14px; background: var(--mist); border: 1px solid #dfebe9; border-radius: 11px; }
.profile-avatar { width: 42px; height: 42px; font-size: 13px; }
.profile-card h3 { margin: 0; font: 600 18px Fraunces, Georgia, serif; }
.profile-card p { margin: 4px 0 0; color: var(--ink-soft); font-size: 11px; }
.profile-details { display: grid; gap: 0; margin: 18px 0 0; border-top: 1px solid var(--line); }
.profile-details div { display: flex; justify-content: space-between; gap: 16px; padding: 11px 0; border-bottom: 1px solid var(--line); }
.profile-details dt { color: var(--ink-soft); font-size: 11px; }
.profile-details dd { margin: 0; color: var(--ink); font-size: 12px; font-weight: 700; text-align: right; }
.profile-actions { display: flex; justify-content: flex-end; margin-top: 17px; }
.password-requirements { color: var(--ink-soft); font-size: 10px; line-height: 1.4; margin: -2px 0 0; }
.password-error { color: var(--coral); font-size: 11px; line-height: 1.4; margin: -3px 0 0; }
.danger-button { min-height: 39px; border: 1px solid transparent; border-radius: 9px; padding: 0 15px; background: var(--coral); color: #fff; font-size: 12px; font-weight: 700; }
.danger-button:hover { background: #963d32; }
.danger-text { color: var(--coral); }
.delete-warning { color: var(--ink-soft); font-size: 12px; line-height: 1.5; margin: -4px 0 18px; }
.access-note { margin: -2px 0 0; color: #728789; font-size: 11px; line-height: 1.45; }
.charge-summary { margin: -4px 0 19px; padding: 12px; background: var(--mist); border: 1px solid #dfebe9; border-radius: 10px; display: flex; justify-content: space-between; gap: 10px; }
.charge-summary strong, .charge-summary small { display: block; }
.charge-summary strong { font-size: 13px; }
.charge-summary small { color: #718689; font-size: 10px; margin-top: 4px; }
.charge-summary .remaining { color: var(--coral); text-align: right; font-size: 14px; }
.details-head { display: flex; justify-content: space-between; gap: 18px; padding-bottom: 18px; }
.details-head h3 { font: 600 23px Fraunces, Georgia, serif; margin: 0; }
.details-head p { margin: 5px 0; color: #657d7f; font-size: 12px; }
.details-head .details-balance { color: var(--coral); text-align: right; font-size: 16px; font-weight: 700; }
.details-head .details-balance small { display: block; color: #718688; font-size: 10px; font-weight: 400; margin-top: 5px; }
.details-info { background: var(--mist); border: 1px solid #e4eded; border-radius: 11px; display: grid; grid-template-columns: repeat(3, 1fr); padding: 13px; gap: 13px; }
.details-info span { display: block; color: #74888a; text-transform: uppercase; letter-spacing: .7px; font-size: 9px; font-weight: 700; margin-bottom: 4px; }
.details-info strong { display: block; font-size: 11px; line-height: 1.35; }
.details-section { margin-top: 22px; }
.details-section h4 { font: 600 17px Fraunces, Georgia, serif; margin: 0 0 10px; }
.history-row { display: grid; grid-template-columns: .5fr 1fr .6fr .8fr .7fr .7fr; gap: 10px; font-size: 11px; padding: 11px 4px; border-top: 1px solid #e7eeee; }
.history-row:first-of-type { border-top: 0; }
.details-actions { display: flex; justify-content: flex-end; margin-top: 20px; }
.toast-region { position: fixed; z-index: 100; right: 22px; bottom: 22px; display: grid; gap: 8px; width: min(360px, calc(100vw - 44px)); }
.toast-top-region { top: 22px; bottom: auto; }
.toast { background: #173f43; color: #fff; border-radius: 10px; padding: 13px 15px; box-shadow: 0 12px 28px rgba(11,43,45,.2); font-size: 12px; animation: toast-in .2s ease-out; }
.toast.error { background: #9a3e33; }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

@media (max-width: 1120px) {
  .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dashboard-grid { grid-template-columns: 1fr; }
}
@media (max-width: 820px) {
  .sidebar { transform: translateX(-100%); transition: transform .22s; box-shadow: 12px 0 34px rgba(13,49,52,.16); }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .menu-toggle { display: block; margin-right: 10px; }
  .topbar { justify-content: flex-start; height: 74px; padding: 0 18px; }
  .topbar-actions { margin-left: auto; }
  .topbar-actions time { display: none; }
  .view { padding: 28px 18px 46px; }
  .dashboard-intro, .view-heading { align-items: flex-start; flex-direction: column; }
  .period-control { width: 100%; justify-content: space-between; }
  .period-control select { flex: 1; }
  .toolbar { flex-wrap: wrap; }
  .search-field { max-width: none; min-width: 100%; order: -1; }
  .toolbar-wide .search-field { max-width: none; }
  .result-count { margin-left: 0; }
  .audit-entry { grid-template-columns: 34px 1fr auto; gap: 10px; }
  .audit-summary { grid-column: 2 / -1; }
  .audit-date { grid-column: 2 / -1; text-align: left; }
}
@media (max-width: 500px) {
  .metric-grid { grid-template-columns: 1fr; }
  .metric-card { min-height: 100px; }
  .dashboard-intro h2, .view-heading h2 { font-size: 25px; }
  .payments-panel, .attention-panel { padding: 16px; }
  .form-grid { grid-template-columns: 1fr; }
  .wide { grid-column: auto; }
  .details-info { grid-template-columns: 1fr 1fr; }
  .history-row { grid-template-columns: 1fr 1fr; }
  .history-row > :last-child { grid-column: 1 / -1; }
  .modal { padding: 18px; }
}
