:root {
  --sidebar-bg: #16213a;
  --sidebar-fg: #c3cad9;
  --sidebar-active: #f2b705;
  --brand: #1f6feb;
  --paid: #d4f3e1;
  --paid-strong: #198754;
  --partial: #fdebcc;
  --partial-strong: #d97706;
  --unpaid: #fadadd;
  --unpaid-strong: #dc3545;
  --surface: #f4f6fa;
}

body { background: var(--surface); font-size: .925rem; }
.app-shell { display: flex; min-height: 100vh; }

/* ---------- sidebar */
.sidebar {
  width: 250px; flex-shrink: 0; background: var(--sidebar-bg); color: var(--sidebar-fg);
  position: sticky; top: 0; height: 100vh; overflow-y: auto; padding-bottom: 2rem;
}
.sidebar .brand { display: flex; align-items: center; gap: .6rem; padding: 1.1rem 1.2rem; color: #fff;
  font-weight: 700; font-size: 1.05rem; text-decoration: none; border-bottom: 1px solid rgba(255,255,255,.07); }
.sidebar .brand i { color: var(--sidebar-active); font-size: 1.4rem; }
.sidebar .nav-section { font-size: .7rem; text-transform: uppercase; letter-spacing: .08em;
  color: #7c879e; padding: 1.1rem 1.2rem .35rem; }
.sidebar a.nav-link { color: var(--sidebar-fg); padding: .45rem 1.2rem; display: flex; align-items: center;
  gap: .65rem; border-left: 3px solid transparent; }
.sidebar a.nav-link:hover { color: #fff; background: rgba(255,255,255,.05); }
.sidebar a.nav-link.active { color: #fff; background: rgba(242,183,5,.09); border-left-color: var(--sidebar-active); }
.sidebar a.nav-link .badge { margin-left: auto; }

.main { flex: 1; min-width: 0; }
.topbar { background: #fff; border-bottom: 1px solid #e3e7ef; padding: .6rem 1.5rem; display: flex;
  align-items: center; gap: 1rem; position: sticky; top: 0; z-index: 20; }
.content { padding: 1.5rem; max-width: 1400px; }
.page-title { font-size: 1.35rem; font-weight: 700; margin: 0; }
.page-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .75rem;
  margin-bottom: 1.25rem; }

@media (max-width: 991.98px) {
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; height: auto; width: min(84vw, 300px); z-index: 1060;
    transform: translateX(-105%); transition: transform .22s ease; padding-top: env(safe-area-inset-top);
    padding-bottom: calc(1.5rem + env(safe-area-inset-bottom)); overscroll-behavior: contain; }
  .sidebar.open { transform: none; box-shadow: 0 0 40px rgba(0,0,0,.45); }
  .sidebar a.nav-link { padding: .65rem 1.2rem; }
  .content { padding: 1rem; }
}
.sidebar-backdrop { position: fixed; inset: 0; background: rgba(10,15,30,.5); z-index: 1055; opacity: 0;
  pointer-events: none; transition: opacity .2s; }
.sidebar-backdrop.show { opacity: 1; pointer-events: auto; }
body.no-scroll { overflow: hidden; }

/* ---------- cards & KPIs */
.card { border: 1px solid #e3e7ef; border-radius: .6rem; box-shadow: 0 1px 2px rgba(16,24,40,.04); }
.card-header { background: #fff; font-weight: 600; border-bottom: 1px solid #edf0f5; }
.kpi { padding: 1rem 1.1rem; }
.kpi .label { font-size: .78rem; color: #6b7387; text-transform: uppercase; letter-spacing: .04em; }
.kpi .value { font-size: 1.45rem; font-weight: 700; line-height: 1.2; margin-top: .2rem; }
.kpi .sub { font-size: .8rem; color: #6b7387; }
.kpi-icon { width: 42px; height: 42px; border-radius: 10px; display: grid; place-items: center; font-size: 1.2rem; }

/* ---------- aidat durum renkleri */
tr.row-paid > td { background: var(--paid) !important; }
tr.row-partial > td { background: var(--partial) !important; }
tr.row-unpaid > td { background: var(--unpaid) !important; }
.unit-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: .5rem; }
.unit-tile { border-radius: .5rem; padding: .5rem .45rem; text-align: center; font-size: .8rem;
  border: 1px solid transparent; text-decoration: none; color: #1d2433; display: block; }
.unit-tile .no { font-weight: 700; font-size: .95rem; }
.unit-tile.PAID { background: var(--paid); border-color: #a9e4c2; }
.unit-tile.PARTIAL { background: var(--partial); border-color: #f7cf8c; }
.unit-tile.UNPAID { background: var(--unpaid); border-color: #f2aab3; }
.unit-tile.NONE { background: #eef0f4; border-color: #dde1e8; color: #6b7387; }
.legend span { display: inline-flex; align-items: center; gap: .35rem; margin-right: 1rem; font-size: .82rem; }
.legend i { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }

.progress-thin { height: 6px; }
.table > :not(caption) > * > * { padding: .55rem .65rem; }
.table thead th { font-size: .75rem; text-transform: uppercase; letter-spacing: .03em; color: #5d6578;
  background: #f8f9fb; white-space: nowrap; }
.money { font-variant-numeric: tabular-nums; white-space: nowrap; }
.text-debt { color: var(--unpaid-strong); font-weight: 600; }
.text-credit { color: var(--paid-strong); font-weight: 600; }

/* ---------- forms */
.form-label { font-weight: 500; font-size: .85rem; margin-bottom: .3rem; }
.checkbox-grid > div { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: .25rem .75rem;
  max-height: 260px; overflow-y: auto; border: 1px solid #dee2e6; border-radius: .4rem; padding: .6rem; }
.checkbox-grid label, .radio-list label { font-weight: 400; display: flex; align-items: center; gap: .4rem; }
.radio-list > div > div { margin-bottom: .25rem; }
.errorlist { color: var(--unpaid-strong); list-style: none; padding: 0; margin: .25rem 0 0; font-size: .82rem; }

/* ---------- mesajlaşma */
.thread { display: flex; flex-direction: column; gap: .9rem; }
.bubble { max-width: 80%; padding: .75rem 1rem; border-radius: .8rem; background: #fff; border: 1px solid #e3e7ef; }
.bubble.mine { align-self: flex-end; background: #e8f0fe; border-color: #c9dafc; }
.bubble.internal { background: #fff8e1; border-color: #ffe08a; }
.bubble .meta { font-size: .75rem; color: #6b7387; margin-bottom: .3rem; }
.attachment-chip { display: inline-flex; align-items: center; gap: .35rem; padding: .25rem .6rem; border-radius: 99px;
  background: #f1f3f7; font-size: .8rem; text-decoration: none; margin: .25rem .25rem 0 0; }
.attachment-thumb { max-height: 140px; border-radius: .4rem; margin-top: .4rem; }

/* ---------- giriş */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 1rem;
  background: radial-gradient(circle at 20% 20%, #23345c 0, #16213a 55%, #0e1628 100%); }
.auth-card { width: 100%; max-width: 410px; border-radius: 1rem; }

.empty { padding: 2.5rem 1rem; text-align: center; color: #8a92a5; }
.empty i { font-size: 2rem; display: block; margin-bottom: .5rem; }

@media print {
  .sidebar, .topbar, .no-print, .btn { display: none !important; }
  .content { padding: 0; max-width: none; }
  tr.row-paid > td, tr.row-partial > td, tr.row-unpaid > td { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}


/* ================================================================ mobil / uygulama görünümü */
.topbar { padding-top: calc(.6rem + env(safe-area-inset-top)); }
.topbar-brand { color: #f2b705; font-size: 1.5rem; line-height: 1; text-decoration: none; }
.topbar-title { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.building-switch select { min-width: 200px; }

.bottom-nav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 1040; display: flex; background: #fff;
  border-top: 1px solid #e3e7ef; padding-bottom: env(safe-area-inset-bottom); box-shadow: 0 -4px 16px rgba(16,24,40,.06); }
.bottom-nav a { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  padding: .45rem .2rem .4rem; color: #6b7387; text-decoration: none; font-size: .68rem; position: relative; min-height: 56px;
  -webkit-tap-highlight-color: transparent; }
.bottom-nav a i { font-size: 1.3rem; line-height: 1; }
.bottom-nav a.active { color: var(--brand); font-weight: 600; }
.bottom-nav a .dot { position: absolute; top: 4px; left: calc(50% + 6px); background: #dc3545; color: #fff; font-size: .62rem;
  min-width: 17px; height: 17px; border-radius: 9px; display: grid; place-items: center; padding: 0 4px; font-weight: 700; }
.bottom-nav a.bottom-nav-primary i { background: #198754; color: #fff; width: 46px; height: 46px; border-radius: 50%;
  display: grid; place-items: center; margin-top: -22px; box-shadow: 0 4px 12px rgba(25,135,84,.4); border: 3px solid #fff; }
.bottom-nav a.bottom-nav-primary { color: #198754; font-weight: 600; }

.install-hint { position: fixed; left: .75rem; right: .75rem; z-index: 1045; background: #16213a; color: #fff;
  border-radius: .8rem; padding: .8rem 1rem; box-shadow: 0 8px 24px rgba(0,0,0,.3);
  bottom: calc(68px + env(safe-area-inset-bottom)); }
@media (min-width: 992px) { .install-hint { bottom: 1rem; left: auto; max-width: 420px; } }

@media (max-width: 991.98px) {
  body.has-bottom-nav .content { padding-bottom: calc(80px + env(safe-area-inset-bottom)); }
}

@media (max-width: 767.98px) {
  body { font-size: .9rem; }
  .topbar { padding-left: .9rem; padding-right: .9rem; gap: .6rem; }
  .building-switch { flex: 1; min-width: 0; }
  .building-switch select { min-width: 0; width: 100%; }
  .content { padding: .85rem .75rem; }
  .page-head { margin-bottom: .9rem; }
  .page-title { font-size: 1.15rem; }
  .page-head .btn { font-size: .85rem; }
  .kpi { padding: .8rem .85rem; }
  .kpi .value { font-size: 1.15rem; }
  .kpi .label { font-size: .68rem; }
  .kpi-icon { display: none; }
  .card { border-radius: .75rem; }
  /* iOS'ta odaklanınca yakınlaştırmayı engelle */
  .form-control, .form-select, textarea { font-size: 16px !important; }
  .btn { min-height: 40px; }
  .btn-sm { min-height: 34px; }
  .bubble { max-width: 94%; }
  .unit-grid { grid-template-columns: repeat(auto-fill, minmax(70px, 1fr)); gap: .4rem; }
  .unit-tile { padding: .4rem .2rem; font-size: .72rem; }
  .legend span { margin-right: .5rem; }
  .pagination { flex-wrap: wrap; }
  .dropdown-menu { font-size: 1rem; }
  .fs-2 { font-size: 1.6rem !important; }

  /* Tablolar telefonda kart görünümüne geçer (sütun başlıkları app.js ile etiket olur) */
  .table-stack thead { display: none; }
  .table-stack, .table-stack > tbody, .table-stack > tfoot, .table-stack tr { display: block; width: 100%; }
  .table-stack tr { width: auto; margin: .55rem; border: 1px solid #e3e7ef; border-radius: .6rem; overflow: hidden;
    background: #fff; }
  .table-stack > tbody > tr > td, .table-stack > tfoot > tr > td, .table-stack > tbody > tr > th {
    display: flex; justify-content: space-between; align-items: center; gap: .75rem; text-align: right !important;
    border: 0; border-bottom: 1px solid #f0f2f6; padding: .5rem .75rem; min-height: 2.3rem; white-space: normal; }
  .table-stack td::before { content: attr(data-label); font-weight: 600; color: #6b7387; font-size: .72rem;
    text-transform: uppercase; letter-spacing: .02em; text-align: left; flex-shrink: 0; max-width: 45%; }
  .table-stack td[data-label=""]::before, .table-stack td.cell-full::before { content: none; }
  .table-stack td[data-label=""] { justify-content: flex-end; }
  .table-stack td.cell-full { display: block; text-align: center !important; }
  .table-stack td:last-child { border-bottom: 0; }
  .table-stack td:empty { display: none; }
  .table-stack .cell-val { min-width: 0; text-align: right; overflow-wrap: anywhere; }
  .table-stack td[data-label=""] .cell-val { width: 100%; display: flex; justify-content: flex-end; flex-wrap: wrap; gap: .35rem; }
  .table-stack .cell-val > form.d-flex { width: 100%; }
  .table-stack .cell-val > form.d-flex input { min-width: 0; }
  .table-stack tr.row-paid { border-color: #a9e4c2; }
  .table-stack tr.row-partial { border-color: #f7cf8c; }
  .table-stack tr.row-unpaid { border-color: #f2aab3; }
  .table-stack tfoot tr { background: #f8f9fb; }
  .card > .table-responsive > .table-stack, .card .table-stack { margin-bottom: .2rem !important; }
}

/* Kurulu uygulama (standalone) olarak açıldığında */
.is-standalone body { -webkit-user-select: none; user-select: none; }
.is-standalone input, .is-standalone textarea, .is-standalone .user-select-all, .is-standalone td,
.is-standalone .bubble, .is-standalone dd { -webkit-user-select: text; user-select: text; }
@media (display-mode: standalone) { .auth-wrap { padding-top: env(safe-area-inset-top); } }

/* ================================================================ WhatsApp tarzı sohbet */
:root { --wa-bg: #efeae2; --wa-out: #d9fdd3; --wa-in: #ffffff; --wa-green: #00a884; --wa-tick: #53bdeb; }
.chat { display: flex; flex-direction: column; background: var(--wa-bg); border: 1px solid #e3e7ef; border-radius: .8rem;
  overflow: hidden; height: calc(100dvh - 64px - 3rem); min-height: 420px; }
.chat-header { display: flex; align-items: center; gap: .65rem; padding: .55rem .75rem; background: #f0f2f5;
  border-bottom: 1px solid #e1e4e8; }
.chat-back { color: #54656f; font-size: 1.25rem; text-decoration: none; padding: .2rem .3rem; }
.chat-avatar { width: 40px; height: 40px; border-radius: 50%; background: #dfe5e7; color: #54656f; display: grid;
  place-items: center; font-weight: 700; flex-shrink: 0; font-size: .95rem; }
.chat-avatar.staff { background: #16213a; color: #f2b705; font-size: 1.1rem; }
.chat-title { min-width: 0; flex: 1; }
.chat-title .name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-title .sub { font-size: .76rem; color: #667781; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-menu { color: #54656f; font-size: 1.2rem; }
.chat-body { flex: 1; overflow-y: auto; padding: .75rem 4% 1rem; display: flex; flex-direction: column; gap: 2px;
  background-color: var(--wa-bg);
  background-image: radial-gradient(rgba(0,0,0,.035) 1px, transparent 1px); background-size: 18px 18px;
  overscroll-behavior: contain; }
.chat-hint { align-self: center; background: #fff5c4; color: #54656f; font-size: .74rem; border-radius: .5rem;
  padding: .35rem .7rem; margin-bottom: .6rem; text-align: center; max-width: 90%; }
.chat-day { align-self: center; margin: .6rem 0 .35rem; }
.chat-day span { background: #fff; color: #54656f; font-size: .74rem; padding: .25rem .7rem; border-radius: .5rem;
  box-shadow: 0 1px .5px rgba(11,20,26,.13); }
.msg { display: flex; margin-top: 3px; }
.msg.out { justify-content: flex-end; }
.msg.in + .msg.out, .msg.out + .msg.in { margin-top: 10px; }
.bubble-wa { max-width: min(75%, 560px); padding: .4rem .55rem .25rem; border-radius: .55rem; position: relative;
  box-shadow: 0 1px .5px rgba(11,20,26,.13); font-size: .93rem; line-height: 1.35; word-wrap: break-word; }
.msg.in .bubble-wa { background: var(--wa-in); border-top-left-radius: 0; }
.msg.out .bubble-wa { background: var(--wa-out); border-top-right-radius: 0; }
.msg.internal .bubble-wa { background: #fff3cd; border: 1px dashed #e0b84c; }
.bubble-wa .sender { font-size: .78rem; font-weight: 600; color: #1f7aec; margin-bottom: 2px; }
.msg.out .bubble-wa .sender { color: #008069; }
.bubble-wa .internal-tag { font-size: .72rem; color: #8a6d1a; margin-bottom: 2px; }
.bubble-wa .text { white-space: normal; }
.bubble-wa .meta { font-size: .68rem; color: #667781; text-align: right; margin-top: 2px; margin-left: 1.5rem;
  white-space: nowrap; float: right; position: relative; top: 4px; }
.bubble-wa::after { content: ""; display: block; clear: both; }
.tick { font-size: .95rem; vertical-align: -2px; color: #8696a0; }
.tick.read { color: var(--wa-tick); }
.msg-img img { display: block; max-width: 100%; max-height: 280px; border-radius: .4rem; margin: 2px 0 4px; }
.msg-file { display: flex; align-items: center; gap: .55rem; background: rgba(0,0,0,.05); border-radius: .4rem;
  padding: .5rem .6rem; margin: 2px 0 4px; text-decoration: none; color: inherit; min-width: 200px; }
.msg-file i { font-size: 1.7rem; color: #e74c3c; }
.msg-file .fname { display: block; font-size: .85rem; font-weight: 500; overflow: hidden; text-overflow: ellipsis;
  white-space: nowrap; max-width: 220px; }
.msg-file small { color: #667781; font-size: .72rem; }

.chat-composer { background: #f0f2f5; padding: .45rem .6rem calc(.45rem + 0px); border-top: 1px solid #e1e4e8; }
.composer-options { display: flex; align-items: center; gap: .75rem; margin-bottom: .35rem; padding: 0 .25rem; }
.composer-options .form-select { width: auto; max-width: 55%; }
.composer-files { display: flex; flex-wrap: wrap; gap: .35rem; align-items: center; margin-bottom: .35rem; }
.file-chip { background: #fff; border-radius: 1rem; padding: .15rem .6rem; font-size: .78rem; max-width: 220px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.composer-row { display: flex; align-items: flex-end; gap: .45rem; }
.composer-btn { width: 42px; height: 42px; display: grid; place-items: center; color: #54656f; font-size: 1.35rem;
  cursor: pointer; flex-shrink: 0; margin: 0; border-radius: 50%; }
.composer-btn:hover { background: #e4e7ea; }
.composer-input { flex: 1; resize: none; border: 0; border-radius: 1.3rem; padding: .6rem 1rem; background: #fff;
  line-height: 1.35; max-height: 140px; outline: none; font-size: 16px; }
.composer-send { width: 44px; height: 44px; border-radius: 50%; border: 0; background: var(--wa-green); color: #fff;
  display: grid; place-items: center; font-size: 1.1rem; flex-shrink: 0; }
.composer-send:disabled { opacity: .6; }
.chat-closed { background: #f0f2f5; padding: .9rem; text-align: center; font-size: .88rem; color: #54656f; }

/* sohbet listesi */
.chat-search { display: flex; align-items: center; gap: .5rem; position: relative; }
.chat-search > i { position: absolute; left: .85rem; color: #8696a0; }
.chat-search input { padding-left: 2.3rem; border-radius: 1.5rem; background: #f0f2f5; border: 0; }
.chat-search select { width: auto; border-radius: 1.5rem; background-color: #f0f2f5; border: 0; }
.chat-list { overflow: hidden; }
.chat-item { display: flex; gap: .8rem; align-items: center; padding: .7rem .9rem; text-decoration: none; color: inherit;
  border-bottom: 1px solid #f0f2f5; }
.chat-item:hover { background: #f5f6f6; }
.chat-item-main { flex: 1; min-width: 0; }
.chat-item .name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-item .time { font-size: .74rem; color: #667781; flex-shrink: 0; }
.chat-item.unread .time { color: var(--wa-green); font-weight: 600; }
.chat-item .preview { font-size: .86rem; color: #667781; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-item.unread .preview { color: #111b21; }
.unread-badge { background: var(--wa-green); color: #fff; border-radius: 1rem; min-width: 20px; height: 20px;
  font-size: .72rem; font-weight: 700; display: grid; place-items: center; padding: 0 6px; flex-shrink: 0; }
.chat-item .meta-line { font-size: .72rem; color: #8696a0; display: flex; gap: .35rem; align-items: center;
  flex-wrap: wrap; margin-top: 2px; }
.chat-fab { position: fixed; right: 1rem; bottom: calc(76px + env(safe-area-inset-bottom)); width: 56px; height: 56px;
  border-radius: 1rem; background: var(--wa-green); color: #fff; display: grid; place-items: center; font-size: 1.35rem;
  box-shadow: 0 4px 12px rgba(0,0,0,.25); z-index: 1030; text-decoration: none; }

@media (max-width: 991.98px) {
  .chat-page .content { padding: 0 !important; }
  .chat-page .content > .alert { margin: .5rem; }
  .chat { border-radius: 0; border: 0;
    height: calc(100dvh - 58px - 57px - env(safe-area-inset-bottom) - env(safe-area-inset-top)); }
  .bubble-wa { max-width: 85%; }
}

/* ödeme yöntemi seçimi */
.pay-num { width: 30px; height: 30px; border-radius: 50%; background: #16213a; color: #f2b705; display: grid;
  place-items: center; font-weight: 700; flex-shrink: 0; }
.iban-card { border: 1px solid #e3e7ef; border-radius: .6rem; padding: .65rem .8rem; margin-bottom: .5rem; background: #fafbfc; }
.iban-card code.iban { font-size: .92rem; color: #1d2433; user-select: all; word-break: keep-all; overflow-wrap: normal; }
/* sohbet ekranında ortadaki yuvarlak düğme yazma çubuğunun üstüne taşmasın */
.chat-page .bottom-nav a.bottom-nav-primary i { margin-top: 0; width: 34px; height: 34px; border-width: 0;
  box-shadow: none; font-size: 1.1rem; }

/* banka hesapları / hareketleri */
.min-w-0 { min-width: 0; }
@media (min-width: 768px) { .w-md-auto { width: auto !important; } }
code.iban { color: #1d2433; font-size: .9rem; letter-spacing: .02em; }
.tx-amount { font-variant-numeric: tabular-nums; white-space: nowrap; }
.tx-sender { font-weight: 600; }
.tx-desc { max-width: 340px; }
.badge-tx-MATCHED { background: #d1f0dc; color: #0f6b34; }
.badge-tx-SUGGESTED { background: #fff1c2; color: #7a5600; }
.badge-tx-UNMATCHED { background: #fde0e0; color: #9b1c1c; }
.badge-tx-IGNORED { background: #e9ecef; color: #495057; }
.upload-drop { border: 2px dashed #c9d1e0; border-radius: .7rem; padding: 1rem; background: #fafbfc; }

.code-input { letter-spacing: .5em; font-weight: 700; font-size: 1.6rem; }
.kvkk-text h2 { margin-top: 1.4rem; }
.kvkk-text p, .kvkk-text li { font-size: .95rem; line-height: 1.6; }
.kvkk-banner { position: sticky; top: 0; z-index: 1030; }
