:root {
  --bg: #0a0a0a;
  --home-bg: #fdf6f4;
  --surface: #141414;
  --surface-light: #ffffff;
  --surface2: #1c1c1c;
  --border: #2a2a2a;
  --border-light: #e8e0dc;
  --text: #f5f5f5;
  --text-dark: #1a1a1a;
  --muted: #9a9a9a;
  --muted-light: #6b6b6b;
  --gold: #c9a227;
  --gold-dim: #8a7020;
  --green: #2ecc71;
  --red: #e74c3c;
  --blue: #1e6fd9;
  --blue-dark: #1557b0;
  --radius: 14px;
  --hero-h: 168px;
  --page-h: 56px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.45;
  -webkit-tap-highlight-color: transparent;
}

a { color: var(--gold); text-decoration: none; }

/* Login */
.login-page {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
  background: radial-gradient(ellipse at top, #1a1510 0%, var(--bg) 60%);
}
.login-wrap { width: 100%; max-width: 400px; }
.brand { text-align: center; margin-bottom: 28px; }
.brand-mark {
  width: 72px; height: 72px; margin: 0 auto 12px;
  border-radius: 20px;
  background: linear-gradient(135deg, var(--gold), var(--gold-dim));
  display: flex; align-items: center; justify-content: center;
  font-size: 32px; font-weight: 800; color: #111;
}
.brand h1 { font-size: 26px; letter-spacing: 0.04em; }
.brand p { color: var(--muted); margin-top: 4px; font-size: 14px; }
.login-note { text-align: center; color: var(--muted); font-size: 12px; margin-top: 20px; }

/* Hero header (ana sayfa) */
.hero-header {
  position: relative;
  padding: 28px 20px 48px;
  text-align: center;
  color: #fff;
  background: linear-gradient(160deg, #2d8cff 0%, #1e6fd9 45%, #1557b0 100%);
  border-radius: 0 0 28px 28px;
  box-shadow: 0 8px 24px rgba(30, 111, 217, 0.25);
}
.hero-logout {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  opacity: 0.9;
  border-radius: 10px;
  background: rgba(255,255,255,0.12);
}
.hero-brand { font-size: 22px; font-weight: 800; letter-spacing: 0.02em; }
.hero-shop { font-size: 14px; opacity: 0.9; margin-top: 4px; }
.hero-user { font-size: 15px; font-weight: 600; margin-top: 14px; }
.hero-role { font-size: 13px; opacity: 0.85; margin-top: 2px; }

/* Alt sayfa başlığı */
.page-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  height: var(--page-h);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  background: rgba(10,10,10,0.95);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.page-header[hidden] { display: none !important; }
.btn-back {
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 10px;
  background: var(--surface2);
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
}
.page-title {
  flex: 1;
  font-size: 17px;
  font-weight: 700;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.period-select-compact {
  flex-shrink: 0;
  max-width: 110px;
  padding: 8px 8px;
  font-size: 12px;
}

body.mode-home {
  background: var(--home-bg);
  color: var(--text-dark);
}
body.mode-home .hero-header { display: block; }
body.mode-home .page-header { display: none !important; }
body.mode-home .app-main {
  padding: 8px 14px calc(20px + var(--safe-b));
  max-width: 520px;
}
body.mode-page {
  background: var(--bg);
  color: var(--text);
}
body.mode-page .hero-header { display: none; }
body.mode-page .page-header { display: flex !important; }
body.mode-page .app-main {
  padding: calc(var(--page-h) + 12px) 12px calc(20px + var(--safe-b));
  max-width: 720px;
}

.app-main {
  margin: 0 auto;
}

/* Ana sayfa grid */
.home-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}
.menu-tile {
  aspect-ratio: 1;
  border: none;
  border-radius: 16px;
  background: var(--surface-light);
  box-shadow: 0 2px 12px rgba(0,0,0,0.06);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 12px 8px;
  cursor: pointer;
  color: var(--text-dark);
  transition: transform 0.15s, box-shadow 0.15s;
}
.menu-tile:active {
  transform: scale(0.97);
  box-shadow: 0 1px 6px rgba(0,0,0,0.08);
}
.menu-tile svg {
  width: 36px;
  height: 36px;
  stroke: #111;
  fill: none;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.menu-tile span {
  font-size: 11px;
  font-weight: 600;
  line-height: 1.25;
  text-align: center;
}

body.mode-page .card {
  background: var(--surface);
  border-color: var(--border);
}
body.mode-page .section-title { color: var(--muted); }
body.mode-page input,
body.mode-page select,
body.mode-page textarea {
  background: var(--surface2);
  border-color: var(--border);
  color: var(--text);
}

.period-select {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 10px;
  padding: 8px 10px;
  font-size: 13px;
}
body.mode-home .period-select { display: none; }

/* Eski topbar/bottom-nav kaldırıldı */

.customer-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--gold-dim), var(--gold));
  color: #111;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 16px;
  flex-shrink: 0;
}
.customer-inline-fields {
  margin-top: 10px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}
