:root {
    --pmg-sidebar: #1e293b;
    --pmg-sidebar-soft: #334155;
    --pmg-accent: #2563eb;
    --pmg-bg: #f6f8fb;
    --pmg-border: #e2e8f0;
    --pmg-text-muted: #64748b;
}

html,
body {
    max-width: 100%;
    overflow-x: hidden;
}

body {
    background: var(--pmg-bg);
    color: #0f172a;
    font-size: 14px;
}

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

main {
    min-width: 0;
}

.auth-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    background: linear-gradient(var(--auth-gradient-angle, 135deg), var(--auth-gradient-from, #1e293b), var(--auth-gradient-to, #2563eb));
}

.auth-card {
    width: min(440px, calc(100vw - 32px));
    border: 0;
    border-radius: 8px;
    box-shadow: 0 24px 70px rgba(15, 23, 42, .25);
}

.auth-logo {
    max-width: 180px;
    max-height: 72px;
    object-fit: contain;
}

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

.sidebar,
.mobile-sidebar {
    background: var(--pmg-sidebar);
    color: #dbeafe;
}

.mobile-sidebar.offcanvas {
    --bs-offcanvas-width: min(320px, 86vw);
}

.sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}

.brand,
.sidebar .brand,
.mobile-sidebar .brand {
    height: 64px;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 20px;
    border-bottom: 1px solid rgba(255, 255, 255, .08);
    font-weight: 700;
    color: #fff;
}

.mobile-sidebar .offcanvas-header {
    min-height: 64px;
    padding: 0 8px 0 0;
    gap: 8px;
    border-bottom: 1px solid rgba(255, 255, 255, .08);
}

.mobile-sidebar .offcanvas-header .brand {
    height: 64px;
    border-bottom: 0;
    flex: 1;
    min-width: 0;
    padding-right: 8px;
}

.mobile-sidebar .offcanvas-header .mobile-sidebar-close {
    width: 44px;
    height: 44px;
    flex: 0 0 44px;
    min-width: 44px;
    margin: 0 8px 0 0;
    padding: 0;
    border-radius: 8px;
    box-sizing: border-box;
    background-size: 14px;
    background-color: rgba(255, 255, 255, .08);
    opacity: .9;
}

.mobile-sidebar .offcanvas-header .mobile-sidebar-close:hover,
.mobile-sidebar .offcanvas-header .mobile-sidebar-close:focus {
    background-color: rgba(255, 255, 255, .16);
    opacity: 1;
    box-shadow: 0 0 0 .2rem rgba(255, 255, 255, .12);
}

.brand-logo {
    width: 34px;
    height: 34px;
    object-fit: contain;
    border-radius: 6px;
    background: rgba(255, 255, 255, .08);
}

.settings-logo-preview {
    max-width: 180px;
    max-height: 72px;
    object-fit: contain;
}

.settings-favicon-preview {
    width: 40px;
    height: 40px;
    object-fit: contain;
}

.sidebar .nav-link,
.mobile-sidebar .nav-link {
    color: #cbd5e1;
    border-radius: 6px;
    margin: 2px 12px;
    padding: 10px 12px;
    display: flex;
    gap: 10px;
    align-items: center;
}

.sidebar .nav-link:hover,
.sidebar .nav-link.active,
.mobile-sidebar .nav-link:hover,
.mobile-sidebar .nav-link.active {
    color: #fff;
    background: var(--pmg-sidebar-soft);
}

