/* ============================================================
   디지털사이니지 견적서 — 모던 기업용 UI
   팔레트: 차분한 회백 배경 + DIDBANK 틸(teal) 포인트
   ============================================================ */
:root {
  --bg:        #f6f7f9;
  --surface:   #ffffff;
  --surface-2: #fbfcfd;
  --ink:       #0f172a;
  --muted:     #64748b;
  --faint:     #94a3b8;
  --line:      #e7eaee;
  --line-2:    #eef1f4;
  --teal:      #0ea5a4;
  --teal-700:  #0c8584;
  --teal-50:   #ecfdfc;
  --danger:    #e11d48;
  --danger-50: #fff1f3;
  --ok:        #059669;
  --ok-50:     #ecfdf5;
  --shadow-sm: 0 1px 2px rgba(15,23,42,.04), 0 1px 3px rgba(15,23,42,.06);
  --shadow-md: 0 4px 12px rgba(15,23,42,.06), 0 2px 4px rgba(15,23,42,.04);
  --shadow-lg: 0 12px 32px rgba(15,23,42,.10);
  --r:   10px;
  --r-sm: 7px;
  --r-lg: 14px;
}

* { box-sizing: border-box; }
html { -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; }
body {
  margin: 0;
  font-family: "Pretendard", "Pretendard Variable", -apple-system,
               "Malgun Gothic", "맑은 고딕", system-ui, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.5;
}
.num { font-variant-numeric: tabular-nums; font-feature-settings: "tnum"; }

/* ---------- 앱 레이아웃 (사이드바 + 메인) ---------- */
.app-shell { display: flex; min-height: 100vh; }
.app-main { flex: 1; min-width: 0; }

