:root {
    --bg: #0b1020;
    --bg-soft: #11182d;
    --panel: rgba(17, 24, 45, 0.92);
    --panel-strong: #151f38;
    --border: rgba(148, 163, 184, 0.18);
    --text: #e5e7eb;
    --muted: #94a3b8;
    --primary: #38bdf8;
    --primary-strong: #0ea5e9;
    --accent: #f59e0b;
    --success: #22c55e;
    --warning: #f59e0b;
    --danger: #ef4444;
    --shadow: 0 24px 70px rgba(0, 0, 0, 0.35);
    --radius: 22px;
}

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    color: var(--text);
    background:
        radial-gradient(circle at top left, rgba(56, 189, 248, 0.25), transparent 34rem),
        radial-gradient(circle at bottom right, rgba(245, 158, 11, 0.18), transparent 30rem),
        var(--bg);
}

body.modal-open {
    overflow: hidden;
}

a {
    color: inherit;
    text-decoration: none;
}

button,
input,
select {
    font: inherit;
}

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

.sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    padding: 28px 20px;
    background: rgba(8, 13, 28, 0.82);
    border-right: 1px solid var(--border);
    backdrop-filter: blur(18px);
}

.brand {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 16px;
    border: 1px solid var(--border);
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.04);
    box-shadow: var(--shadow);
}

.brand-icon {
    display: grid;
    place-items: center;
    width: 46px;
    height: 46px;
    border-radius: 16px;
    color: #06121f;
    font-size: 24px;
    font-weight: 900;
    background: linear-gradient(135deg, var(--primary), #67e8f9);
}

.brand strong,
.brand small {
    display: block;
}

.brand strong {
    font-size: 20px;
}

.brand small {
    margin-top: 3px;
    color: var(--muted);
}

.nav-menu {
    display: grid;
    gap: 10px;
    margin-top: 30px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 13px 14px;
    border: 0;
    border-radius: 16px;
    color: var(--muted);
    text-align: left;
    background: transparent;
    cursor: pointer;
    transition: 0.2s ease;
}

.nav-item:hover,
.nav-item.active {
    color: var(--text);
    background: rgba(56, 189, 248, 0.13);
}

.sidebar-note {
    position: absolute;
    left: 20px;
    right: 20px;
    bottom: 24px;
    padding: 16px;
    border: 1px solid rgba(245, 158, 11, 0.28);
    border-radius: 18px;
    color: var(--muted);
    background: rgba(245, 158, 11, 0.1);
}

.sidebar-note strong {
    display: block;
    margin-top: 5px;
    color: var(--accent);
    font-size: 22px;
}

.main-content {
    width: 100%;
    max-width: 1480px;
    margin: 0 auto;
    padding: 34px;
}

.hero-card,
.panel,
.stat-card {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--panel);
    box-shadow: var(--shadow);
    backdrop-filter: blur(18px);
}

.hero-card {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 24px;
    padding: 34px;
    overflow: hidden;
    position: relative;
}

.hero-card::after {
    content: "";
    position: absolute;
    inset: auto -8rem -10rem auto;
    width: 25rem;
    height: 25rem;
    border-radius: 999px;
    background: rgba(56, 189, 248, 0.14);
    pointer-events: none;
}

.eyebrow {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--primary);
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    font-size: 12px;
}

.hero-card h1,
.panel h1,
.panel h2,
.modal h2 {
    margin: 10px 0;
    line-height: 1.08;
}

.hero-card h1 {
    max-width: 850px;
    font-size: clamp(32px, 5vw, 58px);
}

.hero-card p,
.panel p,
.modal p {
    margin: 0;
    color: var(--muted);
    line-height: 1.65;
}

.hero-actions,
.panel-actions,
.form-actions,
.filter-actions,
.action-cell,
.modal-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 16px;
    margin: 20px 0;
}

.stat-card {
    padding: 20px;
    transition: transform 0.2s ease, border-color 0.2s ease;
}

.stat-card:hover {
    transform: translateY(-4px);
    border-color: rgba(56, 189, 248, 0.42);
}

.stat-card span,
.stat-card small {
    color: var(--muted);
}

.stat-card strong {
    display: block;
    margin: 10px 0 4px;
    font-size: clamp(24px, 2vw, 34px);
}

.stat-card.warning strong { color: var(--warning); }
.stat-card.danger strong { color: var(--danger); }
.stat-card.success strong { color: var(--success); }

.panel {
    margin-top: 20px;
    padding: 24px;
}

.panel-header {
    margin-bottom: 22px;
}

.panel-header.split {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 20px;
}

.modern-form,
.filter-bar {
    width: 100%;
}

.form-grid,
.filter-bar {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 14px;
}

