* { box-sizing: border-box; }

:root {
    --ink: #2b1c14;
    --muted: #6b5847;
    --faint: #a89882;
    --line: #e6d9c3;
    --panel: #fffefb;
    --bg: #f8f1e2;
    --accent: #6b2b1f;
    --accent-dark: #401a12;
    --accent-light: #f0e0d3;
    --gold: #a8976a;
    --gold-dark: #8a7a52;
    --gold-light: #f5ecd8;
}

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

a { color: #7a3323; text-decoration: none; }
a:hover { text-decoration: underline; }

main { max-width: 1100px; margin: 0 auto; padding: 1.75rem 2rem 4rem; }

h2 { font-size: 1.4rem; margin: 1.25rem 0 0.75rem; font-weight: 700; letter-spacing: -0.01em; color: var(--ink); }
h3 { font-size: 1.05rem; margin: 1.1rem 0 0.4rem; font-weight: 700; color: var(--accent); }

/* ---------- Site navigation bar (every public page) ----------
   Light cream bar so the full-color MHH logo (chocolate + cream wordmark,
   originally designed for a light background) reads at full contrast,
   rather than fighting a dark background. */
.site-nav {
    background: var(--panel);
    color: var(--ink);
    border-bottom: 3px solid var(--accent);
    position: sticky;
    top: 0;
    z-index: 20;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}
.site-nav-inner {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0.65rem 2rem;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
}
.site-brand { display: flex; align-items: center; gap: 0.75rem; color: var(--ink); text-decoration: none; }
.site-brand:hover { text-decoration: none; }
.site-brand-mark {
    display: block;
    width: 196px;
    height: auto;
    flex-shrink: 0;
}
.site-brand-text { display: flex; flex-direction: column; line-height: 1.25; font-weight: 600; font-size: 1.02rem; color: var(--accent); }
.site-brand-text small {
    font-weight: 500;
    font-size: 0.7rem;
    color: var(--muted);
    letter-spacing: 0.03em;
    text-transform: uppercase;
}
.site-nav-links { display: flex; justify-content: center; gap: 1.5rem; flex-wrap: wrap; width: 100%; }
.site-nav-links a {
    color: var(--muted);
    font-size: 0.92rem;
    font-weight: 500;
    text-decoration: none;
    padding-bottom: 3px;
    border-bottom: 2px solid transparent;
}
.site-nav-links a:hover,
.site-nav-links a.active {
    color: var(--accent);
    border-bottom-color: var(--gold);
    text-decoration: none;
}

/* ---------- Site footer (every public page) ---------- */
.site-footer { background: var(--accent-dark); color: #cbb896; margin-top: 3rem; }
.site-footer-inner {
    max-width: 1100px;
    margin: 0 auto;
    padding: 1.5rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.6rem;
    font-size: 0.85rem;
}
.site-footer-copy {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}
.site-footer-software {
    font-size: 0.78rem;
    color: #a68a63;
}
.site-footer a { color: var(--gold-light); }
.site-footer a:hover { color: #fff; }
.site-footer-notice {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 2rem 1.25rem;
    font-size: 0.75rem;
    color: #a68a63;
}

/* ---------- Landing page hero + stats (index.php only) ---------- */
.hero {
    /* Wild-horse-herd photo as a faint watermark behind the hero content --
       the navy gradient sits on top at high opacity so it still reads as
       the same solid brand-color hero (text/search bar contrast unchanged),
       with just a hint of the photo showing through beneath everything. */
    background:
        linear-gradient(135deg, rgba(107, 43, 31, 0.91) 0%, rgba(64, 26, 18, 0.95) 100%),
        url('images/hero-horses.jpg') center 38% / cover no-repeat;
    color: #fff;
    padding: 3.75rem 2rem 5rem;
    text-align: center;
}
.hero-inner { max-width: 720px; margin: 0 auto; }
.hero-eyebrow {
    display: inline-block;
    font-family: 'Cinzel', Georgia, serif;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    font-size: 0.76rem;
    font-weight: 600;
    color: var(--gold-light);
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 999px;
    padding: 0.32rem 0.95rem;
    margin-bottom: 1.35rem;
}
.hero h1 {
    font-family: 'Cinzel', Georgia, 'Times New Roman', serif;
    font-weight: 800;
    font-size: 3.1rem;
    margin: 0 0 0.85rem;
    letter-spacing: 0.01em;
}
.hero p.lead { font-size: 1.05rem; color: #e6d7bd; margin: 0 0 2.1rem; line-height: 1.6; }
.hero-search {
    display: flex;
    gap: 0.5rem;
    background: #fff;
    border-radius: 10px;
    padding: 0.45rem;
    box-shadow: 0 14px 30px rgba(20, 12, 7, 0.25);
    max-width: 540px;
    margin: 0 auto;
}
.hero-search input[type="text"] {
    flex: 1;
    border: none;
    padding: 0.65rem 0.9rem;
    font-size: 1rem;
    border-radius: 6px;
    color: var(--ink);
    min-width: 0;
}
.hero-search input[type="text"]:focus { outline: 2px solid var(--gold); }
.hero-search button {
    background: var(--gold);
    color: #401a12;
    border: none;
    padding: 0.65rem 1.4rem;
    border-radius: 6px;
    font-weight: 700;
    font-size: 0.95rem;
    cursor: pointer;
    white-space: nowrap;
}
.hero-search button:hover { background: var(--gold-dark); }
.hero-advanced-link { display: block; margin-top: 1rem; font-size: 0.88rem; color: #e6d7bd; }
.hero-advanced-link a { color: var(--gold-light); font-weight: 600; }

.stats-strip {
    max-width: 1100px;
    margin: -2.75rem auto 0;
    padding: 0 2rem;
    position: relative;
    z-index: 2;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 1rem;
}
.stat-tile {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 1.3rem 1.5rem;
    box-shadow: 0 8px 22px rgba(43, 28, 20, 0.1);
    text-align: center;
}
.stat-tile .stat-value { font-size: 1.85rem; font-weight: 700; color: var(--accent); line-height: 1.2; }
.stat-tile .stat-label {
    font-size: 0.8rem;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-top: 0.25rem;
}

/* Nav cards on the landing page (Quick Search / Advanced Search / Browse) */
.nav-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1.25rem;
    margin: 2.75rem 0 2.5rem;
}
.nav-cards-2 {
    grid-template-columns: repeat(2, minmax(220px, 340px));
    justify-content: center;
}
.nav-card {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 1.5rem;
    display: block;
    color: var(--ink);
    text-decoration: none;
    transition: box-shadow 0.15s ease, transform 0.15s ease;
}
.nav-card:hover { box-shadow: 0 12px 26px rgba(43, 28, 20, 0.12); transform: translateY(-2px); text-decoration: none; }
.nav-card-icon {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    background: var(--accent-light);
    color: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    margin-bottom: 1rem;
}
.nav-card h3 { margin: 0 0 0.4rem; color: var(--ink); font-size: 1.05rem; }
.nav-card p { margin: 0; color: var(--muted); font-size: 0.88rem; line-height: 1.55; }

.about-section {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 2rem 2.25rem;
    margin: 2.5rem 0;
}
.about-section h2 { margin-top: 0; }
.about-section p { color: var(--muted); line-height: 1.7; max-width: 760px; margin: 0; }

/* Quick search box (homepage) */
.search-form {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    flex-wrap: wrap;
    margin-bottom: 1.75rem;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 0.9rem 1rem;
}
.search-form input[type="text"] {
    flex: 1 1 260px;
    padding: 0.55rem 0.7rem;
    font-size: 1rem;
    border: 1px solid var(--line);
    border-radius: 6px;
}
.search-form button {
    background: var(--accent);
    color: #fff;
    border: none;
    padding: 0.55rem 1.1rem;
    font-size: 0.95rem;
    border-radius: 6px;
    cursor: pointer;
}
.search-form button:hover { background: var(--accent-dark); }
.search-form .advanced-link { font-size: 0.9rem; white-space: nowrap; }

/* Generic small inline forms (admin-style search, generation pickers) */
.inline-form {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin: 1rem 0;
    flex-wrap: wrap;
}
.inline-form label { font-size: 0.9rem; color: var(--muted); display: flex; align-items: center; gap: 0.4rem; }
.inline-form select, .inline-form input, .inline-form button {
    padding: 0.4rem 0.6rem;
    border: 1px solid var(--line);
    border-radius: 6px;
    font-size: 0.9rem;
}

/* Standard data tables (browse list, record detail) */
table.results, table.detail {
    width: 100%;
    border-collapse: collapse;
    background: var(--panel);
    margin-bottom: 1rem;
    border: 1px solid var(--line);
    border-radius: 8px;
    overflow: hidden;
}
table.results th, table.results td,
table.detail th, table.detail td {
    border-bottom: 1px solid var(--line);
    padding: 0.45rem 0.9rem;
    text-align: left;
    vertical-align: top;
}
table.results tbody tr:last-child td,
table.detail tr:last-child td { border-bottom: none; }
table.results th { background: var(--accent-light); font-weight: 600; font-size: 0.9rem; color: var(--muted); }
table.results tbody tr:hover { background: #faf3e6; }
table.detail th { width: 200px; background: var(--accent-light); font-weight: 600; font-size: 0.9rem; color: var(--muted); }

.unknown-name { color: var(--faint); font-style: italic; }
.title { color: var(--gold-dark); font-weight: 600; font-size: 0.9em; }

/* Subject card header used on the report pages (detail / pedigree / reverse / offspring) */
.subject-card {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 1rem 1.25rem;
    margin-bottom: 0.85rem;
}
.subject-card h2 { margin: 0 0 0.4rem; }
.subject-card .subtext { margin: 0 0 0.5rem; color: var(--muted); font-size: 0.9rem; }

/* Record detail page: dense two-column field grid for each field group,
   instead of one row per field -- keeps records with many populated
   fields (Breed & Appearance, Registration, etc.) from running long. */
.detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    column-gap: 2rem;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 0.2rem 1rem;
    margin-bottom: 1rem;
}
/* Fixed 2-column variant, used where fields are meant to read as
   deliberate pairs (e.g. Owner/Breeder, Bred State/Birth State) rather
   than flowing however many columns fit the viewport. */
.detail-grid-pairs {
    grid-template-columns: repeat(2, minmax(240px, 1fr));
}
.detail-field {
    display: flex;
    align-items: baseline;
    gap: 0.5rem;
    padding: 0.4rem 0;
    border-bottom: 1px solid var(--line);
    font-size: 0.9rem;
    min-width: 0;
}
.detail-field-label { color: var(--muted); font-weight: 600; flex-shrink: 0; white-space: nowrap; }
.detail-field-value { color: var(--ink); overflow-wrap: break-word; min-width: 0; }

/* Record detail page only: photo shown to the right of the name/links */
.subject-card-photo {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1.5rem;
    flex-wrap: wrap;
}
.subject-card-photo .subject-card-info { flex: 1 1 260px; min-width: 0; }
.subject-photo-link {
    flex-shrink: 0;
    display: block;
    border-radius: 8px;
    transition: opacity 0.15s ease;
}
.subject-photo-link:hover,
.subject-photo-link:focus-visible { opacity: 0.85; }
.subject-photo {
    width: 140px;
    height: 140px;
    object-fit: cover;
    border-radius: 8px;
    border: 1px solid var(--line);
    background: var(--accent-light);
    cursor: pointer;
}

.action-links {
    display: block;
    margin-top: 0.4rem;
    font-size: 0.88rem;
    color: var(--muted);
}
.action-links a { color: #7a3323; }

/* Shared small panel + label/value table -- used by search.php (quick
   search) and trial_mating.php as well as (indirectly, via .panel/.warning)
   the results page, so these stay generic rather than advanced-search-
   specific. The advanced search page's own layout lives further down. */
.panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 1.5rem 1.75rem;
    margin-bottom: 1.5rem;
    box-shadow: 0 1px 3px rgba(64, 26, 18, 0.06);
}
.panel h3 { margin-top: 0; margin-bottom: 0.2rem; }

.sr-only {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

table.input { width: 100%; border-collapse: collapse; }
table.input td { padding: 0.7rem 0.5rem; vertical-align: top; border-bottom: 1px solid var(--accent-light); }
table.input tr:last-child td { border-bottom: none; }
table.input tr:hover td { background: var(--accent-light); }
table.input .fieldname { width: 220px; font-weight: 600; color: var(--ink); padding-top: 0.85rem; }
table.input .fieldvalue { color: var(--muted); font-size: 0.9rem; }
table.input select, table.input input[type="text"] {
    padding: 0.45rem 0.65rem;
    border: 1px solid var(--line);
    border-radius: 6px;
    font-size: 0.95rem;
    margin-top: 0.4rem;
    background: #fff;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
table.input select:focus, table.input input[type="text"]:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(107, 43, 31, 0.15);
}
table.input button {
    background: var(--accent);
    color: #fff;
    border: none;
    padding: 0.65rem 1.75rem;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 600;
}
table.input button:hover { background: var(--accent-dark); }

.warning {
    background: #fdf1f0;
    border: 1px solid #f3c9c4;
    color: #8a2e24;
    border-radius: 6px;
    padding: 0.75rem 1rem;
}

/* ---------- Advanced search page ---------- */
.adv-hero { margin-bottom: 1.75rem; max-width: 62em; }
.adv-hero-eyebrow {
    display: inline-block;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    font-size: 0.74rem;
    font-weight: 700;
    color: var(--accent-dark);
    background: var(--gold-light);
    border: 1px solid #ecd8a4;
    border-radius: 999px;
    padding: 0.28rem 0.85rem;
    margin-bottom: 0.85rem;
}
.adv-hero h2 { margin: 0 0 0.5rem; font-size: 1.65rem; }
.adv-hero p { color: var(--muted); margin: 0; line-height: 1.6; }

/* Two-column layout: the criteria builder on the left, a sticky "Refine &
   Sort" panel on the right that carries the submit button -- so the button
   stays close at hand no matter how many rows are filled in. Collapses to a
   single column (options panel below the criteria) on narrow screens. */
.adv-layout {
    display: grid;
    grid-template-columns: 1fr 320px;
    align-items: start;
    gap: 1.5rem;
}
.adv-panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 1.5rem 1.65rem;
    box-shadow: 0 1px 3px rgba(64, 26, 18, 0.06);
}
.adv-options-panel { position: sticky; top: 90px; }
.adv-panel-head { margin-bottom: 1.25rem; }
.adv-panel-head h3 { margin: 0 0 0.3rem; }
.adv-panel-head p { margin: 0; color: var(--muted); font-size: 0.88rem; line-height: 1.5; }

/* Criteria rows rendered as a numbered vertical timeline -- a connecting
   line down the badge column ties the cards together visually, with the
   AND/OR connector select sitting directly on that line between rows,
   making the row-to-row relationship read at a glance instead of being a
   plain per-row dropdown at the end of a table row. */
.criteria-timeline { position: relative; }
.criteria-timeline::before {
    content: "";
    position: absolute;
    left: 17px;
    top: 20px;
    bottom: 20px;
    width: 2px;
    background: var(--line);
}
.criteria-item { position: relative; display: flex; gap: 1rem; align-items: flex-start; }
.criteria-badge {
    position: relative;
    z-index: 1;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--accent);
    color: #fff;
    font-weight: 700;
    font-size: 0.92rem;
    margin-top: 0.15rem;
}
.criteria-card {
    flex: 1;
    display: grid;
    grid-template-columns: 150px 1fr 190px;
    gap: 0.85rem;
    background: var(--accent-light);
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 0.9rem 1rem;
    margin-bottom: 0.9rem;
    transition: box-shadow 0.15s ease;
}
.criteria-card:hover { box-shadow: 0 4px 14px rgba(64, 26, 18, 0.08); }
.criteria-card label {
    display: block;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--muted);
    margin-bottom: 0.3rem;
}
.criteria-card select, .criteria-card input[type="text"] {
    width: 100%;
    padding: 0.5rem 0.6rem;
    border: 1px solid var(--line);
    border-radius: 6px;
    font-size: 0.92rem;
    background: #fff;
    box-sizing: border-box;
}
.criteria-card select:focus, .criteria-card input[type="text"]:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(107, 43, 31, 0.15);
}
.criteria-connector {
    position: relative;
    z-index: 1;
    display: flex;
    justify-content: center;
    margin: -0.35rem 0 0.55rem 0;
}
.connector-select {
    background: var(--gold);
    color: var(--accent-dark);
    border: none;
    border-radius: 999px;
    font-weight: 700;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 0.25rem 1rem;
    cursor: pointer;
    box-shadow: 0 1px 2px rgba(60, 40, 20, 0.15);
}

/* Sidebar filter groups */
.option-group { margin-bottom: 1.5rem; }
.option-group:last-of-type { margin-bottom: 0; }
.option-group-label {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-weight: 700;
    color: var(--faint);
    border-bottom: 1px solid var(--line);
    padding-bottom: 0.4rem;
    margin-bottom: 0.85rem;
}
.option-field { margin-bottom: 0.9rem; }
.option-field:last-child { margin-bottom: 0; }
.option-field label { display: block; font-size: 0.86rem; font-weight: 600; color: var(--ink); margin-bottom: 0.3rem; }
.option-field select {
    width: 100%;
    padding: 0.5rem 0.6rem;
    border: 1px solid var(--line);
    border-radius: 6px;
    font-size: 0.9rem;
    background: #fff;
    box-sizing: border-box;
}
.option-field select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(107, 43, 31, 0.15);
}
.option-hint { margin: 0.35rem 0 0; font-size: 0.78rem; color: var(--muted); line-height: 1.4; }

