/* ========================================
   Tavuk Yaşam Döngüsü Yönetim Sistemi
   Custom Styles
   ======================================== */

/* --- Base --- */
html {
    font-size: 14px;
    position: relative;
    min-height: 100%;
}

@media (min-width: 768px) {
    html {
        font-size: 15px;
    }
}

body {
    margin: 0;
    padding-top: 56px; /* navbar height */
    min-height: 100vh;
    background-color: #f8f9fa;
}

/* --- Top Navbar --- */
.navbar {
    z-index: 1040;
    height: 56px;
}

/* --- Sidebar --- */
#sidebar {
    min-width: 240px;
    max-width: 240px;
    min-height: calc(100vh - 56px);
    height: calc(100vh - 56px);
    transition: all 0.3s ease;
    position: fixed;
    top: 56px;
    left: 0;
    overflow-y: auto;
    overflow-x: hidden;
    z-index: 1030;
}

#sidebar .sidebar-content {
    min-height: 100%;
    padding-bottom: 1rem;
}

#sidebar::-webkit-scrollbar {
    width: 8px;
}

#sidebar::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.04);
}

#sidebar::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.22);
    border-radius: 999px;
}

#sidebar::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.34);
}

#sidebar.collapsed {
    min-width: 60px;
    max-width: 60px;
}

#sidebar.collapsed .link-text {
    display: none;
}

#sidebar.collapsed .sidebar-link {
    text-align: center;
    padding-left: 0;
    padding-right: 0;
}

#sidebar.collapsed .sidebar-link i {
    margin-right: 0 !important;
    font-size: 1.2rem;
}

/* Sidebar links */
.sidebar-link {
    color: rgba(255, 255, 255, 0.75);
    padding: 0.6rem 1rem;
    border-radius: 0;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.sidebar-link:hover {
    color: #fff;
    background-color: rgba(255, 255, 255, 0.1);
}

.sidebar-link.active {
    color: #fff;
    background-color: rgba(13, 110, 253, 0.3);
    border-left: 3px solid #0d6efd;
}

/* Sidebar tree toggle */
.sidebar-toggle {
    display: flex;
    align-items: center;
    cursor: pointer;
}

.sidebar-toggle[aria-expanded="true"] .toggle-icon {
    transform: rotate(180deg);
}

.toggle-icon {
    font-size: 0.7rem;
    transition: transform 0.2s ease;
}

/* Sidebar submenu */
.sidebar-submenu {
    background-color: rgba(0, 0, 0, 0.15);
}

.sidebar-sub-link {
    padding: 0.4rem 1rem !important;
    font-size: 0.85rem;
}

.sidebar-sub-link .bi-circle {
    font-size: 0.4rem;
    vertical-align: middle;
}

.sidebar-sub-link.active {
    border-left: 2px solid #0d6efd !important;
}

/* --- Page Content --- */
#page-content-wrapper {
    margin-left: 240px;
    transition: margin-left 0.3s ease;
    min-height: calc(100vh - 56px);
    display: flex;
    flex-direction: column;
}

#sidebar.collapsed ~ #page-content-wrapper {
    margin-left: 60px;
}

/* --- Footer --- */
footer {
    margin-top: auto;
}

/* --- Responsive --- */
@media (max-width: 768px) {
    #sidebar {
        margin-left: -240px;
    }

    #sidebar.show {
        margin-left: 0;
    }

    #page-content-wrapper {
        margin-left: 0;
    }

    #sidebar.collapsed ~ #page-content-wrapper {
        margin-left: 0;
    }
}

/* --- Data Tables & Cards --- */
.table-responsive {
    border-radius: 0.375rem;
}

.table thead th {
    background-color: #f1f3f5;
    font-weight: 600;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    border-bottom: 2px solid #dee2e6;
}

.table thead.table-dark th {
    background-color: #212529;
    color: #fff;
    border-color: #373b3e;
}

.table thead.table-light th {
    background-color: #f8f9fa;
    color: #212529;
}

.table tbody tr:hover {
    background-color: rgba(13, 110, 253, 0.04);
}

/* Card stats */
.card-stat {
    border-left: 4px solid;
    transition: transform 0.2s ease;
}

.card-stat:hover {
    transform: translateY(-2px);
}

