/* ===========================
   Kochler V2 Theme
   Visual-only layer loaded after the legacy stylesheet.
   =========================== */

:root[data-theme="light"] {
    --bg-primary: #f6f8fb;
    --bg-secondary: #ffffff;
    --bg-tertiary: #eef3f6;
    --card-bg: #ffffff;
    --text-primary: #102027;
    --text-secondary: #5b6b72;
    --text-muted: #8a9aa3;
    --border-color: #dbe4e8;
    --accent: #0f766e;
    --accent-hover: #115e59;
    --primary-color: #0f766e;
    --primary-hover: #115e59;
    --primary-rgb: 15, 118, 110;
    --success: #16a34a;
    --warning: #d97706;
    --danger: #dc2626;
    --brand-coral: #f97316;
    --brand-blue: #2563eb;
    --brand-ink: #102027;
    --radius: 10px;
    --shadow-sm: 0 1px 2px rgba(16, 32, 39, 0.06);
    --shadow-md: 0 12px 30px rgba(16, 32, 39, 0.08);
    --shadow-lg: 0 18px 42px rgba(16, 32, 39, 0.12);
}

:root[data-theme="dark"] {
    --bg-primary: #101820;
    --bg-secondary: #17232c;
    --bg-tertiary: #21323d;
    --card-bg: #17232c;
    --text-primary: #f4f7f8;
    --text-secondary: #b2c1c8;
    --text-muted: #7f929c;
    --border-color: #2a3d49;
    --accent: #2dd4bf;
    --accent-hover: #14b8a6;
    --primary-color: #2dd4bf;
    --primary-hover: #14b8a6;
    --primary-rgb: 45, 212, 191;
    --success: #4ade80;
    --warning: #fbbf24;
    --danger: #fb7185;
    --brand-coral: #fb923c;
    --brand-blue: #60a5fa;
    --brand-ink: #f4f7f8;
    --radius: 10px;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.24);
    --shadow-md: 0 14px 34px rgba(0, 0, 0, 0.28);
    --shadow-lg: 0 20px 48px rgba(0, 0, 0, 0.34);
}

html {
    background: var(--bg-primary);
}

body {
    background:
        radial-gradient(circle at 18% 0%, rgba(var(--primary-rgb), 0.08), transparent 26rem),
        linear-gradient(180deg, var(--bg-primary) 0%, var(--bg-tertiary) 100%);
    color: var(--text-primary);
    letter-spacing: 0;
}

body::selection {
    background: rgba(var(--primary-rgb), 0.2);
}

.topnav {
    height: 74px;
    padding: 0 1.5rem;
    background: color-mix(in srgb, var(--bg-secondary) 88%, transparent);
    border-bottom: 1px solid color-mix(in srgb, var(--border-color) 76%, transparent);
    box-shadow: 0 10px 30px rgba(16, 32, 39, 0.06);
    backdrop-filter: blur(16px);
    overflow: visible;
    z-index: 10000;
}

.topnav-logo {
    padding-right: 1.1rem;
    margin-right: 0.5rem;
}

.topnav-logo-img {
    max-height: 58px !important;
}

.topnav-nav {
    min-width: 0;
    overflow-x: auto;
    overflow-y: visible;
    scrollbar-width: none;
}

.topnav-nav::-webkit-scrollbar {
    display: none;
}

.topnav-item,
.topnav-dropdown,
.topnav-dropdown-btn {
    height: 74px;
}

.topnav-item {
    padding: 0 0.85rem;
    border-bottom: 0;
    border-radius: 999px;
    height: 42px;
    align-self: center;
    font-size: 0.88rem;
    font-weight: 650;
}

