/* Ortak tasarım: renkler, yazı, butonlar, formlar */
:root {
    --brand: #0e5e4f;
    --brand-2: #127a66;
    --brand-soft: #e3f1ed;
    --oil: #e0a21b;
    --oil-soft: #fdf3dc;
    --debt: #c2312b;
    --debt-soft: #fdeceb;
    --pay: #15803d;
    --pay-soft: #e6f5ea;
    --warn: #b45309;
    --warn-soft: #fff4e0;
    --ink: #17201d;
    --ink-2: #4a5753;
    --muted: #7b8783;
    --line: #e3e8e6;
    --bg: #f3f5f4;
    --card: #ffffff;
    --radius: 14px;
    --shadow: 0 1px 2px rgba(16, 40, 32, .06), 0 2px 8px rgba(16, 40, 32, .05);
    font-synthesis: none;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
    margin: 0;
    font-family: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
    color: var(--ink);
    background: var(--bg);
    font-size: 15px;
    line-height: 1.45;
}
a { color: var(--brand); text-decoration: none; }
h1, h2, h3 { margin: 0; line-height: 1.2; }
.ic { flex: none; vertical-align: middle; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.hidden { display: none !important; }
.num { font-variant-numeric: tabular-nums; }

.debt { color: var(--debt); }
.pay { color: var(--pay); }
.warn { color: var(--warn); }

/* Butonlar */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    min-height: 42px; padding: 0 18px;
    border: 1px solid var(--line); border-radius: 10px;
    background: var(--card); color: var(--ink);
    font: inherit; font-weight: 600; cursor: pointer;
    transition: transform .06s, background .15s, box-shadow .15s;
    -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: scale(.97); }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-2); }
