/* Importación de Google Fonts: INTER */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

/* Variables de Diseño (Tokens de Diseño) */
:root {
    --primary: #00BAF2;
    --primary-hover: #009ecd;
    --bg-app: #f1f5f9;
    --card-bg: rgba(255, 255, 255, 0.85);
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --border-color: rgba(0, 186, 242, 0.15);
    --border-radius: 12px;
    --shadow-sm: 0 4px 6px -1px rgb(0 0 0 / 0.05), 0 2px 4px -2px rgb(0 0 0 / 0.05);
    --shadow-md: 0 10px 15px -3px rgb(0 0 0 / 0.05), 0 4px 6px -4px rgb(0 0 0 / 0.05);
    --shadow-lg: 0 20px 25px -5px rgb(0 0 0 / 0.05), 0 8px 10px -6px rgb(0 0 0 / 0.05);
    --status-success: #10b981;
    --status-warning: #f59e0b;
    --status-danger: #ef4444;
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

[data-theme="dark"] {
    --bg-app: #0f172a;
    --card-bg: rgba(30, 41, 59, 0.8);
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --border-color: rgba(255, 255, 255, 0.08);
}

/* Reset y Estilos Base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: var(--font-sans);
}

body {
    background-color: var(--bg-app);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
    transition: background-color 0.3s ease, color 0.3s ease;
}

html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

.skip-link {
    position: fixed;
    top: 0.75rem;
    left: 0.75rem;
    z-index: 1300;
    padding: 0.6rem 0.9rem;
    color: #ffffff;
    background: var(--text-primary);
    border-radius: 8px;
    font-weight: 700;
    text-decoration: none;
    transform: translateY(-140%);
    transition: transform 0.2s ease;
}

.skip-link:focus {
    transform: translateY(0);
}

header {
    background: var(--card-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-color);
    padding: 0.9rem clamp(1rem, 2.8vw, 2rem);
    position: sticky;
    top: 0;
    z-index: 1000;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
    box-shadow: var(--shadow-sm);
}

.logo-container {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    min-width: 0;
}

.logo-container img {
    height: clamp(34px, 5vw, 40px);
    object-fit: contain;
    flex: 0 0 auto;
}

.logo-text {
    font-weight: 700;
    font-size: 1.25rem;
    letter-spacing: 0;
    color: var(--text-primary);
    overflow-wrap: anywhere;
}

.logo-text span {
    color: var(--primary);
}

.logo-text-group {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.version-badge {
    font-size: 0.65rem;
    font-weight: 600;
    color: var(--primary);
    background: rgba(0, 186, 242, 0.1);
    border: 1px solid rgba(0, 186, 242, 0.25);
    padding: 2px 8px;
    border-radius: 20px;
    white-space: nowrap;
    letter-spacing: 0.03em;
    align-self: flex-start;
}

.nav-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.65rem;
    flex-wrap: wrap;
    min-width: 0;
}

button {
    font-family: var(--font-sans);
    cursor: pointer;
    border: none;
    outline: none;
    transition: all 0.2s ease;
    min-height: 44px;
    line-height: 1.2;
}

.btn-primary,
.btn-secondary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    min-width: 0;
    text-align: center;
    text-decoration: none;
    white-space: normal;
}

.btn-primary {
    background-color: var(--primary);
    color: white;
    padding: 0.65rem 1rem;
    font-weight: 600;
    border-radius: 8px;
    box-shadow: 0 4px 10px rgba(0, 186, 242, 0.25);
}

.btn-primary:hover {
    background-color: var(--primary-hover);
    transform: translateY(-1px);
}

.btn-secondary {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 0.65rem 1rem;
    font-weight: 500;
    border-radius: 8px;
}

.btn-secondary:hover {
    background: rgba(0, 186, 242, 0.05);
}

button:focus-visible,
a:focus-visible,
.form-control:focus-visible {
    outline: 3px solid rgba(0, 186, 242, 0.32);
    outline-offset: 2px;
}

.offline-badge {
    background-color: var(--status-warning);
    color: white;
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
    display: none;
    align-items: center;
    gap: 0.25rem;
}

.offline-badge.visible {
    display: inline-flex;
    animation: pulse 2s infinite;
}

/* Modales conformes a la regla: width: 80% y height: 80% */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(8px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1100;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    isolation: isolate;
    overflow-y: auto;
    padding: 1rem;
}

.modal-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.modal-content {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    width: 80%;
    height: 80%;
    max-width: 1180px;
    max-height: 860px;
    padding: 2rem;
    display: flex;
    flex-direction: column;
    position: relative;
    z-index: 1;
    box-shadow: var(--shadow-lg);
    overflow: hidden;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.5rem;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 1rem;
}

.modal-body {
    flex: 1;
    overflow-y: auto;
    padding-right: 0.5rem;
    min-width: 0;
}

.close-modal {
    background: transparent;
    font-size: 1.5rem;
    color: var(--text-secondary);
    width: 44px;
    height: 44px;
    border-radius: 8px;
    flex: 0 0 auto;
}

.login-modal-content {
    width: min(92vw, 520px);
    height: auto;
    max-width: 520px;
    max-height: calc(100dvh - 2rem);
    transform: translateZ(0);
}

.login-modal-body {
    flex: 0 1 auto;
    overflow-y: auto;
    padding-right: 0;
}

.login-form {
    width: 100%;
    max-width: 400px;
    margin: 0 auto;
}

.smart-catalog-open-btn {
    width: 100%;
    margin-top: 0.5rem;
}

.donation-insumo-search {
    margin-bottom: 0.5rem;
}

.smart-catalog-modal-content {
    max-width: 760px;
}

.smart-catalog-form {
    display: grid;
    gap: 1rem;
    max-width: 620px;
    margin: 0 auto;
}

.smart-catalog-duplicates {
    display: none;
    border: 1px solid var(--status-warning);
    border-radius: 10px;
    background: rgba(234, 179, 8, 0.08);
    padding: 1rem;
}

.smart-catalog-duplicates.visible {
    display: block;
}

.smart-catalog-duplicates h3 {
    margin: 0 0 0.75rem;
    font-size: 1rem;
}

.smart-catalog-match-list {
    display: grid;
    gap: 0.65rem;
}

.smart-catalog-match {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 0.75rem;
    align-items: center;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.48);
}