.form-grid.two-columns {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.field {
    position: relative;
    display: grid;
    gap: 8px;
}

.field > span {
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
}

.field input,
.field select {
    width: 100%;
    min-height: 48px;
    padding: 12px 14px;
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 15px;
    background: rgba(15, 23, 42, 0.88);
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.field input:focus,
.field select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(56, 189, 248, 0.13);
    background: rgba(15, 23, 42, 1);
}

.field input::placeholder {
    color: rgba(148, 163, 184, 0.7);
}

.search-field {
    grid-column: span 2;
}

.compact-field {
    min-width: 110px;
}

.filter-bar {
    align-items: end;
    grid-template-columns: 1.6fr 1.02fr 1.02fr 1.02fr 0.76fr 0.76fr 0.72fr auto;
    padding: 16px;
    border: 1px solid var(--border);
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.035);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    padding: 0 16px;
    border: 0;
    border-radius: 14px;
    font-weight: 800;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

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

.btn-primary {
    color: #06121f;
    background: linear-gradient(135deg, var(--primary), #67e8f9);
    box-shadow: 0 12px 30px rgba(56, 189, 248, 0.24);
}

.btn-ghost {
    color: var(--text);
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.07);
}

.btn-muted {
    color: var(--text);
    background: rgba(148, 163, 184, 0.18);
}

.btn-danger {
    color: #fff;
    background: rgba(239, 68, 68, 0.84);
}

.flash-stack {
    display: grid;
    gap: 10px;
    margin: 18px 0;
}

.flash {
    padding: 14px 16px;
    border-radius: 16px;
    border: 1px solid var(--border);
    font-weight: 700;
}

.flash-success {
    color: #bbf7d0;
    background: rgba(34, 197, 94, 0.12);
    border-color: rgba(34, 197, 94, 0.25);
}

.flash-error {
    color: #fecaca;
    background: rgba(239, 68, 68, 0.12);
    border-color: rgba(239, 68, 68, 0.25);
}

.table-wrapper {
    margin-top: 18px;
    overflow-x: hidden;
    border: 1px solid var(--border);
    border-radius: 20px;
}

table {
    width: 100%;
    min-width: 0;
    border-collapse: collapse;
    table-layout: auto;
    background: rgba(15, 23, 42, 0.58);
}

th,
td {
    padding: 15px 12px;
    text-align: left;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
    overflow-wrap: anywhere;
}

th {
    position: sticky;
    top: 0;
    z-index: 1;
    color: var(--muted);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    background: var(--panel-strong);
}

th a:hover {
    color: var(--primary);
}

tbody tr {
    transition: background 0.2s ease;
}

tbody tr:hover {
    background: rgba(56, 189, 248, 0.08);
}

.name-cell {
    color: #f8fafc;
    font-weight: 800;
}

.badge {
    display: inline-flex;
    align-items: center;
    white-space: nowrap;
    padding: 7px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 900;
}

.badge-success {
    color: #bbf7d0;
    background: rgba(34, 197, 94, 0.14);
}

.badge-warning {
    color: #fde68a;
    background: rgba(245, 158, 11, 0.16);
}

.badge-danger {
    color: #fecaca;
    background: rgba(239, 68, 68, 0.16);
}

.badge-muted {
    color: var(--muted);
    background: rgba(148, 163, 184, 0.14);
}

.icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 36px;
    padding: 0 12px;
    border: 0;
    border-radius: 12px;
    color: var(--text);
    font-size: 13px;
    font-weight: 800;
    cursor: pointer;
    transition: transform 0.2s ease, background 0.2s ease;
}

.icon-btn:hover {
    transform: translateY(-1px);
}

.icon-btn.edit {
    background: rgba(56, 189, 248, 0.14);
}

.icon-btn.delete {
    background: rgba(239, 68, 68, 0.16);
}

.empty-state {
    padding: 30px;
    text-align: center;
    color: var(--muted);
}

.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    margin-top: 20px;
    flex-wrap: wrap;
}

.pagination a,
.pagination span {
    display: inline-grid;
    place-items: center;
    min-width: 42px;
    height: 42px;
    padding: 0 12px;
    border: 1px solid var(--border);
    border-radius: 12px;
    color: var(--muted);
    background: rgba(255, 255, 255, 0.04);
}

.pagination a:hover,
.pagination a.active {
    color: #06121f;
    background: var(--primary);
}

.single-page {
    width: min(920px, calc(100% - 32px));
    margin: 0 auto;
    padding: 34px 0;
}

.back-link {
    display: inline-flex;
    margin-bottom: 18px;
    color: var(--primary);
    font-weight: 800;
}

.update-panel {
    margin-top: 0;
}

.native-select-hidden {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    opacity: 0 !important;
    pointer-events: none !important;
}

.custom-select {
    position: relative;
    width: 100%;
    z-index: 5;
}

.custom-select.open {
    z-index: 100;
}