.card-stat.border-primary { border-left-color: #0d6efd; }
.card-stat.border-success { border-left-color: #198754; }
.card-stat.border-warning { border-left-color: #ffc107; }
.card-stat.border-danger  { border-left-color: #dc3545; }
.card-stat.border-info    { border-left-color: #0dcaf0; }

/* --- Status Badges --- */
.badge-dolu        { background-color: #198754; }
.badge-dinlenme    { background-color: #dc3545; }
.badge-planlanan   { background-color: #ffc107; color: #000; }
.badge-hazir       { background-color: #0dcaf0; color: #000; }
.badge-bakim       { background-color: #6c757d; }

/* --- Form Focus States --- */
.btn:focus,
.btn:active:focus,
.btn-link.nav-link:focus,
.form-control:focus,
.form-check-input:focus,
.form-select:focus {
    box-shadow: 0 0 0 0.1rem white, 0 0 0 0.25rem #258cfb;
}

/* --- Utility --- */
.cursor-pointer {
    cursor: pointer;
}

.text-truncate-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Loading spinner overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.7);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ================================================================
   Operasyon Tasarım Sistemi
   Saha koşulları, yüksek okunabilirlik ve tutarlı geri bildirim için.
   ================================================================ */
:root {
    --app-green-950: #102d27;
    --app-green-900: #173f35;
    --app-green-800: #1f5748;
    --app-green-700: #2b705d;
    --app-green-100: #dcece6;
    --app-green-50: #f1f8f5;
    --app-egg: #fffdf7;
    --app-canvas: #f4f5f1;
    --app-amber: #b87316;
    --app-amber-soft: #fff2d6;
    --app-danger: #b4232f;
    --app-danger-soft: #fce8e9;
    --app-info: #286782;
    --app-ink: #18231f;
    --app-muted: #60706a;
    --app-border: #dce3df;
    --app-radius: 0.85rem;
    --app-shadow: 0 0.25rem 1.25rem rgba(16, 45, 39, 0.08);
    --topbar-height: 64px;
    --sidebar-width: 264px;
}

html {
    scroll-behavior: smooth;
}

body.app-shell {
    padding-top: var(--topbar-height);
    color: var(--app-ink);
    background: var(--app-canvas);
    font-family: Inter, "Segoe UI", system-ui, -apple-system, sans-serif;
    line-height: 1.5;
}

.skip-link {
    position: fixed;
    top: 0.5rem;
    left: 0.5rem;
    z-index: 2000;
    padding: 0.65rem 1rem;
    color: #fff;
    background: var(--app-green-950);
    border-radius: 0.5rem;
    transform: translateY(-150%);
}

.skip-link:focus {
    transform: translateY(0);
}

.app-topbar {
    height: var(--topbar-height);
    z-index: 1040;
    color: #fff;
    background: linear-gradient(100deg, var(--app-green-950), var(--app-green-900) 72%, #285e4f);
    box-shadow: 0 0.25rem 1rem rgba(16, 45, 39, 0.22);
}

.app-brand {
    display: inline-flex;
    align-items: center;
    gap: 0.7rem;
    color: #fff;
    text-decoration: none;
}

.brand-mark,
.user-avatar {
    display: inline-grid;
    place-items: center;
    flex: 0 0 auto;
    width: 2.25rem;
    height: 2.25rem;
    border: 1px solid rgba(255, 255, 255, 0.24);
    border-radius: 0.7rem;
    background: rgba(255, 255, 255, 0.12);
}

.brand-copy {
    display: flex;
    flex-direction: column;
    line-height: 1.15;
}

.brand-copy strong {
    font-size: 0.98rem;
    letter-spacing: 0.01em;
}

.brand-copy small {
    margin-top: 0.18rem;
    color: rgba(255, 255, 255, 0.7);
    font-size: 0.69rem;
}

.topbar-action,
.user-menu-button {
    display: inline-flex;
    align-items: center;
    min-height: 2.35rem;
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.24);
    background: rgba(255, 255, 255, 0.09);
}

.topbar-action:hover,
.user-menu-button:hover,
.user-menu-button:focus {
    color: #fff;
    background: rgba(255, 255, 255, 0.16);
}

#sidebar {
    top: var(--topbar-height);
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
    max-width: var(--sidebar-width);
    height: calc(100vh - var(--topbar-height));
    min-height: calc(100vh - var(--topbar-height));
    background: var(--app-green-950);
    box-shadow: inset -1px 0 rgba(255, 255, 255, 0.05);
}

#sidebar.collapsed {
    width: 68px;
    min-width: 68px;
    max-width: 68px;
}

@media (min-width: 992px) {
    /* Dar görünümde yalnızca birincil menü ikonlarını göster. Açık kalan
       alt menülerdeki nokta ikonları navigasyonu görsel olarak bozuyordu. */
    #sidebar.collapsed .sidebar-submenu {
        display: none !important;
    }

    #sidebar.collapsed .sidebar-content > .nav > .nav-item > .sidebar-link {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 48px;
        min-height: 48px;
        margin: 0.25rem auto;
        padding: 0;
        color: rgba(255, 255, 255, 0.86);
        border-radius: 0.7rem;
    }

    #sidebar.collapsed .sidebar-content > .nav > .nav-item > .sidebar-link > i:first-child {
        flex: 0 0 auto;
        margin: 0 !important;
        font-size: 1.25rem;
        line-height: 1;
    }

    #sidebar.collapsed .sidebar-content > .nav > .nav-item > .sidebar-link.active {
        color: #fff;
        box-shadow: inset 0 0 0 1px rgba(127, 206, 176, 0.42);
    }

    #sidebar.collapsed .sidebar-content > .nav > .nav-item > .sidebar-link:focus-visible {
        outline: 3px solid rgba(127, 206, 176, 0.55);
        outline-offset: 1px;
    }
}

.nav-section-label {
    padding: 0.8rem 1rem 0.45rem;
    color: rgba(255, 255, 255, 0.45);
    font-size: 0.67rem;
    font-weight: 700;
    letter-spacing: 0.09em;
    text-transform: uppercase;
}

.sidebar-link {
    min-height: 2.7rem;
    margin: 0.12rem 0.55rem;
    padding: 0.68rem 0.75rem;
    color: rgba(255, 255, 255, 0.76);
    border-radius: 0.6rem;
}

.sidebar-link:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.08);
}

.sidebar-link.active {
    color: #fff;
    border-left: 0;
    background: rgba(115, 190, 156, 0.19);
    box-shadow: inset 3px 0 #7fceb0;
}

.sidebar-submenu {
    margin: 0 0.55rem;
    background: rgba(0, 0, 0, 0.12);
    border-radius: 0.65rem;
}

.sidebar-sub-link {
    min-height: 2.25rem;
    margin-left: 0.2rem;
    margin-right: 0.2rem;
}

#page-content-wrapper {
    margin-left: var(--sidebar-width);
    min-height: calc(100vh - var(--topbar-height));
}

#sidebar.collapsed ~ #page-content-wrapper {
    margin-left: 68px;
}

.app-content {
    width: 100%;
    max-width: 1680px;
    padding: 1.5rem clamp(1rem, 2.2vw, 2.25rem) 2.5rem;
}

.app-footer {
    border-top: 1px solid var(--app-border);
    background: rgba(255, 255, 255, 0.65);
}

.page-heading {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.25rem;
}

