/*
 * 업무 데스크 — 글로벌 SaaS·핀테크 대시보드 톤
 * 전체 높이 사이드바 + 얇은 상단 바, 헤어라인 테두리, 단일 강조색(딥 블루),
 * 날짜·D-day는 고정폭 글꼴로 금융 단말처럼 정렬
 */
:root {
  --bg: #fbfbfc;
  --surface: #ffffff;
  --sidebar: #f6f7f9;
  --surface-2: #f2f3f6;
  --hover: #eceef2;
  --line: #e7e9ee;
  --line-strong: #d6dae2;
  --text: #15171c;
  --text-2: #4b5161;
  --text-3: #8b91a0;
  --primary: #3e63dd;
  --primary-soft: #edf1fd;
  --primary-text: #ffffff;
  --danger: #d93f3f;
  --danger-soft: #fdeeee;
  --warn: #b25e09;
  --warn-soft: #fdf3e5;
  --ok: #18825a;
  --ok-soft: #e6f5ee;
  --holiday: #d93f3f;
  --shadow: 0 1px 2px rgba(16, 20, 32, .04);
  --shadow-lg: 0 16px 48px rgba(16, 20, 32, .16), 0 2px 6px rgba(16, 20, 32, .06);
  --radius: 10px;
  --radius-sm: 6px;
  --font: "IBM Plex Sans KR", "Pretendard", "Apple SD Gothic Neo", "Malgun Gothic", "맑은 고딕", system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  --side-w: 248px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #111215;
    --surface: #17181c;
    --sidebar: #0d0e11;
    --surface-2: #1d1f24;
    --hover: #23252b;
    --line: #26282e;
    --line-strong: #353840;
    --text: #eceef2;
    --text-2: #a9aeba;
    --text-3: #6f7482;
    --primary: #7d95f2;
    --primary-soft: #1d2340;
    --primary-text: #0d1022;
    --danger: #f2726f;
    --danger-soft: #35191b;
    --warn: #eeaa55;
    --warn-soft: #33250f;
    --ok: #4cc993;
    --ok-soft: #102b21;
    --holiday: #f2726f;
    --shadow: none;
    --shadow-lg: 0 16px 48px rgba(0, 0, 0, .6);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #111215;
  --surface: #17181c;
  --sidebar: #0d0e11;
  --surface-2: #1d1f24;
  --hover: #23252b;
  --line: #26282e;
  --line-strong: #353840;
  --text: #eceef2;
  --text-2: #a9aeba;
  --text-3: #6f7482;
  --primary: #7d95f2;
  --primary-soft: #1d2340;
  --primary-text: #0d1022;
  --danger: #f2726f;
  --danger-soft: #35191b;
  --warn: #eeaa55;
  --warn-soft: #33250f;
  --ok: #4cc993;
  --ok-soft: #102b21;
  --holiday: #f2726f;
  --shadow: none;
  --shadow-lg: 0 16px 48px rgba(0, 0, 0, .6);
  color-scheme: dark;
}

