:root {
  --red: #D70F19;
  --red-dark: #A80A12;
  --red-tint: #FCEBEC;
  --ink: #000000;
  --ink-2: #3D4046;
  --muted: #6B6F76;
  --line: #DCDEE1;
  --surface: #F2F3F5;
  --paper: #FFFFFF;
  --ok: #1D6B3A;
  --serif: "Source Serif 4", "Times New Roman", Georgia, serif;
  --sans: "IBM Plex Sans", "Segoe UI", system-ui, -apple-system, sans-serif;
  --radius: 4px;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: var(--sans); font-size: 15px; line-height: 1.5; color: var(--ink); background: var(--paper); -webkit-font-smoothing: antialiased; }
[hidden] { display: none !important; }
h1 { font-family: var(--serif); font-weight: 600; font-size: 2rem; line-height: 1.15; margin: 1.25rem 0 .5rem; letter-spacing: -.01em; }
h2 { font-family: var(--serif); font-weight: 600; font-size: 1.25rem; margin: 0; }
.lead { color: var(--ink-2); margin: 0 0 1.75rem; max-width: 40ch; }
.fine, .hint { color: var(--muted); font-size: .8125rem; }
.hint { margin: -.25rem 0 .75rem; }
:focus-visible { outline: 2px solid var(--red); outline-offset: 2px; }

/* Formlar */
label { display: block; font-size: .8125rem; font-weight: 500; color: var(--ink-2); margin-bottom: .3rem; }
input, select { font: inherit; width: 100%; height: 42px; padding: 0 .75rem; border: 1px solid var(--line); border-radius: var(--radius); background: var(--paper); color: var(--ink); }
input:focus, select:focus { border-color: var(--ink); outline: none; box-shadow: 0 0 0 3px rgba(215, 15, 25, .15); }
form > input { margin-bottom: 1rem; }
.form-error { color: var(--red); font-size: .875rem; min-height: 1.25rem; margin: .25rem 0 .5rem; flex-basis: 100%; }
.form-error:empty { min-height: 0; margin: 0; }