.page-eyebrow {
    margin-bottom: 0.25rem;
    color: var(--app-green-700);
    font-size: 0.72rem;
    font-weight: 750;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.page-title {
    margin: 0;
    color: var(--app-green-950);
    font-size: clamp(1.45rem, 2vw, 2rem);
    font-weight: 750;
    letter-spacing: -0.025em;
}

.page-subtitle {
    max-width: 66rem;
    margin: 0.35rem 0 0;
    color: var(--app-muted);
}

/* Kayıt ve ölçüm ekranlarında aynı sol başlangıç çizgisi ve içerik ritmi. */
.record-page-form {
    width: 100%;
    max-width: 72rem;
}

.record-page-grid {
    --bs-gutter-x: 1rem;
    --bs-gutter-y: 1rem;
}

.record-page-aside {
    display: grid;
    align-content: start;
    gap: 1rem;
}

.record-page-aside > .card {
    margin-bottom: 0 !important;
}

.validation-summary-valid {
    display: none;
}

.card,
.surface-card {
    border: 1px solid var(--app-border);
    border-radius: var(--app-radius);
    background: #fff;
    box-shadow: var(--app-shadow);
}

.card-header {
    min-height: 3.25rem;
    padding: 0.85rem 1.1rem;
    border-bottom: 1px solid var(--app-border);
    border-radius: var(--app-radius) var(--app-radius) 0 0 !important;
    background: #fff;
}

.section-title {
    margin: 0;
    color: var(--app-green-950);
    font-size: 1rem;
    font-weight: 720;
}

.section-kicker {
    color: var(--app-muted);
    font-size: 0.78rem;
}

.metric-card {
    position: relative;
    min-height: 8.8rem;
    padding: 1rem;
    overflow: hidden;
    color: inherit;
    text-decoration: none;
    transition: transform 160ms ease, box-shadow 160ms ease, border-color 160ms ease;
}

.metric-card:hover {
    color: inherit;
    border-color: #b7cec5;
    box-shadow: 0 0.6rem 1.6rem rgba(16, 45, 39, 0.12);
    transform: translateY(-2px);
}

.metric-icon {
    display: inline-grid;
    place-items: center;
    width: 2.35rem;
    height: 2.35rem;
    color: var(--app-green-800);
    border-radius: 0.7rem;
    background: var(--app-green-50);
    font-size: 1.15rem;
}

.metric-label {
    margin-top: 0.8rem;
    color: var(--app-muted);
    font-size: 0.76rem;
    font-weight: 650;
    letter-spacing: 0.035em;
    text-transform: uppercase;
}

.metric-value {
    margin-top: 0.15rem;
    color: var(--app-green-950);
    font-size: clamp(1.4rem, 2.2vw, 2rem);
    font-weight: 780;
    line-height: 1.1;
}

.metric-context {
    margin-top: 0.35rem;
    color: var(--app-muted);
    font-size: 0.77rem;
}

.metric-card.metric-warning .metric-icon {
    color: var(--app-amber);
    background: var(--app-amber-soft);
}

.metric-card.metric-danger .metric-icon {
    color: var(--app-danger);
    background: var(--app-danger-soft);
}

.metric-card.metric-info .metric-icon {
    color: var(--app-info);
    background: #e4f1f6;
}

.operational-strip {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
    padding: 0.75rem;
    border: 1px solid #cfe0d8;
    border-radius: var(--app-radius);
    background: linear-gradient(110deg, var(--app-green-50), #fffdf7);
}

.quick-action {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    min-height: 2.7rem;
    padding: 0.55rem 0.8rem;
    color: var(--app-green-900);
    border: 1px solid #cfe0d8;
    border-radius: 0.65rem;
    background: #fff;
    font-weight: 650;
    text-decoration: none;
}

.quick-action:hover {
    color: #fff;
    border-color: var(--app-green-800);
    background: var(--app-green-800);
}

.filter-panel {
    padding: 1rem;
    border: 1px solid var(--app-border);
    border-radius: var(--app-radius);
    background: rgba(255, 255, 255, 0.78);
}

.form-label {
    color: #33443e;
    font-size: 0.82rem;
    font-weight: 650;
}

.form-control,
.form-select {
    min-height: 2.7rem;
    border-color: #cfd9d4;
    border-radius: 0.6rem;
}

.form-control:focus,
.form-select:focus {
    border-color: var(--app-green-700);
    box-shadow: 0 0 0 0.2rem rgba(43, 112, 93, 0.16);
}

.btn {
    min-height: 2.5rem;
    border-radius: 0.6rem;
    font-weight: 650;
}

.btn-primary {
    border-color: var(--app-green-800);
    background: var(--app-green-800);
}

.btn-primary:hover,
.btn-primary:focus {
    border-color: var(--app-green-950);
    background: var(--app-green-950);
}

.btn-outline-primary {
    color: var(--app-green-800);
    border-color: var(--app-green-700);
}

.btn-outline-primary:hover {
    border-color: var(--app-green-800);
    background: var(--app-green-800);
}

.status-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.3rem 0.55rem;
    border-radius: 999px;
    font-size: 0.73rem;
    font-weight: 700;
}

.status-pill::before {
    width: 0.45rem;
    height: 0.45rem;
    border-radius: 50%;
    background: currentColor;
    content: "";
}

.status-good { color: #176545; background: #e5f4ed; }
.status-watch { color: #8a5810; background: var(--app-amber-soft); }
.status-critical { color: #a21d2a; background: var(--app-danger-soft); }
.status-neutral { color: #55645f; background: #eef1ef; }

.action-list {
    display: grid;
    gap: 0.65rem;
}

.action-item {
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: start;
    gap: 0.75rem;
    padding: 0.85rem;
    color: inherit;
    border: 1px solid var(--app-border);
    border-radius: 0.7rem;
    background: #fff;
    text-decoration: none;
}

.action-item:hover {
    color: inherit;
    border-color: #aac8bb;
    background: var(--app-green-50);
}

.action-item-icon {
    display: inline-grid;
    place-items: center;
    width: 2rem;
    height: 2rem;
    color: var(--app-green-800);
    border-radius: 0.55rem;
    background: var(--app-green-100);
}

.data-freshness {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    color: var(--app-muted);
    font-size: 0.76rem;
}

.data-freshness::before {
    width: 0.5rem;
    height: 0.5rem;
    border-radius: 50%;
    background: #31946c;
    box-shadow: 0 0 0 0.2rem rgba(49, 148, 108, 0.13);
    content: "";
}

.empty-state {
    padding: 2.5rem 1rem;
    text-align: center;
}

.empty-state-icon {
    display: inline-grid;
    place-items: center;
    width: 3.25rem;
    height: 3.25rem;
    margin-bottom: 0.75rem;
    color: var(--app-green-700);
    border-radius: 1rem;
    background: var(--app-green-50);
    font-size: 1.5rem;
}

.chart-shell {
    position: relative;
    min-height: 23rem;
}

/* Planlama matrisi */
.matrix-legend {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 0.45rem;
}

.matrix-scroll-region {
    border-radius: 0.7rem;
    outline: none;
}

.matrix-scroll-region:focus-visible {
    box-shadow: 0 0 0 0.25rem rgba(43, 112, 93, 0.2);
}

.planning-matrix-table {
    table-layout: fixed;
    min-width: 1180px;
}

.planning-matrix-table thead th:not(.matrix-house-column) {
    width: 68px;
    min-width: 68px;
    padding: 0.55rem 0.2rem;
}

.planning-matrix-table thead small {
    display: block;
    color: var(--app-muted);
    font-size: 0.65rem;
    font-weight: 500;
}

.planning-matrix-table thead .matrix-header-occupancy {
    margin-top: 0.2rem;
    color: var(--app-green-700);
    font-size: 0.67rem;
    font-weight: 700;
    white-space: nowrap;
}

.planning-matrix-table .matrix-house-column {
    width: 170px;
    min-width: 170px;
}

.planning-matrix-table .sticky-col {
    position: sticky;
    left: 0;
    z-index: 2;
    color: var(--app-ink);
    border-right: 2px solid var(--app-border);
    background: #fff;
}

.planning-matrix-table thead .sticky-col {
    z-index: 4;
    background: #f4f7f5;
}

.matrix-house-column span,
.matrix-house-column small {
    display: block;
    color: var(--app-muted);
    font-size: 0.69rem;
    font-weight: 500;
}

.matrix-cell {
    height: 82px;
    cursor: pointer;
    outline: none;
    overflow: hidden;
}

.matrix-cell-content {
    display: grid;
    place-items: center;
    gap: 0.1rem;
    min-height: 80px;
    max-width: 100%;
    padding: 0.2rem;
    overflow: hidden;
}

/* Hücre içeriği hiçbir koşulda hücre genişliğini aşmaz. */
.matrix-cell-content > * {
    max-width: 100%;
    min-width: 0;
    overflow: hidden;
}

.matrix-cell-content i {
    font-size: 0.9rem;
}

.matrix-cell-content small {
    font-size: 0.59rem;
    font-weight: 700;
    line-height: 1;
}

.matrix-cell-content strong {
    font-size: 0.66rem;
}

.matrix-cell-content .matrix-cell-live-count {
    font-size: 0.72rem;
    font-variant-numeric: tabular-nums;
    line-height: 1;
}

.matrix-cell-content .matrix-cell-forecast-live-count {
    color: inherit;
    font-size: 0.58rem;
    font-style: italic;
    font-weight: 500;
    font-variant-numeric: tabular-nums;
    line-height: 1;
    white-space: nowrap;
}

.matrix-cell-content .matrix-cell-planned-count {
    padding: 0.02rem 0.3rem;
    color: #5f4300;
    background: #fff3c4;
    border: 1px dashed #d9a300;
    border-radius: 999px;
    white-space: nowrap;
}

/*
    Planlanan canlı sayısı ve birleştirme göstergesi aynı satırda durur.
    Böylece hücreye yeni bir satır eklenmez, dikey taşma oluşmaz.
*/
.matrix-cell-planned-group {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.14rem;
    max-width: 100%;
    overflow: hidden;
}

.matrix-cell-merge-badge {
    flex: 0 0 auto;
    padding: 0.02rem 0.24rem;
    color: #4c1d95;
    background: #ede9fe;
    border: 1px solid #a78bfa;
    border-radius: 999px;
    font-size: 0.5rem !important;
    font-weight: 800 !important;
    line-height: 1.25 !important;
    white-space: nowrap;
}

.matrix-cell-flock-code {
    max-width: 82px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.matrix-cell-age {
    display: inline-flex !important;
    align-items: center;
    gap: 0.16rem;
    color: inherit;
    font-size: 0.58rem !important;
    font-weight: 800 !important;
    white-space: nowrap;
}

.matrix-cell-age i {
    font-size: 0.56rem !important;
}

.matrix-cell-planned-balance {
    display: inline-flex !important;
    align-items: center;
    gap: 0.16rem;
    max-width: 96px;
    padding: 0.12rem 0.28rem;
    color: #1e3a8a;
    background: #dbeafe;
    border: 1px solid #60a5fa;
    border-radius: 999px;
    font-size: 0.54rem !important;
    font-weight: 800 !important;
    line-height: 1.1 !important;
    white-space: nowrap;
}

.matrix-cell-planned-balance i {
    color: #1d4ed8;
    font-size: 0.56rem !important;
}

/*
    Hücre detay popup'ı: Bootstrap modal-sm tabanı 300px; bu ekranda %30 geniş (390px) kullanılır.
    Bootstrap .modal-dialog genişliğini --bs-modal-width değişkeninden okuduğu için max-width
    yerine değişken geçersiz kılınır; böylece 576px altındaki tam genişlik davranışı korunur.
*/
.modal-dialog.matrix-cell-detail-dialog {
    --bs-modal-width: 390px;
}

.matrix-hover-popup {
    position: fixed;
    z-index: 1090;
    width: min(330px, calc(100vw - 16px));
    padding: 0.7rem;
    color: #18362f;
    background: #fff;
    border: 1px solid #8fa79e;
    border-radius: 0.65rem;
    box-shadow: 0 12px 30px rgba(16, 45, 39, 0.24);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: translateY(3px);
    transition: opacity 120ms ease, transform 120ms ease;
}

.matrix-hover-popup.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.matrix-hover-title {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    padding-bottom: 0.4rem;
    margin-bottom: 0.45rem;
    color: #123c33;
    font-size: 0.8rem;
    font-weight: 800;
    border-bottom: 1px solid #dce7e2;
}

.matrix-hover-merge {
    display: block;
    padding: 0.3rem 0.4rem;
    margin-bottom: 0.5rem;
    color: #4c1d95;
    background: #ede9fe;
    border: 1px solid #c4b5fd;
    border-radius: 0.4rem;
    font-size: 0.7rem;
    font-weight: 700;
    line-height: 1.3;
}

.matrix-hover-transfer {
    display: grid;
    gap: 0.18rem;
    font-size: 0.72rem;
    line-height: 1.35;
}

.matrix-hover-transfer + .matrix-hover-transfer {
    padding-top: 0.5rem;
    margin-top: 0.5rem;
    border-top: 1px dashed #b8c9c2;
}

.matrix-hover-status {
    width: fit-content;
    padding: 0.08rem 0.35rem;
    color: #5f4300;
    background: #fff3c4;
    border-radius: 999px;
    font-size: 0.64rem;
    font-weight: 800;
}

.matrix-hover-status.is-delayed {
    color: #fff;
    background: #b4232f;
}

.matrix-cell-activities {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.16rem;
    min-height: 14px;
}

.matrix-activity-badge,
.matrix-activity-more {
    display: inline-flex;
    align-items: center;
    gap: 0.08rem;
    border-radius: 999px;
    padding: 0.05rem 0.22rem;
    font-size: 0.5rem;
    font-weight: 800;
    line-height: 1.15;
}

.matrix-activity-badge i {
    font-size: 0.56rem;
}

.activity-realized {
    color: #fff;
    background: #123c33;
}

.activity-planned {
    color: #5f4300;
    border: 1px dashed #8a6500;
    background: #fff3c4;
}

.activity-delayed {
    color: #fff;
    border: 1px solid #8f1d28;
    background: #b4232f;
}

/* Aynı kümese birleştirilen çoklu gelen transferler tek rozette toplanır. */
.activity-merged {
    color: #4c1d95;
    border: 1px solid #a78bfa;
    background: #ede9fe;
}

.activity-merged-delayed {
    color: #fff;
    border: 1px solid #6d28d9;
    background: #7c3aed;
}

.matrix-activity-more {
    color: #243f37;
    background: rgba(255, 255, 255, 0.78);
}

.matrix-cell:focus-visible {
    position: relative;
    z-index: 3;
    box-shadow: inset 0 0 0 3px #102d27, 0 0 0 2px #fff;
}

.matrix-cell[data-house-id]:hover {
    position: relative;
    z-index: 3;
    box-shadow: inset 0 0 0 2px var(--app-green-950);
}

.matrix-cell-dolu {
    color: #fff;
    background-color: #27765c !important;
}

.matrix-cell-bakim {
    color: #fff;
    background-color: #64736d !important;
}

.matrix-cell-past {
    opacity: 0.62;
    filter: saturate(0.65);
}

.matrix-cell-historical-occupied {
    opacity: 0.5;
    filter: saturate(0.45);
}

.matrix-header-past {
    color: #718079;
    background: #edf0ee !important;
}

.matrix-header-future {
    background: var(--app-green-50) !important;
}

.matrix-cell-hazir {
    background: #fff !important;
    background-image: radial-gradient(#b9c9c2 0.7px, transparent 0.7px) !important;
    background-size: 6px 6px !important;
}

.matrix-cell-istisna {
    background-color: #fff3cd !important;
    background-image: repeating-linear-gradient(135deg, rgba(245, 158, 11, .16), rgba(245, 158, 11, .16) 5px, transparent 5px, transparent 10px) !important;
    box-shadow: inset 0 0 0 2px #f59e0b;
}

.matrix-cell-operasyonel {
    color: #fff !important;
    background-color: #6f42c1 !important;
    background-image: repeating-linear-gradient(135deg, rgba(255,255,255,.12), rgba(255,255,255,.12) 5px, transparent 5px, transparent 10px) !important;
}

.status-operational,
.bg-operational {
    color: #fff;
    background: #6f42c1;
    border-color: #5a32a3;
}

.status-exception {
    color: #7a4b00;
    background: #fff3cd;
    border-color: #f59e0b;
}

.status-merge {
    color: #4c1d95;
    background: #ede9fe;
    border-color: #a78bfa;
}

.matrix-cell-planli {
    background-color: #f4c764 !important;
    background-image: repeating-linear-gradient(135deg, rgba(255,255,255,.18), rgba(255,255,255,.18) 5px, transparent 5px, transparent 10px) !important;
}

.matrix-cell-bloklu {
    background-color: #b4232f !important;
    background-image: repeating-linear-gradient(45deg, rgba(255,255,255,.1), rgba(255,255,255,.1) 4px, transparent 4px, transparent 8px) !important;
}

#matrixContextMenu {
    z-index: 1060;
    box-shadow: var(--app-shadow);
}

.matrix-loading-overlay {
    position: absolute;
    inset: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.72);
    backdrop-filter: blur(2px);
}

/* Sürü yaşam döngüsü */
.lifecycle-track {
    display: grid;
    grid-template-columns: repeat(8, minmax(6.5rem, 1fr));
    min-width: 760px;
    margin: 0;
    padding: 0;
    list-style: none;
    overflow: hidden;
}

.lifecycle-scroll {
    overflow-x: auto;
}

.lifecycle-track li {
    position: relative;
    display: grid;
    justify-items: center;
    gap: 0.45rem;
    padding: 0 0.35rem;
    color: var(--app-muted);
    text-align: center;
    font-size: 0.72rem;
    font-weight: 650;
}

.lifecycle-track li::before {
    position: absolute;
    top: 1rem;
    right: 50%;
    width: 100%;
    height: 2px;
    background: var(--app-border);
    content: "";
}

.lifecycle-track li:first-child::before {
    display: none;
}

.lifecycle-dot {
    position: relative;
    z-index: 1;
    display: grid;
    place-items: center;
    width: 2rem;
    height: 2rem;
    border: 2px solid var(--app-border);
    border-radius: 50%;
    background: #fff;
}

.lifecycle-track .is-complete,
.lifecycle-track .is-current {
    color: var(--app-green-900);
}

.lifecycle-track .is-complete::before,
.lifecycle-track .is-current::before {
    background: #69aa8c;
}

.lifecycle-track .is-complete .lifecycle-dot {
    color: #fff;
    border-color: var(--app-green-700);
    background: var(--app-green-700);
}

.lifecycle-track .is-current .lifecycle-dot {
    color: var(--app-green-800);
    border-color: var(--app-green-700);
    box-shadow: 0 0 0 0.3rem var(--app-green-100);
}

.lifecycle-track + * {
    margin-top: 1rem;
}

.next-action-card {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    border: 1px solid #c9ddd4;
    border-radius: var(--app-radius);
    background: linear-gradient(100deg, var(--app-green-50), #fff);
}

.next-action-icon {
    display: grid;
    place-items: center;
    flex: 0 0 auto;
    width: 2.75rem;
    height: 2.75rem;
    color: var(--app-green-800);
    border-radius: 0.8rem;
    background: #fff;
    box-shadow: var(--app-shadow);
    font-size: 1.25rem;
}

/* Hızlı günlük saha girişi */
.entry-action-bar {
    position: sticky;
    bottom: 0;
    z-index: 5;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin: 0 -1rem -1rem;
    padding: 0.85rem 1rem;
    border-top: 1px solid var(--app-border);
    border-radius: 0 0 var(--app-radius) var(--app-radius);
    background: rgba(255, 255, 255, 0.94);
    box-shadow: 0 -0.5rem 1rem rgba(16, 45, 39, 0.06);
    backdrop-filter: blur(8px);
}

.class-input {
    min-height: 3.15rem;
    font-size: 1.05rem;
    font-variant-numeric: tabular-nums;
    text-align: right;
}

#totalEggsInput {
    font-size: 1.35rem;
    font-variant-numeric: tabular-nums;
    font-weight: 720;
    text-align: right;
}

.forecast-explain {
    display: flex;
    align-items: flex-start;
    gap: 0.8rem;
    padding: 0.9rem 1rem;
    color: #344b42;
    border: 1px solid #cfe0d8;
    border-radius: 0.75rem;
    background: var(--app-green-50);
}

.forecast-explain-icon {
    color: var(--app-green-700);
    font-size: 1.2rem;
}

.forecast-explain p {
    margin-top: 0.2rem;
    color: var(--app-muted);
    font-size: 0.82rem;
}

@media (max-width: 768px) {
    .entry-action-bar {
        align-items: stretch;
        flex-direction: column;
    }

    .entry-action-bar > *,
    .entry-action-bar .btn {
        width: 100%;
    }
}

@media (max-width: 900px) {
    .lifecycle-track {
        overflow-x: auto;
    }

    .next-action-card {
        align-items: flex-start;
        flex-wrap: wrap;
    }

    .next-action-card .btn {
        width: 100%;
    }
}

.table {
    --bs-table-hover-bg: var(--app-green-50);
    vertical-align: middle;
}

.table thead th {
    color: #4e5f58;
    border-bottom-color: #cad7d1;
    background: #f4f7f5;
    font-size: 0.72rem;
}

.sidebar-backdrop {
    display: none;
}

@media (max-width: 768px) {
    .brand-copy small,
    .brand-copy strong {
        display: none;
    }

    #sidebar {
        margin-left: calc(var(--sidebar-width) * -1);
    }

    #sidebar.show {
        margin-left: 0;
    }

    .sidebar-backdrop.show {
        position: fixed;
        inset: var(--topbar-height) 0 0;
        z-index: 1025;
        display: block;
        background: rgba(9, 24, 20, 0.52);
        backdrop-filter: blur(2px);
    }

    #page-content-wrapper,
    #sidebar.collapsed ~ #page-content-wrapper {
        margin-left: 0;
    }

    .app-content {
        padding: 1rem 0.8rem 2rem;
    }

    .page-heading {
        flex-direction: column;
    }

    .page-heading > :last-child {
        width: 100%;
    }

    .page-heading .btn {
        flex: 1;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        transition-duration: 0.01ms !important;
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
    }
}

/* Oturum ekranı */
.auth-shell {
    min-height: 100vh;
    padding: 0;
    color: var(--app-ink);
    background: var(--app-canvas);
}

.auth-main,
.auth-grid {
    min-height: 100vh;
}

.auth-grid {
    display: grid;
    grid-template-columns: minmax(22rem, 1.05fr) minmax(24rem, 0.95fr);
}

.auth-story {
    display: grid;
    place-items: center;
    padding: clamp(2rem, 6vw, 6rem);
    color: #fff;
    background:
        radial-gradient(circle at 12% 18%, rgba(143, 211, 178, 0.24), transparent 28%),
        radial-gradient(circle at 86% 82%, rgba(255, 215, 139, 0.13), transparent 30%),
        linear-gradient(145deg, var(--app-green-950), var(--app-green-800));
}

.auth-story-content {
    max-width: 38rem;
}

.auth-brand {
    display: inline-flex;
    align-items: center;
    gap: 0.55rem;
    margin-bottom: 3rem;
    font-weight: 750;
}

.auth-story h1 {
    max-width: 34rem;
    margin-bottom: 1.25rem;
    font-size: clamp(2.3rem, 5vw, 4.6rem);
    font-weight: 780;
    letter-spacing: -0.055em;
    line-height: 1.02;
}

.auth-story p {
    max-width: 34rem;
    color: rgba(255, 255, 255, 0.74);
    font-size: 1.05rem;
}

.auth-points {
    display: grid;
    gap: 0.65rem;
    margin-top: 2rem;
    color: rgba(255, 255, 255, 0.88);
}

.auth-points i {
    margin-right: 0.45rem;
    color: #9dd8bc;
}

.auth-form-panel {
    display: grid;
    place-items: center;
    padding: 2rem;
}

.auth-card {
    width: min(100%, 28rem);
}

@media (max-width: 860px) {
    .auth-grid {
        grid-template-columns: 1fr;
    }

    .auth-story {
        min-height: 16rem;
        padding: 2rem;
    }

    .auth-story h1 {
        font-size: 2.25rem;
    }

    .auth-brand {
        margin-bottom: 1.5rem;
    }

    .auth-points {
        display: none;
    }

    .auth-form-panel {
        padding: 2.5rem 1rem;
    }
}

/* ================================================================
   Responsive safety layer
   Mobile, tablet, zoomed desktop and wide-screen layouts share the
   same predictable overflow and touch behaviour.
   ================================================================ */
html,
body {
    max-width: 100%;
    overflow-x: hidden;
}

body.app-shell {
    min-height: 100dvh;
}

#wrapper,
#page-content-wrapper,
#main-content,
.app-content,
.row > *,
.card,
.card-body,
.card-header,
.modal-content,
.dropdown-menu {
    min-width: 0;
}

.app-content {
    margin-inline: auto;
}

img,
picture,
video,
canvas,
svg {
    max-width: 100%;
}

pre,
code,
.alert,
.card-body,
dd {
    overflow-wrap: anywhere;
}

.form-control,
.form-select,
.input-group,
.btn-group {
    max-width: 100%;
}

.page-heading > *,
.card-header > *,
.next-action-card > *,
.entry-action-bar > * {
    min-width: 0;
}

.page-heading > :last-child {
    flex: 0 0 auto;
}

.page-heading > :last-child,
.card-header.d-flex,
.card-body > .d-flex,
.modal-footer,
.operational-strip {
    flex-wrap: wrap;
}

.action-item {
    grid-template-columns: auto minmax(0, 1fr) auto;
}

.table-responsive,
.matrix-scroll-region,
.lifecycle-scroll {
    max-width: 100%;
    overflow-x: auto;
    overscroll-behavior-inline: contain;
    scrollbar-gutter: stable;
    -webkit-overflow-scrolling: touch;
}

.table-responsive:focus-visible {
    border-radius: 0.45rem;
    outline: 3px solid rgba(43, 112, 93, 0.24);
    outline-offset: 2px;
}

.table-responsive > .table {
    margin-bottom: 0;
}

.table-responsive > .table.table-layout-wide {
    min-width: 48rem;
}

.toast-container {
    width: min(100%, 26rem);
    max-width: calc(100vw - 1rem);
}

.chart-shell {
    width: 100%;
    min-height: clamp(16rem, 42vw, 23rem);
}

.app-footer .container-fluid > .d-flex {
    flex-wrap: wrap;
    gap: 0.35rem 1rem;
}

@media (max-width: 991.98px) {
    .btn {
        min-inline-size: 44px;
    }

    .btn,
    .form-control,
    .form-select {
        min-height: 44px;
    }

    #sidebar,
    #sidebar.collapsed {
        width: min(86vw, var(--sidebar-width));
        min-width: min(86vw, var(--sidebar-width));
        max-width: min(86vw, var(--sidebar-width));
        margin-left: 0;
        transform: translateX(-100%);
    }

    #sidebar.show {
        margin-left: 0;
        transform: translateX(0);
    }

    #sidebar.collapsed .link-text {
        display: initial;
    }

    #sidebar.collapsed .sidebar-link {
        justify-content: flex-start;
        padding: 0.68rem 0.75rem;
        text-align: left;
    }

    #sidebar.collapsed .sidebar-link i {
        margin-right: 0.5rem !important;
        font-size: inherit;
    }

    .sidebar-backdrop.show {
        position: fixed;
        inset: var(--topbar-height) 0 0;
        z-index: 1025;
        display: block;
        background: rgba(9, 24, 20, 0.52);
        backdrop-filter: blur(2px);
    }

    #page-content-wrapper,
    #sidebar.collapsed ~ #page-content-wrapper {
        margin-left: 0;
    }

    .app-content {
        padding: 1.15rem clamp(0.8rem, 2.5vw, 1.25rem) 2rem;
    }

    .page-heading {
        align-items: stretch;
        flex-direction: column;
    }

    .page-heading > :last-child {
        display: flex;
        flex: 1 1 auto;
        width: 100%;
        gap: 0.5rem;
    }
}

