/* =========================================================================
   CSS Variables
   ========================================================================= */

:root {
    --bg-primary: #ffffff;
    --bg-secondary: #f9fafb;
    --bg-card: #ffffff;
    --text-primary: #1f2937;
    --text-secondary: #6b7280;
    --border-color: #e5e7eb;
    --accent-blue: #3b82f6;
    --accent-green: #10b981;
    --accent-purple: #8b5cf6;
    --accent-yellow: #f59e0b;
    --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1);
}

.dark {
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-card: #1e293b;
    --text-primary: #f1f5f9;
    --text-secondary: #cbd5e1;
    --border-color: #334155;
    --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.3);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.4);
}

/* =========================================================================
   Base Styles
   ========================================================================= */

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
        'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
}

#app {
    min-height: 100vh;
    background-color: var(--bg-primary);
    transition: background-color 0.3s, color 0.3s;
}

.container {
    max-width: 1280px;
    margin: 0 auto;
    padding: 0 1rem;
}

/* =========================================================================
   Header
   ========================================================================= */

.header {
    background-color: var(--bg-card);
    border-bottom: 1px solid var(--border-color);
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.5rem 0;
}

.header h1 {
    font-size: 1.875rem;
    font-weight: bold;
    margin-bottom: 0.25rem;
    color: var(--text-primary);
}

.by-text {
    font-size: 0.75rem;
    font-weight: normal;
    color: var(--text-secondary);
    vertical-align: super;
    margin-left: 0.25rem;
}

.by-text a {
    color: var(--accent-blue);
    text-decoration: none;
}

.by-text a:hover {
    text-decoration: underline;
}

.dark .by-text {
    color: #94a3b8;
}

.update-info {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-top: 0.5rem;
}

.dark .update-info {
    color: #94a3b8;
}

.update-info a {
    color: var(--accent-blue);
    text-decoration: none;
}

.update-info a:hover {
    text-decoration: underline;
}

.theme-toggle {
    padding: 0.5rem;
    background-color: var(--bg-secondary);
    border: none;
    border-radius: 0.5rem;
    cursor: pointer;
    font-size: 1.5rem;
    transition: background-color 0.2s;
}

.theme-toggle:hover {
    background-color: var(--border-color);
}

/* =========================================================================
   Loading & Error States
   ========================================================================= */

.loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 50vh;
    gap: 1rem;
}

