/* Şirket Paneli — tasarım dili DESIGN.md (İnşaat Takibi Blade admin + DESIGN.md tokenlarından türetildi).
   CSP style-src 'self' olduğu için satır içi stil yok; her şey bu dosyada. */
:root {
    --bg: #F3F5F9;
    --surface: #FFFFFF;
    --surface-2: #E9EDF4;
    --border: #DDE3EE;
    --divider: #EEF1F6;
    --text: #0B1F4B;
    --navy: #0B1F4B;
    --navy-hover: #13295E;
    --muted: #5B6B8C;
    --blue: #1E6FF0;
    --blue-soft: #E6EFFD;
    --success: #1F9D55;
    --success-soft: #E7F6EE;
    --warning-text: #B7791F;
    --warning-soft: #FDF3E1;
    --danger: #D64545;
    --danger-soft: #FDECEC;
    /* Metin tonları — soft zeminde ve --bg üzerinde AA (≥ 4.5:1); dolgu/kenarlık için yukarıdakiler. */
    --blue-text: #1558C7;
    --success-text: #177A41;
    --warning-strong: #8A5A12;
    --danger-text: #B02A2A;
    --radius: 14px;
    --radius-card: 16px;
    --side-w: 232px;
    color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
    margin: 0;
    font: 14px/1.5 Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    color: var(--text);
    background: var(--bg);
}
a { color: var(--blue-text); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
h1 { font-size: 22px; margin: 0 0 16px; line-height: 1.25; }
h2 { font-size: 16px; margin: 0 0 12px; }
h3 { font-size: 14px; margin: 0 0 8px; }
p { margin: 0 0 12px; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; word-break: break-all; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip-link { position: absolute; left: -999px; top: 8px; background: var(--surface); padding: 8px 12px; border-radius: 10px; z-index: 10; }
.skip-link:focus { left: 8px; }
a, button, summary, label, input, select, textarea { touch-action: manipulation; }
h1, h2 { text-wrap: balance; }

/* Kabuk */
.shell { display: flex; min-height: 100vh; }
.side { width: var(--side-w); background: var(--navy); color: #fff; padding: 20px 12px; flex-shrink: 0; display: flex; flex-direction: column; }
.brand { font-weight: 800; font-size: 17px; padding: 0 10px 18px; color: #fff; }
.brand small { display: block; font-weight: 500; font-size: 12px; opacity: .75; }
.nav-section { font-size: 11px; letter-spacing: .06em; text-transform: uppercase; opacity: .6; padding: 12px 10px 4px; }
.side nav a { display: flex; align-items: center; min-height: 44px; color: #fff; opacity: .85; padding: 8px 10px; border-radius: 10px; margin-bottom: 2px; }
.side nav a:hover { opacity: 1; text-decoration: none; background: rgba(255, 255, 255, .08); }
.side nav a[aria-current="page"] { opacity: 1; background: var(--blue); }
.side :focus-visible { outline-color: #fff; }
.side-foot { margin-top: auto; padding: 16px 10px 0; }
.side-foot .who { font-size: 12px; opacity: .8; word-break: break-all; margin-bottom: 8px; }
.side-foot button { width: 100%; background: rgba(255, 255, 255, .12); color: #fff; }
.side-foot button:hover { background: rgba(255, 255, 255, .2); }
.side-head { display: flex; align-items: center; justify-content: space-between; }
.menu-toggle { display: none; background: rgba(255, 255, 255, .12); color: #fff; min-height: 44px; min-width: 44px; }
.main { flex: 1; padding: 24px 32px; min-width: 0; }
.main-inner { max-width: 1120px; }

/* Kart ve düzen */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-card); padding: 18px; margin-bottom: 16px; box-shadow: 0 1px 2px rgb(11 31 75 / 5%); }
.card > :last-child { margin-bottom: 0; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-2 > * { min-width: 0; }
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; }
.stat b { display: block; font-size: 24px; font-variant-numeric: tabular-nums; }
.stat span { color: var(--muted); font-size: 12px; }
.page-head { display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; margin-bottom: 16px; }
.page-head h1 { margin: 0; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.stack > * + * { margin-top: 12px; }
dl.facts { display: grid; grid-template-columns: 160px 1fr; gap: 8px 12px; margin: 0; }
dl.facts dt { color: var(--muted); }
dl.facts dd { margin: 0; overflow-wrap: anywhere; }

/* Çip */
.chip { display: inline-block; padding: 2px 8px; border-radius: 6px; font-size: 12px; font-weight: 600; background: var(--blue-soft); color: var(--blue-text); white-space: nowrap; max-width: 100%; overflow-wrap: anywhere; }
.chip-success { background: var(--success-soft); color: var(--success-text); }
.chip-warning { background: var(--warning-soft); color: var(--warning-strong); }
.chip-danger { background: var(--danger-soft); color: var(--danger-text); }
.chip-muted { background: var(--divider); color: var(--muted); }

/* Form */
label { display: block; font-weight: 600; font-size: 14px; margin-bottom: 6px; }
.field { margin-bottom: 14px; }
.field-inline { display: flex; gap: 8px; align-items: flex-end; flex-wrap: wrap; }
.field-inline .field { margin-bottom: 0; flex: 1 1 180px; }
.hint { color: var(--muted); font-size: 13px; margin-top: 4px; font-weight: 400; }
input[type=text], input[type=email], input[type=password], input[type=tel], input[type=date], input[type=search], select, textarea {
    width: 100%; font: inherit; font-size: 16px; min-height: 44px; padding: 10px 12px;
    border: 1px solid var(--border); border-radius: 12px; background: #fff; color: var(--text);
}
textarea { min-height: 88px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--blue); outline-offset: 0; border-color: var(--blue); }
input[aria-invalid="true"] { border-color: var(--danger); }
.otp-input { letter-spacing: .3em; font-variant-numeric: tabular-nums; max-width: 220px; }
.check { display: flex; gap: 10px; align-items: flex-start; font-weight: 400; min-height: 44px; padding: 10px 0; margin: 0; }
.check input { width: 20px; height: 20px; margin: 2px 0 0; flex-shrink: 0; }
.error-text { color: var(--danger-text); font-size: 13px; margin-top: 4px; }

/* Düğme */
button, .button {
    font: inherit; font-weight: 600; min-height: 44px; padding: 10px 16px; border-radius: 12px; border: 0;
    background: var(--blue); color: #fff; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
}
button:hover, .button:hover { text-decoration: none; filter: brightness(.95); }
button:disabled { opacity: .55; cursor: not-allowed; }
.button-primary { background: var(--navy); }
.button-primary:hover { background: var(--navy-hover); filter: none; }
.button-secondary { background: var(--surface); color: var(--text); border: 1px solid var(--border); }
.button-danger { background: var(--danger); }
.button-danger-soft { background: var(--danger-soft); color: var(--danger-text); }
.button-text { background: none; color: var(--blue-text); padding: 10px 4px; min-height: 44px; }
.button-text:hover { filter: none; text-decoration: underline; }
.button-block { width: 100%; }

/* Bildirim */
.notice { padding: 12px 14px; border-radius: 12px; margin-bottom: 16px; background: var(--blue-soft); color: var(--navy); }
.notice-success { background: var(--success-soft); color: #136B3A; }
.notice-warn { background: #FEF5E7; color: #8A5A00; }
.notice-danger { background: var(--danger-soft); color: #A12F2F; }
.notice ul { margin: 0; padding-left: 18px; }
.notice > :last-child { margin-bottom: 0; }

/* Tablo: dar ekranda satırlar karta dönüşür (yatay kaydırma yok — KA13) */
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--divider); vertical-align: top; }
th { font-size: 12px; color: var(--muted); font-weight: 600; }
tbody tr:last-child td { border-bottom: 0; }
td.actions { text-align: right; white-space: nowrap; }
.pager { display: flex; gap: 8px; justify-content: space-between; align-items: center; margin-top: 12px; flex-wrap: wrap; }

/* Kimlik sayfaları (giriş, davet, sıfırlama) */
.auth-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px 16px; }
.auth-card { width: 100%; max-width: 420px; background: var(--surface); border: 1px solid var(--border); border-radius: 20px; padding: 28px; box-shadow: 0 1px 2px rgb(11 31 75 / 5%); }
.auth-brand { font-weight: 800; font-size: 18px; margin-bottom: 4px; }
h1.auth-sub { color: var(--muted); font-size: 14px; font-weight: 400; line-height: 1.5; margin: 0 0 20px; }
.qr { display: flex; justify-content: center; margin: 8px 0 12px; }
.qr svg { width: 220px; height: 220px; background: #fff; }
.codes { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; list-style: none; padding: 0; margin: 0 0 16px; }
.codes li { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 15px; background: var(--bg); border: 1px solid var(--border); border-radius: 10px; padding: 8px; text-align: center; }
details summary { cursor: pointer; color: var(--blue-text); font-weight: 600; min-height: 44px; display: flex; align-items: center; }
.danger-zone { border-color: #F3C6C6; }

@media (max-width: 860px) {
    .shell { flex-direction: column; }
    .side { width: auto; padding: 8px 12px; }
    .brand { padding: 8px 4px; }
    .menu-toggle { display: inline-flex; }
    .side nav, .side-foot { display: none; }
    .side.open nav, .side.open .side-foot { display: block; }
    .side-foot { padding: 12px 4px 8px; }
    .main { padding: 16px; }
    .grid-2 { grid-template-columns: 1fr; }
    dl.facts { grid-template-columns: 1fr; gap: 2px 0; }
    dl.facts dd { margin-bottom: 8px; }
}

@media (max-width: 640px) {
    table.responsive thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
    table.responsive, table.responsive tbody, table.responsive tr, table.responsive td { display: block; width: 100%; }
    table.responsive tr { border-bottom: 1px solid var(--divider); padding: 8px 0; }
    table.responsive tbody tr:last-child { border-bottom: 0; }
    table.responsive td { border: 0; padding: 4px 0; overflow-wrap: anywhere; min-width: 0; display: flex; flex-wrap: wrap; gap: 4px 12px; justify-content: space-between; align-items: baseline; text-align: right; }
    table.responsive td > * { min-width: 0; }
    table.responsive td .row { justify-content: flex-end; }
    table.responsive td::before { content: attr(data-label); color: var(--muted); font-size: 12px; font-weight: 600; text-align: left; flex-shrink: 0; }
    table.responsive td.actions { justify-content: flex-end; }
    table.responsive td.actions::before { content: none; }
    .auth-card { padding: 20px; }
    .codes { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
    * { transition: none !important; animation: none !important; }
}
[x-cloak] { display: none !important; }
.grid-2 { margin-bottom: 16px; }
.grid-2 > .card { margin-bottom: 0; }
.card form.row, .card > form + form { margin-top: 12px; }
fieldset { border: 0; padding: 0; margin: 0 0 14px; min-width: 0; } legend { padding: 0; margin-bottom: 6px; }

/* ---- Muhasebe (Aşama 1b) ---- */
input[type=file] { width: 100%; font: inherit; font-size: 16px; min-height: 44px; padding: 8px; border: 1px dashed var(--border); border-radius: 12px; background: #fff; color: var(--text); }
td.amount, th.amount { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.entity-bar { display: flex; gap: 8px 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; margin-bottom: 16px; padding: 10px 14px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.entity-bar form { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: 0; }
.entity-bar select { width: auto; max-width: 100%; min-width: 0; }
.filters { display: flex; gap: 8px; align-items: flex-end; flex-wrap: wrap; margin-bottom: 12px; }
.filters input, .filters select, .filters button, .filters .button { min-height: 44px; }
.filters label { min-height: 20px; }
.filters .field { margin: 0; flex: 1 1 160px; }
.form-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0 16px; }
.form-grid .span-2 { grid-column: span 2; }
.form-grid .span-3 { grid-column: 1 / -1; }
.line { border: 1px solid var(--border); border-radius: 12px; padding: 12px; margin-bottom: 10px; display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr) minmax(0, 1fr) minmax(0, 1.4fr) minmax(0, 1fr); gap: 0 10px; align-items: end; }
.line .field { margin-bottom: 8px; display: flex; flex-direction: column; justify-content: flex-end; height: 100%; }
.line .field label { min-height: 20px; }
.line legend { font-size: 12px; color: var(--muted); font-weight: 600; }
.line .line-foot { grid-column: 1 / -1; display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; align-items: center; }
.line .check { min-height: 32px; padding: 4px 0; }
.totals { display: grid; grid-template-columns: auto auto; gap: 4px 16px; justify-content: end; margin: 0; }
.totals dt { color: var(--muted); text-align: right; }
.totals dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }
.totals .grand { font-weight: 700; font-size: 16px; }
.actions-bar { display: flex; gap: 8px; flex-wrap: wrap; align-items: flex-start; }
.actions-bar > form, .actions-bar > details { margin: 0; }
.actions-bar details[open] { flex-basis: 100%; }
.decision { border-top: 1px solid var(--divider); padding-top: 12px; margin-top: 12px; }
.doc-list { list-style: none; padding: 0; margin: 0 0 12px; display: grid; gap: 12px; }
.doc-list li { border: 1px solid var(--border); border-radius: 12px; padding: 10px; }
.doc-head { display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; align-items: center; }
.doc-preview { display: block; width: 100%; margin-top: 8px; border: 1px solid var(--divider); border-radius: 8px; background: var(--bg); }
img.doc-preview { height: auto; max-height: 480px; object-fit: contain; }
iframe.doc-preview { height: 520px; }
.warn-inline { color: var(--warning-text); font-weight: 600; }
.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li { padding: 8px 0; border-bottom: 1px solid var(--divider); display: flex; gap: 4px 12px; flex-wrap: wrap; }
.timeline li:last-child { border-bottom: 0; }
.timeline .when { color: var(--muted); font-variant-numeric: tabular-nums; min-width: 128px; }
.quote { margin: 6px 0 0; padding: 8px 10px; background: var(--bg); border-radius: 8px; white-space: pre-line; overflow-wrap: anywhere; }
.inbox-item { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px 16px; padding: 12px 0; border-bottom: 1px solid var(--divider); align-items: center; }
.inbox-item:last-child { border-bottom: 0; }
.inbox-item .meta { color: var(--muted); font-size: 13px; }
.inbox-item a.title { font-weight: 600; }
.subtle-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; flex-wrap: wrap; }

@media (max-width: 860px) {
    .form-grid { grid-template-columns: minmax(0, 1fr); }
    .form-grid .span-2 { grid-column: auto; }
    .line { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
    .line .line-desc { grid-column: 1 / -1; }
    .totals { justify-content: stretch; grid-template-columns: 1fr auto; }
    .totals dt { text-align: left; }
    iframe.doc-preview { display: none; }
}
@media (max-width: 640px) {
    td.amount { text-align: right; }
    .inbox-item { grid-template-columns: minmax(0, 1fr); }
}
[hidden] { display: none !important; }
.actions-bar:not(:has(*)) { display: none; }
.actions-bar:not(:has(*)) + .decision { border-top: 0; padding-top: 0; margin-top: 0; }
.inline-form { display: inline; margin: 0; }

/* ---- Muhasebe raporları, dönemler, dışa aktarma (Aşama 1b, 2. dilim) ---- */
.report-nav { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 12px; border-bottom: 1px solid var(--border); }
.report-nav a { display: inline-flex; align-items: center; min-height: 44px; padding: 8px 12px; color: var(--muted); font-weight: 600; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.report-nav a:hover { text-decoration: none; color: var(--text); }
.report-nav a[aria-current="page"] { color: var(--blue-text); border-bottom-color: var(--blue); }
.scope-switch { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
tfoot td { border-top: 1px solid var(--border); border-bottom: 0; font-weight: 600; }
td.overdue { color: var(--warning-text); font-weight: 600; }
table.aging th, table.aging td { padding-left: 6px; padding-right: 6px; }
.period-list { list-style: none; padding: 0; margin: 0; }
.period-head { display: flex; gap: 8px; align-items: center; justify-content: space-between; flex-wrap: wrap; margin-bottom: 8px; }
.period-head h2 { margin: 0; }
.period .actions-bar { margin-top: 12px; }
.period .lock-form { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; margin: 0; }
.period .lock-form .check { padding: 4px 0; }
.period.is-highlight { border-color: var(--blue); box-shadow: 0 0 0 2px var(--blue-soft); }
.period-history { margin-top: 8px; }
.print-only { display: none; }

@media (max-width: 1100px) and (min-width: 641px) {
    table.aging { font-size: 12px; }
    table.aging td.amount, table.aging th.amount { white-space: normal; }
}
@media (max-width: 640px) {
    table.responsive tfoot { display: block; width: 100%; }
    table.responsive tfoot tr { border-top: 1px solid var(--border); border-bottom: 0; padding-top: 8px; }
    table.responsive tfoot td { border: 0; }
}

/* Yazdırma (rapor sayfaları): menü, süzgeç ve düğmeler gizlenir; kartlar düz. */
@media print {
    @page { margin: 12mm; }
    body { background: #fff; font-size: 11px; }
    .side, .skip-link, .no-print, .entity-bar form, .notice-success, .pager { display: none !important; }
    .shell { display: block; }
    .main { padding: 0; }
    .main-inner { max-width: none; }
    .card { box-shadow: none; border: 0; padding: 0; margin-bottom: 12px; break-inside: avoid; }
    .grid-2 { display: block; }
    .print-only { display: block; color: var(--muted); }
    a { color: inherit; }
    table.responsive { display: table; }
    table.responsive thead { display: table-header-group; position: static; width: auto; height: auto; overflow: visible; clip: auto; }
    table.responsive tbody { display: table-row-group; }
    table.responsive tfoot { display: table-footer-group; }
    table.responsive tr { display: table-row; }
    table.responsive td { display: table-cell; text-align: inherit; }
    table.responsive td.amount { text-align: right; }
    table.responsive td::before { content: none; }
    th, td { padding: 4px 6px; }
}
.break-anywhere { overflow-wrap: anywhere; word-break: break-word; }
.section-gap { margin-top: 16px; }

/* Dokunma alanı (beta tasarım taraması 04.10): tek başına duran küçük metin bağlantıları ≥ 44 px. */
.link-line, p.small > a:only-child, .auth-card p.small a { display: inline-flex; align-items: center; min-height: 44px; }
.link-line { margin-top: 8px; }
.brand small { margin-top: 2px; }
.muted-empty { color: var(--muted); text-align: center; padding: 16px 8px; }
.cell-stack { display: inline-flex; flex-direction: column; gap: 2px; align-items: flex-start; }
@media (max-width: 640px) { .cell-stack { align-items: flex-end; } }
.period-older { margin-top: 12px; }
.period-older > .period-list { margin-top: 12px; }
