:root {
    /* Color Palette */
    --primary: #059669;
    /* Emerald 600 */
    --primary-dark: #047857;
    /* Emerald 700 */
    --secondary: #d97706;
    /* Amber 600 */
    --bg-body: #f3f4f6;
    /* Gray 100 */
    --bg-card: #ffffff;
    --text-main: #111827;
    /* Gray 900 */
    --text-muted: #6b7280;
    /* Gray 500 */
    --border: #e5e7eb;
    /* Gray 200 */
    --danger: #ef4444;
    --warning: #d97706;
    /* Amber 600 */

    /* Spacing & Layout */
    --header-height: 60px;
    --nav-height: 60px;
    --radius: 12px;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg-body);
    color: var(--text-main);
    line-height: 1.5;
    height: 100vh;
    overflow: hidden;
    /* App-like behavior */
}

#app {
    display: flex;
    flex-direction: column;
    height: 100%;
}

/* Header */
.app-header {
    height: var(--header-height);
    background-color: var(--bg-card);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    position: fixed;
    top: 0;
    width: 100%;
    z-index: 10;
}

.app-header h1 {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--primary);
}

.icon-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-muted);
    padding: 8px;
    border-radius: 50%;
}

.icon-btn:active {
    background-color: var(--bg-body);
}

/* Main Content */
.content-container {
    flex: 1;
    overflow-y: auto;
    padding: calc(var(--header-height) + 16px) 16px calc(var(--nav-height) + 80px);
    /* Bottom padding for FAB */
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* Bottom Nav */
.bottom-nav {
    height: var(--nav-height);
    background-color: var(--bg-card);
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: space-around;
    position: fixed;
    bottom: 0;
    width: 100%;
    z-index: 10;
    padding-bottom: env(safe-area-inset-bottom);
}

.nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    color: var(--text-muted);
    font-size: 0.7rem;
    gap: 2px;
}

.nav-item.active {
    color: var(--primary);
}

.nav-item svg {
    width: 24px;
    height: 24px;
}

/* Components */

/* Internal Tabs */
.flock-tab-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 0.75rem;
    font-weight: 500;
    cursor: pointer;
    min-width: 64px;
    padding: 4px;
    transition: color 0.2s, transform 0.1s;
    touch-action: manipulation;
    flex-shrink: 0;
    /* Prevents button from shrinking in overflow container */
}

.flock-tab-btn:active {
    transform: scale(0.95);
}

.flock-tab-btn.active {
    color: var(--primary);
}

.flock-tab-btn svg {
    opacity: 0.8;
    width: 24px;
    height: 24px;
    flex-shrink: 0;
    /* Prevents SVG collapsing when vertical scrollbar narrows the screen */
}

.flock-tab-btn.active svg {
    opacity: 1;
    filter: drop-shadow(0 2px 4px rgba(5, 150, 105, 0.3));
}

.detail-tabs::-webkit-scrollbar {
    display: none;
}

.detail-tabs {
    -ms-overflow-style: none;
    /* IE and Edge */
    scrollbar-width: none;
    /* Firefox */
}

.tab-btn {
    background: var(--bg-card);
    border: 1px solid var(--border);
    padding: 12px 20px;
    /* Incrementado para mejor área táctil */
    border-radius: 24px;
    font-size: 1rem;
    font-weight: 500;
    white-space: nowrap;
    cursor: pointer;
    min-height: 48px;
    /* Estándar de accesibilidad móvil (48x48) */
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    touch-action: manipulation;
    /* Optimiza tap en dispositivos web view */
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.tab-btn.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 16px;
    box-shadow: var(--shadow);
}

.card h3 {
    margin-bottom: 8px;
    font-size: 1rem;
    color: var(--text-main);
}

.stat-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.stat-item {
    background: var(--bg-body);
    padding: 12px;
    border-radius: 8px;
    text-align: center;
}

.stat-item .label {
    font-size: 0.75rem;
    color: var(--text-muted);
    display: block;
}

.stat-item .value {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-main);
}

.stat-item .value.good {
    color: var(--primary);
}

.fab {
    position: fixed;
    bottom: calc(var(--nav-height) + 16px);
    right: 16px;
    width: 56px;
    height: 56px;
    border-radius: 28px;
    background-color: var(--primary);
    color: white;
    border: none;
    box-shadow: 0 4px 12px rgba(5, 150, 105, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 20;
    transition: transform 0.2s;
}

.fab:active {
    transform: scale(0.95);
}

.fab.hidden {
    display: none;
}

/* Forms */
.form-group {
    margin-bottom: 16px;
}

.form-label {
    display: block;
    margin-bottom: 6px;
    font-weight: 500;
    font-size: 0.9rem;
}

.form-input {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 1rem;
    font-family: inherit;
}

.form-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(5, 150, 105, 0.2);
}

.btn {
    display: inline-block;
    width: 100%;
    padding: 12px;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    text-align: center;
    cursor: pointer;
    font-size: 1rem;
}

.btn-primary {
    background-color: var(--primary);
    color: white;
}

.btn-secondary {
    background-color: var(--bg-body);
    color: var(--text-main);
}

/* Utilities */
.text-center {
    text-align: center;
}

.mt-4 {
    margin-top: 16px;
}

.text-sm {
    font-size: 0.875rem;
}

.text-muted {
    color: var(--text-muted);
}

/* Print Styles for PDF Export */
@media print {

    .app-header,
    .bottom-nav,
    .fab,
    #btn-export-pdf,
    #btn-export-xml,
    .analysis-controls {
        display: none !important;
    }

    .content-container {
        padding: 0 !important;
        margin: 0 !important;
        height: auto !important;
        overflow: visible !important;
    }

    body {
        background-color: white !important;
        height: auto !important;
        overflow: visible !important;
    }

    #app {
        height: auto !important;
        overflow: visible !important;
    }

    .card {
        box-shadow: none !important;
        border: 1px solid #ddd !important;
        page-break-inside: avoid;
        margin-bottom: 20px;
    }

    canvas {
        max-width: 100% !important;
        height: auto !important;
        page-break-inside: avoid;
    }
}