/* ===== 간편견적서 style.css ===== */
:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-light: #eff6ff;
  --text: #1e293b;
  --text-sub: #64748b;
  --border: #e2e8f0;
  --bg: #f1f5f9;
  --white: #ffffff;
  --danger: #ef4444;
  --sheet-w: 794px; /* A4 @96dpi */
}

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

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

body {
  font-family: "Pretendard Variable", Pretendard, -apple-system, BlinkMacSystemFont,
    "Malgun Gothic", "맑은 고딕", "Apple SD Gothic Neo", "Noto Sans KR", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
}

button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; font-size: 14px; color: var(--text); }

/* ===== Header ===== */
.site-header {
  background: var(--white);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 50;
}
.header-inner {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 20px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 20px;
  font-weight: 800;
  color: var(--text);
  text-decoration: none;
}
.brand .brand-mark {
  width: 30px; height: 30px;
  background: var(--primary);
  color: #fff;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  font-weight: 800;
}
.site-nav { display: flex; gap: 4px; }
.site-nav a {
  padding: 8px 14px;
  border-radius: 8px;
  color: var(--text-sub);
  text-decoration: none;
  font-size: 14px;
  font-weight: 600;
}
.site-nav a:hover { background: var(--primary-light); color: var(--primary); }
.site-nav a.active { color: var(--primary); }

/* ===== Hero ===== */
.hero {
  max-width: 1400px;
  margin: 0 auto;
  padding: 28px 20px 8px;
}
.hero h1 { font-size: 26px; font-weight: 800; letter-spacing: -0.5px; }
.hero p { color: var(--text-sub); margin-top: 6px; font-size: 15px; }

/* ===== Layout ===== */
.app-layout {
  max-width: 1400px;
  margin: 0 auto;
  padding: 20px;
  display: grid;
  grid-template-columns: minmax(380px, 460px) 1fr;
  gap: 24px;
  align-items: start;
}

/* ===== Form panel ===== */
.form-panel { display: flex; flex-direction: column; gap: 16px; }

.card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 18px;
}
.card h2 {
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.card h2 .step {
  width: 22px; height: 22px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  font-size: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.card h2 .hint { font-size: 12px; font-weight: 500; color: var(--text-sub); margin-left: auto; }

.remember-row {
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 12px;
}
.remember-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13.5px;
  font-weight: 700;
  cursor: pointer;
}
.remember-label input { width: 16px; height: 16px; accent-color: var(--primary); cursor: pointer; }
.remember-hint { font-size: 12px; color: var(--text-sub); margin-top: 5px; }

.field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.field-grid .full { grid-column: 1 / -1; }
.field label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-sub);
  margin-bottom: 4px;
}
.field input, .field select, .field textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 10px;
  background: #fff;
  transition: border-color 0.15s;
}
.field textarea { resize: vertical; min-height: 64px; }
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

/* stamp upload */
.stamp-row { display: flex; align-items: center; gap: 10px; margin-top: 4px; }
.stamp-preview {
  width: 54px; height: 54px;
  border: 1px dashed var(--border);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
  background: #fafafa;
  flex-shrink: 0;
}
.stamp-preview img { max-width: 100%; max-height: 100%; }
.stamp-preview span { font-size: 11px; color: #b0b7c3; text-align: center; }
.btn-sm {
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}
.btn-sm:hover { border-color: var(--primary); color: var(--primary); }
.btn-sm.danger:hover { border-color: var(--danger); color: var(--danger); }

/* ===== Items ===== */
.items-head, .item-row {
  display: grid;
  grid-template-columns: 1.7fr 1fr 0.7fr 1.1fr 28px;
  gap: 6px;
  align-items: center;
}
.items-head {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-sub);
  margin-bottom: 6px;
  padding: 0 2px;
}
.item-row { margin-bottom: 6px; }
.item-row input {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 9px;
  width: 100%;
  min-width: 0;
}
.item-row input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}
.item-row input.num { text-align: right; }
.row-del {
  border: none;
  background: transparent;
  color: #cbd5e1;
  font-size: 16px;
  line-height: 1;
  padding: 4px;
  border-radius: 6px;
}
.row-del:hover { color: var(--danger); background: #fef2f2; }
.add-row {
  width: 100%;
  border: 1px dashed var(--border);
  background: #fafbfc;
  border-radius: 8px;
  padding: 9px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-sub);
  margin-top: 4px;
}
.add-row:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-light); }

