/* Kasanibil — mobil uyumluluk (tek kaynak) */

:root {
    --mob-nav-h: 3.5rem;
    --safe-t: env(safe-area-inset-top, 0px);
    --safe-b: env(safe-area-inset-bottom, 0px);
    --safe-l: env(safe-area-inset-left, 0px);
    --safe-r: env(safe-area-inset-right, 0px);
}

html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

/* Masaüstü: mobil öğeleri gizle */
.erp-mobile-nav,
.erp-drawer-backdrop,
.erp-mobile-drawer,
.erp-menu-btn,
.erp-mobile-account {
    display: none;
}

.erp-menu-btn--desktop {
    display: inline-flex;
}

/* —— Genel site (landing, giriş) —— */
.site-nav-toggle {
    display: none;
}

@media (max-width: 1024px) {
    html,
    body.erp-body,
    body.yp-body {
        overflow-x: hidden;
        max-width: 100vw;
    }

    .site-nav-toggle {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 44px;
        height: 44px;
        margin-left: auto;
        padding: 0;
        border: 1px solid #c3c4c7;
        border-radius: 10px;
        background: #fff;
        font-size: 1.25rem;
        cursor: pointer;
    }

    .header-inner {
        flex-wrap: wrap;
        gap: 10px;
        padding-top: var(--safe-t);
    }

    /* .site-header ile özgüllük: app.css'teki genel .nav{display:flex} kuralını yener */
    .site-header .site-nav {
        display: none;
        flex-direction: column;
        width: 100%;
        order: 3;
        gap: 6px;
        padding: 12px 0 8px;
        border-top: 1px solid #e2e8f0;
    }

    .site-header.nav-open .site-nav {
        display: flex;
    }

    .site-nav a,
    .site-nav .btn {
        width: 100%;
        min-height: 44px;
        justify-content: center;
    }

    .site-main {
        padding: 16px 0 calc(24px + var(--safe-b));
    }

    .container {
        padding-left: max(16px, var(--safe-l));
        padding-right: max(16px, var(--safe-r));
    }

    /* —— ERP panel —— */
    .erp-app {
        display: block;
        width: 100%;
        min-height: 100dvh;
        overflow-x: hidden;
    }

    .erp-main {
        width: 100%;
        min-height: 100dvh;
        padding-bottom: calc(var(--mob-nav-h) + var(--safe-b) + 8px);
    }

    .erp-menu-btn {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 44px;
        height: 44px;
        min-width: 44px;
        padding: 0;
        border: 1px solid #c3c4c7;
        border-radius: 10px;
        background: #fff;
        font-size: 1.25rem;
        line-height: 1;
        cursor: pointer;
        flex-shrink: 0;
        -webkit-tap-highlight-color: transparent;
        touch-action: manipulation;
    }

    .erp-menu-btn--desktop {
        display: none !important;
    }

    .erp-drawer-backdrop {
        display: none;
        position: fixed;
        inset: 0;
        z-index: 2040;
        background: rgba(15, 23, 42, 0.55);
        -webkit-tap-highlight-color: transparent;
        touch-action: manipulation;
    }

    .erp-app.is-nav-open .erp-drawer-backdrop {
        display: block;
    }

    .erp-header {
        position: sticky;
        top: 0;
        z-index: 200;
    }

    .erp-topnav {
        flex-direction: column;
        align-items: stretch;
    }

    .erp-topnav-brand {
        display: none;
    }

    /* Masaüstü yatay menü mobilde gizli; kök seviye çekmece kullanılır */
    .erp-topnav .erp-topnav-scroll {
        display: none !important;
    }

    .erp-mobile-drawer {
        display: flex;
        flex-direction: column;
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        width: min(300px, 88vw);
        z-index: 2050;
        background: #1e293b;
        color: #e2e8f0;
        box-shadow: 4px 0 32px rgba(0, 0, 0, 0.28);
        transform: translate3d(-105%, 0, 0);
        transition: transform 0.24s cubic-bezier(0.32, 0.72, 0, 1);
        padding-top: var(--safe-t);
        padding-bottom: var(--safe-b);
        padding-left: var(--safe-l);
        visibility: hidden;
        pointer-events: none;
    }

    .erp-app.is-nav-open .erp-mobile-drawer {
        transform: translate3d(0, 0, 0);
        visibility: visible;
        pointer-events: auto;
    }

    .erp-mobile-drawer-head {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 12px;
        padding: 14px 16px 12px;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
        flex-shrink: 0;
    }

    .erp-mobile-drawer-brand {
        display: inline-flex;
        align-items: center;
        gap: 10px;
        font-size: 1.125rem;
        font-weight: 700;
        color: #f8fafc;
        text-decoration: none;
        letter-spacing: -0.02em;
        line-height: 1;
        min-height: 44px;
    }

    .erp-mobile-drawer-logo {
        display: block;
        width: 28px;
        height: 28px;
        border-radius: 6px;
        object-fit: cover;
        object-position: center;
        flex-shrink: 0;
    }

    .erp-mobile-drawer-close {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 44px;
        height: 44px;
        padding: 0;
        border: 1px solid rgba(255, 255, 255, 0.15);
        border-radius: 10px;
        background: rgba(255, 255, 255, 0.08);
        color: #f8fafc;
        font-size: 1.5rem;
        line-height: 1;
        cursor: pointer;
        -webkit-tap-highlight-color: transparent;
        touch-action: manipulation;
    }

    .erp-mobile-drawer-search-wrap {
        padding: 0 12px 10px;
        flex-shrink: 0;
    }

    .erp-mobile-drawer-search {
        width: 100%;
        min-height: 44px;
        padding: 10px 12px;
        border: 1px solid rgba(255, 255, 255, 0.15);
        border-radius: 10px;
        background: rgba(0, 0, 0, 0.25);
        color: #f8fafc;
        font-size: 16px;
        box-sizing: border-box;
    }

    .erp-mobile-drawer-search::placeholder {
        color: #94a3b8;
    }

    .erp-mobile-drawer-scroll {
        flex: 1;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior: contain;
        padding: 8px 12px 20px;
    }

    .erp-mobile-drawer .erp-topnav-drop-menu--mega {
        display: block;
        max-width: none;
        min-width: 0;
        padding: 4px 0;
    }

    .erp-mobile-drawer .erp-topnav-mega-col {
        border-right: none;
        border-bottom: 1px solid rgba(255, 255, 255, 0.06);
        padding-bottom: 4px;
        margin-bottom: 4px;
    }

    .erp-mobile-drawer .erp-topnav-mega-col:last-child {
        border-bottom: none;
        margin-bottom: 0;
    }

    .erp-mobile-drawer .erp-topnav-inner {
        flex-direction: column;
        align-items: stretch;
        gap: 2px;
    }

    .erp-mobile-drawer .erp-topnav-link,
    .erp-mobile-drawer .erp-topnav-drop-toggle {
        width: 100%;
        min-height: 48px;
        justify-content: flex-start;
        border-radius: 10px;
        font-size: 0.9375rem;
        touch-action: manipulation;
        -webkit-tap-highlight-color: transparent;
    }

    .erp-mobile-drawer .erp-topnav-drop {
        display: block;
    }

    .erp-mobile-drawer .erp-topnav-drop-menu {
        position: static;
        display: block !important;
        box-shadow: none;
        border: none;
        background: rgba(0, 0, 0, 0.2);
        border-radius: 10px;
        margin: 2px 0 6px 8px;
        padding: 4px 0;
        min-width: 0;
    }

    .erp-mobile-drawer .erp-topnav-drop:not([open]) .erp-topnav-drop-menu {
        display: none !important;
    }

    .erp-mobile-drawer .erp-topnav-sublink {
        min-height: 44px;
        padding-left: 20px;
        font-size: 0.875rem;
    }

    .erp-mobile-drawer .erp-topnav-drop-toggle::after {
        margin-left: auto;
    }

    body.erp-menu-open {
        overflow: hidden;
        touch-action: none;
    }

    .erp-abonelik-strip {
        padding: 8px max(12px, var(--safe-l)) 8px max(12px, var(--safe-r));
        font-size: 0.75rem;
        line-height: 1.4;
    }

    .erp-abonelik-strip-link {
        display: flex;
        align-items: flex-start;
        gap: 6px;
        width: 100%;
    }

    .erp-topbar {
        position: sticky;
        top: 0;
        z-index: 100;
        padding: 8px max(12px, var(--safe-l)) 8px max(12px, var(--safe-r));
        padding-top: max(8px, var(--safe-t));
        gap: 8px;
        flex-wrap: wrap;
        background: #fff;
        box-shadow: 0 1px 0 rgba(0, 0, 0, 0.06);
    }

    .erp-topbar-left {
        display: flex;
        align-items: center;
        gap: 10px;
        flex: 1;
        min-width: 0;
    }

    .erp-page-title {
        font-size: 1rem;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        min-width: 0;
    }

    .erp-firma-badge {
        display: none;
    }

    .erp-topbar-right {
        width: 100%;
        gap: 8px;
    }

    .erp-mobile-account {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        gap: 5px;
        min-height: 44px;
        padding: 8px 10px;
        border: 1px solid #dcdcde;
        border-radius: 10px;
        background: #fff;
        color: #2271b1;
        font-size: 0.75rem;
        font-weight: 700;
        text-decoration: none;
        white-space: nowrap;
    }

    .erp-mobile-account span[aria-hidden="true"] {
        font-size: 1rem;
    }

    .erp-user-name {
        display: none;
    }

    .erp-kasa-select {
        flex: 1;
        min-width: 0;
    }

    .erp-kasa-select select {
        width: 100%;
        min-height: 44px;
        font-size: 16px;
        border-radius: 10px;
    }

    .erp-content {
        padding: 12px max(12px, var(--safe-l)) 16px max(12px, var(--safe-r));
        max-width: none;
        margin: 0 auto;
    }

    .erp-body .panel-card {
        border-radius: 14px;
    }

    .panel-grid,
    .marketplace-grid {
        grid-template-columns: 1fr !important;
    }

    .erp-mobile-nav {
        display: flex;
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 150;
        height: calc(var(--mob-nav-h) + var(--safe-b));
        padding-bottom: var(--safe-b);
        padding-left: var(--safe-l);
        padding-right: var(--safe-r);
        background: #fff;
        border-top: 1px solid #dcdcde;
        box-shadow: 0 -2px 12px rgba(0, 0, 0, 0.06);
    }

    .erp-mobile-nav a,
    .erp-mobile-nav button {
        flex: 1;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 2px;
        min-width: 0;
        min-height: var(--mob-nav-h);
        padding: 4px 2px;
        border: none;
        background: transparent;
        color: #64748b;
        font: inherit;
        font-size: 0.625rem;
        font-weight: 600;
        text-decoration: none;
        cursor: pointer;
        -webkit-tap-highlight-color: transparent;
        touch-action: manipulation;
    }

    .erp-mobile-nav a.active,
    .erp-mobile-nav button.active {
        color: #2271b1;
    }

    .erp-mobile-nav-icon {
        font-size: 1.1rem;
        line-height: 1;
    }

    .erp-mobile-nav-label {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        max-width: 100%;
    }

    /* İçerik düzeni */
    .panel-grid {
        grid-template-columns: 1fr !important;
        gap: 12px;
    }

    .panel-card {
        padding: 16px;
        border-radius: 12px;
    }

    .panel-header-split {
        flex-direction: column;
    }

    .operasyon-filtre-presets {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 6px;
    }

    .operasyon-filtre-presets .btn {
        width: 100%;
        justify-content: center;
    }

    .operasyon-filtre-ozel {
        flex-direction: column;
        align-items: stretch;
    }

    .operasyon-filtre-ozel input[type="date"] {
        width: 100%;
        max-width: none;
    }

    .ozet-grid,
    .kayit-ozet-grid,
    .kayit-stat-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }

    .kayit-layout {
        grid-template-columns: 1fr !important;
    }

    .form-actions {
        flex-direction: column;
    }

    .form-actions .btn {
        width: 100%;
        min-height: 44px;
    }

    .form-group input,
    .form-group select,
    .form-group textarea,
    .auth-form input,
    .auth-form select,
    .auth-form textarea {
        width: 100%;
        max-width: 100%;
        font-size: 16px;
        min-height: 44px;
        border-radius: 10px;
    }

    .btn {
        min-height: 44px;
    }

    .table-actions {
        flex-direction: column;
        align-items: stretch;
    }

    .table-actions .btn {
        width: 100%;
    }

    .admin-tabs,
    .erp-subnav,
    .rapor-sub-tabs {
        overflow-x: auto;
        flex-wrap: nowrap;
        -webkit-overflow-scrolling: touch;
    }

    .admin-tab,
    .rapor-sub-tab {
        flex-shrink: 0;
        white-space: nowrap;
    }

    .table-scroll {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        margin: 0 -4px;
        padding: 0 4px;
    }

    .table-scroll .data-table {
        min-width: 520px;
    }

    .erp-user-name {
        display: none;
    }

    /* Destek widget — alt menü üstünde */
    .erp-destek-fab {
        right: max(14px, var(--safe-r));
        bottom: calc(var(--mob-nav-h) + var(--safe-b) + 12px);
        z-index: 140;
    }

    .erp-destek-widget {
        right: max(14px, var(--safe-r));
        left: max(14px, var(--safe-l));
        width: auto;
        bottom: calc(var(--mob-nav-h) + var(--safe-b) + 72px);
        max-height: min(70dvh, 480px);
        z-index: 141;
    }

    .erp-modal {
        padding: max(12px, var(--safe-t)) max(12px, var(--safe-r)) max(12px, var(--safe-l));
    }

    .erp-modal-panel {
        width: 100%;
        max-width: none;
        max-height: calc(100dvh - var(--safe-t) - var(--safe-b) - 24px);
        overflow-y: auto;
        border-radius: 14px;
    }

    .servis-header-actions,
    .servis-detay-header-actions,
    .panel-header-actions {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
    }

    .servis-header-actions .btn,
    .servis-detay-header-actions .btn,
    .panel-header-actions .btn {
        width: 100%;
        justify-content: center;
    }

    .servis-bildirim-header-actions {
        display: flex;
        flex-wrap: wrap;
        gap: 8px;
    }

    .servis-bildirim-header-actions .btn {
        flex: 1 1 calc(50% - 4px);
        min-width: 0;
    }

    .servis-grid-2 {
        grid-template-columns: 1fr !important;
    }

    .servis-filtre {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
    }

    .servis-filtre .btn {
        width: 100%;
        justify-content: center;
    }

    /* —— Yönetim paneli —— */
    .yp-app {
        display: block;
        overflow-x: hidden;
    }

    .yp-sidebar-backdrop {
        display: none;
        position: fixed;
        inset: 0;
        z-index: 2040;
        background: rgba(15, 23, 42, 0.55);
    }

    .yp-app.is-nav-open .yp-sidebar-backdrop {
        display: block;
    }

    .yp-sidebar {
        position: fixed !important;
        top: 0;
        left: 0;
        bottom: 0;
        z-index: 2050;
        width: min(300px, 88vw);
        height: 100dvh !important;
        transform: translate3d(-105%, 0, 0);
        transition: transform 0.24s cubic-bezier(0.32, 0.72, 0, 1);
        padding-top: var(--safe-t);
        padding-bottom: var(--safe-b);
    }

    .yp-app.is-nav-open .yp-sidebar {
        transform: translate3d(0, 0, 0);
    }

    body.yp-menu-open {
        overflow: hidden;
        touch-action: none;
    }

    .yp-sidebar-toggle {
        display: inline-flex;
        width: 44px;
        height: 44px;
        align-items: center;
        justify-content: center;
        border: 1px solid var(--yp-border);
        border-radius: 10px;
        background: #fff;
        font-size: 1.2rem;
        cursor: pointer;
    }

    .yp-topbar {
        position: sticky;
        top: 0;
        z-index: 100;
        padding: 12px 16px;
        background: #fff;
    }

    .yp-content {
        padding: 12px 16px 24px;
    }

    .yp-grid-2,
    .yp-form-grid {
        grid-template-columns: 1fr !important;
    }

    .yp-span-2 {
        grid-column: auto;
    }

    .yp-stat-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .yp-card {
        overflow-x: auto;
    }

    .yp-form input,
    .yp-form select,
    .yp-form textarea {
        font-size: 16px;
        min-height: 44px;
    }
}

@media (max-width: 600px) {
    .ozet-grid,
    .kayit-ozet-grid,
    .kayit-stat-grid,
    .yp-stat-grid {
        grid-template-columns: 1fr;
    }
}