.customer-inline-fields[hidden] { display: none; }
.link-btn {
  background: none;
  border: none;
  color: var(--gold);
  font-size: 13px;
  padding: 0;
  cursor: pointer;
  margin-top: 6px;
}

/* Cards */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
}
.form-card label { display: block; font-size: 12px; color: var(--muted); margin: 12px 0 6px; }
.form-card label:first-child { margin-top: 0; }

.stat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 12px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
}
.stat-card.wide { grid-column: 1 / -1; }
.stat-label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }
.stat-value { font-size: 22px; font-weight: 700; margin-top: 4px; }
.stat-value.gold { color: var(--gold); }
.stat-value.green { color: var(--green); }
.stat-value.red { color: var(--red); }

.section-title {
  font-size: 13px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin: 16px 0 8px;
}

/* Forms */
input, select, textarea {
  width: 100%;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text);
  font-size: 16px;
}
textarea { min-height: 80px; resize: vertical; }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--gold);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 12px 18px;
  border-radius: 12px;
  border: none;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}
.btn-primary {
  background: linear-gradient(135deg, var(--gold), var(--gold-dim));
  color: #111;
}
.btn-secondary {
  background: var(--surface2);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-danger {
  background: rgba(220, 53, 69, 0.15);
  color: #ff6b7a;
  border: 1px solid rgba(220, 53, 69, 0.35);
}
.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}
.btn-block { width: 100%; }
.btn-sm { padding: 8px 12px; font-size: 13px; }
.btn-icon {
  width: 40px; height: 40px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 10px;
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  text-decoration: none;
  font-size: 16px;
}

.alert {
  padding: 12px 14px;
  border-radius: 10px;
  margin-bottom: 12px;
  font-size: 14px;
}
.alert-error { background: #3a1515; color: #ff8a80; }
.alert-success { background: #153a20; color: #81c784; }

/* Lists */
.list-item {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
}
.list-item:last-child { border-bottom: none; }
.list-item-product { align-items: center; }
.list-item-body { flex: 1; min-width: 0; }
.product-thumb {
  width: 56px;
  height: 56px;
  border-radius: 12px;
  object-fit: cover;
  flex-shrink: 0;
  border: 1px solid var(--border);
  background: var(--surface2);
}
.product-thumb-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
}
.product-detail-image {
  margin-bottom: 16px;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--surface2);
}
.product-detail-image img {
  width: 100%;
  max-height: 280px;
  object-fit: cover;
  display: block;
}
.image-upload { margin-bottom: 8px; }
.image-preview {
  width: 100%;
  height: 180px;
  border-radius: 12px;
  border: 1px dashed var(--border);
  background: var(--surface2);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  margin-bottom: 10px;
}
.image-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.image-preview-empty { color: var(--muted); font-size: 14px; }
.image-upload input[type="file"] { font-size: 14px; }
.remove-image {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--muted);
  margin-top: 8px;
}
.item-title { font-weight: 600; font-size: 15px; }
.item-meta { font-size: 12px; color: var(--muted); margin-top: 4px; }
.item-right { text-align: right; white-space: nowrap; }
.badge {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
}
.badge-low { background: #3a1515; color: #ff8a80; }
.badge-ok { background: #153a20; color: #81c784; }

.payment-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.payment-tag {
  font-size: 11px;
  padding: 4px 8px;
  border-radius: 8px;
  background: var(--surface2);
  border: 1px solid var(--border);
}

.toolbar {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.toolbar input { flex: 1; min-width: 140px; }

.fab {
  position: fixed;
  right: 16px;
  bottom: calc(20px + var(--safe-b));
  width: 56px; height: 56px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, var(--gold), var(--gold-dim));
  color: #111;
  font-size: 28px;
  font-weight: 300;
  box-shadow: 0 4px 20px rgba(201,162,39,0.35);
  cursor: pointer;
  z-index: 90;
}

/* Modal */
.modal[hidden] { display: none; }
.modal {
  position: fixed; inset: 0; z-index: 200;
  display: flex; align-items: flex-end;
}
.modal-backdrop {
  position: absolute; inset: 0;
  background: rgba(0,0,0,0.6);
}
.modal-sheet {
  position: relative;
  width: 100%;
  max-height: 90dvh;
  background: var(--surface);
  border-radius: 20px 20px 0 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px;
  border-bottom: 1px solid var(--border);
}
.modal-header h2 { font-size: 17px; }
.modal-body {
  padding: 16px;
  overflow-y: auto;
  flex: 1;
}

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.form-actions { display: flex; gap: 10px; margin-top: 16px; }
.form-actions .btn { flex: 1; }
.modal-body .form-actions {
  position: sticky;
  bottom: 0;
  background: var(--surface);
  padding-top: 12px;
  margin-top: 20px;
  border-top: 1px solid var(--border);
}

.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--muted);
}
.empty-state p { margin-top: 8px; font-size: 14px; }

