/* Mercury Clair (DESIGN.md) — açık tema, tek sütun, tek vurgu rengi */
:root {
  --page: #eae7de;
  --card: #ffffff;
  --sunk: #dedbcf;
  --sunk-soft: #f5f4ef;
  --text: #1a1a1c;
  --text-2: #363639;
  --muted: #656568;
  --disabled: #b0aea8;
  --border: #d2cfc4;
  --border-strong: #bab8ae;
  --border-subtle: #d8d5cb;
  --brand: #1a6b54;
  --brand-hover: #155848;
  --brand-subtle: #e8f0ec;
  --success: #15803d;
  --success-subtle: #ecfdf3;
  --warning: #b45309;
  --warning-subtle: #fff7e6;
  --danger: #b91c1c;
  --danger-subtle: #fef2f2;
  --shadow-float: 0 1px 3px rgba(0, 0, 0, 0.04), 0 8px 24px rgba(0, 0, 0, 0.06);
  --focus: 0 0 0 3px rgba(26, 107, 84, 0.15);
  --r-md: 10px;
  --r-lg: 12px;
  --r-xl: 16px;
  --pill: 9999px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  color-scheme: light;
  font-family: 'Inter Variable', Inter, ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif;
  -webkit-text-size-adjust: 100%;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  background: var(--page);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
  -webkit-tap-highlight-color: transparent;
}

button,
input {
  font: inherit;
  color: inherit;
}

.tabular {
  font-variant-numeric: tabular-nums;
}
.mono {
  font-family: ui-monospace, 'SF Mono', 'JetBrains Mono', Menlo, monospace;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.01em;
}
.muted {
  color: var(--muted);
}
.caption {
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.01em;
  color: var(--muted);
}
.small {
  font-size: 13px;
}
.truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

h1,
h2,
h3,
h4 {
  margin: 0;
  font-weight: 600;
}
h1 {
  font-size: 28px;
  line-height: 1.2;
  letter-spacing: -0.015em;
}
h2 {
  font-size: 20px;
  line-height: 1.3;
  letter-spacing: -0.01em;
}
h3 {
  font-size: 16px;
  line-height: 1.4;
}
p {
  margin: 0;
}

/* ---- yerleşim ---- */
.shell {
  max-width: 640px;
  margin: 0 auto;
  padding: 12px 16px calc(112px + var(--safe-bottom));
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.shell.no-bar {
  padding-bottom: calc(32px + var(--safe-bottom));
}
.topbar {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 48px;
}
.topbar .grow {
  flex: 1;
  min-width: 0;
}
.stack {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.row.wrap {
  flex-wrap: wrap;
}
.row > .grow {
  flex: 1;
  min-width: 0;
}
.split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.bottom-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 12px 16px calc(12px + var(--safe-bottom));
  background: var(--page);
  border-top: 1px solid var(--border);
  z-index: 10;
}
.bottom-bar > * {
  max-width: 608px;
  margin: 0 auto;
}

/* ---- kart ---- */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  padding: 20px;
}
.card.tight {
  padding: 16px;
}
.card.flush {
  padding: 0;
  overflow: hidden;
}
.nested {
  background: var(--sunk-soft);
  border-radius: var(--r-lg);
  padding: 16px;
}