[data-theme="dark"] .smart-catalog-match {
    background: rgba(15, 23, 42, 0.55);
}

.smart-catalog-match strong,
.smart-catalog-match span {
    overflow-wrap: anywhere;
}

.smart-catalog-actions {
    display: flex;
    gap: 0.75rem;
    align-items: center;
}

.smart-catalog-actions .btn-primary,
.smart-catalog-actions .btn-secondary {
    flex: 1;
}

.modal-overlay.spec-modal-overlay {
    z-index: 9999;
    padding: 1rem;
}

.modal-content.spec-modal-content {
    width: 80%;
    height: 80%;
    max-width: 1400px;
    max-height: calc(100dvh - 2rem);
    display: flex;
    flex-direction: column;
    padding: 0;
    overflow: hidden;
    min-height: 0;
    background: #0f172a;
    border: 1px solid rgba(255, 255, 255, 0.12);
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.6);
}

.modal-header.spec-modal-header {
    flex: 0 0 auto;
    align-items: center;
    margin-bottom: 0;
    padding: 1rem 1.5rem;
    background: #0f172a;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.modal-header.spec-modal-header h2 {
    margin: 0;
    color: #f1f5f9;
    font-size: 1.1rem;
    line-height: 1.2;
}

.close-modal.spec-modal-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 0;
    color: #94a3b8;
    font-size: 1.25rem;
    font-weight: 800;
    line-height: 1;
    cursor: pointer;
}

.spec-modal-body {
    flex: 1 1 auto;
    min-height: 0;
    margin: 0;
    padding: 0;
    overflow: hidden;
    background: #090d16;
}

.spec-modal-body iframe {
    display: block;
    width: 100%;
    height: 100%;
    border: 0;
    background: #090d16;
}

/* Layout Principal Bento Grid */
.bento-container {
    max-width: 1400px;
    margin: clamp(1rem, 3vw, 2rem) auto;
    padding: 0 clamp(1rem, 3vw, 1.5rem);
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    grid-auto-rows: minmax(120px, auto);
    gap: 1.5rem;
    width: 100%;
    flex: 1;
}

/* Items Bento */
.bento-item {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: clamp(1rem, 2.2vw, 1.5rem);
    box-shadow: var(--shadow-sm);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    overflow: hidden;
    position: relative;
    backdrop-filter: blur(10px);
}

.bento-item:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
    border-color: rgba(0, 186, 242, 0.35);
}

/* Configuraciones de tamaño Bento Grid */
.col-12 { grid-column: span 12; }
.col-8 { grid-column: span 8; }
.col-6 { grid-column: span 6; }
.col-4 { grid-column: span 4; }
.col-3 { grid-column: span 3; }

.row-1 { grid-row: span 1; }
.row-2 { grid-row: span 2; }
.row-3 { grid-row: span 3; }
.row-4 { grid-row: span 4; }

/* Vista pública sin login: expandir widgets visibles a ancho completo */
.public-only .bento-item.col-8 {
    grid-column: span 12;
}

.public-only .bento-item.col-6 {
    grid-column: span 12;
}

.public-only .bento-item.col-6.row-2 {
    grid-row: span 1;
}

/* Bento Widgets específicos */
.welcome-card {
    background: linear-gradient(135deg, rgba(0, 186, 242, 0.08) 0%, rgba(0, 186, 242, 0.02) 100%);
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 1rem;
}

.dashboard-hero {
    flex-wrap: wrap;
}

.dashboard-hero > div:first-child {
    min-width: min(100%, 320px);
}

.dashboard-tab-list,
.admin-subtab-nav,
.admin-section-head {
    flex-wrap: wrap;
}

.dashboard-tab-list {
    justify-content: flex-end;
}

.dashboard-tab {
    flex: 1 1 170px;
}

.admin-subtab-nav .btn-primary,
.admin-subtab-nav .btn-secondary {
    flex: 1 1 190px;
}

.admin-section-head {
    gap: 0.75rem;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.85rem;
    height: 100%;
}

.national-stats-card .stats-grid {
    height: auto;
}

.stat-box {
    background: rgba(255, 255, 255, 0.5);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
}

[data-theme="dark"] .stat-box {
    background: rgba(30, 41, 59, 0.4);
}

.stat-value {
    font-size: 2.25rem;
    font-weight: 700;
    color: var(--primary);
    line-height: 1;
    margin-bottom: 0.5rem;
}

.stat-label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.chart-card-heading {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1rem;
}

.chart-card-heading h3,
.chart-card-heading h4 {
    line-height: 1.2;
}

.chart-card-heading h4 {
    font-size: 0.95rem;
}

