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

body {
  font-family: "Hiragino Kaku Gothic Pro", "Meiryo", sans-serif;
  background: #f5f5f5;
  color: #222;
  min-height: 100vh;
}

.app-wrapper {
  display: flex;
  flex-wrap: wrap;
  gap: 24px;
  max-width: 1000px;
  margin: 0 auto;
  padding: 24px 16px;
}

/* ===== 入力フォーム ===== */
.form-section {
  flex: 1 1 340px;
  background: #fff;
  border-radius: 10px;
  padding: 24px;
  box-shadow: 0 2px 8px rgba(0,0,0,.08);
}

.form-section h1 {
  font-size: 1.3rem;
  margin-bottom: 16px;
  color: #1a1a2e;
}

.issuer-setting {
  margin-bottom: 16px;
}

.issuer-setting label {
  display: block;
  font-size: .85rem;
  color: #555;
  margin-bottom: 4px;
}

.issuer-row {
  display: flex;
  gap: 8px;
}

hr {
  border: none;
  border-top: 1px solid #e0e0e0;
  margin: 16px 0;
}

.form-group {
  margin-bottom: 14px;
}

.form-group label {
  display: block;
  font-size: .85rem;
  color: #555;
  margin-bottom: 4px;
}

.required {
  color: #e53935;
  font-size: .8rem;
}

input[type="text"],
input[type="number"],
input[type="date"],
select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #ccc;
  border-radius: 6px;
  font-size: 1rem;
  font-family: inherit;
  outline: none;
  transition: border-color .2s;
}

input:focus, select:focus {
  border-color: #1a73e8;
}

.btn-row {
  display: flex;
  gap: 8px;
  margin-top: 4px;
}

.btn-primary {
  flex: 1;
  padding: 12px;
  background: #1a73e8;
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 1rem;
  cursor: pointer;
  font-family: inherit;
  transition: background .2s;
}

.btn-primary:hover { background: #1558b0; }

.btn-secondary {
  padding: 10px 14px;
  background: #fff;
  color: #444;
  border: 1px solid #ccc;
  border-radius: 6px;
  font-size: .9rem;
  cursor: pointer;
  font-family: inherit;
  transition: background .2s;
}

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

.btn-print {
  display: block;
  width: 100%;
  margin-top: 16px;
  padding: 13px;
  background: #2e7d32;
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 1rem;
  cursor: pointer;
  font-family: inherit;
  transition: background .2s;
}

.btn-print:hover { background: #1b5e20; }

/* ===== 領収書プレビュー ===== */
.receipt-section {
  flex: 1 1 340px;
  display: flex;
  flex-direction: column;
}

.receipt {
  background: #fff;
  border: 2px solid #333;
  border-radius: 4px;
  padding: 32px 28px;
  box-shadow: 0 2px 8px rgba(0,0,0,.1);
  min-height: 420px;
  position: relative;
}

.receipt-title {
  text-align: center;
  font-size: 1.7rem;
  font-weight: bold;
  letter-spacing: .6em;
  margin-bottom: 8px;
}

.receipt-no {
  text-align: right;
  font-size: .85rem;
  color: #555;
  margin-bottom: 16px;
}

.receipt-date-row {
  text-align: right;
  font-size: .95rem;
  margin-bottom: 16px;
}

.recipient-row {
  font-size: 1.15rem;
  border-bottom: 1px solid #333;
  padding-bottom: 4px;
  margin-bottom: 20px;
  display: flex;
  align-items: baseline;
  gap: 4px;
}

.recipient-name {
  font-size: 1.2rem;
  font-weight: bold;
  flex: 1;
}

.amount-box {
  display: flex;
  align-items: center;
  gap: 6px;
  border: 2px solid #333;
  padding: 10px 16px;
  border-radius: 4px;
  margin-bottom: 8px;
  background: #fafafa;
}

.yen-mark {
  font-size: 1.3rem;
  font-weight: bold;
}

.amount-value {
  font-size: 1.6rem;
  font-weight: bold;
  letter-spacing: .05em;
  flex: 1;
}

.hoshi {
  font-size: 1.2rem;
  font-weight: bold;
}

.tax-info {
  font-size: .82rem;
  color: #666;
  text-align: right;
  margin-bottom: 12px;
  min-height: 1.2em;
}

.description-row {
  font-size: .95rem;
  margin-bottom: 12px;
  border-bottom: 1px solid #ccc;
  padding-bottom: 8px;
}

.above-desc {
  font-size: .9rem;
  margin-bottom: 24px;
}

.issuer-section {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
}

.issuer-label {
  font-size: .82rem;
  color: #555;
}

.issuer-value {
  font-size: 1.05rem;
  font-weight: bold;
  min-width: 80px;
  text-align: right;
}

.seal-area {
  font-size: .85rem;
  color: #888;
  margin-top: 4px;
}

/* ===== 発行履歴 ===== */
.history-section {
  max-width: 1000px;
  margin: 0 auto 32px;
  padding: 0 16px;
  width: 100%;
}

.history-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.history-header h2 {
  font-size: 1.1rem;
}

.btn-danger-sm {
  padding: 6px 12px;
  background: #fff;
  color: #e53935;
  border: 1px solid #e53935;
  border-radius: 6px;
  font-size: .85rem;
  cursor: pointer;
  font-family: inherit;
}

.btn-danger-sm:hover { background: #ffebee; }

.history-list {
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 2px 8px rgba(0,0,0,.08);
  overflow: hidden;
}

.empty-msg {
  text-align: center;
  padding: 24px;
  color: #999;
  font-size: .9rem;
}

.history-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid #f0f0f0;
  font-size: .9rem;
}

.history-item:last-child { border-bottom: none; }

.history-item .h-no {
  color: #888;
  font-size: .8rem;
  min-width: 80px;
}

.history-item .h-date {
  color: #555;
  min-width: 90px;
}

.history-item .h-recipient {
  font-weight: bold;
  flex: 1;
}

.history-item .h-amount {
  font-weight: bold;
  color: #1a1a2e;
  min-width: 90px;
  text-align: right;
}

.history-item .h-delete {
  padding: 4px 8px;
  background: none;
  border: 1px solid #ccc;
  border-radius: 4px;
  cursor: pointer;
  color: #888;
  font-size: .8rem;
  font-family: inherit;
}

.history-item .h-delete:hover { background: #f5f5f5; }

/* ===== 印刷スタイル ===== */
@media print {
  body { background: #fff; }

  .no-print { display: none !important; }

  .app-wrapper {
    padding: 0;
    max-width: 100%;
    display: block;
  }

  .form-section { display: none; }

  .receipt-section {
    width: 100%;
    box-shadow: none;
  }

  .receipt {
    border: 2px solid #000;
    box-shadow: none;
    page-break-inside: avoid;
    width: 100%;
    max-width: 600px;
    margin: 0 auto;
  }

  .history-section { display: none; }
}

/* ===== レスポンシブ ===== */
@media (max-width: 600px) {
  .app-wrapper { flex-direction: column; gap: 16px; }
  .receipt-section { order: -1; }
  .receipt { padding: 20px 16px; }
  .receipt-title { font-size: 1.4rem; }
  .amount-value { font-size: 1.3rem; }
}
