:root {
    --primary: #1a4480;
    --secondary: #4a7c59;
    --accent: #8b5a2b;
    --bg: #f8f9fa;
    --card: #ffffff;
    --text: #333333;
    --text-light: #555555;
    --border: #dee2e6;
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    line-height: 1.6;
    color: var(--text);
    background-color: var(--bg);
    margin: 0;
    padding: 0;
}

/* Layout */
.site-wrapper {
    display: flex;
    min-height: 100vh;
    flex-direction: column;
}

.top-bar {
    background: var(--primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.logo {
    font-weight: 700;
    font-size: 1.1rem;
    color: white;
    text-decoration: none;
}

.logo:hover {
    text-decoration: none;
}

.hamburger {
    display: none;
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.5);
    color: white;
    border-radius: 6px;
    padding: 0.6rem 0.9rem;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    touch-action: manipulation;
}

.hamburger:hover {
    background: rgba(255, 255, 255, 0.25);
}

.hamburger:focus-visible {
    outline: 3px solid white;
    outline-offset: 2px;
}

.main-layout {
    display: flex;
    flex: 1;
}

.sidebar {
    width: 260px;
    background: var(--card);
    border-right: 1px solid var(--border);
    padding: 1.5rem 0;
    flex-shrink: 0;
}

.sidebar-nav {
    width: 100%;
}

.nav-section {
    border-bottom: 1px solid var(--border);
}

.nav-toggle {
    width: 100%;
    background: none;
    border: none;
    text-align: left;
    padding: 0.85rem 1.25rem;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--primary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.nav-toggle:hover,
.nav-toggle:focus {
    background: var(--bg);
}

.nav-toggle::after {
    content: "+";
    font-size: 1.1rem;
    line-height: 1;
}

.nav-toggle[aria-expanded="true"]::after {
    content: "−";
}

.nav-panel {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.25s ease-out;
}

.nav-panel.open {
    max-height: 500px;
}

.nav-panel ul {
    list-style: none;
    margin: 0;
    padding: 0 0 0.75rem 0;
}

.nav-panel a {
    display: block;
    padding: 0.55rem 1.75rem;
    color: var(--text);
    text-decoration: none;
    font-size: 0.92rem;
    border-left: 4px solid transparent;
}

.nav-panel a:hover,
.nav-panel a:focus {
    background: var(--bg);
    color: var(--primary);
}

.nav-panel a.current {
    background: #e8f0fa;
    color: var(--primary);
    border-left-color: var(--secondary);
    font-weight: 600;
}

.content-area {
    flex: 1;
    min-width: 0;
}

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

/* Hero */
.hero {
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    color: white;
    padding: 4rem 1rem;
    text-align: center;
}

.hero h1 {
    margin: 0 0 0.75rem 0;
    font-size: clamp(2rem, 5vw, 3rem);
    line-height: 1.2;
}

.hero .subheadline {
    margin: 0 auto 1.5rem auto;
    font-size: clamp(1rem, 2.5vw, 1.25rem);
    opacity: 0.95;
    max-width: 700px;
}

.hero-intro {
    max-width: 700px;
    margin: 0 auto 2rem auto;
    font-size: 1.05rem;
    opacity: 0.92;
}

.cta-group {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
}

.btn {
    display: inline-block;
    padding: 0.75rem 1.5rem;
    border-radius: 6px;
    font-weight: 600;
    text-decoration: none;
    transition: transform 0.1s ease, box-shadow 0.1s ease;
}

.btn:hover {
    transform: translateY(-1px);
    text-decoration: none;
}

.btn-primary {
    background: white;
    color: var(--primary);
}

.btn-primary:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.btn-secondary {
    background: transparent;
    color: white;
    border: 2px solid white;
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* Cards */
.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 1.5rem;
    margin-top: 1.5rem;
}

.card {
    background: var(--card);
    border-radius: 8px;
    box-shadow: var(--shadow);
    padding: 1.75rem;
    margin-bottom: 1.75rem;
    border-left: 5px solid var(--primary);
}

.card:nth-child(odd) {
    border-left-color: var(--secondary);
}

.card:nth-child(even) {
    border-left-color: var(--accent);
}

.card-link {
    text-decoration: none;
    color: inherit;
    display: block;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.card-link:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.1);
}

.card-link h3 {
    color: var(--primary);
    margin-top: 0;
    font-size: 1.2rem;
}

.card-link p {
    color: var(--text-light);
    margin-bottom: 0;
    font-size: 0.95rem;
}

h2 {
    color: var(--primary);
    margin-top: 0;
    font-size: 1.8rem;
    border-bottom: 2px solid var(--border);
    padding-bottom: 0.5rem;
}

h3 {
    color: var(--secondary);
    margin-top: 1.5rem;
    margin-bottom: 0.5rem;
    font-size: 1.25rem;
}

ul,
ol {
    margin-top: 0.5rem;
    padding-left: 1.5rem;
}

li {
    margin-bottom: 0.5rem;
}

a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 500;
}