/* totals mini */
.totals-mini {
  margin-top: 12px;
  border-top: 1px solid var(--border);
  padding-top: 10px;
  font-size: 13px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.totals-mini div { display: flex; justify-content: space-between; }
.totals-mini .grand { font-weight: 800; font-size: 15px; color: var(--primary); }

/* vat radios */
.vat-options { display: flex; gap: 8px; }
.vat-options label {
  flex: 1;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 6px;
  text-align: center;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-sub);
  cursor: pointer;
  transition: all 0.15s;
}
.vat-options input { display: none; }
.vat-options label:has(input:checked) {
  border-color: var(--primary);
  background: var(--primary-light);
  color: var(--primary);
}

/* action buttons */
.actions { display: flex; gap: 10px; position: sticky; bottom: 12px; }
.btn-primary {
  flex: 1;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 12px;
  padding: 15px;
  font-size: 16px;
  font-weight: 700;
  box-shadow: 0 4px 14px rgba(37, 99, 235, 0.35);
  transition: background 0.15s;
}
.btn-primary:hover { background: var(--primary-dark); }
.btn-ghost {
  border: 1px solid var(--border);
  background: var(--white);
  border-radius: 12px;
  padding: 15px 18px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-sub);
}
.btn-ghost:hover { border-color: var(--danger); color: var(--danger); }
.autosave-note {
  font-size: 12px;
  color: var(--text-sub);
  text-align: center;
  margin-top: -4px;
}

/* ===== Preview panel ===== */
.preview-panel { position: sticky; top: 76px; }
.preview-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}
.preview-toolbar span { font-size: 13px; font-weight: 700; color: var(--text-sub); }
.preview-wrap {
  overflow: hidden;
  border-radius: 6px;
}
#sheet-scaler { transform-origin: top left; }

/* ===== A4 Sheet ===== */
.sheet {
  width: var(--sheet-w);
  min-height: 1123px;
  background: #fff;
  box-shadow: 0 2px 24px rgba(15, 23, 42, 0.12);
  padding: 56px 52px;
  color: #111;
  font-size: 13px;
  position: relative;
}
.sheet-title {
  text-align: center;
  font-size: 34px;
  font-weight: 800;
  letter-spacing: 26px;
  text-indent: 26px;
  margin-bottom: 34px;
}
.sheet-title::after {
  content: "";
  display: block;
  width: 190px;
  margin: 10px auto 0;
  border-bottom: 3px double #111;
}