.chart-card-heading p {
    color: var(--text-secondary);
    font-size: 0.8rem;
    line-height: 1.35;
    margin-top: 0.25rem;
}

.donut-chart-wrap {
    position: relative;
    width: min(180px, 72vw);
    aspect-ratio: 1;
    margin: 0 auto 1rem;
    display: grid;
    place-items: center;
}

.donut-chart {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: conic-gradient(var(--primary) 0deg, rgba(0, 186, 242, 0.12) 0deg);
    box-shadow: inset 0 0 0 1px var(--border-color);
}

.donut-chart::after {
    content: '';
    position: absolute;
    inset: 18%;
    border-radius: 50%;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
}

.donut-center {
    position: absolute;
    inset: 28%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    z-index: 1;
}

.donut-center strong {
    color: var(--text-primary);
    font-size: 1.5rem;
    line-height: 1;
}

.donut-center span {
    color: var(--text-secondary);
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
}

.chart-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
}

.legend-item {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    min-width: 0;
    color: var(--text-secondary);
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.4rem 0.55rem;
    background: rgba(255, 255, 255, 0.35);
    border: 1px solid var(--border-color);
    border-radius: 8px;
}

[data-theme="dark"] .legend-item {
    background: rgba(15, 23, 42, 0.3);
}

.legend-dot {
    width: 0.65rem;
    height: 0.65rem;
    border-radius: 999px;
    flex: 0 0 auto;
}

.bar-chart-list {
    display: grid;
    gap: 0.8rem;
}

.compact-chart-list {
    max-height: 250px;
    overflow-y: auto;
    padding-right: 0.25rem;
}

.bar-row {
    display: grid;
    gap: 0.45rem;
}

.bar-row-header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.75rem;
    color: var(--text-secondary);
    font-size: 0.78rem;
    font-weight: 600;
}

.bar-row-title {
    color: var(--text-primary);
    overflow-wrap: anywhere;
}

.bar-row-value {
    flex: 0 0 auto;
}

.bar-track {
    position: relative;
    height: 0.7rem;
    overflow: hidden;
    background: rgba(15, 23, 42, 0.08);
    border-radius: 999px;
}

[data-theme="dark"] .bar-track {
    background: rgba(255, 255, 255, 0.08);
}

.bar-fill {
    position: absolute;
    inset: 0 auto 0 0;
    width: 0%;
    min-width: 0.18rem;
    border-radius: inherit;
    background: var(--primary);
}

.bar-fill.secondary {
    background: var(--status-success);
}

.dual-bar {
    display: grid;
    gap: 0.28rem;
}

.inventory-insights-grid {
    display: grid;
    grid-template-columns: minmax(220px, 0.75fr) repeat(2, minmax(220px, 1fr));
    gap: 1rem;
    margin: 1rem 0 1.25rem;
}

.insight-metrics {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.7rem;
}

.metric-tile,
.mini-chart-panel {
    min-width: 0;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.35);
}

[data-theme="dark"] .metric-tile,
[data-theme="dark"] .mini-chart-panel {
    background: rgba(15, 23, 42, 0.28);
}

.metric-tile {
    min-height: 96px;
    padding: 0.9rem;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 0.6rem;
}

.metric-tile span {
    color: var(--text-secondary);
    font-size: 0.76rem;
    font-weight: 700;
    line-height: 1.25;
    text-transform: uppercase;
}

.metric-tile strong {
    color: var(--text-primary);
    font-size: 1.5rem;
    line-height: 1;
    overflow-wrap: anywhere;
}

.mini-chart-panel {
    padding: 1rem;
}

.mini-chart-panel.wide {
    grid-column: span 2;
}

.status-stack-chart {
    display: flex;
    width: 100%;
    height: 1rem;
    overflow: hidden;
    border-radius: 999px;
    background: rgba(15, 23, 42, 0.08);
    margin-bottom: 0.8rem;
}

[data-theme="dark"] .status-stack-chart {
    background: rgba(255, 255, 255, 0.08);
}

.stack-segment {
    min-width: 0;
}

.trend-chart {
    min-height: 170px;
    display: flex;
    justify-content: space-between;
    align-items: end;
    gap: 0.5rem;
    padding-top: 0.5rem;
    overflow-x: auto;
    scrollbar-width: thin;
    padding-bottom: 0.25rem;
}

.trend-chart::-webkit-scrollbar {
    height: 4px;
}

.trend-chart::-webkit-scrollbar-thumb {
    background-color: var(--border-color);
    border-radius: 4px;
}

.trend-day {
    flex: 1;
    min-width: 28px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    gap: 0.4rem;
    height: 150px;
}

.trend-bars {
    display: flex;
    align-items: end;
    justify-content: center;
    gap: 3px;
    height: 120px;
    width: 100%;
    border-bottom: 1px solid var(--border-color);
}

.trend-bar {
    width: 8px;
    min-height: 2px;
    border-radius: 4px 4px 0 0;
    transition: transform 0.2s ease, filter 0.2s ease;
}

.trend-bar:hover {
    transform: scaleY(1.05);
    filter: brightness(0.9);
}

.trend-bar.ingreso {
    background: var(--primary);
}

.trend-bar.entrega {
    background: var(--status-success);
}

.trend-label {
    color: var(--text-secondary);
    font-size: 0.7rem;
    font-weight: 700;
    text-align: center;
    line-height: 1;
    white-space: nowrap;
}

.inline-legend {
    margin-top: 0.25rem;
}

