:root {
  --bg: #0d1117;
  --card: #161b22;
  --border: #30363d;
  --text: #e6edf3;
  --muted: #8b949e;
  --accent: #1f6feb;
  --accent-hover: #388bfd;
  --warn: #d29922;
  --ok: #3fb950;
  --err: #f85149;
  --radius: 12px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Malgun Gothic", sans-serif;
  line-height: 1.5;
}

.app {
  max-width: 560px;
  margin: 0 auto;
  padding: 16px calc(16px + env(safe-area-inset-right)) 48px calc(16px + env(safe-area-inset-left));
}

.topbar {
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
  margin: 8px 0 16px;
}
.topbar h1 { font-size: 1.25rem; margin: 0; }

.store-name { font-size: 1.1rem; font-weight: 700; }
.store-id {
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--muted);
  margin-left: 6px;
}
.store-id:not(:empty)::before { content: "("; }
.store-id:not(:empty)::after { content: ")"; }
.store-sub { font-size: 0.85rem; color: var(--muted); margin-top: 2px; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 14px;
  overflow: hidden;
}
.card.muted { opacity: 0.85; }
.card > summary {
  cursor: pointer;
  padding: 14px 16px;
  font-weight: 600;
  user-select: none;
}
.card-body { padding: 4px 16px 16px; }
.card-body h2 { font-size: 1.05rem; margin: 8px 0 12px; }
.card-body h3 { font-size: 0.85rem; color: var(--muted); margin: 14px 0 4px; }

label {
  display: block;
  font-size: 0.85rem;
  color: var(--muted);
  margin: 12px 0 0;
}
label .hint { font-size: 0.72rem; opacity: 0.8; }
input {
  width: 100%;
  margin-top: 4px;
  padding: 11px 12px;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 16px; /* iOS 확대 방지 */
}
input:focus { outline: none; border-color: var(--accent); }

.row { display: flex; gap: 10px; margin-top: 16px; align-items: center; }
.row.between { justify-content: space-between; }

.search-row { display: flex; gap: 10px; align-items: center; margin-top: 12px; }
.search-row input { margin-top: 0; letter-spacing: 0.18em; }
.search-row button { flex: none; }
.search-result { font-size: 0.82rem; color: var(--muted); margin-top: 10px; }
.search-result:empty { display: none; }
.search-result.err { color: var(--err); }
.search-result.warn { color: var(--warn); margin: 10px 0 0; }

button {
  font-size: 0.95rem;
  padding: 11px 18px;
  border-radius: 8px;
  border: 1px solid transparent;
  cursor: pointer;
  font-weight: 600;
}
button.primary { background: var(--accent); color: #fff; }
button.primary:hover { background: var(--accent-hover); }
button.ghost { background: transparent; color: var(--muted); border-color: var(--border); }
button:disabled { opacity: 0.5; cursor: default; }

.warn { font-size: 0.78rem; color: var(--warn); margin: 14px 0 0; }

.status { font-size: 0.9rem; color: var(--muted); }
.status.ok { color: var(--ok); }
.status.err { color: var(--err); }
.status.loading { color: var(--accent); }

.tickets { display: grid; gap: 10px; }
.ticket {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  background: var(--bg);
}
.ticket-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.ticket-title { font-weight: 600; }
.ticket-value { font-size: 1.05rem; margin: 4px 0 6px; }
.ticket-value .kind { font-size: 0.78rem; color: var(--ok); margin-left: 2px; }
.ticket-meta { font-size: 0.8rem; color: var(--muted); }
.ticket-meta b { color: var(--text); font-weight: 600; }

.badge {
  flex: none;
  font-size: 0.7rem;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--muted);
}
.badge.ok { color: var(--ok); border-color: var(--ok); }

.ticket.car { cursor: pointer; }
.ticket.car:hover { border-color: var(--accent); }
.ticket.car.selected { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }

.apply-target { font-size: 0.85rem; color: var(--muted); margin: 10px 0 0; }
.apply-target:empty { display: none; }

.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 10;
}
.modal[hidden] { display: none; }
.modal-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  width: 100%;
  max-width: 380px;
  max-height: 90vh;
  overflow-y: auto;
}
.modal-card h2 { margin: 0 0 12px; font-size: 1.05rem; }
.modal-info {
  font-size: 0.9rem;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}
.modal-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.85rem;
  color: var(--muted);
  margin-top: 14px;
}
.modal-row b { color: var(--text); }
.modal-card .row { margin-top: 18px; }
.modal-card .row button { flex: 1; }
.modal-card .warn { font-size: 0.75rem; margin: 8px 0 0; }

label.check {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
}
label.check input { width: auto; margin: 0; }

.stepper { display: flex; gap: 8px; align-items: center; margin-top: 6px; }
.stepper input { flex: 1; margin-top: 0; }
.stepper button { flex: none; width: 46px; padding: 11px 0; font-size: 1.1rem; }

.count { font-size: 0.8rem; font-weight: 500; color: var(--muted); }

.raw {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px;
  font-size: 0.72rem;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-all;
  color: var(--muted);
  max-height: 260px;
  overflow-y: auto;
}