/* ===== 기본 ===== */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 13.5px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
h1, h2, h3 { margin: 0; letter-spacing: -0.015em; text-wrap: balance; }
code { font-family: var(--mono); font-size: .92em; }
kbd {
  display: inline-grid; place-items: center; min-width: 18px; height: 18px; padding: 0 4px;
  border: 1px solid var(--line-strong); border-radius: 4px;
  font-family: var(--mono); font-size: 10.5px; color: var(--text-3); background: var(--surface);
}
.num { font-variant-numeric: tabular-nums; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* ===== 앱 골격 ===== */
.app { display: grid; grid-template-columns: var(--side-w) minmax(0, 1fr); min-height: 100vh; }
.main { min-width: 0; display: flex; flex-direction: column; }

/* ===== 사이드바 ===== */
.sidebar {
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; gap: 12px;
  padding: 14px 12px 12px;
  background: var(--sidebar);
  border-right: 1px solid var(--line);
}
.side-top { display: flex; align-items: center; gap: 4px; }
.brand { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; padding: 4px 6px; border-radius: var(--radius-sm); }
.brand:hover { background: var(--hover); }
.brand-mark {
  display: grid; place-items: center; flex: none;
  width: 28px; height: 28px; border-radius: 7px;
  background: var(--primary); color: var(--primary-text);
}
.brand-mark svg { width: 18px; height: 18px; stroke-width: 3; }
.brand-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.brand-name { font-weight: 700; font-size: 14px; }
.brand-sub { font-size: 11.5px; color: var(--text-3); }
.new-task {
  display: flex; align-items: center; gap: 8px;
  height: 34px; padding: 0 10px;
  border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text);
  font-weight: 600; cursor: pointer; box-shadow: var(--shadow);
}
.new-task:hover { border-color: var(--primary); color: var(--primary); }
.new-task kbd { margin-left: auto; }
.side-nav { flex: 1; overflow-y: auto; margin: 0 -4px; padding: 0 4px; }
.nav-group + .nav-group { margin-top: 18px; }
.nav-label {
  display: flex; align-items: center; justify-content: space-between;
  height: 24px; padding: 0 8px 2px;
  font-size: 11px; font-weight: 600; color: var(--text-3); letter-spacing: .06em; text-transform: uppercase;
}
.nav-label-btn { display: grid; place-items: center; width: 22px; height: 22px; border: 0; border-radius: 5px; background: transparent; color: var(--text-3); cursor: pointer; }
.nav-label-btn:hover { background: var(--hover); color: var(--text); }
.nav-label-btn svg { width: 14px; height: 14px; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  height: 32px; padding: 0 8px; border-radius: var(--radius-sm);
  color: var(--text-2); font-weight: 500;
}
.nav-item:hover { background: var(--hover); color: var(--text); }
.nav-item.active { background: var(--hover); color: var(--text); font-weight: 600; }
.nav-item.active svg { color: var(--primary); }
.nav-item .count { margin-left: auto; font-family: var(--mono); font-size: 11.5px; color: var(--text-3); }
.nav-item .label, .cat-txt .label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.cat-dot { width: 8px; height: 8px; border-radius: 2px; flex: none; }
.cat-item {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 8px; border-radius: var(--radius-sm); color: var(--text-2);
}
.cat-item + .cat-item { margin-top: 1px; }
.cat-item:hover { background: var(--hover); color: var(--text); }
.cat-item.active { background: var(--hover); color: var(--text); }
.cat-ic {
  display: grid; place-items: center; flex: none;
  width: 24px; height: 24px; border-radius: 6px;
  background: color-mix(in srgb, var(--c) 14%, transparent);
  color: color-mix(in srgb, var(--c) 78%, var(--text));
  font-weight: 700; font-size: 11.5px;
}
.cat-item.active .cat-ic { background: var(--c); color: #fff; }
.cat-txt { display: flex; flex-direction: column; flex: 1; min-width: 0; line-height: 1.3; }
.cat-txt .label { font-weight: 500; }
.cat-item.active .cat-txt .label { font-weight: 600; }
.cat-sub { font-size: 11px; color: var(--text-3); font-family: var(--mono); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pill-od { flex: none; padding: 0 6px; height: 18px; display: inline-grid; place-items: center; border-radius: 4px; background: var(--danger-soft); color: var(--danger); font-size: 10.5px; font-weight: 700; white-space: nowrap; }

/* 장 상태 (사이드바 하단) */
.market {
  padding: 10px 12px; border-radius: var(--radius-sm);
  border: 1px solid var(--line); background: var(--surface);
}
.market .m-row { display: flex; align-items: center; gap: 8px; }
.market b { font-weight: 600; font-size: 12.5px; }
.market .m-time { margin-left: auto; font-family: var(--mono); font-size: 12px; color: var(--text-2); }
.market .m-sub { margin-top: 2px; padding-left: 16px; font-size: 11px; color: var(--text-3); }
.market .pulse { width: 8px; height: 8px; border-radius: 50%; background: var(--text-3); flex: none; }
.market.open .pulse { background: var(--ok); box-shadow: 0 0 0 3px var(--ok-soft); animation: pulse 2s ease-in-out infinite; }
.market.closed-day .pulse { background: var(--holiday); }
@keyframes pulse { 50% { box-shadow: 0 0 0 5px transparent; } }

/* ===== 상단 바 ===== */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 8px;
  height: 52px; padding: 0 28px;
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: saturate(1.4) blur(10px);
  -webkit-backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--line);
}
.crumb { display: flex; align-items: center; gap: 8px; min-width: 0; font-size: 13px; color: var(--text-3); white-space: nowrap; }
.crumb b { color: var(--text); font-weight: 600; overflow: hidden; text-overflow: ellipsis; }
.crumb .sep { color: var(--line-strong); }
.topbar-spacer { flex: 1; }
.search {
  display: flex; align-items: center; gap: 8px;
  width: 280px; height: 32px; padding: 0 8px 0 10px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm);
  color: var(--text-3);
}
.search:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.search:focus-within kbd { display: none; }
.search input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; color: var(--text); font-size: 13px; }