.adv-actions { margin-top: 1.5rem; padding-top: 1.25rem; border-top: 1px solid var(--line); }
.adv-actions button {
    width: 100%;
    background: var(--accent);
    color: #fff;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 700;
}
.adv-actions button:hover { background: var(--accent-dark); }

@media (max-width: 900px) {
    .adv-layout { grid-template-columns: 1fr; }
    .adv-options-panel { position: static; }
}

@media (max-width: 640px) {
    /* The three-field grid per criteria row no longer fits side by side --
       stack Field / Search Pattern / Comparison within each card instead. */
    .criteria-card { grid-template-columns: 1fr; gap: 0.6rem; }
    .criteria-timeline::before { left: 17px; }
}

/* ---------- Quick search page ---------- */
/* The primary field/pattern/comparison controls, laid out as one prominent
   search bar (field + pattern + comparison + button) rather than a stacked
   label/value table -- this page only ever searches one field at a time, so
   a single-line search bar reads faster than a form to fill in top to
   bottom. The "Filters & Sort" panel below it reuses .adv-panel/.adv-panel-
   head/.option-field from the advanced search page for a consistent look
   between the two search pages. */
.quick-searchbar-panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 1.25rem 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: 0 1px 3px rgba(64, 26, 18, 0.06);
}
.quick-searchbar { display: flex; align-items: flex-end; gap: 0.85rem; flex-wrap: wrap; }
.quick-searchbar label {
    display: block;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--muted);
    margin-bottom: 0.3rem;
}
.qs-field { flex: 0 0 170px; }
.qs-pattern { flex: 1 1 280px; min-width: 220px; }
.qs-where { flex: 0 0 200px; }
.quick-searchbar select, .quick-searchbar input[type="text"] {
    width: 100%;
    padding: 0.6rem 0.75rem;
    border: 1px solid var(--line);
    border-radius: 8px;
    font-size: 0.95rem;
    background: #fff;
    box-sizing: border-box;
}
.quick-searchbar select:focus, .quick-searchbar input[type="text"]:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(107, 43, 31, 0.15);
}
.quick-searchbar button {
    flex: 0 0 auto;
    background: var(--accent);
    color: #fff;
    border: none;
    padding: 0.65rem 1.75rem;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 700;
}
.quick-searchbar button:hover { background: var(--accent-dark); }
.quick-searchbar-hint { margin: 0.7rem 0 0; font-size: 0.82rem; color: var(--muted); }