.btn-debt { background: var(--debt); border-color: var(--debt); color: #fff; }
.btn-pay { background: var(--pay); border-color: var(--pay); color: #fff; }
.btn-oil { background: var(--oil); border-color: var(--oil); color: #2b1d00; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--ink-2); }
.btn-danger-text { background: transparent; border-color: transparent; color: var(--debt); }
.btn-sm { min-height: 34px; padding: 0 12px; font-size: 13px; border-radius: 8px; }
.btn-block { width: 100%; }
.btn-icon { width: 38px; padding: 0; }

/* Formlar */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field > label { font-size: 13px; font-weight: 600; color: var(--ink-2); }
.input, select.input, textarea.input {
    width: 100%; min-height: 44px; padding: 10px 12px;
    border: 1px solid #cfd8d5; border-radius: 10px;
    background: #fff; color: var(--ink); font: inherit;
    outline: none; transition: border-color .15s, box-shadow .15s;
}
textarea.input { min-height: 70px; resize: vertical; }
.input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(14, 94, 79, .15); }
.input.money { font-variant-numeric: tabular-nums; }
.row { display: flex; gap: 12px; }
.row > * { flex: 1; min-width: 0; }

.seg { display: flex; background: #e7ecea; border-radius: 10px; padding: 3px; gap: 3px; }
.seg label { flex: 1; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span {
    display: block; text-align: center; padding: 9px 6px; border-radius: 8px;
    font-weight: 600; color: var(--ink-2); cursor: pointer;
}
.seg input:checked + span { background: #fff; color: var(--brand); box-shadow: var(--shadow); }

/* Mesajlar */
.toast {
    display: flex; align-items: center; gap: 10px;
    background: #10291f; color: #fff;
    padding: 12px 16px; border-radius: 12px; margin-bottom: 14px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, .18);
    animation: toast-in .25s ease-out;
    cursor: pointer;
}
.toast .ic { color: #6ee7a8; }
@keyframes toast-in { from { opacity: 0; transform: translateY(-8px); } }
.alert-err {
    background: var(--debt-soft); color: var(--debt);
    border: 1px solid #f5c6c3; border-radius: 12px; padding: 10px 14px; margin-bottom: 14px; font-weight: 600;
}

.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); }
.chip {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600;
    background: #edf1ef; color: var(--ink-2);
}
.chip-debt { background: var(--debt-soft); color: var(--debt); }
.chip-pay { background: var(--pay-soft); color: var(--pay); }
.chip-warn { background: var(--warn-soft); color: var(--warn); }
.chip-brand { background: var(--brand-soft); color: var(--brand); }

.empty { text-align: center; color: var(--muted); padding: 30px 16px; }
.empty .ic { color: #b9c4c0; margin-bottom: 6px; }

/* Satış satırları (web ve mobil ortak) */
.line-total { font-weight: 700; font-variant-numeric: tabular-nums; }

/* Öneri listesi */
.suggest {
    position: absolute; z-index: 500; max-height: 320px; overflow-y: auto;
    background: #fff; border: 1px solid var(--line); border-radius: 12px;
    box-shadow: 0 12px 32px rgba(16, 40, 32, .18); padding: 4px;
}
.sg-item { padding: 10px 12px; border-radius: 8px; cursor: pointer; font-weight: 500; }
.sg-item:hover, .sg-item.on { background: var(--brand-soft); color: var(--brand); }
body.mob .sg-item { padding: 13px 14px; font-size: 16px; }

/* Detay penceresi (Görüntüle) */
.modal-backdrop {
    position: fixed; inset: 0; z-index: 900; background: rgba(10, 20, 16, .5);
    display: flex; align-items: center; justify-content: center; padding: 20px;
    opacity: 0; transition: opacity .18s;
}
.modal-backdrop.open { opacity: 1; }
.modal {
    background: #fff; border-radius: 18px; width: 100%; max-width: 560px; max-height: 90vh; overflow-y: auto;
    box-shadow: 0 24px 64px rgba(0, 0, 0, .3); padding: 0 0 6px;
    transform: translateY(10px); transition: transform .2s;
}
.modal-backdrop.open .modal { transform: none; }
.modal .sheet-handle { display: none; }
.vw-head { display: flex; align-items: center; gap: 12px; padding: 18px 20px; border-bottom: 1px solid var(--line); }
.vw-ic { width: 44px; height: 44px; border-radius: 12px; display: flex; align-items: center; justify-content: center; flex: none; }
.vw-head.sale .vw-ic { background: var(--debt-soft); color: var(--debt); }
.vw-head.payment .vw-ic { background: var(--pay-soft); color: var(--pay); }
.vw-head.buy .vw-ic { background: var(--warn-soft); color: var(--warn); }
.vw-head > div { flex: 1; min-width: 0; }
.vw-title { font-weight: 800; font-size: 17px; }
.vw-sub { color: var(--muted); font-size: 14px; }
.vw-amt { font-weight: 800; font-size: 20px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.vw-head.sale .vw-amt { color: var(--debt); }
.vw-head.payment .vw-amt { color: var(--pay); }
.vw-head.buy .vw-amt { color: var(--warn); }
.vw-dl { display: grid; grid-template-columns: auto 1fr; gap: 8px 16px; margin: 0; padding: 16px 20px; }
.vw-dl dt { color: var(--muted); font-size: 13.5px; font-weight: 600; }
.vw-dl dd { margin: 0; }
.vw-lines { width: calc(100% - 40px); margin: 0 20px 12px; border-collapse: collapse; font-size: 14px; }
.vw-lines th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 600; padding: 6px 4px; border-bottom: 1px solid var(--line); }
.vw-lines td { padding: 8px 4px; border-bottom: 1px solid var(--line); }
.vw-lines tfoot td { font-weight: 800; border-bottom: 0; }
.vw-lines .r { text-align: right; }
.vw-photo { padding: 0 20px 12px; text-align: center; }
.vw-photo img { max-width: 100%; max-height: 55vh; border-radius: 12px; border: 1px solid var(--line); cursor: zoom-in; display: block; margin: 0 auto 6px; }
.vw-nophoto { margin: 0 20px 12px; padding: 14px; border-radius: 12px; background: #f4f6f5; color: var(--muted); display: flex; gap: 8px; align-items: center; justify-content: center; font-size: 14px; }
.vw-actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; padding: 12px 20px 14px; border-top: 1px solid var(--line); }
.vw-actions form { margin: 0; }
.vw-actions form:first-child { margin-right: auto; }

body.mob .modal-backdrop { align-items: flex-end; padding: 0; }
body.mob .modal { max-width: none; border-radius: 22px 22px 0 0; max-height: 92vh; transform: translateY(100%); padding-bottom: env(safe-area-inset-bottom); }
body.mob .modal-backdrop.open .modal { transform: none; }
body.mob .modal .sheet-handle { display: block; margin-top: 8px; }
body.mob .vw-actions .btn { min-height: 50px; flex: 1; }
body.mob .vw-actions form { flex: 1; display: flex; }
body.mob .vw-actions form .btn { flex: 1; }
body.mob .vw-actions form:first-child { margin-right: 0; }

/* Şifre onayı penceresi */
.auth-backdrop {
    position: fixed; inset: 0; z-index: 950; background: rgba(10, 20, 16, .55);
    display: flex; align-items: center; justify-content: center; padding: 20px; opacity: 0; transition: opacity .15s;
}
.auth-backdrop.open { opacity: 1; }
.auth-box { background: #fff; border-radius: 18px; padding: 24px; width: 100%; max-width: 380px; text-align: center; box-shadow: 0 24px 64px rgba(0, 0, 0, .3); }
.auth-ic { width: 56px; height: 56px; border-radius: 50%; margin: 0 auto 12px; display: flex; align-items: center; justify-content: center; font-size: 24px; background: var(--brand-soft); }
.auth-ic.danger { background: var(--debt-soft); }
.auth-title { font-weight: 800; font-size: 18px; }
.auth-msg { color: var(--ink-2); font-size: 14px; margin-top: 6px; }
.auth-pw { margin-top: 16px; text-align: center; font-size: 18px; }
.auth-err { color: var(--debt); font-size: 13px; font-weight: 600; margin-top: 6px; }
.auth-btns { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 16px; }
.auth-btns .btn { min-height: 48px; }

/* Fotoğraf seçici */
.photo-pick {
    display: flex; align-items: center; justify-content: center; gap: 10px;
    min-height: 64px; border: 2px dashed #c4d0cc; border-radius: 12px;
    color: var(--ink-2); font-weight: 600; cursor: pointer; background: #fafcfb;
    position: relative; overflow: hidden;
}
.photo-pick input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.photo-pick.has-photo { border-style: solid; border-color: var(--brand); padding: 6px; }
.photo-pick img { max-width: 100%; max-height: 260px; border-radius: 8px; display: block; }

/* Resim görüntüleyici */
.viewer {
    position: fixed; inset: 0; background: rgba(0, 0, 0, .92); z-index: 1000;
    display: flex; align-items: center; justify-content: center;
}
.viewer img { max-width: 100%; max-height: 100%; object-fit: contain; }
.viewer .close { position: absolute; top: 14px; right: 14px; color: #fff; background: rgba(255, 255, 255, .15); border: 0; border-radius: 50%; width: 44px; height: 44px; }

/* Giriş */
body.plain { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px;
    background: linear-gradient(160deg, #0e5e4f 0%, #0b4a3e 55%, #2a2410 100%); }
.plain-card { background: #fff; border-radius: 20px; padding: 32px 26px; width: 100%; max-width: 380px; box-shadow: 0 20px 60px rgba(0, 0, 0, .3); }
.plain-card h1 { font-size: 22px; margin-bottom: 4px; }
.login-logo { display: flex; align-items: center; gap: 12px; margin-bottom: 24px; }
.login-logo img { width: 52px; height: 52px; }
.login-logo small { display: block; color: var(--muted); font-weight: 500; }

@media print {
    .no-print, .side, .quickbar, .toast, .tabbar, .appbar { display: none !important; }
    body { background: #fff; }
    .main { margin: 0 !important; padding: 0 !important; }
    .card { box-shadow: none; border: 1px solid #ddd; }
}