/* ---- buton (hepsi pill) ---- */
.btn {
  appearance: none;
  border: 1px solid transparent;
  border-radius: var(--pill);
  min-height: 48px;
  padding: 12px 20px;
  font-size: 15px;
  font-weight: 500;
  line-height: 1.2;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  user-select: none;
  transition: background-color 0.12s ease;
  touch-action: manipulation;
}
.btn:focus-visible {
  outline: none;
  box-shadow: var(--focus);
}
.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.btn-primary {
  background: var(--brand);
  color: #fff;
}
.btn-primary:active:not(:disabled) {
  background: var(--brand-hover);
}
.btn-secondary {
  background: var(--sunk-soft);
  border-color: var(--border);
  color: var(--text);
}
.btn-secondary:active:not(:disabled) {
  background: #eeede9;
}
.btn-ghost {
  background: transparent;
  color: var(--text);
  min-height: 40px;
  padding: 8px 12px;
}
.btn-ghost:active {
  background: var(--sunk-soft);
}
.btn-ghost.brand {
  color: var(--brand);
}
.btn-danger {
  background: var(--danger);
  color: #fff;
}
.btn-ghost.danger {
  color: var(--danger);
}
.btn-block {
  width: 100%;
}
.btn-lg {
  min-height: 56px;
  font-size: 16px;
}
.btn-icon {
  min-height: 40px;
  min-width: 40px;
  padding: 8px;
}

/* ---- rozet ---- */
.badge {
  display: inline-flex;
  align-items: center;
  height: 24px;
  padding: 0 10px;
  border-radius: var(--pill);
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
  background: var(--sunk-soft);
  color: var(--text-2);
}
.badge.success {
  background: var(--success-subtle);
  color: var(--success);
}
.badge.warning {
  background: var(--warning-subtle);
  color: var(--warning);
}
.badge.danger {
  background: var(--danger-subtle);
  color: var(--danger);
}
.badge.brand {
  background: var(--brand-subtle);
  color: var(--brand);
}

/* ---- form ---- */
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-2);
}
.input {
  width: 100%;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 12px 14px;
  font-size: 16px; /* iOS 16px altında sayfayı yakınlaştırır */
  min-height: 48px;
}
select.input {
  appearance: none;
  background-image: none;
}
.hint {
  font-size: 13px;
  color: var(--muted);
}
.error-text {
  font-size: 13px;
  color: var(--danger);
}
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.chip {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--card);
  border-radius: var(--pill);
  min-height: 40px;
  padding: 8px 14px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  touch-action: manipulation;
}
.chip.selected {
  background: var(--brand-subtle);
  border-color: var(--brand);
  color: var(--brand);
}
.chip.small {
  min-height: 34px;
  padding: 6px 12px;
  font-size: 13px;
}
.stepper {
  display: grid;
  grid-template-columns: 56px 1fr 56px;
  align-items: center;
  gap: 8px;
}
.stepper .value {
  text-align: center;
  font-size: 28px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

/* ---- sayım ekranı ---- */
.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  overflow: hidden;
}
.stat {
  padding: 12px 8px;
  text-align: center;
  border-left: 1px solid var(--border-subtle);
}
.stat:first-child {
  border-left: 0;
}
.stat .num {
  display: block;
  font-size: 24px;
  font-weight: 600;
  line-height: 1.1;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}
.stat .caption {
  display: block;
  margin-top: 2px;
  line-height: 1.25;
}
.stat.alert .num {
  color: var(--danger);
}
.stat.warn .num {
  color: var(--warning);
}

.result {
  border-radius: var(--r-xl);
  border: 1px solid var(--border);
  background: var(--card);
  padding: 20px;
  min-height: 200px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.result.idle {
  align-items: center;
  justify-content: center;
  text-align: center;
  border-style: dashed;
  border-color: var(--border-strong);
  background: var(--sunk-soft);
}
.result.ok {
  background: var(--success-subtle);
  border-color: #b7e4c7;
  animation: flash 0.5s ease-out;
}
.result .status {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--success);
}
.result .desc {
  font-size: 24px;
  line-height: 1.25;
  font-weight: 600;
  letter-spacing: -0.01em;
  word-break: break-word;
}
.result .code {
  font-size: 18px;
  font-weight: 500;
}
.meta {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 2px 12px;
  font-size: 14px;
}
.meta dt {
  color: var(--muted);
}
.meta dd {
  margin: 0;
  color: var(--text-2);
  word-break: break-word;
}
@keyframes flash {
  from {
    background: #c9f0d6;
  }
}
.pulse-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--brand);
  animation: pulse 1.6s ease-in-out infinite;
}
@keyframes pulse {
  50% {
    opacity: 0.25;
  }
}