.map-container {
    height: 100%;
    min-height: clamp(280px, 45vh, 380px);
    width: 100%;
    border-radius: 10px;
    overflow: hidden;
    border: 1px solid var(--border-color);
}

.map-heading,
.needs-panel-heading {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}

.map-heading h3,
.needs-panel-heading h3 {
    margin-bottom: 0.35rem;
}

.map-heading p,
.needs-panel-heading p {
    color: var(--text-secondary);
    font-size: 0.85rem;
    line-height: 1.45;
    margin: 0;
}

.map-layer-toggle {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    gap: 0.55rem;
    padding: 0.55rem 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.35);
    font-size: 0.85rem;
    font-weight: 700;
    cursor: pointer;
}

[data-theme="dark"] .map-layer-toggle {
    background: rgba(15, 23, 42, 0.3);
}

.map-layer-toggle input {
    width: 1rem;
    height: 1rem;
    accent-color: var(--primary);
}

.map-layer-summary {
    min-height: 1.8rem;
    color: var(--text-secondary);
    font-size: 0.8rem;
    margin-bottom: 0.6rem;
}

.needs-map-marker {
    background: transparent;
    border: 0;
}

.needs-map-marker-bubble {
    width: 42px;
    height: 42px;
    display: grid;
    place-items: center;
    border-radius: 999px;
    color: #ffffff;
    background: var(--status-warning);
    border: 3px solid #ffffff;
    box-shadow: 0 8px 18px rgba(15, 23, 42, 0.2);
    font-size: 0.78rem;
    font-weight: 800;
}

.needs-map-marker-bubble.critical {
    background: var(--status-danger);
}

.center-needs-modal-body {
    display: grid;
    gap: 1rem;
}

.center-needs-summary,
.need-card {
    border: 1px solid var(--border-color);
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.35);
    padding: 1rem;
}

[data-theme="dark"] .center-needs-summary,
[data-theme="dark"] .need-card {
    background: rgba(15, 23, 42, 0.28);
}

.center-needs-summary {
    display: grid;
    gap: 0.35rem;
}

.center-needs-summary strong {
    font-size: 1rem;
}

.public-needs-list {
    display: grid;
    gap: 0.75rem;
}

.need-card {
    display: grid;
    gap: 0.6rem;
}

.need-card-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.need-card-title {
    min-width: 0;
}

.need-card-title strong {
    display: block;
    color: var(--text-primary);
    overflow-wrap: anywhere;
}

.need-card-title span,
.need-card-meta,
.need-card-details {
    color: var(--text-secondary);
    font-size: 0.8rem;
    line-height: 1.4;
}

.need-status-pill,
.need-urgency-pill,
.need-public-pill {
    display: inline-flex;
    align-items: center;
    min-height: 28px;
    padding: 0.25rem 0.55rem;
    border-radius: 8px;
    font-size: 0.74rem;
    font-weight: 800;
    text-transform: uppercase;
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    background: rgba(0, 186, 242, 0.08);
}

.need-urgency-pill.critica {
    color: #ffffff;
    background: var(--status-danger);
    border-color: transparent;
}

.need-urgency-pill.alta {
    color: #ffffff;
    background: var(--status-warning);
    border-color: transparent;
}

.need-urgency-pill.media {
    color: var(--text-primary);
    background: rgba(0, 186, 242, 0.12);
}

.need-urgency-pill.baja {
    color: var(--status-success);
    background: rgba(16, 185, 129, 0.1);
}

.need-public-pill.public {
    color: var(--status-success);
    background: rgba(16, 185, 129, 0.1);
}

.need-public-pill.private {
    color: var(--text-secondary);
    background: rgba(148, 163, 184, 0.12);
}

.needs-filter-bar {
    grid-template-columns: minmax(220px, 2fr) repeat(4, minmax(140px, 1fr)) auto;
}

.need-crud-form {
    max-width: 980px;
    margin: 0 auto;
}

.need-form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem;
    align-items: start;
}

.need-details-field {
    grid-column: 1 / -1;
}

.center-crud-form {
    max-width: 1040px;
    margin: 0 auto;
}

.center-crud-grid {
    display: grid;
    grid-template-columns: minmax(260px, 0.9fr) minmax(320px, 1.1fr);
    gap: 1.5rem;
    align-items: start;
}

.center-crud-fields,
.center-location-panel {
    min-width: 0;
}

.center-location-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 0.5rem;
}

.center-location-header label {
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-weight: 600;
}

.center-location-header .btn-secondary {
    padding: 0.5rem 0.75rem;
    white-space: nowrap;
}

.center-location-map {
    width: 100%;
    height: 360px;
    min-height: 320px;
    background: var(--bg-app);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    overflow: hidden;
}

.center-coordinates-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.75rem;
    margin-top: 1rem;
}

.center-coordinates-grid .form-group {
    margin-bottom: 0;
}

/* Formularios Bento */
.form-group {
    margin-bottom: 1.25rem;
}

.form-group label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--text-secondary);
}

.form-control {
    width: 100%;
    min-height: 44px;
    padding: 0.75rem 1rem;
    background: var(--bg-app);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 0.9rem;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.form-control:focus {
    border-color: var(--primary);
    outline: none;
    box-shadow: 0 0 0 3px rgba(0, 186, 242, 0.12);
}

.delivery-form {
    max-width: 760px;
    margin: 0 auto;
}

.donation-contact-grid,
.delivery-form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.75rem;
}

.donation-contact-grid .form-group,
.delivery-form-grid .form-group {
    min-width: 0;
}

