:root {
    --paper: #f6efe5;
    --panel: #fffaf3;
    --ink: #2d241c;
    --muted: #726555;
    --line: #d9c7af;
    --accent: #6f4e37;
    --accent-soft: #eadbc7;
    --success: #dff0da;
    --error: #f7dbd7;
    --shadow: 0 16px 40px rgba(45, 36, 28, 0.12);
}

* { box-sizing: border-box; }
body {
    margin: 0;
    font-family: "Segoe UI", Tahoma, sans-serif;
    background: linear-gradient(180deg, #f8f2e8 0%, #eee1cf 100%);
    color: var(--ink);
}

.landing-body {
    min-height: 100vh;
}

.landing-shell {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 32px 20px;
}

.legal-shell {
    min-height: 100vh;
    display: flex;
    justify-content: center;
    padding: 32px 20px;
}

.legal-panel {
    width: min(960px, 100%);
    background: var(--panel);
    border: 1px solid rgba(111, 78, 55, 0.16);
    border-radius: 24px;
    box-shadow: var(--shadow);
    padding: 28px;
}

.legal-meta {
    margin: 0 0 18px;
    color: var(--muted);
    font-weight: 600;
}

.legal-section + .legal-section {
    margin-top: 22px;
}

.legal-section h2 {
    margin: 0 0 10px;
}

.legal-section p {
    margin: 0;
    color: var(--muted);
    line-height: 1.6;
}

.legal-list {
    margin: 12px 0 0;
    padding-left: 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    color: var(--muted);
    line-height: 1.55;
}

.landing-hero {
    width: min(1120px, 100%);
    display: grid;
    grid-template-columns: minmax(0, 1.5fr) minmax(280px, 420px);
    gap: 24px;
    align-items: stretch;
}

.landing-copy,
.landing-card {
    background: var(--panel);
    border: 1px solid rgba(111, 78, 55, 0.16);
    border-radius: 24px;
    box-shadow: var(--shadow);
    padding: 28px;
}

.landing-kicker {
    margin: 0 0 10px;
    color: var(--accent);
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.landing-copy h1 {
    margin: 0 0 16px;
    font-size: clamp(2.25rem, 4vw, 4rem);
    line-height: 1;
}

.landing-intro {
    margin: 0 0 14px;
    color: var(--muted);
    font-size: 1.08rem;
    line-height: 1.6;
}

.landing-card h2 {
    margin-top: 0;
}

.landing-feature-list {
    margin: 0;
    padding-left: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    color: var(--muted);
    line-height: 1.5;
}

.auth-body {
    min-height: 100vh;
}

.auth-shell {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 24px;
    gap: 16px;
}

.auth-panel {
    width: min(100%, 480px);
}

.auth-brand h1 {
    margin-bottom: 8px;
}

.auth-brand p {
    margin-top: 0;
}
a { color: inherit; }

.app-shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 260px minmax(0, 1fr);
}

.sidebar {
    background: #30271e;
    color: #f7f0e4;
    padding: 24px 18px;
    display: flex;
    flex-direction: column;
    gap: 18px;
    align-self: start;
}

.sidebar-content {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.sidebar-toggle {
    display: none;
    align-self: flex-start;
    background: rgba(255, 255, 255, 0.12);
    color: #f7f0e4;
    border: 1px solid rgba(255, 255, 255, 0.18);
}

.brand h1 {
    margin: 0;
    font-size: 28px;
}

.brand p {
    margin: 6px 0 0;
    color: #d9c8b1;
    line-height: 1.4;
}

.nav-links {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.nav-links a {
    padding: 10px 12px;
    border-radius: 12px;
    text-decoration: none;
    color: #f7f0e4;
}

.nav-links a.active,
.nav-links a:hover {
    background: rgba(255, 255, 255, 0.12);
}

.sidebar-user {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding-top: 4px;
}

.sidebar-user-label {
    color: #d9c8b1;
    font-size: 14px;
}

.main {
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    min-width: 0;
}

.hero,
.panel,
.flash {
    background: var(--panel);
    border: 1px solid rgba(111, 78, 55, 0.16);
    border-radius: 18px;
    box-shadow: var(--shadow);
}

.hero,
.panel {
    padding: 20px;
    min-width: 0;
}

.flash-stack {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.flash {
    padding: 14px 18px;
}

.flash.success { background: var(--success); }
.flash.error { background: var(--error); }

.hero h2,
.panel h2,
.panel h3 {
    margin-top: 0;
}

.muted { color: var(--muted); }

.split {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(320px, 430px);
    gap: 20px;
}

.split > * {
    min-width: 0;
}

.stack {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 14px;
}

.stat-card {
    border: 1px solid var(--line);
    background: #fff;
    border-radius: 16px;
    padding: 16px;
}

.stat-card strong {
    display: block;
    font-size: 26px;
    margin-top: 6px;
}

.toolbar,
.form-grid,
.button-row,
.card-list {
    display: flex;
    gap: 12px;
}

.toolbar,
.button-row {
    flex-wrap: wrap;
    align-items: center;
}

.kits-quick-actions {
    margin: 12px 0 16px;
}

.card-list {
    flex-direction: column;
}

.form-grid {
    flex-wrap: wrap;
}

.sync-form {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.sync-field {
    max-width: 360px;
}

.field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 180px;
    flex: 1 1 180px;
}

.field.wide { flex-basis: 100%; }

input, select, textarea, button {
    font: inherit;
}

input, select, textarea {
    border: 1px solid var(--line);
    background: #fff;
    border-radius: 12px;
    padding: 10px 12px;
    color: var(--ink);
}

textarea { min-height: 110px; resize: vertical; }

button,
.button-link {
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: 999px;
    padding: 10px 16px;
    text-decoration: none;
    cursor: pointer;
}

.button-link.secondary,
button.secondary {
    background: var(--accent-soft);
    color: var(--ink);
}

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

.data-table th,
.data-table td {
    text-align: left;
    padding: 10px 12px;
    border-bottom: 1px solid var(--line);
    vertical-align: top;
}

.data-table th a {
    text-decoration: none;
}

.litter-filter-toolbar select,
.litter-filter-toolbar input[type="search"] {
    min-width: 150px;
}

.litter-archive-toggle {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--muted);
}

.litter-table th,
.litter-table td {
    white-space: nowrap;
}

#litters-table-panel.is-loading {
    opacity: 0.65;
    transition: opacity 0.15s ease;
}

#rabbits-list-panel.is-loading {
    opacity: 0.65;
    transition: opacity 0.15s ease;
}

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 8px;
}

