:root {
    --green: #07371f;
    --green-2: #0f4a2e;
    --gold: #d6b36b;
    --gold-light: #f1d994;
    --cream: #f8f3e7;
    --dark: #102016;
    --glass: rgba(7, 55, 31, 0.88);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
    margin: 0;
    font-family: Georgia, 'Times New Roman', serif;
    color: var(--cream);
    background:
        radial-gradient(circle at top left, rgba(214,179,107,.22), transparent 32%),
        linear-gradient(135deg, #061b12, #0a2a1a 45%, #03140d);
    min-height: 100vh;
}
body::before {
    content: "";
    position: fixed;
    inset: 0;
    background-image: linear-gradient(rgba(255,255,255,.025) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.025) 1px, transparent 1px);
    background-size: 38px 38px;
    pointer-events: none;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 22px;
    background: rgba(4, 32, 19, .94);
    border-bottom: 1px solid rgba(214,179,107,.45);
    box-shadow: 0 10px 35px rgba(0,0,0,.28);
    backdrop-filter: blur(12px);
}
.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--gold-light);
    text-decoration: none;
    font-size: 26px;
    font-weight: 700;
    letter-spacing: .5px;
}
.brand img {
    width: 54px;
    height: 54px;
    border-radius: 50%;
    object-fit: cover;
    box-shadow: 0 0 0 2px rgba(214,179,107,.5);
}
.top-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}
.logout-form, .delete-form { margin: 0; }
.menu-wrap { position: relative; }

button, .edit-btn {
    border: 1px solid rgba(214,179,107,.75);
    background: linear-gradient(180deg, var(--gold-light), var(--gold));
    color: #17301f;
    border-radius: 999px;
    padding: 11px 18px;
    font-weight: 700;
    cursor: pointer;
    font-family: inherit;
    text-decoration: none;
    display: inline-block;
    box-shadow: 0 8px 20px rgba(0,0,0,.22);
}
button:hover, .edit-btn:hover { filter: brightness(1.06); }
.danger {
    background: linear-gradient(180deg, #f2b2a8, #cf6b5e);
    color: #2b0905;
}

.dropdown {
    position: absolute;
    top: 58px;
    right: 0;
    min-width: 230px;
    display: none;
    flex-direction: column;
    gap: 7px;
    padding: 14px;
    background: var(--glass);
    border: 1px solid rgba(214,179,107,.5);
    border-radius: 18px;
    box-shadow: 0 20px 50px rgba(0,0,0,.35);
}
.dropdown.open { display: flex; }
.dropdown a {
    width: 100%;
    text-align: left;
    text-decoration: none;
    color: var(--cream);
    padding: 12px 14px;
    border-radius: 12px;
    background: rgba(255,255,255,.06);
    border: 1px solid rgba(255,255,255,.08);
}
.dropdown a:hover { background: rgba(214,179,107,.2); }
.dropdown .sep {
    height: 1px;
    background: rgba(214,179,107,.45);
    margin: 7px 4px;
}

.adminbar {
    position: sticky;
    top: 79px;
    z-index: 15;
    background: rgba(214,179,107,.96);
    color: #102016;
    padding: 9px 16px;
    text-align: center;
    font-weight: 700;
}

main {
    width: min(1160px, calc(100% - 28px));
    margin: 34px auto 70px;
}
.section-card {
    background: rgba(255,255,255,.075);
    border: 1px solid rgba(214,179,107,.32);
    border-radius: 30px;
    padding: clamp(22px, 4vw, 46px);
    margin-bottom: 28px;
    box-shadow: 0 30px 80px rgba(0,0,0,.3);
    backdrop-filter: blur(9px);
}
.hero {
    display: grid;
    grid-template-columns: 1.1fr .9fr;
    gap: 28px;
    align-items: center;
    min-height: 560px;
}
h1, h2 {
    color: var(--gold-light);
    margin: 0 0 16px;
    line-height: 1.05;
}
h1 { font-size: clamp(42px, 7vw, 86px); }
h2 { font-size: clamp(30px, 4vw, 54px); }
p {
    font-size: clamp(18px, 2.1vw, 24px);
    line-height: 1.6;
    margin: 0;
    color: rgba(248,243,231,.92);
}
.hero-logo-wrap { text-align: center; }
.hero-logo {
    width: min(440px, 100%);
    border-radius: 28px;
    filter: drop-shadow(0 20px 34px rgba(0,0,0,.45));
}
.split-section {
    display: grid;
    grid-template-columns: 230px 1fr;
    gap: 28px;
    align-items: center;
}
.section-logo {
    width: 100%;
    border-radius: 24px;
    filter: drop-shadow(0 16px 26px rgba(0,0,0,.35));
}
.editable-line {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 12px;
    align-items: start;
    margin-bottom: 14px;
}
.edit-btn { padding: 8px 13px; font-size: 14px; }

.form {
    display: grid;
    gap: 12px;
    max-width: 760px;
}
label { color: var(--gold-light); font-weight: 700; }
input, select, textarea {
    width: 100%;
    padding: 13px 14px;
    border-radius: 14px;
    border: 1px solid rgba(214,179,107,.5);
    background: rgba(255,255,255,.08);
    color: white;
    font-size: 17px;
    font-family: Arial, sans-serif;
}
select option { color: #102016; }
textarea { resize: vertical; min-height: 170px; }
.form button { width: fit-content; }
.notice {
    padding: 14px 16px;
    border-radius: 16px;
    background: rgba(214,179,107,.18);
    border: 1px solid rgba(214,179,107,.42);
    margin-bottom: 16px;
}
.small {
    color: var(--gold-light);
    opacity: .85;
    margin-bottom: 10px;
    font-size: 16px;
}
.event-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 16px;
}
.event-card {
    background: rgba(255,255,255,.065);
    border: 1px solid rgba(214,179,107,.25);
    border-radius: 24px;
    padding: 22px;
    margin-top: 18px;
}
.event-card h2 { font-size: 30px; }
.admin-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 16px;
}
.user-card { max-width: 850px; }
.login-card { max-width: 680px; margin-left: auto; margin-right: auto; }
.footer {
    opacity: .62;
    text-align: center;
    padding: 30px;
}

@media (max-width: 760px) {
    .brand span { font-size: 21px; }
    .brand img { width: 45px; height: 45px; }
    .topbar { padding: 10px 12px; }
    .top-actions { gap: 7px; }
    .dropdown { top: 54px; right: 0; }
    .hero, .split-section { grid-template-columns: 1fr; }
    .hero { min-height: auto; }
    .section-logo { width: min(260px, 85%); margin: 0 auto; }
    .editable-line { grid-template-columns: 1fr; }
    button, .edit-btn { padding: 10px 13px; }
}

.user-list {
    display: grid;
    gap: 14px;
    margin-top: 18px;
}
.user-row {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 18px;
    align-items: center;
    background: rgba(255,255,255,.065);
    border: 1px solid rgba(214,179,107,.25);
    border-radius: 24px;
    padding: 20px;
}
.user-info h2 {
    font-size: 30px;
    margin-bottom: 6px;
}
.user-info p {
    font-size: 18px;
}
.user-contact {
    color: rgba(248,243,231,.82);
    margin-top: 8px;
    font-size: 16px;
}
@media (max-width: 760px) {
    .user-row { grid-template-columns: 1fr; }
}


