:root {
    --bg: #f6f7f9;
    --surface: #ffffff;
    --surface-2: #f1f3f6;
    --text: #1d2330;
    --muted: #6b7280;
    --border: #e3e6eb;
    --accent: #2563eb;
    --accent-hover: #1d4ed8;
    --accent-text: #ffffff;
    --ok: #15803d;
    --ok-bg: #ecfdf3;
    --warn: #a16207;
    --warn-bg: #fefce8;
    --danger: #dc2626;
    --danger-bg: #fef2f2;
    --radius: 10px;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #12151b;
        --surface: #1b1f27;
        --surface-2: #232833;
        --text: #e7e9ee;
        --muted: #9aa1ad;
        --border: #2b313c;
        --accent: #4f8bff;
        --accent-hover: #6b9dff;
        --ok: #4ade80;
        --ok-bg: #12261a;
        --warn: #facc15;
        --warn-bg: #2a2410;
        --danger: #f87171;
        --danger-bg: #2c1515;
    }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    font-size: 16px;
    line-height: 1.5;
}

a { color: var(--accent); }
h1 { font-size: 1.6rem; margin: 0 0 8px; }
h2 { font-size: 1.15rem; margin: 0; }
code, .mono { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; }

/* ---------- üst çubuk ---------- */
.topbar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px 20px;
    padding: 10px 16px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}
.brand { font-weight: 600; color: var(--text); text-decoration: none; }
.nav { display: flex; gap: 4px; flex-wrap: wrap; }
.nav a {
    color: var(--text);
    text-decoration: none;
    padding: 6px 10px;
    border-radius: 8px;
}
.nav a:hover { background: var(--surface-2); }
.nav-user { margin-left: auto; display: flex; align-items: center; gap: 10px; }

.banner { padding: 10px 16px; font-size: 0.95rem; }
.banner-warn { background: var(--warn-bg); color: var(--warn); border-bottom: 1px solid var(--border); }

/* ---------- yerleşim ---------- */
.page { max-width: 1100px; margin: 0 auto; padding: 24px 16px 48px; }
.page > h1 { margin-bottom: 16px; }

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 16px;
}
.card.highlight { border-color: var(--accent); }
.center { max-width: 480px; margin: 32px auto; text-align: center; }
.left { text-align: left; }
.stack > * + * { margin-top: 12px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; justify-content: center; }
.grow { flex: 1; min-width: 0; }
.section-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }

.muted { color: var(--muted); }
.small { font-size: 0.875rem; }

.divider {
    display: flex; align-items: center; gap: 12px;
    color: var(--muted); font-size: 0.875rem;
}
.divider::before, .divider::after { content: ""; flex: 1; border-top: 1px solid var(--border); }

.steps { text-align: left; padding-left: 20px; }

/* ---------- düğmeler ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    padding: 9px 16px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    color: var(--text);
    font: inherit;
    text-decoration: none;
    cursor: pointer;
}
.btn:hover { background: var(--surface-2); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn-primary:hover { background: var(--accent-hover); }
.btn-danger, .btn-danger:hover { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-sm { padding: 5px 10px; font-size: 0.875rem; }
.btn-lg { padding: 13px 20px; font-size: 1.05rem; width: 100%; }

/* ---------- form ---------- */
.form { text-align: left; }
.form label, label.form { display: flex; flex-direction: column; gap: 4px; }
.form label > span:first-child, label.form > span:first-child { font-weight: 500; font-size: 0.9rem; }
input, select {
    font: inherit;
    padding: 9px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    color: var(--text);
    width: 100%;
}
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.check { display: flex; align-items: center; gap: 8px; justify-content: center; }
.check input { width: auto; }
.field-error { color: var(--danger); font-size: 0.85rem; }
.grid-3 { display: grid; grid-template-columns: 2fr 1fr 1fr auto; gap: 12px; align-items: end; }
@media (max-width: 720px) { .grid-3 { grid-template-columns: 1fr; } }

