:root {
  --bg: #f3f5f8; --card: #fff; --ink: #1b263b; --muted: #6b7686; --line: #e1e6ed;
  --brand: #1d3557; --brand2: #457b9d; --ok: #2a9d8f; --warn: #e9a23b; --bad: #d64545;
  --radius: 10px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font-family: "Segoe UI", system-ui, -apple-system, Arial, sans-serif; color: var(--ink); background: var(--bg); font-size: 14px; }
a { color: var(--brand2); }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.error { color: var(--bad); min-height: 18px; margin: 6px 0; }

/* giriş */
.login { min-height: 100%; display: grid; place-items: center; background: linear-gradient(135deg, #1d3557, #457b9d); }
.login-card { width: 340px; padding: 28px; }
.login-card h1 { margin: 0; color: var(--brand); }
.login-card .btn { width: 100%; margin-top: 8px; }

/* yerleşim */
.shell { display: flex; min-height: 100%; }
aside { width: 220px; background: var(--brand); color: #fff; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; flex-shrink: 0; }
.brand { font-weight: 700; font-size: 18px; padding: 20px 18px 14px; }
.brand span { font-weight: 300; margin-left: 4px; opacity: .8; }
nav { flex: 1; overflow-y: auto; }
nav a { display: block; color: #dbe4ee; text-decoration: none; padding: 10px 18px; border-left: 3px solid transparent; }
nav a:hover { background: rgba(255,255,255,.06); color: #fff; }
nav a.active { background: rgba(255,255,255,.12); border-left-color: #a8dadc; color: #fff; font-weight: 600; }
nav .badge { background: var(--warn); color: #1b263b; border-radius: 10px; padding: 0 7px; font-size: 11px; margin-left: 6px; font-weight: 700; }
.me { padding: 14px 18px; border-top: 1px solid rgba(255,255,255,.12); font-size: 13px; }
.me .muted { color: #a9b8c9; }
.me a { color: #a8dadc; }
.me-actions { margin-top: 6px; }
main { flex: 1; padding: 22px 26px 60px; min-width: 0; }
h2 { margin: 0 0 16px; font-size: 21px; color: var(--brand); }
h3 { margin: 0 0 10px; font-size: 16px; color: var(--brand); }

.card { background: var(--card); border-radius: var(--radius); box-shadow: 0 1px 3px rgba(16,24,40,.08); padding: 16px 18px; margin-bottom: 16px; }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: 1fr 1fr; }
.g3 { grid-template-columns: repeat(3, 1fr); }
.offer-grid { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(300px, 1fr); gap: 16px; align-items: start; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.row > label { flex: 1; min-width: 140px; }
.spacer { flex: 1; }

label { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 8px; }
input, select, textarea { display: block; width: 100%; margin-top: 4px; padding: 8px 10px; border: 1px solid #cdd5df; border-radius: 7px; font: inherit; color: var(--ink); background: #fff; }
input:focus, select:focus, textarea:focus { outline: 2px solid #a8dadc; border-color: var(--brand2); }
input[type=checkbox] { display: inline; width: auto; margin: 0 6px 0 0; }
textarea { min-height: 60px; resize: vertical; }

.btn { display: inline-block; padding: 8px 14px; border-radius: 7px; border: 1px solid #cdd5df; background: #fff; color: var(--ink); cursor: pointer; font: inherit; text-decoration: none; white-space: nowrap; }
.btn:hover { background: #f1f4f8; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: #16294a; }
.btn.ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn.bad { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn.sm { padding: 4px 9px; font-size: 12.5px; }
.btn:disabled { opacity: .55; cursor: default; }

table.t { width: 100%; border-collapse: collapse; }
.t th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 600; padding: 8px; border-bottom: 2px solid var(--line); white-space: nowrap; background: #fafbfc; position: sticky; top: 0; }
.t td { padding: 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.t tr:hover td { background: #f8fafc; }
.t .r, .r { text-align: right; white-space: nowrap; }
.t tfoot td { font-weight: 700; border-top: 2px solid var(--line); }
.scroll { overflow: auto; max-height: 68vh; }
.cost { color: #7a4b00; background: #fff8e8; }
.t td.cost, .t th.cost { background: #fff8e8; }
.pos { color: var(--ok); } .neg { color: var(--bad); }

.pill { display: inline-block; padding: 2px 9px; border-radius: 12px; font-size: 12px; background: #e9eef4; color: var(--ink); white-space: nowrap; }
.pill.yeni { background: #e3f0ff; color: #1b5aa6; }
.pill.arandi { background: #eef0ff; color: #4c4fb5; }
.pill.gorusuldu { background: #f3e9ff; color: #7442a8; }
.pill.teklif_verildi, .pill.acik { background: #fff3db; color: #8a5a00; }
.pill.satis, .pill.onaylandi { background: #def7ef; color: #1c7a63; }
.pill.olumsuz, .pill.kaybedildi, .pill.reddedildi { background: #fde6e6; color: #a83232; }
.pill.bekliyor { background: #ffe9c2; color: #8a5a00; font-weight: 600; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat { background: #fff; border-radius: var(--radius); padding: 14px 16px; box-shadow: 0 1px 3px rgba(16,24,40,.08); }
.stat b { display: block; font-size: 20px; color: var(--brand); }
.stat span { font-size: 12px; color: var(--muted); }

.sum-line { display: flex; justify-content: space-between; padding: 5px 0; }
.sum-line.big { font-size: 18px; font-weight: 700; border-top: 2px solid var(--brand); margin-top: 6px; padding-top: 10px; color: var(--brand); }
.sum-box { background: #f4f7fb; border-radius: 8px; padding: 12px; margin-top: 10px; }
.notice { padding: 9px 12px; border-radius: 7px; margin: 8px 0; font-size: 13px; }
.notice.warn { background: #fff4d6; border: 1px solid #f0d58c; }
.notice.bad { background: #fde6e6; border: 1px solid #f3b5b5; }
.notice.info { background: #e8f2fb; border: 1px solid #bcd6ef; }

.search-wrap { position: relative; }
.search-results { position: absolute; left: 0; right: 0; top: 100%; z-index: 20; background: #fff; border: 1px solid #cdd5df; border-radius: 7px; max-height: 320px; overflow-y: auto; box-shadow: 0 8px 20px rgba(16,24,40,.15); }
.search-results div { padding: 8px 10px; cursor: pointer; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; gap: 10px; }
.search-results div:hover, .search-results div.sel { background: #eef4fa; }
.search-results small { color: var(--muted); }

.tabs { display: flex; gap: 4px; border-bottom: 2px solid var(--line); margin-bottom: 16px; flex-wrap: wrap; }
.tabs a { padding: 8px 14px; text-decoration: none; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -2px; }
.tabs a.active { color: var(--brand); border-bottom-color: var(--brand); font-weight: 600; }

.modal { position: fixed; inset: 0; background: rgba(15,23,42,.45); display: grid; place-items: center; z-index: 50; padding: 20px; }
.modal-box { background: #fff; border-radius: 12px; width: min(860px, 100%); max-height: 90vh; overflow-y: auto; padding: 22px; position: relative; }
.modal-x { position: absolute; right: 12px; top: 8px; border: 0; background: none; font-size: 26px; cursor: pointer; color: var(--muted); }
.toast { position: fixed; bottom: 22px; right: 22px; background: var(--ink); color: #fff; padding: 11px 16px; border-radius: 8px; z-index: 60; max-width: 420px; box-shadow: 0 6px 18px rgba(0,0,0,.2); }
.toast.bad { background: var(--bad); }
.bar { height: 8px; border-radius: 4px; background: var(--ok); min-width: 2px; }
.bar.neg { background: var(--bad); }
iframe.report { width: 100%; height: 560px; border: 1px solid var(--line); border-radius: 8px; background: #fff; }

@media (max-width: 900px) {
  .shell { flex-direction: column; }
  aside { width: 100%; height: auto; position: static; }
  nav { display: flex; overflow-x: auto; }
  nav a { white-space: nowrap; border-left: 0; border-bottom: 3px solid transparent; }
  nav a.active { border-bottom-color: #a8dadc; }
  .me { display: flex; gap: 12px; align-items: center; padding: 8px 18px; }
  .offer-grid, .g2, .g3 { grid-template-columns: 1fr; }
  main { padding: 16px; }
}

.t.compact th, .t.compact td { padding: 5px 6px; font-size: 12.5px; }
.t tr.sec td { background: #eef3f8; color: #1f3a5a; font-size: 12px; padding-top: 10px; }

.t.compact td:nth-child(2) { min-width: 230px; }
.login-wrap { display: flex; flex-direction: column; align-items: center; gap: 22px; padding: 24px 16px; }
.login-logo { display: block; width: 240px; max-width: 70vw; max-height: 90px; object-fit: contain; }

/* ---------------- telefon ---------------- */
.only-mobile { display: none; }
@media (max-width: 700px) {
  .only-mobile { display: initial; }
  .only-desktop { display: none !important; }
  body { font-size: 15px; }
  input, select, textarea { font-size: 16px; padding: 10px 11px; }  /* iPhone'da odaklanınca yakınlaştırmayı önler */
  .btn { padding: 10px 14px; }
  .btn.sm { padding: 7px 11px; font-size: 13.5px; }
  aside { position: sticky; top: 0; z-index: 30; flex-direction: row; flex-wrap: wrap; align-items: center; box-shadow: 0 2px 8px rgba(0,0,0,.18); }
  .brand { flex: 1; padding: 10px 14px; font-size: 16px; }
  .me { order: 1; border-top: 0; padding: 6px 14px; gap: 10px; font-size: 13px; }
  .me #meRole { display: none; }
  .me #meName { max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .me-actions { margin-top: 0; }
  nav { order: 2; width: 100%; flex: none; border-top: 1px solid rgba(255,255,255,.12); scrollbar-width: none; }
  nav::-webkit-scrollbar { display: none; }
  nav a { padding: 11px 14px; }
  main { padding: 12px 12px 80px; }
  h2 { font-size: 19px; margin-bottom: 12px; }
  .card { padding: 14px; margin-bottom: 12px; }
  .offer-grid > .card { position: static !important; }
  .row > label { min-width: 120px; }
  .scroll { max-height: none; -webkit-overflow-scrolling: touch; }
  .tabs { flex-wrap: nowrap; overflow-x: auto; }
  .tabs a { white-space: nowrap; padding: 8px 10px; }
  /* teklif kalemleri: tablo yerine kart görünümü */
  #itemsTbl tr:first-child { display: none; }
  #itemsTbl tr { display: grid; grid-template-columns: 1fr 86px auto; gap: 6px 10px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); }
  #itemsTbl td { padding: 0; border: 0; }
  #itemsTbl td:first-child { grid-column: 1 / -1; }
  #itemsTbl td.r { text-align: left; }
  .search-results { max-height: 50vh; }
  .search-results div { padding: 11px 10px; }
  .modal { padding: 0; place-items: stretch; }
  .modal-box { width: 100%; max-height: 100vh; height: 100%; border-radius: 0; padding: 18px 14px 40px; }
  .toast { left: 12px; right: 12px; bottom: 12px; max-width: none; }
  .stats { grid-template-columns: 1fr 1fr; }
  iframe.report { height: 70vh; }
  .login-card { width: min(340px, calc(100vw - 32px)); }
}

/* ---------------- performans ---------------- */
.motive { background: linear-gradient(135deg, #1d3557, #457b9d); color: #fff; }
.motive .motive-note { background: rgba(255,255,255,.12); border-radius: 8px; padding: 10px 12px; margin-bottom: 12px; }
.motive .motive-note p { margin: 4px 0; white-space: pre-line; font-size: 15px; line-height: 1.45; }
.motive small { color: #cfdbe8; }
.motive-tag { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: #a8dadc; font-weight: 700; }
.quote { margin: 0; font-size: 17px; font-style: italic; line-height: 1.45; }
.quote small { display: block; font-style: normal; font-size: 11px; color: #a8dadc; margin-top: 6px; text-transform: uppercase; letter-spacing: .06em; }
.tgrid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin: 12px 0; }
.tgrid span { display: block; font-size: 12px; color: var(--muted); }
.tgrid b { font-size: 22px; color: var(--brand); }
.tgrid b.pos { color: var(--ok); }
.progress { position: relative; height: 22px; background: #e9eef4; border-radius: 11px; overflow: hidden; }
.progress .fill { height: 100%; background: linear-gradient(90deg, #457b9d, #2a9d8f); border-radius: 11px; }
.progress .fill.done { background: var(--ok); }
.progress .pace { position: absolute; top: 0; bottom: 0; width: 2px; background: #1b263b; opacity: .5; }
.progress .pct { position: absolute; right: 10px; top: 2px; font-weight: 700; font-size: 13px; color: var(--ink); }
.progress.sm { height: 10px; flex: 1; min-width: 70px; }
.pbar { display: flex; align-items: center; gap: 8px; }
.pbar span { min-width: 40px; text-align: right; font-size: 12.5px; }
.sec-h { margin: 4px 0 10px; }
.stats.s3 { grid-template-columns: repeat(3, 1fr); }
.stat .delta { font-size: 11.5px; margin-top: 4px; }
.grid.top { align-items: start; }
.tips { list-style: none; padding: 0; margin: 0; }
.tips li { padding: 8px 10px 8px 32px; border-radius: 7px; margin-bottom: 6px; position: relative; background: #f4f7fb; line-height: 1.4; }
.tips li::before { position: absolute; left: 11px; top: 8px; font-weight: 700; }
.tips li.good { background: #e8f7f2; } .tips li.good::before { content: "✓"; color: var(--ok); }
.tips li.tip::before { content: "→"; color: var(--brand2); }
.tips li.warn { background: #fff4d6; } .tips li.warn::before { content: "!"; color: #8a5a00; }
.card h4 { margin: 14px 0 6px; font-size: 13.5px; color: var(--brand); }
.card h3 + h4 { margin-top: 0; }
.t.compact2 td { padding: 6px; font-size: 13px; }
.t tr.cur td { background: #eef6fb; font-weight: 600; }
input.tin { width: 130px; text-align: right; margin: 0; display: inline-block; padding: 5px 8px; }
@media (max-width: 700px) {
  .tgrid { gap: 8px; } .tgrid b { font-size: 16px; }
  .stats.s3 { grid-template-columns: 1fr 1fr; }
  .quote { font-size: 15.5px; }
  input.tin { width: 110px; }
}

/* ---------------- bildirim & kurulum ---------------- */
.brand { display: flex; align-items: center; }
.bell { margin-left: auto; position: relative; text-decoration: none; font-size: 18px; line-height: 1; padding: 5px; border-radius: 8px; }
.bell:hover { background: rgba(255,255,255,.12); }
.brand .bell .bn { position: absolute; top: -3px; right: -5px; margin: 0; opacity: 1; background: var(--bad); color: #fff; border-radius: 10px;
  font-size: 10.5px; font-weight: 700; padding: 1px 5px; line-height: 1.3; }
.push-banner { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; margin: 0 0 14px; }
.nlist { display: flex; flex-direction: column; }
.nitem { display: block; padding: 10px 12px; border-bottom: 1px solid var(--line); text-decoration: none; color: var(--ink); border-left: 3px solid transparent; }
.nitem:hover { background: #f8fafc; }
.nitem span { display: block; color: var(--muted); font-size: 13px; margin-top: 2px; }
.nitem small { color: var(--muted); font-size: 11.5px; }
.nitem.unread { background: #eef6fb; border-left-color: var(--brand2); }
.icard { background: #fff; border-radius: var(--radius); box-shadow: 0 1px 3px rgba(16,24,40,.08); padding: 12px 14px; margin-bottom: 10px;
  cursor: pointer; border-left: 4px solid #cdd5df; display: flex; flex-direction: column; gap: 4px; }
.icard:hover { box-shadow: 0 2px 8px rgba(16,24,40,.14); }
.icard.bekliyor { border-left-color: var(--warn); }
.icard.yonlendirildi { border-left-color: var(--brand2); }
.icard.kuruldu { border-left-color: var(--ok); }
.icard.sorun, .icard.late { border-left-color: var(--bad); }
.icard-h { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.icard-h b { font-size: 15px; margin-right: 4px; }
.pill.i-bekliyor { background: #ffe9c2; color: #8a5a00; }
.pill.i-yonlendirildi { background: #e3f0ff; color: #1b5aa6; }
.pill.i-kuruldu { background: #def7ef; color: #1c7a63; }
.pill.i-sorun { background: #fde6e6; color: #a83232; font-weight: 600; }
.pill.i-iptal { background: #eceff3; color: #6b7686; }
.tline > div { border-left: 2px solid var(--line); padding: 4px 0 8px 12px; margin-left: 4px; }

/* ---------------- telefonda kart tablolar ---------------- */
@media (max-width: 700px) {
  .tabs { flex-wrap: wrap; overflow-x: visible; }
  .tabs a { padding: 7px 10px; }
  table.t.cards, table.t.cards tbody, table.t.cards tfoot, table.t.cards tr { display: block; width: 100%; }
  table.t.cards thead, table.t.cards tr.hdr { display: none; }
  table.t.cards tr { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 4px 12px; margin-bottom: 10px;
    box-shadow: 0 1px 2px rgba(16,24,40,.05); }
  table.t.cards tr:hover td { background: transparent; }
  table.t.cards td { display: flex; justify-content: space-between; align-items: center; gap: 12px; min-width: 0 !important;
    padding: 7px 0; border: 0; border-bottom: 1px dashed #e8ecf1; text-align: right; white-space: normal; overflow-wrap: anywhere; }
  table.t.cards td:last-child { border-bottom: 0; }
  table.t.cards td::before { content: attr(data-label); color: var(--muted); font-size: 12.5px; font-weight: 400; text-align: left;
    flex-shrink: 0; max-width: 46%; }
  table.t.cards td[data-label=""]::before { content: none; }
  table.t.cards td[data-label=""] { justify-content: flex-end; }
  table.t.cards td:empty { display: none; }
  table.t.cards td:first-child { font-weight: 600; }
  table.t.cards td.cost { background: #fff8e8; margin: 0 -12px; padding: 7px 12px; }
  table.t.cards tr.full { background: #eef3f8; padding: 8px 12px; }
  table.t.cards tr.full td { display: block; text-align: left; border: 0; padding: 0; }
  table.t.cards tfoot tr { background: #f4f7fb; }
  table.t.cards tfoot td { border-top: 0; font-weight: 700; }
  table.t.cards td select, table.t.cards td input { width: auto; max-width: 62%; margin: 0; }
  table.t.cards td .pbar { flex: 1; max-width: 62%; }
  table.t.cards td > .bar { flex: 0 1 auto; max-width: 55%; }
  table.t.cards td .btn { white-space: nowrap; }
  .scroll:has(> table.t.cards) { overflow: visible; }
}

/* ---------------- telefonda fiyat listesi: iki satır ---------------- */
.plist { display: none; }
@media (max-width: 700px) {
  .plist { display: block; }
  table.ptable { display: none !important; }
  .prow { padding: 9px 0; border-bottom: 1px solid var(--line); cursor: pointer; }
  .prow:last-child { border-bottom: 0; }
  .pname { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .pname small { display: none; color: var(--muted); font-weight: 400; }
  .prow.open .pname { white-space: normal; }
  .prow.open .pname small { display: inline; }
  .pprice { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; margin-top: 2px; font-size: 14px; }
  .pprice b { color: var(--brand); }
  .pprice .pm { color: var(--muted); white-space: nowrap; }
}

/* ---------------- uygulama adı (sol menü / üst çubuk) ---------------- */
.brand .bname { display: flex; flex-direction: column; margin: 0; opacity: 1; font-weight: 700; line-height: 1.1; min-width: 0; }
.brand .bname b { font-size: 20px; letter-spacing: .4px; }
.brand .bname small { font-size: 10.5px; font-weight: 400; letter-spacing: 1.2px; text-transform: uppercase; opacity: .8; margin-top: 2px; white-space: nowrap; }
.login-card h1 { font-size: 24px; line-height: 1.2; }
@media (max-width: 700px) {
  .brand .bname b { font-size: 17px; }
  .brand .bname small { font-size: 9.5px; letter-spacing: 1px; }
}

/* ---------------- prim, kârlılık, tahsilat ---------------- */
.sum-box.prim { background: #eefaf6; border: 1px solid #cdeee3; }
.sum-box.prim > small { display: block; margin-top: 6px; font-size: 12px; line-height: 1.45; }
.sum-line.strong { font-weight: 700; border-top: 1px solid #cfd8e3; margin-top: 4px; padding-top: 8px; }
.sum-line small { font-weight: 400; }
.tgrid.g4 { grid-template-columns: repeat(4, 1fr); }
.tgrid b.neg { color: var(--bad); }
.tgrid small { font-size: 12px; }
.primc h4 { margin: 14px 0 6px; }
#collBox .tgrid b { font-size: 17px; }
#collBox form label { min-width: 120px; }
b.neg, span.neg, td.neg { color: var(--bad); }
@media (max-width: 700px) {
  .tgrid.g4 { grid-template-columns: 1fr 1fr; }
  #collBox .tgrid b { font-size: 14.5px; }
}