.donation-receipt {
    margin-top: 0;
    padding: 1rem;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    background: rgba(0, 186, 242, 0.04);
}

.donation-receipt-modal-content .modal-body {
    padding-right: 0.25rem;
}

.donation-receipt-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1rem;
}

.donation-receipt-kicker {
    color: var(--primary);
    display: block;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
}

.donation-receipt h4 {
    font-size: 1rem;
    font-weight: 700;
    margin-top: 0.2rem;
}

.donation-receipt-body {
    display: grid;
    grid-template-columns: 208px minmax(0, 1fr);
    gap: 1rem;
    align-items: start;
}

.donation-qr {
    width: 208px;
    min-height: 208px;
    padding: 12px;
    display: grid;
    place-items: center;
    background: #ffffff;
    border: 1px solid rgba(15, 23, 42, 0.08);
    border-radius: 8px;
}

.donation-qr img,
.donation-qr canvas {
    width: 184px;
    height: 184px;
    display: block;
}

.donation-code-panel {
    min-width: 0;
}

.donation-code-panel label {
    display: block;
    color: var(--text-secondary);
    font-size: 0.8rem;
    font-weight: 600;
    margin-bottom: 0.45rem;
}

.donation-code-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 0.5rem;
    align-items: stretch;
}

.donation-code-input {
    font-family: monospace;
    font-weight: 700;
}

.donation-meta {
    display: grid;
    gap: 0.35rem;
    color: var(--text-secondary);
    font-size: 0.78rem;
    margin: 0.75rem 0;
}

.donation-meta strong {
    color: var(--text-primary);
    font-family: monospace;
    word-break: break-word;
}

.donation-detail-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.6rem;
    margin: 0.75rem 0;
}

.donation-detail-grid div {
    min-width: 0;
    padding: 0.65rem;
    background: rgba(255, 255, 255, 0.45);
    border: 1px solid var(--border-color);
    border-radius: 8px;
}

[data-theme="dark"] .donation-detail-grid div {
    background: rgba(15, 23, 42, 0.35);
}

.donation-detail-grid span {
    display: block;
    color: var(--text-secondary);
    font-size: 0.72rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
    text-transform: uppercase;
}

.donation-detail-grid strong {
    display: block;
    color: var(--text-primary);
    font-size: 0.88rem;
    font-weight: 700;
    line-height: 1.25;
    word-break: break-word;
}

.donation-share-fields {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.5rem;
    margin-bottom: 0.65rem;
}

.donation-share-actions {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.5rem;
}

.donation-share-actions .btn-secondary,
.donation-code-row .btn-secondary {
    min-height: 42px;
    padding: 0.5rem 0.7rem;
    white-space: nowrap;
}

.donors-toolbar {
    display: grid;
    grid-template-columns: minmax(240px, 1fr) auto;
    gap: 0.75rem;
    align-items: center;
    margin-bottom: 0.85rem;
}

.donors-summary {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.donors-summary span {
    color: var(--text-secondary);
    font-size: 0.8rem;
    padding: 0.45rem 0.65rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: rgba(0, 186, 242, 0.04);
}

.donors-summary strong {
    color: var(--text-primary);
}

.donors-table-wrap {
    max-height: calc(80vh - 210px);
}

.donors-table th,
.donors-table td {
    vertical-align: top;
}

.donors-table .tx-hash {
    margin-top: 0;
}

.donor-table-subtext {
    color: var(--text-secondary);
    font-size: 0.76rem;
    margin-top: 0.25rem;
    line-height: 1.3;
    word-break: break-word;
}

/* Filtros del panel administrativo */
.admin-filter-bar {
    display: grid;
    grid-template-columns: minmax(220px, 2fr) repeat(2, minmax(150px, 1fr)) auto;
    gap: 0.75rem;
    align-items: end;
    margin-bottom: 1rem;
    padding: 1rem 0;
    border-top: 1px solid var(--border-color);
    border-bottom: 1px solid var(--border-color);
}

.admin-filter-field label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    margin-bottom: 0.4rem;
    color: var(--text-secondary);
}

.admin-filter-actions {
    display: flex;
    align-items: end;
    min-width: 0;
}

.admin-filter-actions .btn-secondary {
    min-height: 42px;
    white-space: nowrap;
    width: 100%;
}

.inventory-filter-bar {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 0.75rem;
    align-items: end;
    margin-bottom: 1rem;
    padding: 1rem 0;
    border-top: 1px solid var(--border-color);
    border-bottom: 1px solid var(--border-color);
}

.inventory-filter-field {
    min-width: 0;
}

.inventory-filter-field label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    margin-bottom: 0.4rem;
    color: var(--text-secondary);
}

.inventory-filter-actions {
    display: flex;
    align-items: end;
    min-width: 0;
}

.inventory-filter-actions .btn-secondary {
    min-height: 42px;
    width: 100%;
    white-space: nowrap;
}

.inventory-panel-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}

.inventory-panel-heading h3 {
    margin: 0;
}

.inventory-batch-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.65rem;
    flex-wrap: wrap;
}

.batch-delivery-count {
    color: var(--text-secondary);
    font-size: 0.82rem;
    font-weight: 600;
    padding: 0.5rem 0.65rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: rgba(0, 186, 242, 0.04);
}

.inventory-batch-checkbox {
    width: 22px;
    height: 22px;
    accent-color: var(--primary);
}

.batch-delivery-form {
    max-width: 980px;
    margin: 0 auto;
}

.batch-delivery-summary {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 0.85rem;
}