/* Sauekontroll - appstil */
body:has(.sheep-page-card) {
    background:
        radial-gradient(circle at 20% 0%, rgba(241,217,148,.16), transparent 28%),
        linear-gradient(180deg, #071a12, #0a2318 48%, #06140e);
}
body:has(.sheep-page-card) main {
    width: min(720px, 100%);
    margin: 0 auto 38px;
    padding: 0 12px;
}
.sheep-page-card {
    background: transparent;
    border: 0;
    border-radius: 0;
    padding: 14px 0 28px;
    box-shadow: none;
    backdrop-filter: none;
}
.sheep-topline {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin: 0 -12px 16px;
    padding: 12px;
    background: rgba(4, 32, 19, .86);
    border-bottom: 1px solid rgba(214,179,107,.22);
    backdrop-filter: blur(12px);
}
.sheep-title-mini {
    color: var(--gold-light);
    font-weight: 800;
    font-size: 18px;
    letter-spacing: .4px;
}
.sheep-hero {
    display: grid;
    grid-template-columns: 86px 1fr;
    gap: 14px;
    align-items: center;
    margin: 8px 0 18px;
    background: linear-gradient(145deg, rgba(214,179,107,.18), rgba(255,255,255,.055));
    border: 1px solid rgba(214,179,107,.22);
    border-radius: 26px;
    padding: 16px;
}
.sheep-hero img {
    width: 86px;
    height: 86px;
    object-fit: cover;
    border-radius: 22px;
    filter: drop-shadow(0 12px 20px rgba(0,0,0,.35));
}
.sheep-hero h1 { font-size: 34px; margin-bottom: 6px; }
.sheep-hero p { font-size: 16px; line-height: 1.35; }
.sheep-panel-grid {
    display: grid;
    gap: 12px;
}
.sheep-panel {
    background: rgba(255,255,255,.07);
    border: 1px solid rgba(214,179,107,.2);
    border-radius: 24px;
    padding: 18px;
    box-shadow: 0 16px 34px rgba(0,0,0,.22);
}
.sheep-panel h2 {
    font-size: 25px;
    margin-bottom: 12px;
}
.sheep-panel-bottom { margin-top: 4px; }
.sheep-form-small { max-width: none; }
.sheep-results {
    display: grid;
    gap: 9px;
    margin-top: 14px;
}
.sheep-result-row, .sheep-child-link {
    display: grid;
    gap: 4px;
    color: var(--cream);
    text-decoration: none;
    background: rgba(0,0,0,.16);
    border: 1px solid rgba(214,179,107,.18);
    border-radius: 18px;
    padding: 14px;
}
.sheep-result-row:hover, .sheep-child-link:hover { background: rgba(214,179,107,.15); }
.sheep-result-row span, .sheep-child-link span { color: rgba(248,243,231,.75); font-size: 14px; }
.sheep-modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 100;
    background: rgba(0,0,0,.72);
    padding: 10px;
    overflow: auto;
}
.sheep-modal.open { display: block; }
.sheep-modal-box {
    width: min(720px, 100%);
    margin: 12px auto;
    position: relative;
    background: linear-gradient(180deg, rgba(10,48,31,.99), rgba(6,31,20,.99));
    border: 1px solid rgba(214,179,107,.32);
    border-radius: 28px;
    padding: 22px;
    box-shadow: 0 30px 90px rgba(0,0,0,.58);
}
.sheep-info-box { width: min(760px, 100%); }
.sheep-lamming-box { width: min(760px, 100%); }
.sheep-close {
    position: absolute;
    top: 12px;
    right: 14px;
    width: 42px;
    height: 42px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: rgba(255,255,255,.09);
    color: var(--gold-light);
    text-decoration: none;
    border: 1px solid rgba(214,179,107,.35);
    font-size: 26px;
    padding: 0;
}
.sheep-lamming-top {
    display: grid;
    grid-template-columns: 1fr 1.3fr;
    gap: 12px;
    margin-top: 12px;
}
.sheep-lamming-top label { display: grid; gap: 7px; }
.sheep-action-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin: 16px 0;
}
.sheep-lambing-form {
    display: none;
    background: rgba(255,255,255,.055);
    border: 1px solid rgba(214,179,107,.18);
    border-radius: 20px;
    padding: 16px;
    margin-top: 10px;
}
.sheep-lambing-form.open { display: grid; }
.sheep-status-form {
    display: grid;
    grid-template-columns: 80px minmax(150px, 220px);
    gap: 10px;
    align-items: center;
    margin-bottom: 18px;
}
.sheep-info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 10px;
    margin: 18px 0;
}
.sheep-info-grid div {
    background: rgba(0,0,0,.14);
    border: 1px solid rgba(214,179,107,.16);
    border-radius: 18px;
    padding: 13px;
}
.sheep-info-grid span {
    display: block;
    color: rgba(248,243,231,.72);
    font-size: 13px;
    margin-bottom: 5px;
}
.sheep-info-grid strong { color: var(--gold-light); font-size: 18px; }
.sheep-tabs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 9px;
    margin: 18px 0;
}
.sheep-inner-box {
    display: none;
    background: rgba(255,255,255,.055);
    border: 1px solid rgba(214,179,107,.18);
    border-radius: 22px;
    padding: 16px;
    margin-top: 12px;
}
.sheep-inner-box.open { display: block; }
.sheep-inner-box h3 { color: var(--gold-light); margin: 0 0 14px; font-size: 25px; }
.sheep-comment, .sheep-lambing-note {
    padding: 14px;
    border-radius: 18px;
    background: rgba(0,0,0,.16);
    border: 1px solid rgba(255,255,255,.08);
    margin-bottom: 10px;
}
.sheep-comment p, .sheep-lambing-note p { font-size: 16px; margin-bottom: 8px; }
.sheep-comment-form { margin-top: 18px; }
.sheep-year-group {
    margin-bottom: 18px;
    display: grid;
    gap: 8px;
}
.sheep-year-group h4 {
    color: var(--gold-light);
    margin: 8px 0 0;
    font-size: 22px;
}
@media (max-width: 760px) {
    body:has(.sheep-page-card) main { padding: 0 10px; }
    .sheep-hero { grid-template-columns: 72px 1fr; padding: 14px; }
    .sheep-hero img { width: 72px; height: 72px; }
    .sheep-hero h1 { font-size: 29px; }
    .sheep-lamming-top { grid-template-columns: 1fr; }
    .sheep-status-form { grid-template-columns: 1fr; }
    .sheep-modal-box { padding: 19px; border-radius: 24px; }
}

/* Sauekontroll v1.3 - mer kompakt lamming */
.sheep-lambing-compact-row {
    display: grid;
    grid-template-columns: 1fr 1fr 120px;
    gap: 10px;
}
.sheep-lambing-compact-row label {
    display: grid;
    gap: 7px;
}
.sheep-lambing-form textarea {
    min-height: 88px;
}
.sheep-lambing-form input,
.sheep-lambing-form select,
.sheep-lambing-form textarea {
    padding: 10px 12px;
}
.sheep-lambing-form button[type="submit"] {
    width: 100%;
    margin-top: 4px;
}
@media (max-width: 760px) {
    .sheep-lambing-compact-row { grid-template-columns: 1fr; }
}

