* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --primary: #0066b3;
  --primary-dark: #004a80;
  --accent: #00a8e1;
  --bg: #f5f7fa;
  --card: #ffffff;
  --text: #1a1a1a;
  --text-sub: #666;
  --border: #ddd;
  --success: #2ecc71;
  --danger: #e74c3c;
  --shadow: 0 2px 8px rgba(0,0,0,0.08);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "ヒラギノ角ゴシック", "Yu Gothic", "メイリオ", sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-text-size-adjust: 100%;
}

header {
  background: var(--primary);
  color: white;
  padding: 16px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: var(--shadow);
}

header h1 {
  font-size: 18px;
  font-weight: 600;
}

#user-info {
  font-size: 13px;
  opacity: 0.95;
  display: flex;
  align-items: center;
  gap: 8px;
}

#user-info .btn-mini {
  background: rgba(255,255,255,0.2);
  color: white;
  border-color: rgba(255,255,255,0.3);
}

#user-info .btn-mini:hover {
  background: rgba(255,255,255,0.3);
}

.login-error {
  color: var(--danger);
  font-size: 13px;
  min-height: 18px;
  margin-top: 6px;
}

main {
  max-width: 720px;
  margin: 0 auto;
  padding: 20px;
}

.step {
  display: none;
  background: var(--card);
  border-radius: 12px;
  padding: 24px;
  box-shadow: var(--shadow);
  margin-bottom: 16px;
}

.step.active {
  display: block;
  animation: fadeIn 0.2s ease-out;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

h2 {
  font-size: 20px;
  margin-bottom: 20px;
  color: var(--text);
}

/* Mode selection */
.mode-buttons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.mode-btn {
  background: white;
  border: 2px solid var(--border);
  border-radius: 12px;
  padding: 24px 16px;
  cursor: pointer;
  transition: all 0.15s;
  font-family: inherit;
  text-align: center;
}

.mode-btn:hover, .mode-btn:active {
  border-color: var(--primary);
  background: #f0f8ff;
  transform: translateY(-1px);
}

.mode-icon {
  font-size: 40px;
  margin-bottom: 8px;
}

.mode-label {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 4px;
}

.mode-desc {
  font-size: 12px;
  color: var(--text-sub);
}

/* Upload area */
.upload-area {
  border: 2px dashed var(--border);
  border-radius: 12px;
  padding: 40px 20px;
  text-align: center;
  cursor: pointer;
  transition: all 0.15s;
}

.upload-area:hover, .upload-area.dragging {
  border-color: var(--primary);
  background: #f0f8ff;
}

.upload-icon {
  font-size: 56px;
  margin-bottom: 12px;
}

.upload-text {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 4px;
}

.upload-hint {
  font-size: 13px;
  color: var(--text-sub);
}

/* Forms */
.field-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--text-sub);
}

.text-input, textarea {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 16px;
  font-family: inherit;
  background: white;
}

.text-input:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(0,102,179,0.1);
}

textarea {
  resize: vertical;
  line-height: 1.6;
}

.hint {
  font-size: 12px;
  color: var(--text-sub);
  margin-top: 6px;
}

/* Items list */
.quick-actions {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.btn-mini {
  padding: 6px 12px;
  border: 1px solid var(--border);
  background: white;
  border-radius: 6px;
  font-size: 12px;
  cursor: pointer;
  font-family: inherit;
}

.btn-mini:hover {
  background: var(--bg);
}

.items-list {
  max-height: 50vh;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 12px;
}

.item-row {
  display: flex;
  align-items: center;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.1s;
  gap: 12px;
}

.item-row:last-child { border-bottom: none; }
.item-row:hover { background: #f0f8ff; }
.item-row.selected { background: #e3f2fd; }

.item-row input[type="checkbox"] {
  width: 22px;
  height: 22px;
  cursor: pointer;
  accent-color: var(--primary);
}

.item-code {
  display: inline-block;
  background: var(--primary);
  color: white;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 12px;
  min-width: 28px;
  text-align: center;
}

.item-name {
  flex: 1;
  font-size: 14px;
  line-height: 1.4;
}

.item-price {
  font-weight: 600;
  color: var(--primary);
  font-size: 14px;
  white-space: nowrap;
}

.summary-bar {
  background: #f0f8ff;
  padding: 12px 16px;
  border-radius: 8px;
  margin-bottom: 12px;
  text-align: right;
  font-size: 14px;
}

.summary-bar strong {
  color: var(--primary);
  font-size: 16px;
}

/* Navigation buttons */
.nav-buttons {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 20px;
}

.nav-buttons-row {
  display: flex;
  gap: 8px;
  margin-top: 16px;
  flex-wrap: wrap;
}

.btn-back, .btn-next, .btn-primary, .btn-secondary {
  padding: 12px 18px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  font-family: inherit;
  transition: all 0.15s;
}

.btn-back {
  background: white;
  border: 1px solid var(--border);
  color: var(--text-sub);
}

.btn-next, .btn-primary {
  background: var(--primary);
  color: white;
  flex: 1;
}

.btn-next:hover, .btn-primary:hover {
  background: var(--primary-dark);
}

.btn-secondary {
  background: white;
  border: 1px solid var(--primary);
  color: var(--primary);
}

.btn-secondary:hover {
  background: #f0f8ff;
}

.char-count {
  font-weight: normal;
  color: var(--text-sub);
  font-size: 11px;
  margin-left: 6px;
}

.char-count.over {
  color: var(--danger);
  font-weight: 600;
}

.copy-status {
  margin-top: 10px;
  font-size: 13px;
  color: var(--success);
  font-weight: 600;
  min-height: 20px;
  text-align: center;
}

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
}

.modal.hidden { display: none; }

.modal-content {
  background: white;
  border-radius: 12px;
  padding: 24px;
  max-width: 400px;
  width: 100%;
  text-align: center;
}

.modal-content.wide {
  max-width: 600px;
  text-align: left;
}

.modal-content h3 {
  font-size: 18px;
  margin-bottom: 16px;
}

#qr-code {
  display: flex;
  justify-content: center;
  margin: 20px 0;
}

#qr-code img, #qr-code canvas {
  max-width: 100%;
}

.template-selector-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}

.template-selector-row select {
  flex: 1;
}

.template-selector-row .field-label {
  margin-bottom: 0;
  white-space: nowrap;
}

.template-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.tab-btn {
  padding: 8px 14px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  color: var(--text-sub);
}

.tab-btn.active {
  border-bottom-color: var(--primary);
  color: var(--primary);
  font-weight: 600;
}

.hidden { display: none !important; }

code {
  background: #f0f0f0;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 12px;
  font-family: "SF Mono", Consolas, monospace;
}

/* iPad / large screens */
@media (min-width: 768px) {
  header h1 { font-size: 22px; }
  main { padding: 32px; }
  .step { padding: 32px; }
}