.sidebar {
  width: 76px; flex: none;
  background: #0f172a; color: #cbd5e1;
  display: flex; flex-direction: column; align-items: center;
  padding: 14px 0; gap: 6px;
  position: sticky; top: 0; height: 100vh;
}
.sb-logo {
  width: 40px; height: 40px; border-radius: 11px; margin-bottom: 10px;
  background: linear-gradient(135deg, var(--teal), #0891b2);
  display: grid; place-items: center; color: #fff; font-weight: 800; font-size: 18px;
  box-shadow: 0 2px 10px rgba(14,165,164,.4);
}
.sb-item {
  width: 60px; padding: 9px 0; border-radius: 10px;
  background: transparent; color: #94a3b8;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  font-size: 11px; font-weight: 600; transition: all .12s;
}
.sb-item svg { stroke: currentColor; }
.sb-item:hover { background: rgba(255,255,255,.06); color: #e2e8f0; }
.sb-item.active { background: var(--teal); color: #fff; }
.sb-spacer { flex: 1; }
#sbLogout:hover { background: rgba(225,29,72,.15); color: #fda4af; }

/* ---------- 헤더 ---------- */
header {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  padding: 0 28px;
  height: 60px;
  display: flex;
  align-items: center;
  gap: 14px;
  position: sticky; top: 0; z-index: 20;
}
.logo-dot {
  width: 30px; height: 30px; border-radius: 9px;
  background: linear-gradient(135deg, var(--teal), #0891b2);
  display: grid; place-items: center;
  color: #fff; font-weight: 800; font-size: 15px;
  box-shadow: 0 2px 8px rgba(14,165,164,.35);
}
header h1 { font-size: 16px; font-weight: 700; margin: 0; letter-spacing: -.01em; }
header .sub { font-size: 12px; color: var(--faint); margin-left: 2px; }
header .spacer { flex: 1; }
header .pill {
  font-size: 12px; color: var(--teal-700); background: var(--teal-50);
  border: 1px solid #cdeeed; padding: 5px 11px; border-radius: 999px; font-weight: 600;
}

/* ---------- 레이아웃 ---------- */
main {
  display: grid;
  grid-template-columns: minmax(0,1fr) 380px;
  gap: 20px;
  padding: 24px 28px 64px;
  max-width: 1320px;
  margin: 0 auto;
  align-items: start;
}
/* 3분할: 좌(입력) 중(품목) 우(이력) */
main.cols3 {
  grid-template-columns: minmax(0,1fr) 320px 320px;
  max-width: 1560px;
}
.col { min-width: 0; }
.sticky-card { position: sticky; top: 84px; }
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
}
.card + .card { margin-top: 18px; }
.card-head {
  display: flex; align-items: center; gap: 10px;
  padding: 16px 20px; border-bottom: 1px solid var(--line-2);
}
.card-head .step {
  width: 22px; height: 22px; border-radius: 7px; flex: none;
  background: var(--ink); color: #fff; font-size: 12px; font-weight: 700;
  display: grid; place-items: center;
}
.card-head h2 { font-size: 14px; font-weight: 700; margin: 0; letter-spacing: -.01em; }
.card-head .hint { font-size: 12px; color: var(--faint); margin-left: auto; font-weight: 500; }
.btn-new {
  margin-left: auto; padding: 7px 14px; border-radius: 999px;
  background: var(--teal); color: #fff; font-size: 13px; font-weight: 700;
  box-shadow: 0 2px 8px rgba(14,165,164,.3); transition: all .12s;
}
.btn-new:hover { background: var(--teal-700); transform: translateY(-1px); }
.card-body { padding: 18px 20px; }

/* ---------- 폼 ---------- */
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 14px; }
label.field { display: flex; flex-direction: column; gap: 6px; }
label.field > span { font-size: 12px; font-weight: 600; color: var(--muted); letter-spacing: -.005em; }
input, textarea, select {
  font: inherit; font-size: 13.5px; color: var(--ink);
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--surface);
  transition: border-color .12s, box-shadow .12s, background .12s;
  width: 100%;
}
input::placeholder, textarea::placeholder { color: #b3bccb; }
input:hover, textarea:hover, select:hover { border-color: #d3d9e1; }
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(14,165,164,.14);
  background: var(--surface);
}
textarea { min-height: 40px; resize: vertical; line-height: 1.45; }
select { cursor: pointer; appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2.5'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center; padding-right: 30px;
}

/* ---------- 버튼 ---------- */
button { cursor: pointer; font: inherit; border: none; border-radius: var(--r-sm); transition: all .12s; }
.btn-ghost {
  width: 100%; margin-top: 12px; padding: 10px;
  background: var(--surface-2); color: var(--muted);
  border: 1px dashed var(--line); font-size: 13px; font-weight: 600;
}
.btn-ghost:hover { border-color: var(--teal); color: var(--teal-700); background: var(--teal-50); }
.btn-primary {
  width: 100%; padding: 13px; margin-top: 4px;
  background: var(--ink); color: #fff; font-size: 14.5px; font-weight: 700;
  letter-spacing: -.01em; box-shadow: var(--shadow-md);
}
.btn-primary:hover { background: #1e293b; transform: translateY(-1px); box-shadow: var(--shadow-lg); }
.btn-primary:active { transform: translateY(0); }
.btn-primary:disabled { background: #cbd5e1; cursor: wait; transform: none; box-shadow: none; }
.btn-row { display: flex; gap: 10px; margin-top: 4px; }
.btn-row .btn-primary { margin-top: 0; flex: 1; }
.btn-save {
  flex: none; padding: 13px 22px;
  background: var(--surface); color: var(--ink);
  border: 1px solid var(--line); font-size: 14.5px; font-weight: 700;
  box-shadow: var(--shadow-sm);
}
.btn-save:hover { border-color: var(--teal); color: var(--teal-700); background: var(--teal-50); transform: translateY(-1px); }
.btn-save:active { transform: translateY(0); }
.btn-save:disabled { color: #94a3b8; cursor: wait; transform: none; }

/* ---------- 품목 그룹 ---------- */
.group {
  border: 1px solid var(--line); border-radius: var(--r);
  margin-bottom: 14px; overflow: hidden; background: var(--surface);
}
.group:last-child { margin-bottom: 0; }
.group-head {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px; background: var(--surface-2); border-bottom: 1px solid var(--line-2);
}
.group-head .gidx {
  width: 20px; height: 20px; border-radius: 6px; flex: none;
  background: var(--teal-50); color: var(--teal-700);
  font-size: 11px; font-weight: 800; display: grid; place-items: center;
}
.group-install { border-color: #cdeeed; }
.group-install .group-head { background: var(--teal-50); }
.grp-badge { flex: none; font-size: 11px; font-weight: 700; color: var(--teal-700); background: #d7f5f4; padding: 3px 9px; border-radius: 999px; }
.group-head input { flex: 1; font-weight: 600; border: none; background: transparent; padding: 4px 6px; }
.group-head input:hover { background: var(--surface); }
.group-head input:focus { background: var(--surface); box-shadow: 0 0 0 2px rgba(14,165,164,.2); }
.group-items { padding: 10px 12px; }

/* 품목 테이블 헤더 */
.item-cols, .item-row {
  display: grid;
  grid-template-columns: 1.5fr 2.2fr 64px 56px 100px 30px;
  gap: 8px; align-items: start;
}
.item-cols { padding: 0 2px 6px; }
.item-cols span { font-size: 11px; font-weight: 700; color: var(--faint); text-transform: uppercase; letter-spacing: .03em; }
.item-cols span:nth-child(n+3) { text-align: right; }
.item-row { margin-bottom: 7px; }
.item-row input, .item-row textarea { padding: 7px 9px; font-size: 13px; }
.item-row .num { text-align: right; }
.item-row textarea { min-height: 36px; }
.icon-btn {
  width: 30px; height: 34px; display: grid; place-items: center;
  background: var(--surface-2); color: var(--faint);
  border: 1px solid var(--line); border-radius: var(--r-sm); font-size: 14px;
}
.icon-btn:hover { background: var(--danger-50); color: var(--danger); border-color: #fbcfe8; }
.row-add {
  width: 100%; margin-top: 4px; padding: 8px;
  background: transparent; color: var(--muted);
  border: 1px dashed var(--line); font-size: 12.5px; font-weight: 600;
}
.row-add:hover { color: var(--teal-700); border-color: var(--teal); background: var(--teal-50); }
.empty-items { color: var(--faint); font-size: 12.5px; text-align: center; padding: 10px; }

/* ---------- 우측 패널 ---------- */
.side { position: sticky; top: 84px; display: flex; flex-direction: column; gap: 18px; }

/* 품목 라이브러리 */
.lib-target { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; font-size: 12.5px; color: var(--muted); }
.lib-target select { width: auto; flex: 1; padding: 7px 28px 7px 10px; font-size: 13px; }
.product-list { display: flex; flex-direction: column; gap: 7px; max-height: 260px; overflow-y: auto; margin: -2px -2px 0; padding: 2px; }
.product-list::-webkit-scrollbar { width: 8px; }
.product-list::-webkit-scrollbar-thumb { background: #d8dee6; border-radius: 8px; border: 2px solid var(--surface); }
.product {
  display: flex; align-items: center; gap: 10px;
  border: 1px solid var(--line); border-radius: var(--r-sm);
  padding: 9px 11px; cursor: pointer; background: var(--surface);
  transition: all .12s;
}
.product:hover { border-color: var(--teal); background: var(--teal-50); transform: translateX(2px); }
.product .p-main { flex: 1; min-width: 0; }
.product .p-name { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.product .p-meta { font-size: 11.5px; color: var(--muted); margin-top: 1px; }
.product .p-add { color: var(--teal-700); font-size: 13px; font-weight: 700; opacity: 0; transition: opacity .12s; }
.product:hover .p-add { opacity: 1; }
.product .p-del { color: var(--faint); font-size: 13px; padding: 2px 6px; border-radius: 5px; background: transparent; }
.product .p-del:hover { background: var(--danger-50); color: var(--danger); }

.newprod { margin-top: 12px; border-top: 1px solid var(--line-2); padding-top: 12px; }
.newprod summary { cursor: pointer; color: var(--teal-700); font-size: 13px; font-weight: 600; list-style: none; user-select: none; }
.newprod summary::-webkit-details-marker { display: none; }
.newprod summary::before { content: "＋ "; }
.newprod[open] summary::before { content: "－ "; }
.newprod .np-form { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.newprod button { background: var(--ok); color: #fff; padding: 9px; font-size: 13px; font-weight: 600; }
.newprod button:hover { filter: brightness(.95); }

/* ---------- 견적 요약 (시그니처) ---------- */
.summary { padding: 0; overflow: hidden; }
.summary .sum-rows { padding: 18px 20px 4px; }
.sum-line { display: flex; justify-content: space-between; align-items: baseline; padding: 7px 0; font-size: 13.5px; color: var(--muted); }
.sum-line .v { color: var(--ink); font-weight: 600; }
.sum-line + .sum-line { border-top: 1px dashed var(--line-2); }
.sum-total {
  margin-top: 6px; padding: 18px 20px;
  background: linear-gradient(135deg, #0f172a, #1e293b);
  color: #fff;
}
.sum-total .lbl { font-size: 12px; color: #94a3b8; letter-spacing: .02em; }
.sum-total .amt { font-size: 30px; font-weight: 800; letter-spacing: -.02em; margin-top: 2px; }
.sum-total .amt small { font-size: 16px; font-weight: 600; color: #cbd5e1; margin-right: 2px; }
.sum-total .korean {
  margin-top: 10px; padding-top: 10px; border-top: 1px solid rgba(255,255,255,.12);
  font-size: 13px; color: #5eead4; font-weight: 600; text-align: center; letter-spacing: .02em;
}

/* ---------- 결과 ---------- */
.result { margin-top: 14px; display: flex; flex-wrap: wrap; gap: 8px; }
.result a {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 10px 16px; border-radius: var(--r-sm); text-decoration: none;
  font-size: 13.5px; font-weight: 600; border: 1px solid;
}
.result a.xlsx { background: var(--ok-50); color: #047857; border-color: #a7f3d0; }
.result a.pdf  { background: #fff7ed; color: #c2410c; border-color: #fed7aa; }
.result a:hover { transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.result .err { width: 100%; color: var(--danger); font-size: 12.5px; background: var(--danger-50); padding: 8px 12px; border-radius: var(--r-sm); }
.result .ok-line { width: 100%; color: var(--teal-700); font-size: 12.5px; font-weight: 600; }
.result .ok-line b { font-variant-numeric: tabular-nums; }

/* ---------- 발행 이력 (우측) ---------- */
.search-box {
  display: flex; align-items: center; gap: 8px;
  border: 1px solid var(--line); border-radius: var(--r-sm);
  padding: 0 10px; margin-bottom: 12px; color: var(--faint);
  transition: border-color .12s, box-shadow .12s;
}
.search-box:focus-within { border-color: var(--teal); box-shadow: 0 0 0 3px rgba(14,165,164,.14); color: var(--teal); }
.search-box svg { flex: none; }
.search-box input { border: none; padding: 9px 0; background: transparent; }
.search-box input:focus { box-shadow: none; }

.history-list { display: flex; flex-direction: column; gap: 8px; max-height: calc(100vh - 230px); overflow-y: auto; margin: 0 -2px; padding: 2px; }
.history-list::-webkit-scrollbar { width: 8px; }
.history-list::-webkit-scrollbar-thumb { background: #d8dee6; border-radius: 8px; border: 2px solid var(--surface); }
.hist {
  border: 1px solid var(--line); border-radius: var(--r-sm);
  padding: 11px 12px; cursor: pointer; background: var(--surface);
  transition: all .12s;
}
.hist:hover { border-color: var(--teal); background: var(--teal-50); transform: translateX(-2px); box-shadow: var(--shadow-sm); }
.hist .h-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.hist .h-serial { font-size: 12.5px; font-weight: 700; color: var(--teal-700); font-variant-numeric: tabular-nums; }
.hist .h-right { display: flex; align-items: center; gap: 4px; }
.hist .h-date { font-size: 11px; color: var(--faint); white-space: nowrap; }
.hist .h-del {
  width: 20px; height: 20px; flex: none; display: grid; place-items: center;
  background: transparent; color: var(--faint); font-size: 12px; border-radius: 5px;
  opacity: 0; transition: opacity .12s, background .12s, color .12s;
}
.hist:hover .h-del { opacity: 1; }
.hist .h-del:hover { background: var(--danger-50); color: var(--danger); }
.hist .h-recv { font-size: 13px; font-weight: 600; margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hist .h-bot { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin-top: 2px; }
.hist .h-proj { font-size: 11.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hist .h-total { font-size: 12.5px; font-weight: 700; color: var(--ink); font-variant-numeric: tabular-nums; white-space: nowrap; }
.hist mark { background: #fde68a; color: inherit; border-radius: 2px; padding: 0 1px; }
.empty-hist { color: var(--faint); font-size: 12.5px; text-align: center; padding: 24px 10px; }

/* ---------- 로그인 페이지 ---------- */
.login-page {
  display: grid; place-items: center; min-height: 100vh;
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
}
.login-card {
  width: min(380px, calc(100vw - 32px));
  background: var(--surface); border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0,0,0,.3);
  padding: 36px 32px 28px; text-align: center;
}
.login-logo {
  width: 56px; height: 56px; margin: 0 auto 16px; border-radius: 15px;
  background: linear-gradient(135deg, var(--teal), #0891b2);
  display: grid; place-items: center; color: #fff; font-weight: 800; font-size: 26px;
  box-shadow: 0 4px 16px rgba(14,165,164,.4);
}
.login-brand { font-size: 22px; font-weight: 800; margin: 0; letter-spacing: -.02em; }
.login-sub { font-size: 13px; color: var(--faint); margin: 4px 0 24px; }
.login-form { display: flex; flex-direction: column; gap: 12px; text-align: left; }
.login-form .field span { font-size: 12px; font-weight: 600; color: var(--muted); }
.login-form .btn-primary { margin-top: 6px; }
.login-error { color: var(--danger); font-size: 13px; background: var(--danger-50); padding: 9px 12px; border-radius: var(--r-sm); }
.login-hint { font-size: 12px; color: var(--faint); margin-top: 18px; }
.login-hint b { color: var(--muted); }

/* ---------- 설정 화면 ---------- */
.settings-view { max-width: 760px; padding: 24px 28px 64px; }
/* hidden 속성이 display:grid/flex 보다 우선하도록 강제 (뷰 전환 정상화) */
[hidden] { display: none !important; }
.user-list { display: flex; flex-direction: column; gap: 8px; }
.user-row {
  display: flex; align-items: center; gap: 10px;
  border: 1px solid var(--line); border-radius: var(--r-sm); padding: 11px 14px;
}
.user-row .u-name { font-weight: 600; font-size: 14px; }
.user-row .u-badge { font-size: 11px; font-weight: 700; color: var(--teal-700); background: var(--teal-50); padding: 2px 8px; border-radius: 999px; }
.user-row .u-me { font-size: 11px; color: var(--faint); }
.user-row .u-del { margin-left: auto; background: transparent; color: var(--faint); padding: 5px 9px; border-radius: 6px; font-size: 13px; }
.user-row .u-del:hover { background: var(--danger-50); color: var(--danger); }
.chk { display: flex; align-items: center; gap: 7px; font-size: 13px; color: var(--muted); }
.chk input { width: auto; }

/* ---------- 확인 모달 ---------- */
.modal-overlay {
  position: fixed; inset: 0; z-index: 1000;
  background: rgba(15, 23, 42, .45);
  backdrop-filter: blur(2px);
  display: grid; place-items: center;
  animation: overlayIn .15s ease;
}
.modal-overlay[hidden] { display: none; }
@keyframes overlayIn { from { opacity: 0; } to { opacity: 1; } }
.modal {
  width: min(400px, calc(100vw - 40px));
  background: var(--surface);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg);
  padding: 26px 24px 20px;
  text-align: center;
  animation: modalIn .18s cubic-bezier(.16,1,.3,1);
}
@keyframes modalIn { from { opacity: 0; transform: translateY(12px) scale(.97); } to { opacity: 1; transform: none; } }
.modal-icon {
  width: 48px; height: 48px; margin: 0 auto 14px;
  border-radius: 50%; display: grid; place-items: center;
  font-size: 24px; font-weight: 700;
  background: var(--danger-50); color: var(--danger);
}
.modal-icon.ask { background: var(--teal-50); color: var(--teal-700); }
.modal-title { font-size: 16px; font-weight: 700; color: var(--ink); letter-spacing: -.01em; }
.modal-msg { font-size: 13.5px; color: var(--muted); margin-top: 8px; line-height: 1.55; white-space: pre-line; }
.modal-actions { display: flex; gap: 10px; margin-top: 22px; }
.modal-btn { flex: 1; padding: 11px; border-radius: var(--r-sm); font-size: 14px; font-weight: 700; transition: all .12s; }
.modal-btn.cancel { background: var(--surface-2); color: var(--muted); border: 1px solid var(--line); }
.modal-btn.cancel:hover { background: #eef1f4; color: var(--ink); }
.modal-btn.confirm { background: var(--danger); color: #fff; }
.modal-btn.confirm:hover { filter: brightness(.94); }
.modal-btn.confirm.teal { background: var(--teal); }

/* ---------- 반응형 ---------- */
@media (max-width: 1280px) {
  main.cols3 { grid-template-columns: minmax(0,1fr) 300px; }
  .col-history { grid-column: 1 / -1; }
  .col-history .sticky-card { position: static; }
  .history-list { max-height: 320px; }
}
@media (max-width: 860px) {
  main, main.cols3 { grid-template-columns: 1fr; }
  .sticky-card { position: static; }
  .history-list { max-height: 320px; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