.spinner {
    width: 3rem;
    height: 3rem;
    border: 4px solid var(--border-color);
    border-top-color: var(--accent-blue);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.error {
    text-align: center;
    padding: 3rem 1rem;
    color: #ef4444;
}

/* =========================================================================
   Main Content
   ========================================================================= */

.main-content {
    padding: 2rem 1rem;
}

.card {
    background-color: var(--bg-card);
    border-radius: 0.5rem;
    box-shadow: var(--shadow-lg);
    padding: 1.5rem;
    margin-bottom: 2rem;
    border: 1px solid var(--border-color);
}

.card h2 {
    font-size: 1.5rem;
    font-weight: bold;
    margin-bottom: 1rem;
    color: var(--text-primary);
}

.section-subtitle {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
    margin-top: -0.5rem;
}

.dark .section-subtitle {
    color: #94a3b8;
}

.dark .card {
    background-color: #1e293b;
    border-color: #334155;
}

.generated-from {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: 1rem;
}

/* =========================================================================
   Global Stats
   ========================================================================= */

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

.stat-card {
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    padding: 1rem;
}

.dark .stat-card {
    background-color: #0f172a;
    border-color: #334155;
}

.stat-label {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
    font-weight: 500;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: bold;
    margin-bottom: 0.25rem;
    color: var(--text-primary);
}

.stat-subtext {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.dark .stat-label {
    color: #94a3b8;
}

.dark .stat-subtext {
    color: #94a3b8;
}

.allocations-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1rem;
}

.allocation-card {
    border-radius: 0.5rem;
    padding: 1rem;
    border: 1px solid;
}

.allocation-card.blue {
    background-color: rgba(59, 130, 246, 0.15);
    border-color: rgba(59, 130, 246, 0.4);
}

.dark .allocation-card.blue {
    background-color: rgba(59, 130, 246, 0.2);
    border-color: rgba(59, 130, 246, 0.5);
}

.allocation-card.green {
    background-color: rgba(16, 185, 129, 0.15);
    border-color: rgba(16, 185, 129, 0.4);
}

.dark .allocation-card.green {
    background-color: rgba(16, 185, 129, 0.2);
    border-color: rgba(16, 185, 129, 0.5);
}

.allocation-card.purple {
    background-color: rgba(139, 92, 246, 0.15);
    border-color: rgba(139, 92, 246, 0.4);
}

.dark .allocation-card.purple {
    background-color: rgba(139, 92, 246, 0.2);
    border-color: rgba(139, 92, 246, 0.5);
}

.allocation-label {
    font-size: 0.875rem;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: var(--text-primary);
}

.allocation-value {
    font-size: 1.25rem;
    font-weight: bold;
    color: var(--text-primary);
}

.dark .allocation-card.blue .allocation-label,
.dark .allocation-card.blue .allocation-value {
    color: #e0e7ff;
}

.dark .allocation-card.green .allocation-label,
.dark .allocation-card.green .allocation-value {
    color: #d1fae5;
}

.dark .allocation-card.purple .allocation-label,
.dark .allocation-card.purple .allocation-value {
    color: #ede9fe;
}

/* =========================================================================
   Search
   ========================================================================= */

.search-container {
    position: relative;
}

.search-input {
    width: 100%;
    padding: 0.75rem 1rem;
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    color: var(--text-primary);
    font-size: 1rem;
}

.search-input:focus {
    outline: none;
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.search-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    margin-top: 0.5rem;
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    box-shadow: var(--shadow-lg);
    max-height: 16rem;
    overflow-y: auto;
    z-index: 50;
    display: none;
}

.search-result-item {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
    transition: background-color 0.2s;
    color: var(--text-primary);
}

.search-result-item:last-child {
    border-bottom: none;
}

.search-result-item:hover {
    background-color: var(--bg-secondary);
}

.search-result-item .address-mono {
    color: var(--text-primary);
}

.search-result-item .text-sm {
    color: var(--text-secondary);
}

.dark .search-result-item {
    color: #f1f5f9;
}

.dark .search-result-item .address-mono {
    color: #e0e7ff;
}

.dark .search-result-item .text-sm {
    color: #94a3b8;
}

.selected-withdrawer {
    margin-top: 1rem;
}

.selected-tag {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem;
    background-color: rgba(59, 130, 246, 0.15);
    border: 1px solid rgba(59, 130, 246, 0.4);
    border-radius: 0.5rem;
}

.selected-tag .text-sm,
.selected-tag .address-mono {
    color: var(--text-primary);
}

.dark .selected-tag {
    background-color: rgba(59, 130, 246, 0.25);
    border-color: rgba(59, 130, 246, 0.6);
}

.dark .selected-tag .text-sm,
.dark .selected-tag .address-mono {
    color: #e0e7ff;
}

.close-btn {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-primary);
    padding: 0.25rem 0.5rem;
    border-radius: 0.25rem;
}

.close-btn:hover {
    background-color: rgba(0, 0, 0, 0.1);
}

/* =========================================================================
   Comparison
   ========================================================================= */

.comparison-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

.comparison-card {
    border-radius: 0.5rem;
    padding: 1.5rem;
    border: 1px solid;
}

.comparison-card.purple {
    background-color: rgba(139, 92, 246, 0.15);
    border-color: rgba(139, 92, 246, 0.4);
}

