/* ============================================================
   消費税計算ツール — style.css
   Primary: #0369a1 (計算・金融ジャンル)
   ============================================================ */

:root {
  --primary: #0369a1;
  --primary-hover: #0284c7;
  --primary-light: #e0f2fe;
  --primary-rgb: 3, 105, 161;
  --accent-8: #059669;
  --accent-8-bg: #d1fae5;
  --accent-10: #d97706;
  --accent-10-bg: #fef3c7;
  --bg: #f9f7f4;
  --surface: #ffffff;
  --text: #1a1a2e;
  --text-muted: #6b7280;
  --text-weak: #9ca3af;
  --border: #e2e8f0;
  --border-focus: #0369a1;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 4px 12px rgba(0,0,0,0.08);
  --shadow-hover: 0 4px 16px rgba(0,0,0,0.10), 0 1px 4px rgba(0,0,0,0.06);
  --transition: 0.15s ease;
}

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

body {
  font-family: 'BIZ UDPGothic', 'Hiragino Sans', 'Yu Gothic Medium', sans-serif;
  font-size: 0.9375rem;
  line-height: 1.75;
  color: var(--text);
  background: var(--bg);
  overflow-x: hidden;
  word-break: break-word;
}

/* ============================================================
   Header
   ============================================================ */

header {
  background: var(--primary);
  color: #fff;
  padding: 1.5rem 1.25rem 1.25rem;
  text-align: center;
}

.header-inner {
  max-width: 860px;
  margin: 0 auto;
}

.header-icon {
  font-size: 2.25rem;
  margin-bottom: 0.5rem;
  opacity: 0.92;
}

header h1 {
  font-family: 'Outfit', 'BIZ UDPGothic', sans-serif;
  font-size: clamp(1.1rem, 3.5vw, 1.6rem);
  font-weight: 700;
  line-height: 1.3;
  letter-spacing: 0.01em;
}

.header-sub {
  font-size: 0.85rem;
  opacity: 0.88;
  margin-top: 0.4rem;
}

/* ============================================================
   Main layout
   ============================================================ */

main {
  max-width: 860px;
  margin: 0 auto;
  padding: 1rem 1rem 2rem;
}

/* ============================================================
   Privacy notice
   ============================================================ */

.privacy-notice {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-radius: var(--radius-sm);
  color: #065f46;
  font-size: 0.8125rem;
  padding: 0.625rem 1rem;
  margin-bottom: 1rem;
}

/* ============================================================
   Ad units
   ============================================================ */

.ad-unit {
  min-height: 0;
  background: #f0f4f8;
  border: 1px dashed #d1d5db;
  border-radius: var(--radius-sm);
  margin: 1.25rem 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-weak);
  font-size: 0.75rem;
}

/* ============================================================
   Tab navigation
   ============================================================ */

.tab-nav {
  display: flex;
  gap: 0.375rem;
  background: var(--surface);
  border-radius: var(--radius);
  padding: 0.375rem;
  box-shadow: var(--shadow);
  margin-bottom: 1rem;
  overflow-x: auto;
  scrollbar-width: none;
}

.tab-nav::-webkit-scrollbar { display: none; }

.tab-btn {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.375rem;
  padding: 0.625rem 0.75rem;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.8125rem;
  font-weight: 600;
  font-family: 'BIZ UDPGothic', sans-serif;
  border-radius: 8px;
  cursor: pointer;
  white-space: nowrap;
  min-height: 44px;
  transition: background var(--transition), color var(--transition);
}

.tab-btn:hover {
  background: var(--primary-light);
  color: var(--primary);
}

.tab-btn.active {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 2px 8px rgba(var(--primary-rgb), 0.30);
}

.tab-btn i { font-size: 1rem; }

/* ============================================================
   Tab panels
   ============================================================ */

.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ============================================================
   Card
   ============================================================ */

.card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: var(--shadow);
  border: 1px solid rgba(0,0,0,0.05);
}

/* ============================================================
   Form elements
   ============================================================ */

