:root {
  --bg: #f5f7f6; --card: #fff; --text: #1d2523; --muted: #66726f; --line: #e2e7e5;
  --primary: #1f6f5c; --primary-2: #e6f2ee; --danger: #c0392b; --danger-2: #fbeae8;
  --warn: #b7791f; --warn-2: #fdf3e1; --ok: #2e7d32; --ok-2: #e8f4e9;
  --radius: 12px; --shadow: 0 1px 2px rgba(0,0,0,.05), 0 2px 8px rgba(0,0,0,.04);
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111615; --card: #1a201f; --text: #e6ecea; --muted: #94a19d; --line: #2a3331;
    --primary: #4cb79a; --primary-2: #1d3530; --danger: #ef6b5e; --danger-2: #3a1f1c;
    --warn: #e0a84a; --warn-2: #3a2e18; --ok: #6cc070; --ok-2: #1d3220;
    --shadow: none;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--primary); }
h1 { font-size: 1.45rem; margin: 0 0 4px; }
h2 { font-size: 1.1rem; margin: 24px 0 10px; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }

.layout { display: flex; min-height: 100vh; }
.topbar { display: none; }
.nav { width: 240px; flex-shrink: 0; background: var(--card); border-right: 1px solid var(--line);
  padding: 14px 10px; position: sticky; top: 0; height: 100vh; overflow-y: auto; display: flex; flex-direction: column; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 1.1rem; padding: 4px 10px 12px; }
.brand img { width: 32px; height: 32px; }
#nav-links { display: flex; flex-direction: column; gap: 1px; }
.nav a { display: flex; gap: 10px; align-items: center; padding: 7px 12px; border-radius: 9px; text-decoration: none; color: var(--text); font-size: .93rem; }
.nav a i { font-style: normal; width: 20px; text-align: center; }
.nav a:hover { background: var(--primary-2); }
.nav a.active { background: var(--primary); color: #fff; }
.nav-title { font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); padding: 14px 12px 4px; }
#site-select { margin: 2px 4px 6px; width: calc(100% - 8px); font-weight: 600; }
.nav-user { margin-top: 16px; padding: 10px 12px; border-top: 1px solid var(--line); font-size: .88rem; }
#scrim { display: none; }
.main { flex: 1; padding: 24px 28px 40px; max-width: 1280px; min-width: 0; }

@media (max-width: 860px) {
  .topbar { display: flex; align-items: center; gap: 10px; position: sticky; top: 0; z-index: 30; background: var(--card);
    border-bottom: 1px solid var(--line); padding: 8px 12px; padding-top: calc(8px + env(safe-area-inset-top)); }
  .layout { display: block; }
  .nav { position: fixed; left: 0; top: 0; bottom: 0; z-index: 50; width: 280px; max-width: 85vw; transform: translateX(-105%);
    transition: transform .2s ease; box-shadow: 0 0 30px rgba(0,0,0,.25); padding-top: calc(14px + env(safe-area-inset-top)); }
  body.menu-open .nav { transform: none; }
  body.menu-open #scrim { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 40; }
  .main { padding: 14px 14px 60px; }
}
body.auth .topbar, body.auth .nav { display: none !important; }
body.auth .main { display: flex; justify-content: center; align-items: flex-start; padding-top: 10vh; max-width: none; }
.login { width: min(400px, 100%); padding: 24px; }
.login h2 { margin-top: 4px; }
.err { background: var(--danger-2); color: var(--danger); border-radius: 8px; padding: 8px 10px; margin-bottom: 10px; font-size: .9rem; }

.head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: var(--card); color: var(--text);
  padding: 8px 14px; border-radius: 9px; cursor: pointer; font: inherit; text-decoration: none; }