.batch-delivery-summary span {
    color: var(--text-secondary);
    font-size: 0.8rem;
    padding: 0.45rem 0.65rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: rgba(0, 186, 242, 0.04);
}

.batch-delivery-summary strong {
    color: var(--text-primary);
}

.batch-delivery-table-wrap {
    max-height: 260px;
    margin-bottom: 1rem;
}

.batch-delivery-table .form-control {
    min-width: 140px;
}

.batch-delivery-result {
    margin-top: 0.75rem;
}

.batch-delivery-result-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    padding: 0.85rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: rgba(0, 186, 242, 0.06);
}

.batch-delivery-result-card span {
    display: block;
    color: var(--text-secondary);
    font-size: 0.76rem;
    font-weight: 700;
    text-transform: uppercase;
    margin-bottom: 0.25rem;
}

.batch-delivery-result-card strong {
    display: block;
    color: var(--text-primary);
    font-family: monospace;
    font-size: 1rem;
    word-break: break-word;
}

.batch-delivery-result-actions,
.batch-delivery-submit-row {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.batch-delivery-submit-row {
    justify-content: flex-end;
    margin-top: 1rem;
}

.empty-table-message {
    color: var(--text-secondary);
    text-align: center;
}

.transfer-panel-heading {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 1.25rem;
}

.transfer-panel-heading h3,
.transfer-panel-heading p,
.transfer-workspace h4 {
    margin: 0;
}

.transfer-panel-heading p,
.transfer-prefill-note,
.transfer-meta,
.transfer-subtext {
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.transfer-panel-grid {
    display: grid;
    grid-template-columns: minmax(280px, 0.9fr) minmax(300px, 1fr) minmax(300px, 1fr);
    gap: 1rem;
    align-items: start;
}

.transfer-workspace {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    min-width: 0;
}

.transfer-workspace-wide {
    grid-column: 1 / -1;
}

.transfer-form,
.transfer-list,
.transfer-recommendations-grid {
    display: grid;
    gap: 0.85rem;
}

.transfer-form-row {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.85rem;
}

.transfer-card {
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1rem;
    background: rgba(255, 255, 255, 0.72);
}

[data-theme="dark"] .transfer-card {
    background: rgba(30, 41, 59, 0.68);
}

.transfer-card-header {
    display: flex;
    justify-content: space-between;
    gap: 0.75rem;
    align-items: flex-start;
    flex-wrap: wrap;
}

.transfer-card-title {
    font-weight: 700;
    word-break: break-word;
}

.transfer-status-pill {
    display: inline-flex;
    align-items: center;
    min-height: 28px;
    padding: 0.2rem 0.55rem;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0;
    background: rgba(245, 158, 11, 0.12);
    color: var(--status-warning);
}

.transfer-status-pill.accepted {
    background: rgba(16, 185, 129, 0.12);
    color: var(--status-success);
}

.transfer-status-pill.rejected {
    background: rgba(239, 68, 68, 0.12);
    color: var(--status-danger);
}

.transfer-route {
    display: grid;
    gap: 0.25rem;
    font-size: 0.9rem;
}

.transfer-card-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.transfer-card-actions button {
    min-height: 44px;
}

.transfer-recommendations-grid {
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}

/* Tablas Bento */
.table-responsive {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: 10px;
}

.bento-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    min-width: 720px;
}

.bento-table th {
    padding: 0.75rem 1rem;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
    border-bottom: 2px solid var(--border-color);
    text-transform: uppercase;
    background: rgba(0, 186, 242, 0.035);
    position: sticky;
    top: 0;
    z-index: 1;
}

.bento-table td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.9rem;
    vertical-align: top;
}

.bento-table tr:hover {
    background: rgba(0, 186, 242, 0.03);
}

/* Trazabilidad Timeline */
.timeline {
    position: relative;
    padding-left: 2rem;
    margin-top: 1rem;
}

.timeline::before {
    content: '';
    position: absolute;
    left: 7px;
    top: 0;
    bottom: 0;
    width: 2px;
    background: var(--border-color);
}

.timeline-item {
    position: relative;
    margin-bottom: 1.5rem;
}

.timeline-dot {
    position: absolute;
    left: -29px;
    top: 4px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--primary);
    border: 3px solid var(--bg-app);
}

.timeline-content {
    background: rgba(0, 186, 242, 0.03);
    border-radius: 10px;
    padding: 1rem;
    border: 1px solid var(--border-color);
}

.timeline-title {
    font-weight: 600;
    font-size: 0.95rem;
    margin-bottom: 0.25rem;
}

.timeline-date {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.tx-hash {
    font-family: monospace;
    font-size: 0.75rem;
    color: var(--primary);
    word-break: break-all;
    background: rgba(0, 186, 242, 0.08);
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    display: inline-block;
    margin-top: 0.5rem;
    max-width: 100%;
}

#tracking-search-form {
    align-items: stretch;
}

#tracking-search-form .btn-primary {
    flex: 0 0 auto;
}

/* Animaciones */
@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.spinner {
    width: 24px;
    height: 24px;
    border: 3px solid rgba(0, 186, 242, 0.1);
    border-top: 3px solid var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    display: inline-block;
}

/* Responsividad general */
@media (max-width: 1180px) {
    .transfer-panel-grid {
        grid-template-columns: 1fr 1fr;
    }

    .transfer-workspace:first-child,
    .transfer-workspace-wide {
        grid-column: 1 / -1;
    }
}