.btn { font: inherit; font-weight: 500; display: inline-flex; align-items: center; justify-content: center; gap: .5rem; height: 42px; padding: 0 1.1rem; border-radius: var(--radius); border: 1px solid transparent; cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn-primary { background: var(--red); color: #fff; }
.btn-primary:hover { background: var(--red-dark); }
.btn-primary[disabled] { background: #C9CBCF; cursor: progress; }
.btn-outline { background: var(--paper); border-color: var(--ink); color: var(--ink); }
.btn-outline:hover { background: var(--ink); color: #fff; }
.btn-outline[aria-disabled="true"] { border-color: var(--line); color: #A3A6AB; pointer-events: none; }
.btn-ghost { background: none; color: var(--ink-2); }
.btn-ghost:hover { color: var(--red); }
.btn-block { width: 100%; margin-top: .25rem; }

/* Giriş */
.login { min-height: 100vh; display: grid; grid-template-columns: minmax(340px, 480px) 1fr; }
.login-form { padding: 64px clamp(24px, 6vw, 72px); display: flex; flex-direction: column; justify-content: center; }
.login-logo { width: 214px; height: auto; }
.login-form .fine { margin-top: 2rem; max-width: 46ch; }
.login-art { background: var(--ink); overflow: hidden; }
.login-art svg { width: 100%; height: 100%; display: block; }
.narrow { max-width: 420px; margin: 0 auto; padding: 64px 24px; }
.narrow img { width: 171px; height: auto; }

/* Üst çubuk */
.topbar { border-bottom: 1px solid var(--line); background: var(--paper); position: sticky; top: 0; z-index: 5; }
.topbar::before { content: ""; display: block; height: 4px; background: var(--red); }
.topbar-inner { max-width: 1240px; margin: 0 auto; padding: 14px 24px 6px; display: flex; align-items: center; gap: 24px; }
.top-logo { width: 150px; height: auto; }
.who { margin-left: auto; text-align: right; line-height: 1.25; }
.who-name { display: block; font-weight: 600; }
.who-acc { display: block; color: var(--muted); font-size: .8125rem; }
.tabs { max-width: 1240px; margin: 0 auto; padding: 0 24px; display: flex; gap: 4px; overflow-x: auto; }
.tabs button { font: inherit; font-weight: 500; background: none; border: 0; border-bottom: 3px solid transparent; padding: 12px 14px 10px; color: var(--muted); cursor: pointer; white-space: nowrap; }
.tabs button:hover { color: var(--ink); }
.tabs button[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--red); }

.content { max-width: 1240px; margin: 0 auto; padding: 28px 24px 48px; }
.toolbar { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px 16px; margin-bottom: 20px; }
.toolbar .field { min-width: 170px; }
.toolbar-end { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }
.empty { border: 1px dashed var(--line); border-radius: var(--radius); padding: 40px 24px; color: var(--muted); text-align: center; background: var(--surface); }
.foot { max-width: 1240px; margin: 0 auto; padding: 16px 24px 32px; color: var(--muted); font-size: .8125rem; border-top: 1px solid var(--line); }

/* Bakiye */
.balance { display: grid; grid-template-columns: 1.4fr 1fr; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.balance-main { padding: 32px; border-right: 1px solid var(--line); }
.balance-date { color: var(--muted); margin: 0; }
.balance-amount { font-family: var(--serif); font-weight: 600; font-size: clamp(2.5rem, 5vw, 3.75rem); line-height: 1.05; margin: .5rem 0; font-variant-numeric: tabular-nums lining-nums; letter-spacing: -.02em; }
.balance-amount small { font-family: var(--sans); font-size: 1rem; font-weight: 500; color: var(--muted); margin-left: .4rem; letter-spacing: 0; }
.balance-side { margin: 0; font-weight: 500; }
.balance-side.debt { color: var(--red); }
.balance-side.zero { color: var(--ok); }
.balance-facts { margin: 0; padding: 32px; display: grid; gap: 16px; background: var(--surface); }
.balance-facts div { display: flex; justify-content: space-between; gap: 16px; border-bottom: 1px solid var(--line); padding-bottom: 12px; }
.balance-facts div:last-child { border: 0; padding: 0; }
.balance-facts dt { color: var(--ink-2); }
.balance-facts dd { margin: 0; font-weight: 600; font-variant-numeric: tabular-nums; }

.balance-list { list-style: none; margin: .5rem 0 0; padding: 0; }
.balance-list li { padding: .5rem 0; border-bottom: 1px solid var(--line); }
.balance-list li:last-child { border-bottom: 0; }
.balance-list .balance-amount { display: block; margin: 0; font-size: clamp(2rem, 4vw, 3rem); }
.balance-list .balance-side { font-size: .875rem; }
.note { border-left: 3px solid var(--red); background: var(--red-tint); padding: 8px 12px; font-size: .875rem; margin: 12px 0; }
.st-cur { margin: 0 0 10px; color: var(--ink-2); }
.toolbar .field-cur { min-width: 140px; }
td.bp { color: var(--ink-2); background: var(--surface); }
.st-table { font-size: .8125rem; }
.st-table th, .st-table td { padding: 8px 8px; }
.st-table th { white-space: normal; line-height: 1.25; }
.st-table td:nth-child(1), .st-table td:nth-child(2), .st-table td:nth-child(7) { white-space: nowrap; }
.st-table td:nth-child(4) { min-width: 120px; }
.st-table td.text { min-width: 150px; }

/* Tablolar */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; font-size: .875rem; }
th { text-align: left; font-weight: 600; background: var(--ink); color: #fff; padding: 10px 12px; white-space: nowrap; position: sticky; top: 0; }
td { padding: 9px 12px; border-top: 1px solid var(--line); vertical-align: top; }
tbody tr:hover td { background: #FAFAFA; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
td.text { min-width: 220px; }
tr.opening td { font-style: italic; color: var(--ink-2); background: var(--surface); }
tfoot td { font-weight: 600; border-top: 2px solid var(--ink); background: var(--paper); }
.neg { color: var(--red); }
.ba { color: var(--muted); font-size: .75rem; margin-left: .25rem; }

.stat-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0; border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 28px; }
.stat { padding: 16px 20px; border-right: 1px solid var(--line); }
.stat:last-child { border-right: 0; }
.stat dt { color: var(--muted); font-size: .8125rem; }
.stat dd { margin: .25rem 0 0; font-family: var(--serif); font-size: 1.5rem; font-weight: 600; font-variant-numeric: tabular-nums; }

/* Mutabakat */
.drop { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; border: 1.5px dashed #B9BCC1; border-radius: var(--radius); padding: 28px; margin-bottom: 20px; cursor: pointer; text-align: center; background: var(--surface); }
.drop:hover, .drop.over { border-color: var(--red); background: var(--red-tint); }
.drop input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.drop:focus-within { outline: 2px solid var(--red); outline-offset: 2px; }
.drop-title { font-weight: 600; }
.drop-sub { color: var(--muted); font-size: .8125rem; }
.verdict { display: flex; gap: 20px; align-items: baseline; flex-wrap: wrap; padding: 20px 24px; border-left: 4px solid var(--red); background: var(--surface); margin-bottom: 20px; }
.verdict.ok { border-left-color: var(--ok); }
.verdict h2 { font-size: 1.375rem; }
.verdict p { margin: 0; color: var(--ink-2); flex-basis: 100%; }
.diff-block { margin-top: 32px; }
.diff-head { display: flex; align-items: baseline; gap: 12px; margin-bottom: 4px; }
.diff-head .count { font-family: var(--serif); font-size: 1.25rem; color: var(--red); font-weight: 600; }
.diff-desc { color: var(--muted); margin: 0 0 12px; font-size: .875rem; max-width: 80ch; }
.diff-none { padding: 14px 16px; border: 1px solid var(--line); border-radius: var(--radius); color: var(--ok); font-weight: 500; }
.side-label { display: block; font-size: .75rem; color: var(--muted); }
details.matched { margin-top: 32px; }
details.matched summary { cursor: pointer; font-weight: 500; padding: 8px 0; }
.spinner { width: 16px; height: 16px; border: 2px solid rgba(255,255,255,.5); border-top-color: #fff; border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 860px) {
  .login { grid-template-columns: 1fr; }
  .login-art { display: none; }
  .balance { grid-template-columns: 1fr; }
  .balance-main { border-right: 0; border-bottom: 1px solid var(--line); }
  .stat-row { grid-template-columns: repeat(2, 1fr); }
  .stat:nth-child(2) { border-right: 0; }
  .stat:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
  .toolbar-end { margin-left: 0; }
  .topbar-inner { gap: 12px; }
  .who-acc { display: none; }
}
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 3s; } }
@media print { .topbar, .toolbar, .foot, .drop { display: none; } }

/* Yönetim (belge türleri düzenleyicisi; web ve masaüstü ortak) */
.admin-page { max-width: 900px; }
.admin-page h2 { margin-bottom: .5rem; }
.help { color: var(--muted); font-size: .875rem; margin: 0 0 .75rem; max-width: 70ch; }
.msg { font-size: .875rem; min-height: 1.25rem; margin: .5rem 0; }
.msg.ok { color: var(--ok); } .msg.err { color: var(--red); }
.actions { display: flex; gap: 8px; flex-wrap: wrap; margin: 1rem 0; }
.dt-table td { vertical-align: middle; }
.dt-table input { height: 34px; }
.dt-table .dt-c1 { width: 110px; } .dt-table .dt-c3 { width: 130px; } .dt-table .dt-c4 { width: 70px; }
.dt-table .dt-code { text-transform: uppercase; }
.dt-missing { margin: 0 0 .75rem; font-size: .875rem; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.dt-missing .btn { height: 28px; font-size: .8125rem; padding: 0 8px; }
@media (min-width: 1400px) { #panel-statement .table-wrap { margin-inline: -80px; } }

/* Şirket seçimi */
.company-pick { display: flex; flex-direction: column; min-width: 260px; max-width: 380px; flex: 1; }
.company-pick label { margin-bottom: .15rem; font-size: .75rem; color: var(--muted); }
.company-pick select { height: 36px; font-weight: 600; border-color: var(--ink); }

/* gg/aa/yyyy tarih alanı */
.date-field { position: relative; }
.date-field .date-input { padding-right: 42px; font-variant-numeric: tabular-nums; }
.date-pick { position: absolute; right: 1px; top: 1px; height: 40px; width: 40px; border: 0; background: none; color: var(--ink-2); cursor: pointer; display: grid; place-items: center; border-radius: 0 var(--radius) var(--radius) 0; }
.date-pick:hover { color: var(--red); }
.date-native { position: absolute; right: 0; bottom: 0; width: 1px; height: 1px; opacity: 0; pointer-events: none; border: 0; padding: 0; }

/* Mutabakat formu */
.letter-box { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 20px; border: 1px solid var(--line); border-left: 4px solid var(--ok); border-radius: var(--radius); padding: 16px 20px; margin: 20px 0; }
.letter-box .fine { flex-basis: 100%; margin: 0; }
.check { display: flex; align-items: center; gap: 10px; font-size: .9375rem; font-weight: 500; color: var(--ink); margin: 0; cursor: pointer; }
.check input { width: 18px; height: 18px; margin: 0; accent-color: var(--red); }
.btn-primary[aria-disabled="true"] { background: #C9CBCF; pointer-events: none; }
.note.info { border-left-color: var(--ink-2); background: var(--surface); }
@media (max-width: 860px) { .company-pick { min-width: 0; } .company-pick label { display: none; } }

/* Şirket yönetimi */
.co-card { border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; margin-bottom: 12px; }
.co-head { display: flex; gap: 10px; align-items: center; margin-bottom: 12px; }
.co-code { font-family: var(--serif); font-weight: 600; font-size: 1.25rem; min-width: 56px; }
.co-head .co-name { height: 38px; font-weight: 500; }
.co-slots { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.co-slot-title { display: block; font-size: .8125rem; font-weight: 500; color: var(--ink-2); margin-bottom: 4px; }
.co-img { height: 110px; border: 1px dashed #B9BCC1; border-radius: var(--radius); display: grid; place-items: center; background: var(--surface); overflow: hidden; }
.co-img img { max-width: 100%; max-height: 104px; object-fit: contain; }
.co-img span { color: var(--muted); font-size: .8125rem; }
.co-slot-actions { display: flex; gap: 6px; margin-top: 6px; }
.co-slot-actions .btn { height: 32px; font-size: .8125rem; padding: 0 10px; }
.co-file { position: relative; margin: 0; color: var(--ink); }
.co-file input { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%; }
.co-add { display: flex; gap: 10px; align-items: flex-end; margin-top: 8px; }
.co-add > div { min-width: 120px; } .co-add .grow { flex: 1; }
.co-add input { height: 38px; }
.co-add label { margin: 0 0 .2rem; }
@media (max-width: 640px) { .co-slots { grid-template-columns: 1fr; } }

.admin-page .sec2 { margin-top: 2.5rem; }
.balance-facts { align-content: start; }
