:root {
  --ground: #f3f5f8; --surface: #fff; --ink: #14213d; --muted: #5b6577;
  --rule: #d5dbe5; --accent: #1f5fa8; --accent-soft: #e6eef8;
  --warn: #a4500a; --warn-soft: #fcf1e1; --ok: #1e7a4f; --ok-soft: #e3f3ea;
  --err: #b42318; --err-soft: #fde8e6; --admin: #8a5a00;
  --sans: "IBM Plex Sans KR", "Malgun Gothic", "Apple SD Gothic Neo", "Noto Sans KR", sans-serif;
  --mono: "IBM Plex Mono", Consolas, "D2Coding", monospace;
}
[hidden] { display: none !important; }
* { box-sizing: border-box; }
body { margin: 0; background: var(--ground); color: var(--ink); font: 15px/1.5 var(--sans); }
a { color: var(--accent); }
code { font-family: var(--mono); font-size: 0.9em; }
h1 { font-size: 1.5rem; margin: 0 0 0.75rem; }
h2 { font-size: 1.1rem; margin: 1rem 0 0.5rem; }
h2:first-child { margin-top: 0; }
.muted { color: var(--muted); }
.nowrap { white-space: nowrap; }

.topbar { display: flex; align-items: center; gap: 1.5rem; padding: 0.6rem 1.25rem;
  background: var(--surface); border-bottom: 1px solid var(--rule); flex-wrap: wrap; }
.brand { font-weight: 700; }
.tabs { display: flex; gap: 0.25rem; flex-wrap: wrap; }
.tabs a { padding: 0.3rem 0.6rem; border-radius: 6px; text-decoration: none; color: var(--ink); }
.tabs a:hover { background: var(--accent-soft); }
.tabs a.admin-tab { color: var(--admin); }
.user { margin-left: auto; color: var(--muted); font-size: 0.9rem; display: flex; gap: 0.5rem; align-items: center; }
form.inline { display: inline; }
button.linklike { background: none; border: 0; padding: 0; color: var(--accent); cursor: pointer; font: inherit; }

.container { max-width: 1100px; margin: 1.5rem auto; padding: 0 1rem; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.card { background: var(--surface); border: 1px solid var(--rule); border-radius: 10px; padding: 1.25rem; margin-bottom: 1rem; }
.card.narrow { max-width: 480px; margin: 2rem auto; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 1rem; }
.card.stat .label { color: var(--muted); font-size: 0.85rem; }
.card.stat .value { font-size: 1.8rem; font-weight: 700; }
.grid-2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 1rem; }
@media (max-width: 760px) { .grid-2 { grid-template-columns: minmax(0, 1fr); } }

.field { margin-bottom: 0.75rem; }
.field label { display: block; font-size: 0.85rem; color: var(--muted); margin-bottom: 0.2rem; }
.field input[type=text], .field input[type=email], .field input[type=password], .field input[type=number],
.field input[type=date], .field input[type=time], .field input[type=datetime-local], .field input[type=url],
.field select, .field textarea { width: 100%; padding: 0.45rem 0.6rem; border: 1px solid var(--rule);
  border-radius: 6px; font: inherit; background: var(--surface); color: var(--ink); }
.field textarea { font-family: var(--mono); font-size: 0.9rem; }
.field.has-error input, .field.has-error select, .field.has-error textarea { border-color: var(--err); }
.field .error { color: var(--err); font-size: 0.85rem; margin-top: 0.2rem; }
.field-check label { display: inline; }

.btn { display: inline-block; padding: 0.45rem 0.9rem; border-radius: 6px; border: 1px solid var(--rule);
  background: var(--surface); color: var(--ink); text-decoration: none; font: inherit; cursor: pointer; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }

.table { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--rule); border-radius: 10px; }
.table th, .table td { padding: 0.5rem 0.7rem; border-bottom: 1px solid var(--rule); text-align: left; vertical-align: top; }
.table th { font-size: 0.85rem; color: var(--muted); }
.table tr.inactive td { color: var(--muted); }
.table td.json { font-family: var(--mono); font-size: 0.8rem; word-break: break-all; max-width: 320px; }
.pager { display: flex; gap: 1rem; margin-top: 0.75rem; }

.flashes { margin-bottom: 1rem; }
.flash { padding: 0.6rem 0.9rem; border-radius: 6px; margin-bottom: 0.5rem; }
.flash-success { background: var(--ok-soft); color: var(--ok); }
.flash-error { background: var(--err-soft); color: var(--err); }
.flash-warn { background: var(--warn-soft); color: var(--warn); }
.flash-info, .flash-message { background: var(--accent-soft); color: var(--accent); }

