:root {
  --green: #007a2d;
  --green-600: #006626;
  --green-700: #00521f;
  --leaf: #4c9e57;
  --leaf-50: #eef6ef;
  --leaf-100: #dcecde;
  --ink: #161615;
  --ink-2: #4a4f4b;
  --muted: #6f756f;
  --line: #e2e7e2;
  --bg: #f5f7f4;
  --surface: #ffffff;
  --danger: #b42318;
  --danger-50: #fef3f2;
  --warn-50: #fff8e6;
  --warn: #8a5a00;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(22, 22, 21, .05), 0 6px 20px rgba(22, 22, 21, .06);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
  line-height: 1.45;
  -webkit-tap-highlight-color: transparent;
}
[hidden] { display: none !important; }
.sprite { display: none; }
svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }
button { font: inherit; }
a { color: var(--green); }

/* ---------- butonlar / formlar ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 52px; padding: 0 22px; border: 0; border-radius: 14px;
  font-weight: 650; font-size: 16px; cursor: pointer;
  transition: background .15s, transform .05s, opacity .15s;
}
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .55; cursor: default; }
.btn-primary { background: var(--green); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--green-600); }
.btn-block { width: 100%; }
.icon-btn {
  width: 42px; height: 42px; display: grid; place-items: center;
  border: 0; border-radius: 12px; background: transparent; color: var(--ink-2); cursor: pointer;
}
.icon-btn:hover { background: var(--leaf-50); color: var(--green); }
.link-btn { border: 0; background: none; color: var(--green); font-weight: 600; font-size: 14px; cursor: pointer; padding: 6px 4px; }

.form { display: grid; gap: 14px; }
.field { display: grid; gap: 6px; font-size: 14px; font-weight: 600; color: var(--ink-2); }
.field small { font-weight: 400; color: var(--muted); }
.field input {
  width: 100%; min-height: 50px; padding: 0 14px;
  border: 1.5px solid var(--line); border-radius: 12px; background: var(--surface);
  font: inherit; font-size: 16px; color: var(--ink); font-weight: 400;
}
.field input:focus { outline: none; border-color: var(--leaf); box-shadow: 0 0 0 4px var(--leaf-100); }
.form-error { margin: 0; padding: 10px 12px; border-radius: 10px; background: var(--danger-50); color: var(--danger); font-size: 14px; }

/* ---------- giris ---------- */
.login {
  min-height: 100dvh; display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 24px 16px calc(24px + var(--safe-bottom));
  background:
    radial-gradient(1200px 500px at 50% -10%, var(--leaf-100), transparent 60%),
    var(--bg);
}
.login-card {
  width: 100%; max-width: 400px; padding: 32px 24px 28px;
  background: var(--surface); border-radius: 22px; box-shadow: var(--shadow);
  border-top: 5px solid var(--leaf);
}
.login-logo { display: block; width: 168px; height: auto; margin: 0 0 22px; }
.login-title { margin: 0; font-size: 26px; letter-spacing: -.01em; color: var(--green); }
.login-title span { color: var(--ink); font-weight: 600; }
.login-sub { margin: 6px 0 22px; color: var(--muted); font-size: 15px; }
.login-foot { margin-top: 18px; color: var(--muted); font-size: 13px; }

/* ---------- uygulama ---------- */
.app { min-height: 100dvh; }
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 8px;
  padding: calc(10px + env(safe-area-inset-top, 0px)) 12px 10px 16px;
  background: rgba(255, 255, 255, .92); backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--line);
}
.topbar-logo { width: 112px; height: auto; }
.topbar-badge {
  margin-right: auto; padding: 3px 10px; border-radius: 999px;
  background: var(--leaf-50); color: var(--green); font-weight: 700; font-size: 13px; letter-spacing: .02em;
}

.content { max-width: 620px; margin: 0 auto; padding: 16px 16px 170px; display: grid; gap: 16px; }

.banner { padding: 10px 14px; border-radius: 12px; font-size: 14px; }
.banner-warn { background: var(--warn-50); color: var(--warn); }
.banner-info { background: var(--leaf-50); color: var(--ink-2); }