@media (max-width: 575.98px) {
    :root {
        --topbar-height: 60px;
    }

    body.app-shell {
        padding-top: var(--topbar-height);
    }

    .app-topbar {
        height: var(--topbar-height);
        padding-inline: 0.5rem !important;
    }

    #sidebarToggle {
        min-width: 44px;
        min-height: 44px;
        margin-right: 0.45rem !important;
        padding: 0.35rem 0.65rem;
    }

    .brand-mark,
    .user-avatar {
        width: 2.1rem;
        height: 2.1rem;
    }

    .user-menu-button {
        min-width: 44px;
        min-height: 44px;
        padding: 0.25rem 0.4rem;
    }

    .user-menu-button::after {
        margin-left: 0.3rem;
    }

    .app-content {
        padding: 0.85rem 0.65rem calc(1.5rem + env(safe-area-inset-bottom));
    }

    .page-heading {
        gap: 0.75rem;
        margin-bottom: 1rem;
    }

    .page-heading > :last-child,
    .page-heading > :last-child > .btn-group,
    .page-heading > :last-child > form,
    .card-header > .btn-group {
        align-items: stretch;
        flex-direction: column;
        width: 100%;
    }

    .page-heading .btn,
    .page-heading form .btn,
    .card-header > .btn,
    .card-header > .btn-group .btn {
        width: 100%;
    }

    .card-header,
    .card-body,
    .filter-panel {
        padding-inline: 0.85rem;
    }

    .modal {
        --bs-modal-margin: 0.5rem;
    }

    .modal-dialog {
        margin: 0.5rem;
    }

    .modal-footer {
        align-items: stretch;
        flex-direction: column-reverse;
    }

    .modal-footer > *,
    .modal-footer .btn {
        width: 100%;
        margin: 0;
    }

    .input-group {
        flex-wrap: wrap;
    }

    .input-group > .form-control,
    .input-group > .form-select {
        flex: 1 1 12rem;
    }

    .input-group > .btn,
    .input-group > .input-group-text {
        flex: 0 0 auto;
    }

    .action-item {
        grid-template-columns: auto minmax(0, 1fr);
    }

    .action-item > :last-child {
        grid-column: 1 / -1;
        width: 100%;
    }

    .operational-strip .quick-action {
        justify-content: center;
        flex: 1 1 100%;
    }

    .entry-action-bar {
        padding-bottom: calc(0.85rem + env(safe-area-inset-bottom));
    }

    .app-footer {
        text-align: center;
    }

    .app-footer .container-fluid {
        padding-inline: 0.75rem !important;
    }

    .app-footer .container-fluid > .d-flex {
        justify-content: center !important;
    }

    .toast-container {
        inset: var(--topbar-height) 0 auto 0 !important;
        width: auto;
        max-width: none;
        padding: 0.5rem !important;
    }

    .auth-story {
        min-height: auto;
        padding: 1.25rem;
    }

    .auth-brand {
        margin-bottom: 0.75rem;
    }

    .auth-story h1 {
        margin-bottom: 0.75rem;
        font-size: clamp(1.65rem, 9vw, 2.15rem);
        letter-spacing: -0.04em;
    }

    .auth-story p {
        margin-bottom: 0;
        font-size: 0.92rem;
    }

    .auth-form-panel {
        padding: 1.25rem 0.75rem calc(1.5rem + env(safe-area-inset-bottom));
    }
}