/* ---- Phase 1: CRM ---- */
.hidden { display: none !important; }
.badge { display: inline-block; padding: 0.1rem 0.5rem; border-radius: 999px; font-size: 0.8rem; background: var(--accent-soft); color: var(--accent); vertical-align: middle; }
.badge.muted { background: var(--ground); color: var(--muted); }
.badge.stage-open { background: var(--accent-soft); color: var(--accent); }
.badge.stage-won { background: var(--ok-soft); color: var(--ok); }
.badge.stage-lost { background: var(--err-soft); color: var(--err); }
.btn.active { background: var(--accent-soft); border-color: var(--accent); }
.filters { display: flex; gap: 0.5rem; align-items: center; margin-bottom: 1rem; flex-wrap: wrap; }
.filters input[type=search], .filters select { padding: 0.4rem 0.6rem; border: 1px solid var(--rule); border-radius: 6px; font: inherit; }
.card.narrow-wide { max-width: 640px; }
.card.danger { border-color: var(--err-soft); }
.grid-2.tight { gap: 0 1rem; }
.dl { display: grid; grid-template-columns: max-content 1fr; gap: 0.3rem 1rem; margin: 0; }
.dl dt { color: var(--muted); font-size: 0.85rem; }
.dl dd { margin: 0; }
.pre { white-space: pre-wrap; }
.num { text-align: right; white-space: nowrap; }
.table.compact td { padding: 0.35rem 0.5rem; }
.row-form { display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; margin-bottom: 0.5rem; }
.row-form input, .row-form select { padding: 0.4rem 0.6rem; border: 1px solid var(--rule); border-radius: 6px; font: inherit; }
.row-form input[type=text] { flex: 1; min-width: 160px; }
details summary { cursor: pointer; color: var(--accent); margin: 0.5rem 0; }

.similar { background: var(--warn-soft); color: var(--warn); border-radius: 6px; padding: 0.6rem 0.9rem; margin: -0.25rem 0 0.75rem; }
.similar ul { margin: 0.3rem 0 0.5rem 1.2rem; padding: 0; }
.similar a { color: var(--warn); font-weight: 600; }

.todo { list-style: none; margin: 0 0 0.5rem; padding: 0; }
.todo li { display: flex; gap: 0.5rem; align-items: baseline; padding: 0.35rem 0; border-bottom: 1px solid var(--rule); }
.todo li:last-child { border-bottom: 0; }
.todo li.done span { text-decoration: line-through; color: var(--muted); }
.todo li.overdue .due, tr.overdue td:last-child { color: var(--err); font-weight: 600; }
.todo .due { margin-left: auto; font-size: 0.85rem; color: var(--muted); white-space: nowrap; }
button.check { background: none; border: 0; font-size: 1.1rem; cursor: pointer; padding: 0; color: var(--accent); }

.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { padding: 0.5rem 0 0.5rem 0.9rem; border-left: 3px solid var(--rule); margin-bottom: 0.4rem; }
.timeline li.tl-stage { border-left-color: var(--accent); }
.timeline li.tl-meeting, .timeline li.tl-call { border-left-color: var(--ok); }
.timeline li.tl-system { border-left-color: var(--rule); color: var(--muted); }
.tl-head { font-size: 0.85rem; display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; }
.tl-body { margin-top: 0.2rem; }

.kanban { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(240px, 1fr); gap: 0.75rem; overflow-x: auto; padding-bottom: 0.5rem; }
.kanban .col { background: var(--ground); border: 1px solid var(--rule); border-radius: 10px; padding: 0.5rem; min-height: 200px; }
.kanban .col.over { border-color: var(--accent); background: var(--accent-soft); }
.kanban .col header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.5rem; padding: 0 0.25rem; }
.kcard { background: var(--surface); border: 1px solid var(--rule); border-radius: 8px; padding: 0.6rem 0.7rem; margin-bottom: 0.5rem; cursor: grab; font-size: 0.9rem; }
.kcard.dragging { opacity: 0.5; }
.kcard a { font-weight: 600; text-decoration: none; }
.kmeta { display: flex; gap: 0.6rem; color: var(--muted); font-size: 0.8rem; margin-top: 0.3rem; }
.kcard .stale { color: var(--warn); font-size: 0.8rem; margin-top: 0.2rem; }
.closed-links { margin-top: 0.75rem; }
.card.stat .value.small { font-size: 1.2rem; }

/* ---- Phase 2: catalog & FX ---- */
.rates { display: flex; gap: 0.6rem; flex-wrap: wrap; font-size: 0.95rem; font-weight: 600; margin-top: 0.2rem; }
h3.muted { font-size: 0.85rem; margin: 0.6rem 0 0.2rem; }
.card ul { margin: 0.2rem 0 0.4rem 1.1rem; padding: 0; }

/* ---- Phase 3: quotations ---- */
.container.wide { max-width: 1400px; }
.small { font-size: 0.85rem; }
.warn { color: var(--warn); }
.badge.quote-draft { background: var(--ground); color: var(--muted); border: 1px solid var(--rule); }
.badge.quote-issued { background: var(--accent-soft); color: var(--accent); }
.badge.quote-sent, .badge.quote-accepted { background: var(--ok-soft); color: var(--ok); }
.badge.quote-lost { background: var(--err-soft); color: var(--err); }
.timeline li.tl-quote { border-left-color: var(--warn); }
.page-head .actions { display: flex; gap: 0.4rem; flex-wrap: wrap; align-items: center; }
.combo { position: relative; }
.combo.grow { flex: 1; min-width: 260px; }
.combo input { width: 100%; padding: 0.45rem 0.6rem; border: 1px solid var(--rule); border-radius: 6px; font: inherit; }
.combo-list { position: absolute; z-index: 20; left: 0; right: 0; top: 100%; margin: 2px 0 0; padding: 0; list-style: none;
  background: var(--surface); border: 1px solid var(--rule); border-radius: 6px; box-shadow: 0 4px 14px rgba(0,0,0,.12);
  max-height: 320px; overflow-y: auto; }
