/* office.css: 사무 처리 도구(견적서, 영수증, 정산, 출장비, 할 일, 엑셀 수식) 공통 디자인
   누끼·PDF 압축과 같은 값(흑백 + 파랑 하나)을 써요. share/design-prompt.md 참고. */

:root {
  --ink: #111;
  --ink-2: #555;
  --ink-3: #8a8a8a;
  --line: #e4e4e4;
  --bg: #fafafa;
  --card: #fff;
  --accent: #1f6feb;
  --good: #1a7f37;
  --bad: #c0392b;
  --font: "Pretendard Variable", Pretendard, -apple-system, "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--font); color: var(--ink); background: var(--bg); line-height: 1.6; word-break: keep-all; }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }

/* ---------- 머리글 ---------- */
.site-header { display: flex; align-items: center; justify-content: space-between; max-width: 1200px; margin: 0 auto; padding: 16px 20px; }
.logo { font-weight: 800; font-size: 22px; text-decoration: none; letter-spacing: -0.5px; }
.logo span { color: var(--accent); }
.site-header nav { display: flex; gap: 18px; font-size: 14px; align-items: center; }
.site-header nav a { text-decoration: none; color: var(--ink-2); }
.site-header nav a:hover { color: var(--ink); }

main { max-width: 1200px; margin: 0 auto; padding: 0 20px; }

/* ---------- 첫 화면 ---------- */
.hero { padding: 32px 0 16px; text-align: center; }
.hero h1 { font-size: clamp(26px, 4.6vw, 40px); line-height: 1.25; letter-spacing: -1px; margin: 0 0 12px; font-weight: 800; }
.points { list-style: none; padding: 0; margin: 0 0 8px; display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 18px; color: var(--ink-2); font-size: 15px; }
.points li::before { content: "✓ "; color: var(--accent); font-weight: 700; }

/* ---------- 작업 공간 ---------- */
.workspace { max-width: 900px; margin: 8px auto 24px; display: flex; flex-direction: column; gap: 12px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 16px; }
.card h2 { font-size: 15px; margin: 0 0 12px; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.card h2 small { font-weight: 400; color: var(--ink-3); font-size: 12.5px; }

.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 10px 12px; }
.field { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--ink-2); min-width: 0; }
.field input, .field select, .field textarea, .cell-input {
  width: 100%; border: 1px solid #d6d6d6; border-radius: 8px; padding: 8px 10px; background: #fff; font-size: 14px; color: var(--ink);
}
.field input:focus, .field select:focus, .field textarea:focus, .cell-input:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
.field.wide { grid-column: 1 / -1; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.check { display: inline-flex; gap: 6px; align-items: center; font-size: 13.5px; color: var(--ink-2); cursor: pointer; }

.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg button { border: 0; background: #fff; padding: 7px 12px; cursor: pointer; font-size: 13.5px; }
.seg button + button { border-left: 1px solid var(--line); }
.seg button.active { background: var(--ink); color: #fff; }

/* 표 입력 */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; background: var(--card); }
th, td { text-align: left; padding: 8px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { color: var(--ink-2); font-weight: 600; background: #f4f4f4; white-space: nowrap; font-size: 13px; }
td.num, th.num { text-align: right; }
.cell-input { padding: 6px 8px; min-width: 70px; }

/* 합계 줄 */
.totals { display: grid; grid-template-columns: 1fr auto; gap: 6px 16px; font-size: 14.5px; max-width: 420px; margin-left: auto; }
.totals dt { color: var(--ink-2); }
.totals dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
.totals .grand { font-size: 18px; font-weight: 800; color: var(--ink); }
.big-result { font-size: clamp(22px, 4vw, 30px); font-weight: 800; letter-spacing: -0.5px; }
.sub-result { color: var(--ink-2); font-size: 14px; }

/* 버튼 */
.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.btn-primary, .btn-line { border-radius: 8px; padding: 9px 14px; cursor: pointer; font-weight: 600; font-size: 14px; }
.btn-primary { background: var(--ink); color: #fff; border: 1px solid var(--ink); }
.btn-primary:hover { background: #333; }
.btn-line { background: #fff; border: 1px solid #cfcfcf; }
.btn-line:hover { border-color: var(--ink); }
.btn-sm { padding: 5px 10px; font-size: 13px; }
.btn-text { border: 0; background: none; padding: 6px 0; cursor: pointer; color: var(--accent); font-size: 13px; text-decoration: underline; text-underline-offset: 3px; }
.x { width: 28px; height: 28px; border: 0; border-radius: 50%; background: transparent; color: var(--ink-3); cursor: pointer; font-size: 16px; line-height: 28px; padding: 0; }
.x:hover { background: #f1f1f1; color: var(--ink); }
button:disabled { opacity: .45; cursor: not-allowed; }

.hint { font-size: 12.5px; color: var(--ink-3); margin: 8px 0 0; }
.warn { color: var(--bad); }
.good { color: var(--good); }
.muted { color: var(--ink-3); }

/* ---------- 광고 자리 (승인 전에는 보이지 않음) ---------- */
.ad-slot { margin: 24px auto; max-width: 970px; }
.ad-slot:empty { margin: 0; }
body.show-ad-slots .ad-slot:empty { min-height: 90px; margin: 24px auto; border: 1px dashed #c8c8c8; border-radius: 8px; display: flex; align-items: center; justify-content: center; }
body.show-ad-slots .ad-slot:empty::after { content: "광고 자리 (" attr(data-ad) ")"; color: var(--ink-3); font-size: 13px; }

/* ---------- 설명 글 ---------- */
.content { max-width: 820px; margin: 24px auto 40px; }
.content section { padding: 28px 0; border-top: 1px solid var(--line); }
.content h2 { font-size: 22px; margin: 0 0 12px; letter-spacing: -0.4px; }
.content p, .content li { color: #333; font-size: 15.5px; }
.content ol, .content ul { padding-left: 20px; }
.content li { margin-bottom: 8px; }
.content code { background: #f1f1f1; padding: 1px 6px; border-radius: 4px; font-size: 14px; }

.site-footer { border-top: 1px solid var(--line); padding: 28px 20px 40px; text-align: center; font-size: 13px; color: var(--ink-3); }
.site-footer nav { display: flex; gap: 18px; justify-content: center; flex-wrap: wrap; margin-bottom: 8px; }
.site-footer a { text-decoration: none; color: var(--ink-2); }

#toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); max-width: calc(100% - 32px); background: var(--ink); color: #fff; font-size: 14px; padding: 10px 16px; border-radius: 10px; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 10; }
#toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- 휴대폰 ---------- */
@media (max-width: 720px) {
  main { padding: 0 14px; }
  .site-header { padding: 12px 14px; }
  .site-header nav { gap: 12px; font-size: 13px; }
  .hero { padding: 20px 0 10px; }
  .points { font-size: 13px; gap: 4px 12px; }
  .content h2 { font-size: 19px; }
  .totals { max-width: none; }
}

/* ---------- 인쇄할 문서 미리보기 (A4 모양) ---------- */
.paper {
  background: #fff; border: 1px solid var(--line); border-radius: 6px; box-shadow: 0 1px 0 rgba(0,0,0,.02);
  padding: 32px 36px; color: #111; font-size: 13px; line-height: 1.5; overflow-x: auto;
}
.paper h1 { text-align: center; font-size: 26px; letter-spacing: 10px; margin: 0 0 18px; }
.paper table { font-size: 12.5px; }
.paper th, .paper td { border: 1px solid #bbb; padding: 5px 7px; }
.paper th { background: #f2f2f2; color: #111; }
.paper .amount-line { border: 2px solid #111; padding: 10px 12px; margin: 12px 0; font-size: 15px; font-weight: 700; display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.paper .meta { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 8px; }
.paper .meta table th { width: 76px; }
.paper .note { margin-top: 12px; white-space: pre-wrap; }

/* ---------- 인쇄: .print-area(문서)만 찍어요 ---------- */
@media print {
  @page { size: A4; margin: 12mm; }
  body { background: #fff; }
  body * { visibility: hidden !important; }
  .print-area, .print-area * { visibility: visible !important; }
  .print-area { position: absolute; left: 0; top: 0; width: 100%; border: 0 !important; padding: 0 !important; box-shadow: none !important; overflow: visible !important; }
  .no-print { display: none !important; }
}
