@font-face {
  font-family: "Paperlogy";
  src: url("https://cdn.jsdelivr.net/gh/fonts-archive/Paperlogy/Paperlogy-5Medium.woff2") format("woff2");
  font-weight: 500;
  font-style: normal;
}

@font-face {
  font-family: "Paperlogy";
  src: url("https://cdn.jsdelivr.net/gh/fonts-archive/Paperlogy/Paperlogy-7Bold.woff2") format("woff2");
  font-weight: 700;
  font-style: normal;
}

:root {
  --bg: #ffffff;
  --ink: #111827;
  --muted: #6b7280;
  --line: #e5e7eb;
  --soft: #f3f4f6;

  --mint: #e9f6e4;
  --mint-line: #cfe7c3;
  --mint-ink: #2f5f2f;

  --blue: #2563eb;
  --blue-ink: #ffffff;

  --r: 10px;
  --shadow: 0 8px 22px rgba(17, 24, 39, 0.08);

  /* Unified container */
  --container-max: 1180px;
  --pad-x: clamp(14px, 4vw, 28px);
}

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  overflow-x: hidden; /* fallback */
}

html,
body {
  height: 100%;
  width: 100%;
  max-width: 100%;
}

body {
  margin: 0;
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
  overflow-x: clip;
  background: var(--bg);
  color: var(--ink);
  font-family: "Paperlogy", "Noto Sans KR", system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  word-break: keep-all; /* prefer 어절 단위 줄바꿈 */
  overflow-wrap: break-word; /* but allow long tokens to wrap */
}

@supports (overflow: clip) {
  html,
  body {
    overflow-x: clip;
  }
}

img,
svg,
video,
canvas {
  max-width: 100%;
  height: auto;
}

input,
textarea,
select {
  max-width: 100%;
  font: inherit;
  font-size: 16px; /* iOS input auto-zoom prevention */
}

button {
  max-width: 100%;
  font: inherit;
}

a {
  color: inherit;
}

main,
section,
header,
footer,
.wrapper,
.container {
  width: 100%;
  max-width: 100%;
}

/* Sidebar (hamburger category) */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  height: 100%;
  width: 320px;
  max-width: calc(100% - 60px); /* avoid iOS 100vw overflow */
  background:
    radial-gradient(420px 280px at 20% 0%, rgba(233, 246, 228, 0.85), rgba(255, 255, 255, 0) 60%),
    linear-gradient(180deg, #ffffff, #fbfbfb);
  border-right: 1px solid rgba(229, 231, 235, 0.9);
  box-shadow: 0 22px 54px rgba(0, 0, 0, 0.16);
  transform: translateX(-102%);
  transition: transform 180ms cubic-bezier(0.2, 0.9, 0.2, 1);
  z-index: 50;
  display: grid;
  grid-template-rows: auto 1fr auto;
  border-top-right-radius: 16px;
  border-bottom-right-radius: 16px;
}

body.nav-open .sidebar {
  transform: translateX(0);
}

.scrim {
  position: fixed;
  inset: 0;
  background: rgba(17, 24, 39, 0.30);
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease;
  z-index: 40;
  backdrop-filter: blur(2px);
}

body.nav-open .scrim {
  opacity: 1;
  pointer-events: auto;
}

.side-head {
  padding: 14px 14px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border-bottom: 1px solid rgba(229, 231, 235, 0.9);
}

.side-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.side-mark {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  background:
    radial-gradient(14px 14px at 30% 25%, rgba(255, 255, 255, 0.75), rgba(255, 255, 255, 0) 65%),
    linear-gradient(135deg, rgba(47, 95, 47, 0.95), rgba(37, 99, 235, 0.85));
  box-shadow: 0 10px 22px rgba(17, 24, 39, 0.18);
}

.side-brand-text {
  display: grid;
  gap: 1px;
  min-width: 0;
}

.side-app {
  font-weight: 900;
  letter-spacing: -0.2px;
  line-height: 1.1;
}

