/* ===== 설악중기 견적 ===== */
* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Pretendard", "Apple SD Gothic Neo", sans-serif;
  background: #f5f6f8;
  color: #1a1a1a;
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}
input, button, select, textarea { font-family: inherit; font-size: 16px; }
button { cursor: pointer; }
a { color: inherit; }

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

/* ===== 상단 바 ===== */
.topbar {
  position: sticky; top: 0; z-index: 10;
  background: #1a1a1a; color: #fff;
  border-bottom: 3px solid #f5b800;
}
.topbar-inner {
  max-width: 600px; margin: 0 auto;
  padding: 12px 16px;
  display: flex; justify-content: space-between; align-items: center;
}
.brand-mini { font-weight: 700; font-size: 17px; }
.topbar-links {
  display: flex; align-items: center; gap: 14px;
}
.topbar-link {
  font-size: 13px; opacity: 0.85;
  text-decoration: none; color: #F5C400;
}
.logout {
  font-size: 13px; opacity: 0.7;
  text-decoration: none;
}

/* ===== 컨테이너 ===== */
.container {
  max-width: 600px; margin: 0 auto;
  padding: 16px;
}

/* ===== 버튼 ===== */
.btn-primary {
  background: #f5b800; color: #1a1a1a;
  border: none; border-radius: 10px;
  padding: 14px 20px; font-weight: 700;
  font-size: 16px;
}
.btn-primary:active { background: #d99e00; }
.btn-block { width: 100%; display: block; }
.btn-ghost {
  background: transparent; border: 1.5px dashed #aaa;
  color: #555; padding: 12px; border-radius: 10px;
  width: 100%; margin-top: 8px;
}
.btn-danger {
  background: #fff; color: #c00;
  border: 1.5px solid #c00; border-radius: 10px;
  padding: 12px; margin-top: 12px; font-weight: 600;
}
.btn-back {
  background: transparent; border: none;
  color: #555; padding: 8px 12px 8px 0;
  font-size: 15px; text-decoration: none;
}

/* ===== 액션 행 ===== */
.action-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.action-row .btn-primary,
.action-row .btn-secondary {
  width: 100%;
}
.btn-secondary {
  background: #fff; color: #1a1a1a;
  border: 1.5px solid #1a1a1a; border-radius: 10px;
  padding: 14px 12px; font-weight: 600;
  font-size: 15px;
}
.btn-secondary:active { background: #f0f0f0; }

/* ===== 견적 목록 ===== */
.search-row { margin: 16px 0 12px; }
#search-input {
  width: 100%; padding: 12px 14px;
  border: 1px solid #ddd; border-radius: 10px;
  background: #fff;
}
.quote-list { display: flex; flex-direction: column; gap: 8px; }
.quote-item {
  background: #fff; border-radius: 12px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
  display: flex; align-items: stretch;
  overflow: hidden;
}
.qi-link {
  flex: 1; display: flex; align-items: center; justify-content: space-between;
  padding: 14px 14px 14px 16px;
  text-decoration: none; color: inherit;
  min-width: 0;
}
.qi-link:active { background: #f8f8f8; }
.qi-left { flex: 1; min-width: 0; }
.qi-date { font-size: 12px; color: #888; }
.qi-client { font-weight: 600; margin-top: 2px; font-size: 16px; }
.qi-site { font-size: 13px; color: #666; margin-top: 2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.qi-total {
  font-weight: 700; color: #1a1a1a;
  font-size: 15px; text-align: right;
  margin-left: 12px; white-space: nowrap;
}
.qi-edit {
  background: #f5f5f5; border: none;
  border-left: 1px solid #eee;
  color: #1a1a1a; font-size: 13px; font-weight: 600;
  padding: 0 16px; min-width: 70px;
  cursor: pointer;
}
.qi-edit:active { background: #e5e5e5; }
.empty { text-align: center; color: #888; padding: 40px 0; }

/* ===== 견적 폼 ===== */
.form-head {
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 16px;
}
.form-title { font-size: 18px; font-weight: 700; }

#quote-form label {
  display: block; margin-bottom: 14px;
  font-size: 13px; color: #555; font-weight: 600;
}
#quote-form input[type=text],
#quote-form input[type=date],
#quote-form input[type=number],
#quote-form textarea {
  width: 100%; margin-top: 6px;
  padding: 12px 14px; border: 1px solid #ddd;
  border-radius: 10px; background: #fff;
  font-size: 16px; color: #1a1a1a;
}
#quote-form textarea { resize: vertical; }
.date-range {
  display: flex; align-items: center; gap: 8px;
  margin-top: 6px;
}
.date-range input[type=date] {
  flex: 1; min-width: 0; margin-top: 0 !important;
}
.date-tilde { color: #888; font-weight: 600; }
.hint {
  display: block; margin-top: 4px;
  color: #999; font-size: 11px; font-weight: 400;
}

.party-fieldset {
  margin: 0 0 14px; padding: 14px;
  background: #fff; border: 1px solid #eee;
  border-radius: 12px;
}
.party-fieldset legend {
  padding: 0 6px;
  font-size: 13px; color: #555; font-weight: 700;
}
.party-fieldset label { margin-bottom: 10px; }
.party-fieldset > label:last-child { margin-bottom: 0; }
.form-row {
  display: flex; gap: 8px; flex-wrap: wrap;
}
.form-row > label {
  flex: 1 1 calc(50% - 4px); min-width: 140px;
}

.items-section {
  margin: 18px 0; padding: 14px;
  background: #fff; border-radius: 12px;
  border: 1px solid #eee;
}
.items-label {
  font-size: 13px; color: #555; font-weight: 600;
  margin-bottom: 10px;
}
.item-row {
  display: flex; flex-wrap: wrap;
  gap: 6px; align-items: center;
  margin-bottom: 8px;
  padding: 10px; border: 1px solid #eee;
  border-radius: 8px; background: #fafafa;
}
.item-row select,
.item-row input {
  padding: 10px 8px; border: 1px solid #ddd;
  border-radius: 8px; background: #fff;
  font-size: 14px; min-width: 0;
}
.item-row .i-eq    { flex: 1 1 100%; }
.item-row .i-dur   { flex: 1 1 110px; }
.item-row .i-name  { flex: 1 1 100%; }
.item-row .i-price { flex: 1 1 110px; }
.item-row .i-qty   { width: 70px; }
.i-amount {
  flex: 1; text-align: right;
  font-weight: 700; font-size: 14px;
  min-width: 90px;
}
.i-del {
  background: transparent; border: none;
  color: #c00; font-size: 24px;
  padding: 0 4px; line-height: 1;
  width: 32px;
}
.item-row[hidden], .item-row .i-dur[hidden],
.item-row .i-name[hidden], .item-row .i-price[hidden] {
  display: none !important;
}

/* 데스크탑은 한 줄로 */
@media (min-width: 600px) {
  .item-row .i-eq { flex: 2 1 180px; }
  .item-row .i-name { flex: 2 1 180px; }
}

.total-box {
  background: #fff; border-radius: 12px;
  padding: 14px 16px; margin: 18px 0;
  border: 1px solid #eee;
}
.total-box .row {
  display: flex; justify-content: space-between;
  padding: 6px 0; font-size: 15px;
}
.total-box .row.total {
  border-top: 1px solid #eee; margin-top: 6px;
  padding-top: 12px; font-size: 18px; font-weight: 700;
}
.total-box .row.total b { color: #c8102e; }

/* ===== 로그인 ===== */
.login-body {
  background: #1a1a1a;
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.login-box {
  width: 100%; max-width: 360px;
  background: #fff; border-radius: 16px;
  padding: 32px 24px;
}
.logo-area { text-align: center; margin-bottom: 24px; }
.brand {
  font-size: 26px; font-weight: 800;
  color: #1a1a1a;
}
.brand-sub { color: #888; margin-top: 4px; }
.login-box input[type=password] {
  width: 100%; padding: 14px;
  border: 1px solid #ddd; border-radius: 10px;
  font-size: 16px;
}
.login-box button {
  width: 100%; margin-top: 12px;
  background: #f5b800; color: #1a1a1a;
  border: none; padding: 14px; border-radius: 10px;
  font-weight: 700; font-size: 16px;
}
.err {
  color: #c00; font-size: 13px;
  margin-top: 8px; text-align: center;
}

/* ===== 견적서 출력 ===== */
.quote-body {
  background: #ddd;
  margin: 0; padding: 0;
}
.quote-toolbar {
  position: sticky; top: 0; z-index: 5;
  background: #1a1a1a;
  padding: 12px 16px;
  display: flex; justify-content: space-between; align-items: center;
  gap: 12px;
}
.quote-toolbar .btn-back { color: #fff; }
.quote-toolbar .btn-primary { padding: 10px 16px; }

.quote-paper {
  background: #fff;
  max-width: 780px; margin: 20px auto;
  padding: 36px 40px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.1);
  font-size: 14px;
  color: #1a1a1a;
}

.q-header {
  display: flex; justify-content: space-between; align-items: flex-start;
  border-bottom: 3px solid #1a1a1a;
  padding-bottom: 16px;
}
.q-title {
  font-size: 30px; font-weight: 800;
  letter-spacing: 12px;
}
.q-meta { font-size: 12px; color: #555; text-align: right; }

.q-parties {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 20px; margin: 20px 0;
}
.q-party-label {
  font-size: 11px; color: #888;
  border-bottom: 1px solid #ddd;
  padding-bottom: 4px; margin-bottom: 8px;
}
.q-party-name { font-size: 18px; font-weight: 700; }
.q-party-sub { font-size: 13px; color: #555; margin-top: 4px; }

.q-supplier-table {
  width: 100%; border-collapse: collapse;
  font-size: 13px;
}
.q-supplier-table th {
  text-align: left; padding: 4px 8px 4px 0;
  color: #777; font-weight: 500; width: 60px; vertical-align: top;
}
.q-supplier-table td { padding: 4px 0; position: relative; }
.stamp {
  width: 64px; height: 64px;
  position: absolute; right: 0; top: -14px;
  opacity: 0.92;
  pointer-events: none;
}

.q-greeting { margin: 16px 0 8px; font-size: 14px; }

.q-items {
  width: 100%; border-collapse: collapse;
  margin-top: 8px;
}
.q-items th, .q-items td {
  border: 1px solid #ccc;
  padding: 10px 8px;
  text-align: center;
}
.q-items thead th {
  background: #1a1a1a; color: #fff;
  font-weight: 600;
}
.q-items td:first-child { text-align: left; }
.q-items td:last-child, .q-items th:last-child { text-align: right; }
.q-items tfoot th {
  background: #f7f7f7; text-align: right;
  font-weight: 600;
}
.q-items tfoot td { text-align: right; font-weight: 600; }
.q-items tfoot tr.total-row th,
.q-items tfoot tr.total-row td {
  font-size: 16px; color: #c8102e;
  background: #fff8e0;
}

.q-note {
  margin-top: 16px; padding: 12px;
  background: #fafafa; border-left: 3px solid #f5b800;
  font-size: 13px;
}
.q-note-label { color: #888; font-size: 11px; margin-bottom: 4px; }

.q-bank {
  margin-top: 16px; padding: 12px;
  border: 1px solid #ddd; border-radius: 6px;
  font-size: 13px;
}
.q-bank-label { color: #888; font-size: 11px; margin-bottom: 4px; }
.q-bank-body { font-weight: 600; }

/* 거래명세서 전용 */
.statement-paper .q-title { letter-spacing: 8px; }
.statement-items th, .statement-items td {
  padding: 8px 6px;
  font-size: 13px;
}
.statement-items td { text-align: right; }
.statement-items td:nth-child(1),
.statement-items td:nth-child(2),
.statement-items td:nth-child(3) { text-align: left; }
.statement-items th:nth-child(1),
.statement-items th:nth-child(2),
.statement-items th:nth-child(3) { text-align: left; }
.statement-items tfoot td { text-align: right; }
.statement-items tfoot tr.total-row td { text-align: right; }

.statement-receipt {
  margin-top: 24px;
  padding: 16px;
  border: 1px solid #ccc; border-radius: 6px;
  background: #fafafa;
}
.statement-receipt .receipt-row { display: flex; align-items: center; }
.statement-receipt .receipt-row + .receipt-row { margin-top: 12px; }
.statement-receipt .receipt-label {
  font-size: 13px; color: #444;
}
.statement-receipt .receipt-cell {
  display: flex; align-items: flex-end;
  width: 100%; gap: 12px;
}
.statement-receipt .receipt-cell-label {
  font-size: 13px; color: #666; min-width: 60px;
}
.statement-receipt .receipt-cell-blank {
  flex: 1; border-bottom: 1px solid #999; height: 32px;
}
.statement-receipt .receipt-cell-sub {
  font-size: 11px; color: #888;
}

.q-links {
  margin-top: 16px;
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.q-link {
  display: flex; flex-direction: column; gap: 2px;
  padding: 10px 12px;
  border: 1px solid #ddd; border-radius: 6px;
  text-decoration: none; color: #1a1a1a;
  font-size: 13px;
}
.q-link:hover { background: #fafafa; }
.q-link-url {
  font-size: 11px; color: #666;
  word-break: break-all;
}

.q-footer {
  margin-top: 16px; padding-top: 12px;
  border-top: 1px solid #eee;
  text-align: center; color: #888; font-size: 12px;
}

@media (max-width: 480px) {
  .q-links { grid-template-columns: 1fr; }
}

@media print {
  .q-links { display: none; }
}

/* 모바일에서 견적서 미리보기 */
@media (max-width: 600px) {
  .quote-paper { margin: 0; padding: 20px; box-shadow: none; }
  .q-title { font-size: 22px; letter-spacing: 8px; }
  .q-parties { grid-template-columns: 1fr; gap: 12px; }
  .q-items th, .q-items td { padding: 6px 4px; font-size: 12px; }
}

/* ===== 모달 (작업일보 선택) ===== */
.modal {
  position: fixed; inset: 0;
  z-index: 100;
  display: flex; align-items: stretch; justify-content: center;
}
.modal.hidden { display: none; }
.modal-backdrop {
  position: absolute; inset: 0;
  background: rgba(0,0,0,0.5);
}
.modal-panel {
  position: relative;
  background: #fff;
  width: 100%; max-width: 600px;
  margin: 0;
  display: flex; flex-direction: column;
  max-height: 100vh;
}
@media (min-width: 600px) {
  .modal { padding: 20px; align-items: center; }
  .modal-panel { border-radius: 16px; max-height: 90vh; }
}

.modal-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 16px; border-bottom: 1px solid #eee;
  background: #1a1a1a; color: #fff;
}
@media (min-width: 600px) {
  .modal-head { border-radius: 16px 16px 0 0; }
}
.modal-title { font-weight: 700; font-size: 17px; }
.modal-close {
  background: transparent; border: none; color: #fff;
  font-size: 28px; line-height: 1; padding: 0 4px;
}

.modal-filter {
  padding: 12px 16px;
  display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
  border-bottom: 1px solid #eee; background: #fafafa;
  font-size: 13px;
}
.modal-filter label {
  display: flex; align-items: center; gap: 4px;
  color: #555;
}
.modal-filter select {
  padding: 6px 8px; border: 1px solid #ddd; border-radius: 6px;
  background: #fff; font-size: 13px;
}
#wl-reload { padding: 6px 12px; margin-left: auto; }

.modal-body {
  flex: 1; overflow-y: auto;
  padding: 8px 12px;
}

.wl-group {
  margin-bottom: 14px;
  border: 1px solid #eee;
  border-radius: 10px;
  overflow: hidden;
}
.wl-group-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 12px;
  background: #f7f7f7; border-bottom: 1px solid #eee;
  font-size: 14px;
}
.wl-group-toggle {
  display: flex; align-items: center; gap: 8px;
  cursor: pointer;
}
.wl-group-toggle input { width: 18px; height: 18px; }
.wl-group-count { color: #888; font-size: 12px; }

.wl-rows { display: flex; flex-direction: column; }
.wl-row {
  display: grid;
  grid-template-columns: 24px 50px 1fr auto;
  gap: 10px; align-items: center;
  padding: 12px;
  border-bottom: 1px solid #f0f0f0;
  cursor: pointer;
}
.wl-row:last-child { border-bottom: none; }
.wl-row.selected { background: #fff8e0; }
.wl-row input { width: 18px; height: 18px; margin: 0; }
.wl-cell-date {
  font-size: 12px; color: #666; font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.wl-cell-main { min-width: 0; }
.wl-eq { font-weight: 600; font-size: 14px; }
.wl-tt { color: #888; font-weight: 400; font-size: 12px; margin-left: 4px; }
.wl-site { font-size: 12px; color: #777; margin-top: 2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wl-content { font-size: 11px; color: #999; margin-top: 2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wl-cell-amt {
  font-weight: 700; font-size: 14px;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.modal-foot {
  padding: 12px 16px;
  border-top: 1px solid #eee;
  display: flex; justify-content: space-between; align-items: center;
  gap: 10px; background: #fff;
}
.wl-summary {
  font-size: 13px; color: #555; font-weight: 600;
}
#wl-import { flex: 1; padding: 12px 16px; }
#wl-import:disabled { opacity: 0.4; cursor: not-allowed; }

/* 내 정보 페이지 (도장 + 공급자) */
.profile-page, .stamp-page {
  max-width: 520px;
  margin: 16px auto;
  padding: 0 4px;
}
.profile-head, .stamp-page-head { margin-bottom: 12px; }
.profile-head h2, .stamp-page-head h2 {
  margin: 4px 0;
  font-size: 22px;
}
.profile-sub, .stamp-page-sub {
  color: #555; font-size: 14px; margin-bottom: 4px;
}
.profile-sub .profile-id,
.stamp-page-sub .stamp-id { color: #999; margin-left: 4px; }

.profile-card {
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 10px;
  padding: 16px;
  margin-bottom: 16px;
}
.profile-card h3 {
  margin: 0 0 6px;
  font-size: 17px;
}

.supplier-form label {
  display: block;
  font-size: 13px;
  color: #555;
  margin: 10px 0 4px;
}
.supplier-form label input {
  display: block; width: 100%;
  padding: 10px 12px; font-size: 15px;
  border: 1px solid #ccc; border-radius: 6px; background: #fafafa;
  box-sizing: border-box;
}
.sup-section-label {
  margin: 14px 0 4px;
  font-size: 13px; font-weight: 600; color: #333;
  border-top: 1px dashed #e0e0e0; padding-top: 12px;
}
.sup-section-label:first-of-type { border-top: 0; padding-top: 0; }
.supplier-form .btn-primary { margin-top: 14px; }
.supplier-reset-form { margin-top: 8px; }

.stamp-preview-box {
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 8px;
  padding: 16px;
  margin: 16px 0;
}
.stamp-preview-label {
  font-size: 13px; color: #777; margin-bottom: 8px;
}
.stamp-preview {
  display: flex; align-items: center; justify-content: center;
  min-height: 180px;
  background:
    linear-gradient(45deg, #f4f4f4 25%, transparent 25%) 0 0/16px 16px,
    linear-gradient(-45deg, #f4f4f4 25%, transparent 25%) 0 8px/16px 16px,
    linear-gradient(45deg, transparent 75%, #f4f4f4 75%) 8px -8px/16px 16px,
    linear-gradient(-45deg, transparent 75%, #f4f4f4 75%) 8px 0/16px 16px,
    #fff;
  border-radius: 6px;
}
.stamp-large {
  max-width: 180px; max-height: 180px;
  width: auto; height: auto;
  display: block;
}
.stamp-empty {
  color: #aaa; font-size: 14px;
}

.stamp-form {
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 12px;
}
.stamp-file-label {
  display: block; font-size: 14px; color: #333;
  margin-bottom: 12px;
}
.stamp-file-label span { display: block; margin-bottom: 6px; color: #555; }
.stamp-file-label input[type="file"] {
  width: 100%; padding: 8px; font-size: 14px;
  border: 1px solid #ccc; border-radius: 6px; background: #fafafa;
}
.stamp-del-form { margin-top: 8px; }

.msg {
  padding: 10px 12px; border-radius: 6px;
  font-size: 14px; margin: 12px 0;
}
.msg.ok   { background: #e7f6ec; color: #1f7a3e; border: 1px solid #b8e2c6; }
.msg.err  { background: #fdecec; color: #b71c1c; border: 1px solid #f5c2c2; }
.msg.warn { background: #fff5e0; color: #8a5a00; border: 1px solid #f0d29a; }

/* 인쇄 */
@media print {
  body { background: #fff; }
  .no-print { display: none !important; }
  .quote-paper {
    box-shadow: none; margin: 0; max-width: none;
    padding: 20mm;
  }
  .q-parties { grid-template-columns: 1fr 1fr; }
}