.btn:hover { border-color: var(--primary); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.danger { color: var(--danger); }
.btn.sm { padding: 4px 10px; font-size: .85rem; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }

.grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.stat .label { color: var(--muted); font-size: .85rem; }
.stat .value { font-size: 1.45rem; font-weight: 700; margin-top: 2px; font-variant-numeric: tabular-nums; }
.stat .sub { color: var(--muted); font-size: .8rem; }
.stat.bad .value { color: var(--danger); }
.stat.good .value { color: var(--ok); }
.bar { height: 6px; border-radius: 3px; background: var(--line); overflow: hidden; margin-top: 8px; }
.bar > i { display: block; height: 100%; background: var(--primary); }

.list { display: flex; flex-direction: column; gap: 8px; }
.row { display: flex; align-items: center; gap: 12px; background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 10px 14px; }
.row .main-col { flex: 1; min-width: 0; }
.row .title { font-weight: 600; overflow-wrap: anywhere; }
.row .meta { color: var(--muted); font-size: .85rem; }
.row .amount { font-weight: 700; text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.row .amount.in { color: var(--ok); }
.row .actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
@media (max-width: 560px) {
  .row { flex-wrap: wrap; }
  .row .actions { width: 100%; justify-content: flex-start; }
}

.badge { display: inline-block; font-size: .72rem; font-weight: 600; padding: 2px 8px; border-radius: 99px; white-space: nowrap; }
.badge.gecikti { background: var(--danger-2); color: var(--danger); }
.badge.bekliyor { background: var(--warn-2); color: var(--warn); }
.badge.kismi { background: var(--warn-2); color: var(--warn); }
.badge.odendi { background: var(--ok-2); color: var(--ok); }
.badge.kind { background: var(--primary-2); color: var(--primary); }

.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.filters select, .filters input { width: auto; }
input, select, textarea { width: 100%; font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--line);
  border-radius: 8px; padding: 8px 10px; }
textarea { min-height: 64px; resize: vertical; }
label.field { display: block; margin-bottom: 10px; font-size: .88rem; color: var(--muted); }
label.field > input, label.field > select, label.field > textarea { margin-top: 4px; color: var(--text); }
label.check { display: flex; gap: 8px; align-items: center; margin-bottom: 10px; }
label.check input { width: auto; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }

dialog { border: 0; border-radius: 16px; padding: 0; width: min(520px, calc(100vw - 24px)); background: var(--card); color: var(--text);
  box-shadow: 0 10px 40px rgba(0,0,0,.25); }
dialog::backdrop { background: rgba(0,0,0,.4); }
dialog form { padding: 18px 20px; max-height: 85vh; overflow: auto; }
dialog h3 { margin: 0 0 14px; }
dialog .btn-row { justify-content: flex-end; margin-top: 8px; }
.hint { background: var(--primary-2); border-radius: 8px; padding: 8px 10px; font-size: .85rem; margin-bottom: 10px; }

.toast { position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%); background: var(--text); color: var(--bg);
  padding: 10px 16px; border-radius: 10px; z-index: 100; max-width: 90vw; }
.empty { text-align: center; padding: 28px 12px; color: var(--muted); border: 1px dashed var(--line); border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); }
th { color: var(--muted); font-weight: 600; font-size: .85rem; }
td.num, th.num { text-align: right; }
.table-wrap { overflow-x: auto; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); }
.chart { display: flex; align-items: flex-end; gap: 6px; height: 160px; padding: 10px 4px 0; }
.chart .col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; height: 100%; justify-content: flex-end; }
.chart .bars { display: flex; gap: 2px; align-items: flex-end; height: 100%; width: 100%; justify-content: center; }
.chart .b { width: 40%; max-width: 16px; border-radius: 3px 3px 0 0; min-height: 1px; }
.chart .b.in { background: var(--ok); } .chart .b.out { background: var(--danger); }
.chart .m { font-size: .7rem; color: var(--muted); }
.legend { display: flex; gap: 14px; font-size: .8rem; color: var(--muted); margin-top: 6px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 4px; vertical-align: -1px; }
@media (max-width: 560px) {
  .grid { grid-template-columns: 1fr 1fr; gap: 8px; }
  .stat .value { font-size: 1.1rem; }
  .card { padding: 12px; }
}