.calendar-cell {
    min-height: 112px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: #fff;
    padding: 10px;
}

.calendar-cell.empty { background: transparent; border-style: dashed; }

.badge {
    display: inline-block;
    margin-top: 6px;
    padding: 4px 8px;
    border-radius: 999px;
    background: var(--accent-soft);
    font-size: 12px;
}

.ancestor-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
}

.pedigree-browser {
    display: grid;
    grid-template-columns: 952px 320px;
    gap: 24px;
    align-items: start;
    min-width: 1296px;
}

.pedigree-scroll {
    overflow-x: auto;
    padding-bottom: 10px;
    max-width: 100%;
}

.pedigree-hero-fluid {
    width: 100%;
}

.pedigree-panel-fixed {
    width: min(1336px, 100%);
    max-width: 100%;
    align-self: flex-start;
    min-width: 0;
}

.pedigree-lineage,
.pedigree-branching {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.pedigree-grid {
    display: grid;
    grid-template-columns: repeat(4, 220px);
    gap: 18px;
    align-items: start;
}

.ancestor-column {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.generation-stack,
.selected-stack {
    display: grid;
    grid-template-rows: repeat(8, minmax(82px, 1fr));
    row-gap: 14px;
    min-height: 900px;
}

.generation-2 .ancestor-slot-1 { grid-row: 1 / span 2; align-self: center; }
.generation-2 .ancestor-slot-2 { grid-row: 3 / span 2; align-self: center; }
.generation-2 .ancestor-slot-3 { grid-row: 5 / span 2; align-self: center; }
.generation-2 .ancestor-slot-4 { grid-row: 7 / span 2; align-self: center; }

.generation-1 .ancestor-slot-1 { grid-row: 2 / span 3; align-self: center; }
.generation-1 .ancestor-slot-2 { grid-row: 6 / span 3; align-self: center; }

.selected-card {
    grid-row: 3 / span 4;
    align-self: center;
    border-width: 2px;
}

.rabbit-card {
    border: 1px solid var(--line);
    border-radius: 14px;
    background: #fff;
    padding: 12px;
}

.dashboard-action-list {
    margin-top: 14px;
}

.dashboard-action-card {
    width: 100%;
}

.rabbit-card strong { display: block; }

.rabbit-record-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.rabbit-record {
    border: 1px solid var(--line);
    border-left: 6px solid var(--line);
    border-radius: 14px;
    background: #fff;
    padding: 14px 16px;
    display: grid;
    grid-template-columns: 72px minmax(0, 1fr);
    gap: 12px;
    align-items: center;
}

.rabbit-record-buck {
    border-left-color: #5e89c7;
}

.rabbit-record-doe {
    border-left-color: #d27a8d;
}

.rabbit-record-head {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 12px;
}

.rabbit-record-body {
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-width: 0;
}

.rabbit-record-link {
    text-decoration: none;
    font-weight: 700;
    font-size: 18px;
    min-width: 0;
}

.rabbit-record-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    color: var(--muted);
}

.rabbit-sex-tag {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 5px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
    white-space: nowrap;
}

.rabbit-sex-tag-buck {
    background: #e3eefc;
    color: #31588f;
}

.rabbit-sex-tag-doe {
    background: #f8e1e8;
    color: #8f3854;
}

.rabbit-sex-tag-unknown {
    background: #efe5d7;
    color: #6f4e37;
}

.rabbit-record-cover,
.rabbit-record-cover-placeholder {
    width: 72px;
    aspect-ratio: 1;
    border-radius: 12px;
    overflow: hidden;
    background: #f1e7d9;
    border: 1px solid var(--line);
}

.rabbit-record-cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.rabbit-record-cover-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--muted);
    font-size: 11px;
    text-align: center;
    padding: 6px;
}

