:root {
  --bg: #f6f7f9; --card: #fff; --text: #111827; --muted: #6b7280; --line: #e5e7eb;
  --brand: #0f766e; --brand-d: #115e59; --brand-l: #ccfbf1;
  --red: #b91c1c; --red-l: #fee2e2; --orange: #c2410c; --orange-l: #ffedd5;
  --yellow: #a16207; --yellow-l: #fef9c3; --green: #15803d; --green-l: #dcfce7;
  --blue: #1d4ed8; --blue-l: #dbeafe; --gray-l: #f3f4f6;
  --radius: 10px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif; }
a { color: var(--brand); }
h1 { font-size: 22px; margin: 0 0 4px; }
h2 { font-size: 17px; margin: 0 0 12px; }
h3 { font-size: 15px; margin: 0 0 8px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.center { text-align: center; }
[hidden] { display: none !important; }

.top { background: #fff; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 10px 20px; position: sticky; top: 0; z-index: 10; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; color: var(--text); text-decoration: none; }
nav { display: flex; gap: 4px; flex-wrap: wrap; align-items: center; }
nav a, nav .link { padding: 6px 10px; border-radius: 6px; color: var(--text); text-decoration: none; font-size: 14px; }
nav a.on { background: var(--brand-l); color: var(--brand-d); font-weight: 600; }
nav a:hover { background: var(--gray-l); }

main { max-width: 1180px; margin: 0 auto; padding: 22px 20px 60px; }
.head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin-bottom: 16px; }
.grid { display: grid; gap: 12px; }
.kpis { grid-template-columns: repeat(4, 1fr); margin-bottom: 16px; }
.kpi { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; border-top: 4px solid var(--line); }
.kpi b { display: block; font-size: 28px; line-height: 1.1; }
.kpi span { color: var(--muted); font-size: 13px; }
.kpi.red { border-top-color: var(--red); } .kpi.red b { color: var(--red); }
.kpi.orange { border-top-color: var(--orange); } .kpi.orange b { color: var(--orange); }
.kpi.yellow { border-top-color: #eab308; } .kpi.yellow b { color: var(--yellow); }
.kpi.gray { border-top-color: #9ca3af; }

button, .btn { font: inherit; font-size: 14px; border: 1px solid var(--line); background: #fff; color: var(--text); padding: 7px 12px;
  border-radius: 7px; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
button:hover, .btn:hover { background: var(--gray-l); }
button.primary, .btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
button.primary:hover, .btn.primary:hover { background: var(--brand-d); }
button.wa { background: #16a34a; border-color: #16a34a; color: #fff; }
button.wa:hover { background: #15803d; }
button.danger { color: var(--red); }
body.ro .w { display: none !important; }   /* patron: yalnız görüntüleme */
button.link { border: 0; background: none; padding: 6px 10px; color: var(--muted); }
button:disabled { opacity: .55; cursor: default; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 10px; }
input, select, textarea { font: inherit; font-size: 14px; width: 100%; padding: 8px 10px; border: 1px solid #d1d5db; border-radius: 7px; background: #fff; color: var(--text); margin-top: 3px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand-l); border-color: var(--brand); }
input[type=checkbox] { width: auto; margin: 0 6px 0 0; }
.form2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.check { display: flex; align-items: center; color: var(--text); font-size: 14px; }

table { border-collapse: collapse; width: 100%; font-size: 14px; }
th { text-align: left; font-weight: 600; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .03em; padding: 8px; border-bottom: 1px solid var(--line); }
td { padding: 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
.scroll { overflow-x: auto; }
.clickrow { cursor: pointer; }
.clickrow:hover td { background: #fafafa; }

.pill { display: inline-block; font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 999px; white-space: nowrap; }
.s-overdue { background: var(--red-l); color: var(--red); }
.s-week { background: var(--orange-l); color: var(--orange); }
.s-month { background: var(--yellow-l); color: var(--yellow); }
.s-later { background: var(--green-l); color: var(--green); }
.s-done { background: var(--gray-l); color: var(--muted); }

/* giriş / kayıt */
.auth { max-width: 420px; margin: 6vh auto 40px; }
.auth-brand { display: flex; align-items: center; justify-content: center; gap: 10px; font-size: 20px; margin-bottom: 16px; }
.wide { width: 100%; justify-content: center; padding: 10px; font-size: 15px; }

/* özet çipleri ve filtreler */
.chips { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 12px; }
.chip { flex-direction: column; align-items: flex-start; gap: 0; padding: 10px 14px; border-radius: var(--radius); border-top: 4px solid var(--line); white-space: normal; }
.chip b { font-size: 24px; line-height: 1.15; }
.chip span { font-size: 13px; color: var(--muted); }
.chip.c-overdue { border-top-color: var(--red); } .chip.c-overdue b { color: var(--red); }
.chip.c-week { border-top-color: var(--orange); } .chip.c-week b { color: var(--orange); }
.chip.c-month { border-top-color: #eab308; } .chip.c-month b { color: var(--yellow); }
.chip.c-all { border-top-color: var(--brand); }
.chip.on { outline: 2px solid var(--brand); background: #f0fdfa; }
.filters { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 8px; margin-bottom: 14px; }
.filters input, .filters select { margin: 0; }

/* liste */
.group { margin-bottom: 14px; }
.gh { margin: 0 0 6px; font-size: 14px; }
.g-overdue { color: var(--red); } .g-week { color: var(--orange); } .g-month { color: var(--yellow); } .g-later { color: var(--green); }
.card.list { padding: 0; overflow: hidden; }
.irow { display: flex; align-items: center; gap: 14px; padding: 12px 14px; border-bottom: 1px solid var(--line); border-left: 4px solid transparent; cursor: pointer; }
.irow:last-child { border-bottom: 0; }
.irow:hover { background: #fafafa; }
.b-overdue { border-left-color: var(--red); } .b-week { border-left-color: var(--orange); } .b-month { border-left-color: #eab308; } .b-later { border-left-color: #86efac; } .b-done { border-left-color: var(--line); }
.imain { flex: 1; min-width: 0; }
.ititle { font-weight: 600; overflow-wrap: anywhere; }
.isub { font-weight: 400; color: var(--muted); }
.iside { text-align: right; display: flex; flex-direction: column; align-items: flex-end; gap: 3px; }
.idate { font-weight: 600; font-variant-numeric: tabular-nums; }
.renew { font-size: 13px; padding: 5px 10px; }

/* form */
.lbl { font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.daychips { display: flex; flex-wrap: wrap; gap: 6px; }
.daychip { margin: 0; color: var(--text); }
.daychip input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.daychip span { display: inline-block; padding: 5px 10px; border: 1px solid #d1d5db; border-radius: 999px; font-size: 13px; cursor: pointer; background: #fff; }
.daychip input:checked + span { background: var(--brand); border-color: var(--brand); color: #fff; }
.daychip input:focus-visible + span { outline: 2px solid var(--brand-l); }
.daychip-add { padding: 5px 10px; border-radius: 999px; border-style: dashed; font-size: 13px; color: var(--brand); }
.calc { background: var(--gray-l); border-radius: 8px; padding: 10px 12px; margin-bottom: 12px; }
.fs { border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px 2px; margin: 0 0 12px; }
.fs legend { font-size: 13px; color: var(--muted); padding: 0 4px; }
input[type=radio] { width: auto; margin: 0 6px 0 0; }
.kv th { text-transform: none; letter-spacing: 0; font-size: 13px; width: 110px; padding: 6px 8px 6px 0; vertical-align: top; }
.kv td { padding: 6px 0; }
.hist { padding-left: 18px; margin: 8px 0 0; }

/* evrak dosyaları */
.files { border-top: 1px solid var(--line); padding-top: 12px; margin-bottom: 12px; }
.thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px; margin-top: 10px; }
.thumb { min-width: 0; }
.thumb a { display: block; aspect-ratio: 4 / 3; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: var(--gray-l); }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb .pdf { height: 100%; display: flex; align-items: center; justify-content: center; font-weight: 700; color: var(--red); font-size: 20px; }
.tname { font-size: 13px; margin-top: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.thumb .link { padding: 0 0 0 6px; font-size: 12px; }
.clip { font-weight: 400; font-size: 13px; }
.starter td { padding: 6px; }

/* abonelik */
.subbar { display: flex; gap: 10px; align-items: center; justify-content: center; flex-wrap: wrap; padding: 8px 16px; font-size: 14px; text-align: center; }
.subbar.info { background: var(--blue-l); color: #1e3a8a; }
.subbar.warn { background: var(--yellow-l); color: #713f12; }
.subbar.danger { background: var(--red-l); color: #7f1d1d; }
.subbar .btn { padding: 4px 10px; font-size: 13px; }
.plans { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px; }
.plan { position: relative; flex-direction: column; align-items: flex-start; gap: 2px; padding: 16px; border-radius: var(--radius); border: 2px solid var(--line); white-space: normal; text-align: left; }
.plan b { font-size: 16px; }
.plan .price { font-size: 24px; font-weight: 700; color: var(--brand-d); }
.plan.on { border-color: var(--brand); background: #f0fdfa; }
.plan .badge { position: absolute; top: -10px; right: 10px; background: var(--brand); color: #fff; font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 999px; }
.paybox code { font-size: 15px; background: var(--gray-l); padding: 2px 6px; border-radius: 4px; }
.paybox .ref { font-size: 17px; font-weight: 700; color: var(--brand-d); }
.paybox .big { font-size: 20px; }
.banner.danger { background: var(--red-l); color: #7f1d1d; }
code { white-space: nowrap; }

/* yönetim */
body.admin .top { background: #0f172a; border-bottom-color: #0f172a; }
body.admin .top .brand, body.admin .top .link { color: #fff; }
body.admin .top .muted { color: #cbd5e1; }
dialog.wide-dialog { width: min(820px, calc(100vw - 32px)); }
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 24px; }
.detail-grid h3, dialog h3 { margin: 14px 0 6px; }
@media (max-width: 760px) { .detail-grid { grid-template-columns: 1fr; } }
.pickrow { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-bottom: 12px; }
.picked { display: contents; }
.pchip { display: inline-flex; align-items: center; gap: 2px; max-width: 220px; font-size: 13px; background: var(--gray-l); border-radius: 999px; padding: 3px 4px 3px 10px; }
.pchip button { padding: 0 6px; font-size: 15px; line-height: 1; }

.banner { border-radius: var(--radius); padding: 12px 14px; margin-bottom: 16px; font-size: 14px; display: flex; gap: 10px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.banner.warn { background: var(--yellow-l); color: #713f12; }
.banner.info { background: var(--blue-l); color: #1e3a8a; }
.banner.ok { background: var(--green-l); color: #14532d; }

.login { max-width: 360px; margin: 10vh auto; }
.drop { border: 2px dashed #cbd5e1; border-radius: var(--radius); padding: 28px; text-align: center; background: #fff; }
.drop.over { border-color: var(--brand); background: var(--brand-l); }

dialog { border: 0; border-radius: 12px; padding: 0; width: min(520px, calc(100vw - 32px)); box-shadow: 0 20px 50px rgba(0,0,0,.25); }
dialog::backdrop { background: rgba(17,24,39,.45); }
dialog .dhead { padding: 16px 18px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; }
dialog .dbody { padding: 16px 18px; max-height: 70vh; overflow: auto; }

#toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: #111827; color: #fff; padding: 10px 16px;
  border-radius: 8px; font-size: 14px; opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 50; max-width: calc(100vw - 32px); }
#toast.show { opacity: 1; }
#toast.err { background: var(--red); }

.legend { display: flex; gap: 6px; flex-wrap: wrap; margin: 8px 0 0; }

@media (max-width: 760px) {
  main { padding: 16px 16px 50px; }
  .top { padding: 8px 16px; }
  .kpis { grid-template-columns: 1fr 1fr; }
  .form2 { grid-template-columns: 1fr; }
  .hide-m { display: none; }
  .chips { grid-template-columns: 1fr 1fr; }
  .filters { grid-template-columns: 1fr 1fr; }
  .filters input { grid-column: 1 / -1; }
  .irow { flex-wrap: wrap; gap: 8px 12px; }
  .imain { flex-basis: 100%; }
  .iside { flex-direction: row; align-items: center; gap: 8px; margin-right: auto; }
}

@media print {
  .chips, .filters, dialog { display: none !important; }
  .irow { break-inside: avoid; }
  body { background: #fff; font-size: 12px; }
  .noprint, .top, #toast { display: none !important; }
  main { padding: 0; max-width: none; }
  .card { border: 0; padding: 0; }
  .pill { border: 1px solid currentColor; }
  td, th { padding: 4px 6px; }
}