.dark .comparison-card.purple {
    background-color: rgba(139, 92, 246, 0.25);
    border-color: rgba(139, 92, 246, 0.6);
}

.dark .comparison-card.purple h3,
.dark .comparison-card.purple .comparison-row span,
.dark .comparison-card.purple .comparison-row strong {
    color: #ede9fe;
}

.comparison-card.blue {
    background-color: rgba(59, 130, 246, 0.15);
    border-color: rgba(59, 130, 246, 0.4);
}

.dark .comparison-card.blue {
    background-color: rgba(59, 130, 246, 0.25);
    border-color: rgba(59, 130, 246, 0.6);
}

.dark .comparison-card.blue h3,
.dark .comparison-card.blue .comparison-row span,
.dark .comparison-card.blue .comparison-row strong {
    color: #e0e7ff;
}

.comparison-card h3 {
    font-size: 1.125rem;
    margin-bottom: 1rem;
    color: var(--text-primary);
}

.comparison-stats {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.comparison-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.comparison-row span {
    color: var(--text-secondary);
}

.comparison-row strong {
    color: var(--text-primary);
}

.comparison-network {
    padding: 1.5rem;
    background-color: var(--bg-secondary);
    border-radius: 0.5rem;
    margin-bottom: 1.5rem;
}

.comparison-network h3 {
    font-size: 1.125rem;
    margin-bottom: 1rem;
    color: var(--text-primary);
}

.network-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
}

.network-grid > div {
    color: var(--text-primary);
}

.dark .network-grid .text-sm,
.dark .network-grid .text-lg,
.dark .network-grid .text-xs {
    color: #f1f5f9;
}