.rabbit-photo-panel {
    gap: 14px;
}

.rabbit-photo-inline {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 18px;
}

.photo-upload-form {
    margin: 0;
}

.photo-upload-button {
    position: relative;
    overflow: hidden;
}

.photo-upload-button input[type="file"] {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
}

.rabbit-photo-cover,
.rabbit-photo-cover-placeholder {
    width: 100%;
    max-width: 320px;
    aspect-ratio: 1;
    border-radius: 16px;
    overflow: hidden;
    background: #f1e7d9;
    border: 1px solid var(--line);
}

.rabbit-photo-cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.rabbit-photo-cover-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--muted);
    font-weight: 600;
}

.rabbit-photo-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 12px;
}

.rabbit-photo-cover-top {
    max-width: 360px;
}

.rabbit-photo-strip,
.rabbit-gallery-strip {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    padding-bottom: 6px;
}

.rabbit-photo-strip-thumb {
    width: 86px;
    min-width: 86px;
    aspect-ratio: 1;
    border-radius: 12px;
    overflow: hidden;
    border: 2px solid transparent;
    display: block;
    background: #f1e7d9;
}

.rabbit-photo-strip-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.rabbit-photo-strip-thumb.is-cover {
    border-color: var(--accent);
}

.rabbit-photo-strip-thumb.is-selected {
    border-color: #31588f;
}