/* ===== 버튼 ===== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 32px; padding: 0 12px;
  border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text);
  font-weight: 500; font-size: 13px; cursor: pointer; white-space: nowrap;
  box-shadow: var(--shadow);
}
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--primary-text); font-weight: 600; }
.btn.primary:hover { filter: brightness(1.07); }
.btn.danger { color: var(--danger); }
.btn.ghost { border-color: transparent; background: transparent; box-shadow: none; }
.btn.ghost:hover { background: var(--hover); }
.btn.sm { height: 28px; padding: 0 10px; font-size: 12.5px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.icon-btn {
  position: relative; display: grid; place-items: center;
  width: 32px; height: 32px; border-radius: var(--radius-sm);
  border: 0; background: transparent; color: var(--text-2); cursor: pointer;
}
.icon-btn:hover { background: var(--hover); color: var(--text); }
.icon-btn .dot { position: absolute; top: 6px; right: 6px; width: 7px; height: 7px; border-radius: 50%; background: var(--danger); box-shadow: 0 0 0 2px var(--bg); }

/* ===== 본문 ===== */
.content { width: 100%; max-width: 1280px; margin: 0 auto; padding: 28px 28px 72px; outline: none; }
.page-head { display: flex; align-items: flex-end; flex-wrap: wrap; gap: 12px 16px; margin-bottom: 22px; }
.page-head h1 { font-size: 22px; font-weight: 700; }
.page-head .sub { color: var(--text-2); margin-top: 4px; }
.page-head .actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.card-head { display: flex; align-items: center; gap: 8px; padding: 14px 16px 8px; }
.card-head h3 { font-size: 14px; font-weight: 600; }
.card-head .more { margin-left: auto; font-size: 12px; color: var(--text-3); }
.card-body { padding: 0 16px 14px; }

/* 요약 지표: 한 줄 스트립 */
.stats {
  display: grid; grid-template-columns: repeat(5, minmax(0, 1fr));
  margin-bottom: 28px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden;
}
.stats .card { border: 0; border-radius: 0; background: transparent; }
.stats .stat + .stat { border-left: 1px solid var(--line); }
.stat { padding: 14px 18px 16px; }
.stat .k { font-size: 12px; color: var(--text-2); font-weight: 500; display: flex; align-items: center; gap: 6px; }
.stat .k::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--line-strong); }
.stat.warn .k::before { background: var(--warn); }
.stat.danger .k::before { background: var(--danger); }
.stat .v { margin-top: 6px; font-size: 28px; font-weight: 600; line-height: 1.1; font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
.stat .v small { font-size: 12.5px; font-weight: 500; color: var(--text-3); margin-left: 3px; letter-spacing: 0; }
.stat.danger .v { color: var(--danger); }
.stat.clickable { cursor: pointer; transition: background .15s; }
.stat.clickable:hover { background: var(--surface-2); }

/* 카테고리 개요 */
.section-title { font-size: 14px; font-weight: 600; margin: 0 0 12px; display: flex; align-items: center; gap: 8px; }
.cat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; margin-bottom: 28px; }
.cat-tile { display: flex; flex-direction: column; padding: 16px; cursor: pointer; transition: border-color .15s, box-shadow .15s; }
.cat-tile:hover { border-color: var(--line-strong); box-shadow: 0 4px 16px rgba(16, 20, 32, .06); }
.cat-tile .name { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 14px; }
.cat-tile .desc { margin-top: 4px; color: var(--text-3); font-size: 12px; line-height: 1.5; min-height: 36px; }
.cat-tile .nums { display: flex; gap: 16px; margin-top: 14px; font-size: 11.5px; color: var(--text-3); }
.cat-tile .nums span { display: flex; flex-direction: column; }
.cat-tile .nums b { order: -1; font-size: 20px; font-weight: 600; color: var(--text); font-variant-numeric: tabular-nums; line-height: 1.2; }
.cat-tile .nums .od b { color: var(--danger); }
.cat-tile .next { margin-top: auto; padding-top: 12px; font-size: 12px; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cat-tile .next b { font-family: var(--mono); font-weight: 500; color: var(--text); }
.bar { height: 3px; border-radius: 3px; background: var(--surface-2); margin-top: 12px; overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--c); border-radius: 3px; }