a:hover {
    text-decoration: underline;
}

.highlight {
    background-color: #fff3cd;
    padding: 1rem;
    border-left: 4px solid var(--accent);
    margin: 1rem 0;
    border-radius: 4px;
}

.contact-box {
    background-color: #e8f4f8;
    padding: 1rem;
    border-radius: 6px;
    margin-top: 1rem;
}

/* Tables */
table {
    width: 100%;
    border-collapse: collapse;
    margin: 1rem 0;
}

th,
td {
    border: 1px solid var(--border);
    padding: 0.75rem;
    text-align: left;
}

th {
    background-color: var(--primary);
    color: white;
}

tr:nth-child(even) {
    background-color: #f8f9fa;
}

.badge {
    display: inline-block;
    background-color: var(--secondary);
    color: white;
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

footer {
    text-align: center;
    padding: 2rem 1rem;
    color: var(--text-light);
    font-size: 0.9rem;
    background: var(--bg);
    border-top: 1px solid var(--border);
}

footer p {
    margin: 0.25rem 0;
}

/* Form & printable record-keeping styles */
.form-field {
    border: 1px solid var(--border);
    min-height: 2rem;
    padding: 0.5rem;
    background-color: #fff;
    margin-bottom: 0.75rem;
    border-radius: 4px;
}

.form-label {
    font-weight: 600;
    display: block;
    margin-bottom: 0.25rem;
    color: var(--primary);
}

.two-col {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.checklist {
    list-style: none;
    padding-left: 0;
}

.checklist li {
    position: relative;
    padding-left: 1.75rem;
    margin-bottom: 0.75rem;
}

.checklist li::before {
    content: "☐";
    position: absolute;
    left: 0;
    font-size: 1.2rem;
    color: var(--primary);
}

.template-box {
    background-color: #f1f3f5;
    border: 1px dashed var(--border);
    padding: 1rem;
    border-radius: 4px;
    font-style: italic;
    margin: 1rem 0;
}

.template-box strong {
    font-style: normal;
}

.placeholder-note {
    color: var(--text-light);
    font-style: italic;
}

/* AI Grant Assistant */
.assistant-panel {
    background: #f1f5f9;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1.5rem;
    margin-top: 1.5rem;
}

.assistant-status {
    display: inline-block;
    padding: 0.35rem 0.75rem;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 1rem;
}

.assistant-status.ok {
    background-color: #d1fae5;
    color: #065f46;
}

.assistant-status.error {
    background-color: #fee2e2;
    color: #991b1b;
}

.assistant-form label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.35rem;
    color: var(--primary);
}

.assistant-form select,
.assistant-form textarea {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-family: inherit;
    font-size: 1rem;
    margin-bottom: 1rem;
    background: white;
}

.assistant-form textarea {
    min-height: 140px;
    resize: vertical;
}

.assistant-form .hint {
    font-size: 0.9rem;
    color: var(--text-light);
    margin-top: -0.75rem;
    margin-bottom: 1rem;
}

.assistant-output {
    background: white;
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 1rem;
    min-height: 120px;
    white-space: pre-wrap;
    margin-top: 1rem;
}

.assistant-actions {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    margin-top: 1rem;
}

.btn-assistant {
    background: var(--primary);
    color: white;
    border: none;
    padding: 0.75rem 1.25rem;
    border-radius: 6px;
    font-weight: 600;
    cursor: pointer;
    font-size: 1rem;
}

.btn-assistant:hover {
    background: #143a6d;
}

.btn-assistant:disabled {
    background: #9ca3af;
    cursor: not-allowed;
}

.btn-secondary-action {
    background: white;
    color: var(--primary);
    border: 1px solid var(--primary);
    padding: 0.75rem 1.25rem;
    border-radius: 6px;
    font-weight: 600;
    cursor: pointer;
    font-size: 1rem;
}

.btn-secondary-action:hover {
    background: var(--bg);
}

/* Mobile */
@media (max-width: 768px) {
    .hamburger {
        display: block;
    }

    .main-layout {
        flex-direction: column;
        position: relative;
    }

    .sidebar {
        width: 100%;
        border-right: none;
        border-bottom: 1px solid var(--border);
        padding: 0;
        max-height: 0;
        overflow: hidden;
        opacity: 0;
        transition: max-height 0.35s ease, opacity 0.25s ease, padding 0.25s ease;
        will-change: max-height, opacity;
    }

    .sidebar.open {
        max-height: 600px;
        opacity: 1;
        padding: 0.5rem 0;
    }

    .nav-toggle {
        padding: 1rem 1.25rem;
        min-height: 48px;
    }

    .nav-panel a {
        padding: 0.75rem 1.75rem;
        min-height: 44px;
        display: flex;
        align-items: center;
    }

    .hero {
        padding: 2.5rem 1rem;
    }

    .card {
        padding: 1.25rem;
    }

    .two-col {
        grid-template-columns: 1fr;
    }

    /* Make wide tables scrollable on small screens */
    .card > table {
        display: block;
        width: 100%;
        overflow-x: auto;
        white-space: nowrap;
        -webkit-overflow-scrolling: touch;
    }

    .card > table th,
    .card > table td {
        white-space: normal;
        min-width: 120px;
    }
}

@media (max-width: 600px) {
    h2 {
        font-size: 1.5rem;
    }

    th,
    td {
        padding: 0.55rem;
        font-size: 0.9rem;
    }
}

/* Print styles */
@media print {
    .no-print,
    .top-bar,
    .sidebar,
    .hamburger,
    .hero .cta-group,
    .hero-intro {
        display: none !important;
    }

    body {
        background: white;
        color: black;
    }

    .site-wrapper,
    .main-layout,
    .content-area {
        display: block;
    }

    .hero {
        background: white !important;
        color: black !important;
        padding: 1rem;
        border-bottom: 2px solid #333;
        text-align: left;
    }

    .hero h1,
    .hero .subheadline {
        color: black;
    }

    .container {
        max-width: 100%;
        padding: 0;
    }

    .card {
        box-shadow: none;
        border: 1px solid #ccc;
        break-inside: avoid;
        page-break-inside: avoid;
        margin-bottom: 1rem;
    }

    a {
        color: black;
        text-decoration: none;
    }

    a[href]::after {
        content: " (" attr(href) ")";
        font-size: 0.8rem;
        word-break: break-all;
    }

    .card-link:hover {
        transform: none;
        box-shadow: none;
    }

    .form-field {
        border: 1px solid #999;
        background: white;
    }

    table {
        font-size: 0.9rem;
    }

    footer {
        border-top: 1px solid #ccc;
    }
}