dialog.wide { width: min(760px, calc(100vw - 24px)); }
dialog h4 { margin: 12px 0 6px; font-size: .9rem; }
fieldset.field { border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; margin: 0 0 10px; }
fieldset.field legend { padding: 0 4px; }
fieldset.checks { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 2px 10px; color: var(--text); }
fieldset.checks .check { margin: 2px 0; font-size: .88rem; }
.weights { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 6px 10px; }
.weights label { color: var(--muted); }
input.mini { width: 110px; padding: 5px 8px; text-align: right; }
.hint.warn { background: var(--warn-2); }
.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 960px) { .cols { grid-template-columns: 1fr; } }
.hbar { display: grid; grid-template-columns: 1fr auto; gap: 2px 8px; font-size: .88rem; margin-bottom: 8px; }
.hbar .bar { grid-column: 1 / -1; margin-top: 0; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 14px; overflow-x: auto; }
.tabs a { padding: 8px 12px; text-decoration: none; color: var(--muted); border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs a.active { color: var(--primary); border-color: var(--primary); font-weight: 600; }
table.matrix th, table.matrix td { white-space: nowrap; font-size: .85rem; padding: 6px 8px; }
table.matrix td:first-child, table.matrix th:first-child { position: sticky; left: 0; background: var(--card); }
td.actions-cell { white-space: nowrap; text-align: right; }
td.actions-cell .btn { margin-left: 2px; }
a.card.link { text-decoration: none; color: var(--text); display: block; }
a.card.link:hover { border-color: var(--primary); }
.badge:not(.kind):not(.gecikti):not(.bekliyor):not(.kismi):not(.odendi) { background: var(--line); color: var(--muted); }
tfoot th { border-top: 2px solid var(--line); }
@media (max-width: 560px) { input.mini { width: 84px; } .filters input, .filters select { flex: 1 1 140px; } }
@media print {
  .nav, .topbar, .no-print, .btn-row, .toast, #scrim { display: none !important; }
  body, .card, .table-wrap { background: #fff !important; color: #000 !important; box-shadow: none !important; }
  .main { padding: 0; max-width: none; }
}
.brand em { font-style: normal; color: #d99a1e; }
.top-logo { width: 26px; height: 26px; }
.login-logo { display: block; width: 100%; max-width: 320px; margin: 0 auto 8px; }
@media (prefers-color-scheme: dark) { .login-logo { filter: brightness(1.25); } }

/* Telefon: iOS 16 px altındaki kutulara odaklanınca sayfayı büyütür ve geri küçültmez */
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body { overflow-x: hidden; }
.layout, .main, .card, .head > div, .filters > * { min-width: 0; }
img, svg, video { max-width: 100%; }
@media (max-width: 860px), (pointer: coarse) {
  input, select, textarea { font-size: 16px; }
  input.mini { padding: 6px 8px; }
  .head h1 { overflow-wrap: anywhere; }
  .two { grid-template-columns: 1fr; }
}

/* Sayaç fotoğrafı */
.photo-col { text-align: center; white-space: nowrap; }
button.thumb { border: 1px solid var(--line); border-radius: 8px; padding: 0; background: none; cursor: pointer; width: 52px; height: 40px; overflow: hidden; vertical-align: middle; }
button.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
img.meter-photo { display: block; width: 100%; max-height: 70vh; object-fit: contain; border-radius: 10px; background: var(--bg); margin-bottom: 12px; }
@media (max-width: 560px) {
  .hide-sm { display: none; }
  table.meters th, table.meters td { padding: 6px 4px; }
  table.meters input.mini { width: 64px; }
  table.meters .photo-col { width: 1%; }
}