/* Sauekontroll v1.4 - flere lam i samme lamming */
.lambing-rows {
    display: grid;
    gap: 12px;
}
.lambing-entry {
    display: grid;
    gap: 10px;
    background: rgba(0,0,0,.16);
    border: 1px solid rgba(214,179,107,.20);
    border-radius: 18px;
    padding: 12px;
}
.lambing-entry-deadborn {
    border-color: rgba(207,107,94,.55);
}
.lambing-entry-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    color: var(--gold-light);
}
.mini-danger {
    padding: 6px 10px;
    font-size: 13px;
    background: linear-gradient(180deg, #f2b2a8, #cf6b5e);
    color: #2b0905;
}
.sheep-action-row-bottom {
    margin: 4px 0 0;
}
.sheep-save-full {
    width: 100%;
    margin-top: 0;
}


.sheep-lambing-note-simple {
    display: grid;
    gap: 4px;
    padding: 11px 12px;
    background: rgba(214,179,107,.10);
    border-color: rgba(214,179,107,.24);
}
.sheep-lambing-note-simple strong {
    color: var(--gold-light);
    font-size: 14px;
}
.sheep-lambing-note-simple span {
    color: rgba(248,243,231,.9);
    font-size: 15px;
    line-height: 1.35;
}
.sheep-child-link-simple {
    display: block;
    padding: 11px 13px;
    font-size: 17px;
    font-weight: 700;
}

.sheep-dead, .sheep-dead:hover {
    border-color: rgba(255, 95, 95, .75) !important;
    background: rgba(120, 15, 15, .28) !important;
}
.sheep-dead strong, .sheep-dead span, .sheep-dead-title, .sheep-dead-inline {
    color: #ffb0a8 !important;
}
.sheep-dead-status select {
    border-color: rgba(255, 95, 95, .8);
    color: #ffddd9;
}
.sheep-inline-link {
    color: var(--gold-light);
    text-decoration: none;
    border-bottom: 1px solid rgba(214,179,107,.55);
}
.sheep-inline-link:hover { filter: brightness(1.15); }


.sheep-panel-button {
    display: grid;
    place-items: center;
    min-height: 86px;
}
.sheep-panel-button button {
    width: min(360px, 100%);
    font-size: 18px;
    padding: 15px 20px;
}
.sheep-status-ok {
    margin-top: 14px;
    padding: 12px 14px;
    border-radius: 18px;
    background: rgba(72, 184, 111, .16);
    border: 1px solid rgba(72, 184, 111, .35);
    color: #d9ffe4;
    font-weight: 700;
}
.sheep-status-box { width: min(900px, 100%); }
.status-change-grid {
    display: grid;
    grid-template-columns: 1fr minmax(140px, .55fr) 1.25fr;
    gap: 12px;
    align-items: start;
}
.status-list-box {
    background: rgba(0,0,0,.14);
    border: 1px solid rgba(214,179,107,.18);
    border-radius: 18px;
    padding: 12px;
    min-height: 104px;
}
.status-chosen-list {
    display: grid;
    gap: 7px;
    margin-top: 10px;
}
.status-picked-row {
    display: grid;
    grid-template-columns: 1fr auto 34px;
    gap: 8px;
    align-items: center;
    background: rgba(255,255,255,.07);
    border: 1px solid rgba(214,179,107,.16);
    border-radius: 14px;
    padding: 8px 9px;
}
.status-picked-row span { font-weight: 800; color: var(--gold-light); }
.status-picked-row strong { color: rgba(248,243,231,.9); }
.status-picked-row button {
    width: 30px;
    height: 30px;
    padding: 0;
    border-radius: 50%;
}
@media (max-width: 760px) {
    .status-change-grid { grid-template-columns: 1fr; }
}


.sheep-delete-all-form { margin: 0; }
.sheep-topline .danger { padding: 8px 13px; font-size: 14px; }

.status-id-message {
    display: block;
    margin-top: 7px;
    font-size: 14px;
    color: #ffb7ad;
    font-family: Arial, sans-serif;
}
.status-id-message.ok { color: #bff0c3; }
.sheep-status-error {
    margin-top: 14px;
    padding: 12px 14px;
    border-radius: 16px;
    background: rgba(207, 107, 94, .2);
    border: 1px solid rgba(207, 107, 94, .55);
    color: #ffd8d3;
    font-weight: 700;
}

.sheep-file-row {
    display: grid;
    grid-template-columns: 1fr auto auto;
    gap: 10px;
    align-items: center;
}
.camera-btn {
    margin: 0;
    border: 1px solid rgba(214,179,107,.75);
    background: linear-gradient(180deg, var(--gold-light), var(--gold));
    color: #17301f;
    border-radius: 999px;
    padding: 11px 15px;
    font-weight: 700;
    cursor: pointer;
    white-space: nowrap;
    box-shadow: 0 8px 20px rgba(0,0,0,.22);
}
.camera-status {
    color: var(--gold-light);
    font-weight: 700;
    font-size: 14px;
}
.sheep-camera-box {
    position: fixed;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 18px;
    background: rgba(0,0,0,.72);
    z-index: 9999;
}
.sheep-camera-box.open { display: flex; }
.sheep-camera-panel {
    width: min(720px, 100%);
    background: rgba(7, 55, 31, .98);
    border: 1px solid rgba(214,179,107,.55);
    border-radius: 24px;
    padding: 16px;
    position: relative;
    box-shadow: 0 30px 80px rgba(0,0,0,.5);
}
.sheep-camera-panel video {
    width: 100%;
    max-height: 62vh;
    object-fit: contain;
    border-radius: 18px;
    background: #000;
}
.sheep-camera-close {
    position: absolute;
    top: 8px;
    right: 8px;
    z-index: 2;
    padding: 8px 13px;
}
.sheep-camera-actions {
    display: flex;
    gap: 10px;
    margin-top: 12px;
    flex-wrap: wrap;
}
.sheep-camera-actions button { flex: 1; }
@media (max-width: 760px) {
    .sheep-file-row { grid-template-columns: 1fr; }
    .camera-btn { text-align: center; }
    .camera-status { text-align: center; }
}


/* Sauekontroll v1.13 */
.sheep-slakt, .sheep-slakt:hover {
    border-color: rgba(255, 168, 64, .85) !important;
    background: rgba(145, 82, 8, .30) !important;
}
.sheep-slakt strong, .sheep-slakt span, .sheep-slakt-title, .sheep-slakt-inline {
    color: #ffd29a !important;
}
.sheep-slakt-status select {
    border-color: rgba(255, 168, 64, .85);
    color: #ffe3bb;
}
.sheep-overview-panel h2 { margin-bottom: 10px; }
.sheep-overview-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}
.sheep-overview-grid div {
    background: rgba(0,0,0,.16);
    border: 1px solid rgba(214,179,107,.20);
    border-radius: 18px;
    padding: 14px;
}
.sheep-overview-grid span {
    display: block;
    color: rgba(248,243,231,.75);
    font-size: 14px;
    margin-bottom: 5px;
}
.sheep-overview-grid strong {
    display: block;
    color: var(--gold-light);
    font-size: 32px;
    line-height: 1;
}
.sheep-checkline {
    display: flex;
    align-items: center;
    gap: 9px;
    width: fit-content;
    color: var(--gold-light);
    font-weight: 700;
}
.sheep-checkline input {
    width: auto;
    accent-color: var(--gold);
}
@media (min-width: 900px) {
    .sheep-panel-grid {
        grid-template-columns: 1.35fr .75fr;
        align-items: stretch;
    }
    .sheep-panel-grid > .sheep-panel:first-child { grid-row: span 4; }
}


/* Sauekontroll v1.14 */
.sheep-panel-grid-with-overview {
    display: grid;
    gap: 12px;
}
.sheep-side-area {
    display: grid;
    gap: 12px;
}
.sheep-button-stack {
    display: grid;
    gap: 12px;
}
.sheep-button-stack .sheep-panel-bottom { margin-top: 0; }
@media (min-width: 900px) {
    .sheep-panel-grid-with-overview {
        grid-template-columns: 1.35fr 1fr;
        align-items: stretch;
    }
    .sheep-panel-grid-with-overview > .sheep-search-panel {
        grid-row: auto;
    }
    .sheep-side-area {
        grid-template-columns: 1fr .95fr;
        align-items: stretch;
    }
    .sheep-overview-panel {
        align-self: stretch;
    }
    .sheep-overview-grid {
        grid-template-columns: 1fr;
    }
}
@media (max-width: 899px) {
    .sheep-side-area {
        grid-template-columns: 1fr;
    }
}

/* Sauekontroll v1.15 */
body:has(.sheep-page-card) .sheep-panel-grid {
    grid-template-columns: 1fr !important;
}
body:has(.sheep-page-card) .sheep-panel-grid > .sheep-panel:first-child {
    grid-row: auto !important;
}
.sheep-main-buttons {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
    margin-top: 22px;
}
.sheep-main-buttons button {
    width: 100%;
    min-height: 92px;
    font-size: clamp(24px, 3vw, 36px);
    border-radius: 999px;
}
.sheep-overview-box { width: min(760px, 100%); }
.sheep-overview-grid-big {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
    margin-top: 18px;
}
.sheep-overview-grid-big div {
    padding: 20px;
    border-radius: 24px;
}
.sheep-overview-grid-big span {
    font-size: 18px;
}
.sheep-overview-grid-big strong {
    font-size: 48px;
}
@media (max-width: 760px) {
    .sheep-main-buttons { grid-template-columns: 1fr; }
    .sheep-main-buttons button { min-height: 74px; font-size: 25px; }
    .sheep-overview-grid-big { grid-template-columns: 1fr; }
}

/* Sauekontroll v1.16 - avlange hovedknapper */
.sheep-main-buttons {
    grid-template-columns: 1fr !important;
    gap: 12px;
}
.sheep-main-buttons button {
    width: 100%;
    min-height: 68px !important;
    font-size: clamp(23px, 2.6vw, 34px) !important;
    border-radius: 999px;
}
@media (max-width: 760px) {
    .sheep-main-buttons button {
        min-height: 62px !important;
        font-size: 24px !important;
    }
}

/* Sauekontroll v1.17 - ryddigere oversikt */
.sheep-overview-summary {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
    margin-top: 18px;
}
.overview-main-card {
    background: rgba(214,179,107,.14);
    border: 1px solid rgba(214,179,107,.42);
    border-radius: 26px;
    padding: 24px;
    text-align: center;
}
.overview-main-card span {
    display: block;
    color: var(--gold-light);
    font-size: 21px;
    font-weight: 800;
    margin-bottom: 8px;
}
.overview-main-card strong {
    display: block;
    font-size: 62px;
    line-height: 1;
    color: var(--gold-light);
}
.sheep-overview-list {
    display: grid;
    gap: 12px;
    margin-top: 16px;
}
.sheep-overview-list div {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    background: rgba(255,255,255,.07);
    border: 1px solid rgba(214,179,107,.28);
    border-radius: 18px;
    padding: 15px 18px;
}
.sheep-overview-list span {
    font-size: 20px;
    color: rgba(248,243,231,.95);
    font-weight: 700;
}
.sheep-overview-list strong {
    min-width: 54px;
    text-align: center;
    font-size: 34px;
    color: var(--gold-light);
}
@media (max-width: 760px) {
    .sheep-overview-summary { grid-template-columns: 1fr; }
    .overview-main-card strong { font-size: 50px; }
}


.sheep-download-box { max-width: 520px; }
.sheep-download-buttons {
    display: grid;
    gap: 12px;
    margin-top: 18px;
}
.sheep-download-buttons .edit-btn {
    width: 100%;
    text-align: center;
    padding: 16px 18px;
    border-radius: 18px;
    font-size: 18px;
}
.sheep-topline > .edit-btn,
.sheep-topline > button.edit-btn {
    padding: 8px 13px;
    font-size: 14px;
    white-space: nowrap;
}
.sheep-year-box { max-width: 430px; }

.status-comment-bubble {
    display: none;
    margin-top: 14px;
    padding: 14px;
    border-radius: 20px;
    background: rgba(214,179,107,.13);
    border: 1px solid rgba(214,179,107,.36);
    box-shadow: 0 14px 30px rgba(0,0,0,.20);
}
.status-comment-bubble.open {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 10px;
    align-items: end;
}
.status-comment-bubble strong {
    grid-column: 1 / -1;
    color: var(--gold-light);
}
.status-comment-bubble input { min-width: 0; }
.status-picked-row { grid-template-columns: 1fr auto; }
.status-picked-row small {
    display: block;
    margin-top: 3px;
    color: rgba(248,243,231,.78);
    font-weight: 400;
    font-family: Arial, sans-serif;
}
@media (max-width: 760px) {
    .status-comment-bubble.open { grid-template-columns: 1fr; }
}

/* Sauekontroll v1.22 - mobil og oversikt live */
body:has(.sheep-page-card) {
    overflow-x: hidden;
}
.sheep-page-card, .sheep-page-card * {
    max-width: 100%;
}
@media (max-width: 760px) {
    body:has(.sheep-page-card) main {
        width: 100%;
        padding: 0 8px;
        overflow-x: hidden;
    }
    .sheep-topline {
        margin: 0 0 12px;
        padding: 8px;
        gap: 6px;
        flex-wrap: wrap;
        justify-content: flex-start;
        border-radius: 0 0 16px 16px;
    }
    .sheep-topline .sheep-title-mini {
        width: 100%;
        order: 5;
        font-size: 16px;
        margin-top: 2px;
    }
    .sheep-topline > .edit-btn,
    .sheep-topline > button.edit-btn,
    .sheep-topline .danger {
        padding: 7px 10px;
        font-size: 13px;
        white-space: nowrap;
    }
    .sheep-hero {
        margin-top: 8px;
    }
}

/* Sauekontroll v1.23 - funksjoner som egne visninger/sider */
.sheep-view-card {
    width: min(860px, calc(100% - 28px));
    margin: 24px auto 34px;
    position: relative;
    background: linear-gradient(180deg, rgba(10,48,31,.96), rgba(6,31,20,.96));
    border: 1px solid rgba(214,179,107,.34);
    border-radius: 30px;
    padding: clamp(20px, 3.5vw, 34px);
    box-shadow: 0 28px 80px rgba(0,0,0,.42);
}
.sheep-view-card h2 { padding-right: 54px; }
.sheep-main-buttons a {
    width: 100%;
    min-height: 68px;
    font-size: clamp(23px, 2.6vw, 34px);
    border-radius: 999px;
    border: 1px solid rgba(214,179,107,.75);
    background: linear-gradient(180deg, var(--gold-light), var(--gold));
    color: #17301f;
    font-weight: 700;
    cursor: pointer;
    font-family: inherit;
    text-decoration: none;
    display: grid;
    place-items: center;
    box-shadow: 0 8px 20px rgba(0,0,0,.22);
}
.sheep-main-buttons a:hover { filter: brightness(1.06); }
.sheep-view-card .sheep-close { position: absolute; }
@media (max-width: 760px) {
    .sheep-view-card {
        width: min(100% - 16px, 860px);
        margin: 16px auto 26px;
        padding: 18px;
        border-radius: 24px;
    }
    .sheep-main-buttons a {
        min-height: 62px;
        font-size: 24px;
    }
}


/* Sauekontroll v1.24 - egne sentrerte visninger */
.sheep-main-hidden {
    display: none !important;
}
body:has(.sheep-main-hidden) main {
    min-height: calc(100vh - 120px);
    display: grid;
    place-items: center;
    padding-top: 12px;
    padding-bottom: 12px;
}
body:has(.sheep-main-hidden) .sheep-view-card {
    margin: 0 auto;
    width: min(760px, calc(100vw - 24px));
    max-height: calc(100vh - 135px);
    overflow-y: auto;
}
body:has(.sheep-main-hidden) .sheep-view-card h2 {
    margin-bottom: 18px;
}
body:has(.sheep-main-hidden) .sheep-close {
    position: sticky;
    top: 0;
    float: right;
    z-index: 5;
}
@media (max-width: 760px) {
    body:has(.sheep-main-hidden) main {
        min-height: calc(100vh - 96px);
        padding: 8px;
    }
    body:has(.sheep-main-hidden) .sheep-view-card {
        width: calc(100vw - 16px);
        max-height: calc(100vh - 112px);
        padding: 16px;
    }
}

/* Sauekontroll v1.25 */
.sheep-save-full, a.sheep-save-full {
    border: 1px solid rgba(214,179,107,.75);
    background: linear-gradient(180deg, var(--gold-light), var(--gold));
    color: #17301f !important;
    border-radius: 999px;
    padding: 12px 18px;
    font-weight: 700;
    cursor: pointer;
    font-family: inherit;
    text-decoration: none;
    display: grid;
    place-items: center;
    box-shadow: 0 8px 20px rgba(0,0,0,.22);
    text-align: center;
    min-height: 46px;
}
.sheep-save-full:hover, a.sheep-save-full:hover { filter: brightness(1.06); }
body:has(.sheep-main-hidden) .sheep-info-box {
    width: min(820px, calc(100vw - 24px));
}


/* Sauekontroll v1.28 - startanimasjon */
.sheep-intro {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: none;
    overflow: hidden;
    background:
        radial-gradient(circle at top left, rgba(241,217,148,.25), transparent 35%),
        linear-gradient(135deg, #03140d, #07371f 55%, #020b07);
    cursor: pointer;
    color: var(--cream);
}
.sheep-intro.open { display: block; }
.sheep-intro.hide {
    opacity: 0;
    transform: scale(1.02);
    transition: opacity .28s ease, transform .28s ease;
}
.sheep-intro-slider {
    height: 100%;
    width: 200vw;
    display: flex;
    animation: sheepIntroSlide 3.4s ease-in-out forwards;
}
.sheep-intro-slide {
    width: 100vw;
    height: 100%;
    display: grid;
    place-items: center;
    align-content: center;
    gap: 22px;
    padding: 28px;
    text-align: center;
}
.sheep-intro-slide img {
    width: min(280px, 58vw);
    border-radius: 32px;
    filter: drop-shadow(0 28px 48px rgba(0,0,0,.48));
    animation: sheepIntroPop .9s ease both;
}
.sheep-intro-slide h1 {
    font-size: clamp(36px, 8vw, 82px);
    margin: 0;
    color: var(--gold-light);
    text-shadow: 0 12px 34px rgba(0,0,0,.45);
    animation: sheepIntroText .9s ease both;
}
.sheep-intro-slide p {
    font-size: clamp(16px, 3vw, 24px);
    opacity: .82;
}
.sheep-intro-icon {
    width: min(180px, 45vw);
    height: min(180px, 45vw);
    border-radius: 40px;
    display: grid;
    place-items: center;
    font-size: clamp(70px, 16vw, 130px);
    background: rgba(255,255,255,.09);
    border: 1px solid rgba(214,179,107,.42);
    box-shadow: 0 28px 60px rgba(0,0,0,.35);
}
@keyframes sheepIntroSlide {
    0%, 42% { transform: translateX(0); }
    58%, 100% { transform: translateX(-100vw); }
}
@keyframes sheepIntroPop {
    from { opacity: 0; transform: scale(.78) translateY(20px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}
@keyframes sheepIntroText {
    from { opacity: 0; transform: translateY(22px); }
    to { opacity: 1; transform: translateY(0); }
}
@media (max-width: 760px) {
    .sheep-intro-slide { padding: 18px; gap: 16px; }
    .sheep-intro-slide img { width: min(220px, 62vw); }
}

/* Sauekontroll bildevisning */
.sheep-image-view-card {
    max-width: min(960px, calc(100vw - 24px));
    margin-left: auto;
    margin-right: auto;
}
.sheep-image-stage {
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    margin-top: 14px;
}
.sheep-image-stage img {
    max-width: 100%;
    max-height: min(72vh, 760px);
    object-fit: contain;
    border-radius: 22px;
    border: 1px solid rgba(214,179,107,.35);
    box-shadow: 0 18px 45px rgba(0,0,0,.42);
    background: rgba(0,0,0,.2);
}
@media (max-width: 760px) {
    .sheep-image-view-card { padding: 18px; }
    .sheep-image-stage img { max-height: 70vh; border-radius: 16px; }
}

/* Butikk */
.menu-shop-toggle { margin: 0; }
.menu-shop-toggle button {
    width: 100%;
    text-align: left;
    border-radius: 12px;
    padding: 12px 14px;
    box-shadow: none;
}
.shop-hero {
    display: grid;
    grid-template-columns: 1fr 220px;
    gap: 28px;
    align-items: center;
    overflow: hidden;
}
.shop-hero img {
    width: 100%;
    max-width: 220px;
    justify-self: center;
    border-radius: 26px;
    filter: drop-shadow(0 18px 28px rgba(0,0,0,.4));
}
.shop-admin-card h2,
.shop-public-card h2 { font-size: 42px; }
.shop-admin-grid {
    display: grid;
    grid-template-columns: .8fr 1.2fr;
    gap: 22px;
    align-items: start;
}
.shop-mini-form {
    background: rgba(255,255,255,.055);
    border: 1px solid rgba(214,179,107,.25);
    border-radius: 24px;
    padding: 20px;
}
.shop-product-admin-list {
    display: grid;
    gap: 10px;
    margin-top: 14px;
}
.shop-product-admin-row {
    display: grid;
    grid-template-columns: 1fr 230px auto;
    gap: 10px;
    align-items: center;
    padding: 12px;
    border-radius: 18px;
    background: rgba(255,255,255,.055);
    border: 1px solid rgba(214,179,107,.22);
}
.shop-theme-list { display: grid; gap: 18px; }
.shop-theme {
    background: rgba(255,255,255,.055);
    border: 1px solid rgba(214,179,107,.28);
    border-radius: 26px;
    overflow: hidden;
}
.shop-theme summary {
    cursor: pointer;
    padding: 20px 24px;
    font-size: clamp(24px, 4vw, 38px);
    color: var(--gold-light);
    font-weight: 800;
    list-style: none;
    background: rgba(214,179,107,.10);
}
.shop-theme summary::-webkit-details-marker { display: none; }
.shop-theme summary::after {
    content: '⌄';
    float: right;
    color: var(--gold);
}
.shop-theme[open] summary::after { content: '⌃'; }
.shop-products {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 16px;
    padding: 18px;
}
.shop-product-card {
    background: rgba(255,255,255,.07);
    border: 1px solid rgba(214,179,107,.26);
    border-radius: 24px;
    overflow: hidden;
    box-shadow: 0 18px 45px rgba(0,0,0,.22);
}
.shop-product-card img {
    width: 100%;
    height: 190px;
    object-fit: cover;
    display: block;
    background: rgba(255,255,255,.05);
}
.shop-product-card > div { padding: 18px; }
.shop-product-card h3 {
    margin: 0 0 8px;
    color: var(--gold-light);
    font-size: 28px;
}
.shop-price {
    width: fit-content;
    color: #17301f;
    background: linear-gradient(180deg, var(--gold-light), var(--gold));
    border-radius: 999px;
    padding: 7px 13px;
    font-weight: 800;
    margin-bottom: 10px;
}
.shop-product-card p { font-size: 17px; }
@media (max-width: 760px) {
    .shop-hero, .shop-admin-grid, .shop-product-admin-row { grid-template-columns: 1fr; }
    .shop-hero img { max-width: 180px; }
    .shop-products { grid-template-columns: 1fr; padding: 12px; }
    .shop-theme summary { padding: 16px 18px; }
}

/* Butikk v1.31 */
.shop-page-card {
    padding: clamp(18px, 3vw, 32px);
}
.shop-top {
    display: grid;
    grid-template-columns: 110px 1fr auto;
    gap: 22px;
    align-items: center;
}
.shop-logo {
    width: 110px;
    height: 110px;
    object-fit: contain;
    border-radius: 24px;
    background: rgba(255,255,255,.08);
    border: 1px solid rgba(214,179,107,.35);
    padding: 8px;
    filter: drop-shadow(0 14px 22px rgba(0,0,0,.25));
}
.shop-top h1 {
    font-size: clamp(38px, 6vw, 70px);
    margin-bottom: 8px;
}
.shop-top p {
    font-size: clamp(17px, 2vw, 22px);
}
.shop-visibility-form { margin: 0; }
.shop-hidden-note { margin-top: 14px; }
.shop-owner-panel h2 {
    font-size: 34px;
}
.shop-owner-buttons {
    display: grid;
    grid-template-columns: repeat(2, minmax(180px, 1fr));
    gap: 14px;
    margin-bottom: 18px;
}
.shop-owner-buttons button {
    width: 100%;
    border-radius: 22px;
    padding: 16px 20px;
    font-size: 19px;
}
.shop-slide-panel {
    display: none;
    background: rgba(255,255,255,.055);
    border: 1px solid rgba(214,179,107,.28);
    border-radius: 24px;
    padding: 20px;
    margin-bottom: 18px;
}
.shop-slide-panel.open { display: block; }
.shop-admin-overview { margin-top: 24px; }
.shop-manage-list {
    display: grid;
    gap: 12px;
}
.shop-manage-item {
    background: rgba(255,255,255,.065);
    border: 1px solid rgba(214,179,107,.28);
    border-radius: 22px;
    overflow: hidden;
}
.shop-manage-item summary {
    list-style: none;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: center;
    padding: 16px 18px;
    color: var(--gold-light);
    font-size: 20px;
    font-weight: 700;
}
.shop-manage-item summary::-webkit-details-marker { display: none; }
.shop-manage-item summary small {
    color: rgba(248,243,231,.78);
    font-size: 15px;
    font-weight: 700;
}
.shop-edit-form {
    max-width: none;
    padding: 0 18px 18px;
}
.shop-delete-form {
    padding: 0 18px 18px;
    margin: 0;
}
.shop-current-image img {
    width: 130px;
    height: 95px;
    object-fit: cover;
    border-radius: 14px;
    border: 1px solid rgba(214,179,107,.35);
}
.shop-storefront {
    background:
        radial-gradient(circle at top left, rgba(214,179,107,.18), transparent 36%),
        rgba(255,255,255,.07);
}
.shop-theme-list { display: grid; gap: 18px; }
.shop-theme {
    background: rgba(4, 32, 19, .58);
    border: 1px solid rgba(214,179,107,.34);
    border-radius: 28px;
    overflow: hidden;
}
.shop-theme summary {
    list-style: none;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 20px 24px;
    color: var(--gold-light);
    font-size: clamp(24px, 4vw, 38px);
    font-weight: 800;
    background: linear-gradient(90deg, rgba(214,179,107,.18), rgba(255,255,255,.04));
}
.shop-theme summary::-webkit-details-marker { display: none; }
.shop-theme summary::after {
    content: '⌄';
    font-size: 26px;
    opacity: .9;
}
.shop-theme[open] summary::after { content: '⌃'; }
.shop-products {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 18px;
    padding: 20px;
}
.shop-product-card {
    display: grid;
    grid-template-rows: 190px 1fr;
    background: rgba(248,243,231,.96);
    color: #102016;
    border: 1px solid rgba(214,179,107,.4);
    border-radius: 26px;
    overflow: hidden;
    box-shadow: 0 20px 45px rgba(0,0,0,.22);
}
.shop-product-image-wrap {
    background: linear-gradient(135deg, #e7d7aa, #fff7df);
    overflow: hidden;
}
.shop-product-image-wrap img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.shop-product-placeholder {
    height: 100%;
    display: grid;
    place-items: center;
    color: #36523f;
    font-weight: 800;
    font-size: 22px;
    letter-spacing: .5px;
}
.shop-product-body {
    padding: 18px 18px 20px;
}
.shop-product-card h3 {
    color: #123520;
    font-size: 25px;
    margin: 0 0 8px;
}
.shop-price {
    display: inline-block;
    margin: 0 0 12px;
    padding: 7px 12px;
    border-radius: 999px;
    background: #d6b36b;
    color: #102016;
    font-weight: 900;
    font-size: 18px;
}
.shop-product-card p {
    color: #263b2e;
    font-size: 16px;
    line-height: 1.45;
}

@media (max-width: 1120px) {
    .shop-products { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
    .shop-products { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 760px) {
    .shop-top {
        grid-template-columns: 70px 1fr;
        gap: 12px;
    }
    .shop-logo {
        width: 70px;
        height: 70px;
        border-radius: 18px;
    }
    .shop-visibility-form {
        grid-column: 1 / -1;
    }
    .shop-visibility-form button { width: 100%; }
    .shop-owner-buttons {
        grid-template-columns: 1fr;
    }
    .shop-products {
        grid-template-columns: 1fr;
        padding: 14px;
    }
    .shop-product-card {
        grid-template-rows: 170px 1fr;
    }
}


/* Sauekontroll v1.25 - oversiktlister, medisinering og slektstre */
.sheep-overview-list .overview-list-button {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    background: rgba(255,255,255,.07);
    border: 1px solid rgba(214,179,107,.28);
    border-radius: 18px;
    padding: 15px 18px;
    color: var(--cream);
    text-decoration: none;
}
.sheep-overview-list .overview-list-button:hover {
    background: rgba(214,179,107,.16);
}
.overview-id-box {
    margin-top: 18px;
    padding: 16px;
    border-radius: 22px;
    background: rgba(0,0,0,.16);
    border: 1px solid rgba(214,179,107,.22);
}
.overview-id-box h3,
.tree-stage h3 {
    margin: 0 0 12px;
    color: var(--gold-light);
    font-size: 24px;
}
.overview-id-grid {
    display: grid;
    gap: 10px;
}
.overview-id-pill {
    display: grid;
    gap: 3px;
    padding: 13px 15px;
    border-radius: 18px;
    color: var(--cream);
    text-decoration: none;
    background: rgba(255,255,255,.06);
    border: 1px solid rgba(214,179,107,.18);
}
.overview-id-pill:hover {
    background: rgba(214,179,107,.15);
}
.overview-id-pill span {
    color: rgba(248,243,231,.76);
    font-size: 14px;
}
.overview-id-kopplam {
    border-color: rgba(241,217,148,.55);
}
.sheep-medisinering-box {
    width: min(760px, 100%);
}
.sheep-tree-box {
    width: min(980px, 100%);
}
.tree-stage {
    display: grid;
    grid-template-columns: 1fr minmax(190px, .8fr) 1fr;
    gap: 14px;
    align-items: start;
    margin-top: 18px;
}
.tree-column,
.tree-center {
    display: grid;
    gap: 10px;
}
.tree-center {
    position: sticky;
    top: 82px;
}
.tree-branch {
    display: grid;
    gap: 10px;
    padding-left: 12px;
    border-left: 2px solid rgba(214,179,107,.34);
}
.tree-child-wrap {
    display: grid;
    gap: 8px;
}
.tree-node {
    display: grid;
    gap: 4px;
    color: var(--cream);
    text-decoration: none;
    background: rgba(255,255,255,.07);
    border: 1px solid rgba(214,179,107,.24);
    border-radius: 20px;
    padding: 14px;
}
.tree-node:hover {
    background: rgba(214,179,107,.16);
}
.tree-node span {
    color: rgba(248,243,231,.70);
    font-size: 13px;
}
.tree-node strong {
    color: var(--gold-light);
    font-size: 19px;
}
.tree-node small {
    color: rgba(248,243,231,.74);
}
.tree-main-node {
    text-align: center;
    background: rgba(214,179,107,.18);
    border-color: rgba(214,179,107,.52);
}
.tree-child-node {
    border-color: rgba(143,199,146,.28);
}
.tree-muted {
    padding: 12px;
    border-radius: 16px;
    color: rgba(248,243,231,.72);
    background: rgba(0,0,0,.13);
    border: 1px dashed rgba(214,179,107,.24);
}
@media (max-width: 860px) {
    .tree-stage {
        grid-template-columns: 1fr;
    }
    .tree-center {
        position: static;
        order: -1;
    }
}


/* Sauekontroll v1.31 - enklere faner og nytt slektstre */
.tree-flow-stage {
    display: grid;
    gap: 14px;
    margin-top: 18px;
    overflow-x: auto;
}
.tree-flow-stage h3 {
    color: var(--gold-light);
    margin: 10px 0 0;
    font-size: 22px;
}
.tree-lineage-row {
    display: flex;
    align-items: center;
    gap: 9px;
    min-width: max-content;
    padding: 10px;
    border-radius: 20px;
    background: rgba(0,0,0,.13);
    border: 1px solid rgba(214,179,107,.14);
}
.tree-button-node {
    min-width: 118px;
    text-align: center;
    color: #17301f;
    background: linear-gradient(180deg, var(--gold-light), var(--gold));
    border: 1px solid rgba(214,179,107,.85);
    border-radius: 999px;
    padding: 11px 15px;
    font-weight: 800;
    text-decoration: none;
    box-shadow: 0 10px 24px rgba(0,0,0,.25);
    white-space: nowrap;
}
.tree-button-node:hover {
    filter: brightness(1.07);
    transform: translateY(-1px);
}
.tree-button-node.tree-main-node {
    background: linear-gradient(180deg, #fff1b8, var(--gold-light));
    box-shadow: 0 0 0 3px rgba(241,217,148,.18), 0 12px 28px rgba(0,0,0,.28);
}
.tree-arrow {
    color: var(--gold-light);
    font-size: 28px;
    font-weight: 900;
    text-shadow: 0 5px 18px rgba(0,0,0,.45);
}
.tree-descendant-list {
    display: grid;
    gap: 10px;
}
.sheep-tree-popup {
    position: fixed;
    z-index: 250;
    inset: 12px;
    width: min(760px, calc(100% - 24px));
    max-height: calc(100vh - 24px);
    margin: 0 auto;
    overflow: auto;
    background: linear-gradient(180deg, rgba(10,48,31,.99), rgba(6,31,20,.99));
    border: 1px solid rgba(214,179,107,.42);
    box-shadow: 0 34px 100px rgba(0,0,0,.68);
}
.sheep-tree-popup::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: -1;
    background: rgba(0,0,0,.56);
}
@media (max-width: 760px) {
    .tree-lineage-row { padding: 8px; gap: 7px; }
    .tree-button-node { min-width: 96px; padding: 10px 12px; }
    .tree-arrow { font-size: 24px; }
    .sheep-tree-popup { inset: 8px; width: calc(100% - 16px); max-height: calc(100vh - 16px); }
}


/* Sauekontroll v1.32 - grafisk slektstre */
.tree-graphic-stage {
    gap: 16px;
}
.family-tree-scroll {
    overflow: auto;
    padding: 18px 12px 24px;
    background:
        radial-gradient(circle at 15% 20%, rgba(241,217,148,.10), transparent 24%),
        rgba(0,0,0,.13);
    border: 1px solid rgba(214,179,107,.16);
    border-radius: 24px;
}
.family-tree {
    display: flex;
    align-items: center;
    gap: 48px;
    width: max-content;
    min-width: 100%;
}
.family-tree-node-wrap {
    position: relative;
    flex: 0 0 auto;
}
.family-tree-children {
    position: relative;
    display: grid;
    gap: 18px;
    padding-left: 38px;
}
.family-tree-children::before {
    content: "";
    position: absolute;
    left: 0;
    top: 24px;
    bottom: 24px;
    width: 3px;
    border-radius: 999px;
    background: linear-gradient(180deg, rgba(241,217,148,.25), rgba(241,217,148,.95), rgba(241,217,148,.25));
    box-shadow: 0 0 14px rgba(214,179,107,.22);
}
.family-tree-node-wrap::after {
    content: "";
    position: absolute;
    right: -48px;
    top: 50%;
    width: 48px;
    height: 3px;
    transform: translateY(-50%);
    border-radius: 999px;
    background: rgba(241,217,148,.78);
    box-shadow: 0 0 12px rgba(214,179,107,.20);
}
.family-tree:not(:has(.family-tree-children)) > .family-tree-node-wrap::after {
    display: none;
}
.family-tree-child {
    position: relative;
}
.family-tree-child::before {
    content: "";
    position: absolute;
    left: -38px;
    top: 50%;
    width: 38px;
    height: 3px;
    transform: translateY(-50%);
    border-radius: 999px;
    background: rgba(241,217,148,.78);
    box-shadow: 0 0 12px rgba(214,179,107,.20);
}
.family-tree-child:first-child::after,
.family-tree-child:last-child::after {
    content: "";
    position: absolute;
    left: -40px;
    width: 7px;
    background: rgba(7, 35, 24, .98);
}
.family-tree-child:first-child::after {
    top: 0;
    height: calc(50% - 2px);
}
.family-tree-child:last-child::after {
    bottom: 0;
    height: calc(50% - 2px);
}
.family-tree-child:only-child::after {
    top: 0;
    bottom: 0;
    height: auto;
}
.family-tree-root > .family-tree-node-wrap .tree-button-node {
    min-width: 132px;
}
.family-tree .tree-button-node {
    position: relative;
    z-index: 2;
    display: block;
    border: 2px solid rgba(255,241,184,.88);
    background: linear-gradient(180deg, #fff4c7, #d6b36b);
    box-shadow:
        inset 0 1px 0 rgba(255,255,255,.55),
        0 10px 24px rgba(0,0,0,.30),
        0 0 0 4px rgba(214,179,107,.10);
}
.family-tree .tree-button-node.tree-main-node {
    background: linear-gradient(180deg, #ffffff, #f1d994);
    box-shadow:
        inset 0 1px 0 rgba(255,255,255,.75),
        0 14px 32px rgba(0,0,0,.34),
        0 0 0 5px rgba(241,217,148,.18);
}
@media (max-width: 760px) {
    .family-tree-scroll {
        padding: 14px 8px 20px;
    }
    .family-tree {
        gap: 34px;
    }
    .family-tree-children {
        padding-left: 28px;
        gap: 14px;
    }
    .family-tree-node-wrap::after {
        right: -34px;
        width: 34px;
    }
    .family-tree-child::before {
        left: -28px;
        width: 28px;
    }
    .family-tree-child:first-child::after,
    .family-tree-child:last-child::after {
        left: -30px;
    }
}


/* Sauekontroll v1.33 - tydeligere grafisk slektstre */
.family-tree-scroll {
    overflow: auto;
    padding: 22px 18px 28px;
}
.family-tree,
.family-tree * {
    box-sizing: border-box;
}
.family-tree {
    align-items: center;
    gap: 54px;
}
.family-tree-node-wrap {
    min-width: 150px;
}
.family-tree-children {
    gap: 22px;
    padding-left: 46px;
}
.family-tree-children::before {
    width: 4px;
    left: 0;
    top: 28px;
    bottom: 28px;
    background: linear-gradient(180deg, rgba(241,217,148,.28), rgba(241,217,148,.96), rgba(241,217,148,.28));
}
.family-tree-node-wrap::after {
    right: -54px;
    width: 54px;
    height: 4px;
    background: rgba(241,217,148,.92);
}
.family-tree.no-children > .family-tree-node-wrap::after {
    display: none;
}
.family-tree-child::before {
    left: -46px;
    width: 46px;
    height: 4px;
    background: rgba(241,217,148,.92);
}
.family-tree-child:first-child::after,
.family-tree-child:last-child::after {
    left: -48px;
    width: 8px;
    background: rgba(5, 29, 18, 1);
}
.tree-button-node,
a.tree-button-node,
a.tree-button-node:visited,
a.tree-button-node:hover,
a.tree-button-node:active {
    display: inline-flex !important;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    min-width: 150px;
    min-height: 64px;
    padding: 10px 18px;
    border-radius: 999px;
    text-decoration: none !important;
    color: #17301f !important;
    background: linear-gradient(180deg, #fff6d6 0%, #ecd28d 48%, #d8b86d 100%) !important;
    border: 2px solid rgba(255,241,184,.95) !important;
    box-shadow: inset 0 1px 0 rgba(255,255,255,.7), 0 10px 24px rgba(0,0,0,.32), 0 0 0 4px rgba(214,179,107,.09) !important;
    font-weight: 800;
    line-height: 1.05;
    white-space: normal;
}
.tree-button-node:hover {
    transform: translateY(-1px);
    filter: brightness(1.03);
}
.tree-button-node.tree-main-node,
a.tree-button-node.tree-main-node {
    background: linear-gradient(180deg, #ffffff 0%, #fff0b3 50%, #f1d994 100%) !important;
    box-shadow: inset 0 1px 0 rgba(255,255,255,.85), 0 14px 30px rgba(0,0,0,.34), 0 0 0 5px rgba(241,217,148,.16) !important;
}
.tree-button-node .tree-id {
    display: block;
    font-size: 22px;
    font-weight: 800;
    color: #17301f !important;
}
.tree-button-node .tree-nickname {
    display: block;
    font-size: 13px;
    font-weight: 700;
    color: rgba(23,48,31,.82) !important;
}
@media (max-width: 760px) {
    .family-tree-scroll { padding: 14px 10px 20px; }
    .family-tree { gap: 34px; }
    .family-tree-node-wrap { min-width: 120px; }
    .family-tree-children { gap: 14px; padding-left: 30px; }
    .family-tree-node-wrap::after { right: -34px; width: 34px; }
    .family-tree-child::before { left: -30px; width: 30px; }
    .family-tree-child:first-child::after,
    .family-tree-child:last-child::after { left: -32px; }
    .tree-button-node,
    a.tree-button-node,
    a.tree-button-node:visited,
    a.tree-button-node:hover,
    a.tree-button-node:active {
        min-width: 120px;
        min-height: 56px;
        padding: 9px 12px;
    }
    .tree-button-node .tree-id { font-size: 18px; }
    .tree-button-node .tree-nickname { font-size: 12px; }
}


/* Sauekontroll v1.34 - slektstre som egen bred side nederst */
#slektstreView.sheep-tree-box {
    width: min(1180px, calc(100vw - 24px));
    max-width: none;
    margin-left: 50%;
    transform: translateX(-50%);
}

#slektstreView .form {
    max-width: 760px;
}

#slektstreView .tree-graphic-stage,
#slektstreView .tree-flow-stage,
#slektstreView .tree-stage {
    display: block !important;
    width: 100%;
    margin-top: 24px;
    overflow: visible !important;
}

#slektstreView .tree-graphic-stage h3 {
    margin-top: 26px;
    margin-bottom: 6px;
}

#slektstreView .tree-help-text {
    display: block;
    max-width: none;
    margin: 0 0 12px;
}

#slektstreView .tree-lineage-row {
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    margin-bottom: 14px;
}

#slektstreView .family-tree-scroll {
    width: 100%;
    max-width: 100%;
    min-height: 360px;
    overflow: auto;
    padding: 34px 30px;
    margin-top: 10px;
    border-radius: 28px;
    background:
        radial-gradient(circle at 12% 18%, rgba(241,217,148,.10), transparent 28%),
        linear-gradient(180deg, rgba(0,0,0,.16), rgba(0,0,0,.09));
    border: 1px solid rgba(214,179,107,.24);
}

#slektstreView .family-tree {
    min-width: max-content;
}

@media (max-width: 760px) {
    #slektstreView.sheep-tree-box {
        width: calc(100vw - 16px);
    }

    #slektstreView .family-tree-scroll {
        min-height: 300px;
        padding: 24px 18px;
    }
}


/* Sauekontroll v1.36 - mobil mer lik PC */
@media (max-width: 760px) {
    #slektstreView .family-tree-scroll {
        overflow: auto;
        overflow-y: hidden;
        min-height: 280px;
        padding: 22px 18px 26px;
        -webkit-overflow-scrolling: touch;
    }

    #slektstreView .family-tree,
    #slektstreView .family-tree-child .family-tree {
        display: flex;
        flex-direction: row;
        align-items: center;
        gap: 32px;
        width: max-content;
        min-width: max-content;
    }

    #slektstreView .family-tree-node-wrap {
        width: auto;
        min-width: 110px;
        display: block;
    }

    #slektstreView .family-tree-children {
        width: auto;
        padding-left: 28px;
        padding-top: 0;
        display: grid;
        gap: 12px;
        justify-items: start;
    }

    #slektstreView .family-tree-children::before {
        left: 0;
        top: 22px;
        bottom: 22px;
        width: 3px;
        height: auto;
        transform: none;
    }

    #slektstreView .family-tree-node-wrap::after {
        right: -32px;
        left: auto;
        top: 50%;
        bottom: auto;
        width: 32px;
        height: 3px;
        transform: translateY(-50%);
        display: block;
    }

    #slektstreView .family-tree.no-children > .family-tree-node-wrap::after {
        display: none;
    }

    #slektstreView .family-tree-child {
        width: auto;
        display: block;
        position: relative;
    }

    #slektstreView .family-tree-child::before {
        left: -28px;
        top: 50%;
        width: 28px;
        height: 3px;
        transform: translateY(-50%);
    }

    #slektstreView .family-tree-child:first-child::after,
    #slektstreView .family-tree-child:last-child::after {
        display: block;
        left: -30px;
        width: 7px;
        background: rgba(5, 29, 18, 1);
    }

    #slektstreView .family-tree-child:first-child::after {
        top: 0;
        height: calc(50% - 2px);
    }

    #slektstreView .family-tree-child:last-child::after {
        bottom: 0;
        height: calc(50% - 2px);
    }

    #slektstreView .family-tree-child:only-child::after {
        top: 0;
        bottom: 0;
        height: auto;
    }

    #slektstreView .tree-button-node,
    #slektstreView a.tree-button-node {
        width: auto;
        min-width: 110px;
        min-height: 50px;
        padding: 8px 12px;
        border-radius: 999px;
    }

    #slektstreView .tree-button-node .tree-id {
        font-size: 17px;
    }

    #slektstreView .tree-button-node .tree-nickname {
        font-size: 11px;
    }

    #slektstreView .tree-help-text {
        font-size: 15px;
        line-height: 1.35;
    }
}


