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

html {
    font-size: 16px; /* Reset to standard base size */
    font-family: Arial, Helvetica, sans-serif;
    line-height: 1.5;
    scroll-behavior: smooth;
}

body {
    color: #222;
    background: linear-gradient(135deg, #293c8e 0%, #ffffff 100%);
    min-height: 100vh;
    padding: 0 15px; /* Add space on both sides */
}

/* ===========================
   SKIP LINK
=========================== */
.skip-link {
    position: absolute;
    top: -40px;
    left: 0;
    background: #4c5eaa;
    color: #fff;
    padding: 8px 12px;
    z-index: 1000;
    text-decoration: none;
    transition: top 0.3s ease-in-out;
}

.skip-link:focus {
    top: 0;
}

/* ===========================
   LAYOUT & CONTAINERS
=========================== */
.site-header {
    background: linear-gradient(135deg, #2c3e50 0%, #3498db 100%);
    color: white;
    padding: 1rem;
    text-align: center;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.site-header h1 {
    margin-bottom: 0.5rem;
    font-size: 1.8rem; /* Better size for header */
    text-shadow: 1px 1px 2px rgba(0,0,0,0.3);
}

.main-nav ul {
    list-style: none;
    display: flex;
    justify-content: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.main-nav a {
    color: white;
    text-decoration: none;
    padding: 0.5rem 1rem;
    border-radius: 25px;
    transition: all 0.3s ease;
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.2);
    font-size: 0.9rem;
}

.main-nav a:hover,
.main-nav a:focus {
    background: rgba(255,255,255,0.2);
    outline: 2px solid #1e202b;
    transform: translateY(-2px);
}

/* ===========================
   MAIN CONTENT
=========================== */
main {
    max-width: 1200px;
    width: 100%;
    margin: 0 auto;
    padding: 0 10px;
}

/* ===========================
   COMPACT SECTIONS
=========================== */
section {
    margin: 1rem 0;
    padding: 1.5rem;
    background: linear-gradient(135deg, #334697 0%, #829db6 100%);
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
    border: 1px solid rgba(255,255,255,0.5);
    backdrop-filter: blur(10px);
}

/* Individual section backgrounds */
#about {
    background: linear-gradient(135deg, #2d3659 0%, #031a29 100%);
    border-left: 4px solid #2196f3;
}

#dashboard {
    background: linear-gradient(135deg, #1a234a 0%, #4c5eaa 100%);
    border-left: 4px solid #4c7eaf;
}

#add-record {
    background: linear-gradient(135deg, #0d1c5e 0%, #0f1635 100%);
    border-left: 4px solid #242f5e;
}

/* ===========================
   COMPACT FORMS
=========================== */
#add-record h2 {
    font-size: 1.4rem;
    margin-bottom: 1.2rem;
    color: #ffffff;
}

.form-group {
    margin-bottom: 1.2rem;
}

label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    font-size: 0.9rem;
    color: #ffffff;
}

input, select {
    width: 100%;
    padding: 0.7rem 0.8rem; /* Better padding */
    border: 2px solid #af7d41;
    border-radius: 8px;
    font-size: 0.95rem; /* Better readable size */
    background: white;
    transition: all 0.3s ease;
    min-height: 44px; /* Better touch target */
}

input:focus, select:focus {
    outline: none;
    border-color: #021a2b;
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
    transform: translateY(-1px);
}

#add-btn {
    width: auto;
    min-width: 160px;
    padding: 0.8rem 2rem;
    background: linear-gradient(135deg, #2e47b3 0%, #151916 100%);
    color: #ffffff;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    margin-top: 1rem;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(39, 174, 96, 0.3);
    min-height: 48px;
}

#add-btn:hover {
    background: linear-gradient(135deg, #171918 0%, #4c5eaa 100%);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(255, 255, 255, 0.4);
}

/* ===========================
   ERROR STATES
=========================== */
.error-msg {
    font-size: 0.8rem;
    color: #e74c3c;
    margin-top: 0.5rem;
    display: block;
    font-weight: 500;
}

input:invalid, select:invalid {
    border-color: #e74c3c;
}

/* ===========================
   TABLE
=========================== */
table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 1rem;
    background: white;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

th, td {
    padding: 0.8rem 1rem; /* Better padding */
    text-align: left;
    border-bottom: 1px solid #e1e8ed;
    font-size: 0.9rem;
}

th {
    background: linear-gradient(135deg, #34495e 0%, #2c3e50 100%);
    color: white;
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.8rem;
    letter-spacing: 0.5px;
}

tr:hover {
    background: #1f4368;
    transition: background 0.3s ease;
}

/* Button variants */
.btn-edit, .btn-delete {
    padding: 0.4rem 0.8rem !important;
    font-size: 0.8rem !important;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 600;
    min-height: 32px;
}

.btn-edit {
    background: linear-gradient(135deg, #0a1e75 0%, #30418a 100%) !important;
    color: white;
    box-shadow: 0 2px 8px rgba(198, 197, 196, 0.3);
}

.btn-edit:hover {
    background: linear-gradient(135deg, #e67e22 0%, #f39c12 100%) !important;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(243, 156, 18, 0.4);
}

.btn-delete {
    background: linear-gradient(135deg, #e74c3c 0%, #c0392b 100%) !important;
    color: white;
    box-shadow: 0 2px 8px rgba(231, 76, 60, 0.3);
}

.btn-delete:hover {
    background: linear-gradient(135deg, #c0392b 0%, #e74c3c 100%) !important;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(231, 76, 60, 0.4);
}

.actions {
    white-space: nowrap;
}

/* ===========================
   SEARCH ENHANCEMENTS
=========================== */
.search-bar {
    margin-bottom: 1rem;
    position: relative;
}

.search-feedback {
    font-size: 0.875rem;
    margin-top: 0.5rem;
    padding: 0.5rem 0.75rem;
    border-radius: 6px;
    font-weight: 500;
}

.search-feedback.success {
    background: linear-gradient(135deg, #30418a 0%, #c3e6cb 100%);
    color: #155724;
    border: 1px solid #c3e6cb;
}

.search-feedback.error {
    background: linear-gradient(135deg, #f8d7da 0%, #f5c6cb 100%);
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.match-count {
    font-weight: bold;
    margin-left: 0.5rem;
}

.search-stats {
    font-size: 0.875rem;
    color: #6c757d;
    margin-bottom: 1rem;
    font-style: italic;
}

/* Search options */
.search-options {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-top: 0.5rem;
    flex-wrap: wrap;
}

.search-options label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.8rem;
    margin-bottom: 0;
}

.search-options input[type="checkbox"] {
    width: auto;
}

.search-hint {
    color: #ffffff;
    font-size: 0.8rem;
    font-style: italic;
}

/* Highlight styles */
mark {
    background: linear-gradient(135deg, #2e47b3 0%, #3c5d7c 100%);
    padding: 0.1em 0.3em;
    border-radius: 4px;
    font-weight: 600;
}

/* ===========================
   DASHBOARD - PROPER SIZING
=========================== */
#dashboard h2 {
    font-size: 1.4rem;
    margin-bottom: 1.2rem;
    color: #ffffff;
}

#stats {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
    margin-bottom: 0;
}

.stat-card {
    background: linear-gradient(135deg, #1a234a 0%, #2d3b78 100%);
    padding: 1.2rem;
    border-radius: 12px;
    text-align: center;
    border: 1px solid rgba(255,255,255,0.3);
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(135deg, #3498db, #080b09);
}

.stat-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(0,0,0,0.15);
}

.stat-card h3 {
    font-size: 0.8rem;
    color: #e0e0e0;
    margin-bottom: 0.5rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-card p {
    font-size: 1.3rem;
    font-weight: bold;
    color: #ffffff;
    margin: 0;
}

.stat-card .usd-amount {
    font-size: 0.8rem;
    color: #b0b0b0;
    margin-top: 0.3rem;
}

/* Specific styling for cap status */
#cap-status {
    font-size: 0.85rem;
    font-weight: 600;
}

/* ===========================
   SETTINGS IMPROVEMENTS
=========================== */
.settings-explanation {
    background: linear-gradient(135deg, #072953 0%, #303233 100%);
    padding: 1.2rem;
    border-radius: 8px;
    margin-bottom: 1.5rem;
    border-left: 4px solid #171819;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.settings-explanation ul {
    margin-left: 1.5rem;
}

.settings-explanation li {
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
}

.field-hint {
    color: #ffffff;
    font-size: 0.75rem;
    font-style: italic;
    display: block;
    margin-top: 0.25rem;
}

/* Form buttons container */
.form-buttons {
    display: flex;
    gap: 1rem;
    margin-top: 1.5rem;
}

.form-buttons button {
    flex: 1;
    padding: 0.8rem 1.5rem;
    border: none;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    min-height: 44px;
}

#save-settings {
    background: linear-gradient(135deg, #3498db 0%, #2980b9 100%);
    color: white;
    box-shadow: 0 4px 12px rgba(52, 152, 219, 0.3);
}

#save-settings:hover {
    background: linear-gradient(135deg, #2980b9 0%, #3498db 100%);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(52, 152, 219, 0.4);
}

#import-sample {
    background: linear-gradient(135deg, #9b59b6 0%, #8e44ad 100%);
    color: white;
    box-shadow: 0 4px 12px rgba(155, 89, 182, 0.3);
}

#import-sample:hover {
    background: linear-gradient(135deg, #8e44ad 0%, #9b59b6 100%);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(155, 89, 182, 0.4);
}

/* ===========================
   FOOTER
=========================== */
footer {
    text-align: center;
    padding: 1.5rem;
    background: linear-gradient(135deg, #0b2947 0%, #34495e 100%);
    color: white;
    margin-top: 2rem;
    box-shadow: 0 -4px 12px rgba(0,0,0,0.1);
}

/* ===========================
   ACCESSIBILITY
=========================== */
:focus {
    outline: 3px solid #3498db;
    outline-offset: 2px;
}

[aria-live="polite"], [aria-live="assertive"] {
    padding: 0.5rem;
    border-radius: 4px;
}

.contact-info {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid #eee;
}

.contact-info a {
    color: #3498db;
    text-decoration: none;
    font-weight: 600;
}

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

/* Category tags in table */
.category-tag {
    background: linear-gradient(135deg, #131a39 0%, #101e2c 100%);
    padding: 0.3rem 0.7rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    color: #ffffff;
    border: 1px solid #ced4da;
}

/* ===========================
   RESPONSIVE DESIGN
=========================== */
@media (max-width: 768px) {
    body {
        padding: 0 10px;
    }

    .site-header {
        padding: 0.75rem;
    }

    .site-header h1 {
        font-size: 1.4rem;
    }

    .main-nav ul {
        gap: 0.5rem;
    }

    .main-nav a {
        padding: 0.4rem 0.8rem;
        font-size: 0.8rem;
    }

    main {
        padding: 0;
    }

    section {
        padding: 1rem;
        margin: 0.75rem 0;
    }

    #stats {
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }

    .stat-card {
        padding: 1rem;
    }

    .search-options {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }

    .form-buttons {
        flex-direction: column;
    }

    input, select {
        font-size: 0.9rem;
        padding: 0.6rem 0.7rem;
    }
}

@media (min-width: 1024px) {
    #stats {
        grid-template-columns: repeat(4, 1fr);
    }

    .stat-card {
        padding: 1.2rem;
    }

    .stat-card h3 {
        font-size: 0.75rem;
    }

    .stat-card p {
        font-size: 1.4rem;
    }
}

/* Animation for new elements */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

section {
    animation: fadeInUp 0.5s ease-out;
}

/* Hover effects for interactive elements */
button, .main-nav a, .stat-card {
    transition: all 0.3s ease;
}

/* Loading animation */
@keyframes pulse {
    0% { opacity: 1; }
    50% { opacity: 0.5; }
    100% { opacity: 1; }
}

.loading {
    animation: pulse 1.5s ease-in-out infinite;
}