:root {
  --bg: #0f1116;
  --bg2: #161922;
  --card: #1a1e29;
  --line: #2a3040;
  --text: #eef1f7;
  --muted: #8d95a8;
  --accent: #2b9fe6;
  --accent2: #5cc0ff;
  --ok: #2fbf71;
  --danger: #ef5a5a;
  --shadow: 0 10px 30px rgba(0,0,0,.35);
  --radius: 18px;
}
[data-theme="light"] {
  --bg: #f3f4f8;
  --bg2: #eef0f5;
  --card: #ffffff;
  --line: #dde1ea;
  --text: #171a22;
  --muted: #646c80;
  --accent: #1a86cf;
  --shadow: 0 8px 24px rgba(30,40,70,.10);
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: radial-gradient(1200px 600px at 50% -200px, rgba(43,159,230,.14), transparent 70%), var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-tap-highlight-color: transparent;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent); }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.center { text-align: center; }
.mt { margin-top: 12px; }

/* ---------- header ---------- */
.top {
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 12px;
  max-width: 1240px; margin: 0 auto; padding: 14px 18px;
  padding-top: max(14px, env(safe-area-inset-top));
}
.brand { display: flex; align-items: center; gap: 10px; font-size: 1.25rem; letter-spacing: .2px; }
.brand b { color: var(--accent); }
.top-actions { display: flex; gap: 8px; justify-self: end; }
.maker-logo {
  justify-self: center; display: block; background: #fff; border-radius: 12px; padding: 5px 12px;
  box-shadow: 0 2px 10px rgba(0,0,0,.18); transition: transform .12s, box-shadow .12s; line-height: 0;
}
[data-theme="light"] .maker-logo { box-shadow: 0 0 0 1px var(--line); }
.maker-logo:hover { transform: translateY(-1px); box-shadow: 0 4px 16px rgba(79,195,247,.35); }
.maker-logo img { height: 36px; width: auto; display: block; }
.icon-btn {
  width: 38px; height: 38px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--card); display: grid; place-items: center; font-weight: 700;
}
.icon-btn:hover, .chip:hover { border-color: var(--accent); }

main { max-width: 1240px; margin: 0 auto; padding: 0 18px 20px; }
.intro { text-align: center; margin: 4px auto 18px; max-width: 760px; }
.intro h1 { font-size: clamp(1.35rem, 2.6vw, 1.9rem); margin: 6px 0 6px; line-height: 1.2; }
.intro p { margin: 0; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.panel { padding: 16px 18px 18px; }
.panel + .panel { margin-top: 14px; }
.panel h2 { margin: 0; font-size: 1.05rem; display: flex; align-items: center; gap: 9px; }
.num {
  width: 24px; height: 24px; border-radius: 8px; background: var(--accent); color: #fff;
  display: inline-grid; place-items: center; font-size: .8rem; font-weight: 700;
}
.ph { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.pill { padding: 3px 11px; border-radius: 99px; background: var(--bg2); border: 1px solid var(--line); color: var(--muted); font-size: .8rem; }

.chip {
  border: 1px solid var(--line); background: var(--bg2); border-radius: 10px; padding: 7px 11px;
  font-size: .9rem; line-height: 1.1;
}
.btn {
  border: 0; border-radius: 12px; padding: 10px 16px; background: var(--accent); color: #fff; font-weight: 600;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
}
.btn.ghost { background: var(--bg2); color: var(--text); border: 1px solid var(--line); }
.btn.ghost:hover { border-color: var(--accent); }
.btn.sm { padding: 6px 12px; font-size: .85rem; }
.btn.big { padding: 14px 22px; font-size: 1.05rem; box-shadow: 0 8px 22px rgba(43,159,230,.35); }
.btn:active, .chip:active { transform: scale(.97); }
.btn[disabled] { opacity: .6; cursor: progress; }

/* ---------- form ---------- */
.layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 18px; align-items: start; }
.grid { display: grid; gap: 10px 12px; }
.g2 { grid-template-columns: 1fr 1fr; }
.g3 { grid-template-columns: 1.3fr 1fr 1fr; }
.span2 { grid-column: span 2; }
.grid + .grid, .seg + .grid { margin-top: 10px; }
.f { display: flex; flex-direction: column; gap: 5px; font-size: .8rem; color: var(--muted); min-width: 0; }
.f > .swatches { margin-top: 2px; }
section > .f { margin-top: 12px; }
input, select, textarea {
  width: 100%; min-width: 0; border: 1px solid var(--line); background: var(--bg2); border-radius: 10px;
  padding: 9px 11px; font-size: .95rem; color: var(--text); outline: none; transition: border-color .12s, box-shadow .12s;
}
textarea { resize: vertical; min-height: 64px; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(43,159,230,.18); }
input[type="date"] { color-scheme: dark; }
[data-theme="light"] input[type="date"] { color-scheme: light; }
input[type="number"] { -moz-appearance: textfield; }
input[type="number"]::-webkit-inner-spin-button, input[type="number"]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }

.seg { display: grid; grid-template-columns: 1fr 1fr; background: var(--bg2); border: 1px solid var(--line); border-radius: 12px; padding: 4px; gap: 4px; }
.seg button { border: 0; background: transparent; border-radius: 9px; padding: 9px; font-weight: 600; color: var(--muted); }
.seg button.active { background: var(--accent); color: #fff; }

.swatches { display: flex; gap: 8px; flex-wrap: wrap; }
.sw { width: 30px; height: 30px; border-radius: 50%; border: 2px solid var(--card); box-shadow: 0 0 0 1px var(--line); padding: 0; }
.sw.active { box-shadow: 0 0 0 2px var(--text); }

.switch { display: flex; align-items: center; gap: 10px; cursor: pointer; user-select: none; font-size: .9rem; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch span { width: 42px; height: 24px; border-radius: 99px; background: var(--line); position: relative; flex: none; transition: background .15s; }
.switch span::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: transform .15s; }
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::after { transform: translateX(18px); }
.switch input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.switch em { font-style: normal; }

/* logo */
.logo-row { display: flex; gap: 14px; align-items: center; margin-bottom: 12px; }
.logo-drop {
  position: relative; width: 150px; height: 84px; flex: none; border: 2px dashed var(--line); border-radius: 14px;
  display: grid; place-items: center; cursor: pointer; background: var(--bg2); overflow: hidden; text-align: center;
  transition: border-color .12s;
}
.logo-drop:hover, .logo-drop.drag { border-color: var(--accent); }
.logo-drop input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.logo-drop img { max-width: 88%; max-height: 74%; object-fit: contain; background: #fff; border-radius: 6px; padding: 3px; }
.logo-drop span { display: flex; flex-direction: column; gap: 2px; pointer-events: none; }
.logo-drop b { color: var(--accent); font-size: .95rem; }
.logo-drop small { color: var(--muted); font-size: .72rem; }
.logo-side p { margin: 0 0 8px; }

/* kalemler */
.items-head, .item {
  display: grid; grid-template-columns: minmax(0, 3fr) 70px 78px minmax(0, 1.3fr) 66px minmax(0, 1.2fr) 32px; gap: 6px; align-items: center;
}
.items-head { font-size: .74rem; color: var(--muted); padding: 0 2px 6px; }
.items-head .r { text-align: right; }
.item { margin-bottom: 6px; }
.item input, .item select { padding: 8px 8px; font-size: .9rem; }
.item .tot { text-align: right; font-variant-numeric: tabular-nums; font-size: .9rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item .del { width: 32px; height: 32px; border-radius: 9px; border: 1px solid var(--line); background: transparent; color: var(--muted); line-height: 1; }
.item .del:hover { color: var(--danger); border-color: var(--danger); }
.add { margin-top: 4px; width: 100%; border-style: dashed !important; }
.disc { margin-top: 12px; }

/* ---------- önizleme ---------- */
.sticky { position: sticky; top: 12px; }
.prev-bar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.paper-wrap {
  border-radius: 14px; background: #4a5263; padding: 14px; box-shadow: var(--shadow); overflow: hidden;
  max-height: calc(100vh - 170px); overflow-y: auto;
}
[data-theme="light"] .paper-wrap { background: #cfd5e0; }
.paper {
  --pc: #1a86cf;
  background: #fff; color: #1f2430; width: 100%; aspect-ratio: 210 / 297; border-radius: 3px;
  box-shadow: 0 6px 20px rgba(0,0,0,.25); padding: 6.5% 6.5% 5%; font-family: Roboto, "Segoe UI", Arial, sans-serif;
  font-size: clamp(5px, .9vw, 10px); line-height: 1.4; display: flex; flex-direction: column; position: relative;
}
@supports (font-size: 1cqw) { .paper-wrap { container-type: inline-size; } .paper { font-size: 1.62cqw; } }
.pp-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 4%; }
.pp-logo { max-width: 42%; max-height: 5.5em; object-fit: contain; }
.pp-sname { font-size: 1.7em; font-weight: 700; color: var(--pc); }
.pp-title { text-align: right; }
.pp-title h3 { margin: 0; font-size: 2.1em; letter-spacing: .04em; color: var(--pc); font-weight: 800; }
.pp-meta { margin-top: .4em; font-size: .92em; color: #5b6272; }
.pp-meta b { color: #1f2430; }
.pp-bar { height: .3em; background: var(--pc); border-radius: 1em; margin: 1.2em 0 1.2em; }
.pp-parties { display: grid; grid-template-columns: 1fr 1fr; gap: 5%; }
.pp-lbl { font-size: .8em; text-transform: uppercase; letter-spacing: .08em; color: var(--pc); font-weight: 700; margin-bottom: .3em; }
.pp-party b { font-size: 1.1em; }
.pp-party div { color: #4a5060; }
.pp-table { width: 100%; border-collapse: collapse; margin-top: 1.6em; font-size: .95em; }
.pp-table th { background: var(--pc); color: #fff; font-weight: 600; text-align: left; padding: .55em .6em; }
.pp-table th:first-child { border-radius: .4em 0 0 .4em; }
.pp-table th:last-child { border-radius: 0 .4em .4em 0; }
.pp-table td { padding: .55em .6em; border-bottom: 1px solid #e6e9ef; }
.pp-table tr:nth-child(even) td { background: #f6f8fb; }
.pp-table .r { text-align: right; white-space: nowrap; }
.pp-table .c { text-align: center; }
.pp-bottom { display: grid; grid-template-columns: 1fr 42%; gap: 5%; margin-top: 1.2em; }
.pp-tot { display: grid; grid-template-columns: 1fr auto; row-gap: .35em; column-gap: 1em; align-content: start; }
.pp-tot span:nth-child(even) { text-align: right; font-variant-numeric: tabular-nums; }
.pp-grand { grid-column: span 2; display: flex; justify-content: space-between; background: var(--pc); color: #fff; padding: .6em .8em; border-radius: .4em; font-weight: 700; font-size: 1.12em; margin-top: .3em; }
.pp-words { font-style: italic; color: #4a5060; margin-bottom: .7em; }
.pp-note { color: #4a5060; white-space: pre-wrap; margin-bottom: .6em; }
.pp-note b { color: #1f2430; }
.pp-sign { margin-top: auto; display: flex; justify-content: flex-end; padding-top: 1.5em; }
.pp-sign div { width: 36%; text-align: center; border-top: 1px solid #9aa1b0; padding-top: .4em; color: #5b6272; font-size: .9em; }
.pp-foot { margin-top: 1.4em; display: flex; justify-content: space-between; font-size: .78em; color: #9aa1b0; border-top: 1px solid #eceff4; padding-top: .6em; }
.pp-foot .sig { color: #7c8496; }
.pp-foot .sig b { color: var(--pc); font-weight: 600; }
.pp-disclaim { font-size: .82em; color: #8a91a1; margin-top: .4em; }
.pp-empty { color: #aab0bd; font-style: italic; }

.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 12px; }
.actions .big { grid-column: span 2; }
#status { min-height: 1.2em; margin: 8px 0 0; }

/* ---------- alt ---------- */
.about { margin-top: 22px; }
.about h2 { margin-bottom: 8px; }
.steps { margin: 8px 0 10px; padding-left: 20px; line-height: 1.6; }
.foot { max-width: 1240px; margin: 0 auto; padding: 8px 18px 28px; display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; }

.modal { position: fixed; inset: 0; background: rgba(5,8,14,.6); display: grid; place-items: center; z-index: 50; padding: 16px; }
.modal-box { max-width: 520px; width: 100%; padding: 22px; position: relative; }
.modal-box h2 { margin: 0 0 10px; }
.close { position: absolute; top: 12px; right: 12px; }
.help-list { margin: 0; padding-left: 20px; line-height: 1.6; }

/* ---------- responsive ---------- */
@media (max-width: 980px) {
  .layout { grid-template-columns: 1fr; }
  .sticky { position: static; }
  .paper-wrap { max-height: none; }
}
@media (max-width: 640px) {
  .top { grid-template-columns: auto 1fr auto; padding: 10px 12px; }
  .brand span { display: none; }
  .maker-logo img { height: 30px; }
  main { padding: 0 12px 16px; }
  .panel { padding: 14px; }
  .g3 { grid-template-columns: 1fr 1fr; }
  .g3 > :first-child { grid-column: span 2; }
  .items-head { display: none; }
  .item {
    grid-template-columns: 1fr 1fr 1fr; grid-template-areas: "d d x" "q u v" "p p t";
    background: var(--bg2); border: 1px solid var(--line); border-radius: 12px; padding: 8px; margin-bottom: 8px;
  }
  .item input, .item select { background: var(--card); }
  .item .i-desc { grid-area: d; } .item .i-qty { grid-area: q; } .item .i-unit { grid-area: u; }
  .item .i-price { grid-area: p; } .item .i-vat { grid-area: v; } .item .tot { grid-area: t; align-self: center; }
  .item .del { grid-area: x; justify-self: end; }
  .paper-wrap { padding: 8px; }
  .logo-drop { width: 120px; height: 72px; }
}