/* Sauekontroll v1.37 - midtstilt slektstre på PC */
@media (min-width: 761px) {
    #slektstreView.sheep-tree-box {
        min-height: calc(100vh - 40px);
        display: flex;
        flex-direction: column;
        justify-content: center;
    }

    #slektstreView .form,
    #slektstreView > h2,
    #slektstreView > p.small {
        width: min(760px, 100%);
        margin-left: auto;
        margin-right: auto;
    }

    #slektstreView .form button {
        justify-self: start;
    }

    #slektstreView .tree-graphic-stage {
        width: min(1000px, 100%);
        margin-left: auto;
        margin-right: auto;
    }

    #slektstreView .family-tree-scroll {
        display: flex;
        justify-content: center;
    }

    #slektstreView .family-tree {
        margin-left: auto;
        margin-right: auto;
    }
}


/* Sauekontroll v1.38 - bedre startvisning for slektstre */
@media (min-width: 761px) {
    #slektstreView.sheep-tree-box {
        width: min(980px, calc(100vw - 80px));
        min-height: auto;
        margin-top: 42px;
        margin-bottom: 42px;
        padding: 54px 64px 64px;
        display: block;
        transform: translateX(-50%);
    }

    #slektstreView .sheep-close {
        top: 24px;
        right: 28px;
        left: auto;
    }

    #slektstreView > h2,
    #slektstreView > p.small,
    #slektstreView .form {
        width: min(720px, 100%);
        margin-left: auto;
        margin-right: auto;
    }

    #slektstreView > h2 {
        margin-top: 0;
    }

    #slektstreView .form {
        margin-top: 18px;
    }

    #slektstreView .form input {
        max-width: 100%;
    }

    #slektstreView .tree-graphic-stage {
        width: 100%;
        margin-top: 34px;
    }

    #slektstreView .family-tree-scroll {
        justify-content: flex-start;
        min-height: 260px;
    }
}