.rabbit-gallery-panel {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.rabbit-gallery-main {
    width: 100%;
    max-width: 520px;
    border-radius: 18px;
    overflow: hidden;
    border: 1px solid var(--line);
    background: #fff;
}

.rabbit-gallery-main a {
    display: block;
}

.rabbit-gallery-main img {
    width: 100%;
    display: block;
    object-fit: cover;
}

.photo-cover-pill {
    display: inline-flex;
    align-items: center;
    padding: 10px 14px;
    border-radius: 999px;
    background: var(--accent-soft);
    color: var(--ink);
    font-weight: 700;
}

.rabbit-photo-thumb-card {
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 10px;
    background: #fff;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.rabbit-photo-thumb-card.is-cover {
    border-color: var(--accent);
    box-shadow: inset 0 0 0 1px var(--accent);
}

.rabbit-photo-thumb-card a {
    display: block;
}

.rabbit-photo-thumb-card img {
    width: 100%;
    aspect-ratio: 1;
    object-fit: cover;
    border-radius: 12px;
    display: block;
}

.record-file-list {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.record-file-card {
    border: 1px solid var(--line);
    border-radius: 14px;
    background: #fff;
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.record-file-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
}

.photo-thumb-actions {
    gap: 8px;
}

.photo-thumb-actions form {
    margin: 0;
}

.pedigree-export-page {
    width: 975px;
    min-height: 754px;
    height: 754px;
    margin: 0 auto;
    background: #fff;
    color: #000;
    position: relative;
    box-shadow: 0 18px 60px rgba(0, 0, 0, 0.18);
    overflow: hidden;
    font-family: Arial, sans-serif;
}

.pedigree-export-template {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    display: block;
    object-fit: fill;
    z-index: 0;
    pointer-events: none;
}

.pedigree-export-title {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    font-family: "Times New Roman", Georgia, serif;
    font-style: italic;
    font-size: 52px;
    line-height: 1;
    color: #000;
    z-index: 1;
}

.pedigree-export-section-title {
    position: absolute;
    font-size: 12px;
    font-weight: 700;
    line-height: 1;
    color: #000;
    z-index: 1;
}

.pedigree-export-section-title.static {
    position: static;
}

.pedigree-export-field {
    position: absolute;
    color: #000;
    z-index: 1;
}

.pedigree-export-field-label,
.pedigree-export-node-relation {
    font-size: 10px;
    line-height: 1;
    color: #000;
}

.pedigree-export-field-value {
    margin-top: 2px;
    font-size: 12px;
    line-height: 1.1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.pedigree-export-field-line {
    margin-top: 2px;
    border-bottom: 1px solid #000;
}

.pedigree-export-text-block {
    position: absolute;
    display: flex;
    flex-direction: column;
    gap: 2px;
    color: #000;
    z-index: 1;
}

.pedigree-export-line {
    font-size: 12px;
    line-height: 1.1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.pedigree-export-line.strong {
    font-weight: 700;
}

.pedigree-export-line.small {
    font-size: 10px;
    line-height: 1.05;
}

.pedigree-export-node {
    gap: 1px;
}

.pedigree-export-underline-row {
    display: flex;
    flex-direction: column;
    gap: 2px;
    height: 22px;
}

.pedigree-export-text-block.breeder .pedigree-export-underline-row {
    height: 24px;
}

.pedigree-export-text-block.italic .pedigree-export-line {
    font-family: "Times New Roman", Georgia, serif;
    font-style: italic;
    font-size: 14px;
    line-height: 1;
}

.pedigree-export-breeder-title {
    font-size: 30px;
    line-height: 1;
    margin-bottom: 2px;
}

.pedigree-export-breeder-line {
    font-size: 18px;
    line-height: 1.1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.changes-panel {
    overflow: hidden;
}

.changes-report {
    margin: 0;
    padding: 20px;
    white-space: pre-wrap;
    word-break: break-word;
    font: 0.95rem/1.55 "Consolas", "Courier New", monospace;
    color: var(--ink);
    background: rgba(255, 255, 255, 0.55);
}

@media print {
    @page {
        size: letter landscape;
        margin: 0;
    }

    body {
        background: #fff;
        margin: 0;
    }

    .sidebar,
    .print-hide,
    .flash-stack,
    .main > :not(.pedigree-export-shell) {
        display: none !important;
    }

    .app-shell,
    .main,
    .pedigree-export-shell {
        display: block !important;
        margin: 0 !important;
        padding: 0 !important;
        gap: 0 !important;
        background: transparent !important;
        border: 0 !important;
        box-shadow: none !important;
    }

    .pedigree-export-shell {
        width: 975px !important;
        min-height: 754px !important;
        height: 754px !important;
        overflow: hidden !important;
    }

    .pedigree-export-page {
        position: relative;
        margin: 0;
        box-shadow: none;
        page-break-inside: avoid;
        break-inside: avoid;
    }
}

@media (max-width: 1100px) {
    .landing-hero {
        grid-template-columns: 1fr;
    }
    .app-shell {
        display: block;
    }
    .split { grid-template-columns: 1fr; }
    .ancestor-grid { grid-template-columns: 1fr 1fr; }
    .main {
        padding: 12px 16px 16px;
        gap: 16px;
    }
    .hero,
    .panel {
        padding: 16px;
    }
    .sidebar {
        padding: 16px;
        gap: 0;
        position: relative;
        overflow: visible;
        min-height: auto;
        height: auto;
    }
    .sidebar-toggle {
        display: inline-flex;
    }
    .sidebar-content {
        display: none;
        position: absolute;
        left: 16px;
        right: 16px;
        top: calc(100% + 8px);
        z-index: 50;
        background: #30271e;
        padding: 12px;
        border-radius: 16px;
        box-shadow: 0 16px 40px rgba(0, 0, 0, 0.22);
    }
    .sidebar.is-open .sidebar-content {
        display: flex;
    }
    .mobile-hide {
        display: none;
    }
    .due-table {
        table-layout: fixed;
        width: 100%;
    }
    .due-table th,
    .due-table td {
        overflow-wrap: anywhere;
        word-break: break-word;
    }
    .due-table th:nth-child(1),
    .due-table td:nth-child(1) {
        width: 34%;
    }
    .due-table th:nth-child(2),
    .due-table td:nth-child(2) {
        width: 66%;
        max-width: 0;
    }
    .due-table .due-litter {
        max-width: 0;
        overflow: hidden;
    }
    .due-table .due-litter-link {
        display: block;
        max-width: 100%;
        white-space: normal;
        overflow-wrap: anywhere;
        word-break: break-word;
    }
    .litter-table th,
    .litter-table td {
        white-space: normal;
    }
    .litter-filter-toolbar {
        align-items: stretch;
    }
    .litter-filter-toolbar > * {
        width: 100%;
    }
    .litter-archive-toggle {
        width: 100%;
    }
    .calendar-cell {
        padding: 2px;
    }
    .badge {
        padding: 2px 6px;
        border-radius: 0;
        margin-top: 4px;
    }
}
