/* ===== Reset & Base ===== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --primary: #1a73e8;
  --primary-dark: #1557b0;
  --bg: #f5f7fa;
  --surface: #ffffff;
  --text: #1a1a1a;
  --text-secondary: #5f6368;
  --border: #dadce0;
  --danger: #d93025;
  --danger-bg: #fce8e6;
  --success: #1e8e3e;
  --success-bg: #e6f4ea;
  --warning: #f9ab00;
  --warning-bg: #fef7e0;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-lg: 0 4px 12px rgba(0,0,0,0.1), 0 2px 4px rgba(0,0,0,0.06);
  --font: 'Noto Sans JP', -apple-system, BlinkMacSystemFont, sans-serif;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
}

/* ===== Layout ===== */
.container {
  max-width: 600px;
  margin: 0 auto;
  padding: 16px;
}

/* ===== Header ===== */
.app-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 12px 16px;
  position: sticky;
  top: 0;
  z-index: 100;
}

.app-header h1 {
  font-size: 1.125rem;
  font-weight: 700;
  text-align: center;
}

.app-header .store-badge {
  display: inline-block;
  background: var(--primary);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 500;
  padding: 2px 10px;
  border-radius: 20px;
  margin-left: 8px;
  vertical-align: middle;
}

/* ===== Section Card ===== */
.section-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 16px;
  overflow: hidden;
}

.section-header {
  background: #f8f9fa;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  font-weight: 700;
  font-size: 0.875rem;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
}

.section-header .icon {
  font-size: 1rem;
}

/* ===== Buttons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 24px;
  border: none;
  border-radius: var(--radius);
  font-family: var(--font);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  min-height: 48px;
}

.btn:active {
  transform: scale(0.97);
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}

.btn-primary:active {
  background: var(--primary-dark);
}

.btn-outline {
  background: transparent;
  color: var(--primary);
  border: 2px solid var(--primary);
}

.btn-danger {
  background: var(--danger);
  color: #fff;
}

.btn-block {
  display: flex;
  width: 100%;
}

.btn-lg {
  padding: 16px 32px;
  font-size: 1.125rem;
  min-height: 56px;
}

/* ===== Form Inputs ===== */
.form-row {
  display: flex;
  align-items: center;
  padding: 8px 16px;
  border-bottom: 1px solid #f0f0f0;
  gap: 8px;
}

.form-row:last-child {
  border-bottom: none;
}

.form-row label {
  flex: 1;
  font-size: 0.875rem;
  color: var(--text);
  min-width: 0;
}

.form-row input[type="number"],
.form-row input[type="text"] {
  width: 130px;
  flex-shrink: 0;
  padding: 8px 12px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-family: var(--font);
  font-size: 1rem;
  text-align: right;
  background: var(--surface);
  transition: border-color 0.15s;
  -webkit-appearance: none;
  appearance: none;
}

.form-row input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(26, 115, 232, 0.15);
}

.form-row .calculated {
  width: 130px;
  flex-shrink: 0;
  padding: 8px 12px;
  text-align: right;
  font-size: 1rem;
  font-weight: 600;
  color: var(--primary);
  background: #e8f0fe;
  border-radius: 8px;
}

/* ===== Totals Row ===== */
.total-row {
  background: #f8f9fa;
  border-top: 2px solid var(--border);
  font-weight: 700;
}

.total-row .calculated {
  font-weight: 700;
  font-size: 1.0625rem;
}

/* ===== Denomination Table ===== */
.denom-row {
  display: grid;
  grid-template-columns: 80px 1fr 100px;
  align-items: center;
  padding: 6px 16px;
  border-bottom: 1px solid #f0f0f0;
  gap: 8px;
}

/* 2列入力（レジ/封筒） */
.denom-row-2col {
  grid-template-columns: 70px 1fr 1fr;
}

.denom-col-header {
  background: #f8f9fa;
  border-bottom: 2px solid var(--border);
  padding: 4px 16px;
}

.denom-col-label {
  text-align: center;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-secondary);
}

.denom-subtotal-row {
  background: #f8f9fa;
  border-top: 2px solid var(--border);
  padding: 10px 16px;
  grid-template-columns: 70px 1fr 1fr 1fr;
}

.denom-row:last-child {
  border-bottom: none;
}

.denom-label {
  font-size: 0.875rem;
  font-weight: 500;
}

.denom-row input {
  width: 100%;
  padding: 6px 10px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-family: var(--font);
  font-size: 1rem;
  text-align: right;
  -webkit-appearance: none;
  appearance: none;
}

.denom-row input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(26, 115, 232, 0.15);
}

.denom-amount {
  text-align: right;
  font-size: 0.9375rem;
  font-weight: 500;
  color: var(--text-secondary);
}

/* ===== Alert ===== */
.alert {
  padding: 10px 16px;
  border-radius: 8px;
  font-size: 0.875rem;
  font-weight: 500;
  margin: 8px 16px;
}

.alert-danger {
  background: var(--danger-bg);
  color: var(--danger);
}

.alert-success {
  background: var(--success-bg);
  color: var(--success);
}

.alert-warning {
  background: var(--warning-bg);
  color: #7c6200;
}

/* ===== Footer Actions ===== */
.footer-actions {
  position: sticky;
  bottom: 0;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 12px 16px;
  display: flex;
  gap: 8px;
  z-index: 100;
}

.footer-actions .btn {
  flex: 1;
}

/* ===== Toast ===== */
.toast {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: #323232;
  color: #fff;
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 0.875rem;
  opacity: 0;
  transition: all 0.3s ease;
  z-index: 1000;
  pointer-events: none;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ===== Utility ===== */
.text-danger { color: var(--danger); }
.text-success { color: var(--success); }
.text-muted { color: var(--text-secondary); }
.text-center { text-align: center; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mb-8 { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.hidden { display: none !important; }

/* ===== Loading ===== */
.spinner {
  width: 20px;
  height: 20px;
  border: 2.5px solid #fff;
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  display: inline-block;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}