@media (max-height: 520px) and (orientation: landscape) {
    #sidebar {
        height: calc(100dvh - var(--topbar-height));
        min-height: 0;
    }

    .auth-story {
        display: none;
    }

    .auth-grid,
    .auth-main {
        min-height: 100dvh;
    }
}

/* Yumurta üretim matrisi */
.egg-production-matrix-table {
    min-width: 2250px;
}

.egg-production-matrix-table thead th:not(.matrix-house-column) {
    width: 130px;
    min-width: 130px;
}

.egg-production-matrix-table .matrix-cell-content {
    min-height: 136px;
    gap: .2rem;
    padding: .45rem .3rem;
}

.planning-matrix-table .egg-matrix-cell {
    min-width: 130px;
    cursor: default;
}

.egg-matrix-cell-actual { background: #eef8f0; }
.egg-matrix-cell-actual-incomplete { background: #fff8df; }
.egg-matrix-cell-forecast { background: #edf5ff; }
.egg-matrix-cell-unavailable { background: #fff0f0; color: #842029; }

.egg-production-matrix-table .matrix-cell-content .egg-matrix-total,
.egg-production-matrix-table .matrix-cell-content .egg-matrix-unavailable-label {
    display: block;
    font-size: 1rem;
    line-height: 1.15;
}

.egg-production-matrix-table .matrix-cell-content .egg-matrix-kind-label,
.egg-production-matrix-table .matrix-cell-content .egg-matrix-coverage,
.egg-production-matrix-table .matrix-cell-content .egg-matrix-actual-live,
.egg-production-matrix-table .matrix-cell-content .egg-matrix-yield,
.egg-production-matrix-table .matrix-cell-content .egg-matrix-formula,
.egg-matrix-header-total,
.egg-matrix-header-missing {
    display: block;
    font-size: .68rem;
    line-height: 1.2;
}

.egg-matrix-coverage.is-incomplete,
.egg-matrix-header-missing {
    color: #a15c00;
    font-weight: 600;
}

.egg-production-matrix-table .matrix-cell-content .egg-matrix-actual-live {
    color: #496057;
}

.egg-production-matrix-table .matrix-cell-content .egg-matrix-yield {
    color: #146c43;
    font-weight: 700;
}

.egg-production-matrix-table .matrix-cell-content .egg-matrix-yield.is-unavailable {
    color: #6c757d;
    font-weight: 600;
}

.egg-production-matrix-table .matrix-cell-content .egg-matrix-formula {
    color: #315b86;
    white-space: normal;
}

.egg-matrix-header-total {
    margin-top: .2rem;
    font-weight: 700;
}

.egg-matrix-header-current { box-shadow: inset 0 -3px 0 #0d6efd; }
.egg-legend-actual { background: #d1e7dd; color: #0f5132; }
.egg-legend-forecast { background: #cfe2ff; color: #084298; }
.egg-legend-incomplete { background: #fff3cd; color: #664d03; }
.egg-legend-unavailable { background: #f8d7da; color: #842029; }

/* Yumurta üretimi: Ana Plan / What-if Senaryoları geçişi */
.egg-mode-switch {
    display: inline-flex;
    gap: .25rem;
    padding: .25rem;
    margin-bottom: .75rem;
    border: 1px solid var(--app-border);
    border-radius: var(--app-radius);
    background: #fff;
}

.egg-mode-switch-link {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    padding: .3rem .8rem;
    border-radius: .35rem;
    color: #495057;
    font-size: .875rem;
    text-decoration: none;
}

.egg-mode-switch-link:hover,
.egg-mode-switch-link:focus-visible {
    background: #f1f3f5;
    color: #212529;
}

.egg-mode-switch-link.is-active {
    background: var(--app-green-800);
    color: #fff;
}
