/* リセット・基本 */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Helvetica Neue', Arial, 'Hiragino Kaku Gothic ProN', Meiryo, sans-serif;
  font-size: 14px;
  background: #f0f2f5;
  color: #333;
  min-height: 100vh;
  padding: 16px;
}

/* アプリコンテナ */
.app-container {
  max-width: 860px;
  margin: 0 auto;
}

/* 操作バー */
.action-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #2c3e50;
  color: #fff;
  padding: 12px 16px;
  border-radius: 8px 8px 0 0;
}
.action-bar h1 {
  font-size: 17px;
  font-weight: bold;
}
.action-buttons {
  display: flex;
  gap: 8px;
}

/* ボタン */
.btn {
  padding: 7px 14px;
  border: none;
  border-radius: 5px;
  font-size: 13px;
  cursor: pointer;
  font-weight: bold;
  transition: opacity 0.2s;
}
.btn:hover { opacity: 0.85; }
.btn-primary { background: #3498db; color: #fff; }
.btn-secondary { background: #95a5a6; color: #fff; }
.btn-danger { background: #e74c3c; color: #fff; }
.btn-add { background: #27ae60; color: #fff; width: 100%; padding: 9px; }

/* 見積書ドキュメント */
.estimate-doc {
  background: #fff;
  border: 1px solid #ddd;
  border-top: none;
  padding: 28px 28px 24px;
  border-radius: 0 0 8px 8px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.07);
}

/* ヘッダー */
.doc-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 20px;
  border-bottom: 2px solid #2c3e50;
  padding-bottom: 16px;
}
.doc-title { font-size: 26px; font-weight: bold; color: #2c3e50; letter-spacing: 4px; }

.doc-meta { display: flex; flex-direction: column; gap: 6px; }
.meta-row { display: flex; align-items: center; gap: 8px; }
.meta-row label { font-size: 12px; color: #666; white-space: nowrap; min-width: 70px; text-align: right; }
.meta-row input { font-size: 13px; border: 1px solid #ccc; border-radius: 4px; padding: 4px 7px; width: 150px; }

/* 宛先・差出人 */
.doc-info {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 20px;
}
.to-block { flex: 1; }
.to-row { display: flex; align-items: center; gap: 6px; margin-bottom: 8px; }
.to-input { font-size: 18px; font-weight: bold; border: none; border-bottom: 2px solid #333; width: 100%; padding: 4px 0; }
.to-input:focus { outline: none; border-bottom-color: #3498db; }
.to-suffix { font-size: 16px; font-weight: bold; white-space: nowrap; }
.subject-row { display: flex; align-items: center; gap: 8px; }
.subject-row label { white-space: nowrap; color: #555; }
.subject-row input { font-size: 14px; border: 1px solid #ccc; border-radius: 4px; padding: 4px 8px; width: 100%; }

.from-block { min-width: 220px; }
.from-row { display: flex; align-items: center; gap: 8px; margin-bottom: 5px; }
.from-row label { font-size: 12px; color: #666; white-space: nowrap; min-width: 50px; }
.from-row input { font-size: 13px; border: 1px solid #ccc; border-radius: 4px; padding: 4px 7px; width: 100%; }

/* 合計サマリー（目立つ表示） */
.total-summary {
  background: #eaf4fb;
  border: 2px solid #3498db;
  border-radius: 6px;
  padding: 10px 16px;
  text-align: right;
  margin-bottom: 16px;
  font-size: 15px;
  color: #2c3e50;
}
.total-amount { font-size: 22px; color: #e74c3c; margin-left: 8px; }

/* 品目テーブル */
.items-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 0;
  font-size: 13px;
}
.items-table th, .items-table td {
  border: 1px solid #ccc;
  padding: 7px 8px;
  text-align: center;
}
.items-table th {
  background: #2c3e50;
  color: #fff;
  font-weight: bold;
}
.items-table tbody tr:nth-child(even) { background: #f9f9f9; }

.col-no { width: 40px; }
.col-name { text-align: left !important; }
.col-qty { width: 65px; }
.col-unit { width: 60px; }
.col-price { width: 100px; }
.col-subtotal { width: 100px; }
.col-action { width: 60px; }

.items-table input {
  width: 100%;
  border: none;
  background: transparent;
  font-size: 13px;
  padding: 2px 4px;
  text-align: inherit;
}
.items-table input[type="number"] { text-align: right; }
.items-table input:focus { outline: 1px solid #3498db; background: #fff; border-radius: 2px; }
.items-table .row-subtotal { text-align: right; font-weight: bold; color: #2c3e50; }

.btn-del {
  background: none;
  border: 1px solid #e74c3c;
  color: #e74c3c;
  border-radius: 4px;
  padding: 3px 8px;
  cursor: pointer;
  font-size: 12px;
}
.btn-del:hover { background: #e74c3c; color: #fff; }

/* 行追加エリア */
.add-row-area {
  margin-top: 0;
  border: 1px solid #ccc;
  border-top: none;
}

/* 小計・税・合計ブロック */
.totals-block {
  margin-top: 16px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
}
.totals-row {
  display: flex;
  gap: 60px;
  justify-content: flex-end;
  width: 280px;
  padding: 4px 8px;
  font-size: 13px;
}
.totals-row span:first-child { color: #555; }
.totals-row span:last-child { text-align: right; min-width: 100px; font-weight: bold; }
.totals-grand {
  border-top: 2px solid #2c3e50;
  margin-top: 4px;
  padding-top: 8px;
  font-size: 16px;
  color: #e74c3c;
}

/* 備考 */
.remarks-block {
  margin-top: 20px;
}
.remarks-label {
  display: block;
  font-size: 12px;
  color: #666;
  margin-bottom: 5px;
}
.remarks-block textarea {
  width: 100%;
  border: 1px solid #ccc;
  border-radius: 4px;
  padding: 8px;
  font-size: 13px;
  resize: vertical;
  font-family: inherit;
}

/* スマホ対応 */
@media (max-width: 600px) {
  body { padding: 8px; }
  .estimate-doc { padding: 16px 12px; }
  .doc-header { flex-direction: column; gap: 10px; }
  .doc-meta .meta-row label { min-width: 55px; }
  .doc-meta .meta-row input { width: 100%; }
  .doc-info { flex-direction: column; }
  .from-block { min-width: 0; }
  .action-bar { flex-direction: column; gap: 8px; align-items: flex-start; }
  .items-table { font-size: 11px; }
  .items-table th, .items-table td { padding: 5px 4px; }
  .col-unit { display: none; }
  .totals-row { width: 220px; gap: 20px; }
}

/* 印刷用スタイル */
@media print {
  body { background: #fff; padding: 0; }
  .no-print { display: none !important; }
  .app-container { max-width: 100%; }
  .estimate-doc {
    border: none;
    box-shadow: none;
    border-radius: 0;
    padding: 20px;
  }
  .doc-header { border-bottom: 2px solid #000; }
  .items-table { font-size: 12px; }
  .items-table th { background: #555 !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .total-summary { border: 2px solid #000; }
  .items-table input, .to-input, .subject-row input, .from-row input, .meta-row input, .remarks-block textarea {
    border: none !important;
    background: transparent !important;
  }
  .btn-del { display: none; }
}