.option-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    gap: 1.1rem 1.5rem;
}
.option-grid .option-field { margin-bottom: 0; }

@media (max-width: 560px) {
    .qs-field, .qs-pattern, .qs-where { flex-basis: 100%; }
    .quick-searchbar button { width: 100%; }
}

/* Search results list */
.searchtitle { font-size: 1.15rem; color: var(--muted); font-weight: 500; }
table.search { width: 100%; border-collapse: collapse; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
table.search td { padding: 0.75rem 1rem; border-bottom: 1px solid var(--line); vertical-align: top; }
table.search tr:last-child td { border-bottom: none; }
table.search tr.result { background: var(--panel); }
table.search tr.altresult { background: #faf3e6; }
table.search tr:hover { background: var(--accent-light); }
.rownum { width: 2.5rem; color: var(--faint); font-size: 0.85rem; text-align: right; }
.result-name { font-weight: 600; font-size: 1.02rem; }
.resultdetails { display: block; color: var(--muted); font-size: 0.88rem; margin-top: 0.15rem; }
.search-more { text-align: center; margin: 1.25rem 0; }
.search-more a {
    display: inline-block;
    padding: 0.5rem 1.1rem;
    background: var(--accent-light);
    border: 1px solid var(--line);
    border-radius: 6px;
    font-size: 0.9rem;
}

/* Report pages: pedigree chart, reverse pedigree, offspring/breeding report */
/* ---------- Stallion Directory (search page + map) ---------- */
.stallion-map {
    height: 420px;
    width: 100%;
    border-radius: 8px;
    border: 1px solid var(--line);
    margin: 1rem 0 1.5rem;
    background: var(--panel);
}
.stallion-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1rem;
    margin: 1rem 0 2rem;
}
.stallion-card {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 1rem 1.1rem;
}
.stallion-card h4 { margin: 0 0 0.3rem; font-size: 1rem; }
.stallion-card-owner { font-size: 0.9rem; margin-top: 0.5rem; color: var(--ink); }
.stallion-card-address { font-size: 0.88rem; color: var(--muted); margin: 0.15rem 0 0.4rem; }

/* ---------- Breeder/Farm Directory (search page + map) ---------- */
.breeder-map {
    height: 420px;
    width: 100%;
    border-radius: 8px;
    border: 1px solid var(--line);
    margin: 1rem 0 1.5rem;
    background: var(--panel);
}
.breeder-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1rem;
    margin: 1rem 0 2rem;
}
.breeder-card {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 1rem 1.1rem;
}
.breeder-card h4 { margin: 0 0 0.3rem; font-size: 1rem; }
.breeder-card-address { font-size: 0.88rem; color: var(--muted); margin: 0.15rem 0 0.4rem; }
.breeder-card-contact { font-size: 0.88rem; margin: 0.4rem 0; }
.breeder-card-contact div { margin: 0.1rem 0; }
.breeder-card-count { font-size: 0.9rem; margin-top: 0.5rem; }
.breeder-card-description { font-size: 0.9rem; margin: 0.4rem 0; }
.breeder-card-featured {
    border-color: var(--accent);
    box-shadow: 0 0 0 1px var(--accent);
    position: relative;
}
.breeder-card-featured-flag {
    display: inline-block;
    background: var(--accent);
    color: #fff;
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    padding: 0.15rem 0.5rem;
    border-radius: 4px;
    margin-bottom: 0.4rem;
}