/* Progress Bars */
.progress-bar-container {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.progress-label {
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    margin-bottom: 0.5rem;
    color: var(--text-secondary);
}

.dark .progress-label {
    color: #e0e7ff;
}

.progress-bar {
    width: 100%;
    height: 0.75rem;
    background-color: rgba(0, 0, 0, 0.2);
    border-radius: 0.375rem;
    overflow: hidden;
}

.dark .progress-bar {
    background-color: rgba(0, 0, 0, 0.4);
}

.progress-fill {
    height: 100%;
    transition: width 0.3s ease;
    border-radius: 0.375rem;
}

.progress-fill.purple {
    background: linear-gradient(90deg, #8b5cf6 0%, #a78bfa 100%);
}

.progress-fill.blue {
    background: linear-gradient(90deg, #3b82f6 0%, #60a5fa 100%);
}

/* Vote Performance Section */
.vote-performance {
    padding: 1.5rem;
    background-color: var(--bg-secondary);
    border-radius: 0.5rem;
    margin-bottom: 1.5rem;
}

.vote-performance h3 {
    font-size: 1.125rem;
    margin-bottom: 1rem;
    color: var(--text-primary);
}

.vote-perf-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}

.vote-perf-card {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    padding: 1rem;
    text-align: center;
}

.dark .vote-perf-card {
    background-color: #1e293b;
    border-color: #334155;
}

.vote-perf-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    font-weight: 600;
}

.dark .vote-perf-label {
    color: #94a3b8;
}

.vote-perf-address {
    font-family: 'Courier New', monospace;
    font-size: 0.875rem;
    color: var(--accent-blue);
    margin-bottom: 0.5rem;
}

.vote-perf-value {
    font-size: 1.125rem;
    font-weight: bold;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}

.vote-perf-percent {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.dark .vote-perf-percent {
    color: #94a3b8;
}

/* =========================================================================
   Charts
   ========================================================================= */

.chart-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
}

.tab-button {
    padding: 0.5rem 1rem;
    background-color: var(--bg-secondary);
    border: none;
    border-radius: 0.5rem;
    cursor: pointer;
    color: var(--text-primary);
    font-weight: 500;
    transition: all 0.2s;
}

.tab-button:hover {
    background-color: var(--border-color);
}

.tab-button.active {
    background-color: var(--accent-blue);
    color: white;
}

.chart-container {
    position: relative;
    height: 400px;
}

/* =========================================================================
   Table
   ========================================================================= */

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

.table-controls {
    display: flex;
    gap: 1rem;
    align-items: center;
    flex-wrap: wrap;
}

.table-search-input {
    padding: 0.5rem 0.75rem;
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    color: var(--text-primary);
    font-size: 0.875rem;
    min-width: 200px;
}

.table-search-input:focus {
    outline: none;
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.table-controls select {
    padding: 0.25rem 0.5rem;
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 0.25rem;
    color: var(--text-primary);
    margin: 0 0.5rem;
}

.table-responsive {
    overflow-x: auto;
}

.rewards-table {
    width: 100%;
    border-collapse: collapse;
}

.rewards-table th {
    text-align: left;
    padding: 0.75rem;
    font-size: 0.875rem;
    font-weight: 600;
    border-bottom: 2px solid var(--border-color);
    color: var(--text-primary);
}

.rewards-table th.sortable {
    cursor: pointer;
    user-select: none;
}

.rewards-table th.sortable:hover {
    background-color: var(--bg-secondary);
}

.sort-icon {
    margin-left: 0.25rem;
    opacity: 0.5;
}

.rewards-table td {
    padding: 0.75rem;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-primary);
}

.rank-cell {
    font-weight: 600;
    color: var(--text-secondary);
}

.dark .rank-cell {
    color: #94a3b8;
}

.validator-cell {
    max-width: 200px;
}

.validator-info-inline {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.validator-icon-small {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
    border: 1px solid var(--border-color);
}

.validator-name-small {
    font-size: 0.813rem;
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.dark .validator-name-small {
    color: #f1f5f9;
}

.text-muted {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.dark .text-muted {
    color: #64748b;
}

.rewards-table tbody tr {
    transition: background-color 0.2s;
}

.rewards-table tbody tr:hover {
    background-color: var(--bg-secondary);
}

.rewards-table tbody tr.highlighted {
    background-color: rgba(59, 130, 246, 0.1);
}

.expand-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    color: var(--text-primary);
    border-radius: 0.25rem;
}

.expand-btn:hover {
    background-color: var(--border-color);
}

.expanded-row {
    background-color: var(--bg-secondary);
}

.vote-accounts {
    padding: 1rem;
}

.vote-accounts h4 {
    font-size: 0.875rem;
    margin-bottom: 0.75rem;
}

.vote-accounts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 0.5rem;
}

.vote-account-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem;
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 0.375rem;
    font-size: 0.75rem;
    gap: 0.75rem;
}

.vote-account-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex: 1;
    min-width: 0;
}

.validator-icon {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
    border: 2px solid var(--border-color);
}

.vote-account-details {
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
    min-width: 0;
}

.validator-name {
    font-weight: 600;
    font-size: 0.813rem;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.dark .validator-name {
    color: #f1f5f9;
}

.vote-account-details a {
    color: var(--accent-blue);
    text-decoration: none;
    font-size: 0.75rem;
}

.vote-account-details a:hover {
    text-decoration: underline;
}

.vote-account-credits {
    flex-shrink: 0;
    text-align: right;
    color: var(--text-secondary);
    font-family: 'Courier New', monospace;
}

.dark .vote-account-credits {
    color: #94a3b8;
}

.btn-explorer {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    background-color: var(--accent-blue);
    color: white;
    text-decoration: none;
    border-radius: 0.5rem;
    font-size: 0.75rem;
    transition: background-color 0.2s;
}

.btn-explorer:hover {
    background-color: #2563eb;
}

/* =========================================================================
   Pagination
   ========================================================================= */

.pagination {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 1.5rem;
    padding: 1rem 0;
    flex-wrap: wrap;
    gap: 1rem;
}

#paginationInfo {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.dark #paginationInfo {
    color: #94a3b8;
}