/* ---------- durum mesajları ---------- */
.status:empty { display: none; }
.status { padding: 10px 12px; border-radius: 8px; background: var(--surface-2); margin: 0; }
.status.ok { background: var(--ok-bg); color: var(--ok); }
.status.warn { background: var(--warn-bg); color: var(--warn); }
.status.error { background: var(--danger-bg); color: var(--danger); }

/* ---------- listeler ve tablolar ---------- */
.list { list-style: none; margin: 0; padding: 0; }
.list-row {
    display: flex; justify-content: space-between; align-items: center; gap: 12px;
    padding: 12px 0;
    border-top: 1px solid var(--border);
}
.list-row:first-child { border-top: 0; }

.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 0.95rem; }
.table th { text-align: left; font-weight: 500; color: var(--muted); font-size: 0.85rem; }
.table th, .table td { padding: 10px 8px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.actions { display: flex; gap: 4px; justify-content: flex-end; flex-wrap: wrap; }

.badge {
    display: inline-block; padding: 1px 8px; border-radius: 99px;
    font-size: 0.75rem; background: var(--surface-2); color: var(--accent);
}
.badge-ok { color: var(--ok); background: var(--ok-bg); }
.badge-danger { color: var(--danger); background: var(--danger-bg); }
.badge-muted { color: var(--muted); }

/* Kullanım çubuğu: satır içi stil yasak (CSP) olduğu için genişlik sınıfla verilir. */
.meter { width: 140px; height: 6px; border-radius: 3px; background: var(--surface-2); overflow: hidden; }
.meter > span { display: block; height: 100%; background: var(--accent); }
.meter-0 { width: 1%; } .meter-10 { width: 10%; } .meter-20 { width: 20%; } .meter-30 { width: 30%; }
.meter-40 { width: 40%; } .meter-50 { width: 50%; } .meter-60 { width: 60%; } .meter-70 { width: 70%; }
.meter-80 { width: 80%; background: var(--warn) !important; } .meter-90 { width: 90%; background: var(--danger) !important; }
.meter-100 { width: 100%; background: var(--danger) !important; }

/* ---------- kurtarma kodları ---------- */
.codes {
    display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px 24px;
    padding: 16px 16px 16px 40px; margin: 0;
    background: var(--surface-2); border-radius: 8px;
    font-size: 1.1rem; text-align: left;
}

@media print {
    .topbar, .banner, .btn, .row { display: none !important; }
    .card { border: 0; }
    body, .codes { background: #fff; color: #000; }
}

/* ---------- giriş ve QR ---------- */
.login-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    max-width: 880px;
    margin: 16px auto;
}
@media (max-width: 760px) { .login-grid { grid-template-columns: 1fr; } }
.login-grid .card { margin: 0; }
.center-text { text-align: center; }

.qr-box {
    display: flex; align-items: center; justify-content: center;
    width: 256px; height: 256px; margin: 0 auto;
    background: #fff; border-radius: 12px; border: 1px solid var(--border);
}
.qr-box img { width: 240px; height: 240px; image-rendering: pixelated; }
.qr-placeholder { font-size: 0.9rem; padding: 16px; }
.match-number { font-size: 2.6rem; font-weight: 700; letter-spacing: 0.1em; margin: 0; }

.invite-share { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; }
.qr-small { background: #fff; border-radius: 8px; padding: 4px; border: 1px solid var(--border); }
.left-row { justify-content: flex-start; }

/* ---------- telefonda onay ---------- */
.facts {
    display: grid; grid-template-columns: auto 1fr; gap: 6px 16px;
    text-align: left; margin: 0; padding: 12px 16px;
    background: var(--surface-2); border-radius: 8px;
}
.facts dt { color: var(--muted); }
.facts dd { margin: 0; font-weight: 500; }

.choice-group { border: 0; padding: 0; margin: 0; }
.choice-group legend { font-weight: 500; margin-bottom: 8px; }
.choice-group .check { justify-content: flex-start; align-items: flex-start; margin-top: 8px; }
.choices { display: flex; gap: 12px; justify-content: center; }
.choice input { position: absolute; opacity: 0; pointer-events: none; }
.choice span {
    display: inline-flex; align-items: center; justify-content: center;
    width: 76px; height: 64px;
    font-size: 1.6rem; font-weight: 700;
    border: 2px solid var(--border); border-radius: 12px;
    cursor: pointer; user-select: none;
}
.choice input:checked + span { border-color: var(--accent); background: var(--accent); color: var(--accent-text); }
.choice input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }

.login-grid.single { grid-template-columns: 1fr; max-width: 480px; }


/* ---------- dosya yöneticisi ---------- */
.page:has(.drive) { max-width: 1400px; }
.drive { display: grid; grid-template-columns: 230px 1fr; gap: 20px; align-items: start; }
.drive-side { position: sticky; top: 16px; display: flex; flex-direction: column; gap: 16px; }
.side-nav { display: flex; flex-direction: column; gap: 2px; }
.side-nav a {
    color: var(--text); text-decoration: none;
    padding: 7px 10px; border-radius: 8px;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.side-nav a.sub { padding-left: 28px; font-size: 0.95rem; }
.side-nav a:hover { background: var(--surface-2); }
.side-nav a.active { background: var(--surface-2); font-weight: 600; color: var(--accent); }
.quota { display: flex; flex-direction: column; gap: 6px; padding: 0 10px; }
.meter-wide { width: 100%; }

.drive-main { min-width: 0; }
.drive-toolbar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.crumbs { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: 1.1rem; font-weight: 600; flex: 1; min-width: 200px; }
.crumbs a { color: var(--text); text-decoration: none; padding: 2px 6px; border-radius: 6px; }
.crumbs a:hover { background: var(--surface-2); }
.crumbs .sep { color: var(--muted); }
.search input { width: 240px; }
.toolbar-actions { display: flex; gap: 8px; }
label.btn { cursor: pointer; }

.items-form { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.selection-bar {
    display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
    padding: 8px 12px; border-bottom: 1px solid var(--border);
    background: var(--surface-2); border-radius: var(--radius) var(--radius) 0 0;
    position: sticky; top: 0; z-index: 2;
}
.selection-bar > span { margin-right: auto; }

.table.items td, .table.items th { padding: 8px 10px; }
.table.items tbody tr:hover { background: var(--surface-2); }
.table.items tr.selected { background: color-mix(in srgb, var(--accent) 12%, transparent); }
.table.items tr.drop-target, .side-nav a.drop-target, .crumbs a.drop-target { outline: 2px dashed var(--accent); outline-offset: -2px; }
.col-check { width: 36px; }
.col-check input { width: auto; }
.col-name a { color: var(--text); text-decoration: none; display: inline-flex; align-items: center; gap: 10px; word-break: break-word; }
.col-name a:hover { color: var(--accent); }
.col-name .icon { font-size: 1.2rem; width: 1.4rem; text-align: center; flex-shrink: 0; }
.col-size { width: 100px; white-space: nowrap; }
.col-date { width: 150px; white-space: nowrap; }
.col-actions { width: 90px; text-align: right; white-space: nowrap; }
.col-path { max-width: 260px; }

.empty-state { text-align: center; padding: 48px 16px; }
.empty-state .big { font-size: 3rem; margin: 0; }

.drop-overlay {
    position: fixed; inset: 0; z-index: 50;
    display: flex; align-items: center; justify-content: center;
    background: color-mix(in srgb, var(--accent) 18%, transparent);
    border: 4px dashed var(--accent);
    font-size: 1.4rem; text-align: center; pointer-events: none;
}
.drop-overlay > div { background: var(--surface); padding: 24px 32px; border-radius: 16px; line-height: 1.6; }

.upload-panel {
    position: fixed; right: 16px; bottom: 16px; z-index: 40;
    width: min(380px, calc(100vw - 32px)); max-height: 50vh; overflow: auto;
    background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
    box-shadow: 0 10px 30px rgb(0 0 0 / 0.25);
}
.upload-head { display: flex; justify-content: space-between; align-items: center; padding: 10px 14px; border-bottom: 1px solid var(--border); }
.upload-list { list-style: none; margin: 0; padding: 6px 14px 12px; }
.upload-item { display: grid; grid-template-columns: 1fr; gap: 3px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.upload-item:last-child { border-bottom: 0; }
.upload-name { font-size: 0.9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.upload-item progress { width: 100%; height: 6px; accent-color: var(--accent); }
.upload-item.done .upload-info { color: var(--ok); }
.upload-item.failed .upload-info { color: var(--danger); }

.dialog {
    border: 1px solid var(--border); border-radius: 12px; padding: 20px;
    width: min(440px, calc(100vw - 32px));
    background: var(--surface); color: var(--text);
}
.dialog::backdrop { background: rgb(0 0 0 / 0.45); }
.right-row { justify-content: flex-end; }
.trash-actions { margin-bottom: 8px; }

/* ---------- önizleme ---------- */
.page:has(.preview-body) { max-width: 1400px; }
.preview-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.preview-title { display: flex; flex-direction: column; flex: 1; min-width: 200px; word-break: break-word; }
.preview-body { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.preview-image { max-width: 100%; max-height: 80vh; border-radius: 8px; background: #fff; }
.preview-media { max-width: 100%; max-height: 80vh; border-radius: 8px; background: #000; }
.preview-pdf { width: 100%; height: 82vh; border: 1px solid var(--border); border-radius: 8px; background: #fff; }
.preview-text {
    width: 100%; max-height: 80vh; overflow: auto; margin: 0;
    padding: 16px; background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
    white-space: pre-wrap; word-break: break-word; font-size: 0.9rem;
}

@media (max-width: 800px) {
    .drive { grid-template-columns: 1fr; }
    .drive-side { position: static; }
    .side-nav { flex-direction: row; overflow-x: auto; gap: 6px; padding-bottom: 4px; }
    .side-nav a, .side-nav a.sub { padding: 6px 12px; background: var(--surface); border: 1px solid var(--border); border-radius: 99px; font-size: 0.9rem; }
    .search, .search input { width: 100%; }
    .col-date, .col-path, th.col-size, td.col-size { display: none; }
    .toolbar-actions { width: 100%; }
    .toolbar-actions .btn { flex: 1; }
}

.shared-mark { margin-left: 6px; font-size: 0.85rem; }
.share-row { align-items: flex-start; }


/* ---------- acil erişim ---------- */
.banner-danger { background: var(--danger-bg); color: var(--danger); border-bottom: 1px solid var(--border); }
.banner a { color: inherit; font-weight: 600; }
.label { font-weight: 500; font-size: 0.9rem; }
.pin-display {
    text-align: center; font-size: 1.6rem; letter-spacing: 0.4em; min-height: 2.6rem;
    padding: 6px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface-2);
}
.pin-display:not(.filled) { font-size: 0.9rem; letter-spacing: normal; color: var(--muted); line-height: 2rem; }
.pin-display.error { color: var(--danger); }
.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; max-width: 280px; margin: 0 auto; }
.key {
    font: inherit; font-size: 1.4rem; font-weight: 600; padding: 12px 0;
    border: 1px solid var(--border); border-radius: 10px; background: var(--surface); color: var(--text); cursor: pointer;
    user-select: none;
}
.key:hover { background: var(--surface-2); }
.key:active { transform: scale(0.97); }
.key-muted { color: var(--muted); font-size: 1.1rem; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 600px) { .grid-2 { grid-template-columns: 1fr; } }

/* ---------- ayarlar ---------- */
.setting-row { display: flex; gap: 16px; align-items: center; justify-content: space-between; padding: 12px 0; border-top: 1px solid var(--border); }
.setting-row:first-child { border-top: 0; }
.setting-text { display: flex; flex-direction: column; gap: 2px; }
.setting-input { width: 220px; flex-shrink: 0; }
input.num { width: 110px; }
.quota-form { display: flex; gap: 4px; align-items: center; margin-top: 4px; }
.quota-form input.num { width: 80px; padding: 4px 8px; }
@media (max-width: 600px) { .setting-row { flex-direction: column; align-items: stretch; } .setting-input { width: 100%; } }

/* ---------- telefon ---------- */
/* 1fr, içindeki kaydırılabilir menünün genişliği kadar büyüyüp sayfayı taşırıyordu; minmax(0, 1fr) sütunu ekrana sabitler. */
.drive { grid-template-columns: 230px minmax(0, 1fr); }
html, body { overflow-x: clip; }
.list-row > div { min-width: 0; overflow-wrap: anywhere; }

@media (max-width: 800px) {
    .drive { grid-template-columns: minmax(0, 1fr); gap: 12px; }
    .drive-side { min-width: 0; gap: 10px; }
    .side-nav { scrollbar-width: none; }
    .side-nav::-webkit-scrollbar { display: none; }
    .side-nav a { flex-shrink: 0; }
    .crumbs { min-width: 0; font-size: 1rem; }

    .table.items { table-layout: fixed; }
    .table.items .col-check { width: 40px; }
    .table.items .col-actions { width: 118px; }
    .table.items td, .table.items th { padding: 8px 6px; }
    .table.items td.col-name a { display: flex; min-width: 0; overflow-wrap: anywhere; word-break: normal; }
    .table.items .btn-sm { min-width: 34px; min-height: 34px; padding: 4px 6px; }
    .col-check input { width: 20px; height: 20px; }

    .selection-bar > span { flex-basis: 100%; }
    .selection-bar .btn { flex: 1 1 auto; white-space: nowrap; }
}

@media (max-width: 640px) {
    .page { padding: 16px 12px 40px; }
    h1 { font-size: 1.35rem; }
    .card { padding: 16px; }

    /* Üst çubuk: marka ve çıkış ilk satırda, menü altta tek satır yatay kaydırmalı. */
    .topbar { padding: 8px 12px 0; gap: 4px 12px; }
    .nav-user { order: 2; gap: 6px; }
    .nav-user .muted { max-width: 30vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .nav {
        order: 3;
        flex-wrap: nowrap; overflow-x: auto;
        margin: 0 -12px; padding: 4px 12px 8px; width: calc(100% + 24px);
        scrollbar-width: none;
    }
    .nav::-webkit-scrollbar { display: none; }
    .nav a { flex-shrink: 0; white-space: nowrap; background: var(--surface-2); border-radius: 99px; padding: 6px 12px; font-size: 0.9rem; }

    .section-head > * { min-width: 0; }
    .section-head .btn { width: 100%; }
    .list-row { flex-wrap: wrap; }

    .upload-panel { left: 8px; right: 8px; bottom: 8px; width: auto; }
    .dialog { padding: 16px; }
    .right-row .btn { flex: 1; }

    .preview-head .btn-ghost { padding-left: 0; }
    .preview-head .row { width: 100%; justify-content: flex-end; }
    .preview-image, .preview-media { max-height: 70vh; }
    .preview-pdf { height: 75vh; }

    .codes { grid-template-columns: 1fr; padding-left: 32px; }
    .qr-box { width: min(256px, 100%); height: auto; aspect-ratio: 1; }
    .qr-box img { width: 94%; height: auto; }
    .choice span { width: 64px; height: 56px; }
}