/* Sauekontroll v1.39 - linjer treffer ID-knappene bedre */
.family-tree {
    align-items: center !important;
}

.family-tree-child {
    display: flex !important;
    align-items: center !important;
}

.family-tree-child > .family-tree {
    align-items: center !important;
}

.family-tree-node-wrap {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
}

.family-tree-children {
    align-content: center !important;
}

.family-tree-node-wrap::after {
    top: 50% !important;
    transform: translateY(-50%) !important;
}

.family-tree-child::before {
    top: 50% !important;
    transform: translateY(-50%) !important;
}

.family-tree-children::before {
    top: 32px !important;
    bottom: 32px !important;
}

.family-tree-child:first-child::after {
    top: 0 !important;
    height: calc(50% - 2px) !important;
}

.family-tree-child:last-child::after {
    bottom: 0 !important;
    height: calc(50% - 2px) !important;
}

.family-tree-child:only-child::after {
    top: 0 !important;
    bottom: 0 !important;
    height: auto !important;
}

.tree-button-node,
a.tree-button-node {
    min-height: 64px !important;
}

/* PC: litt strammere grener */
@media (min-width: 761px) {
    .family-tree {
        gap: 42px !important;
    }

    .family-tree-node-wrap::after {
        right: -42px !important;
        width: 42px !important;
    }

    .family-tree-children {
        padding-left: 42px !important;
    }

    .family-tree-child::before {
        left: -42px !important;
        width: 42px !important;
    }

    .family-tree-child:first-child::after,
    .family-tree-child:last-child::after {
        left: -44px !important;
    }
}

