:root {
    --primary: #4f46e5;
    --primary-hover: #4338ca;
    --bg-color: #f8fafc;
    --text-dark: #1e293b;
    --text-muted: #64748b;
    --danger: #ef4444;
    --success: #22c55e;
    --warning: #f59e0b;
    --info: #3b82f6;
    --border-color: #e2e8f0;
    --radius-md: 12px;
}

* {
    box-sizing: border-box;
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
}

body {
    background-color: var(--bg-color);
    color: var(--text-dark);
    margin: 0;
}

button {
    cursor: pointer;
    border: none;
    transition: all 0.2s ease;
    font-weight: 600;
}

.btn-primary {
    background: var(--primary);
    color: white;
    padding: 10px 15px;
    border-radius: 8px;
}

.btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
}

.btn-secondary {
    background: #e2e8f0;
    color: var(--text-dark);
    padding: 10px 15px;
    border-radius: 8px;
}

.btn-secondary:hover {
    background: #cbd5e1;
}

.btn-danger {
    background: var(--danger);
    color: white;
    padding: 8px 12px;
    border-radius: 6px;
}

.btn-primary-icon {
    background: var(--primary);
    color: white;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
}

.w-100 { width: 100%; }

.input-label {
    display: block;
    font-size: 11px;
    font-weight: 700;
    color: var(--text-muted);
    margin-bottom: 6px;
    letter-spacing: 0.5px;
}

.modal-input {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: white;
    margin-bottom: 15px;
    font-size: 14px;
    outline: none;
    transition: 0.2s;
}

.modal-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.top-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    background: white;
    padding: 15px 25px;
    border-radius: var(--radius-md);
    box-shadow: 0 2px 10px rgba(0,0,0,0.02);
}

.brand-logo {
    font-size: 20px;
    font-weight: 800;
    color: var(--primary);
    letter-spacing: 1px;
}

.profile-area {
    display: flex;
    align-items: center;
    gap: 15px;
}

.profile-name {
    font-size: 14px;
    font-weight: 600;
}

.profile-avatar {
    width: 35px;
    height: 35px;
    background: var(--primary);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 13px;
}

.stats-grid {
    display: grid;
}

.card {
    background: white;
    padding: 20px;
    border-radius: var(--radius-md);
    box-shadow: 0 2px 8px rgba(0,0,0,0.03);
    border: 1px solid var(--border-color);
}

.card-title {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 5px;
}

.card-value {
    font-size: 22px;
    font-weight: 800;
    color: var(--text-dark);
}

.control-hub {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    background: white;
    padding: 15px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
}

.search-box {
    display: flex;
    align-items: center;
    background: var(--bg-color);
    padding: 8px 15px;
    border-radius: 20px;
    width: 250px;
}

.search-box input {
    border: none;
    background: none;
    outline: none;
    margin-left: 10px;
    width: 100%;
}

.filter-buttons {
    display: flex;
    gap: 10px;
}

.filter-btn {
    background: none;
    border: 1px solid var(--border-color);
    padding: 6px 15px;
    border-radius: 20px;
    font-size: 13px;
    color: var(--text-muted);
}

