@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=Outfit:wght@500;600;700;800&display=swap');

/* =============================================================
   KaguTech CRM - arayüz stilleri
   ============================================================= */

:root {
    --primary: #4f46e5;
    --primary-hover: #4338ca;
    --primary-soft: rgba(79, 70, 229, .10);
    --accent: #8b5cf6;

    --bg: #f6f7fb;
    --surface: #ffffff;
    --surface-2: #f8fafc;
    --border: #e5e7eb;
    --border-strong: #d1d5db;

    --text: #111827;
    --text-muted: #6b7280;
    --text-soft: #9ca3af;

    --green: #10b981;
    --green-soft: rgba(16, 185, 129, .12);
    --amber: #f59e0b;
    --amber-soft: rgba(245, 158, 11, .14);
    --red: #ef4444;
    --red-soft: rgba(239, 68, 68, .12);
    --blue: #3b82f6;
    --blue-soft: rgba(59, 130, 246, .12);
    --slate-soft: rgba(100, 116, 139, .12);

    --radius: 12px;
    --radius-sm: 8px;
    --shadow-xs: 0 1px 2px rgba(16, 24, 40, .05);
    --shadow-sm: 0 1px 3px rgba(16, 24, 40, .08), 0 1px 2px rgba(16, 24, 40, .04);
    --shadow-md: 0 6px 16px -4px rgba(16, 24, 40, .12);
    --shadow-lg: 0 20px 40px -12px rgba(16, 24, 40, .22);
    --sidebar-w: 256px;
    --transition: .2s ease;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { font-family: 'Outfit', sans-serif; color: var(--text); line-height: 1.25; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
svg { flex-shrink: 0; }
[data-lucide] { width: 18px; height: 18px; }

/* =============================================================
   GİRİŞ / KURULUM EKRANI
   ============================================================= */

.auth-body {
    min-height: 100vh;
    display: flex; align-items: center; justify-content: center;
    padding: 2rem 1rem;
    background: radial-gradient(circle at 50% 0%, #131a33 0%, #070a16 55%, #05070f 100%);
    position: relative; overflow-x: hidden;
}
.auth-glow {
    position: fixed; width: 700px; height: 700px; border-radius: 50%;
    background: radial-gradient(circle, rgba(99, 102, 241, .16) 0%, transparent 70%);
    top: 50%; left: 50%; transform: translate(-50%, -50%); pointer-events: none;
}
.auth-card {
    position: relative; z-index: 1;
    width: 100%; max-width: 420px;
    background: rgba(255, 255, 255, .04);
    border: 1px solid rgba(255, 255, 255, .10);
    backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px);
    border-radius: 20px; padding: 2.5rem 2rem;
    box-shadow: 0 30px 70px -20px rgba(0, 0, 0, .7);
}
.auth-card-wide { max-width: 620px; }
.auth-head { text-align: center; margin-bottom: 1.75rem; }
.auth-brand {
    display: inline-block; font-family: 'Outfit', sans-serif; font-weight: 800;
    font-size: 1.4rem; color: #fff; text-decoration: none; margin-bottom: 1.25rem;
}
.auth-brand span { color: #818cf8; }
.auth-brand:hover { text-decoration: none; }
.auth-head h1 { color: #fff; font-size: 1.5rem; margin-bottom: .35rem; }
.auth-head p { color: rgba(255, 255, 255, .55); font-size: .9rem; }

.auth-field { margin-bottom: 1.1rem; text-align: left; }
.auth-field label {
    display: block; font-size: .8rem; font-weight: 600;
    color: rgba(255, 255, 255, .7); margin-bottom: .45rem;
}
.auth-input {
    display: flex; align-items: center; gap: .6rem;
    background: rgba(255, 255, 255, .05);
    border: 1px solid rgba(255, 255, 255, .12);
    border-radius: 10px; padding: 0 .9rem; transition: var(--transition);
}
.auth-input:focus-within { border-color: #818cf8; background: rgba(99, 102, 241, .10); }
.auth-input [data-lucide] { color: rgba(255, 255, 255, .4); width: 17px; height: 17px; }
.auth-input input {
    flex: 1; background: none; border: none; outline: none;
    color: #fff; font-family: inherit; font-size: .95rem; padding: .8rem 0; min-width: 0;
}
.auth-input input::placeholder { color: rgba(255, 255, 255, .25); }
.auth-input input:-webkit-autofill {
    -webkit-text-fill-color: #fff;
    -webkit-box-shadow: 0 0 0 1000px #1a2140 inset;
}
.auth-eye { background: none; border: none; cursor: pointer; color: rgba(255,255,255,.4); display: flex; padding: 0; }
.auth-eye:hover { color: #818cf8; }

/* "Beni hatırla" — kutucuk tarayıcı varsayılanı yerine kartın diliyle çizilir:
   giriş alanlarıyla aynı cam yüzey, işaretliyken butonun mor degradesi. */
.auth-check {
    display: inline-flex; align-items: center; gap: .6rem;
    margin: -.15rem 0 .35rem; padding: .35rem .1rem;
    cursor: pointer; user-select: none;
    font-size: .875rem; font-weight: 500; letter-spacing: .01em;
    color: rgba(255, 255, 255, .62);
    transition: color var(--transition);
}
.auth-check:hover { color: rgba(255, 255, 255, .95); }

.auth-check input {
    appearance: none; -webkit-appearance: none;
    width: 19px; height: 19px; margin: 0; flex-shrink: 0;
    border: 1px solid rgba(255, 255, 255, .18);
    border-radius: 6px;
    background: rgba(255, 255, 255, .05);
    cursor: pointer;
    transition: var(--transition);
}
.auth-check:hover input { border-color: rgba(129, 140, 248, .55); background: rgba(99, 102, 241, .12); }
.auth-check input:focus-visible { outline: 2px solid #818cf8; outline-offset: 2px; }

.auth-check input:checked {
    border-color: transparent;
    /* Tik SVG'si degradenin üstüne biner; harici dosya gerekmez. */
    background-image:
        url("data:image/svg+xml;charset=UTF-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%23fff' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3.5 8.4l3.1 3.1L12.5 5'/%3E%3C/svg%3E"),
        linear-gradient(135deg, #6366f1, #8b5cf6);
    background-size: 13px 13px, 100% 100%;
    background-position: center, center;
    background-repeat: no-repeat;
    box-shadow: 0 4px 12px -5px rgba(99, 102, 241, .9);
}
.auth-check:hover input:checked { border-color: transparent; }

.auth-submit {
    display: flex; align-items: center; justify-content: center; gap: .5rem;
    width: 100%; margin-top: .6rem; padding: .9rem 1rem;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: #fff; border: none; border-radius: 10px;
    font-family: inherit; font-size: .95rem; font-weight: 600; cursor: pointer;
    transition: var(--transition); text-decoration: none;
}
.auth-submit:hover { transform: translateY(-1px); box-shadow: 0 10px 24px -8px rgba(99, 102, 241, .7); text-decoration: none; }

.auth-alert {
    display: flex; align-items: flex-start; gap: .6rem;
    background: rgba(239, 68, 68, .12); border: 1px solid rgba(239, 68, 68, .3);
    color: #fca5a5; border-radius: 10px; padding: .8rem 1rem;
    font-size: .88rem; margin-bottom: 1.25rem; text-align: left;
}
.auth-alert-ok { background: rgba(16, 185, 129, .12); border-color: rgba(16, 185, 129, .3); color: #6ee7b7; }
.auth-alert [data-lucide] { width: 17px; height: 17px; margin-top: 2px; }

.auth-foot {
    margin-top: 1.75rem; padding-top: 1.25rem;
    border-top: 1px solid rgba(255, 255, 255, .08);
    text-align: center; font-size: .8rem; color: rgba(255, 255, 255, .45);
}
.auth-foot p { margin-bottom: .5rem; }
.auth-foot a { color: #818cf8; }

.install-legend {
    display: flex; align-items: center; gap: .5rem;
    color: #fff; font-size: 1rem; margin: 1.75rem 0 1rem;
    padding-bottom: .6rem; border-bottom: 1px solid rgba(255, 255, 255, .08);
}
.install-legend:first-of-type { margin-top: 0; }
.install-legend [data-lucide] { color: #818cf8; }
.install-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.install-next { color: rgba(255,255,255,.7); font-size: .88rem; text-align: left; margin-bottom: 1.25rem; }
.install-next ol { margin: .5rem 0 0 1.1rem; }
.install-next li { margin-bottom: .35rem; }
.install-next code { background: rgba(255,255,255,.08); padding: .1rem .4rem; border-radius: 4px; color: #c7d2fe; }

/* =============================================================
   UYGULAMA KABUĞU
   ============================================================= */

.app { display: flex; min-height: 100vh; }

.sidebar {
    width: var(--sidebar-w); flex-shrink: 0;
    background: var(--surface); border-right: 1px solid var(--border);
    display: flex; flex-direction: column;
    position: fixed; inset: 0 auto 0 0; z-index: 60;
    transition: transform var(--transition);
}
.sidebar-head {
    height: 62px; display: flex; align-items: center; justify-content: space-between;
    padding: 0 1.25rem; border-bottom: 1px solid var(--border); flex-shrink: 0;
}
.brand { font-family: 'Outfit', sans-serif; font-weight: 800; font-size: 1.15rem; color: var(--text); }
.brand span { color: var(--primary); }
.brand:hover { text-decoration: none; }
.sidebar-close { display: none; background: none; border: none; cursor: pointer; color: var(--text-muted); }

.tenant-chip {
    display: flex; align-items: center; gap: .65rem;
    margin: .9rem .9rem .25rem; padding: .7rem .8rem;
    background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm);
}
.tenant-avatar {
    width: 34px; height: 34px; border-radius: 9px; flex-shrink: 0;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    color: #fff; font-weight: 700; font-size: .75rem;
    display: flex; align-items: center; justify-content: center;
}
.tenant-meta { min-width: 0; display: flex; flex-direction: column; }
.tenant-meta strong { font-size: .85rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tenant-meta small { font-size: .72rem; color: var(--text-soft); }

.sidebar-nav { flex: 1; overflow-y: auto; padding: .9rem .75rem; }
.nav-group { margin-bottom: 1.1rem; }
.nav-group-title {
    display: block; font-size: .68rem; font-weight: 700; letter-spacing: .07em;
    text-transform: uppercase; color: var(--text-soft); padding: 0 .75rem; margin-bottom: .45rem;
}
.nav-item {
    display: flex; align-items: center; gap: .7rem;
    padding: .6rem .75rem; border-radius: var(--radius-sm);
    color: var(--text-muted); font-weight: 500; font-size: .88rem;
    transition: var(--transition); margin-bottom: .15rem;
}
.nav-item:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav-item.active { background: var(--primary-soft); color: var(--primary); font-weight: 600; }
.nav-item.danger { color: var(--red); }
.nav-item.danger:hover { background: var(--red-soft); color: var(--red); }
.sidebar-foot { padding: .75rem; border-top: 1px solid var(--border); flex-shrink: 0; }

.sidebar-backdrop {
    display: none; position: fixed; inset: 0; z-index: 55;
    background: rgba(15, 23, 42, .5);
}
.sidebar-backdrop.show { display: block; }

.main {
    flex: 1; margin-left: var(--sidebar-w); display: flex; flex-direction: column;
    min-width: 0; transition: margin-left var(--transition);
}

/* Masaüstünde kenar menüyü daraltma (hamburger ile açılıp kapanır) */
@media (min-width: 901px) {
    .app.sidebar-collapsed .sidebar { transform: translateX(-100%); }
    .app.sidebar-collapsed .main { margin-left: 0; }
}

.topbar {
    height: 62px; flex-shrink: 0;
    background: var(--surface); border-bottom: 1px solid var(--border);
    display: flex; align-items: center; gap: 1rem; padding: 0 1.5rem;
    position: sticky; top: 0; z-index: 40;
}
.topbar-title { font-size: 1.05rem; font-weight: 600; flex: 1; }
/* Üst çubukta sekme varsa başlık esnemez; boşluğu sekmeler alır. */
.topbar-title.dar { flex: 0 0 auto; white-space: nowrap; }

/* ÜST ÇUBUK SEKMELERİ — ayrı bir satır açmamak için (53 px kazanç).
   İçerikteki .tabs ile aynı işi görür, yalnızca çubuğa gömülüdür. */
.topbar-tabs { display: flex; align-items: center; gap: .15rem; flex: 1; min-width: 0; overflow-x: auto; }
.tb-tab {
    padding: .4rem .75rem; border-radius: var(--radius-sm);
    color: var(--text-muted); text-decoration: none;
    font-size: .85rem; font-weight: 500; white-space: nowrap;
}
.tb-tab:hover { background: var(--surface-2); color: var(--text); }
.tb-tab.active { background: var(--primary-soft); color: var(--primary); font-weight: 600; }

/* Dar ekranda üst çubuk sıkışıyor ve sekmelere hiç yer kalmıyordu (genişlik
   0'a düşüp görünmez oluyorlardı). Önce başlık, sonra geri düğmesinin metni
   düşer; sekmeler her zaman erişilebilir kalır. */
@media (max-width: 900px) {
    .topbar-title.dar { display: none; }
}
@media (max-width: 640px) {
    .geri-tus span { display: none; }
    .topbar { padding: 0 .75rem; gap: .5rem; }
}
.topbar-right { display: flex; align-items: center; gap: .9rem; }
/* Hamburger her ekranda görünür: masaüstünde menüyü daraltır, mobilde açar. */
.icon-btn {
    background: none; border: none; cursor: pointer; color: var(--text-muted);
    display: flex; align-items: center; padding: .35rem; border-radius: 6px;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }

/* Profil menüsü — Hesabım / Çıkış Yap buradan açılır (eskiden kenar
   menünün altındaydı; kenar menü artık yalnızca CRM ekranlarına ait). */
.user-menu { position: relative; }
.user-chip {
    display: flex; align-items: center; gap: .6rem;
    background: none; border: 1px solid transparent; border-radius: var(--radius-sm);
    padding: .25rem .4rem; font: inherit; color: inherit; cursor: pointer;
}
.user-chip:hover { background: var(--surface-2); }
.user-menu.open .user-chip { background: var(--surface-2); border-color: var(--border); }
.user-caret { width: 15px; height: 15px; color: var(--text-soft); flex-shrink: 0; }
.user-menu.open .user-caret { transform: rotate(180deg); }

.user-drop {
    position: absolute; top: calc(100% + .4rem); right: 0; z-index: 70;
    min-width: 190px; padding: .35rem;
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius-sm); box-shadow: var(--shadow);
}
.user-drop-item {
    display: flex; align-items: center; gap: .55rem;
    padding: .5rem .6rem; border-radius: 6px;
    color: var(--text); text-decoration: none; font-size: .85rem;
}
.user-drop-item i { width: 16px; height: 16px; color: var(--text-soft); }
.user-drop-item:hover { background: var(--surface-2); }
.user-drop-item.danger { color: var(--red); }
.user-drop-item.danger i { color: var(--red); }

/* KANAL MARKA LOGOLARI (bkz. includes/inbox_logos.php)
   Sprite gövdenin başında bir kez basılır, kullanım yerlerinde <use> ile
   çağrılır. Logolar kendi renklerini taşıdığı için currentColor almazlar. */
.kanal-sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.kanal-logo { width: 16px; height: 16px; flex-shrink: 0; display: inline-block; vertical-align: -3px; }
.kanal-logo.buyuk { width: 26px; height: 26px; }

/* TAM EKRAN KİPİ — kenar menü yok, içerik tüm genişliği kullanır.
   Akıllı Mesaj Merkezi bunu kullanır: dört bölmeli arayüz yanında menü
   varken sıkışıyordu. */
.app-solo .main { margin-left: 0; }
.app-solo .content { padding: .75rem 1.25rem; }
/* Firma şeridi (yalnız süper admin görür) tam ekranda inceltilir. */
.app-solo .impersonate-bar { padding: .3rem 1.25rem; font-size: .78rem; }
.avatar {
    width: 34px; height: 34px; border-radius: 50%; flex-shrink: 0;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    color: #fff; font-weight: 700; font-size: .75rem;
    display: flex; align-items: center; justify-content: center;
}
.user-meta { display: flex; flex-direction: column; line-height: 1.2; }
.user-meta strong { font-size: .84rem; }
.user-meta small { font-size: .72rem; color: var(--text-soft); }

.impersonate-bar {
    display: flex; align-items: center; gap: .6rem; flex-wrap: wrap;
    background: #fef3c7; border-bottom: 1px solid #fde68a; color: #92400e;
    padding: .65rem 1.5rem; font-size: .84rem;
}
.impersonate-bar a { color: #92400e; font-weight: 700; text-decoration: underline; }

.content { flex: 1; padding: 1.5rem; max-width: 1500px; width: 100%; }
.app-foot { padding: 1rem 1.5rem; color: var(--text-soft); font-size: .78rem; text-align: center; }

/* MOBİL KABUK — bu blok, ezdiği kuralların (.impersonate-bar, .content)
   TANIMLARINDAN SONRA gelmek zorunda. Aynı özgüllükte (0,1,0) iki kural
   çakıştığında sonra yazılan kazanır; ilk denemede blok yukarıdaki 640 px
   medya sorgusunun içine konmuştu ve temel tanımlar onu sessizce eziyordu
   (ölçüldü: flex-wrap hâlâ "wrap" kalıyor, şerit 86 px'te takılıyordu). */
@media (max-width: 640px) {
    /* Firmaya giriş şeridi mobilde ÜÇ SATIRA sarıp 125 px yiyordu — 375 px'lik
       ekranda mesaj merkezinin altıda biri. Tek satır: açıklama kırpılır,
       "Çıkış" bağlantısı her zaman görünür kalır. */
    .impersonate-bar { flex-wrap: nowrap; padding: .35rem .75rem; font-size: .74rem; gap: .4rem; }
    .impersonate-bar span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
    .impersonate-bar i,
    .impersonate-bar a { flex: 0 0 auto; }
    /* Sayfa dolgusu mobilde 1.5rem çok: sağdan soldan 48 px götürüyordu. */
    .content { padding: .75rem; }
}

/* =============================================================
   BİLEŞENLER
   ============================================================= */

.alert {
    display: flex; align-items: center; gap: .6rem;
    padding: .8rem 1rem; border-radius: var(--radius-sm);
    font-size: .88rem; margin-bottom: 1.25rem; border: 1px solid;
}
/* İnce uyarı şeridi — sürekli ekranda duran kurulum uyarıları için.
   Tam boy kutu 69 px yiyordu; şerit 30 px'te kalır. */
.alert.serit { padding: .35rem .75rem; margin-bottom: .5rem; font-size: .8rem; }
.alert.serit a { color: inherit; font-weight: 700; }

.alert-close { margin-left: auto; background: none; border: none; font-size: 1.2rem; cursor: pointer; color: inherit; opacity: .6; line-height: 1; }
.alert-close:hover { opacity: 1; }
.alert-success { background: #ecfdf5; border-color: #a7f3d0; color: #065f46; }
.alert-danger  { background: #fef2f2; border-color: #fecaca; color: #991b1b; }
.alert-info    { background: #eff6ff; border-color: #bfdbfe; color: #1e40af; }
.alert-warning { background: #fffbeb; border-color: #fde68a; color: #92400e; }

.page-head {
    display: flex; align-items: flex-start; justify-content: space-between;
    gap: 1rem; flex-wrap: wrap; margin-bottom: 1.25rem;
}
.page-head h2 { font-size: 1.35rem; }
.page-head p { color: var(--text-muted); font-size: .875rem; margin-top: .2rem; }
.page-actions { display: flex; gap: .5rem; flex-wrap: wrap; }

.card {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); box-shadow: var(--shadow-xs);
}
.card + .card { margin-top: 1.25rem; }
.card-head {
    display: flex; align-items: center; justify-content: space-between; gap: 1rem;
    padding: 1rem 1.25rem; border-bottom: 1px solid var(--border);
}
.card-head h3 { font-size: .98rem; font-weight: 600; display: flex; align-items: center; gap: .5rem; }
.card-head h3 [data-lucide] { color: var(--text-soft); }
.card-body { padding: 1.25rem; }
.card-body.tight { padding: 0; }

/* İstatistik kartları */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 1rem; margin-bottom: 1.25rem; }
.stat {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 1.1rem 1.25rem; display: flex; align-items: center; gap: 1rem; box-shadow: var(--shadow-xs);
    transition: var(--transition);
}
.stat:hover { box-shadow: var(--shadow-sm); transform: translateY(-1px); }
a.stat:hover { text-decoration: none; }
.stat-ico {
    width: 42px; height: 42px; border-radius: 11px; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    background: var(--primary-soft); color: var(--primary);
}
.stat-ico.green { background: var(--green-soft); color: var(--green); }
.stat-ico.amber { background: var(--amber-soft); color: var(--amber); }
.stat-ico.red   { background: var(--red-soft); color: var(--red); }
.stat-ico.blue  { background: var(--blue-soft); color: var(--blue); }
.stat-ico.slate { background: var(--slate-soft); color: #475569; }
.stat-info { min-width: 0; }
.stat-info span { display: block; font-size: .78rem; color: var(--text-muted); font-weight: 500; }
.stat-info strong { font-family: 'Outfit', sans-serif; font-size: 1.5rem; font-weight: 700; }

/* Butonlar */
.btn {
    display: inline-flex; align-items: center; gap: .45rem;
    padding: .55rem 1rem; border-radius: var(--radius-sm);
    font-family: inherit; font-size: .86rem; font-weight: 600;
    border: 1px solid transparent; cursor: pointer;
    transition: var(--transition); white-space: nowrap;
}
.btn:hover { text-decoration: none; }
.btn [data-lucide] { width: 16px; height: 16px; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); color: #fff; }
.btn-light { background: var(--surface); color: var(--text); border-color: var(--border-strong); }
.btn-light:hover { background: var(--surface-2); color: var(--text); }
.btn-ghost { background: transparent; color: var(--text-muted); border-color: var(--border); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn-danger { background: var(--red); color: #fff; }
.btn-danger:hover { background: #dc2626; color: #fff; }
.btn-success { background: var(--green); color: #fff; }
.btn-success:hover { background: #059669; color: #fff; }
.btn-sm { padding: .35rem .7rem; font-size: .8rem; }
.btn-icon { padding: .4rem; }
.btn:disabled, .btn.disabled { opacity: .5; cursor: not-allowed; }

/* Formlar */
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 1rem 1.15rem; }
.form-grid .span-2 { grid-column: span 2; }
.field { display: flex; flex-direction: column; }
.field label { font-size: .8rem; font-weight: 600; color: var(--text-muted); margin-bottom: .35rem; }
.field .hint { font-size: .74rem; color: var(--text-soft); margin-top: .3rem; }
.input, .select, .textarea {
    width: 100%; padding: .55rem .75rem;
    border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
    font-family: inherit; font-size: .88rem; color: var(--text);
    background: var(--surface); transition: var(--transition);
}
.input:focus, .select:focus, .textarea:focus {
    outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft);
}
.textarea { resize: vertical; min-height: 90px; }
.select { appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right .6rem center; padding-right: 2rem;
}
.form-actions {
    display: flex; gap: .6rem; justify-content: flex-end; flex-wrap: wrap;
    margin-top: 1.5rem; padding-top: 1.25rem; border-top: 1px solid var(--border);
}
.required::after { content: ' *'; color: var(--red); }

/* Filtre çubuğu */
.filters { display: flex; gap: .6rem; flex-wrap: wrap; align-items: flex-end; margin-bottom: 1.1rem; }
.filters .field { min-width: 150px; }
.filters .search { flex: 1; min-width: 210px; }
/* Tarih ve saat girişleri — iOS Safari uyumu.
   iOS bu alanlara kendi yerleşik görünümünü uygular; genişliği yok sayar ve
   asgari içerik genişliği masaüstündekinden çok daha büyüktür. Bu yüzden
   yerleşik görünüm kapatılıp boyutlar açıkça veriliyor. */
input[type="date"],
input[type="datetime-local"] {
    -webkit-appearance: none;
    appearance: none;
    min-width: 0;
    max-width: 100%;
    box-sizing: border-box;
}
.filters input[type="date"] { width: 100%; }

/* iOS değeri dikeyde ortalayıp taşırabiliyor; sola hizala */
input[type="date"]::-webkit-date-and-time-value,
input[type="datetime-local"]::-webkit-date-and-time-value {
    text-align: left;
    margin: 0;
}
/* iOS takvim ikonunu içeriden taşırmasın */
input[type="date"]::-webkit-calendar-picker-indicator {
    margin-left: 0;
    padding-left: 0;
}

/* Tablolar */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: .87rem; }
.table th {
    text-align: left; font-size: .72rem; font-weight: 700; letter-spacing: .04em;
    text-transform: uppercase; color: var(--text-soft);
    padding: .75rem 1rem; border-bottom: 1px solid var(--border); white-space: nowrap;
    background: var(--surface-2);
}
.table td { padding: .8rem 1rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: var(--surface-2); }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table .actions { text-align: right; white-space: nowrap; }
.table .actions .btn { margin-left: .25rem; }
.cell-main { font-weight: 600; color: var(--text); }
.cell-sub { font-size: .78rem; color: var(--text-soft); }

/* Tarih hücresi: dar ekranda yıl gizlenir (bkz. datetime_cell) */
.dt-short { display: none; }

/* Log tabloları: dar ekranda tarih/IP daralır, cihaz-tarayıcı sütunu genişler */
.table-compact .col-time { white-space: nowrap; }
.table-compact .col-device { min-width: 160px; }
.table-compact .col-agent { min-width: 190px; }

/* Rozetler */
.badge {
    display: inline-flex; align-items: center; gap: .3rem;
    padding: .18rem .55rem; border-radius: 999px;
    font-size: .74rem; font-weight: 600; white-space: nowrap;
}
.badge-green { background: var(--green-soft); color: #047857; }
.badge-amber { background: var(--amber-soft); color: #b45309; }
.badge-red   { background: var(--red-soft); color: #b91c1c; }
.badge-blue  { background: var(--blue-soft); color: #1d4ed8; }
.badge-slate { background: var(--slate-soft); color: #475569; }
.badge-primary { background: var(--primary-soft); color: var(--primary); }
.dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }

/* Boş durum */
.empty { text-align: center; padding: 3rem 1.5rem; color: var(--text-muted); }
.empty [data-lucide] { width: 40px; height: 40px; color: var(--border-strong); margin-bottom: .75rem; }
.empty h4 { font-size: 1rem; margin-bottom: .3rem; }
.empty p { font-size: .86rem; margin-bottom: 1rem; }

/* Sayfalama */
.pagination { display: flex; align-items: center; gap: .3rem; flex-wrap: wrap; padding: 1rem 1.25rem; border-top: 1px solid var(--border); }
.pagination-info { font-size: .8rem; color: var(--text-muted); margin-right: auto; }
.page-link {
    min-width: 32px; height: 32px; padding: 0 .5rem;
    display: inline-flex; align-items: center; justify-content: center;
    border: 1px solid var(--border); border-radius: 7px;
    font-size: .82rem; color: var(--text-muted); background: var(--surface);
}
.page-link:hover { background: var(--surface-2); text-decoration: none; }
.page-link.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.page-link.disabled { opacity: .4; pointer-events: none; }

/* Sekmeler */
.tabs { display: flex; gap: .25rem; border-bottom: 1px solid var(--border); margin-bottom: 1.25rem; overflow-x: auto; }
.tab {
    padding: .65rem 1rem; font-size: .87rem; font-weight: 600; color: var(--text-muted);
    border-bottom: 2px solid transparent; white-space: nowrap; cursor: pointer; background: none; border-top: 0; border-left: 0; border-right: 0; font-family: inherit;
}
.tab:hover { color: var(--text); text-decoration: none; }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }
.tab-pane { display: none; }
.tab-pane.active { display: block; animation: fade .25s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* İki kolonlu düzen */
.split { display: grid; grid-template-columns: 2fr 1fr; gap: 1.25rem; align-items: start; }
.split-even { display: grid; grid-template-columns: 1fr 1fr; gap: 1.25rem; align-items: start; }

/* Tanım listesi */
.deflist { display: grid; grid-template-columns: 130px 1fr; gap: .55rem 1rem; font-size: .87rem; }
.deflist dt { color: var(--text-muted); font-weight: 500; }
.deflist dd { color: var(--text); word-break: break-word; }

/* Zaman çizelgesi / mesaj akışı */
.thread { display: flex; flex-direction: column; gap: 1rem; }
.thread-item { display: flex; gap: .8rem; }
.thread-body {
    flex: 1; background: var(--surface-2); border: 1px solid var(--border);
    border-radius: var(--radius-sm); padding: .8rem 1rem; min-width: 0;
}
.thread-item.internal .thread-body { background: #fffbeb; border-color: #fde68a; }
.thread-head { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; margin-bottom: .35rem; }
.thread-head strong { font-size: .84rem; }
.thread-head time { font-size: .75rem; color: var(--text-soft); }
.thread-text { font-size: .87rem; white-space: pre-wrap; word-break: break-word; }

/* Modül tik kutuları (süper admin) */
.module-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(310px, 1fr)); gap: .85rem; }
.module-toggle {
    display: flex; gap: .8rem; align-items: flex-start;
    border: 1px solid var(--border); border-radius: var(--radius);
    padding: .9rem 1rem; cursor: pointer; transition: var(--transition); background: var(--surface);
}
.module-toggle:hover { border-color: var(--border-strong); background: var(--surface-2); }
.module-toggle.on { border-color: var(--primary); background: var(--primary-soft); }
.module-toggle.locked { opacity: .75; cursor: default; background: var(--surface-2); }
.module-toggle input { margin-top: .2rem; width: 17px; height: 17px; accent-color: var(--primary); cursor: pointer; flex-shrink: 0; }
.module-toggle .mt-body { min-width: 0; }
.module-toggle .mt-title { display: flex; align-items: center; gap: .45rem; font-weight: 600; font-size: .9rem; margin-bottom: .2rem; }
.module-toggle .mt-title [data-lucide] { width: 16px; height: 16px; color: var(--primary); }
.module-toggle .mt-desc { font-size: .78rem; color: var(--text-muted); }
.module-toggle .mt-hint { font-size: .74rem; color: var(--primary); margin-top: .35rem; display: flex; gap: .3rem; }
.module-toggle .mt-hint [data-lucide] { width: 13px; height: 13px; margin-top: 2px; }

/* Rolü yetmeyen modül: seçilebilir görünmesin, ama listeden de kaybolmasın —
   firma sahibi neden veremediğini görebilmeli. */
.module-toggle-off { opacity: .45; cursor: not-allowed; background: var(--surface-2); }
.module-toggle-off input { cursor: not-allowed; }

/* Kişiye özel yetki: "tümü / seçtiklerim" tercihi */
.scope-choice { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: .7rem; }
.scope-opt {
    display: flex; gap: .7rem; align-items: flex-start;
    border: 1px solid var(--border); border-radius: var(--radius);
    padding: .8rem .95rem; cursor: pointer; background: var(--surface);
    transition: var(--transition);
}
.scope-opt:hover { border-color: var(--border-strong); background: var(--surface-2); }
.scope-opt input { margin-top: .15rem; width: 17px; height: 17px; accent-color: var(--primary); cursor: pointer; flex-shrink: 0; }
.scope-opt strong { display: block; font-size: .9rem; }
.scope-opt small { display: block; font-size: .78rem; color: var(--text-muted); margin-top: .15rem; }
.scope-opt:has(input:checked) { border-color: var(--primary); background: var(--primary-soft); }

.owner-note {
    display: flex; gap: .6rem; align-items: flex-start;
    font-size: .85rem; color: var(--text-muted);
    background: var(--surface-2); border: 1px solid var(--border);
    border-radius: var(--radius); padding: .8rem .95rem;
}
.owner-note [data-lucide] { width: 16px; height: 16px; color: var(--primary); flex-shrink: 0; margin-top: 1px; }

.hidden { display: none !important; }

/* Bildirim zili (üst çubuk) */
.bell {
    position: relative; display: flex; align-items: center; justify-content: center;
    width: 38px; height: 38px; border-radius: 10px;
    color: var(--text-muted); border: 1px solid var(--border);
    background: var(--surface); transition: var(--transition);
}
.bell:hover { background: var(--surface-2); color: var(--primary); border-color: var(--border-strong); text-decoration: none; }
.bell-badge {
    position: absolute; top: -6px; right: -6px; min-width: 18px; height: 18px;
    padding: 0 4px; border-radius: 999px; background: var(--red); color: #fff;
    font-size: .68rem; font-weight: 700; line-height: 18px; text-align: center;
    border: 2px solid var(--surface);
}

/* Kenar menüdeki okunmamış sayacı */
.nav-count {
    margin-left: auto; min-width: 20px; padding: 0 5px; height: 18px;
    border-radius: 999px; background: var(--red); color: #fff;
    font-size: .68rem; font-weight: 700; line-height: 18px; text-align: center;
}

/* Bildirim listesi */
.notif-list { display: flex; flex-direction: column; }
.notif {
    display: flex; gap: .9rem; align-items: flex-start;
    padding: 1.1rem 1.25rem; border-bottom: 1px solid var(--border);
}
.notif:last-child { border-bottom: none; }
.notif.unread { background: rgba(79, 70, 229, .04); }
.notif-body { flex: 1; min-width: 0; }
.notif-head { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; margin-bottom: .25rem; }
.notif-head strong { font-size: .95rem; }
.notif-head time { font-size: .76rem; color: var(--text-soft); }
.notif-text { font-size: .87rem; color: var(--text-muted); }
.notif-actions { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; margin-top: .7rem; }
.notif-side { display: flex; gap: .2rem; flex-shrink: 0; }

/* Abonelik bilgilendirme bandı */
.sub-notice { align-items: flex-start; }
.sub-notice [data-lucide] { margin-top: 2px; }

/* Tehlikeli işlem düğmesi (satır içi silme) */
.danger-btn { color: var(--red); }
.danger-btn:hover { background: var(--red-soft); color: var(--red); }

/* Canlı gösterge (yanıp sönen nokta) */
.live-dot {
    display: inline-block; width: 7px; height: 7px; border-radius: 50%;
    background: var(--green); margin-left: .25rem; vertical-align: middle;
    animation: livePulse 2s infinite;
}
@keyframes livePulse {
    0%   { box-shadow: 0 0 0 0 rgba(16, 185, 129, .7); }
    70%  { box-shadow: 0 0 0 6px rgba(16, 185, 129, 0); }
    100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

/* Basit sütun grafiği (harici kütüphane yok) */
.bars {
    display: flex; align-items: flex-end; gap: .5rem;
    height: 190px; padding-top: 1.25rem;
}
.bar-col {
    flex: 1; display: flex; flex-direction: column; align-items: center;
    justify-content: flex-end; height: 100%; gap: .35rem; min-width: 0;
}
.bar {
    width: 100%; max-width: 46px; border-radius: 6px 6px 2px 2px;
    background: linear-gradient(180deg, var(--primary), var(--accent));
    transition: height .4s ease; min-height: 3px;
}
.bar-col:hover .bar { filter: brightness(1.12); }
.bar-value { font-size: .78rem; font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums; }
.bar-label { font-size: .74rem; color: var(--text-muted); font-weight: 500; }

/* Etiket girişi */
.chips { display: flex; flex-wrap: wrap; gap: .35rem; }
.chip { background: var(--surface-2); border: 1px solid var(--border); border-radius: 999px; padding: .12rem .55rem; font-size: .75rem; color: var(--text-muted); }

/* Yardımcılar */
.muted { color: var(--text-muted); }
.soft { color: var(--text-soft); }
.small { font-size: .8rem; }
.mt-0 { margin-top: 0; } .mt-1 { margin-top: .75rem; } .mt-2 { margin-top: 1.25rem; }
.mb-1 { margin-bottom: .75rem; } .mb-2 { margin-bottom: 1.25rem; }
.flex { display: flex; align-items: center; gap: .5rem; }
.flex-between { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.flex-wrap { flex-wrap: wrap; }
.text-right { text-align: right; }
.nowrap { white-space: nowrap; }
.overdue { color: var(--red); font-weight: 600; }
.inline-form { display: inline; }

/* =============================================================
   DUYARLI DÜZEN
   ============================================================= */

@media (max-width: 1100px) {
    .split, .split-even { grid-template-columns: 1fr; }
}

/* Dar ekranda filtre çubuğu: esnek sarma yerine düzenli ızgara.
   Sabit min-width'ler yüzünden tarih kutuları taşıp üst üste biniyordu. */
@media (max-width: 700px) {
    .filters {
        display: grid;
        /* KRİTİK: "1fr" aslında minmax(auto, 1fr)'dir; sütun min-content'in
           altına inemez. iOS Safari'de tarih girişinin min-content genişliği
           çok büyük olduğu için sütunlar ekranı taşırıyordu. minmax(0, 1fr)
           sütunun sıfıra kadar daralmasına izin verir.
           Masaüstü tarayıcıların mobil öykünmesi kendi tarih widget'ını
           kullandığı için bu sorun orada görünmez. */
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: .6rem;
        align-items: end;
    }
    .filters .field {
        min-width: 0;      /* daralabilsin */
        width: auto;
        max-width: 100%;
    }
    .filters .search,
    .filters .btn {
        grid-column: 1 / -1;
        min-width: 0;
    }
    .filters .btn { justify-content: center; }
    .filters .input,
    .filters .select { width: 100%; max-width: 100%; }
}

/* Telefonlarda filtreler tek sütun.
   Gerekçe: iOS Safari'de <input type="date"> kendi yerleşik görünümünü kullanır
   ve asgari genişliği CSS ile güvenilir biçimde küçültülemez. Yan yana iki
   tarih kutusu bu yüzden taşabiliyor. Tek sütunda bu yapısal olarak imkânsız
   hale gelir — cihaz ya da tarayıcı ne olursa olsun.
   560px sınırı tüm telefonları dikey modda kapsar (iPhone 12/14/15/16 Pro Max
   dahil: 428-440px). */
@media (max-width: 560px) {
    .filters { grid-template-columns: minmax(0, 1fr); }
    .filters .field,
    .filters .search,
    .filters .btn { grid-column: 1 / -1; }
}

@media (max-width: 900px) {
    .sidebar { transform: translateX(-100%); box-shadow: var(--shadow-lg); }
    .sidebar.open { transform: none; }
    .sidebar-close { display: flex; }
    .main { margin-left: 0; }
    .content { padding: 1rem; }
    .topbar { padding: 0 1rem; }
    .user-meta { display: none; }
    .install-grid { grid-template-columns: 1fr; }
    .form-grid .span-2 { grid-column: span 1; }
}

@media (max-width: 560px) {
    .auth-card { padding: 2rem 1.25rem; }
    .stats { grid-template-columns: 1fr 1fr; gap: .7rem; }
    .stat { padding: .85rem; gap: .7rem; flex-direction: column; align-items: flex-start; }
    .stat-info strong { font-size: 1.25rem; }
    .page-head { flex-direction: column; align-items: stretch; }
    .page-actions .btn { flex: 1; justify-content: center; }
    .deflist { grid-template-columns: 1fr; gap: .15rem 0; }
    .deflist dd { margin-bottom: .6rem; }
    .table th, .table td { padding: .65rem .6rem; }

    /* Tarihte yılı gizle */
    .dt-full { display: none; }
    .dt-short { display: inline; }

    /* Log tabloları: tarih ve IP sıkışsın, satır ekrana sığsın */
    .table-compact th, .table-compact td { padding: .55rem .4rem; }
    .table-compact .col-time { font-size: .74rem; width: 1%; }
    /* IP'ler harf harf alt alta dizilmesin: yalnızca sığmadığında kırılsın.
       Tablo zaten yatay kayabildiği için sütuna yeterli genişlik veriyoruz. */
    .table-compact .col-ip {
        font-size: .74rem;
        min-width: 112px;
        max-width: none;
        width: auto;
        word-break: normal;
        overflow-wrap: anywhere;
        line-height: 1.4;
    }
    /* Ziyaretçi loglarında "Cihaz", güvenlik loglarında "Tarayıcı" sütunu
       mobilde satırı taşırıyordu. Masaüstünde görünmeye devam ediyor. */
    .table-compact .col-device,
    .table-compact .col-agent { display: none; }
    .table-compact .col-target { min-width: 145px; }
}

@media print {
    .sidebar, .topbar, .page-actions, .app-foot, .impersonate-bar, .pagination { display: none !important; }
    .main { margin-left: 0; }
    body { background: #fff; }
}