.list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.list > li + li {
  border-top: 1px solid var(--border-subtle);
}
.list-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
}
.list-item .body {
  flex: 1;
  min-width: 0;
}
.list-item.removed {
  opacity: 0.45;
}
.list-item.removed .desc-line {
  text-decoration: line-through;
}
.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  padding: 0 4px;
}
a.unit-card {
  text-decoration: none;
  color: inherit;
  width: 100%;
  text-align: left;
}
.unit-card:active {
  background: var(--sunk-soft);
}
.empty {
  text-align: center;
  padding: 32px 16px;
  color: var(--muted);
}

/* ---- katmanlar ---- */
.backdrop {
  position: fixed;
  inset: 0;
  background: rgba(29, 29, 31, 0.4);
  z-index: 40;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.backdrop.center {
  align-items: center;
  padding: 16px;
}
.sheet {
  width: 100%;
  max-width: 640px;
  max-height: 92dvh;
  overflow-y: auto;
  background: var(--card);
  border: 1px solid var(--border);
  border-bottom: 0;
  border-radius: var(--r-xl) var(--r-xl) 0 0;
  box-shadow: var(--shadow-float);
  padding: 8px 20px calc(20px + var(--safe-bottom));
  display: flex;
  flex-direction: column;
  gap: 16px;
  animation: rise 0.18s ease-out;
}
.sheet-head {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 48px;
  position: sticky;
  top: -8px;
  background: var(--card);
  z-index: 1;
}
.sheet-head h2 {
  flex: 1;
}
.dialog {
  width: 100%;
  max-width: 420px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-float);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
@keyframes rise {
  from {
    transform: translateY(24px);
    opacity: 0.6;
  }
}

/* Tam ekran okutma uyarıları — "Tamam"a basmadan kapanmaz */
.alert-full {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 16px;
  padding: 24px 24px calc(24px + var(--safe-bottom));
  color: #fff;
  text-align: center;
  animation: shake 0.45s ease-in-out;
}
.alert-full.danger {
  background: var(--danger);
}
.alert-full.warning {
  background: var(--warning);
}
.alert-full .alert-title {
  font-size: 34px;
  line-height: 1.1;
  font-weight: 600;
  letter-spacing: -0.02em;
}
.alert-full .alert-desc {
  font-size: 22px;
  font-weight: 600;
  line-height: 1.3;
  word-break: break-word;
}
.alert-full .alert-code {
  font-size: 20px;
}
.alert-full .alert-note {
  font-size: 16px;
  opacity: 0.92;
}
.alert-full .verdict {
  align-self: center;
  border: 2px solid rgba(255, 255, 255, 0.85);
  border-radius: var(--pill);
  padding: 8px 18px;
  font-weight: 600;
  letter-spacing: 0.04em;
}
.alert-full .actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
  max-width: 420px;
  margin: 12px auto 0;
}
.btn-on-color {
  background: #fff;
  color: var(--text);
}
.btn-outline-on-color {
  background: transparent;
  color: #fff;
  border-color: rgba(255, 255, 255, 0.8);
}
@keyframes shake {
  20%,
  60% {
    transform: translateX(-8px);
  }
  40%,
  80% {
    transform: translateX(8px);
  }
}

.app-toast {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: calc(92px + var(--safe-bottom));
  z-index: 70;
  max-width: 480px;
  margin: 0 auto;
  background: var(--text);
  color: #fff;
  border-radius: var(--r-lg);
  padding: 12px 16px;
  font-size: 14px;
  font-weight: 500;
  box-shadow: var(--shadow-float);
  animation: rise 0.16s ease-out;
}
.app-toast.danger {
  background: var(--danger);
}
.app-toast.warning {
  background: var(--warning);
}
.app-toast.success {
  background: var(--success);
}