.filter-btn.active, .filter-btn:hover {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.centered-action {
    display: flex;
    justify-content: center;
    margin-bottom: 25px;
}

.board-container {
    display: flex;
    gap: 20px;
    min-height: 500px;
}

.column {
    flex: 1;
    background: #f1f5f9;
    border-radius: var(--radius-md);
    padding: 15px;
    display: flex;
    flex-direction: column;
}

.column h4 {
    margin-top: 0;
    margin-bottom: 15px;
    font-size: 14px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.task-list {
    flex: 1;
    min-height: 150px;
}

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

.asya-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.asya-table th {
    text-align: left;
    padding: 12px;
    border-bottom: 2px solid var(--border-color);
    color: var(--text-muted);
    font-weight: 600;
}

.asya-table td {
    padding: 12px;
    border-bottom: 1px solid var(--border-color);
}

.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(4px);
    justify-content: center;
    align-items: center;
}

.modal-content {
    background-color: #fff;
    padding: 25px;
    border-radius: 16px;
    width: 500px;
    max-width: 90%;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
    animation: modalFadeIn 0.3s ease;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 15px;
}

.modal-header h3 {
    margin: 0;
}

.close-icon {
    font-size: 24px;
    color: var(--text-muted);
    cursor: pointer;
    transition: 0.2s;
}

.close-icon:hover {
    color: var(--danger);
}

@keyframes modalFadeIn {
    from { opacity: 0; transform: translateY(-20px); }
    to { opacity: 1; transform: translateY(0); }
}

.chat-container {
    display: flex;
    flex-direction: column;
    height: 75vh;
    background: white;
    border-radius: var(--radius-md);
    box-shadow: 0 2px 10px rgba(0,0,0,0.02);
    border: 1px solid var(--border-color);
    overflow: hidden;
}

.chat-quick-actions {
    display: flex;
    gap: 10px;
    padding: 15px;
    background: #f8fafc;
    border-bottom: 1px solid var(--border-color);
    overflow-x: auto;
}

.chat-action-btn {
    background: white;
    border: 1px solid var(--border-color);
    padding: 8px 12px;
    border-radius: 20px;
    font-size: 12px;
    white-space: nowrap;
    color: var(--text-dark);
}

.chat-action-btn:hover {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.chat-messages {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.chat-input-area {
    display: flex;
    gap: 10px;
    padding: 15px;
    background: white;
    border-top: 1px solid var(--border-color);
}

.chat-input-area input {
    flex: 1;
    padding: 12px 20px;
    border: 1px solid var(--border-color);
    border-radius: 30px;
    outline: none;
    font-size: 14px;
    background: #f8fafc;
}

.mini-board-container {
    display: flex;
    gap: 15px;
}
.mini-column {
    flex: 1;
    background: #f8fafc;
    border-radius: 8px;
    padding: 10px;
    min-height: 200px;
    border: 1px dashed var(--border-color);
}
.mini-task-list {
    min-height: 150px;
}

body {
    background-color: var(--bg-color);
    color: var(--text-dark);
    margin: 0;
    display: flex;
    height: 100vh;
    overflow: hidden;
}

.sidebar {
    width: 260px;
    background: white;
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    z-index: 10;
    box-shadow: 2px 0 10px rgba(0,0,0,0.02);
    overflow-y: auto;
}

.sidebar-item {
    transition: 0.2s;
}

.sidebar-item:hover {
    background: #f1f5f9 !important;
    color: var(--primary) !important;
}

.sidebar-item.active {
    background: #eef2ff !important;
    color: var(--primary) !important;
    font-weight: 700 !important;
}

.main-content {
    flex: 1; 
    overflow-y: auto; 
    padding: 30px;
    background: var(--bg-color);
}

.page {
    max-width: 1200px;
    margin: 0 auto;
}
/* =====================================================================
   MOBİL UYUMLULUK (768px ve altı)
   Yan menü alttaki sekme çubuğuna dönüşür, kartlar alt alta dizilir.
   ===================================================================== */
@media (max-width: 768px) {

    /* --- Genel sayfa yapısı (ana uygulama) --- */
    body:has(> .sidebar) {
        display: block;
        height: auto;
        min-height: 100vh;
        overflow: auto;
    }

    html {
        overflow-x: hidden;
    }

    .main-content canvas {
        max-width: 100% !important;
    }

    .main-content {
        max-width: 100vw;
        overflow-x: hidden;
        padding: 12px 12px calc(80px + env(safe-area-inset-bottom));
    }

    /* --- Yan menü -> alt sekme çubuğu --- */
    .sidebar {
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        width: 100%;
        height: auto;
        flex-direction: row;
        padding: 0 0 env(safe-area-inset-bottom) 0 !important;
        border-right: none;
        border-top: 1px solid var(--border-color);
        box-shadow: 0 -4px 14px rgba(0, 0, 0, 0.06);
        overflow: visible;
        z-index: 900;
    }

    .sidebar > div:first-child {   /* üstteki ASYA yazısı */
        display: none;
    }

    .sidebar nav {
        flex: 5 !important;
        flex-direction: row !important;
        padding: 0 !important;
        gap: 0 !important;
    }

    .sidebar > div:last-child {    /* çıkış butonu kutusu */
        flex: 1;
        display: flex;
        padding: 0 !important;
        margin: 0 !important;
    }

    .sidebar-item {
        flex: 1;
        flex-direction: column !important;
        justify-content: center !important;
        gap: 4px !important;
        padding: 8px 2px !important;
        border-radius: 0 !important;
        font-size: 10px;
        line-height: 1.15;
        text-align: center;
        min-height: 58px;
    }

    .sidebar-item i {
        font-size: 18px;
    }

    .sidebar-item.active {
        font-weight: 700 !important;
        box-shadow: inset 0 3px 0 var(--primary);
    }

    /* --- Üst başlık --- */
    .top-header {
        padding: 12px 15px;
        margin-bottom: 15px;
    }

    .profile-name {
        max-width: 150px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    /* --- Sayfa başlıkları ve satırlar --- */
    .page h2 {
        font-size: 20px !important;
    }

    .page > header {
        flex-wrap: wrap;
        gap: 12px;
        margin-bottom: 18px !important;
    }

    /* Yan yana kart satırlarını alt alta al */
    .page div[style*="gap: 20px"] {
        flex-direction: column !important;
        gap: 15px !important;
    }

    .page div[style*="gap: 20px"] > * {
        flex: 1 1 auto !important;
        width: 100%;
    }

    .page [style*="min-width"] {
        min-width: 0 !important;
    }

    /* Sabit yükseklikli kartlar (sağlık modülü) */
    .page .card[style*="height: 650px"] {
        height: auto !important;
        max-height: none;
    }

    .page .card[style*="height: 650px"][style*="flex-direction: column"] {
        height: 70vh !important;
        min-height: 420px;
    }

    /* --- Özet kartları --- */
    .stats-grid {
        grid-template-columns: 1fr 1fr !important;
        gap: 10px !important;
    }

    #investments .stats-grid {
        grid-template-columns: 1fr !important;
        margin-bottom: 18px !important;
    }

    .card {
        padding: 15px;
    }

    .card-value {
        font-size: 19px;
    }

    /* --- Görev panosu --- */
    .control-hub {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
    }

    .search-box {
        width: 100%;
    }

    .filter-buttons {
        overflow-x: auto;
        padding-bottom: 2px;
    }

    .filter-btn {
        white-space: nowrap;
    }

    .centered-action {
        margin-bottom: 15px;
    }

    .board-container,
    .mini-board-container {
        flex-direction: column;
        min-height: 0;
        gap: 15px;
    }

    .task-list {
        min-height: 80px;
    }

    /* --- Yatırım tablosu: sıkıştırmak yerine yana kaydır --- */
    .table-responsive {
        -webkit-overflow-scrolling: touch;
    }

    .asya-table {
        min-width: 620px;
        font-size: 13px;
    }

    /* --- Sohbet --- */
    .chat-container {
        height: calc(100vh - 190px);
        height: calc(100dvh - 190px);
        min-height: 380px;
    }

    .chat-messages {
        padding: 12px;
    }

    .chat-input-area {
        padding: 10px;
    }

    /* iOS'ta yazarken sayfanın yakınlaşmasını engelle (16px altı yazılar zoom yapar) */
    input,
    select,
    textarea,
    .modal-input,
    .chat-input-area input {
        font-size: 16px !important;
    }

    /* --- Açılır pencereler --- */
    .modal-content {
        width: 94% !important;
        max-width: 94% !important;
        max-height: 88vh;
        overflow-y: auto;
        padding: 18px !important;
    }

    .modal-content div[style*="display: flex"] {
        flex-wrap: wrap;
    }

    .modal-content div[style*="display: flex"] > div[style*="flex: 1"] {
        min-width: 140px;
    }

    #newMiniTaskTitle {
        flex: 1 1 100% !important;
    }

    #newMiniTaskPriority {
        flex: 1 1 auto;
    }

    /* --- Giriş sayfası --- */
    body .auth-box {
        width: 100%;
        max-width: 380px;
        margin: 0 16px;
        padding: 28px 22px;
    }
}

/* Çok küçük ekranlar (iPhone SE vb.) */
@media (max-width: 380px) {
    .stats-grid {
        grid-template-columns: 1fr !important;
    }

    .sidebar-item {
        font-size: 9px;
    }
}