.side-sub {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.icon-btn {
  appearance: none;
  border: 1px solid rgba(229, 231, 235, 0.9);
  background: #fff;
  border-radius: 10px;
  width: 36px;
  height: 36px;
  cursor: pointer;
  font-size: 20px;
  line-height: 1;
  display: grid;
  place-items: center;
  box-shadow: 0 10px 18px rgba(17, 24, 39, 0.08);
}

.side-nav {
  padding: 12px 12px 0;
  display: grid;
  gap: 10px;
  align-content: start;
}

.side-section {
  font-size: 11px;
  font-weight: 900;
  color: rgba(17, 24, 39, 0.55);
  letter-spacing: 0.5px;
  text-transform: uppercase;
  padding: 4px 6px 0;
}

.side-divider {
  height: 1px;
  background: rgba(229, 231, 235, 0.9);
  margin: 2px 6px 0;
}

.side-link {
  text-decoration: none;
  padding: 10px 10px;
  border-radius: 14px;
  border: 1px solid rgba(229, 231, 235, 0.9);
  background: rgba(255, 255, 255, 0.82);
  font-weight: 800;
  display: flex;
  align-items: center;
  gap: 10px;
  transition: background 140ms ease, border-color 140ms ease, transform 140ms ease;
}

.side-link:hover {
  transform: translateY(-1px);
  background: rgba(255, 255, 255, 0.98);
  border-color: rgba(209, 213, 219, 1);
}

.side-ico {
  width: 28px;
  height: 28px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: rgba(17, 24, 39, 0.06);
  color: rgba(17, 24, 39, 0.70);
  font-size: 12px;
  font-weight: 900;
  flex: 0 0 auto;
}

.side-label {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.side-ext {
  color: rgba(17, 24, 39, 0.45);
}

.side-link.is-active {
  border-color: rgba(47, 95, 47, 0.30);
  background: linear-gradient(180deg, rgba(233, 246, 228, 0.95), rgba(233, 246, 228, 0.70));
  color: #1f3f1f;
}

.side-foot {
  padding: 12px 14px 14px;
  border-top: 1px solid rgba(229, 231, 235, 0.9);
}

.side-note {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
  padding: 0 6px;
}

.side-mini {
  font-size: 12px;
  color: rgba(17, 24, 39, 0.72);
  text-decoration: none;
  border: 1px solid rgba(229, 231, 235, 0.9);
  background: rgba(255, 255, 255, 0.75);
  padding: 8px 10px;
  border-radius: 12px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.side-mini:hover {
  background: rgba(255, 255, 255, 0.98);
}

.side-foot-spacer {
  height: 4px;
}

/* Header */
.top {
  padding: 16px 0 4px;
  background:
    radial-gradient(900px 280px at 10% 0%, rgba(233, 246, 228, 0.85), rgba(255, 255, 255, 0) 60%),
    radial-gradient(740px 260px at 90% 0%, rgba(37, 99, 235, 0.10), rgba(255, 255, 255, 0) 60%);
}

.top-inner {
  max-width: var(--container-max);
  margin: 0 auto;
  padding-left: max(var(--pad-x), env(safe-area-inset-left));
  padding-right: max(var(--pad-x), env(safe-area-inset-right));
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.nav-toggle {
  appearance: none;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 10px;
  width: 42px;
  height: 42px;
  cursor: pointer;
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 5px;
  box-shadow: var(--shadow);
  flex: 0 0 auto;
}

.nav-toggle:hover {
  box-shadow: 0 12px 26px rgba(17, 24, 39, 0.12);
  transform: translateY(-1px);
  transition: transform 140ms ease, box-shadow 140ms ease;
}

.nav-toggle .bar {
  width: 18px;
  height: 2px;
  background: #111827;
  border-radius: 99px;
}

.hero {
  display: grid;
  gap: 4px;
}

.hero-top {
  display: flex;
  align-items: center;
  gap: 10px;
}

.title {
  margin: 0;
  font-size: 26px;
  letter-spacing: -0.4px;
  font-weight: 900;
}

.subtitle {
  margin-top: 2px;
  color: var(--muted);
  font-size: 13px;
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 22px;
  padding: 0 10px;
  border-radius: 999px;
  border: 1px solid rgba(37, 99, 235, 0.25);
  background: rgba(37, 99, 235, 0.08);
  color: rgba(29, 78, 216, 0.95);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.2px;
}

/* Page layout */
.page {
  width: 100%;
  max-width: var(--container-max);
  margin-inline: auto;
  padding-left: max(var(--pad-x), env(safe-area-inset-left));
  padding-right: max(var(--pad-x), env(safe-area-inset-right));
  padding-top: max(12px, env(safe-area-inset-top));
  padding-bottom: max(48px, env(safe-area-inset-bottom));
  min-height: 100vh;
}

@supports (height: 100dvh) {
  .page {
    min-height: 100dvh;
  }
}

.footer {
  border-top: 1px solid var(--line);
  background: #fff;
}

.footer-inner {
  max-width: var(--container-max);
  margin: 0 auto;
  padding-top: 18px;
  padding-bottom: max(26px, env(safe-area-inset-bottom));
  padding-left: max(var(--pad-x), env(safe-area-inset-left));
  padding-right: max(var(--pad-x), env(safe-area-inset-right));
  color: rgba(17, 24, 39, 0.62);
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  font-size: 12px;
  min-width: 0;
}

.footer-title {
  font-weight: 900;
  color: rgba(17, 24, 39, 0.72);
}

.footer-copy {
  text-align: right;
}

.guide {
  margin-top: 10px;
  background: #f7f7f7;
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 18px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 18px;
}

.guide-col {
  padding-right: 18px;
  border-right: 1px solid var(--line);
}

.guide-col:last-child {
  padding-right: 0;
  border-right: none;
}

.guide-h {
  font-weight: 800;
  margin-bottom: 10px;
}

.guide-ul {
  margin: 0;
  padding-left: 18px;
  color: #374151;
  line-height: 1.6;
  font-size: 13px;
}

.guide-ul .em {
  color: #d97706;
  font-weight: 700;
}

.section {
  margin-top: 22px;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-width: 0;
}

.section-head > * {
  min-width: 0;
}

.section-title {
  margin: 0;
  font-size: 20px;
  letter-spacing: -0.2px;
  min-width: 0;
}

.head-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  min-width: 0;
}

.link {
  font-size: 12px;
  color: #111827;
  text-decoration: none;
  border-bottom: 1px solid #9ca3af;
  padding-bottom: 1px;
  white-space: nowrap;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}

.form-wrap {
  margin-top: 12px;
  border: 1px solid var(--line);
  border-radius: var(--r);
  overflow: hidden;
  box-shadow: var(--shadow);
}

.form-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed; /* prevent fixed-width label column from forcing horizontal overflow */
}

.form-table th,
.form-table td {
  border-bottom: 1px solid var(--line);
  padding: 10px 10px;
  vertical-align: middle;
  min-width: 0;
}

.form-table th {
  width: 170px;
  background: #eef7e7;
  border-right: 1px solid var(--mint-line);
  color: #2f5f2f;
  font-weight: 800;
  font-size: 13px;
  white-space: nowrap;
}

.form-table tr:last-child th,
.form-table tr:last-child td {
  border-bottom: none;
}

.row {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.row > * {
  min-width: 0;
}

.hint {
  color: var(--muted);
  font-size: 12px;
}

/* Responsive: turn the table-form into a 1-column stacked form on small screens.
   Fixes iOS/viewport clipping and "label column keeps eating width" issues. */
@media (max-width: 820px) {
  .form-wrap {
    overflow: visible;
  }

  /* Slightly more breathing room on mobile */
  .form-wrap {
    padding: 16px;
  }

  .form-wrap .form-table,
  .form-wrap .form-table tbody,
  .form-wrap .form-table tr {
    display: block;
    width: 100%;
  }

  .form-wrap .form-table tr {
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
    padding: 12px 0;
  }

  .form-wrap .form-table tr:last-child {
    border-bottom: 0;
  }

  .form-wrap .form-table th {
    display: block;
    width: 100%;
    padding: 0 0 10px 0;
    background: transparent;
    border-right: 0;
    border-bottom: 0;
    color: rgba(17, 24, 39, 0.82);
    white-space: normal;
    text-align: left;
    line-height: 1.35;
  }

  .form-wrap .form-table td {
    display: block;
    width: 100%;
    padding: 0;
    border-bottom: 0;
  }

  /* File input + button rows: stack cleanly on narrow viewports */
  .form-wrap .form-table td .row {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
    align-items: stretch;
  }

  .form-wrap .form-table td .row > * {
    width: 100%;
  }

  /* Inputs/selects/textareas: padding + line-height for iOS readability */
  .form-wrap input[type="text"],
  .form-wrap input[type="date"],
  .form-wrap input[type="file"],
  .form-wrap select,
  .form-wrap textarea {
    padding: 12px 14px;
    line-height: 1.35;
    border-radius: 14px;
  }

  .form-wrap input[type="date"] {
    min-height: 48px;
  }

  /* Buttons: larger touch target and better text padding */
  .form-wrap button,
  .form-wrap .btn,
  .form-wrap .pill,
  .form-wrap input[type="button"],
  .form-wrap input[type="submit"] {
    padding: 12px 14px;
    min-height: 48px;
    line-height: 1.2;
    border-radius: 14px;
  }

  .form-wrap input::placeholder,
  .form-wrap textarea::placeholder {
    line-height: 1.35;
  }
}

/* Item table (순번/내용/규격/수량/단가/금액): mobile spacing */
@media (max-width: 820px) {
  .table-wrap .table th,
  .table-wrap .table td {
    padding: 12px 10px;
    line-height: 1.4;
    font-size: 14px;
  }

  .table-wrap .table th {
    text-align: center;
  }

  .table-wrap .table th + th {
    border-left: 1px solid rgba(0, 0, 0, 0.08);
  }

  .table-wrap .table thead th {
    background: rgba(47, 95, 47, 0.06);
  }
}

.input,
.textarea {
  width: min(720px, 100%);
  border: 1px solid #d1d5db;
  border-radius: 6px;
  padding: 10px 10px;
  font-size: 16px;
  background: #fff;
}

.textarea {
  width: 100%;
  resize: vertical;
  line-height: 1.55;
}

.textarea-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: end;
}

.textarea-row > * {
  min-width: 0;
}

.textarea-actions {
  display: grid;
  gap: 8px;
  justify-items: end;
}

.file {
  border: 1px solid #d1d5db;
  border-radius: 6px;
  padding: 8px;
  background: #fff;
  font-size: 16px;
  flex: 1 1 260px;
}

.actions {
  padding: 12px 12px;
  display: flex;
  justify-content: flex-start;
  gap: 10px;
  border-top: 1px solid var(--line);
  background: #fafafa;
}

.btn {
  appearance: none;
  border: 1px solid #cbd5e1;
  background: #fff;
  color: #111827;
  border-radius: 999px;
  padding: 8px 14px;
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
}

.btn-primary {
  background: var(--blue);
  border-color: #1d4ed8;
  color: var(--blue-ink);
}

.btn-ghost {
  background: #fff;
}

.btn[disabled] {
  opacity: 0.55;
  cursor: not-allowed;
}

.pill {
  appearance: none;
  border: 1px solid #d1d5db;
  background: #fff;
  border-radius: 999px;
  padding: 7px 12px;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
  white-space: nowrap;
}

.pill-primary {
  border-color: rgba(37, 99, 235, 0.35);
  background: rgba(37, 99, 235, 0.08);
  color: rgba(29, 78, 216, 0.95);
}

.status {
  padding: 12px;
  border-top: 1px solid var(--line);
  background: #ffffff;
  color: #374151;
  font-size: 13px;
}

.summary {
  margin-top: 10px;
  color: var(--muted);
  font-size: 12px;
}

.table-wrap {
  margin-top: 10px;
  border: 1px solid var(--line);
  border-radius: var(--r);
  overflow: auto;
  box-shadow: var(--shadow);
}

.table-in-form {
  margin-top: 8px;
}

.table {
  width: 100%;
  border-collapse: collapse;
  min-width: 920px;
  background: #fff;
}

.table th,
.table td {
  border-bottom: 1px solid var(--line);
  padding: 10px 10px;
  font-size: 13px;
  vertical-align: middle;
}

.table th {
  background: #f9fafb;
  font-weight: 800;
}

.num {
  text-align: right;
  white-space: nowrap;
}

.w-no {
  width: 70px;
}
.w-spec {
  width: 140px;
}
.w-qty {
  width: 110px;
}
.w-unit {
  width: 130px;
}
.w-amt {
  width: 140px;
}

.cell-copy {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.cell-copy .text {
  min-width: 0;
  overflow-wrap: anywhere;
}

/* Generic card helper (optional) */
.card {
  width: 100%;
  background: #fff;
  border: 1px solid rgba(0, 0, 0, 0.12);
  border-radius: 18px;
  padding: clamp(14px, 3.5vw, 20px);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.06);
}

.card * {
  min-width: 0;
}

/* Long text / report output safety */
pre,
code,
.report,
.resultBox,
.output {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
  max-width: 100%;
  overflow-x: auto;
}

.doc {
  margin-top: 12px;
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 14px;
  background: #fff;
  box-shadow: var(--shadow);
}

.doc-empty {
  color: var(--muted);
  font-size: 13px;
}

/* Document preview formatting */
.doc-page {
  color: #111;
  font-family: ui-serif, Georgia, "Times New Roman", serif;
}

.doc-official {
  max-width: 760px;
  margin: 0 auto;
}

.doc-official-title {
  text-align: center;
  font-weight: 900;
  font-size: 22px;
  letter-spacing: 0.4px;
  margin: 4px 0 12px;
}

.doc-official-table {
  width: 100%;
  border-collapse: collapse;
  border: 2px solid rgba(17, 24, 39, 0.72);
  margin-top: 0;
}

.doc-official-table th,
.doc-official-table td {
  border: 1px solid rgba(17, 24, 39, 0.55);
  padding: 10px 10px;
  vertical-align: top;
  font-size: 14px;
}

.doc-official-table th.w-key {
  width: 86px;
  text-align: center;
  background: rgba(17, 24, 39, 0.10);
  font-weight: 900;
  letter-spacing: 0.2px;
  vertical-align: middle;
}

.doc-pre {
  white-space: pre-wrap;
  line-height: 1.7;
}

.doc-sign {
  padding: 0;
}

.sign-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  min-height: 54px;
}

.sign-cell {
  background: rgba(17, 24, 39, 0.08);
  border-left: 1px solid rgba(17, 24, 39, 0.55);
}

.sign-cell:first-child {
  border-left: none;
}

.doc-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
  border-bottom: 2px solid rgba(17, 24, 39, 0.25);
  padding-bottom: 10px;
  margin-bottom: 12px;
}