/* Mobil behold PC-lik visning, men med riktige treffpunkt */
@media (max-width: 760px) {
    #slektstreView .family-tree-node-wrap::after {
        top: 50% !important;
        transform: translateY(-50%) !important;
    }

    #slektstreView .family-tree-child::before {
        top: 50% !important;
        transform: translateY(-50%) !important;
    }

    #slektstreView .family-tree-children::before {
        top: 24px !important;
        bottom: 24px !important;
    }
}


/* Sauekontroll v1.40 - ekte linjefix: kobler linje til selve ID-knappen */
.family-tree-child::before {
    display: none !important;
}

.family-tree-child::after {
    display: none !important;
}

.family-tree-children::before {
    top: 0 !important;
    bottom: 0 !important;
    left: 0 !important;
    width: 4px !important;
    z-index: 0 !important;
}

.family-tree-child > .family-tree > .family-tree-node-wrap {
    position: relative !important;
}

.family-tree-child > .family-tree > .family-tree-node-wrap::before {
    content: "" !important;
    position: absolute !important;
    left: -42px !important;
    top: 50% !important;
    width: 42px !important;
    height: 4px !important;
    transform: translateY(-50%) !important;
    border-radius: 999px !important;
    background: rgba(241,217,148,.96) !important;
    box-shadow: 0 0 12px rgba(214,179,107,.22) !important;
    z-index: 1 !important;
}