.form-row-3 {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.875rem;
  margin-bottom: 0.875rem;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.field-label {
  font-size: 0.875rem;
  font-weight: 700;
  color: #374151;
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.field-hint {
  font-size: 0.8125rem;
  color: var(--text-muted);
}

.form-input {
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.5rem 0.75rem;
  font-size: 0.9375rem;
  font-family: 'BIZ UDPGothic', sans-serif;
  background: #fff;
  color: var(--text);
  transition: border-color var(--transition), box-shadow var(--transition);
  min-height: 44px;
  width: 100%;
}

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

select.form-input { cursor: pointer; }

/* Rounding radio group */
.rounding-field { margin-bottom: 1rem; }

.radio-group {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.radio-label {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.875rem;
  color: var(--text);
  cursor: pointer;
  min-height: 44px;
  padding: 0.5rem 0.875rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: #fff;
  transition: border-color var(--transition), background var(--transition);
}

.radio-label:hover {
  border-color: var(--primary);
  background: var(--primary-light);
}

.radio-label input[type="radio"] {
  accent-color: var(--primary);
  width: 16px;
  height: 16px;
}

/* ============================================================
   Buttons
   ============================================================ */

.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  width: 100%;
  padding: 0.75rem 1.5rem;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 1rem;
  font-weight: 700;
  font-family: 'BIZ UDPGothic', sans-serif;
  cursor: pointer;
  min-height: 48px;
  transition: background var(--transition), transform 0.12s ease, box-shadow var(--transition);
  box-shadow: 0 2px 8px rgba(var(--primary-rgb), 0.30);
  margin-top: 1rem;
}

.btn-primary:hover {
  background: var(--primary-hover);
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(var(--primary-rgb), 0.38);
}

.btn-primary:active {
  transform: translateY(0);
  box-shadow: none;
}

.btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.625rem 1.25rem;
  background: transparent;
  color: var(--primary);
  border: 1.5px solid var(--primary);
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 600;
  font-family: 'BIZ UDPGothic', sans-serif;
  cursor: pointer;
  min-height: 44px;
  transition: background var(--transition), transform 0.12s ease;
}

.btn-secondary:hover {
  background: var(--primary-light);
  transform: translateY(-1px);
}

.btn-secondary:active {
  transform: translateY(0);
}

/* ============================================================
   Basic result panel
   ============================================================ */

.result-panel {
  margin-top: 1.25rem;
  background: linear-gradient(135deg, #e0f2fe, #f0fdf4);
  border: 1px solid #bae6fd;
  border-radius: var(--radius);
  padding: 1.25rem;
}

.result-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.75rem;
}

.result-item {
  background: #fff;
  border-radius: var(--radius-sm);
  padding: 1rem 1.25rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.result-item-label {
  font-size: 0.8125rem;
  color: var(--text-muted);
  font-weight: 600;
}

.result-item-value {
  font-family: 'Outfit', sans-serif;
  font-size: clamp(1.75rem, 5vw, 2.75rem);
  font-weight: 700;
  color: var(--primary);
  line-height: 1.1;
}

.result-item-value.tax-value {
  color: #d97706;
}

.result-item-value.inc-value {
  color: #059669;
}

.result-item-sub {
  font-size: 0.8125rem;
  color: var(--text-muted);
}

/* ============================================================
   Multi-item table
   ============================================================ */

.multi-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.section-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.table-wrapper {
  overflow-x: auto;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.items-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
  min-width: 540px;
}

.items-table thead {
  background: #f8fafc;
}

.items-table th {
  padding: 0.625rem 0.75rem;
  text-align: left;
  font-size: 0.8125rem;
  font-weight: 700;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.items-table td {
  padding: 0.5rem 0.5rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.items-table tbody tr:last-child td {
  border-bottom: none;
}

.items-table tbody tr:hover {
  background: #f9fafb;
}

.item-name-input {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.4rem 0.5rem;
  font-size: 1rem;
  font-family: 'BIZ UDPGothic', sans-serif;
  background: #fff;
  width: 100%;
  min-height: 38px;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.item-name-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(var(--primary-rgb), 0.12);
}

.item-amount-input {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.4rem 0.5rem;
  font-size: 0.875rem;
  font-family: 'Outfit', sans-serif;
  background: #fff;
  width: 100%;
  min-height: 38px;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.item-amount-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(var(--primary-rgb), 0.12);
}

.item-rate-select {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.4rem 0.35rem;
  font-size: 1rem;
  font-family: 'BIZ UDPGothic', sans-serif;
  background: #fff;
  min-height: 38px;
  cursor: pointer;
  transition: border-color var(--transition);
}

.item-rate-select:focus {
  outline: none;
  border-color: var(--primary);
}

.item-rate-select.rate-8 { color: var(--accent-8); background: #f0fdf4; }
.item-rate-select.rate-10 { color: var(--accent-10); background: #fffbeb; }

.item-calc-cell {
  font-family: 'Outfit', sans-serif;
  font-size: 0.875rem;
  text-align: right;
  white-space: nowrap;
  color: var(--text-muted);
}

.btn-del-row {
  background: transparent;
  border: none;
  color: #ef4444;
  cursor: pointer;
  padding: 0.25rem 0.4rem;
  border-radius: 4px;
  font-size: 1rem;
  min-height: 32px;
  min-width: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition);
}

.btn-del-row:hover { background: #fee2e2; }

/* Multi total */
.multi-total-area {
  margin-top: 1.25rem;
  border-top: 2px solid var(--border);
  padding-top: 1rem;
}

.total-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.375rem 0;
  border-bottom: 1px solid var(--border);
}

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

.total-row--grand {
  padding-top: 0.625rem;
  margin-top: 0.25rem;
}

.total-label {
  font-size: 0.875rem;
  color: var(--text-muted);
  font-weight: 600;
}

.total-value {
  font-family: 'Outfit', sans-serif;
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text);
}

.total-value.grand {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--primary);
}

.multi-actions {
  display: flex;
  gap: 0.75rem;
  margin-top: 1.25rem;
  flex-wrap: wrap;
}

.multi-actions .btn-primary {
  flex: 1;
  margin-top: 0;
  min-width: 160px;
}

.multi-actions .btn-secondary {
  flex: 1;
  min-width: 160px;
}

/* ============================================================
   Copy message
   ============================================================ */

.copy-msg {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  color: #059669;
  font-size: 0.875rem;
  font-weight: 600;
  margin-top: 0.5rem;
  animation: fadeIn 0.15s ease;
}

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

/* ============================================================
   Invoice checklist
   ============================================================ */

.invoice-desc {
  font-size: 0.875rem;
  color: var(--text-muted);
  margin-bottom: 1.25rem;
  line-height: 1.6;
}

.reg-input-wrap {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.reg-input-wrap .form-input { flex: 1; }

.reg-badge {
  flex-shrink: 0;
  padding: 0.25rem 0.625rem;
  border-radius: 100px;
  font-size: 0.75rem;
  font-weight: 700;
  white-space: nowrap;
}

.reg-badge.valid {
  background: #d1fae5;
  color: #065f46;
}

.reg-badge.invalid {
  background: #fee2e2;
  color: #991b1b;
}

.checklist {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
}

.check-item {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.875rem 1rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition);
  min-height: 44px;
}

.check-item:hover {
  border-color: var(--primary);
  background: var(--primary-light);
}

.check-item.checked {
  border-color: #059669;
  background: #f0fdf4;
}

.chk-box {
  display: none;
}

.chk-indicator {
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  border: 2px solid var(--border);
  border-radius: 4px;
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color var(--transition), background var(--transition);
  margin-top: 1px;
}

.chk-indicator::after {
  content: '';
  display: block;
  width: 6px;
  height: 11px;
  border: 2.5px solid #fff;
  border-top: none;
  border-left: none;
  transform: rotate(45deg) translateY(-1px);
  opacity: 0;
  transition: opacity 0.1s ease;
}

.check-item.checked .chk-indicator {
  background: #059669;
  border-color: #059669;
}

.check-item.checked .chk-indicator::after {
  opacity: 1;
}

.chk-content {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.chk-title {
  font-size: 0.875rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.4;
}

.chk-desc {
  font-size: 0.8125rem;
  color: var(--text-muted);
  line-height: 1.5;
}

/* Progress bar */
.progress-wrap {
  display: flex;
  align-items: center;
  gap: 0.875rem;
  margin-bottom: 1rem;
}

.progress-bar-bg {
  flex: 1;
  height: 8px;
  background: var(--border);
  border-radius: 100px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background: var(--primary);
  border-radius: 100px;
  transition: width 0.3s ease;
}

.progress-label {
  font-size: 0.8125rem;
  color: var(--text-muted);
  font-weight: 600;
  white-space: nowrap;
}

/* Invoice result */
.invoice-result {
  border-radius: var(--radius-sm);
  padding: 1rem 1.25rem;
  font-size: 0.9375rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 0.625rem;
  animation: fadeIn 0.2s ease;
}

.invoice-result.ok {
  background: #d1fae5;
  border: 1.5px solid #6ee7b7;
  color: #065f46;
}

.invoice-result.ng {
  background: #fef9c3;
  border: 1.5px solid #fde047;
  color: #713f12;
}

/* ============================================================
   Rate badges in table
   ============================================================ */

.tax-8 { color: var(--accent-8); font-weight: 700; }
.tax-10 { color: var(--accent-10); font-weight: 700; }

/* ============================================================
   Howto section
   ============================================================ */

.howto-section {
  margin-top: 2rem;
  padding: 1.25rem;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.howto-details { margin-bottom: 1.5rem; }

.howto-summary {
  font-size: 1rem;
  font-weight: 700;
  color: var(--primary);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0;
  list-style: none;
  user-select: none;
}

.howto-summary::-webkit-details-marker { display: none; }

.howto-steps {
  padding-left: 1.4rem;
  color: var(--text);
  font-size: 0.9rem;
  margin-top: 0.75rem;
}

.howto-steps li { margin-bottom: 0.5rem; }

.howto-section h2 {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 0.75rem;
  margin-top: 1.5rem;
  padding-bottom: 0.35rem;
  border-bottom: 2px solid var(--primary-light);
}

.howto-section p {
  font-size: 0.9rem;
  color: #444;
  line-height: 1.8;
  margin-bottom: 0.75rem;
}

/* Accordion */
.accordion-group {
  margin-top: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.accordion-item {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.accordion-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.875rem 1rem;
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: 700;
  color: var(--text);
  user-select: none;
  list-style: none;
  background: #fafafa;
  transition: background var(--transition);
  min-height: 44px;
}

.accordion-summary::-webkit-details-marker { display: none; }
.accordion-summary:hover { background: var(--primary-light); }

.accordion-icon {
  font-size: 0.75rem;
  color: var(--text-muted);
  transition: transform 0.2s ease;
}

.accordion-item[open] .accordion-icon { transform: rotate(180deg); }
.accordion-icon::before { content: '▼'; }

.accordion-body {
  padding: 1rem;
  font-size: 0.875rem;
  color: #444;
  line-height: 1.75;
  border-top: 1px solid var(--border);
}

.accordion-body table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 0.75rem;
}

.accordion-body th,
.accordion-body td {
  padding: 0.5rem 0.625rem;
  border: 1px solid var(--border);
  font-size: 0.8125rem;
}

.accordion-body th {
  background: #f8fafc;
  font-weight: 700;
  color: var(--text-muted);
}

.accordion-body ul,
.accordion-body ol {
  padding-left: 1.4rem;
}

.accordion-body li { margin-bottom: 0.4rem; }

.accordion-body dt {
  font-weight: 700;
  color: var(--text);
  margin-top: 0.875rem;
}

.accordion-body dd {
  color: #444;
  margin-left: 0;
  margin-top: 0.2rem;
  margin-bottom: 0.375rem;
}

.ref-links {
  list-style: none;
  padding: 0;
  margin-bottom: 0.875rem;
}

.ref-links li { margin-bottom: 0.5rem; }

.ref-links a {
  color: var(--primary);
  text-decoration: underline;
  font-size: 0.875rem;
}

.ref-links a:hover { color: var(--primary-hover); }

.disclaimer-note {
  background: #fff8ed;
  border: 1px solid #fed7aa;
  border-radius: var(--radius-sm);
  padding: 0.75rem 1rem;
  font-size: 0.8125rem;
  color: #78350f;
  margin-top: 0.75rem;
}

.disclaimer-note a { color: var(--primary); }

/* ============================================================
   Footer
   ============================================================ */

footer {
  text-align: center;
  padding: 2rem 1rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}

footer a {
  color: var(--text-muted);
  text-decoration: none;
  transition: color var(--transition);
}

footer a:hover { color: var(--primary); }

/* ============================================================
   Responsive — tablet+
   ============================================================ */

@media (min-width: 640px) {
  main { padding: 1.25rem 1.5rem 2.5rem; }

  .form-row-3 {
    grid-template-columns: 2fr 1fr 1fr;
  }

  .card { padding: 1.75rem; }

  .result-grid { grid-template-columns: repeat(3, 1fr); }

  .multi-actions { flex-wrap: nowrap; }
}

@media (min-width: 900px) {
  main { padding: 1.5rem 0 2.5rem; }
}