/* ---- tuş takımı ---- */
.keypad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.key {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--sunk-soft);
  border-radius: var(--r-lg);
  min-height: 56px;
  font-size: 22px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
  touch-action: manipulation;
}
.key:active {
  background: var(--sunk);
}
.key.fn {
  font-size: 15px;
  color: var(--text-2);
}
.keypad-display {
  font-size: 30px;
  font-weight: 600;
  text-align: center;
  padding: 12px;
  border-radius: var(--r-lg);
  background: var(--sunk-soft);
  min-height: 64px;
}

.splash {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  color: var(--muted);
}
.file-drop {
  border: 1px dashed var(--border-strong);
  border-radius: var(--r-xl);
  background: var(--sunk-soft);
  padding: 24px 16px;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: center;
}
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* ---- açılır kısayol listesi ---- */
details.more > summary {
  cursor: pointer;
  list-style: none;
  font-weight: 500;
  padding: 12px 4px;
  color: var(--brand);
}
summary::-webkit-details-marker {
  display: none;
}

/* ---- birim listesi: satır + sil ---- */
.unit-row {
  gap: 0;
  padding-right: 8px;
}
.unit-row .unit-card {
  flex: 1;
  min-width: 0;
}

/* ---- kamerayla okutma (tam ekran vizör) ---- */
.camera {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: #0f0f10;
  color: #fff;
}
.camera[hidden] {
  display: none !important;
}
body.camera-open {
  overflow: hidden;
}
body.camera-open .bottom-bar {
  display: none !important;
}
.camera video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.camera .guide {
  position: absolute;
  left: 10%;
  right: 10%;
  top: 30%;
  height: 40%;
  border: 2px solid rgba(255, 255, 255, 0.9);
  border-radius: var(--r-lg);
  box-shadow: 0 0 0 100vmax rgba(0, 0, 0, 0.35); /* çerçeve dışını karart */
}
.cam-top {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: calc(12px + env(safe-area-inset-top, 0px)) 16px 12px;
  background: rgba(15, 15, 16, 0.55);
}
.cam-title {
  font-weight: 600;
}
.cam-bottom {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 16px 16px calc(20px + var(--safe-bottom));
}
.cam-note {
  background: rgba(15, 15, 16, 0.7);
  border-radius: var(--r-lg);
  padding: 12px 16px;
  text-align: center;
}
.cam-note.error {
  background: var(--danger);
}
.cam-result {
  display: flex;
  flex-direction: column;
  gap: 2px;
  background: var(--success-subtle);
  color: var(--text);
  border-radius: var(--r-xl);
  padding: 12px 16px;
  animation: flash 0.5s ease-out;
}
.cam-result .caption {
  color: var(--success);
  font-weight: 600;
}
.btn-on-dark {
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
  min-height: 40px;
  padding: 8px 14px;
}

/* Bootstrap 5 + Mercury Clair */
:root {
  --bs-body-bg: #eae7de;
  --bs-body-color: #1a1a1c;
  --bs-primary: #1a6b54;
  --bs-border-radius: 10px;
}
a.btn {
  text-decoration: none;
  color: inherit;
}
a.btn-primary,
a.btn-secondary,
a.btn-danger {
  color: inherit;
}
a.btn-primary {
  color: #fff;
}
.sheet-canvas.offcanvas.offcanvas-bottom {
  height: auto;
  max-height: 92dvh;
  background: var(--card);
  border: 1px solid var(--border);
  border-bottom: 0;
  border-radius: var(--r-xl) var(--r-xl) 0 0;
  box-shadow: var(--shadow-float);
}
.sheet-canvas .offcanvas-header {
  padding: 8px 20px 0;
}
.sheet-canvas .offcanvas-body {
  padding: 8px 20px calc(20px + var(--safe-bottom));
}
.offcanvas-backdrop {
  background: rgba(29, 29, 31, 0.4);
}
.offcanvas-backdrop.show {
  opacity: 1;
}