.family-tree-node-wrap::after {
    z-index: 1 !important;
}

.tree-button-node {
    z-index: 3 !important;
}

@media (min-width: 761px) {
    .family-tree {
        gap: 46px !important;
    }

    .family-tree-node-wrap::after {
        right: -46px !important;
        width: 46px !important;
    }

    .family-tree-children {
        padding-left: 46px !important;
    }

    .family-tree-child > .family-tree > .family-tree-node-wrap::before {
        left: -46px !important;
        width: 46px !important;
    }
}

@media (max-width: 760px) {
    #slektstreView .family-tree-child::before,
    #slektstreView .family-tree-child::after {
        display: none !important;
    }

    #slektstreView .family-tree-children::before {
        top: 0 !important;
        bottom: 0 !important;
        left: 0 !important;
        width: 3px !important;
        height: auto !important;
        transform: none !important;
    }

    #slektstreView .family-tree-child > .family-tree > .family-tree-node-wrap::before {
        left: -28px !important;
        width: 28px !important;
        height: 3px !important;
        top: 50% !important;
        transform: translateY(-50%) !important;
    }
}


/* Sauekontroll v2.00 - ny ordentlig slektstrevisning */
#slektstreView.sheep-tree-box {
    width: min(1120px, calc(100vw - 28px));
    max-width: none;
    margin: 28px auto 42px !important;
    transform: none !important;
    padding: clamp(22px, 4vw, 54px);
    min-height: auto !important;
    display: block !important;
}

#slektstreView .sheep-close {
    top: 18px !important;
    right: 20px !important;
    left: auto !important;
}

#slektstreView > h2,
#slektstreView > p.small,
#slektstreView .form {
    width: min(720px, 100%);
    margin-left: auto;
    margin-right: auto;
}

#slektstreView > h2 {
    margin-top: 0;
}

#slektstreView .form {
    margin-top: 16px;
}

.pedigree-section {
    width: 100%;
    margin-top: 30px;
}

.pedigree-section h3 {
    color: var(--gold-light);
    font-size: 28px;
    margin: 20px 0 8px;
}

.pedigree-scroll {
    width: 100%;
    max-width: 100%;
    overflow: auto;
    padding: 22px;
    margin-top: 12px;
    border-radius: 28px;
    border: 1px solid rgba(214,179,107,.26);
    background:
        radial-gradient(circle at 18% 22%, rgba(241,217,148,.10), transparent 28%),
        linear-gradient(180deg, rgba(0,0,0,.18), rgba(0,0,0,.08));
    -webkit-overflow-scrolling: touch;
}