.custom-select-trigger {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    width: 100%;
    min-height: 48px;
    padding: 12px 14px;
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 15px;
    background: linear-gradient(180deg, rgba(15, 23, 42, 0.98), rgba(12, 19, 35, 0.95));
    outline: none;
    cursor: pointer;
    transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.custom-select-trigger:hover,
.custom-select.open .custom-select-trigger,
.custom-select.is-invalid .custom-select-trigger {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(56, 189, 248, 0.12);
}

.custom-select.is-invalid .custom-select-trigger {
    border-color: var(--danger);
    box-shadow: 0 0 0 4px rgba(239, 68, 68, 0.12);
}

.custom-select-value {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.custom-select-arrow {
    display: inline-grid;
    place-items: center;
    width: 24px;
    height: 24px;
    border-radius: 999px;
    color: var(--primary);
    background: rgba(56, 189, 248, 0.1);
    transition: transform 0.2s ease;
}

.custom-select.open .custom-select-arrow {
    transform: rotate(180deg);
}

.custom-select-menu {
    position: absolute;
    left: 0;
    right: 0;
    top: calc(100% + 8px);
    display: none;
    max-height: 280px;
    overflow-y: auto;
    padding: 8px;
    border: 1px solid rgba(56, 189, 248, 0.28);
    border-radius: 16px;
    background: rgba(10, 17, 32, 0.98);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
    backdrop-filter: blur(20px);
}

.custom-select.open .custom-select-menu {
    display: grid;
    gap: 4px;
}

.custom-select-option {
    width: 100%;
    padding: 11px 12px;
    border: 0;
    border-radius: 12px;
    color: var(--text);
    text-align: left;
    background: transparent;
    cursor: pointer;
}

.custom-select-option:hover,
.custom-select-option.selected {
    color: #06121f;
    background: linear-gradient(135deg, var(--primary), #67e8f9);
}

.custom-select-option.disabled {
    color: rgba(148, 163, 184, 0.8);
    cursor: default;
    background: transparent;
}

.custom-select-menu::-webkit-scrollbar {
    width: 8px;
}

.custom-select-menu::-webkit-scrollbar-thumb {
    border-radius: 999px;
    background: rgba(148, 163, 184, 0.36);
}

.modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 900;
    opacity: 0;
    visibility: hidden;
    background: rgba(3, 7, 18, 0.58);
    backdrop-filter: blur(0);
    transition: opacity 0.22s ease, visibility 0.22s ease, backdrop-filter 0.22s ease;
}

.modal-backdrop.show {
    opacity: 1;
    visibility: visible;
    backdrop-filter: blur(8px);
}

.modal {
    position: fixed;
    inset: 0;
    z-index: 950;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 24px;
    pointer-events: none;
}

.modal.show {
    display: flex;
}

.modal-card {
    position: relative;
    width: min(720px, 100%);
    max-height: calc(100vh - 48px);
    padding: 28px;
    border: 1px solid rgba(148, 163, 184, 0.22);
    border-radius: 26px;
    background:
        radial-gradient(circle at top right, rgba(56, 189, 248, 0.12), transparent 16rem),
        rgba(17, 24, 45, 0.98);
    box-shadow: 0 32px 90px rgba(0, 0, 0, 0.56);
    pointer-events: auto;
    overflow: visible;
    animation: modalIn 0.22s ease both;
}

.modal-card-wide {
    width: min(1060px, 100%);
}

.modal-card-confirm {
    width: min(560px, 100%);
}

@keyframes modalIn {
    from {
        opacity: 0;
        transform: translateY(18px) scale(0.98);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.modal-close {
    position: absolute;
    top: 18px;
    right: 18px;
    display: grid;
    place-items: center;
    width: 38px;
    height: 38px;
    border: 1px solid var(--border);
    border-radius: 999px;
    color: var(--text);
    background: rgba(255, 255, 255, 0.06);
    cursor: pointer;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 20px;
    margin-bottom: 22px;
    padding-right: 42px;
}

.modal-chip {
    display: inline-flex;
    align-items: center;
    padding: 8px 12px;
    border-radius: 999px;
    color: #bae6fd;
    background: rgba(56, 189, 248, 0.14);
    font-weight: 900;
}

.modal-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.modal-actions {
    justify-content: flex-start;
    margin-top: 20px;
}

.modal-actions.right {
    justify-content: flex-end;
}

.confirm-icon {
    display: grid;
    place-items: center;
    width: 48px;
    height: 48px;
    margin-bottom: 14px;
    border-radius: 18px;
    color: #fff;
    font-size: 24px;
    font-weight: 900;
    background: rgba(239, 68, 68, 0.85);
    box-shadow: 0 14px 36px rgba(239, 68, 68, 0.24);
}

@media (max-width: 1320px) {
    .table-wrapper {
        overflow-x: hidden;
    }

    th,
    td {
        padding: 13px 10px;
        font-size: 14px;
    }

    .badge,
    .icon-btn {
        font-size: 12px;
    }
}

@media (max-width: 1180px) {
    .app-shell {
        grid-template-columns: 1fr;
    }

    .sidebar {
        position: relative;
        height: auto;
        padding: 16px;
    }

    .nav-menu {
        grid-template-columns: repeat(4, minmax(0, 1fr));
        margin-top: 14px;
    }

    .sidebar-note {
        position: static;
        margin-top: 14px;
    }

    .stats-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .filter-bar,
    .form-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .search-field {
        grid-column: span 2;
    }

    table {
        min-width: 900px;
    }

    .table-wrapper {
        overflow-x: auto;
        scrollbar-width: none;
    }

    .table-wrapper::-webkit-scrollbar {
        display: none;
    }
}

@media (max-width: 720px) {
    .main-content {
        padding: 18px;
    }

    .hero-card,
    .panel-header.split,
    .modal-header {
        align-items: flex-start;
        flex-direction: column;
    }

    .hero-card h1 {
        font-size: 34px;
    }

    .stats-grid,
    .filter-bar,
    .form-grid,
    .form-grid.two-columns,
    .nav-menu,
    .modal-grid {
        grid-template-columns: 1fr;
    }

    .search-field {
        grid-column: span 1;
    }

    .panel,
    .hero-card,
    .modal-card {
        padding: 20px;
    }

    .modal {
        padding: 14px;
    }

    .modal-card {
        max-height: calc(100vh - 28px);
        overflow-y: auto;
    }
}

/* =========================================================
   GÜNCELLEME: Daraltılabilir yan panel, ayrı ekranlar,
   daha güçlü genel panel ve sıkışmayan stok listesi
   ========================================================= */

.app-shell {
    grid-template-columns: 300px minmax(0, 1fr);
    transition: grid-template-columns 0.24s ease;
}

.app-shell.sidebar-collapsed {
    grid-template-columns: 92px minmax(0, 1fr);
}

.sidebar {
    overflow: hidden;
    transition: width 0.24s ease, padding 0.24s ease;
}

.sidebar-toggle {
    display: grid;
    place-items: center;
    width: 42px;
    height: 42px;
    margin: 0 0 14px auto;
    border: 1px solid var(--border);
    border-radius: 14px;
    color: var(--text);
    background: rgba(255, 255, 255, 0.06);
    cursor: pointer;
    transition: transform 0.2s ease, background 0.2s ease, border-color 0.2s ease;
}

.sidebar-toggle:hover {
    transform: translateY(-1px);
    border-color: rgba(56, 189, 248, 0.38);
    background: rgba(56, 189, 248, 0.12);
}

.brand-text,
.nav-label,
.nav-count,
.sidebar-status,
.sidebar-note {
    transition: opacity 0.18s ease, transform 0.18s ease, max-width 0.18s ease;
}

.app-shell.sidebar-collapsed .sidebar {
    padding-left: 16px;
    padding-right: 16px;
}

.app-shell.sidebar-collapsed .brand {
    justify-content: center;
    padding: 13px 10px;
}

.app-shell.sidebar-collapsed .brand-text,
.app-shell.sidebar-collapsed .nav-label,
.app-shell.sidebar-collapsed .nav-count,
.app-shell.sidebar-collapsed .sidebar-status,
.app-shell.sidebar-collapsed .sidebar-note {
    opacity: 0;
    max-width: 0;
    transform: translateX(-8px);
    pointer-events: none;
    overflow: hidden;
}

.app-shell.sidebar-collapsed .nav-item {
    justify-content: center;
    padding: 13px 10px;
}

.nav-button {
    width: 100%;
    border: 0;
    text-align: left;
    background: transparent;
    cursor: pointer;
}

.nav-icon {
    display: inline-grid;
    place-items: center;
    min-width: 24px;
    height: 24px;
}

.nav-count {
    margin-left: auto;
    display: inline-grid;
    place-items: center;
    min-width: 28px;
    height: 24px;
    padding: 0 8px;
    border-radius: 999px;
    color: #bae6fd;
    font-size: 12px;
    font-weight: 900;
    background: rgba(56, 189, 248, 0.12);
}

.danger-count {
    color: #fecaca;
    background: rgba(239, 68, 68, 0.14);
}

.sidebar-status {
    display: grid;
    gap: 10px;
    margin-top: 24px;
    padding: 16px;
    border: 1px solid rgba(56, 189, 248, 0.18);
    border-radius: 18px;
    background: rgba(56, 189, 248, 0.055);
}

.sidebar-kicker {
    color: var(--primary);
    font-size: 12px;
    font-weight: 900;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.side-metric {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    color: var(--muted);
}

.side-metric strong {
    color: var(--text);
    font-size: 18px;
}

.danger-text {
    color: var(--danger) !important;
}

.mini-progress,
.progress-track {
    overflow: hidden;
    height: 9px;
    border-radius: 999px;
    background: rgba(148, 163, 184, 0.14);
}

.mini-progress span,
.progress-track span {
    display: block;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, var(--primary), #67e8f9);
}

.view-page {
    display: none;
    animation: pageIn 0.22s ease both;
}

.view-page.active {
    display: block;
}

@keyframes pageIn {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.dashboard-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.35fr) minmax(320px, 0.75fr);
    gap: 20px;
    align-items: stretch;
}

.dashboard-panel {
    margin-top: 0;
}

.wide-panel {
    grid-row: span 2;
}

.compact-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 18px;
}

.health-score {
    display: inline-grid;
    place-items: center;
    min-width: 72px;
    height: 72px;
    border-radius: 22px;
    color: #06121f;
    font-size: 24px;
    font-weight: 1000;
    background: linear-gradient(135deg, var(--primary), #67e8f9);
    box-shadow: 0 18px 44px rgba(56, 189, 248, 0.24);
}

.progress-stack {
    display: grid;
    gap: 22px;
    margin-top: 26px;
}

.progress-row {
    display: grid;
    gap: 12px;
}

.progress-row strong,
.info-grid strong,
.insight-item strong {
    display: block;
    color: var(--text);
}

.progress-row span,
.info-grid span,
.info-grid small,
.insight-item small {
    color: var(--muted);
}

.progress-track {
    height: 14px;
}

.progress-track.success span {
    background: linear-gradient(90deg, var(--success), #86efac);
}

.insight-list {
    display: grid;
    gap: 12px;
    margin-top: 16px;
}

.insight-item {
    display: flex;
    gap: 12px;
    padding: 14px;
    border: 1px solid var(--border);
    border-radius: 18px;
}

.insight-item > span {
    display: grid;
    place-items: center;
    width: 42px;
    height: 42px;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.06);
}

.danger-soft {
    background: rgba(239, 68, 68, 0.08);
}

.warning-soft {
    background: rgba(245, 158, 11, 0.08);
}

.success-soft {
    background: rgba(34, 197, 94, 0.08);
}

.info-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    margin-top: 16px;
}

.info-grid > div {
    min-height: 98px;
    padding: 14px;
    border: 1px solid var(--border);
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.035);
}

.info-grid strong {
    margin-top: 6px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Filtre alanı: butonlar sabit yan yana, dropdownlar daha ferah */
.panel,
.filter-bar,
.field,
.type-field {
    overflow: visible;
}

.filter-bar {
    position: relative;
    grid-template-columns: minmax(260px, 1.8fr) minmax(190px, 1fr) minmax(180px, 0.9fr) minmax(180px, 0.9fr) minmax(130px, 0.72fr) minmax(130px, 0.72fr) minmax(120px, 0.6fr);
    align-items: end;
    gap: 16px;
    overflow: visible;
}

.search-field {
    grid-column: auto;
}

.filter-actions {
    grid-column: 1 / -1;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 10px;
    flex-wrap: nowrap !important;
    width: 100%;
}

.filter-actions .btn {
    min-width: 112px;
}

.custom-select {
    min-width: 0;
}

.custom-select-menu {
    right: auto;
    min-width: 100%;
    width: max(100%, 230px);
    max-width: min(320px, calc(100vw - 48px));
    overflow-x: hidden;
    z-index: 250;
}

.type-field .custom-select-menu {
    width: max(100%, 260px);
}

.custom-select.drop-up .custom-select-menu {
    top: auto;
    bottom: calc(100% + 8px);
}

.custom-select-option {
    white-space: normal;
    line-height: 1.35;
}

/* Stok tablosu: masaüstünde yatay scroll oluşturmadan sıkışmayı azaltır */
.table-wrapper {
    overflow-x: hidden !important;
    overflow-y: visible;
}

.medicine-table {
    width: 100%;
    min-width: 0 !important;
    table-layout: fixed;
}

.col-id { width: 5.5%; }
.col-name { width: 14%; }
.col-type { width: 12%; }
.col-stock { width: 6.5%; }
.col-stock-status { width: 11%; }
.col-price { width: 9%; }
.col-value { width: 10%; }
.col-expiry { width: 9.5%; }
.col-expiry-status { width: 11.5%; }
.col-actions { width: 11%; }

.medicine-table th,
.medicine-table td {
    padding: 14px 10px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.medicine-table .type-cell,
.medicine-table .name-cell {
    white-space: normal;
    line-height: 1.3;
}

.action-cell {
    gap: 8px;
    flex-wrap: nowrap !important;
}

.action-cell .icon-btn {
    min-width: 76px;
    padding: 0 10px;
}

body.modal-open {
    overflow: hidden;
}

@media (max-width: 1420px) {
    .main-content {
        max-width: 100%;
    }

    .medicine-table th,
    .medicine-table td {
        padding: 12px 8px;
        font-size: 13px;
    }

    .badge,
    .icon-btn {
        font-size: 11px;
    }

    .action-cell .icon-btn {
        min-width: 66px;
    }
}

@media (max-width: 1180px) {
    .app-shell,
    .app-shell.sidebar-collapsed {
        grid-template-columns: 1fr;
    }

    .sidebar {
        position: relative;
        height: auto;
        overflow: visible;
    }

    .sidebar-toggle {
        display: none;
    }

    .app-shell.sidebar-collapsed .brand-text,
    .app-shell.sidebar-collapsed .nav-label,
    .app-shell.sidebar-collapsed .nav-count,
    .app-shell.sidebar-collapsed .sidebar-status,
    .app-shell.sidebar-collapsed .sidebar-note {
        opacity: 1;
        max-width: none;
        transform: none;
        pointer-events: auto;
        overflow: visible;
    }

    .dashboard-grid {
        grid-template-columns: 1fr;
    }

    .wide-panel {
        grid-row: auto;
    }

    .filter-bar {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .search-field {
        grid-column: span 2;
    }

    .table-wrapper {
        overflow-x: auto !important;
        scrollbar-width: none;
    }

    .table-wrapper::-webkit-scrollbar {
        display: none;
    }

    .medicine-table {
        min-width: 980px !important;
    }
}

@media (max-width: 720px) {
    .dashboard-grid,
    .info-grid,
    .filter-bar {
        grid-template-columns: 1fr;
    }

    .search-field,
    .filter-actions {
        grid-column: span 1;
    }

    .filter-actions {
        flex-wrap: wrap !important;
    }

    .health-score {
        min-width: 58px;
        height: 58px;
        font-size: 20px;
    }
}

/* =========================================================
   SON GÜNCELLEME: taşmayan filtre/tablo, daha dengeli
   daraltılmış panel ve brand içi menü butonu
   ========================================================= */
html,
body {
    max-width: 100%;
    overflow-x: hidden;
}

.app-shell,
.main-content,
.panel,
.filter-bar,
.table-wrapper {
    min-width: 0;
}

/* Yan panel üst alanı: logo kartı + daraltma butonu aynı satırda */
.brand-row {
    display: flex;
    align-items: stretch;
    gap: 10px;
    width: 100%;
}

.brand-row .brand {
    flex: 1 1 auto;
    min-width: 0;
}

.brand-row .sidebar-toggle {
    flex: 0 0 44px;
    width: 44px;
    height: auto;
    min-height: 58px;
    margin: 0;
    border-radius: 18px;
}

.app-shell {
    grid-template-columns: 300px minmax(0, 1fr);
}

.app-shell.sidebar-collapsed {
    grid-template-columns: 118px minmax(0, 1fr);
}

.app-shell.sidebar-collapsed .sidebar {
    padding: 24px 12px;
}

.app-shell.sidebar-collapsed .brand-row {
    gap: 8px;
    justify-content: center;
}

.app-shell.sidebar-collapsed .brand {
    flex: 0 0 52px;
    width: 52px;
    min-height: 58px;
    padding: 8px;
    justify-content: center;
    border-radius: 18px;
}

.app-shell.sidebar-collapsed .brand-icon {
    width: 38px;
    height: 38px;
    min-width: 38px;
    border-radius: 13px;
    font-size: 21px;
}

.app-shell.sidebar-collapsed .sidebar-toggle {
    flex-basis: 42px;
    width: 42px;
    min-height: 58px;
    border-radius: 18px;
}

.app-shell.sidebar-collapsed .nav-menu {
    justify-items: center;
    gap: 14px;
    margin-top: 26px;
}

.app-shell.sidebar-collapsed .nav-item {
    width: 58px;
    height: 58px;
    min-height: 58px;
    justify-content: center;
    padding: 0;
    border-radius: 18px;
}

.app-shell.sidebar-collapsed .nav-icon {
    min-width: 0;
    width: 28px;
    height: 28px;
    font-size: 19px;
    line-height: 1;
}

.app-shell.sidebar-collapsed .brand-text,
.app-shell.sidebar-collapsed .nav-label,
.app-shell.sidebar-collapsed .nav-count {
    display: none;
}

.app-shell.sidebar-collapsed .sidebar-status,
.app-shell.sidebar-collapsed .sidebar-note {
    display: none;
}

/* Filtre alanı: dar ekranda bile taşmadan kırılır */
.filter-bar {
    display: grid;
    grid-template-columns: minmax(240px, 1.65fr) repeat(3, minmax(150px, 1fr));
    gap: 16px;
    align-items: end;
    position: relative;
    z-index: 40;
    overflow: visible !important;
}

.filter-bar .field,
.filter-bar input,
.filter-bar select,
.filter-bar .custom-select {
    min-width: 0;
}

.filter-bar .compact-field {
    min-width: 0;
}

.filter-actions {
    grid-column: 1 / -1;
    display: flex !important;
    flex-direction: row !important;
    align-items: center;
    justify-content: flex-start;
    gap: 10px;
    flex-wrap: nowrap !important;
    width: 100%;
}

.filter-actions .btn {
    flex: 0 0 auto;
    min-width: 118px;
}

.custom-select.open {
    z-index: 2000;
}

.custom-select-menu {
    width: max(100%, 245px);
    min-width: 100%;
    max-width: min(360px, calc(100vw - 64px));
    max-height: 340px;
    overflow-x: hidden;
    overflow-y: auto;
}

.type-field .custom-select-menu {
    width: max(100%, 280px);
    max-height: 390px;
}

.table-wrapper {
    position: relative;
    z-index: 1;
    overflow-x: hidden !important;
    width: 100%;
}

.medicine-table {
    width: 100%;
    table-layout: fixed;
}

/* Kolonlar yeniden dengelendi; işlem kolonu taşmayacak kadar genişletildi. */
.col-id { width: 5%; }
.col-name { width: 14%; }
.col-type { width: 9%; }
.col-stock { width: 6.5%; }
.col-stock-status { width: 10%; }
.col-price { width: 8%; }
.col-value { width: 10%; }
.col-expiry { width: 9%; }
.col-expiry-status { width: 11%; }
.col-actions { width: 17.5%; }

.medicine-table th,
.medicine-table td {
    padding: 13px 9px;
}

.medicine-table td.action-cell {
    overflow: visible;
    text-overflow: clip;
    white-space: nowrap;
}

.action-cell {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: nowrap !important;
    min-width: 0;
}

.action-cell .icon-btn {
    flex: 1 1 0;
    min-width: 64px;
    max-width: 90px;
    padding: 0 9px;
}

@media (min-width: 1500px) {
    .filter-bar {
        grid-template-columns: minmax(260px, 1.55fr) minmax(170px, 1fr) minmax(170px, 1fr) minmax(170px, 1fr) minmax(120px, .72fr) minmax(120px, .72fr) minmax(115px, .62fr);
    }

    .filter-actions {
        grid-column: 1 / -1;
    }
}

@media (max-width: 1380px) {
    .panel-header.split {
        align-items: flex-start;
        flex-direction: column;
    }

    .panel-actions {
        width: 100%;
    }

    .filter-bar {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .search-field {
        grid-column: span 2;
    }
}

@media (max-width: 1180px) {
    .app-shell,
    .app-shell.sidebar-collapsed {
        grid-template-columns: 1fr;
    }

    .brand-row {
        max-width: 420px;
    }

    .app-shell.sidebar-collapsed .brand,
    .app-shell.sidebar-collapsed .sidebar-toggle {
        flex: initial;
    }

    .app-shell.sidebar-collapsed .brand-text,
    .app-shell.sidebar-collapsed .nav-label,
    .app-shell.sidebar-collapsed .nav-count {
        display: inline-flex;
    }

    .app-shell.sidebar-collapsed .sidebar-status,
    .app-shell.sidebar-collapsed .sidebar-note {
        display: grid;
    }

    .table-wrapper {
        overflow-x: auto !important;
        scrollbar-width: thin;
    }

    .medicine-table {
        min-width: 980px !important;
    }
}

@media (max-width: 720px) {
    .filter-bar {
        grid-template-columns: 1fr;
    }

    .search-field {
        grid-column: auto;
    }

    .filter-actions {
        grid-column: auto;
        flex-wrap: nowrap !important;
    }

    .filter-actions .btn {
        min-width: 0;
        flex: 1 1 0;
    }

    .brand-row {
        max-width: none;
    }
}

/* =========================================================
   SON DÜZELTME 2: filtrelerin kutu dışına taşmaması ve
   yan panel marka/toggle hizasının kararlı hale getirilmesi
   ========================================================= */

/* Geniş panelde EczaneDB ve menü butonu tek modern kutu içinde durur. */
.brand-row {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 10px;
    border: 1px solid var(--border);
    border-radius: 22px;
    background: rgba(255, 255, 255, 0.04);
    box-shadow: var(--shadow);
}

.brand-row .brand {
    flex: 1 1 auto;
    min-width: 0;
    padding: 10px;
    border: 0;
    border-radius: 16px;
    background: transparent;
    box-shadow: none;
}

.brand-row .sidebar-toggle {
    flex: 0 0 48px;
    width: 48px;
    align-self: stretch;
    min-height: 54px;
    height: auto;
    margin: 0;
    border-radius: 18px;
}

/* Dar panelde iki simge yan yana değil; menü üstte, eczane simgesi altta olur. */
.app-shell.sidebar-collapsed {
    grid-template-columns: 96px minmax(0, 1fr);
}

.app-shell.sidebar-collapsed .sidebar {
    padding: 24px 14px;
}

.app-shell.sidebar-collapsed .brand-row {
    flex-direction: column-reverse;
    align-items: center;
    justify-content: flex-start;
    gap: 12px;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
}

.app-shell.sidebar-collapsed .brand-row .sidebar-toggle,
.app-shell.sidebar-collapsed .brand-row .brand {
    flex: 0 0 58px;
    width: 58px;
    height: 58px;
    min-height: 58px;
    border: 1px solid var(--border);
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.045);
    box-shadow: none;
}

.app-shell.sidebar-collapsed .brand-row .brand {
    display: grid;
    place-items: center;
    padding: 8px;
}

.app-shell.sidebar-collapsed .brand-icon {
    width: 42px;
    height: 42px;
    min-width: 42px;
    border-radius: 14px;
    font-size: 23px;
}

.app-shell.sidebar-collapsed .sidebar-toggle {
    display: grid;
    place-items: center;
    padding: 0;
}

.app-shell.sidebar-collapsed .nav-menu {
    margin-top: 28px;
    justify-items: center;
    gap: 16px;
}

.app-shell.sidebar-collapsed .nav-item {
    width: 58px;
    height: 58px;
    min-height: 58px;
    padding: 0;
    border-radius: 18px;
}

/* Filtre kutusu kendi içinde kırılır; sağ tarafa taşma yapmaz. */
.main-content,
.view-page,
.panel,
.filter-bar,
.table-wrapper {
    max-width: 100%;
}

.filter-bar {
    display: grid !important;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)) !important;
    align-items: end;
    gap: 16px !important;
    width: 100%;
    min-width: 0;
    overflow: visible !important;
}

.filter-bar .search-field {
    grid-column: span 2;
}

.filter-bar .field,
.filter-bar .compact-field,
.filter-bar input,
.filter-bar select,
.filter-bar .custom-select,
.filter-bar .custom-select-trigger {
    width: 100%;
    min-width: 0 !important;
    max-width: 100%;
}

/* Filtre dropdownları alanın dışına taşmaz; içerik gerekirse satır kırar. */
.filter-bar .custom-select-menu,
.filter-bar .type-field .custom-select-menu {
    left: 0;
    right: auto;
    width: 100% !important;
    min-width: 100% !important;
    max-width: 100% !important;
    overflow-x: hidden;
}

.filter-bar .custom-select-option {
    white-space: normal;
    word-break: break-word;
}

.filter-actions {
    grid-column: 1 / -1 !important;
    display: flex !important;
    flex-direction: row !important;
    align-items: center;
    justify-content: flex-start;
    gap: 12px !important;
    flex-wrap: nowrap !important;
    width: 100%;
}

.filter-actions .btn {
    flex: 0 0 auto;
    min-width: 128px;
}

/* Tablo ve işlem butonları kartın içinde kalır. */
.table-wrapper {
    overflow-x: hidden !important;
}

.medicine-table {
    width: 100%;
    min-width: 0 !important;
    table-layout: fixed;
}

.col-actions {
    width: 16.5%;
}

.action-cell {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 8px;
    flex-wrap: nowrap !important;
    overflow: visible !important;
}

.action-cell .icon-btn {
    flex: 1 1 0;
    min-width: 68px;
    max-width: 96px;
}

@media (max-width: 1500px) {
    .filter-bar {
        grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)) !important;
    }

    .filter-bar .search-field {
        grid-column: span 2;
    }
}

@media (max-width: 1180px) {
    .app-shell,
    .app-shell.sidebar-collapsed {
        grid-template-columns: 1fr;
    }

    .app-shell.sidebar-collapsed .brand-row {
        flex-direction: row;
        width: min(420px, 100%);
        padding: 10px;
        border: 1px solid var(--border);
        border-radius: 22px;
        background: rgba(255, 255, 255, 0.04);
    }

    .app-shell.sidebar-collapsed .brand-row .brand {
        flex: 1 1 auto;
        width: auto;
        display: flex;
        justify-content: flex-start;
    }

    .app-shell.sidebar-collapsed .brand-row .sidebar-toggle {
        display: none;
    }

    .table-wrapper {
        overflow-x: auto !important;
        scrollbar-width: thin;
    }

    .medicine-table {
        min-width: 980px !important;
    }
}

@media (max-width: 760px) {
    .filter-bar {
        grid-template-columns: 1fr !important;
    }

    .filter-bar .search-field {
        grid-column: auto;
    }

    .filter-actions .btn {
        flex: 1 1 0;
        min-width: 0;
    }
}