@media (max-width: 1024px) {
    .transfer-panel-grid {
        grid-template-columns: 1fr;
    }

    .transfer-workspace:first-child,
    .transfer-workspace-wide {
        grid-column: auto;
    }
}

@media (max-width: 768px) {
    .transfer-form-row {
        grid-template-columns: 1fr;
    }

    .transfer-panel-heading,
    .transfer-card-header,
    .transfer-card-actions {
        align-items: stretch;
    }

    .transfer-panel-heading > *,
    .transfer-card-actions button,
    #btn-submit-transfer,
    #refresh-transfers-btn {
        width: 100%;
    }
}

@media (max-width: 1180px) {
    header {
        align-items: flex-start;
    }

    .nav-actions {
        max-width: 100%;
    }

    #user-controls {
        width: 100%;
        justify-content: flex-end;
    }
}

@media (max-width: 1024px) {
    .bento-container {
        grid-template-columns: repeat(6, 1fr);
    }
    .col-12 { grid-column: span 6; }
    .col-8 { grid-column: span 6; }
    .col-6 { grid-column: span 3; }
    .col-4 { grid-column: span 6; } /* Ocupa ancho completo en tablet */
    .col-3 { grid-column: span 3; }

    .public-only .bento-item.col-6 {
        grid-column: span 6;
    }

    .national-stats-card {
        grid-column: span 6;
    }

    .national-stats-card .stats-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .dashboard-hero {
        align-items: stretch !important;
    }

    .dashboard-tab-list {
        width: 100%;
        justify-content: stretch;
    }

    .admin-filter-bar {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .needs-filter-bar {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .inventory-insights-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .insight-metrics,
    .mini-chart-panel.wide {
        grid-column: span 2;
    }
}

@media (max-width: 768px) {
    header {
        position: sticky;
        align-items: stretch;
    }

    .logo-container {
        width: 100%;
    }

    .logo-text {
        font-size: 1.1rem;
    }

    .nav-actions {
        width: 100%;
        justify-content: stretch;
    }

    .nav-actions > .btn-primary,
    .nav-actions > .btn-secondary,
    #user-controls > .btn-primary,
    #user-controls > .btn-secondary {
        flex: 1 1 140px;
    }

    #user-role-text {
        width: 100%;
    }

    .bento-container {
        display: flex;
        flex-direction: column;
        grid-template-columns: 1fr;
        gap: 1rem;
        padding: 0 1rem;
    }

    .col-12,
    .col-8,
    .col-6,
    .col-4,
    .col-3 {
        grid-column: 1 / -1;
    }

    .bento-item {
        align-self: stretch;
        width: 100%;
    }

    .stats-grid {
        grid-template-columns: 1fr;
    }

    .national-stats-card .stats-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .national-stats-card .stat-box {
        aspect-ratio: 1;
        min-height: 0;
        padding: 0.8rem;
    }

    .national-stats-card .stat-value {
        font-size: 1.9rem;
    }

    .national-stats-card .stat-label {
        font-size: 0.75rem;
        line-height: 1.15;
    }

    .inventory-insights-grid {
        grid-template-columns: 1fr;
    }

    .insight-metrics {
        grid-column: auto;
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .mini-chart-panel.wide {
        grid-column: auto;
    }

    .trend-chart {
        gap: 0.3rem;
        padding-bottom: 0.5rem;
    }

    .stat-value {
        font-size: 1.85rem;
    }
    .modal-content {
        width: 80%;
        height: 80%;
        padding: 1rem;
    }

    .login-modal-content {
        width: min(92vw, 520px);
        height: auto;
        max-height: calc(100dvh - 2rem);
    }

    .modal-header {
        align-items: flex-start;
        margin-bottom: 1rem;
    }

    .modal-header h2 {
        font-size: 1.2rem;
        line-height: 1.2;
    }

    .map-container {
        min-height: 300px;
    }

    .map-heading,
    .needs-panel-heading {
        align-items: stretch;
    }

    .map-layer-toggle,
    .needs-panel-heading .btn-primary {
        width: 100%;
        justify-content: center;
    }

    #tracking-search-form {
        display: grid !important;
        grid-template-columns: 1fr;
        gap: 0.65rem !important;
    }

    #tracking-search-form .btn-primary {
        width: 100%;
    }

    .dashboard-tab,
    .admin-subtab-nav .btn-primary,
    .admin-subtab-nav .btn-secondary,
    .admin-section-head .btn-primary {
        flex-basis: 100%;
        width: 100%;
    }

    .admin-section-head {
        align-items: stretch !important;
    }

    .admin-filter-bar {
        grid-template-columns: 1fr;
    }
    .needs-filter-bar {
        grid-template-columns: 1fr;
    }
    .need-form-grid {
        grid-template-columns: 1fr;
    }
    .inventory-filter-bar {
        grid-template-columns: 1fr;
    }
    .inventory-panel-heading,
    .inventory-batch-actions,
    .batch-delivery-result-card,
    .batch-delivery-result-actions,
    .batch-delivery-submit-row {
        align-items: stretch;
        flex-direction: column;
    }
    .inventory-batch-actions .btn-primary,
    .batch-delivery-result-actions .btn-primary,
    .batch-delivery-result-actions .btn-secondary,
    .batch-delivery-submit-row .btn-primary {
        width: 100%;
    }
    .batch-delivery-table-wrap {
        max-height: none;
    }
    .admin-filter-actions .btn-secondary {
        width: 100%;
    }
    .center-crud-grid {
        grid-template-columns: 1fr;
    }
    .center-location-header {
        align-items: stretch;
        flex-direction: column;
    }
    .center-location-map {
        height: 300px;
        min-height: 280px;
    }
    .center-coordinates-grid {
        grid-template-columns: 1fr;
    }
    .donation-contact-grid,
    .delivery-form-grid,
    .donation-receipt-body,
    .donation-detail-grid,
    .donation-share-fields,
    .donation-share-actions {
        grid-template-columns: 1fr;
    }
    .donation-qr {
        width: 100%;
    }
    .donation-code-row {
        grid-template-columns: 1fr;
    }
    .donation-code-row .btn-secondary,
    .donation-share-actions .btn-secondary {
        width: 100%;
    }
    .donors-toolbar {
        grid-template-columns: 1fr;
    }
    .donors-toolbar .btn-secondary {
        width: 100%;
    }
    .donors-table-wrap {
        max-height: calc(80vh - 230px);
    }

    .smart-catalog-actions,
    .smart-catalog-match {
        grid-template-columns: 1fr;
    }

    .smart-catalog-actions {
        flex-direction: column;
        align-items: stretch;
    }

    .smart-catalog-actions .btn-primary,
    .smart-catalog-actions .btn-secondary,
    .smart-catalog-match .btn-secondary {
        width: 100%;
    }
}