.pedigree-board {
    position: relative;
    min-width: 100%;
}

.pedigree-lines {
    position: absolute;
    inset: 0;
    z-index: 1;
    overflow: visible;
    pointer-events: none;
}

.pedigree-path {
    fill: none;
    stroke: rgba(241,217,148,.92);
    stroke-width: 5;
    stroke-linecap: round;
    stroke-linejoin: round;
    filter: drop-shadow(0 0 5px rgba(214,179,107,.18));
}

.pedigree-node,
.pedigree-node:visited,
.pedigree-node:hover,
.pedigree-node:active {
    position: absolute;
    z-index: 2;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    text-decoration: none !important;
    color: #17301f !important;
    border-radius: 999px;
    border: 3px solid rgba(255,246,210,.96);
    background: linear-gradient(180deg, #fff6d6 0%, #edd38d 50%, #d8b76b 100%);
    box-shadow:
        inset 0 1px 0 rgba(255,255,255,.75),
        0 10px 0 rgba(22,43,26,.35),
        0 12px 26px rgba(0,0,0,.30);
    font-weight: 900;
    line-height: 1.05;
    transition: transform .12s ease, filter .12s ease;
}

.pedigree-node:hover {
    transform: translateY(-2px);
    filter: brightness(1.04);
}

.pedigree-root {
    background: linear-gradient(180deg, #ffffff 0%, #fff0b3 50%, #f1d994 100%);
    box-shadow:
        inset 0 1px 0 rgba(255,255,255,.86),
        0 10px 0 rgba(22,43,26,.38),
        0 14px 30px rgba(0,0,0,.34),
        0 0 0 7px rgba(241,217,148,.14);
}

.pedigree-id {
    display: block;
    font-size: 28px;
    letter-spacing: .5px;
}

.pedigree-name {
    display: block;
    max-width: 92%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 18px;
    color: rgba(23,48,31,.82);
}

@media (max-width: 760px) {
    #slektstreView.sheep-tree-box {
        width: calc(100vw - 16px);
        margin: 8px auto 22px !important;
        padding: 20px 14px 24px;
    }

    #slektstreView .sheep-close {
        top: 12px !important;
        right: 12px !important;
    }

    .pedigree-section h3 {
        font-size: 23px;
    }

    .pedigree-scroll {
        padding: 14px;
        border-radius: 22px;
    }

    .pedigree-path {
        stroke-width: 4;
    }

    .pedigree-id {
        font-size: 20px;
    }

    .pedigree-name {
        font-size: 13px;
    }
}


/* Sauekontroll v2.01 - sentrert slektstreside + tydelig barn fremover */
body:has(#slektstreView) main {
    width: min(1240px, calc(100vw - 24px)) !important;
    max-width: none !important;
    margin: 0 auto 36px !important;
    padding: 0 12px !important;
}

#slektstreView.sheep-tree-box {
    width: 100% !important;
    max-width: none !important;
    margin: 18px auto 34px !important;
    transform: none !important;
    left: auto !important;
    right: auto !important;
    padding: clamp(18px, 3vw, 34px) !important;
    min-height: auto !important;
}

#slektstreView > h2,
#slektstreView > p.small,
#slektstreView .form {
    width: min(760px, 100%);
    margin-left: auto !important;
    margin-right: auto !important;
}

#slektstreView .pedigree-section {
    width: 100%;
    max-width: 100%;
    margin-top: 26px;
}

#slektstreView .pedigree-section h3 {
    width: 100%;
    max-width: 100%;
    margin: 22px 0 8px;
}

#slektstreView .tree-help-text,
#slektstreView .pedigree-empty {
    width: 100%;
    max-width: 100%;
}

#slektstreView .pedigree-scroll {
    width: 100%;
    max-width: 100%;
    min-height: 260px;
    margin-top: 12px;
}

#slektstreView .pedigree-board {
    position: relative;
    margin: 0;
}

#slektstreView .tree-lineage-row {
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
}

@media (max-width: 760px) {
    body:has(#slektstreView) main {
        width: 100% !important;
        padding: 0 8px !important;
    }

    #slektstreView.sheep-tree-box {
        width: calc(100vw - 16px) !important;
        margin: 8px auto 22px !important;
        padding: 18px 12px 22px !important;
    }

    #slektstreView > h2,
    #slektstreView > p.small,
    #slektstreView .form {
        width: 100%;
    }
}


/* Sauekontroll v2.02 - viser direkte barn tydelig før treet */
.tree-direct-children {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin: 12px 0 16px;
    padding: 12px;
    border-radius: 20px;
    background: rgba(0,0,0,.12);
    border: 1px solid rgba(214,179,107,.16);
}

.tree-direct-children .tree-button-node {
    min-width: 130px;
    min-height: 48px;
    padding: 8px 14px;
}


/* Sauekontroll v2.03 - ekte barn fremover i treet */
.tree-direct-children {
    display: none !important;
}

#slektstreView .pedigree-empty {
    margin: 12px 0 6px;
}

#slektstreView .pedigree-scroll {
    min-height: 320px;
}


/* Sauekontroll v2.04 - søsken til mødrene uten deres barn */
.ancestor-sibling-groups {
    display: grid;
    gap: 14px;
    margin: 16px 0 10px;
}

.ancestor-sibling-box {
    padding: 14px;
    border-radius: 20px;
    background: rgba(0,0,0,.12);
    border: 1px solid rgba(214,179,107,.18);
}

.ancestor-sibling-title {
    color: var(--gold-light);
    font-weight: 800;
    margin-bottom: 10px;
    font-size: 16px;
}

.ancestor-sibling-list {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}


/* Sauekontroll v2.05 - endelig slektstreoppsett */
body:has(#slektstreView) main {
    width: min(1280px, calc(100vw - 28px)) !important;
    max-width: none !important;
    margin: 0 auto 36px !important;
    padding: 0 12px !important;
    overflow-x: visible !important;
}

#slektstreView.sheep-tree-box {
    width: 100% !important;
    max-width: none !important;
    margin: 18px auto 36px !important;
    transform: none !important;
    left: auto !important;
    right: auto !important;
    min-height: auto !important;
    padding: clamp(18px, 3vw, 34px) !important;
}

#slektstreView > h2,
#slektstreView > p.small,
#slektstreView .form {
    width: min(760px, 100%);
    margin-left: auto !important;
    margin-right: auto !important;
}

#slektstreView .pedigree-section {
    width: 100%;
    margin-top: 26px;
}

#slektstreView .pedigree-scroll {
    width: 100%;
    max-width: 100%;
    min-height: 260px;
    overflow: auto;
    padding: 18px;
    margin-top: 12px;
    border-radius: 26px;
    border: 1px solid rgba(214,179,107,.24);
    background:
        radial-gradient(circle at 18% 22%, rgba(241,217,148,.08), transparent 28%),
        linear-gradient(180deg, rgba(0,0,0,.16), rgba(0,0,0,.08));
    -webkit-overflow-scrolling: touch;
}

#slektstreView .pedigree-board {
    position: relative;
    min-width: 100%;
}

#slektstreView .pedigree-lines {
    position: absolute;
    inset: 0;
    z-index: 1;
    overflow: visible;
    pointer-events: none;
}

#slektstreView .pedigree-path {
    fill: none;
    stroke: rgba(241,217,148,.92);
    stroke-width: 5;
    stroke-linecap: round;
    stroke-linejoin: round;
}

#slektstreView .pedigree-node,
#slektstreView .pedigree-node:visited,
#slektstreView .pedigree-node:hover,
#slektstreView .pedigree-node:active {
    position: absolute;
    z-index: 2;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    text-decoration: none !important;
    color: #17301f !important;
    border-radius: 999px;
    border: 3px solid rgba(255,246,210,.96);
    background: linear-gradient(180deg, #fff6d6 0%, #edd38d 50%, #d8b76b 100%);
    box-shadow:
        inset 0 1px 0 rgba(255,255,255,.75),
        0 8px 0 rgba(22,43,26,.34),
        0 12px 22px rgba(0,0,0,.24);
    font-weight: 900;
    line-height: 1.05;
}

#slektstreView .pedigree-root {
    background: linear-gradient(180deg, #ffffff 0%, #fff0b3 50%, #f1d994 100%);
}

#slektstreView .pedigree-id {
    display: block;
    font-size: 28px;
    letter-spacing: .4px;
}

#slektstreView .pedigree-name {
    display: block;
    max-width: 92%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 18px;
    color: rgba(23,48,31,.82);
}

@media (max-width: 760px) {
    body:has(#slektstreView) main {
        width: 100% !important;
        padding: 0 8px !important;
    }

    #slektstreView.sheep-tree-box {
        width: calc(100vw - 16px) !important;
        margin: 8px auto 22px !important;
        padding: 18px 12px 22px !important;
    }

    #slektstreView .pedigree-scroll {
        padding: 12px;
    }

    #slektstreView .pedigree-path {
        stroke-width: 4;
    }

    #slektstreView .pedigree-id {
        font-size: 20px;
    }

    #slektstreView .pedigree-name {
        font-size: 13px;
    }
}


/* Sauekontroll v2.06 - ryddigere knapperekkefølge */
.sheep-panel-grid a.sheep-less-used,
.sheep-panel a.sheep-less-used,
.sheep-actions a.sheep-less-used,
.sheep-main-actions a.sheep-less-used {
    margin-top: 14px;
}

/* Hvis knappene ligger i grid, gir dette litt luft før de mindre brukte knappene */
.sheep-less-used {
    margin-top: 14px !important;
}