.topnav-item:hover,
.topnav-dropdown.open > .topnav-dropdown-btn {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.topnav-item.active,
.topnav-dropdown.active > .topnav-dropdown-btn {
    background: rgba(var(--primary-rgb), 0.12);
    color: var(--primary-color);
    border-bottom-color: transparent;
}

.topnav-dropdown-menu {
    top: 68px;
    background: var(--bg-secondary);
    border: 1px solid color-mix(in srgb, var(--border-color) 86%, transparent);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    z-index: 10050;
}

.topnav-dropdown.open {
    z-index: 10040;
}

.topnav-dropdown-item {
    border-radius: 8px;
}

.topnav-dropdown-item.active {
    background: rgba(var(--primary-rgb), 0.12);
}

.topnav-icon-btn,
.topnav-logout-btn {
    border-radius: 999px;
    background: var(--bg-secondary);
    box-shadow: var(--shadow-sm);
}

.topnav-user {
    min-height: 36px;
    padding: 0 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 999px;
    background: var(--bg-secondary);
}

.topnav-global-search input {
    min-height: 36px;
    border-radius: 999px !important;
    background: var(--bg-primary) !important;
}

.content {
    width: min(100%, 1480px);
    margin: 0 auto;
    padding: 1.5rem;
}

.dashboard {
    padding-bottom: 4rem;
}

.dash-header {
    padding: 1.25rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    background:
        linear-gradient(135deg, rgba(var(--primary-rgb), 0.13), transparent 52%),
        var(--bg-secondary);
    box-shadow: var(--shadow-md);
}

.dash-title {
    font-size: clamp(1.35rem, 2vw, 1.9rem);
    line-height: 1.15;
}

.dash-sub,
.dash-date {
    color: var(--text-secondary);
}

.kpi-group-label {
    border-radius: 999px;
    padding: 0.35rem 0.7rem;
}

.kpi-card,
.quick-panel,
.metric-panel,
.table-card,
.chart-card,
.form-card,
.info-card,
.help-card {
    background: color-mix(in srgb, var(--card-bg) 96%, var(--accent) 4%);
    border: 1px solid color-mix(in srgb, var(--border-color) 82%, transparent);
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
}

.kpi-card {
    position: relative;
    min-height: 132px;
    overflow: hidden;
}

.kpi-card::after {
    content: "";
    position: absolute;
    right: -24px;
    top: -28px;
    width: 86px;
    height: 86px;
    border-radius: 50%;
    background: rgba(var(--primary-rgb), 0.11);
}

.kpi-card:hover,
.quick-panel:hover {
    transform: translateY(-2px);
}

.kpi-icon-wrap {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(var(--primary-rgb), 0.12);
    font-size: 1.25rem;
}

.kpi-icon-wrap svg {
    width: 23px;
    height: 23px;
    fill: currentColor;
}

.kpi-blue .kpi-icon-wrap { background: rgba(37, 99, 235, 0.12); }
.kpi-yellow .kpi-icon-wrap { background: rgba(217, 119, 6, 0.14); }
.kpi-orange .kpi-icon-wrap { background: rgba(249, 115, 22, 0.14); }
.kpi-red .kpi-icon-wrap { background: rgba(220, 38, 38, 0.12); }
.kpi-purple .kpi-icon-wrap { background: rgba(15, 118, 110, 0.13); }

.kpi-value {
    font-size: clamp(1.7rem, 2.4vw, 2.35rem);
    line-height: 1;
}

.quick-section-label,
.raporlar-title {
    color: var(--text-primary);
}

.qsl-link,
.qp-more,
table a {
    color: var(--primary-color);
}

.qp-count-badge,
.badge {
    border-radius: 999px;
}

.df-btn,
.dp-apply,
.btn,
.btn-primary,
.btn-secondary,
.btn-ghost,
.btn-danger,
.btn-success {
    border-radius: 9px;
}

.btn-primary,
.dp-apply {
    background: var(--primary-color);
}

.btn-primary:hover,
.dp-apply:hover {
    background: var(--primary-hover);
}

.data-table th,
table th {
    background: color-mix(in srgb, var(--bg-tertiary) 72%, transparent);
}

.form-input,
.dp-input,
input[type="text"],
input[type="search"],
input[type="date"],
input[type="number"],
input[type="email"],
input[type="password"],
select,
textarea {
    border-radius: 9px;
}

.mobile-tabbar {
    display: none;
}

body:has(.login-wrapper) {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 1.5rem;
    background:
        linear-gradient(135deg, rgba(15, 118, 110, 0.16), transparent 42%),
        linear-gradient(315deg, rgba(249, 115, 22, 0.12), transparent 36%),
        var(--bg-primary);
}

.login-card {
    border-radius: var(--radius) !important;
    border: 1px solid color-mix(in srgb, var(--border-color) 78%, transparent) !important;
    box-shadow: var(--shadow-lg) !important;
}

.btn-login {
    min-height: 46px;
    border-radius: 9px !important;
    background: linear-gradient(135deg, var(--primary-color), var(--brand-blue)) !important;
    box-shadow: 0 12px 26px rgba(var(--primary-rgb), 0.22);
}

@media (max-width: 1320px) {
    .topnav-global-search,
    .topnav-user {
        display: none !important;
    }
}

@media (max-width: 1180px) {
    .topnav {
        padding: 0 1rem;
    }

    .topnav-item {
        padding: 0 0.7rem;
        font-size: 0.82rem;
    }
}

@media (max-width: 768px) {
    body {
        background: var(--bg-primary);
    }

    .topnav {
        height: 64px;
        padding: 0.65rem 0.9rem;
        border-bottom: 0;
        box-shadow: none;
    }

    .topnav-logo-img {
        max-height: 46px !important;
    }

    .topnav-right {
        margin-left: auto;
    }

    .topnav-icon-btn,
    .topnav-logout-btn {
        width: 40px;
        height: 40px;
    }

    .topnav-logout-btn {
        display: none;
    }

    .topnav-hamburger {
        width: 42px;
        height: 42px;
        align-items: center;
        justify-content: center;
        border: 1px solid var(--border-color);
        border-radius: 999px;
        background: var(--bg-secondary);
    }

    .mobile-drawer {
        width: min(86vw, 340px);
        padding-top: 3.6rem;
        background: var(--bg-secondary);
        border-right: 1px solid var(--border-color);
        box-shadow: var(--shadow-lg);
    }

    .sidebar-close-btn {
        width: 40px;
        height: 40px;
        border-radius: 999px;
        background: var(--bg-tertiary);
    }

    .nav-item {
        min-height: 46px;
        border-radius: 12px;
        font-weight: 650;
    }

    .main-content {
        min-height: calc(100vh - 64px);
    }

    .content {
        width: 100%;
        padding: 0.8rem 0.8rem 5.9rem;
    }

    .dash-header {
        flex-direction: column;
        gap: 0.6rem;
        padding: 1rem;
    }

    .dash-date {
        text-align: left;
    }

    .kpi-sections {
        display: grid;
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .kpi-group-cards {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 0.75rem;
    }

    .kpi-group:last-child .kpi-group-cards {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .kpi-card {
        min-height: 124px;
        padding: 1rem;
    }

    .kpi-label {
        font-size: 0.78rem;
    }

    .quick-row,
    .msummary,
    .charts-grid {
        grid-template-columns: 1fr !important;
    }

    .quick-panel,
    .metric-panel {
        border-radius: var(--radius);
    }

    .qp-item {
        min-height: 48px;
    }

    .date-filters {
        overflow-x: auto;
        flex-wrap: nowrap;
        -webkit-overflow-scrolling: touch;
        padding-bottom: 0.15rem;
    }

    .df-btn {
        white-space: nowrap;
        min-height: 38px;
    }

    .table-responsive,
    .table-container,
    .table-wrap {
        border-radius: var(--radius);
    }

    .mobile-tabbar {
        position: fixed;
        left: 0.75rem;
        right: 0.75rem;
        bottom: 0.75rem;
        z-index: 240;
        display: grid;
        grid-template-columns: repeat(4, 1fr);
        gap: 0.25rem;
        min-height: 64px;
        padding: 0.45rem;
        border: 1px solid color-mix(in srgb, var(--border-color) 84%, transparent);
        border-radius: 20px;
        background: color-mix(in srgb, var(--bg-secondary) 92%, transparent);
        box-shadow: 0 18px 44px rgba(16, 32, 39, 0.18);
        backdrop-filter: blur(18px);
    }

    .mobile-tab {
        display: flex;
        min-width: 0;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 0.2rem;
        border-radius: 15px;
        color: var(--text-secondary);
        text-decoration: none;
        font-size: 0.68rem;
        font-weight: 700;
    }

    .mobile-tab svg {
        width: 21px;
        height: 21px;
        fill: currentColor;
    }

    .mobile-tab.active {
        background: rgba(var(--primary-rgb), 0.13);
        color: var(--primary-color);
    }

    .mobile-tab span {
        max-width: 100%;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
}

@media (max-width: 420px) {
    .kpi-group-cards,
    .kpi-group:last-child .kpi-group-cards {
        grid-template-columns: 1fr;
    }

    .mobile-tabbar {
        left: 0.5rem;
        right: 0.5rem;
        bottom: 0.5rem;
    }
}
