* { box-sizing: border-box; }
body {
  font-family: -apple-system, "Segoe UI", "Malgun Gothic", sans-serif;
  margin: 0; background: #f4f6f8; color: #1f2937;
}
header {
  background: #2f7d4f; color: #fff; padding: 12px 20px;
  display: flex; align-items: center; gap: 24px; flex-wrap: wrap;
  position: sticky; top: 0; z-index: 10;
}
.brand { font-weight: 700; font-size: 18px; }
nav a {
  color: #e8f5ee; text-decoration: none; margin-right: 14px; font-size: 15px;
}
nav a:hover { color: #fff; text-decoration: underline; }
main { max-width: 1000px; margin: 24px auto; padding: 0 16px; }
footer { text-align: center; color: #9ca3af; font-size: 12px; padding: 30px 0; }

h1 { font-size: 22px; margin: 8px 0 16px; }
h2 { font-size: 17px; margin: 24px 0 10px; color: #374151; }

.flash { padding: 12px 16px; border-radius: 8px; margin-bottom: 16px; font-size: 14px; }
.flash.ok { background: #e7f6ec; color: #1a7f3c; border: 1px solid #b8e6c6; }
.flash.err { background: #fdeaea; color: #b42323; border: 1px solid #f4c2c2; }

.summary-bar { display: flex; gap: 20px; margin-bottom: 16px; }
.summary-bar span { background: #fff; padding: 8px 14px; border-radius: 8px; border: 1px solid #e5e7eb; font-size: 14px; }

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; }
.card { background: #fff; border: 1px solid #e5e7eb; border-radius: 12px; padding: 18px; }
.card-title { font-size: 14px; color: #6b7280; }
.card-stock { font-size: 34px; font-weight: 700; color: #2f7d4f; }
.card-stock small { font-size: 14px; font-weight: 400; color: #9ca3af; margin-left: 4px; }
.card-sub { font-size: 13px; color: #6b7280; margin-top: 2px; }
.card-meta { margin-top: 12px; font-size: 13px; color: #374151; line-height: 1.7; border-top: 1px solid #f0f0f0; padding-top: 10px; }

table { width: 100%; border-collapse: collapse; background: #fff; border-radius: 8px; overflow: hidden; font-size: 14px; }
th, td { padding: 9px 12px; text-align: left; border-bottom: 1px solid #eef0f2; }
th { background: #f3f5f7; color: #4b5563; font-weight: 600; }
tr.danger { background: #fdeaea; }
tr.warn { background: #fff6e5; }
.muted { color: #9ca3af; }
td.num, th.num { text-align: right; }

.form { background: #fff; border: 1px solid #e5e7eb; border-radius: 12px; padding: 20px; max-width: 460px; display: flex; flex-direction: column; gap: 14px; }
.form label { display: flex; flex-direction: column; gap: 5px; font-size: 13px; color: #4b5563; }
.form input, .form select { padding: 9px 10px; border: 1px solid #d1d5db; border-radius: 8px; font-size: 15px; }
.form button, .form-inline button { background: #2f7d4f; color: #fff; border: 0; padding: 11px; border-radius: 8px; font-size: 15px; cursor: pointer; }
.form button:hover, .form-inline button:hover { background: #276841; }
.form-inline { display: flex; gap: 12px; align-items: flex-end; margin-bottom: 14px; flex-wrap: wrap; }
.form-inline label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; }
.form-inline input { padding: 8px 10px; border: 1px solid #d1d5db; border-radius: 8px; }

.report-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 18px; }

/* 헤더 우측 (사용자/백업/로그아웃) */
.header-right { margin-left: auto; display: flex; align-items: center; gap: 14px; }
.whoami { color: #e8f5ee; font-size: 13px; }
.backup-btn { color: #fff; background: rgba(255,255,255,0.18); padding: 5px 10px; border-radius: 6px; text-decoration: none; font-size: 13px; }
.backup-btn:hover { background: rgba(255,255,255,0.32); }
.logout { color: #cfe9d8; text-decoration: none; font-size: 13px; }
.logout:hover { color: #fff; }

/* 로그인 화면 */
.login-body { display: flex; align-items: center; justify-content: center; height: 100vh; }
.login-box { background: #fff; padding: 32px; border-radius: 14px; border: 1px solid #e5e7eb; width: 320px; }
.login-brand { font-size: 20px; font-weight: 700; color: #2f7d4f; text-align: center; margin-bottom: 18px; }

/* 네이버 버튼 */
.naver-box { background: #eef6f0; border: 1px solid #cfe6d6; border-radius: 10px; padding: 14px; margin-bottom: 16px; display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.naver-box button { background: #03c75a; color: #fff; border: 0; padding: 10px 16px; border-radius: 8px; font-size: 14px; cursor: pointer; }
.naver-box button:hover { background: #02a94d; }
.naver-box button:disabled { background: #9bd9b3; cursor: default; }

/* 외부 모니터링 카드 */
.card.monitor { background: #f8fafb; border-style: dashed; }
.card.monitor .card-stock { color: #4b5563; font-size: 28px; }

/* 삭제 버튼 */
.del-btn { margin-top: 12px; background: #d64545; color: #fff; border: 0; padding: 9px 16px; border-radius: 8px; font-size: 14px; cursor: pointer; }
.del-btn:hover { background: #b83a3a; }

/* ── 고객관리 (customer-dashboard 레퍼런스 기반) ── */
main.dash { max-width: 1200px; }
.cdash {
  --c-ink:#18241D; --c-ink2:#51605A; --c-ink3:#8A968F;
  --c-line:#E9ECE7; --c-line2:#DCE0DA;
  --c-accent:#1C6B45; --c-accent-ink:#124E32; --c-accent-soft:#E9F2EC; --c-accent-soft2:#D6E7DD;
  --c-bar:#EDF1ED; --c-surface:#fff;
  --c-mono:"JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  font-family:"Pretendard Variable", Pretendard, -apple-system, "Segoe UI", "Malgun Gothic", sans-serif;
  color:var(--c-ink); letter-spacing:-.01em;
}
.cdash .masthead { margin-bottom:20px; }
.cdash .title-row { display:flex; align-items:center; gap:12px; }
.cdash .title-mark { width:34px; height:34px; border-radius:9px; background:var(--c-accent-soft); display:grid; place-items:center; flex:none; }
.cdash .title-mark svg { width:19px; height:19px; color:var(--c-accent); }
.cdash h1 { margin:0; font-size:23px; font-weight:700; letter-spacing:-.025em; color:var(--c-ink); }
.cdash .subtitle { margin:10px 0 0; font-size:13px; color:var(--c-ink2); max-width:820px; }

.cdash .toolbar { display:flex; align-items:center; justify-content:space-between; gap:12px; flex-wrap:wrap; margin-bottom:14px; }
.cdash .toolbar-left, .cdash .toolbar-right { display:flex; align-items:center; gap:10px; flex-wrap:wrap; }
.cdash .segmented { display:inline-flex; background:var(--c-surface); border:1px solid var(--c-line2); border-radius:10px; padding:3px; gap:2px; }
.cdash .segmented a { font-size:13px; font-weight:500; color:var(--c-ink2); text-decoration:none; padding:7px 13px; border-radius:7px; white-space:nowrap; }
.cdash .segmented a:hover { color:var(--c-ink); }
.cdash .segmented a.is-active { background:var(--c-accent); color:#fff; font-weight:600; box-shadow:0 1px 2px rgba(18,78,50,.25); }
.cdash .daterange { display:inline-flex; align-items:center; gap:4px; background:var(--c-surface); border:1px solid var(--c-line2); border-radius:10px; padding:4px 6px; }
.cdash .step { width:28px; height:28px; border-radius:7px; color:var(--c-ink2); font-size:18px; cursor:pointer; line-height:1; display:grid; place-items:center; text-decoration:none; }
.cdash .step:hover { background:var(--c-accent-soft); color:var(--c-accent-ink); }
.cdash .step.disabled { color:#cbd5cf; pointer-events:none; }
.cdash .daterange input[type=date] { font:inherit; font-size:13px; color:var(--c-ink); border:0; background:transparent; padding:4px 2px; font-variant-numeric:tabular-nums; width:116px; cursor:pointer; }
.cdash .daterange input[type=date]:focus { outline:0; }
.cdash .daterange input[type=date]::-webkit-calendar-picker-indicator { display:none; }
.cdash .daterange .sep { color:var(--c-ink3); font-size:13px; padding:0 2px; }
.cdash .btn-csv { display:inline-flex; align-items:center; gap:7px; font-size:13px; font-weight:600; color:var(--c-accent-ink); background:var(--c-surface); border:1px solid var(--c-line2); border-radius:10px; padding:9px 14px; cursor:pointer; text-decoration:none; }
.cdash .btn-csv:hover { background:var(--c-accent-soft); border-color:var(--c-accent-soft2); }
.cdash .btn-csv svg { width:15px; height:15px; }

.cdash .summary { font-size:13px; color:var(--c-ink2); margin-bottom:12px; display:flex; gap:8px; flex-wrap:wrap; align-items:center; }
.cdash .summary b { color:var(--c-ink); font-weight:600; font-variant-numeric:tabular-nums; }
.cdash .summary .pipe { color:var(--c-line2); }

.cdash .table-wrap { background:var(--c-surface); border:1px solid var(--c-line); border-radius:14px; overflow:auto; max-height:74vh; box-shadow:0 1px 2px rgba(24,36,29,.04), 0 10px 28px rgba(24,36,29,.045); }
.cdash table { width:100%; border-collapse:collapse; min-width:1060px; background:transparent; font-size:13.5px; border-radius:0; overflow:visible; }
.cdash thead th { position:sticky; top:0; z-index:2; background:var(--c-surface); text-align:left; font-size:12px; font-weight:600; color:var(--c-ink2); padding:13px 12px; white-space:nowrap; border-bottom:1px solid var(--c-line2); }
.cdash th.num, .cdash td.num { text-align:right; }
.cdash th.ctr, .cdash td.ctr { text-align:center; }
.cdash tbody td { padding:13px 12px; font-size:13.5px; color:var(--c-ink); border-bottom:1px solid var(--c-line); vertical-align:middle; }
.cdash tbody tr:last-child td { border-bottom:0; }
.cdash tbody tr:hover { background:#FAFBF9; }
.cdash tr.repeat td:first-child { box-shadow:inset 3px 0 0 var(--c-accent); }
.cdash .cust-name { display:inline-block; font-weight:600; color:var(--c-ink); font-size:14px; text-decoration:none; }
.cdash .cust-name:hover { color:var(--c-accent); text-decoration:underline; }
.cdash .cust-sub { margin-top:3px; font-family:var(--c-mono); font-size:11.5px; color:var(--c-ink3); white-space:nowrap; }
.cdash .cust-sub .key { color:var(--c-ink2); }
.cdash .cell-mono { font-family:var(--c-mono); font-size:12.5px; color:var(--c-ink); font-variant-numeric:tabular-nums; }
.cdash .cell-sub-mono { margin-top:3px; font-family:var(--c-mono); font-size:11.5px; color:var(--c-ink3); white-space:nowrap; }
.cdash .cell-date { font-variant-numeric:tabular-nums; font-size:13px; color:var(--c-ink); white-space:nowrap; }
.cdash .cell-date .t { color:var(--c-ink3); margin-left:7px; font-size:12.5px; }
.cdash .money { font-variant-numeric:tabular-nums; font-size:13.5px; color:var(--c-ink); white-space:nowrap; }
.cdash td.total { min-width:128px; }
.cdash .total-val { font-variant-numeric:tabular-nums; font-weight:600; font-size:14.5px; color:var(--c-ink); text-align:right; }
.cdash .bar { margin-top:8px; height:4px; border-radius:3px; background:var(--c-bar); overflow:hidden; }
.cdash .bar > span { display:block; height:100%; border-radius:3px; width:var(--w,0%); background:linear-gradient(90deg,#3FA06B,#1C6B45); }
.cdash .badge { display:inline-flex; align-items:center; justify-content:center; min-width:38px; padding:3px 9px; border-radius:999px; font-size:12px; font-weight:600; font-variant-numeric:tabular-nums; background:#F0F2EF; color:var(--c-ink2); }
.cdash .badge.hot { background:var(--c-accent-soft); color:var(--c-accent-ink); }
.cdash .dash-c { color:var(--c-ink3); }
.cdash .cycle { font-variant-numeric:tabular-nums; color:var(--c-ink); }
.cdash .cycle .u { color:var(--c-ink3); font-size:11.5px; margin-left:1px; }
.cdash td.addr { max-width:176px; }
.cdash .addr-text { font-size:12.5px; color:var(--c-ink2); line-height:1.45; display:-webkit-box; -webkit-line-clamp:2; -webkit-box-orient:vertical; overflow:hidden; }

@media (max-width:760px){
  .cdash .toolbar{flex-direction:column;align-items:stretch}
  .cdash .toolbar-left,.cdash .toolbar-right{justify-content:space-between}
  .cdash .table-wrap{max-height:none;overflow:visible;border:0;background:transparent;box-shadow:none;border-radius:0}
  .cdash table{min-width:0;width:100%}
  .cdash thead{position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0 0 0 0)}
  .cdash tbody tr{display:block;background:var(--c-surface);border:1px solid var(--c-line);border-radius:12px;margin-bottom:12px;box-shadow:0 1px 2px rgba(24,36,29,.05);overflow:hidden}
  .cdash tr.repeat td:first-child{box-shadow:none}
  .cdash tr.repeat{box-shadow:0 1px 2px rgba(24,36,29,.05),inset 3px 0 0 var(--c-accent)}
  .cdash tbody td{display:flex;justify-content:space-between;align-items:flex-start;gap:16px;padding:10px 14px;border-bottom:1px solid var(--c-line);text-align:right}
  .cdash tbody tr td:last-child{border-bottom:0}
  .cdash td::before{content:attr(data-label);font-size:12px;font-weight:600;color:var(--c-ink2);text-align:left;flex:none}
  .cdash td.num,.cdash td.ctr{text-align:right}
  .cdash td.cust,.cdash td.addr,.cdash td.total{flex-direction:column;align-items:stretch;text-align:left}
  .cdash .addr-text{-webkit-line-clamp:unset}
  .cdash td.total .total-val{text-align:left}
}

/* 고객 상세 */
.dl-btn { margin-left:auto; background:#1C6B45; color:#fff; padding:9px 16px; border-radius:9px; text-decoration:none; font-size:14px; }
.dl-btn:hover { background:#124E32; }
table.kv { max-width:560px; }
table.kv th { width:130px; background:#f3f5f7; }

.cdash .search-box { display:flex; gap:10px; margin:4px 0 18px; max-width:660px; }
.cdash .search-box input { flex:1; font:inherit; font-size:15px; padding:12px 14px; border:1px solid var(--c-line2); border-radius:11px; background:var(--c-surface); color:var(--c-ink); }
.cdash .search-box input:focus { outline:2px solid var(--c-accent); outline-offset:1px; }
.cdash .search-box button { font:inherit; font-size:14px; font-weight:600; color:#fff; background:var(--c-accent); border:0; border-radius:11px; padding:0 24px; cursor:pointer; }
.cdash .search-box button:hover { background:var(--c-accent-ink); }
.cdash tbody tr[onclick] { cursor:pointer; }
.cdash tbody tr[onclick]:hover { background:#F2F7F3; }
.cdash .go { color:var(--c-accent-ink); font-weight:600; font-size:13px; white-space:nowrap; }

/* 고객 상세 — 배송지/메모 */
.addr-list { display:flex; flex-direction:column; gap:8px; max-width:820px; margin:6px 0 8px; }
.addr-item { display:flex; gap:12px; align-items:baseline; background:#fff; border:1px solid #e5e7eb; border-radius:10px; padding:10px 14px; }
.addr-no { flex:none; font-weight:700; color:#1C6B45; font-size:13px; min-width:46px; }
.addr-body { flex:1; font-size:14px; color:#1f2937; }
.addr-meta { flex:none; font-size:12px; color:#9ca3af; white-space:nowrap; }
.memo-form { display:flex; gap:10px; max-width:820px; margin:6px 0 14px; align-items:flex-start; }
.memo-form textarea { flex:1; font:inherit; font-size:14px; padding:10px 12px; border:1px solid #d1d5db; border-radius:10px; resize:vertical; min-height:44px; }
.memo-form button { flex:none; background:#1C6B45; color:#fff; border:0; padding:11px 18px; border-radius:10px; cursor:pointer; font-size:14px; }
.memo-form button:hover { background:#124E32; }
.memo-list { display:flex; flex-direction:column; gap:10px; max-width:820px; }
.memo-item { background:#fff; border:1px solid #e5e7eb; border-radius:10px; padding:12px 14px; }
.memo-body { font-size:14px; color:#1f2937; white-space:pre-wrap; line-height:1.55; }
.memo-meta { display:flex; justify-content:space-between; align-items:center; margin-top:9px; font-size:12px; color:#9ca3af; }
.memo-del { background:transparent; border:0; color:#b42323; cursor:pointer; font-size:12px; padding:2px 4px; }
.memo-del:hover { text-decoration:underline; }

/* 고객관리내역 (메모 피드) */
.cdash .feed { display:flex; flex-direction:column; gap:10px; max-width:860px; }
.cdash .feed-item { background:var(--c-surface); border:1px solid var(--c-line); border-radius:12px; padding:14px 16px; box-shadow:0 1px 2px rgba(24,36,29,.04); }
.cdash .feed-head { display:flex; justify-content:space-between; align-items:baseline; gap:12px; margin-bottom:7px; }
.cdash .feed-cust { font-weight:600; color:var(--c-ink); text-decoration:none; font-size:14px; }
.cdash .feed-cust:hover { color:var(--c-accent); text-decoration:underline; }
.cdash .feed-time { font-size:12px; color:var(--c-ink3); font-variant-numeric:tabular-nums; white-space:nowrap; }
.cdash .feed-body { font-size:14px; color:var(--c-ink); white-space:pre-wrap; line-height:1.55; }
.cdash .feed-meta { margin-top:8px; font-size:11.5px; color:var(--c-ink3); font-family:var(--c-mono); }
.cdash .feed-meta a { color:var(--c-ink3); }

/* 고객 별칭 */
.cdash .cust-name .alias { color:var(--c-accent); font-weight:500; margin-left:1px; }
.alias-form { display:flex; gap:8px; align-items:center; margin:12px 0 4px; max-width:600px; }
.alias-label { font-weight:600; color:#4b5563; font-size:13px; white-space:nowrap; }
.alias-form input { flex:1; font:inherit; font-size:14px; padding:9px 11px; border:1px solid #d1d5db; border-radius:9px; }
.alias-form button { background:#1C6B45; color:#fff; border:0; padding:9px 18px; border-radius:9px; cursor:pointer; font-size:14px; }
.alias-form button:hover { background:#124E32; }