#paginationButtons {
    display: flex;
    gap: 0.25rem;
    align-items: center;
}

.btn-pagination {
    padding: 0.5rem 0.75rem;
    min-width: 2.5rem;
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 0.375rem;
    cursor: pointer;
    color: var(--text-primary);
    font-size: 0.875rem;
    font-weight: 500;
    transition: all 0.2s;
    text-align: center;
}

.btn-pagination:hover:not(:disabled) {
    background-color: var(--border-color);
    border-color: var(--accent-blue);
}

.btn-pagination.active {
    background-color: var(--accent-blue);
    color: white;
    border-color: var(--accent-blue);
}

.btn-pagination:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    background-color: var(--bg-secondary);
}

.dark .btn-pagination {
    background-color: #0f172a;
}

.dark .btn-pagination:hover:not(:disabled) {
    background-color: #334155;
}

/* =========================================================================
   Utilities
   ========================================================================= */

.address-mono {
    font-family: 'Courier New', monospace;
    font-size: 0.875rem;
}

.mono {
    font-family: 'Courier New', monospace;
}

.text-right {
    text-align: right;
}

.text-center {
    text-align: center;
}

.text-sm {
    font-size: 0.875rem;
}

.text-xs {
    font-size: 0.75rem;
}

.text-lg {
    font-size: 1.125rem;
}

.font-bold {
    font-weight: bold;
}

.font-medium {
    font-weight: 500;
}

.text-green {
    color: var(--accent-green);
}

.dark .text-green {
    color: #34d399;
}

.text-purple {
    color: var(--accent-purple);
}

.dark .text-purple {
    color: #a78bfa;
}

.text-red {
    color: #ef4444;
}

.dark .text-red {
    color: #f87171;
}

.btn-primary {
    display: inline-block;
    padding: 0.75rem 1.5rem;
    background-color: var(--accent-blue);
    color: white;
    text-decoration: none;
    border-radius: 0.5rem;
    font-weight: 500;
    transition: background-color 0.2s;
}

.btn-primary:hover {
    background-color: #2563eb;
}

.button-group {
    display: flex;
    gap: 1rem;
    justify-content: center;
    margin-top: 1.5rem;
}

/* =========================================================================
   Responsive
   ========================================================================= */