.combo-list li { padding: 0.4rem 0.6rem; cursor: pointer; border-bottom: 1px solid var(--rule); }
.combo-list li:hover { background: var(--accent-soft); }
.qe-tools { display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; margin-bottom: 0.5rem; }
.qe-tools select { padding: 0.45rem; border: 1px solid var(--rule); border-radius: 6px; font: inherit; }
.qe-paste textarea { width: 100%; font-family: var(--mono); padding: 0.4rem; border: 1px solid var(--rule); border-radius: 6px; margin-bottom: 0.3rem; }
.chips { display: flex; gap: 0.35rem; flex-wrap: wrap; align-items: center; margin: 0.3rem 0; }
.chips:empty { display: none; }
.chip { border: 1px solid var(--rule); background: var(--surface); border-radius: 999px; padding: 0.15rem 0.6rem; font: inherit;
  font-size: 0.85rem; cursor: pointer; color: var(--accent); }
.chip:hover { background: var(--accent-soft); }
.table-scroll { overflow-x: auto; }
.qe-items td { vertical-align: top; }
.qe-items input, .qe-items textarea { width: 100%; padding: 0.3rem 0.4rem; border: 1px solid var(--rule); border-radius: 5px; font: inherit; }
.qe-items .qe-spec { min-width: 220px; font-size: 0.85rem; }
.qe-items .qe-lead { margin-top: 0.25rem; font-size: 0.85rem; }
.qe-items .qe-qty, .qe-items .qe-disc { width: 4.5rem; }
.qe-items .qe-price { width: 8rem; text-align: right; }
.qe-items .qe-name { min-width: 160px; margin-top: 0.25rem; }
.qe-items input.invalid { border-color: var(--err); background: var(--err-soft); }
.qe-items tr.has-error td { background: #fff8f7; }
.qe-model { font-weight: 600; }
.qe-line-msg { font-size: 0.8rem; margin-top: 0.2rem; }
.qe-line-msg.error { color: var(--err); }
.qe-line-msg.warn { color: var(--warn); }
.qe-row-actions button { margin: 0 0.1rem; }
button.linklike.danger { color: var(--err); }
button.linklike:disabled { color: var(--rule); cursor: default; }
.qe-bottom { display: flex; gap: 1.5rem; justify-content: space-between; align-items: flex-start; flex-wrap: wrap; margin-top: 0.75rem; }
.qe-rates { flex: 1; min-width: 260px; }
.qe-rate { margin-bottom: 0.5rem; }
.qe-rate input { width: 8rem; padding: 0.3rem 0.4rem; border: 1px solid var(--rule); border-radius: 5px; font: inherit; }
.qe-totals { min-width: 300px; }
.qe-sum { border-collapse: collapse; width: 100%; }
.qe-sum th { text-align: left; font-weight: normal; color: var(--muted); padding: 0.2rem 0.8rem 0.2rem 0; }
.qe-sum td { padding: 0.2rem 0; }
.qe-sum tr.grand th, .qe-sum tr.grand td { font-weight: 700; color: var(--ink); font-size: 1.1rem; border-top: 1px solid var(--rule); padding-top: 0.4rem; }
.qe-margin-total { color: var(--ok); font-weight: 600; }
.qe-actions { position: sticky; bottom: 0; z-index: 10; background: var(--surface); border: 1px solid var(--rule); border-radius: 10px;
  padding: 0.75rem 1rem; display: flex; gap: 0.5rem; align-items: center; justify-content: flex-end; box-shadow: 0 -2px 10px rgba(0,0,0,.05); }
.qe-actions #qe-status { margin-right: auto; }
.qe-status-error { color: var(--err); }
.qe-status-warn { color: var(--warn); }
.qe-status-ok { color: var(--ok); }
.btn:disabled { opacity: 0.6; cursor: wait; }
.detail-grid { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 1rem; align-items: start; }
@media (max-width: 1000px) { .detail-grid { grid-template-columns: minmax(0, 1fr); } }
/* Phone width: a wide table scrolls inside its card instead of the page. */
@media (max-width: 760px) { .card > .table, main.container > .table { display: block; overflow-x: auto; } .card code { overflow-wrap: anywhere; } }
.doc-card { padding: 0.75rem; }
.doc-toolbar { display: flex; gap: 0.4rem; flex-wrap: wrap; align-items: center; margin-bottom: 0.5rem; }
.doc-toolbar .seg { display: inline-flex; gap: 0.2rem; margin-right: auto; }
.doc-frame { width: 100%; height: 1180px; border: 1px solid var(--rule); border-radius: 6px; background: #dfe3e8; }
.of-embed { margin: 0.5rem 0 1rem; } .of-frame { height: 1050px; background: #fff; }
@media (max-width: 760px) { .of-frame { height: 80vh; } }
.table.compare tr.diff-added td { background: var(--ok-soft); }
.table.compare tr.diff-removed td { background: var(--err-soft); }
.table.compare tr.diff-changed td { background: var(--warn-soft); }
.table.compare tr.diff-same td { color: var(--muted); }
.asset-row { display: flex; gap: 1rem; align-items: center; margin-bottom: 0.5rem; }
.asset-row > div:first-child { width: 90px; text-align: center; }
.asset-thumb { max-width: 80px; max-height: 60px; border: 1px solid var(--rule); border-radius: 4px; background: #fff; }

/* ---- Phase 4: mail ---- */
.ok { color: var(--ok); }
.popover { position: relative; display: inline-block; }
.popover > summary { list-style: none; }
.popover > summary::-webkit-details-marker { display: none; }
.popover[open] > summary { background: var(--accent-soft); }
.popover-body { position: absolute; right: 0; top: calc(100% + 4px); z-index: 30; width: 300px; white-space: normal; background: var(--surface);
  border: 1px solid var(--rule); border-radius: 8px; padding: 0.75rem; box-shadow: 0 6px 18px rgba(0,0,0,.14); }
.popover-body input[type=text] { width: 100%; padding: 0.4rem 0.5rem; border: 1px solid var(--rule); border-radius: 6px; font: inherit; }
.mail-grid { display: grid; grid-template-columns: minmax(0, 1fr) 420px; gap: 1rem; align-items: start; }
@media (max-width: 1000px) { .mail-grid { grid-template-columns: 1fr; } }
.mail-grid .field input[type=text] { font-family: var(--sans); }
.field textarea.prose { font-family: var(--sans); font-size: 0.95rem; line-height: 1.6; }
.mail-from { margin-bottom: 0.75rem; padding-bottom: 0.5rem; border-bottom: 1px solid var(--rule); }
.card.has-error { border-color: var(--err); }
.att-list select { padding: 0.25rem; border: 1px solid var(--rule); border-radius: 5px; font: inherit; }
.att-total { margin: 0.25rem 0 0.5rem; }
.mail-notes { margin: 0.25rem 0 0 1.1rem; padding: 0; }
.mail-send { position: sticky; bottom: 0; display: flex; gap: 0.75rem; align-items: center; background: var(--surface);
  border: 1px solid var(--rule); border-radius: 10px; padding: 0.75rem 1rem; }
.rev-links a { white-space: nowrap; }
.card ul.mail-log { list-style: none; margin: 0; padding: 0; }
.mail-log li { padding: 0.5rem 0; border-bottom: 1px solid var(--rule); }
.mail-log li:last-child { border-bottom: 0; }
.mail-log .mail-body { background: var(--ground); border-radius: 6px; padding: 0.5rem; margin: 0.3rem 0; max-height: 260px; overflow-y: auto; }
.sig-preview { background: var(--ground); border-radius: 6px; padding: 0.5rem 0.75rem; }
.timeline li.tl-email { border-left-color: var(--ok); }

/* ---- Phase 5: deal registration ---- */
.badge.dealreg-submitted { background: var(--warn-soft); color: var(--warn); }
.badge.dealreg-approved { background: var(--ok-soft); color: var(--ok); }
.badge.dealreg-rejected { background: var(--err-soft); color: var(--err); }
.badge.dealreg-expired { background: var(--ground); color: var(--muted); border: 1px solid var(--rule); }
.seg-row { display: flex; gap: 0.4rem; align-items: center; flex-wrap: wrap; margin: -0.25rem 0 0.75rem; }
.check-row { display: flex; gap: 0.4rem; align-items: baseline; padding: 0.25rem 0; color: var(--ink) !important; font-size: 0.95rem !important; }
.chip.fixed { cursor: default; color: var(--ink); background: var(--ground); }
.chip.fixed:hover { background: var(--ground); }
.card.warn-card { border-color: var(--warn); background: var(--warn-soft); }
.contact-inline { display: flex; gap: 0.4rem; flex-wrap: wrap; align-items: center; margin-top: 0.5rem; }
.contact-inline input, .contact-inline select { padding: 0.4rem 0.5rem; border: 1px solid var(--rule); border-radius: 6px; font: inherit; }
.field.emphasis textarea { border-color: var(--accent); }
.kmeta .badge { font-size: 0.72rem; }

/* Phase 6: calendar */
.cal-head { display: flex; align-items: center; gap: 0.5rem 0.75rem; flex-wrap: wrap; margin-bottom: 0.75rem; }
.cal-head h1 { margin: 0; min-width: 8.5rem; }
.cal-nav { display: inline-flex; gap: 0.2rem; }
.cal-head .actions { margin-left: auto; display: flex; gap: 0.4rem; }
.cal-filters { display: flex; gap: 0.25rem 0.8rem; align-items: center; flex-wrap: wrap; font-size: 0.9rem; }
.cal-filters select { padding: 0.35rem 0.5rem; border: 1px solid var(--rule); border-radius: 6px; font: inherit; }
.cal-kind { display: inline-flex; align-items: center; gap: 0.3rem; cursor: pointer; }
.sw { display: inline-block; width: 0.8rem; height: 0.8rem; border-radius: 3px; }
.sw-task { background: #dde3ec; border-left: 3px solid var(--muted); }
.sw-quote { background: var(--warn-soft); border: 1px solid var(--warn); }
.sw-deal { border: 1px dashed var(--ok); }
.sw-dealreg { border: 1px dashed var(--warn); }
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); background: var(--surface);
       border: 1px solid var(--rule); border-radius: 10px; }
.cal-dow { padding: 0.4rem 0.5rem; font-size: 0.8rem; color: var(--muted); border-bottom: 1px solid var(--rule); }
.cal-dow.sun, .cal-day.sun .cal-d { color: var(--err); }
.cal-dow.sat, .cal-day.sat .cal-d { color: var(--accent); }
.cal-day { min-width: 0; min-height: 118px; padding: 0.25rem 0.3rem 0.45rem; border-right: 1px solid var(--rule);
           border-bottom: 1px solid var(--rule); }
.cal-day:nth-child(7n) { border-right: 0; }
.cal-day:nth-last-child(-n+7) { border-bottom: 0; }
.cal-day:nth-last-child(7) { border-bottom-left-radius: 10px; }
.cal-day:last-child { border-bottom-right-radius: 10px; }
.cal-day.other { background: #f8f9fb; }
.cal-day.other .cal-d { opacity: 0.45; }
.cal-day.today .cal-d { background: var(--accent); color: #fff; border-radius: 999px; padding: 0 0.45rem; }
.cal-day.over { background: var(--accent-soft); outline: 2px dashed var(--accent); outline-offset: -2px; }
.cal-num { display: flex; justify-content: space-between; align-items: center; min-height: 1.4rem; font-size: 0.85rem; font-weight: 600; }
.cal-wd { display: none; }
.cal-add { visibility: hidden; border: 0; background: none; color: var(--accent); font-size: 1.1rem; line-height: 1;
           cursor: pointer; padding: 0 0.3rem; border-radius: 4px; }
.cal-day:hover .cal-add, .cal-add:focus-visible { visibility: visible; }
.cal-add:hover { background: var(--accent-soft); }
@media (hover: none) { .cal-add { visibility: visible; } }
.ev { display: block; position: relative; margin-top: 3px; font-size: 0.78rem; line-height: 1.4; border-radius: 4px; }
.ev > summary, a.ev { display: block; padding: 0.1rem 0.35rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
                      cursor: pointer; text-decoration: none; border-radius: 4px; }
.ev > summary { list-style: none; }
.ev > summary::-webkit-details-marker { display: none; }
.ev-task > summary { background: #eef1f6; color: var(--ink); border-left: 3px solid var(--muted); }
.ev-task.cat-call > summary { background: var(--ok-soft); border-left-color: var(--ok); }
.ev-task.cat-meeting > summary, .ev-task.cat-visit > summary, .ev-task.cat-demo > summary { background: var(--accent-soft); border-left-color: var(--accent); }
.ev-task.overdue > summary { border-left-color: var(--err); color: var(--err); }
.ev-task.done > summary { background: transparent; color: var(--muted); border-left-color: var(--rule); text-decoration: line-through; }
.ev-task[draggable="true"] > summary { cursor: grab; }
.ev-task.dragging { opacity: 0.4; }
.ev-task[open] > summary { box-shadow: 0 0 0 2px var(--accent); }
.ev-task summary i { font-style: normal; color: var(--muted); }
a.ev-quote { background: var(--warn-soft); color: var(--warn); }
a.ev-deal { border: 1px dashed var(--ok); color: var(--ok); }
a.ev-dealreg { border: 1px dashed var(--warn); color: var(--warn); }
.ev-body { position: absolute; z-index: 40; top: calc(100% + 4px); left: 0; width: 280px; padding: 0.7rem 0.8rem;
           background: var(--surface); border: 1px solid var(--rule); border-radius: 8px; font-size: 0.88rem;
           box-shadow: 0 8px 24px rgba(20, 33, 61, 0.16); cursor: default; }
.cal-day:nth-child(7n) .ev-body, .cal-day:nth-child(7n-1) .ev-body, .cal-day:nth-child(7n-2) .ev-body { left: auto; right: 0; }
.ev-title { font-weight: 600; margin: 0.15rem 0 0.25rem; overflow-wrap: anywhere; }
.ev-notes { background: var(--ground); border-radius: 5px; padding: 0.35rem 0.5rem; margin-top: 0.35rem; max-height: 8rem; overflow-y: auto; }
.ev-actions { display: flex; gap: 0.35rem; margin-top: 0.6rem; }
.ev-actions .btn { padding: 0.25rem 0.65rem; font-size: 0.85rem; }
.cal-foot { display: flex; gap: 0.3rem 1rem; flex-wrap: wrap; justify-content: space-between; margin-top: 0.6rem; font-size: 0.85rem; color: var(--muted); }
dialog.dialog { padding: 0; border: 1px solid var(--rule); border-radius: 12px; width: min(540px, calc(100vw - 2rem));
                box-shadow: 0 20px 50px rgba(20, 33, 61, 0.25); color: var(--ink); }
dialog.dialog > form { padding: 1.25rem; }
dialog.dialog::backdrop { background: rgba(20, 33, 61, 0.35); }
.dialog-actions { display: flex; justify-content: flex-end; gap: 0.5rem; margin-top: 0.5rem; }
@media (max-width: 760px) {
  .cal { display: block; }
  .cal-dow, .cal-day.other, .cal-day.empty:not(.today) { display: none; }
  .cal-day { display: grid; grid-template-columns: 6.5rem minmax(0, 1fr); gap: 0.5rem; min-height: 0; padding: 0.5rem; border-right: 0; }
  .cal-day:nth-last-child(-n+7) { border-bottom: 1px solid var(--rule); }
  .cal-num { align-items: flex-start; }
  .cal-d { display: none; }
  .cal-wd { display: inline; }
  .cal-day.today .cal-wd { color: var(--accent); font-weight: 700; }
  .cal-add { visibility: visible; }
  .ev-body, .cal-day:nth-child(7n) .ev-body, .cal-day:nth-child(7n-1) .ev-body, .cal-day:nth-child(7n-2) .ev-body { left: auto; right: 0; width: min(280px, 78vw); }
}
.task-quick { background: var(--surface); border: 1px solid var(--rule); border-radius: 10px; padding: 0.75rem; }
.task-quick select { max-width: 14rem; }
tr.overdue td.due { color: var(--err); font-weight: 600; }
.badge.cat-call { background: var(--ok-soft); color: var(--ok); }
.badge.cat-meeting, .badge.cat-visit, .badge.cat-demo { background: var(--accent-soft); color: var(--accent); }
.badge.cat-todo { background: var(--ground); color: var(--muted); }
.feed-url { display: flex; gap: 0.4rem; margin: 0.4rem 0; }
.feed-url input { flex: 1; min-width: 0; padding: 0.4rem 0.5rem; border: 1px solid var(--rule); border-radius: 6px; font: 0.85rem var(--mono); }

/* Phase 6: forecast and report charts */
.chart { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 0.4rem; align-items: end; height: 230px; }
.chart.short { height: 170px; margin-bottom: 0.5rem; }
.chart-col { display: flex; flex-direction: column; height: 100%; min-width: 0; border-radius: 6px; padding: 0.25rem 0.15rem 0; }
.chart-col.now { background: var(--accent-soft); }
.chart-bars { flex: 1; display: flex; align-items: flex-end; justify-content: center; gap: 3px; min-height: 0; }
.bar { width: min(26px, 40%); border-radius: 3px 3px 0 0; position: relative; display: flex; align-items: flex-end; }
.bar.won { background: var(--ok); }
.bar.open { background: #c9d9ee; }
.bar-in { width: 100%; background: var(--accent); border-radius: 3px 3px 0 0; }
.chart-val { display: flex; flex-direction: column; align-items: center; font-size: 0.72rem; line-height: 1.25; min-height: 1.9rem; margin-top: 0.2rem; }
.chart-label { text-align: center; font-size: 0.8rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chart-label b { color: var(--accent); font-weight: 600; }
.chart-legend { display: flex; gap: 0.3rem 1rem; flex-wrap: wrap; font-size: 0.8rem; color: var(--muted); margin: 0.5rem 0 0; }
.chart-legend > span { display: inline-flex; align-items: center; gap: 0.3rem; }
.sw-won { background: var(--ok); }
.sw-weighted { background: var(--accent); }
.sw-open { background: #c9d9ee; }
.hbar { position: relative; height: 0.85rem; background: var(--ground); border-radius: 4px; min-width: 80px; }
.hbar + .hbar { margin-top: 3px; }
.hbar > span { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 4px; }
.hbar-all { background: #c9d9ee; }
.hbar-w { background: var(--accent); }
.hbar-won { background: var(--ok); }
.bars-table .bar-cell { width: 55%; vertical-align: middle; }
.fc-table td { vertical-align: middle; }
.fc-in { padding: 0.25rem 0.35rem; border: 1px solid var(--rule); border-radius: 5px; font: inherit; font-size: 0.9rem; }
.fc-money { width: 9.5rem; text-align: right; }
.fc-pct { width: 4.2rem; text-align: right; }
.fc-in.late { border-color: var(--warn); color: var(--warn); }
.fc-table tr.dirty td { background: var(--warn-soft); }
.fc-save { padding: 0.25rem 0.7rem; font-size: 0.85rem; }
.fc-save:disabled { opacity: 0.35; cursor: default; }
@media (max-width: 760px) { .chart { height: 180px; } .chart-val { display: none; } }
.digest-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 660px); gap: 1rem; align-items: start; }
@media (max-width: 1100px) { .digest-grid { grid-template-columns: 1fr; } }
.digest-frame { width: 100%; height: 720px; border: 1px solid var(--rule); border-radius: 8px; background: #f3f5f8; }
.nav-menu { position: relative; }
.nav-menu > summary { list-style: none; padding: 0.3rem 0.6rem; border-radius: 6px; cursor: pointer; color: var(--admin); }
.nav-menu > summary::-webkit-details-marker { display: none; }
.nav-menu > summary::after { content: " ▾"; font-size: 0.75em; }
.nav-menu[open] > summary, .nav-menu > summary:hover { background: var(--accent-soft); }
.nav-menu-body { position: absolute; z-index: 60; top: calc(100% + 4px); left: 0; min-width: 11rem; display: flex; flex-direction: column;
                 padding: 0.3rem; background: var(--surface); border: 1px solid var(--rule); border-radius: 8px;
                 box-shadow: 0 8px 24px rgba(20, 33, 61, 0.15); }
.nav-menu-body a { white-space: nowrap; }
.tabs { align-items: center; }
.nav-menu:not([open]) > .nav-menu-body { display: none; }
.nav-menu > summary, .ev > summary { margin: 0; }

/* Phase 7: AI drafts */
.ai-panel > summary { margin: 0; color: var(--ink); }
.ai-panel textarea { width: 100%; margin: 0.6rem 0 0.4rem; padding: 0.5rem 0.6rem; border: 1px solid var(--rule); border-radius: 6px; font: inherit; }
.ai-panel #qe-ai-result > div { margin-top: 0.25rem; }
.btn.ai { border-color: #b9a6e8; color: #5b3fb0; background: #f5f1ff; }
.btn.ai:hover { background: #ece4ff; }
.ai-note { background: #f5f1ff; border: 1px solid #d9ccf6; color: #3f2d80; border-radius: 6px; padding: 0.5rem 0.75rem; margin: 0.4rem 0; font-size: 0.88rem; }
.ai-note .warn { color: var(--warn); }

/* Phase 8 */
.btn.danger-btn { border-color: var(--err); color: var(--err); }
.btn.danger-btn:hover { background: var(--err-soft); }
.popover-body input[type=text] + .btn { display: block; }

/* Phase 9: 기술지원 */
.seg-nav { display: flex; flex-wrap: wrap; gap: 0.25rem; margin: -0.25rem 0 1rem; border-bottom: 1px solid var(--rule); }
.seg-nav a { padding: 0.45rem 0.9rem; color: var(--muted); text-decoration: none; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.seg-nav a.on { color: var(--ink); border-bottom-color: var(--accent); font-weight: 600; }
.seg-radio { display: flex; flex-wrap: wrap; gap: 0.3rem; margin-bottom: 0.75rem; }
.seg-radio label { display: inline-flex; align-items: center; gap: 0.3rem; padding: 0.3rem 0.65rem; border: 1px solid var(--rule); border-radius: 999px; font-size: 0.9rem; cursor: pointer; color: var(--ink) !important; }
.seg-radio label.on, .seg-radio label:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.seg-radio input { margin: 0; }
.overdue-text, tr.late td.due { color: var(--err); font-weight: 600; }
.badge.tk-open { background: var(--warn-soft); color: var(--warn); }
.badge.tk-in_progress { background: var(--accent-soft); color: var(--accent); }
.badge.tk-waiting_customer, .badge.tk-waiting_vendor { background: var(--ground); color: var(--muted); border: 1px dashed var(--rule); }
.badge.tk-resolved, .badge.tk-closed { background: var(--ok-soft); color: var(--ok); }
.badge.pr-urgent { background: var(--err); color: #fff; }
.badge.pr-high { background: var(--err-soft); color: var(--err); }
.badge.pr-normal { background: var(--ground); color: var(--ink); border: 1px solid var(--rule); }
.badge.pr-low { background: var(--ground); color: var(--muted); }
.badge.party-customer { background: var(--warn-soft); color: var(--warn); }
.badge.party-vendor { background: #efe9fb; color: #5b3fa6; }
.badge.tl-ticket { background: var(--ground); color: var(--muted); }
.badge.insp-pass, .badge.res-ok { background: var(--ok-soft); color: var(--ok); }
.badge.insp-conditional { background: var(--warn-soft); color: var(--warn); }
.badge.insp-fail, .badge.res-ng { background: var(--err-soft); color: var(--err); }
.badge.res-na { background: var(--ground); color: var(--muted); }
.table tr.ng td { background: #fff6f5; }
ul.plain { list-style: none; margin: 0; padding: 0; }
ul.plain li { padding: 0.25rem 0; }
.checklist input[type=text] { padding: 0.3rem 0.4rem; border: 1px solid var(--rule); border-radius: 5px; font: inherit; max-width: 100%; }
.checklist td label { margin-right: 0.35rem; white-space: nowrap; }
a.ev-inspection { background: #e8f1fb; color: #1d5b95; }
.badge.vr-waiting { background: var(--warn-soft); color: var(--warn); }
.badge.vr-answered { background: var(--accent-soft); color: var(--accent); }
.badge.vr-closed { background: var(--ok-soft); color: var(--ok); }
details.inline-edit { display: inline-block; margin-left: 0.4rem; }
details.mail-log { border-top: 1px solid var(--rule); padding: 0.5rem 0; }
.badge.in-created, .badge.in-appended { background: var(--accent-soft); color: var(--accent); }
.badge.in-pending { background: var(--warn-soft); color: var(--warn); }
.badge.in-ignored { background: var(--ground); color: var(--muted); }
.badge.new-mail { background: var(--err); color: #fff; }
/* 재고 · 데모 장비 */
.badge.mv-in { background: var(--ok-soft); color: var(--ok); }
.badge.mv-out { background: var(--accent-soft); color: var(--accent); }
.badge.mv-adjust { background: var(--warn-soft); color: var(--warn); }
.badge.dm-available { background: var(--ok-soft); color: var(--ok); }
.badge.dm-on_loan { background: var(--accent-soft); color: var(--accent); }
.badge.dm-repair { background: var(--err-soft); color: var(--err); }
.badge.dm-retired { background: var(--ground); color: var(--muted); }
.overdue-text { color: var(--err); }
a.ev-demo { background: #f3ecfb; color: #5b2d91; }
a.ev-demo.overdue { background: var(--err-soft); color: var(--err); }
.badge.od-open { background: var(--warn-soft); color: var(--warn); }
.badge.od-partial { background: var(--accent-soft); color: var(--accent); }
.badge.od-delivered { background: var(--ok-soft); color: var(--ok); }
.badge.od-cancelled, .badge.iv-none { background: var(--ground); color: var(--muted); }
.badge.iv-requested { background: var(--warn-soft); color: var(--warn); }
/* 제조사 발주 */
.badge.po-draft { background: var(--ground); color: var(--muted); border: 1px solid var(--rule); }
.badge.po-sent, .badge.po-partial { background: var(--warn-soft); color: var(--warn); }
.badge.po-confirmed { background: var(--accent-soft); color: var(--accent); }
.badge.po-received { background: var(--ok-soft); color: var(--ok); }
.badge.po-cancelled { background: var(--ground); color: var(--muted); }
.badge.sh-in_transit { background: var(--accent-soft); color: var(--accent); }
.badge.sh-arrived { background: var(--warn-soft); color: var(--warn); }
.badge.sh-cleared { background: var(--accent-soft); color: var(--accent); border: 1px solid var(--accent); }
.badge.sh-received { background: var(--ok-soft); color: var(--ok); }
.badge.sh-cancelled { background: var(--ground); color: var(--muted); }
.num.minus { color: var(--err); }
/* 주문 결재 */
.badge.ap-pending_lead, .badge.ap-pending_exec { background: var(--warn-soft); color: var(--warn); }
.badge.ap-approved { background: var(--ok-soft); color: var(--ok); }
.badge.ap-rejected { background: var(--err-soft); color: var(--err); }
.card.attention { border-left: 4px solid var(--warn); }
.approval-line { display: flex; flex-wrap: wrap; align-items: stretch; gap: .5rem; margin: .5rem 0 1rem; padding: 0; list-style: none; }
.approval-line li { flex: 1 1 9rem; border: 1px solid var(--rule); border-radius: 10px; padding: .55rem .75rem; background: var(--surface); min-width: 0; }
.approval-line li .who { font-weight: 600; }
.approval-line li .when { font-size: .8rem; color: var(--muted); }
.approval-line li.done { border-color: var(--ok); background: var(--ok-soft); }
.approval-line li.now { border-color: var(--warn); background: var(--warn-soft); }
.approval-line li.no { border-color: var(--err); background: var(--err-soft); }
.approval-line li.skip { opacity: .6; }
.file-list { list-style: none; padding: 0; margin: .25rem 0 .75rem; }
.file-list li { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; padding: .2rem 0; }
.badge.iv-issued { background: var(--ok-soft); color: var(--ok); }
.badge.pay-open { background: var(--warn-soft); color: var(--warn); }
.badge.pay-late { background: var(--err-soft); color: var(--err); }
.badge.pay-done { background: var(--ok-soft); color: var(--ok); }
/* 견적 사양 서식 편집기 */
.qe-items .rte { min-height: 2.6em; padding: 0.3rem 0.45rem; border: 1px solid var(--rule); border-radius: 6px; background: var(--surface);
  white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.4; }
.qe-items .rte:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
.qe-items .rte:empty::before { content: attr(data-placeholder); color: var(--muted); }
.qe-items .rte div, .qe-items .rte p { margin: 0; }
.rte-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 0.2rem; margin-bottom: 0.25rem; }
.rte-btn { min-width: 1.9rem; padding: 0.1rem 0.35rem; border: 1px solid var(--rule); border-radius: 4px; background: var(--surface); cursor: pointer; font-size: 0.8rem; }
.rte-btn:hover { background: var(--accent-soft); }
.rte-colors { display: inline-flex; gap: 2px; }
.rte-color { width: 1.1rem; height: 1.1rem; border: 1px solid var(--rule); border-radius: 3px; cursor: pointer; padding: 0; }
.rte-sel { font-size: 0.8rem; padding: 0.1rem; max-width: 7rem; }

/* 제품 단계 선택기 (_product_picker.html · product_picker.js) */
.pp.ready .pp-source { display: none; }
.pp-search { position: relative; margin-bottom: 0.5rem; }
.pp-q { width: 100%; padding: 0.45rem 0.6rem; border: 1px solid var(--rule); border-radius: 6px; font: inherit;
  background: var(--surface); color: var(--ink); }
.pp-hits { position: absolute; z-index: 20; left: 0; right: 0; top: calc(100% + 2px); max-height: 18rem; overflow-y: auto;
  background: var(--surface); border: 1px solid var(--rule); border-radius: 6px; box-shadow: 0 6px 18px rgba(20, 33, 61, 0.12); }
.pp-hit { display: block; width: 100%; text-align: left; padding: 0.45rem 0.6rem; border: 0; border-bottom: 1px solid var(--rule);
  background: none; color: var(--ink); font: inherit; font-size: 0.9rem; cursor: pointer; }
.pp-hit:hover, .pp-hit:focus { background: var(--accent-soft); outline: none; }
.pp-hit strong { margin-right: 0.3rem; }
.pp-none { padding: 0.45rem 0.6rem; font-size: 0.9rem; }
.pp-steps { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.4rem 0.6rem; }
.pp-cap { display: block; font-size: 0.78rem; color: var(--muted); margin-bottom: 0.1rem; }
.pp-step select:disabled { color: var(--muted); background: var(--ground); }
.pp-tools { margin-top: 0.3rem; }
.pp-tools label.pp-instock { display: inline; font-size: 0.85rem; color: var(--ink); }
.pp-chosen { margin-top: 0.4rem; padding: 0.4rem 0.6rem; border-radius: 6px; background: var(--accent-soft); }
.pp-chosen.muted { background: var(--ground); }