@media (max-width: 680px) {
    .modal-overlay.spec-modal-overlay {
        align-items: stretch;
        padding: 0.5rem;
    }

    .modal-content.spec-modal-content {
        width: 100%;
        height: calc(100dvh - 1rem);
        max-height: none;
        padding: 0;
        border-radius: 10px;
    }

    .modal-header.spec-modal-header {
        padding: 0.75rem 0.85rem;
        gap: 0.5rem;
    }

    .modal-header.spec-modal-header h2 {
        min-width: 0;
        font-size: 0.95rem;
        overflow-wrap: anywhere;
    }

    .close-modal.spec-modal-close {
        width: 40px;
        height: 40px;
        flex-basis: 40px;
    }

    .table-responsive:not(.no-collapse-wrap) {
        overflow-x: visible;
    }

    .bento-table:not(.no-collapse) {
        min-width: 0;
        border-collapse: separate;
        border-spacing: 0 0.75rem;
    }

    .bento-table:not(.no-collapse) thead {
        display: none;
    }

    .bento-table:not(.no-collapse) tbody,
    .bento-table:not(.no-collapse) tr,
    .bento-table:not(.no-collapse) td {
        display: block;
        width: 100%;
    }

    .bento-table:not(.no-collapse) tr {
        padding: 0.75rem;
        border: 1px solid var(--border-color);
        border-radius: 10px;
        background: rgba(255, 255, 255, 0.42);
        box-shadow: var(--shadow-sm);
    }

    [data-theme="dark"] .bento-table:not(.no-collapse) tr {
        background: rgba(15, 23, 42, 0.32);
    }

    .bento-table:not(.no-collapse) td {
        display: grid;
        grid-template-columns: minmax(7.5rem, 38%) minmax(0, 1fr);
        gap: 0.75rem;
        align-items: start;
        padding: 0.65rem 0;
        border-bottom: 1px solid var(--border-color);
        overflow-wrap: anywhere;
    }

    .bento-table:not(.no-collapse) td:last-child {
        border-bottom: 0;
    }

    .bento-table:not(.no-collapse) td::before {
        content: attr(data-label);
        color: var(--text-secondary);
        font-size: 0.76rem;
        font-weight: 700;
        text-transform: uppercase;
    }

    .bento-table:not(.no-collapse) td[colspan] {
        display: block;
        text-align: center;
    }

    .bento-table:not(.no-collapse) td[colspan]::before {
        content: "";
        display: none;
    }
}

@media (max-width: 520px) {
    .modal-overlay {
        align-items: flex-start;
        background: rgba(15, 23, 42, 0.64);
        backdrop-filter: none;
        -webkit-backdrop-filter: none;
        padding: max(1rem, env(safe-area-inset-top)) 1rem max(1rem, env(safe-area-inset-bottom));
    }

    header {
        padding: 0.75rem;
    }

    .logo-text {
        max-width: calc(100vw - 5.5rem);
        font-size: 1rem;
    }

    .bento-container {
        padding: 0 0.75rem;
        margin: 0.75rem auto;
    }

    .bento-item {
        padding: 0.9rem;
    }

    .insight-metrics {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .metric-tile {
        min-height: 88px;
        padding: 0.75rem;
    }

    .metric-tile strong {
        font-size: 1.2rem;
    }

    .donut-chart-wrap {
        width: min(150px, 68vw);
    }

    .modal-content {
        padding: 0.85rem;
    }

    .login-modal-content {
        width: 100%;
        height: auto;
        max-height: calc(100dvh - 2rem);
        margin: 10dvh auto 0;
        padding: 1.1rem;
        overflow: visible;
    }

    .login-modal-content .modal-header {
        align-items: center;
    }

    .login-modal-content .modal-header h2 {
        font-size: 1.45rem;
    }

    .login-modal-body {
        overflow: visible;
    }

    .login-form {
        max-width: none;
    }

    .modal-body {
        padding-right: 0;
    }

    .donation-qr {
        min-height: 180px;
    }

    .donation-qr img,
    .donation-qr canvas {
        width: 160px;
        height: 160px;
    }

    .bento-table td {
        grid-template-columns: 1fr;
        gap: 0.35rem;
    }
}