.doc-kind {
  font-weight: 800;
  letter-spacing: 0.5px;
  font-size: 20px;
}

.doc-meta {
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  font-size: 12px;
  color: rgba(17, 24, 39, 0.70);
  display: grid;
  gap: 4px;
  text-align: right;
}

.doc-meta .k {
  display: inline-block;
  width: 56px;
  color: rgba(17, 24, 39, 0.55);
}

.doc-subject {
  margin: 0 0 14px;
  font-size: 18px;
  font-weight: 800;
}

.doc-section {
  margin: 12px 0;
}

.doc-h {
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  font-size: 12px;
  font-weight: 800;
  color: rgba(17, 24, 39, 0.75);
  margin-bottom: 6px;
}

.doc-b {
  font-size: 14px;
  line-height: 1.65;
  white-space: pre-wrap;
}

.doc-table {
  width: 100%;
  border-collapse: collapse;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  font-size: 12px;
}

.doc-table th,
.doc-table td {
  border: 1px solid rgba(17, 24, 39, 0.16);
  padding: 8px 8px;
  vertical-align: top;
}

.doc-table th {
  background: rgba(17, 24, 39, 0.05);
  text-align: left;
}

.strong {
  font-weight: 900;
}

.doc-foot {
  margin-top: 16px;
  padding-top: 10px;
  border-top: 1px dashed rgba(17, 24, 39, 0.22);
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  font-size: 12px;
  color: rgba(17, 24, 39, 0.70);
}

@media (max-width: 980px) {
  .footer-inner {
    flex-direction: column;
    align-items: flex-start;
  }
  .footer-copy {
    text-align: left;
  }
  .guide {
    grid-template-columns: 1fr;
  }
  .guide-col {
    padding-right: 0;
    border-right: none;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--line);
  }
  .guide-col:last-child {
    padding-bottom: 0;
    border-bottom: none;
  }
  .form-table th {
    width: 120px;
  }
}

@media print {
  .sidebar,
  .scrim,
  .nav-toggle,
  .guide,
  .section-head .link,
  .section-head .head-actions,
  .actions,
  .status,
  .pill {
    display: none !important;
  }
  body {
    background: #fff;
  }
  .doc {
    box-shadow: none;
    border: none;
    padding: 0;
  }
}