.report-scroll { overflow-x: auto; margin-bottom: 1rem; border-radius: 8px; }
table.report { width: 100%; border-collapse: collapse; background: var(--panel); border: 1px solid var(--line); }
table.report td { border: 1px solid var(--line); padding: 0.6rem 0.8rem; vertical-align: top; }
table.report td.subject { background: var(--accent-light); border: none; padding: 1rem 1.1rem; }
table.report td.subject h2 { margin: 0 0 0.35rem; }

ol.offspring-list { list-style: decimal; margin: 0.25rem 0 0.25rem 1.25rem; padding: 0; }
ol.offspring-list li { margin: 0.5rem 0; }

.breeding-entry { padding: 0.15rem 0; }
.ancestor, .subject-inline { font-weight: 600; }
.ancestordetails, .subjectdetails { display: block; color: var(--muted); font-size: 0.85rem; margin-top: 0.1rem; }

/* Offspring/breeding report: one card per breeding, mate clearly separated from her/his actual offspring */
.breeding-group {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 1.1rem 1.25rem;
    margin-bottom: 1.25rem;
}
.breeding-group-header { font-weight: 600; font-size: 1.05rem; color: var(--accent); margin-bottom: 0.75rem; }
.field-label {
    display: block;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--muted);
    margin: 0.9rem 0 0.4rem;
}
.field-label:first-of-type { margin-top: 0; }