.sheet-top { display: flex; justify-content: space-between; gap: 24px; margin-bottom: 22px; }
.sheet-meta { flex: 1; padding-top: 4px; }
.sheet-meta .recipient {
  font-size: 17px;
  font-weight: 700;
  border-bottom: 1px solid #111;
  display: inline-block;
  padding: 0 6px 3px 2px;
  min-width: 230px;
  margin-bottom: 14px;
}
.sheet-meta .meta-line { margin-bottom: 5px; color: #333; }
.sheet-meta .meta-line b { color: #111; display: inline-block; width: 74px; font-weight: 600; }
.sheet-meta .lead { margin-top: 14px; color: #111; }

/* supplier box */
.supplier-wrap { position: relative; }
.supplier-box { width: 348px; border: 1.6px solid #111; border-collapse: collapse; }
.supplier-box td {
  border: 1px solid #444;
  padding: 5px 7px;
  font-size: 11.5px;
  vertical-align: middle;
}
.supplier-box .sb-side {
  width: 22px;
  text-align: center;
  font-weight: 700;
  background: #f3f4f6;
  letter-spacing: 1px;
}
.supplier-box .sb-label {
  width: 60px;
  background: #f9fafb;
  text-align: center;
  font-weight: 600;
  color: #333;
  white-space: nowrap;
}
.supplier-box .sb-value { min-width: 90px; }
.stamp-area {
  position: absolute;
  right: 4px;
  top: 34px;
  width: 54px;
  height: 54px;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}
.stamp-area img { max-width: 100%; max-height: 100%; opacity: 0.9; }
.sign-hint { font-size: 10.5px; color: #888; }

/* grand total bar */
.grand-bar {
  border: 1.6px solid #111;
  display: flex;
  align-items: center;
  padding: 11px 16px;
  margin-bottom: 18px;
  font-weight: 700;
  font-size: 15px;
  gap: 10px;
  flex-wrap: wrap;
}
.grand-bar .gb-label { font-size: 13px; }
.grand-bar .gb-korean { flex: 1; min-width: 200px; }
.grand-bar .gb-num { font-size: 15px; }
.grand-bar .gb-vat { font-size: 11.5px; font-weight: 500; color: #555; }

/* items table */
.items-table { width: 100%; border-collapse: collapse; margin-bottom: 0; }
.items-table th {
  border: 1px solid #444;
  border-top: 1.6px solid #111;
  background: #f3f4f6;
  padding: 8px 6px;
  font-size: 12px;
  font-weight: 700;
}
.items-table td {
  border: 1px solid #666;
  padding: 7px 8px;
  font-size: 12.5px;
  height: 21px;
}
.items-table .c { text-align: center; }
.items-table .r { text-align: right; }
.items-table tfoot td {
  font-weight: 700;
  background: #fafafa;
  border-top: 1.4px solid #111;
}
.items-table tfoot .sum-label { text-align: center; letter-spacing: 4px; }

/* remarks */
.sheet-remarks { border: 1px solid #666; border-top: none; padding: 10px 12px; min-height: 64px; }
.sheet-remarks .rm-title { font-weight: 700; font-size: 12px; margin-bottom: 4px; }
.sheet-remarks .rm-body { white-space: pre-wrap; color: #333; font-size: 12px; }

.sheet-footer {
  margin-top: 28px;
  text-align: center;
  color: #999;
  font-size: 10.5px;
}

/* ===== Content pages (guide/privacy/terms) ===== */
.content-page {
  max-width: 820px;
  margin: 0 auto;
  padding: 36px 20px 80px;
}
.content-page h1 { font-size: 28px; font-weight: 800; margin-bottom: 8px; letter-spacing: -0.5px; }
.content-page .updated { color: var(--text-sub); font-size: 13px; margin-bottom: 28px; }
.content-page h2 { font-size: 20px; font-weight: 700; margin: 34px 0 12px; letter-spacing: -0.3px; }
.content-page h3 { font-size: 16px; font-weight: 700; margin: 22px 0 8px; }
.content-page p { margin-bottom: 12px; color: #334155; font-size: 15px; }
.content-page ul, .content-page ol { margin: 0 0 14px 22px; color: #334155; font-size: 15px; }
.content-page li { margin-bottom: 6px; }
.content-page table { border-collapse: collapse; width: 100%; margin: 14px 0; font-size: 14px; }
.content-page th, .content-page td { border: 1px solid var(--border); padding: 9px 12px; text-align: left; }
.content-page th { background: #f8fafc; }
.content-page .tip {
  background: var(--primary-light);
  border: 1px solid #bfdbfe;
  border-radius: 10px;
  padding: 14px 16px;
  margin: 16px 0;
  font-size: 14px;
  color: #1e40af;
}
.cta-box {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 24px;
  text-align: center;
  margin-top: 40px;
}
.cta-box a {
  display: inline-block;
  margin-top: 12px;
  background: var(--primary);
  color: #fff;
  text-decoration: none;
  font-weight: 700;
  padding: 12px 28px;
  border-radius: 10px;
}

/* ===== Footer ===== */
.site-footer {
  border-top: 1px solid var(--border);
  background: var(--white);
  margin-top: 40px;
}
.footer-inner {
  max-width: 1400px;
  margin: 0 auto;
  padding: 24px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  font-size: 13px;
  color: var(--text-sub);
}
.footer-inner a { color: var(--text-sub); text-decoration: none; margin-right: 14px; }
.footer-inner a:hover { color: var(--primary); }

/* ===== Responsive ===== */
@media (max-width: 1023px) {
  .app-layout { grid-template-columns: 1fr; }
  .preview-panel { position: static; }
}
@media (max-width: 560px) {
  .field-grid { grid-template-columns: 1fr; }
  .hero h1 { font-size: 21px; }
  .items-head, .item-row { grid-template-columns: 1.5fr 0.9fr 0.65fr 1fr 24px; }
}

/* ===== Print ===== */
@media print {
  @page { size: A4; margin: 0; }
  body { background: #fff; }
  .site-header, .hero, .form-panel, .preview-toolbar, .site-footer, .actions, .adsense-slot { display: none !important; }
  .app-layout { display: block; padding: 0; max-width: none; }
  .preview-panel { position: static; }
  .preview-wrap { overflow: visible; border-radius: 0; }
  #sheet-scaler { transform: none !important; width: auto !important; height: auto !important; }
  .sheet {
    width: 210mm;
    min-height: 287mm;
    box-shadow: none;
    padding: 14mm 13mm;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
}