.capture { display: grid; gap: 10px; }
.capture-main {
  display: flex; align-items: center; gap: 16px;
  padding: 22px 20px; border-radius: 20px; cursor: pointer; color: #fff;
  background: linear-gradient(135deg, var(--leaf) 0%, var(--green) 70%);
  box-shadow: 0 8px 24px rgba(0, 122, 45, .25);
  transition: transform .05s;
}
.capture-main:active { transform: scale(.985); }
.capture-icon { width: 60px; height: 60px; border-radius: 16px; display: grid; place-items: center; background: rgba(255, 255, 255, .18); }
.capture-icon svg { width: 32px; height: 32px; stroke-width: 1.7; }
.capture-text { display: grid; }
.capture-text strong { font-size: 20px; }
.capture-text small { opacity: .85; font-size: 14px; }
.capture-alt {
  display: flex; align-items: center; gap: 10px; justify-content: center;
  min-height: 52px; padding: 0 16px; border-radius: 14px; cursor: pointer;
  background: var(--surface); border: 1.5px dashed #c5d3c6; color: var(--ink-2); font-weight: 600; font-size: 15px;
}
.capture-alt:hover { border-color: var(--leaf); color: var(--green); }
.capture-alt small { font-weight: 400; color: var(--muted); }

.section-head { display: flex; align-items: center; justify-content: space-between; }
.section-head h2 { margin: 0; font-size: 17px; }
.hint { margin: 2px 0 0; color: var(--muted); font-size: 14px; }

.pages { display: grid; gap: 12px; padding: 16px; background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); }
.page-grid { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 10px; }
.page-grid:empty { display: none; }
.page {
  position: relative; aspect-ratio: 3 / 4; border-radius: 12px; overflow: hidden;
  background: var(--leaf-50); border: 1px solid var(--line);
}
.page img { width: 100%; height: 100%; object-fit: contain; display: block; }
.page.busy img { opacity: .4; }
.page-no {
  position: absolute; top: 6px; left: 6px; min-width: 24px; height: 24px; padding: 0 7px;
  border-radius: 999px; background: var(--ink); color: #fff; font-size: 12px; font-weight: 700;
  display: grid; place-items: center;
}
.page-tools { position: absolute; left: 0; right: 0; bottom: 0; display: flex; justify-content: space-between; padding: 6px; gap: 4px;
  background: linear-gradient(transparent, rgba(22, 22, 21, .55)); }
.page-tools button {
  width: 34px; height: 34px; display: grid; place-items: center; border: 0; border-radius: 10px;
  background: rgba(255, 255, 255, .94); color: var(--ink); cursor: pointer;
}
.page-tools button svg { width: 18px; height: 18px; }
.page-tools .del { color: var(--danger); }
.page-tools .spacer { flex: 1; }

.pdf-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.pdf-list:empty { display: none; }
.pdf-item { display: flex; align-items: center; gap: 10px; padding: 10px 8px 10px 12px; border: 1px solid var(--line); border-radius: 12px; }
.pdf-item > svg { color: var(--danger); }
.pdf-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 15px; }
.pdf-size { color: var(--muted); font-size: 13px; }
.pdf-item .icon-btn { color: var(--danger); width: 36px; height: 36px; }

.empty { padding: 18px; border-radius: var(--radius); border: 1.5px dashed var(--line); color: var(--muted); font-size: 15px; text-align: center; }
.empty p { margin: 0; }

.recent { display: grid; gap: 10px; }
.recent-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.recent-item { display: flex; align-items: center; gap: 12px; padding: 12px 14px; background: var(--surface); border-radius: 12px; box-shadow: var(--shadow); }
.recent-item > svg { color: var(--leaf); }
.recent-main { flex: 1; min-width: 0; display: grid; }
.recent-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; font-size: 14px; }
.recent-meta { color: var(--muted); font-size: 12px; }
.recent-item a { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 10px; color: var(--green); }
.recent-item a:hover { background: var(--leaf-50); }

.target { margin: 0; text-align: center; color: var(--muted); font-size: 13px; }

.action-bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  padding: 12px 16px calc(12px + var(--safe-bottom));
  background: rgba(255, 255, 255, .96); backdrop-filter: blur(10px);
  border-top: 1px solid var(--line); box-shadow: 0 -6px 24px rgba(22, 22, 21, .06);
  display: grid; gap: 8px;
}
.action-bar > * { width: 100%; max-width: 588px; margin: 0 auto; }
.action-summary { font-size: 14px; color: var(--ink-2); text-align: center; }
.progress { height: 6px; border-radius: 999px; background: var(--leaf-100); overflow: hidden; }
.progress-bar { height: 100%; width: 0; background: var(--green); transition: width .2s; }

.toast {
  position: fixed; left: 50%; top: calc(14px + env(safe-area-inset-top, 0px)); z-index: 50; transform: translateX(-50%);
  max-width: calc(100% - 32px); padding: 12px 16px; border-radius: 12px;
  background: var(--ink); color: #fff; font-size: 14px; box-shadow: var(--shadow);
}
.toast.ok { background: var(--green); }
.toast.err { background: var(--danger); }

@media (min-width: 720px) {
  .content { padding-top: 28px; }
  .capture { grid-template-columns: 1.4fr 1fr; }
  .capture-alt { min-height: auto; flex-direction: column; text-align: center; padding: 16px; }
}