.size-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  margin-top: 6px;
}
.size-grid-readonly { margin-top: 8px; }
.size-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 4px;
}
.size-cell-empty { opacity: 0.45; }
.size-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--gold);
}
.size-cell input {
  width: 100%;
  text-align: center;
  padding: 6px 4px;
  font-size: 14px;
}
.size-qty {
  font-size: 15px;
  font-weight: 700;
}
.size-hint {
  font-size: 11px;
  color: var(--muted);
  margin-top: 6px;
  line-height: 1.4;
}
.size-summary {
  color: var(--gold) !important;
  font-weight: 500;
}
.size-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  color: var(--gold);
  background: rgba(212, 175, 55, 0.15);
  padding: 2px 6px;
  border-radius: 4px;
  margin-left: 4px;
  vertical-align: middle;
}

@media (max-width: 380px) {
  .size-grid { grid-template-columns: repeat(3, 1fr); }
}

.sale-search {
  width: 100%;
  margin-bottom: 12px;
}
.sale-product-list {
  display: flex;
  flex-direction: column;
  gap: 0;
  max-height: 52dvh;
  overflow-y: auto;
  margin: 0 -4px;
  background: var(--surface);
}
.sale-product-card {
  width: 100%;
  text-align: left;
  background: var(--surface);
  border: none;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  padding: 12px 4px;
  color: var(--text);
  font: inherit;
  -webkit-appearance: none;
  appearance: none;
}
.sale-product-card:last-child { border-bottom: none; }
.sale-product-card.sale-product-selected {
  background: rgba(212, 175, 55, 0.08);
  box-shadow: inset 0 0 0 2px var(--gold);
  border-radius: 12px;
}
.sale-selected-summary {
  margin-bottom: 16px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
}
.sale-selected-product {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}
.size-chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 4px;
}
.size-chip {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  min-width: 52px;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text);
  cursor: pointer;
  font: inherit;
  -webkit-appearance: none;
  appearance: none;
}
.size-chip-selected {
  border-color: var(--gold);
  background: rgba(212, 175, 55, 0.15);
}
.size-chip-label {
  font-size: 13px;
  font-weight: 700;
  color: var(--gold);
}
.size-chip-qty {
  font-size: 11px;
  color: var(--muted);
  margin-top: 2px;
}

@media (min-width: 768px) {
  .stat-grid { grid-template-columns: repeat(3, 1fr); }
  .stat-card.wide { grid-column: span 2; }
  .modal { align-items: center; justify-content: center; }
  .modal-sheet {
    max-width: 480px;
    border-radius: var(--radius);
    max-height: 85dvh;
  }
}