.dash-cols { display: grid; grid-template-columns: minmax(0, 1.75fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.stack { display: grid; gap: 16px; min-width: 0; }

/* ===== 업무 행 ===== */
.task-list { display: flex; flex-direction: column; }
.task-row {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 12px;
  margin: 0 -8px; padding: 9px 8px; border-radius: var(--radius-sm);
  cursor: pointer;
}
.task-row + .task-row { box-shadow: 0 -1px 0 var(--line); }
.task-row:hover { background: var(--surface-2); box-shadow: none; }
.task-row:hover + .task-row { box-shadow: none; }
.check {
  width: 18px; height: 18px; border-radius: 50%;
  border: 1.5px solid var(--line-strong); background: var(--surface);
  display: grid; place-items: center; cursor: pointer; padding: 0;
  transition: border-color .15s, background .15s;
}
.check:hover { border-color: var(--ok); }
.check svg { width: 11px; height: 11px; stroke-width: 3.2; color: transparent; }
.check:hover svg { color: var(--ok); }
.task-row.done .check, .kcard.done .check { background: var(--ok); border-color: var(--ok); }
.task-row.done .check svg, .kcard.done .check svg { color: #fff; }
.task-row.done .t-title { text-decoration: line-through; color: var(--text-3); }
.t-title { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.t-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; margin-top: 3px; font-size: 12px; color: var(--text-3); }
.t-meta .ref { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 280px; }
.cat-tag { display: inline-flex; align-items: center; gap: 6px; color: var(--text-2); }
.due { font-family: var(--mono); font-size: 12px; font-weight: 500; color: var(--text-2); white-space: nowrap; text-align: right; }
.due.overdue { color: var(--danger); }
.due.today { color: var(--warn); }
.due small { display: block; font-weight: 400; color: var(--text-3); font-size: 11px; }

.badge {
  display: inline-flex; align-items: center; gap: 4px; height: 20px; padding: 0 7px;
  border-radius: 4px; font-size: 11px; font-weight: 600; white-space: nowrap;
  border: 1px solid transparent;
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.rec::before, .badge.p-high::before { display: none; }
.badge.p-high { background: var(--danger-soft); color: var(--danger); }
.badge.s-todo { border-color: var(--line); color: var(--text-2); }
.badge.s-todo::before { background: var(--text-3); }
.badge.s-doing { background: var(--primary-soft); color: var(--primary); }
.badge.s-review { background: var(--warn-soft); color: var(--warn); }
.badge.s-done { background: var(--ok-soft); color: var(--ok); }
.badge.rec { border-color: var(--line); color: var(--text-2); font-weight: 500; }

.empty { padding: 28px 12px; text-align: center; color: var(--text-3); font-size: 13px; }

/* ===== 증시 정보 ===== */
.kv { display: grid; grid-template-columns: auto 1fr; gap: 9px 12px; margin: 0; font-size: 13px; }
.kv dt { color: var(--text-3); }
.kv dd { margin: 0; font-weight: 500; text-align: right; font-family: var(--mono); font-size: 12.5px; }
.hol-list { list-style: none; margin: 14px 0 0; padding: 12px 0 0; border-top: 1px solid var(--line); display: grid; gap: 7px; font-size: 13px; }
.hol-list li { display: flex; justify-content: space-between; gap: 8px; }
.hol-list .d { color: var(--holiday); font-family: var(--mono); font-size: 12px; }
.notice { padding: 10px 12px; border-radius: var(--radius-sm); background: var(--warn-soft); color: var(--warn); font-size: 12.5px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.notice.ok { background: var(--ok-soft); color: var(--ok); }
.notice span { flex: 1; min-width: 160px; }
.hint { margin: 0; font-size: 12px; color: var(--text-3); font-weight: 400; line-height: 1.55; }
.hint.warn { color: var(--warn); background: var(--warn-soft); padding: 8px 10px; border-radius: var(--radius-sm); display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* ===== 필터 (세그먼트 탭) ===== */
.filters { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 16px; }
.filter {
  display: inline-flex; align-items: center; gap: 6px;
  height: 28px; padding: 0 10px; border-radius: var(--radius-sm);
  border: 1px solid transparent; background: transparent;
  font-size: 12.5px; font-weight: 500; color: var(--text-2); cursor: pointer;
}
.filter:hover { background: var(--hover); color: var(--text); }
.filter.active { background: var(--surface); border-color: var(--line-strong); color: var(--text); font-weight: 600; box-shadow: var(--shadow); }
.filter .num { font-family: var(--mono); font-size: 11px; color: var(--text-3); }

/* ===== 칸반 ===== */
.board { display: grid; grid-template-columns: repeat(4, minmax(250px, 1fr)); gap: 12px; overflow-x: auto; padding-bottom: 8px; }
.col { border-radius: var(--radius); padding: 4px; min-height: 320px; display: flex; flex-direction: column; gap: 8px; background: var(--surface-2); border: 1px solid transparent; transition: background .15s, border-color .15s; }
.col.drop { border-color: var(--primary); background: var(--primary-soft); }
.col-head { display: flex; align-items: center; gap: 8px; padding: 8px 8px 4px; font-weight: 600; }
.col-head .n { font-family: var(--mono); font-size: 12px; color: var(--text-3); font-weight: 500; }
.kcard { padding: 12px; cursor: grab; box-shadow: var(--shadow); transition: border-color .15s; }
.kcard:hover { border-color: var(--line-strong); }
.kcard:active { cursor: grabbing; }
.kcard.dragging { opacity: .5; }
.kcard .top { display: flex; gap: 10px; align-items: flex-start; }
.kcard .top .check { margin-top: 1px; }
.kcard .t-title { white-space: normal; flex: 1; line-height: 1.45; }
.kcard .row2 { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-top: 10px; font-size: 12px; color: var(--text-3); }
.kcard .row2 .due { margin-left: auto; }
.kcard .move { display: flex; gap: 4px; margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line); }
.kcard .move .btn { height: 24px; padding: 0 8px; font-size: 11.5px; box-shadow: none; }
.kcard.done .t-title { color: var(--text-3); text-decoration: line-through; }
.col .empty { padding: 20px 8px; font-size: 12px; }

/* ===== 캘린더 ===== */
.cal-nav { display: flex; align-items: center; gap: 4px; }
.cal-nav .month { font-size: 15px; font-weight: 600; min-width: 116px; text-align: center; font-variant-numeric: tabular-nums; }
.cal { overflow: hidden; }
.cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.cal-dow { padding: 8px; font-size: 11px; font-weight: 600; color: var(--text-3); text-align: left; border-bottom: 1px solid var(--line); letter-spacing: .04em; }
.cal-dow.sun { color: var(--holiday); }
.cal-cell { min-height: 116px; padding: 6px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); cursor: pointer; display: flex; flex-direction: column; gap: 3px; min-width: 0; transition: background .1s; }
.cal-cell:nth-child(7n) { border-right: 0; }
.cal-cell:hover { background: var(--surface-2); }
.cal-cell.other { background: var(--sidebar); }
.cal-cell.other .dnum { opacity: .4; }
.cal-cell.off:not(.other) { background: color-mix(in srgb, var(--surface-2) 55%, var(--surface)); }
.cal-cell .dhead { display: flex; align-items: center; gap: 6px; min-width: 0; margin-bottom: 2px; }
.cal-cell .dnum { font-family: var(--mono); font-size: 12px; font-weight: 500; width: 24px; height: 24px; display: grid; place-items: center; border-radius: 6px; flex: none; color: var(--text-2); }
.cal-cell.sun .dnum, .cal-cell.hol .dnum { color: var(--holiday); }
.cal-cell.today .dnum { background: var(--primary); color: var(--primary-text); font-weight: 600; }
.cal-cell .hname { font-size: 10.5px; color: var(--holiday); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip {
  display: block; padding: 2px 6px; border-radius: 4px;
  font-size: 11.5px; font-weight: 500; line-height: 1.5;
  background: var(--surface); border: 1px solid var(--line); color: var(--text);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.chip::before { content: ""; display: inline-block; width: 6px; height: 6px; margin: 0 5px 1px 0; border-radius: 2px; background: var(--c); vertical-align: middle; }
.chip:hover { border-color: var(--line-strong); }
.chip.done { opacity: .5; text-decoration: line-through; }
.chip-more { font-size: 11px; color: var(--text-3); padding-left: 6px; }

/* ===== 카테고리 페이지 ===== */
.cat-hero { display: flex; gap: 16px; align-items: flex-start; padding: 0 0 20px; margin-bottom: 18px; border: 0; border-bottom: 1px solid var(--line); border-radius: 0; background: transparent; }
.cat-hero .icon { width: 44px; height: 44px; border-radius: 10px; display: grid; place-items: center; background: var(--c); color: #fff; font-weight: 700; font-size: 17px; flex: none; }
.cat-hero h1 { font-size: 22px; font-weight: 700; }
.cat-hero p { margin: 4px 0 0; color: var(--text-2); }
.quick { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 14px; align-items: center; }
.quick .btn { height: 28px; font-size: 12px; font-weight: 500; color: var(--text-2); border-style: dashed; box-shadow: none; }
.quick .btn:hover { color: var(--primary); border-color: var(--primary); background: var(--primary-soft); }
.group-title { font-size: 11px; font-weight: 600; color: var(--text-3); margin: 16px 0 4px; display: flex; gap: 6px; align-items: center; letter-spacing: .06em; text-transform: uppercase; }
.group-title.danger { color: var(--danger); }

/* ===== 모달 ===== */
.modal {
  width: min(560px, calc(100vw - 24px)); max-height: calc(100vh - 32px);
  padding: 0; border: 1px solid var(--line); border-radius: 12px;
  background: var(--surface); color: var(--text); box-shadow: var(--shadow-lg);
}
.modal[open] { animation: pop .16s ease-out; }
@keyframes pop { from { transform: translateY(6px) scale(.985); opacity: 0; } }
#confirmDialog { width: min(400px, calc(100vw - 24px)); }
#confirmDialog p { margin: 4px 0; font-size: 14px; font-weight: 500; line-height: 1.6; }
.modal.wide { width: min(720px, calc(100vw - 24px)); }
.modal::backdrop { background: rgba(10, 12, 18, .4); backdrop-filter: blur(2px); }
.modal form { display: flex; flex-direction: column; max-height: calc(100vh - 34px); }
.modal-head { display: flex; align-items: center; padding: 14px 16px 14px 20px; border-bottom: 1px solid var(--line); }
.modal-head h2 { font-size: 15px; font-weight: 600; flex: 1; }
.modal-body { padding: 18px 20px; overflow-y: auto; display: grid; gap: 16px; }
.modal.wide[open] { display: flex; flex-direction: column; }
.modal.wide .modal-body { flex: 1; min-height: 0; }
.modal-foot { display: flex; gap: 8px; padding: 12px 20px; border-top: 1px solid var(--line); background: var(--sidebar); border-radius: 0 0 12px 12px; }
.spacer { flex: 1; }
.field { display: grid; gap: 6px; min-width: 0; }
.field > span { font-size: 12px; font-weight: 600; color: var(--text-2); }
.field > span em { font-style: normal; font-weight: 400; color: var(--text-3); }
.field input:not([type=radio]):not([type=checkbox]), .field select, .field textarea, .input {
  width: 100%; min-height: 36px; padding: 7px 10px;
  border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  background: var(--surface); outline: none; font-size: 13.5px;
}
.field input[name=title] { font-size: 15px; font-weight: 500; min-height: 40px; }
.field textarea { resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus, .input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.segmented { display: inline-flex; padding: 2px; gap: 2px; background: var(--surface-2); border-radius: var(--radius-sm); width: max-content; }
.segmented label { cursor: pointer; }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented span { display: block; padding: 5px 14px; border-radius: 5px; font-size: 12.5px; font-weight: 500; color: var(--text-2); }
.segmented input:checked + span { background: var(--surface); color: var(--text); font-weight: 600; box-shadow: 0 1px 2px rgba(16, 20, 32, .1), 0 0 0 1px var(--line); }
.segmented input:focus-visible + span { outline: 2px solid var(--primary); outline-offset: -2px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips label { cursor: pointer; }
.chips input { position: absolute; opacity: 0; pointer-events: none; }
.chips span { display: inline-flex; align-items: center; height: 28px; padding: 0 10px; border-radius: var(--radius-sm); border: 1px solid var(--line-strong); font-size: 12.5px; font-weight: 500; color: var(--text-2); }
.chips input:checked + span { background: var(--primary-soft); border-color: var(--primary); color: var(--primary); font-weight: 600; }
.chips input:focus-visible + span { outline: 2px solid var(--primary); outline-offset: 2px; }
.templates { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; padding: 10px; border-radius: var(--radius-sm); background: var(--sidebar); border: 1px solid var(--line); }
.templates:empty { display: none; }
.templates .lbl { font-size: 11px; font-weight: 600; color: var(--text-3); margin-right: 4px; letter-spacing: .06em; }
.templates .btn { height: 24px; padding: 0 8px; font-size: 11.5px; font-weight: 500; box-shadow: none; }
.templates .hint { font-size: 11.5px; }
.tpl-tools { display: flex; gap: 2px; margin-left: auto; }
.templates .tpl-tools .btn { color: var(--primary); font-weight: 600; }
.templates .tpl-tools .btn + .btn { color: var(--text-3); font-weight: 500; }
.tpl-group { display: grid; gap: 6px; }
.tpl-group + .tpl-group { margin-top: 6px; }
.tpl-cat { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.tpl-cat .num { font-family: var(--mono); font-size: 11px; color: var(--text-3); }
.tpl-cat .btn { margin-left: auto; color: var(--primary); }
.tpl-row { display: grid; grid-template-columns: minmax(0, 1fr) 150px auto; gap: 6px; align-items: center; }
.tpl-row .input { min-height: 32px; padding: 5px 9px; font-size: 13px; }
.tpl-empty { padding-left: 16px; }
.quick .hint { margin-right: 2px; }

/* 설정 */
.set-sec { display: grid; gap: 10px; padding-bottom: 18px; border-bottom: 1px solid var(--line); }
.set-sec:last-child { border-bottom: 0; padding-bottom: 0; }
.set-sec h3 { font-size: 13.5px; font-weight: 600; }
.set-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.cat-edit { display: grid; grid-template-columns: 36px minmax(0, 1fr) minmax(0, 1.6fr) auto; gap: 8px; align-items: center; }
.cat-edit input[type=color] { width: 36px; height: 36px; padding: 3px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); background: var(--surface); cursor: pointer; }
.switch { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-weight: 500; }
.switch input { width: 16px; height: 16px; accent-color: var(--primary); }

/* ===== 토스트 ===== */
.toasts { position: fixed; right: 20px; bottom: 20px; z-index: 100; display: grid; gap: 8px; width: min(370px, calc(100vw - 32px)); }
.toast {
  display: grid; grid-template-columns: auto 1fr auto; gap: 10px; align-items: start;
  padding: 12px 12px 12px 14px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--line);
  box-shadow: var(--shadow-lg);
  animation: slide .22s ease-out;
}
.toast .ic { display: grid; place-items: center; width: 22px; height: 22px; border-radius: 6px; background: color-mix(in srgb, var(--c, var(--primary)) 14%, transparent); color: var(--c, var(--primary)); }
.toast .ic svg { width: 13px; height: 13px; }
.toast .tt { font-weight: 600; }
.toast .tb { font-size: 12.5px; color: var(--text-2); margin-top: 2px; }
.toast .ta { display: flex; gap: 6px; margin-top: 10px; flex-wrap: wrap; }
.toast .ta .btn { height: 26px; padding: 0 10px; font-size: 12px; }
@keyframes slide { from { transform: translateY(10px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ===== 반응형 ===== */
@media (max-width: 1180px) {
  .stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .stats .stat:nth-child(4) { border-left: 0; }
  .stats .stat:nth-child(n+4) { border-top: 1px solid var(--line); }
  .stats .stat:nth-child(5) { grid-column: span 2; }
  .dash-cols { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 960px) {
  :root { --side-w: 220px; }
  .search { width: 200px; }
}
@media (max-width: 760px) {
  .app { display: block; }
  .sidebar {
    position: static; height: auto;
    display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px;
    padding: 12px 16px 10px;
    border-right: 0; border-bottom: 1px solid var(--line);
  }
  .side-top { grid-column: 1; }
  .brand-sub { display: none; }
  .new-task { grid-column: 2; grid-row: 1; height: 34px; }
  .new-task kbd { display: none; }
  .market { grid-column: 1 / -1; grid-row: 2; display: flex; align-items: center; gap: 8px; padding: 6px 10px; }
  .market .m-row { flex: 1; }
  .market .m-sub { margin: 0; padding: 0; }
  .side-nav { grid-column: 1 / -1; display: flex; gap: 4px; overflow-x: auto; margin: 0 -16px; padding: 0 16px 2px; }
  .nav-group { display: contents; }
  .nav-label { display: none; }
  .nav-item, .cat-item { flex: none; height: 32px; padding: 0 10px; border: 1px solid var(--line); background: var(--surface); }
  .nav-item.active, .cat-item.active { border-color: var(--line-strong); }
  .cat-item + .cat-item { margin-top: 0; }
  .cat-sub { display: none; }
  .cat-ic { width: 20px; height: 20px; font-size: 10.5px; border-radius: 5px; }
  .topbar { padding: 0 16px; height: 48px; }
  .search { width: auto; flex: 1; max-width: 220px; }
  .search kbd { display: none; }
  .crumb .sep, .crumb span:first-child { display: none; }
  .content { padding: 20px 16px 56px; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stats .stat:nth-child(n) { border-left: 0; border-top: 1px solid var(--line); }
  .stats .stat:nth-child(even) { border-left: 1px solid var(--line); }
  .stats .stat:nth-child(-n+2) { border-top: 0; }
  .stats .stat:nth-child(5) { grid-column: 1 / -1; }
  .grid-2 { grid-template-columns: 1fr; }
  .cal-cell { min-height: 72px; padding: 3px; }
  .cal-cell .hname { display: none; }
  .chip { font-size: 10px; padding: 1px 3px; }
  .chip::before { width: 4px; height: 4px; margin-right: 3px; }
  .cat-edit { grid-template-columns: 36px minmax(0, 1fr) auto; }
  .cat-edit .desc-in { grid-column: 1 / -1; }
  .tpl-row { grid-template-columns: minmax(0, 1fr) auto; }
  .tpl-row select { grid-column: 1; }
  .tpl-tools { margin-left: 0; width: 100%; }
  .t-meta .ref { max-width: 160px; }
  .cat-hero { flex-wrap: wrap; }
}
@media (max-width: 400px) {
  .crumb { display: none; }
  .search { max-width: none; }
}