.topbar {
    min-height: 64px;
    background: #fff;
    border-bottom: 1px solid var(--pmg-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 0 24px;
}

.topbar-title {
    min-width: 0;
}

.topbar-heading {
    min-width: 0;
}

.topbar-actions {
    min-width: 0;
    justify-content: flex-end;
}

.topbar-menu-toggle {
    width: 44px;
    min-width: 44px;
    height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.content {
    padding: 24px;
    min-width: 0;
}

.page-card,
.stat-card {
    background: #fff;
    border: 1px solid var(--pmg-border);
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(15, 23, 42, .04);
}

.stat-card {
    padding: 18px;
    border-left: 4px solid var(--pmg-accent);
}

.stat-card .value {
    font-size: 28px;
    font-weight: 800;
}

.page-toolbar,
.report-list-row,
.report-list-actions,
.notification-row {
    min-width: 0;
}

.toolbar-search {
    min-width: 260px;
    max-width: 420px;
    flex: 1 1 260px;
}

.table-responsive {
    width: 100%;
}

.table th {
    color: #475569;
    font-weight: 700;
    white-space: nowrap;
}

.table td {
    vertical-align: middle;
}

.mobile-card-actions {
    white-space: nowrap;
}

.avatar-initials {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: inline-grid;
    place-items: center;
    background: #dbeafe;
    color: #1d4ed8;
    font-weight: 700;
    flex: 0 0 auto;
}

.badge-status-yeni { background: #2563eb; }
.badge-status-qebul-edildi { background: #06b6d4; }
.badge-status-icradadir { background: #f59e0b; color: #111827; }
.badge-status-gozlemededir { background: #f97316; }
.badge-status-hell-edildi { background: #22c55e; }
.badge-status-baglandi { background: #64748b; }
.badge-status-legv-edildi { background: #ef4444; }
.badge-priority-tecili { background: #ef4444; }
.white-space-pre-line { white-space: pre-line; }

.ticket-row {
    cursor: pointer;
    transition: background-color .18s ease, box-shadow .18s ease, transform .18s ease;
}

.ticket-row > * {
    transition: background-color .18s ease, box-shadow .18s ease;
}

.ticket-row:hover,
.ticket-row:focus {
    background-color: #eff6ff;
    outline: 2px solid rgba(37, 99, 235, .18);
    outline-offset: -2px;
    transform: translateY(-1px);
}

.ticket-row:hover > *,
.ticket-row:focus > * {
    background-color: #eff6ff !important;
    box-shadow: 0 8px 18px rgba(37, 99, 235, .08);
}

.ticket-row:hover > :first-child,
.ticket-row:focus > :first-child {
    box-shadow: inset 3px 0 0 #2563eb, 0 8px 18px rgba(37, 99, 235, .08);
}

.ticket-row:hover td,
.ticket-row:focus td {
    color: #0f172a;
}

.pagination-responsive {
    margin-top: 1rem;
    overflow-x: auto;
    padding-bottom: 2px;
}

.pagination-responsive nav {
    display: flex;
}

.pagination {
    flex-wrap: wrap;
    gap: 4px;
    margin-bottom: 0;
}

.page-item {
    line-height: 1;
}

.page-link {
    min-width: 38px;
    min-height: 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: .45rem .7rem;
    font-size: .9rem;
    line-height: 1;
}

.pagination svg,
.page-link svg {
    width: 1rem;
    height: 1rem;
}

@media (prefers-reduced-motion: reduce) {
    .ticket-row,
    .ticket-row > * {
        transition: none;
    }

    .ticket-row:hover,
    .ticket-row:focus {
        transform: none;
    }
}

@media (max-width: 1199.98px) {
    .content {
        padding: 20px;
    }
}

@media (max-width: 991.98px) {
    .app-shell {
        display: block;
    }

    .topbar {
        min-height: 64px;
        height: auto;
        padding: 10px 16px;
        flex-wrap: wrap;
    }

    .topbar-title {
        flex: 1 1 260px;
    }

    .topbar-actions {
        flex: 1 1 auto;
        flex-wrap: wrap;
        gap: 8px !important;
    }

    .mobile-sidebar.offcanvas {
        --bs-offcanvas-width: min(320px, 86vw);
    }

    .mobile-sidebar .nav-link {
        min-height: 44px;
    }

    .content {
        padding: 16px;
    }

    .page-toolbar {
        flex-wrap: wrap;
    }

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

    .btn-sm {
        min-height: 44px;
    }
}

@media (max-width: 767.98px) {
    .topbar {
        align-items: flex-start;
    }

    .topbar-actions {
        width: 100%;
    }

    .responsive-filter-form > * {
        flex: 0 0 100%;
        max-width: 100%;
    }

    .filter-actions .btn,
    .filter-actions a {
        flex: 1 1 0;
    }

    .page-toolbar > .btn,
    .page-toolbar > form,
    .toolbar-search {
        width: 100%;
        max-width: none;
        flex-basis: 100%;
    }

    .report-list-row {
        align-items: flex-start !important;
        flex-wrap: wrap;
        gap: 8px;
    }

    .report-list-actions {
        width: 100%;
        justify-content: space-between;
        flex-wrap: wrap;
    }

    .report-list-actions .btn {
        flex: 1 1 120px;
    }

    .notification-row {
        align-items: flex-start !important;
        flex-direction: column;
    }

    .notification-row .btn {
        width: 100%;
    }
}

@media (max-width: 575.98px) {
    body {
        font-size: 13px;
    }

    .content {
        padding: 12px;
    }

    .page-card.p-4 {
        padding: 1rem !important;
    }

    .page-card.p-3,
    .stat-card {
        padding: .875rem !important;
    }

    .stat-card .value {
        font-size: 24px;
    }

    .topbar {
        align-items: center;
        flex-wrap: nowrap;
        min-height: 64px;
        padding: 8px 12px;
        gap: 8px;
    }

    .topbar-title {
        flex: 1 1 auto;
        flex-basis: auto;
        min-width: 0;
        gap: 8px !important;
    }

    .topbar-title .fw-bold,
    .topbar-title .small {
        display: block;
        max-width: 100%;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .topbar-actions {
        flex: 0 0 auto;
        flex-wrap: nowrap;
        width: auto;
        justify-content: flex-end;
        gap: 6px !important;
    }

    .topbar-actions > a,
    .topbar-actions > form {
        flex: 0 0 auto;
    }

    .logout-label {
        display: none;
    }

    .topbar-actions .btn,
    .topbar-actions .avatar-initials {
        width: 44px;
        min-width: 44px;
        height: 44px;
        padding: 0;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    .table-responsive {
        overflow-x: visible;
    }

    .mobile-card-table {
        border-collapse: separate;
        border-spacing: 0;
    }

    .mobile-card-table thead {
        display: none;
    }

    .mobile-card-table,
    .mobile-card-table tbody,
    .mobile-card-table tr,
    .mobile-card-table td {
        display: block;
        width: 100%;
    }

    .mobile-card-table tbody {
        background: transparent;
    }

    .mobile-card-table tr {
        border: 1px solid var(--pmg-border);
        border-radius: 8px;
        background: #fff;
        padding: 10px 12px;
        margin-bottom: 12px;
        box-shadow: 0 6px 18px rgba(15, 23, 42, .04);
    }

    .mobile-card-table td {
        border: 0;
        padding: 6px 0;
        white-space: normal;
        word-break: break-word;
    }

    .mobile-card-table td[data-label] {
        display: grid;
        grid-template-columns: minmax(92px, 38%) minmax(0, 1fr);
        gap: 10px;
        align-items: start;
    }

    .mobile-card-table td[data-label]::before {
        content: attr(data-label);
        color: var(--pmg-text-muted);
        font-weight: 700;
    }

    .mobile-card-table .mobile-card-actions {
        display: flex;
        gap: 8px;
        flex-wrap: wrap;
        justify-content: stretch;
        white-space: normal;
        padding-top: 10px;
    }

    .mobile-card-table .mobile-card-actions::before {
        display: none;
    }

    .mobile-card-table .mobile-card-actions .btn,
    .mobile-card-table .mobile-card-actions form {
        flex: 1 1 120px;
    }

    .mobile-card-table .mobile-card-actions form {
        display: flex;
        margin: 0;
    }

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

    .mobile-card-empty td {
        text-align: center;
    }

    .ticket-row:hover,
    .ticket-row:focus {
        transform: none;
    }

    .pagination-responsive {
        overflow-x: visible;
    }

    .pagination-responsive nav,
    .pagination {
        justify-content: center;
    }

    .pagination {
        gap: 5px;
    }

    .page-link {
        min-width: 44px;
        min-height: 44px;
        padding: .5rem .65rem;
        font-size: .875rem;
    }
}