/* Ancestor pedigree grid + reverse pedigree grid. Borders use border-collapse
   (shared 1px lines between cells, no extra spacing/padding layers) so each
   ancestor reads as a clearly boxed cell without inflating the chart's
   overall height -- important since these charts can run to dozens of rows
   at higher generation counts. */
table.pedigree-grid {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
    background: var(--panel);
    border: 1px solid var(--muted);
    border-radius: 6px;
}
table.pedigree-grid td.pednode {
    border: 1px solid var(--muted);
    padding: 0.22rem 0.4rem;
    vertical-align: middle;
    background: var(--panel);
    min-width: 120px;
}
table.pedigree-grid td.pednode-empty { background: #faf5ea; color: var(--faint); }
.pednode-inner { display: flex; flex-direction: column; gap: 0.02rem; }
.pednode-inner-empty { color: var(--faint); font-style: italic; }
.pednode-name { font-weight: 600; font-size: 0.78rem; line-height: 1.15; }
table.pedigree-grid .ancestordetails { font-size: 0.68rem; line-height: 1.15; }

/* subtle generation shading so columns read cleanly left to right */
table.pedigree-grid td.gen-1 { background: #fffdf8; }
table.pedigree-grid td.gen-2 { background: #faf3e6; }
table.pedigree-grid td.gen-3 { background: #f5ecd8; }
table.pedigree-grid td.gen-4 { background: #f0e3c7; }
table.pedigree-grid td.gen-5 { background: #ecdcbb; }
table.pedigree-grid td.gen-6,
table.pedigree-grid td.gen-7,
table.pedigree-grid td.gen-8,
table.pedigree-grid td.gen-9,
table.pedigree-grid td.gen-10 { background: #e6d2a8; }

/* Trial Mating: color-banded estimated-COI badge (subject-card header) */
.coi-badge {
    display: inline-flex;
    align-items: baseline;
    gap: 0.6rem;
    margin-top: 0.5rem;
    padding: 0.5rem 0.9rem;
    border-radius: 6px;
    font-size: 0.9rem;
}
.coi-badge-label { font-weight: 600; }
.coi-badge-value { font-size: 1.15rem; font-weight: 700; }
.coi-low { background: #eaf6ea; border: 1px solid #b7ddb9; color: #2e7d32; }
.coi-moderate { background: var(--gold-light); border: 1px solid var(--gold); color: var(--gold-dark); }
.coi-high { background: #fdf1f0; border: 1px solid #f3c9c4; color: #8a2e24; }

/* Trial Mating: expandable "how this estimate was calculated" breakdown */
.coi-breakdown { margin-top: 0.75rem; }
.coi-breakdown summary { cursor: pointer; font-weight: 600; color: var(--accent); }
.coi-breakdown summary:hover { text-decoration: underline; }
.coi-breakdown-table { width: 100%; border-collapse: collapse; margin-top: 0.6rem; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; overflow: hidden; font-size: 0.88rem; }
.coi-breakdown-table th, .coi-breakdown-table td { padding: 0.5rem 0.75rem; border-bottom: 1px solid var(--line); text-align: left; }
.coi-breakdown-table th { background: var(--accent-light); font-weight: 600; color: var(--muted); }
.coi-breakdown-table tr:last-child td { border-bottom: none; }

/* Trial Mating: predicted foal coat color panel (reuses .coi-breakdown-table's look) */
.coat-color-prediction { margin-top: 0.9rem; padding-top: 0.75rem; border-top: 1px solid var(--line); }
.coat-color-prediction h3 { margin: 0 0 0.3rem; }
.coat-color-sources { margin-top: 0.6rem; font-size: 0.92rem; }
.coat-color-sources summary { cursor: pointer; color: var(--accent, #6b2b1f); }

/* Legend for repeated ancestors */
.legend { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 1rem 1.25rem; margin-top: 1rem; }
.legend h3 { margin-top: 0; }
.legend p { color: var(--muted); font-size: 0.9rem; margin: 0 0 0.6rem; }
.legend-list { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 0.6rem 1.5rem; }
.legend-list li { display: flex; align-items: center; gap: 0.5rem; font-size: 0.9rem; }
.legend-swatch { width: 14px; height: 14px; border-radius: 3px; border: 1px solid rgba(0,0,0,0.15); display: inline-block; }

@media (max-width: 600px) {
    .site-nav-inner { padding: 0.75rem 1.25rem; }
    .site-brand-mark { width: 140px; height: auto; }
    .hero { padding: 2.75rem 1.25rem 4rem; }
    .hero h1 { font-size: 2.35rem; }
    .hero-search { flex-direction: column; }
    /* Total Records / Stallions / Mares: force 2 across instead of each
       stacking full-width (the auto-fit grid's 160px minimum never
       actually fits 2 columns at this width, so it was collapsing to 1).
       Tiles are also shrunk (padding/font) here only -- desktop's
       .stat-tile/.stat-value/.stat-label rules above are untouched --
       so the third tile sits at the same compact size as the other two
       on its own row instead of stretching into a big lone bar. */
    .stats-strip {
        padding: 0 1.25rem;
        grid-template-columns: repeat(2, 1fr);
        gap: 0.75rem;
    }
    .stat-tile { padding: 0.85rem 0.5rem; }
    .stat-tile .stat-value { font-size: 1.4rem; }
    .stat-tile .stat-label { font-size: 0.68rem; }
    main { padding: 1.5rem 1.25rem 3rem; }
}

/* ---------- Record detail (animal.php) / offspring / trial mating on
   narrow screens ---------- */
@media (max-width: 640px) {
    /* table.detail's fixed 200px label column (Sire/Dam/Offspring on
       animal.php, Sire/Dam on offspring.php) leaves too little room for
       the value once the viewport itself is only ~320-375px wide -- stack
       label above value instead of side-by-side. */
    table.detail, table.detail tbody, table.detail tr, table.detail th, table.detail td {
        display: block;
        width: auto;
    }
    table.detail th { border-bottom: none; padding-bottom: 0.15rem; }
    table.detail td { padding-top: 0; }

    /* table.input (trial_mating.php's Sire/Dam picker form) has the same
       fixed-width label-column problem, plus its text inputs use a fixed
       HTML `size` attribute that otherwise forces the field wider than a
       phone screen. Stack label above value and let inputs/selects fill
       the available width instead. */
    table.input, table.input tbody, table.input tr, table.input .fieldname, table.input .fieldvalue {
        display: block;
        width: auto;
    }
    table.input .fieldname { padding-bottom: 0.2rem; }
    table.input input[type="text"], table.input select {
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
    }

    /* A fixed 2-up pairs grid (e.g. Owner/Breeder) no longer fits two
       240px-minimum columns side by side once the viewport is this
       narrow -- fall back to a single column like the regular .detail-grid
       already does via its own auto-fill. */
    .detail-grid-pairs { grid-template-columns: 1fr; }

    /* The stallion map's fixed 420px height eats a disproportionate share
       of a short phone screen -- shrink it a bit. */
    .stallion-map { height: 280px; }
    .breeder-map { height: 280px; }
}
