:root {
    --bg: #ffffff;
    --surface: #f5f6f8;
    --text: #404040;
    --muted: #555e68;
    --border: #c9ced6;
    --link: #0074db;
    --accent: #203f93;
    --accent-text: #ffffff;
    --danger: #b3261e;
    --success-bg: #e7f4ea;
    --success-border: #2e7d32;
    --warning-bg: #fff4e0;
    --warning-border: #a15c00;
    --error-bg: #fdecea;
    --focus: #f2b600;
    color-scheme: light;
}

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

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font: 400 1rem/1.6 "Open Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

.wrap { max-width: 64rem; margin: 0 auto; padding: 0 1rem; }

a { color: var(--link); }
a:hover { text-decoration-thickness: 2px; }

:focus-visible {
    outline: 3px solid var(--focus);
    outline-offset: 2px;
}
main:focus { outline: none; }

.skip-link {
    position: absolute;
    left: 1rem;
    top: -10rem;
    background: var(--bg);
    padding: .5rem 1rem;
    z-index: 10;
}
.skip-link:focus { top: .5rem; }

.visually-hidden {
    position: absolute !important;
    width: 1px; height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}

/* Header & footer (matches pueblolevee.org) */
.site-header { background: #0f0f0f; box-shadow: 0 5px 15px rgba(0,0,0,.08); position: relative; z-index: 20; }
.header-inner {
    max-width: 1120px; margin: 0 auto; padding: .75rem 20px;
    display: flex; align-items: center; justify-content: space-between; gap: 1rem;
}
.logo img { display: block; height: 30px; width: auto; }
.main-nav { font-family: "Source Sans 3", "Source Sans Pro", sans-serif; }
.main-nav ul { list-style: none; margin: 0; padding: 0; }
.main-nav > ul { display: flex; align-items: center; gap: .25rem; }
.main-nav li { position: relative; }
.main-nav a { display: block; padding: 10px 12px; color: #efefef; text-decoration: none; font-size: 1.05rem; }
.main-nav a:hover, .main-nav a:focus-visible { color: #fff; text-decoration: underline; }
.main-nav .has-sub > a::after { content: ""; display: inline-block; margin-left: .4rem; border: solid currentColor; border-width: 0 2px 2px 0; padding: 2px; transform: translateY(-2px) rotate(45deg); }
.sub-menu { display: none; position: absolute; left: 0; top: 100%; min-width: 15rem; background: #0f0f0f; box-shadow: 0 10px 25px rgba(0,0,0,.3); z-index: 30; }
.has-sub:hover > .sub-menu, .has-sub:focus-within > .sub-menu { display: block; }
.sub-menu a { padding: 10px 16px; white-space: nowrap; border-left: 3px solid transparent; }
.sub-menu a:hover, .sub-menu a:focus-visible { border-left-color: #203f93; background: #1b1b1b; text-decoration: none; }

.nav-toggle { display: none; background: none; border: 0; padding: 8px; cursor: pointer; }
.nav-toggle span { display: block; width: 28px; height: 3px; background: rgba(255,255,255,.85); margin: 5px 0; border-radius: 2px; }

/* Left sidebar */
.layout { display: grid; grid-template-columns: 15.5rem minmax(0, 1fr); align-items: start; max-width: 1120px; margin: 0 auto; }
.layout > main.wrap { margin: 0; max-width: none; width: 100%; padding-left: 2.5rem; padding-right: 20px; }

.side-nav {
    font-family: "Source Sans 3", "Source Sans Pro", sans-serif;
    background: #fff; color: #1d2a4d;
    padding: 3.5rem 0 2rem;
    align-self: stretch;
}
.side-nav ul { list-style: none; margin: 0; padding: 0; }
.side-nav ul ul { margin-left: .75rem; }
.side-heading {
    font: 600 .75rem/1 "Source Sans 3", "Source Sans Pro", sans-serif; letter-spacing: .08em; text-transform: uppercase;
    color: #4a5a80; margin: 1.5rem 0 .5rem; padding: 0 1.25rem;
}
.side-heading:first-child { margin-top: 0; }
.side-nav a, .side-nav .link-button, .side-group {
    display: block; padding: 8px 1.25rem; color: #1d2a4d; text-decoration: none;
    font: inherit; font-size: 1rem; border-left: 3px solid transparent;
}
.side-group { color: #1d2a4d; font-weight: 600; }
.side-nav a:hover, .side-nav a:focus-visible, .side-nav .link-button:hover {
    color: #203f93; background: #d6e0f5; border-left-color: #203f93; text-decoration: none;
}
.side-nav a[aria-current="page"] { color: #203f93; font-weight: 600; background: #d0dcf3; border-left-color: #203f93; }
.side-nav .link-button { cursor: pointer; background: none; border-top: 0; border-right: 0; border-bottom: 0; text-align: left; width: 100%; }
.side-nav form.inline { display: block; }

@media (max-width: 62rem) {
    .nav-toggle { display: block; }
    .main-nav { display: none; position: absolute; left: 0; right: 0; top: 100%; background: #0f0f0f; box-shadow: 0 10px 25px rgba(0,0,0,.3); }
    .nav-open .main-nav { display: block; }
    .main-nav > ul { flex-direction: column; align-items: stretch; padding: .5rem 20px 1rem; gap: 0; }
    .sub-menu { display: block; position: static; box-shadow: none; padding-left: 1rem; min-width: 0; }
    .sub-menu a { white-space: normal; }
    .main-nav .has-sub > a::after { display: none; }
    .layout { display: block; }
    .side-nav { padding-bottom: 1rem; }
    .layout > main.wrap { padding-left: 1rem; padding-right: 1rem; margin: 0 auto; }
}

.site-footer { background: #191919; color: rgba(255,255,255,.8); margin-top: 3rem; font-weight: 300; font-size: .9rem; }
.footer-inner { max-width: 1120px; margin: 0 auto; padding: 3rem 20px 2rem; }
.footer-top { display: grid; grid-template-columns: 2fr 1fr; gap: 3rem; }
.footer-logo { height: 30px; width: auto; display: block; margin-bottom: 1rem; }
.footer-about p { margin: 0; max-width: 34rem; }
.footer-nav ul { list-style: none; margin: 0; padding: 0; }
.footer-nav a { display: block; padding: 6px 10px; color: rgba(255,255,255,.8); text-decoration: none; border-left: 3px solid transparent; }
.footer-nav a:hover, .footer-nav a:focus-visible { color: #fff; border-left-color: #203f93; text-decoration: none; }
.site-footer hr { border: 0; height: 1px; background: #353535; margin: 2rem 0 1.25rem; }
.copyright { margin: 0 0 .25rem; }
@media (max-width: 48rem) { .footer-top { grid-template-columns: 1fr; gap: 1.5rem; } }

main.wrap { padding-top: 3rem; padding-bottom: 1.5rem; }
h1, h2, h3 { font-family: "Source Sans 3", "Source Sans Pro", sans-serif; }
h1 { font-size: 1.75rem; line-height: 1.2; margin: .25rem 0 1rem; }
h2 { font-size: 1.3rem; margin-top: 2rem; }
h3 { font-size: 1.1rem; margin-top: 1.5rem; }

.breadcrumb { margin: 0; font-size: .95rem; }
.meeting-date { color: var(--muted); margin-top: -.5rem; font-size: 1.1rem; }
.description { max-width: 45rem; }
.muted, .meta { color: var(--muted); }
.meta { font-size: .9em; }
.empty { padding: 1.5rem; background: var(--surface); border-radius: 6px; }

/* Forms */
.field { margin-bottom: 1rem; }
fieldset.field { border: 0; padding: 0; }
legend, label { display: block; font-weight: 600; margin-bottom: .25rem; }
.radio { display: flex; align-items: center; gap: .5rem; margin: .25rem 0; }
.radio label { font-weight: normal; margin: 0; }
.hint { color: var(--muted); font-size: .9rem; font-weight: normal; margin: .25rem 0 0; }

input[type="text"], input[type="search"], input[type="password"], input[type="date"], select, textarea {
    font: inherit;
    color: var(--text);
    background: var(--bg);
    border: 1px solid var(--muted);
    border-radius: 4px;
    padding: .45rem .6rem;
    width: 100%;
    max-width: 30rem;
}
input[type="file"] { font: inherit; }
textarea { max-width: 45rem; }
[aria-invalid="true"] { border-color: var(--danger); border-width: 2px; }

.narrow { max-width: 30rem; }

button, .button {
    font: inherit;
    display: inline-block;
    padding: .5rem 1rem;
    border-radius: 4px;
    border: 2px solid var(--accent);
    background: var(--accent);
    color: var(--accent-text);
    cursor: pointer;
    text-decoration: none;
}
.button.secondary { background: transparent; color: var(--link); }
button.danger { background: transparent; color: var(--danger); border-color: var(--danger); }
button.small { padding: .1rem .5rem; font-size: .9rem; margin-left: .5rem; }
.link-button { background: none; border: 0; padding: 0; color: var(--link); text-decoration: underline; }
form.inline { display: inline; }

.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 1rem; }
.admin-actions { display: flex; flex-wrap: wrap; gap: .75rem; margin: 1rem 0; }

.search-form {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem 1.25rem;
    align-items: flex-start;
    padding: 1.25rem;
    margin-bottom: 1.75rem;
    background: #f3f6fc;
    border: 1px solid #dbe3f3;
    border-radius: 8px;
}
.search-form .field { margin: 0; min-width: 0; flex: 1 1 8.5rem; }
.search-form .field:first-child { flex: 3 1 10rem; }
.search-form label { font-size: .9rem; margin-bottom: .35rem; }
.search-form input[type="search"], .search-form select {
    max-width: none;
    height: 2.5rem;
    background-color: #fff;
    border-color: #b7c3dc;
}
.search-form input[type="search"]:focus, .search-form select:focus {
    outline: 3px solid var(--focus);
    outline-offset: 1px;
}
.search-form .hint { margin-top: .4rem; font-size: .8rem; }
.search-form .actions { gap: .75rem 1.25rem; padding: 0; margin-top: 1.8rem; min-height: 2.5rem; flex: 0 0 auto; flex-wrap: nowrap; white-space: nowrap; }
.search-form .actions button { height: 2.5rem; padding-top: 0; padding-bottom: 0; }

/* Messages */
.flashes p, .error-summary {
    padding: .75rem 1rem;
    border-left: 4px solid var(--success-border);
    background: var(--success-bg);
    margin: 0 0 1rem;
}
.flash-warning { border-color: var(--warning-border) !important; background: var(--warning-bg) !important; }
.flash-error, .error-summary { border-color: var(--danger) !important; background: var(--error-bg) !important; }
.error-summary p { margin: 0 0 .25rem; font-weight: 600; }
.error-summary ul { margin: 0; }
.error { color: var(--danger); font-weight: 600; margin: .25rem 0 0; }

/* Meeting list */
table.meetings { width: 100%; border-collapse: collapse; }
table.meetings caption { text-align: left; color: var(--muted); padding-bottom: .5rem; }
table.meetings th, table.meetings td {
    text-align: left;
    vertical-align: top;
    padding: .65rem .5rem;
    border-bottom: 1px solid var(--border);
}
table.meetings td.date { white-space: nowrap; }
.doc-links, .extras { list-style: none; margin: 0; padding: 0; }
.doc-links li + li { margin-top: .2rem; }
.matched { margin: .25rem 0 0; font-size: .9rem; color: var(--muted); }

@media (max-width: 40rem) {
    table.meetings thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
    table.meetings, table.meetings tbody, table.meetings tr, table.meetings td { display: block; width: 100%; }
    table.meetings tr { border-bottom: 1px solid var(--border); padding: .5rem 0; }
    table.meetings td { border: 0; padding: .2rem 0; }
}

/* Meeting page */
.documents { margin: 0; }
.doc-row { display: flex; flex-wrap: wrap; gap: .25rem 1rem; padding: .6rem 0; border-bottom: 1px solid var(--border); }
.doc-row dt { font-weight: 600; min-width: 7rem; }
.doc-row dd { margin: 0; }
.extras li { padding: .4rem 0; }

.upload { margin-top: 2.5rem; padding: 1rem 1.25rem; border: 1px solid var(--border); border-radius: 6px; }
.upload h2 { margin-top: 0; }

/* Bulk upload review */
.flash ul { margin: .25rem 0 0; }
.flash p { margin: 0; }
.table-scroll { overflow-x: auto; margin-bottom: 1rem; }
table.bulk th.filename { font-weight: normal; word-break: break-word; min-width: 12rem; }
table.bulk input[type="text"], table.bulk input[type="date"], table.bulk select { width: auto; min-width: 9rem; }
table.bulk input[type="checkbox"] { width: 1.25rem; height: 1.25rem; }
table.bulk input:disabled { opacity: .5; }
table.bulk tr.has-error { background: var(--error-bg); }
table.bulk td.status { font-size: .95rem; }
.status-error { color: var(--danger); font-weight: 600; }
.status-warning { color: var(--warning-border); font-weight: 600; }
.bulk-actions { margin-top: 1rem; }
code { font-size: .95em; background: var(--surface); padding: 0 .25rem; border-radius: 3px; }

@media (max-width: 40rem) {
    table.bulk thead { position: static; width: auto; height: auto; overflow: visible; clip: auto; }
    table.bulk, table.bulk tbody, table.bulk tr, table.bulk td { display: revert; width: auto; }
}

.pagination ul { list-style: none; padding: 0; display: flex; flex-wrap: wrap; gap: .5rem; }
.pagination a { display: inline-block; padding: .25rem .6rem; border: 1px solid var(--border); border-radius: 4px; }
.pagination a[aria-current="page"] { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }

.lede { max-width: 45rem; margin-top: 0; }
.inline-edit { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; }
.inline-edit input[type="text"] { width: auto; flex: 1 1 14rem; max-width: 24rem; }
.inline-edit button.small { margin-left: 0; }
.row-actions { display: flex; align-items: center; gap: 1rem; margin-top: .25rem; font-size: .9rem; }
.row-actions button.small { margin-left: 0; }

.bulk-bar { display: flex; align-items: center; gap: 1rem; margin-bottom: .75rem; }
.bulk-bar button:disabled { opacity: .45; cursor: not-allowed; }
.select-col { width: 2.5rem; }
table.meetings .select-col input[type="checkbox"] { width: 1.15rem; height: 1.15rem; }
@media (max-width: 40rem) {
    table.meetings td.select-col { width: auto; padding-bottom: 0; }
}

.browse-year {
    display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-start; gap: .75rem 1.5rem;
    margin: 0 0 1.75rem; padding: 1.1rem 1.25rem;
    background: #f3f6fc; border: 1px solid #dbe3f3; border-left: 5px solid #203f93; border-radius: 8px;
}
.browse-year h2 { margin: 0; font-size: 1.4rem; line-height: 1.2; color: #203f93; }
.browse-year select {
    width: auto; min-width: 14rem; height: 2.75rem; font-size: 1.1rem; font-weight: 600;
    background-color: #fff; border: 2px solid #203f93; border-radius: 6px; cursor: pointer;
}

.side-search { display: flex; gap: .4rem; padding: 0 1.25rem .5rem; }
.side-search input[type="search"] { flex: 1 1 auto; min-width: 0; width: auto; max-width: none; height: 2.25rem; padding: .3rem .5rem; font-size: .95rem; }
.side-search button { flex: 0 0 auto; width: 2.25rem; height: 2.25rem; padding: 0; display: inline-flex; align-items: center; justify-content: center; }

.adv-search { max-width: 36rem; padding: 1.25rem; background: #f3f6fc; border: 1px solid #dbe3f3; border-radius: 8px; }
.adv-search select, .adv-search input[type="search"] { max-width: none; height: 2.5rem; background-color: #fff; border-color: #b7c3dc; }
.adv-search .actions { margin-top: 1.25rem; }
.pagination .gap { display: inline-block; padding: .25rem .2rem; color: var(--muted); }

.file-tree, .file-tree ul { margin: 0; padding-left: 1.4rem; }
.file-tree { padding-left: 1.2rem; }
.file-tree li { margin: .2rem 0; }
.file-tree > li { margin-top: 1rem; }
.file-tree ul ul { margin-bottom: .35rem; }
.tree-year { font-size: 1.25rem; font-weight: 700; font-family: "Source Sans 3", "Source Sans Pro", sans-serif; }
.tree-group { font-weight: 600; }
