:root {
  --ink: #141414;
  --muted: #5c5c5c;
  --line: #1c1c1c;
  --accent: #c8102e;
  --accent-dark: #9a0c24;
  --paper: #fffdf8;
  --bg: #d9d3c7;
  --nav: #161616;
  --shadow: 0 12px 40px rgba(20, 16, 10, 0.18);
  --font: "Segoe UI", "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: var(--font);
  background: var(--bg);
  background-image:
    radial-gradient(ellipse at top, rgba(255,255,255,.35), transparent 50%),
    repeating-linear-gradient(90deg, transparent, transparent 40px, rgba(0,0,0,.015) 41px);
  color: var(--ink);
}
a { color: var(--accent-dark); }
img { max-width: 100%; }

.app-nav {
  background: var(--nav);
  color: #fff;
  position: sticky;
  top: 0;
  z-index: 40;
  border-bottom: 3px solid var(--accent);
}
.app-nav-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: .6rem 1rem;
  display: flex;
  align-items: center;
  gap: .75rem;
  flex-wrap: wrap;
}
.brand {
  display: flex;
  align-items: center;
  gap: .6rem;
  color: #fff !important;
  text-decoration: none;
  font-weight: 700;
  letter-spacing: .02em;
  margin-right: auto;
}
.brand img { height: 32px; width: auto; background: #fff; border-radius: 4px; padding: 2px; }
.nav-toggle {
  background: transparent;
  color: #fff;
  border: 1px solid #444;
  border-radius: 6px;
  width: 42px;
  height: 38px;
}
.app-menu {
  display: flex;
  flex-wrap: wrap;
  gap: .35rem .9rem;
  align-items: center;
  width: 100%;
}
.app-menu a {
  color: #ececec !important;
  text-decoration: none;
  font-size: .92rem;
  padding: .25rem 0;
}
.app-menu a.accent { color: #ffd4da !important; font-weight: 700; }
.app-menu .who { color: #9a9a9a; font-size: .85rem; margin-left: auto; }
.app-menu.show,
.app-menu.collapsing {
  display: flex !important;
}
@media (min-width: 900px) {
  .nav-toggle { display: none; }
  .app-menu { display: flex !important; width: auto; }
}

.app-main { max-width: 1100px; margin: 0 auto; padding: 1.1rem 1rem 6rem; }

.page-auth {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
.page-auth .app-main {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding-bottom: 2rem;
}
.auth-card {
  background: var(--paper);
  width: min(420px, 100%);
  padding: 2rem 1.5rem;
  border-radius: 12px;
  box-shadow: var(--shadow);
  border-top: 4px solid var(--accent);
}
.auth-wide { width: min(560px, 100%); }
.auth-logo { height: 56px; display: block; margin: 0 auto 1rem; }
.auth-card h1 { font-size: 1.25rem; text-align: center; margin: 0 0 .3rem; }
.muted { color: var(--muted); }
.tiny { font-size: .8rem; color: var(--muted); margin-top: 1rem; }
.check-list { list-style: none; padding: 0; }
.check-list .ok { color: #1b7a3d; }
.check-list .fail { color: var(--accent); }

.dash-hero {
  background: var(--nav);
  color: #fff;
  padding: 1.6rem 1.4rem;
  border-radius: 12px;
  margin-bottom: 1rem;
  border-left: 6px solid var(--accent);
}
.dash-hero h1 { margin: 0 0 .35rem; font-size: 1.6rem; }
.dash-hero .eyebrow { text-transform: uppercase; letter-spacing: .14em; font-size: .72rem; color: #ffb3bf; margin: 0 0 .35rem; }
.dash-hero .lead { color: #cfcfcf; margin: 0 0 1rem; }
.stat-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: .75rem;
  margin-bottom: 1rem;
}
@media (min-width: 800px) { .stat-grid { grid-template-columns: repeat(4, 1fr); } }
.stat-card {
  background: var(--paper);
  padding: .9rem 1rem;
  border-radius: 10px;
  box-shadow: 0 2px 8px rgba(0,0,0,.06);
}
.stat-card span { color: var(--muted); font-size: .8rem; }
.stat-card strong { display: block; font-size: 1.7rem; line-height: 1.1; }
.stat-card em { font-style: normal; color: var(--accent); font-size: .8rem; }

.panel {
  background: var(--paper);
  border-radius: 12px;
  padding: 1rem 1.1rem;
  box-shadow: 0 2px 8px rgba(0,0,0,.06);
}
.panel-h { display: flex; justify-content: space-between; align-items: baseline; }
.panel-h h2 { font-size: 1.05rem; margin: 0 0 .6rem; }
.empty { padding: .5rem 0 0; }

.form-toolbar {
  display: grid;
  gap: 1rem;
  margin-bottom: 1rem;
}
@media (min-width: 800px) {
  .form-toolbar { grid-template-columns: 1fr 1fr; align-items: end; }
}
.form-toolbar h1 { margin: 0; font-size: 1.4rem; }
.form-toolbar p { margin: .2rem 0 0; color: var(--muted); font-size: .9rem; }
.search-wrap { position: relative; }
.search-wrap label { display: block; font-size: .8rem; font-weight: 600; margin-bottom: .25rem; }
.search-wrap input[type="search"] {
  width: 100%;
  padding: .65rem .75rem;
  border: 1px solid #bbb;
  border-radius: 8px;
  font-size: 1rem;
}
#customer-results {
  position: absolute;
  left: 0; right: 0; top: 100%;
  background: #fff;
  border: 1px solid #ccc;
  border-radius: 0 0 8px 8px;
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 240px;
  overflow: auto;
  z-index: 20;
  box-shadow: var(--shadow);
}
#customer-results li { padding: .55rem .75rem; cursor: pointer; border-bottom: 1px solid #eee; }
#customer-results li:hover { background: #f7f1f1; }
#customer-results strong { display: block; }
#customer-results span { font-size: .8rem; color: var(--muted); }
#customer-results .empty { cursor: default; color: var(--muted); }
.search-wrap .btn { margin-top: .4rem; }

.sheet {
  background: var(--paper);
  border: 2px solid var(--line);
  box-shadow: var(--shadow);
  padding: 0;
}
.sheet h3 {
  margin: 0;
  background: #efefef;
  border-bottom: 1px solid var(--line);
  font-size: .82rem;
  letter-spacing: .04em;
  padding: .4rem .7rem;
}
.sheet-head {
  display: grid;
  gap: .75rem;
  padding: .85rem .8rem;
  border-bottom: 1px solid var(--line);
}
@media (min-width: 800px) {
  .sheet-head { grid-template-columns: 1.1fr 1.3fr .9fr; align-items: start; }
}
.head-brand { display: flex; gap: .6rem; align-items: flex-start; }
.head-brand img { height: 52px; width: auto; }
.head-brand strong { display: block; font-size: 1.05rem; }
.head-brand small { display: block; font-size: .68rem; line-height: 1.3; color: #333; }
.head-contact { font-size: .78rem; line-height: 1.45; display: flex; flex-direction: column; gap: .15rem; }
.head-title { text-align: right; }
.head-title h2 { margin: 0; font-size: 1.45rem; }
.head-title em { display: block; font-size: .9rem; }
.head-title span { display: block; margin-top: .55rem; font-weight: 700; font-size: .9rem; }

.sheet-two { display: grid; border-bottom: 1px solid var(--line); }
@media (min-width: 800px) { .sheet-two { grid-template-columns: 1fr 1.1fr; } }
.sheet-two > section + section { border-top: 1px solid var(--line); }
@media (min-width: 800px) { .sheet-two > section + section { border-top: 0; border-left: 1px solid var(--line); } }
.sheet-two label, .sheet section label {
  display: grid;
  grid-template-columns: 92px 1fr;
  gap: .35rem;
  align-items: center;
  padding: .28rem .7rem;
  font-size: .85rem;
}
.sheet .line {
  border: 0;
  border-bottom: 1px dotted #333;
  border-radius: 0;
  background: transparent;
  width: 100%;
  padding: .2rem .25rem;
  font-size: .95rem;
}
.sheet textarea.line { min-height: 52px; resize: vertical; }

.devices { display: grid; grid-template-columns: 1fr 1fr; }
.devices h4 {
  margin: 0;
  font-size: .78rem;
  text-align: center;
  padding: .35rem;
  border-bottom: 1px solid var(--line);
}
.devices label { grid-template-columns: 18px 1fr; padding: .2rem .45rem; }
.devices label span { font-size: .8rem; }

.desc-area {
  width: 100%;
  border: 0;
  min-height: 110px;
  padding: .7rem .8rem;
  resize: vertical;
  background: repeating-linear-gradient(#fffdf8, #fffdf8 22px, #e4e0d6 23px);
  font-size: .95rem;
}

.sec-row { display: flex; justify-content: space-between; align-items: center; background: #efefef; border-bottom: 1px solid var(--line); }
.sec-row h3 { border: 0; background: transparent; }
.sec-row .btn { margin-right: .5rem; }

.items-head, .item-row {
  display: grid;
  grid-template-columns: 1.6fr .6fr .6fr .8fr .8fr 36px;
  gap: 6px;
  padding: 6px 8px;
  align-items: center;
}
.items-head {
  font-size: .75rem;
  font-weight: 700;
  background: #f6f6f6;
  border-bottom: 1px solid #ccc;
}
.item-row input {
  width: 100%;
  border: 1px solid #ccc;
  padding: .35rem .4rem;
  font-size: .9rem;
  background: #fff;
}
.item-row .item-total { background: #f4f4f4; }
.btn-del {
  border: 0;
  background: #eee;
  width: 32px;
  height: 32px;
  border-radius: 6px;
  font-size: 1.1rem;
  line-height: 1;
}
@media (max-width: 767px) {
  .items-head { display: none; }
  .item-row {
    grid-template-columns: 1fr 1fr;
    border-bottom: 1px solid #ddd;
    padding: 10px 8px 12px;
  }
  .item-row .item-name { grid-column: 1 / -1; }
  .item-row .btn-del { grid-column: 1 / -1; justify-self: end; }
}

.amount-row {
  display: grid;
  gap: .5rem;
  padding: .7rem .8rem 1rem;
  border-top: 1px solid var(--line);
}
@media (min-width: 700px) { .amount-row { grid-template-columns: 1fr auto; align-items: end; } }
.yalniz { display: flex; flex-wrap: wrap; align-items: center; gap: .35rem; font-size: .9rem; }
.yalniz input { flex: 1; min-width: 180px; border: 0; border-bottom: 1px dotted #333; background: transparent; font-weight: 600; }
.toplam { font-weight: 700; display: flex; gap: .5rem; align-items: center; }
.toplam input {
  width: 140px;
  border: 1px solid var(--line);
  padding: .35rem .5rem;
  text-align: right;
  font-weight: 700;
}

.when-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border-top: 1px solid var(--line);
}
.when-grid label {
  display: flex;
  flex-direction: column;
  gap: .25rem;
  padding: .55rem .7rem;
  font-size: .78rem;
  font-weight: 700;
  border-bottom: 1px solid var(--line);
}
.when-grid label:nth-child(odd) { border-right: 1px solid var(--line); }
.when-grid input { font-weight: 500; font-size: 1rem; border: 1px solid #ccc; padding: .3rem; }

.confirm-note { font-size: .8rem; font-style: italic; padding: .55rem .8rem; margin: 0; border-bottom: 1px solid var(--line); }

.sign-grid { display: grid; }
@media (min-width: 800px) { .sign-grid { grid-template-columns: 1fr 1fr; } }
.sign-block { padding: .7rem; border-bottom: 1px solid var(--line); }
@media (min-width: 800px) { .sign-block + .sign-block { border-left: 1px solid var(--line); } }
.sign-block h3 { background: transparent; border: 0; padding: 0 0 .4rem; }
.sign-block canvas {
  display: block;
  width: 100%;
  height: 150px;
  border: 1px dashed #888;
  background:
    linear-gradient(#fff, #fff),
    repeating-linear-gradient(0deg, transparent, transparent 24px, #f0f0f0 25px);
  touch-action: none;
  cursor: crosshair;
  margin-top: .5rem;
  border-radius: 4px;
}
.btn-clear {
  margin-top: .4rem;
  background: none;
  border: 0;
  color: var(--muted);
  text-decoration: underline;
  font-size: .8rem;
  padding: 0;
}
.legal-notes { font-size: .72rem; color: #333; padding: .5rem .8rem .7rem; margin: 0; }

.sticky-save {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  background: #161616;
  color: #fff;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: .75rem;
  padding: .7rem 1rem calc(.7rem + env(safe-area-inset-bottom));
  z-index: 50;
  border-top: 3px solid var(--accent);
}
.sticky-save .btn { white-space: nowrap; }
@media (max-width: 480px) {
  .sticky-save { flex-direction: column; align-items: stretch; text-align: center; }
}
body.signing {
  overscroll-behavior: none;
  overflow: hidden;
}

.form-error {
  position: fixed;
  left: 50%;
  bottom: 76px;
  transform: translateX(-50%);
  background: #8b1010;
  color: #fff;
  padding: .6rem 1rem;
  border-radius: 8px;
  z-index: 60;
  max-width: 92%;
}

.success-actions { display: grid; gap: .6rem; margin: 1rem 0; }
@media (min-width: 600px) { .success-actions { grid-template-columns: 1fr 1fr; } }
.btn-wa {
  background: #128c7e;
  border: 0;
  color: #fff;
  padding: .85rem 1rem;
  border-radius: 8px;
  display: block;
  text-align: center;
  text-decoration: none;
  font-weight: 600;
}
.btn-wa:hover { color: #fff; background: #0e7368; }
.btn-wa.company { background: #075e54; }

.filters { display: flex; gap: .5rem; flex-wrap: wrap; margin-bottom: 1rem; }
.filters input, .filters button { min-height: 40px; }

.settings-grid { display: grid; gap: .75rem; }
@media (min-width: 700px) { .settings-grid { grid-template-columns: 1fr 1fr; } }
.settings-grid .full { grid-column: 1 / -1; }
.logo-preview { height: 64px; background: #fff; padding: 4px; border: 1px solid #ddd; }

.pdf-frame {
  width: 100%;
  min-height: 90vh;
  border: 2px solid var(--line);
  background: #fff;
  border-radius: 4px;
}

@media print {
  .app-nav, .sticky-save, .form-toolbar, .form-error, .btn, .btn-clear { display: none !important; }
  body { background: #fff; }
  .app-main { padding: 0; max-width: none; }
  .sheet { box-shadow: none; }
}