/* Mobile - Small devices */
@media (max-width: 640px) {
    .container {
        padding: 0 0.75rem;
    }

    .header-content {
        padding: 1rem 0;
        flex-wrap: wrap;
        gap: 0.75rem;
    }

    .header h1 {
        font-size: 1.25rem;
        line-height: 1.3;
    }

    .by-text {
        display: block;
        margin-left: 0;
        margin-top: 0.25rem;
        vertical-align: baseline;
    }

    .theme-toggle {
        width: 36px;
        height: 36px;
    }

    .update-info {
        font-size: 0.75rem;
    }

    .card {
        padding: 1rem;
        margin-bottom: 1rem;
    }

    .card h2 {
        font-size: 1.25rem;
        margin-bottom: 0.75rem;
    }

    .section-subtitle {
        font-size: 0.813rem;
        margin-bottom: 0.75rem;
    }

    .stats-grid,
    .allocations-grid,
    .comparison-grid,
    .network-grid {
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }

    .stat-card {
        padding: 0.875rem;
    }

    .stat-label {
        font-size: 0.75rem;
    }

    .stat-value {
        font-size: 1.25rem;
    }

    /* Chart tabs - make scrollable on mobile */
    .chart-tabs {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        flex-wrap: nowrap;
        gap: 0.5rem;
        padding-bottom: 0.5rem;
    }

    .tab-button {
        padding: 0.5rem 0.75rem;
        font-size: 0.813rem;
        white-space: nowrap;
        flex-shrink: 0;
    }

    .chart-container {
        height: 350px;
    }

    /* Search */
    .search-input,
    .table-search-input {
        font-size: 1rem; /* Prevent zoom on iOS */
        padding: 0.75rem;
    }

    .search-result-item {
        padding: 0.75rem;
        font-size: 0.875rem;
    }

    /* Table - make scrollable horizontally */
    .table-responsive {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        margin: 0 -1rem;
        padding: 0 1rem;
    }

    .rewards-table {
        font-size: 0.75rem;
        min-width: 800px; /* Force horizontal scroll for full table */
    }

    .rewards-table th,
    .rewards-table td {
        padding: 0.5rem 0.375rem;
        white-space: nowrap;
    }

    .rewards-table .address-mono {
        font-size: 0.688rem;
    }

    /* Validator cell - stack icon and name on mobile */
    .validator-info-inline {
        flex-direction: column;
        gap: 0.25rem;
        align-items: flex-start;
    }

    .validator-icon-small {
        width: 20px;
        height: 20px;
    }

    .validator-name-small {
        font-size: 0.75rem;
    }

    /* Table controls */
    .table-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }

    .table-controls {
        flex-direction: column;
        width: 100%;
        gap: 0.5rem;
    }

    .table-controls input {
        width: 100%;
        font-size: 1rem;
    }

    .table-controls label {
        width: 100%;
        font-size: 0.875rem;
    }

    .table-controls select {
        font-size: 1rem;
        padding: 0.5rem;
    }

    /* Pagination */
    .pagination {
        flex-direction: column;
        gap: 0.75rem;
        font-size: 0.813rem;
    }

    .pagination-buttons {
        flex-wrap: wrap;
        justify-content: center;
        gap: 0.375rem;
    }

    .pagination button {
        padding: 0.5rem 0.75rem;
        font-size: 0.813rem;
        min-width: 36px;
    }

    /* Expanded row details */
    .vote-accounts-list {
        font-size: 0.813rem;
    }

    .vote-account-item {
        padding: 0.5rem;
    }

    /* Comparison section */
    .comparison-cards {
        flex-direction: column;
    }

    .comparison-stat {
        padding: 0.75rem;
    }

    .comparison-stat .label {
        font-size: 0.75rem;
    }

    .comparison-stat .value {
        font-size: 1.125rem;
    }

    .progress-bar-container {
        margin-top: 0.5rem;
    }

    /* Button group */
    .button-group {
        flex-direction: column;
        gap: 0.5rem;
    }

    .btn-primary {
        width: 100%;
        padding: 0.75rem;
    }

    /* Generated from text */
    .generated-from {
        font-size: 0.75rem;
        margin-bottom: 0.75rem;
    }

    /* Loading and error states */
    .loading p,
    .error h2,
    .error p {
        font-size: 0.938rem;
    }

    .spinner {
        width: 40px;
        height: 40px;
    }
}

/* Tablet - Medium devices */
@media (min-width: 641px) and (max-width: 1024px) {
    .header h1 {
        font-size: 1.5rem;
    }

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

    .allocations-grid,
    .comparison-grid,
    .network-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .chart-container {
        height: 350px;
    }

    .rewards-table {
        font-size: 0.875rem;
    }

    .table-header {
        flex-wrap: wrap;
        gap: 1rem;
    }

    .table-controls {
        flex-wrap: wrap;
    }
}

/* Landscape mobile fix */
@media (max-width: 900px) and (orientation: landscape) {
    .chart-container {
        height: 280px;
    }

    .header-content {
        padding: 0.75rem 0;
    }
}

/* Touch device optimizations */
@media (hover: none) and (pointer: coarse) {
    /* Make all interactive elements larger for touch */
    button,
    .tab-button,
    .sortable {
        min-height: 44px; /* iOS recommended touch target */
    }

    .pagination button {
        min-width: 44px;
        min-height: 44px;
    }

    /* Improve table row tap targets */
    .rewards-table tr {
        cursor: pointer;
    }
}
