/* KICUBASE 대시보드 — 부품 스타일. /admin 화면의 <body class="k-root"> 아래에서 쓴다.
   색, 간격, 모서리, 높이는 모두 tokens.css 의 토큰으로만 쓴다. 이 파일에 색 값을 직접 적지 않는다.
   부품별 규칙은 docs/design-system/components.md, 표의 규칙은 docs/design-system/tables.md 에 있다.
   차례: 바탕 · 글 · 단추 · 입력 · 갈래 · 상태 · 꼬리표 · 증감 · 지표 · 표 · 표 도구 · 쪽 넘김 · 이름-값 · 알림 띠 · 화면 제목 줄 · 화면 틀 · 기간 필터 · 파일 첨부 · 좁은 화면 */

/* ── 바탕 ─────────────────────────────────────────── */
.k-root, .k-root *, .k-root *::before, .k-root *::after { box-sizing: border-box; }
.k-root {
  margin: 0;
  background: var(--surface);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 22px;
  word-break: keep-all;
  overflow-wrap: break-word;
  -webkit-font-smoothing: antialiased;
}
.k-root :focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.k-root [hidden] { display: none !important; }
.k-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

/* 부품을 늘어놓는 줄 */
.k-row { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-3); }
.k-stack { display: grid; gap: var(--space-4); }
.k-grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-4); align-items: stretch; }
.k-note { margin: 0; font-size: 12px; line-height: 18px; color: var(--ink-sub); }

/* ── 글 ───────────────────────────────────────────── */
.k-link { color: var(--accent); text-decoration: underline; text-underline-offset: 2px; text-decoration-thickness: 1px; }
.k-link:hover { color: var(--accent-hover); }
.k-code { font-family: var(--font-mono); font-size: 13px; line-height: 20px; }
.k-num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.k-muted { color: var(--ink-muted); }
.k-sub { color: var(--ink-sub); }

/* ── 단추 ─────────────────────────────────────────── */
.k-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  height: var(--control-md); padding: 0 var(--space-4);
  border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--ink);
  font: inherit; font-size: 14px; line-height: 20px; font-weight: 600; white-space: nowrap;
  text-decoration: none; cursor: pointer;
  transition: background-color .18s, border-color .18s, color .18s;
}
.k-btn:hover { border-color: var(--ink-faint); }
.k-btn:active { background: var(--surface-subtle); }
.k-btn-primary { background: var(--ink); border-color: var(--ink); color: var(--on-ink); }
.k-btn-primary:hover { background: var(--ink-hover); border-color: var(--ink-hover); }
.k-btn-primary:active { background: var(--ink-hover); }
.k-btn-quiet { border-color: transparent; background: transparent; font-weight: 500; }
.k-btn-quiet:hover { border-color: transparent; background: var(--surface-subtle); }
.k-btn-quiet:active { background: var(--surface-strong); }
.k-btn-danger { color: var(--danger); }
.k-btn-danger:hover { border-color: var(--danger); }
.k-btn-sm { height: var(--control-sm); padding: 0 var(--space-3); font-size: 13px; }
.k-btn-lg { height: var(--control-lg); padding: 0 var(--space-5); }
.k-btn[disabled], .k-btn[aria-disabled="true"] {
  background: var(--surface-subtle); border-color: var(--line); color: var(--ink-muted); cursor: not-allowed;
}

/* ── 입력 ─────────────────────────────────────────── */
.k-form { display: grid; gap: var(--space-4); max-width: 420px; }
/* 본문에 놓는 긴 폼. 왼쪽에 붙여 두 열로 쌓는다. 화면이 넓어도 폭 720에서 멈춰 입력칸이 늘어지지 않는다. 한 줄을 다 쓰는 항목에는 is-full 을 준다. */
.k-form-wide { max-width: 720px; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-5) var(--space-6); align-items: start; }
.k-form-wide > .is-full { grid-column: 1 / -1; }
/* 한 항목 안에 입력칸 둘을 나란히 둔다(달과 날처럼). 하나가 숨으면 남은 칸이 폭을 다 쓴다. */
.k-pair { display: flex; gap: var(--space-2); }
.k-pair > * { flex: 1 1 0; min-width: 0; }
/* Rails가 오류 난 칸의 라벨과 입력칸을 감싸는 틀. 자리를 차지하면 옆 항목과 높이가 어긋나므로 틀만 없앤다. */
.k-root .field_with_errors { display: contents; }
.k-field { display: grid; gap: var(--space-1); }
.k-label { font-size: 13px; line-height: 20px; font-weight: 500; }
.k-label small { margin-left: var(--space-1); font-size: 12px; font-weight: 400; color: var(--ink-sub); }
.k-input, .k-select, .k-textarea {
  width: 100%; height: var(--control-md); padding: 0 var(--space-3);
  border: 1px solid var(--line-control); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--ink);
  font: inherit; font-size: 14px; line-height: 20px;
  transition: border-color .18s;
}
.k-textarea { height: auto; min-height: 80px; padding: var(--space-2) var(--space-3); line-height: 22px; resize: vertical; }
.k-input::placeholder, .k-textarea::placeholder { color: var(--ink-muted); }
.k-input:hover, .k-select:hover, .k-textarea:hover { border-color: var(--ink-sub); }
.k-input:focus-visible, .k-select:focus-visible, .k-textarea:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; border-color: var(--accent); }
.k-input[aria-invalid="true"], .k-select[aria-invalid="true"] { border-color: var(--danger); }
.k-input[readonly] { background: var(--surface-subtle); border-color: var(--line-strong); }
.k-input[disabled], .k-select[disabled] { background: var(--surface-subtle); border-color: var(--line); color: var(--ink-muted); cursor: not-allowed; }
.k-input.k-num { text-align: right; }
.k-help { margin: 0; font-size: 12px; line-height: 18px; color: var(--ink-sub); }
.k-error { margin: 0; font-size: 12px; line-height: 18px; color: var(--danger); }
.k-error::before { content: "■"; margin-right: var(--space-1); font-size: 8px; vertical-align: 2px; }
/* 단위가 붙는 숫자 입력: 단위는 칸 안 오른쪽 끝에 둔다 */
.k-affix { position: relative; display: block; }
.k-affix .k-input { padding-right: var(--space-8); }
.k-affix > span { position: absolute; right: var(--space-3); top: 0; line-height: var(--control-md); font-size: 13px; color: var(--ink-sub); pointer-events: none; }
/* 고르기: 화살표는 테두리로 그린다 */
.k-select-wrap { position: relative; display: block; }
.k-select { appearance: none; -webkit-appearance: none; padding-right: var(--space-8); cursor: pointer; }
.k-select-wrap::after {
  content: ""; position: absolute; right: 14px; top: 50%; width: 6px; height: 6px; margin-top: -5px;
  border-right: 1.5px solid var(--ink-sub); border-bottom: 1.5px solid var(--ink-sub); transform: rotate(45deg); pointer-events: none;
}
/* 체크칸과 고르는 점 */
.k-check { display: inline-flex; align-items: center; gap: var(--space-2); min-height: var(--control-md); cursor: pointer; }
.k-check input { width: 16px; height: 16px; margin: 0; accent-color: var(--ink); }

/* ── 갈래(탭)와 보기 전환 ─────────────────────────── */
.k-tabs { display: flex; gap: var(--space-6); border-bottom: 1px solid var(--line-strong); overflow-x: auto; scrollbar-width: none; }
.k-tab {
  flex: none; display: inline-flex; align-items: center; gap: var(--space-2);
  height: var(--control-lg); margin-bottom: -1px; padding: 0;
  border: 0; border-bottom: 2px solid transparent; background: none;
  font: inherit; font-weight: 500; color: var(--ink-sub); text-decoration: none; cursor: pointer;
  transition: color .18s, border-color .18s;
}
.k-tab:hover { color: var(--ink); }
.k-tab[aria-selected="true"], .k-tab[aria-current="page"] { color: var(--ink); font-weight: 600; border-bottom-color: var(--ink); }
.k-tab .k-count { font-size: 12px; font-weight: 500; color: var(--ink-sub); font-variant-numeric: tabular-nums; }
.k-seg { display: inline-flex; padding: 2px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); background: var(--surface); }
.k-seg button, .k-seg a {
  height: calc(var(--control-md) - 6px); padding: 0 var(--space-3);
  border: 0; border-radius: 2px; background: none;
  font: inherit; font-size: 13px; font-weight: 500; color: var(--ink-sub); cursor: pointer;
  transition: background-color .18s, color .18s;
  display: inline-flex; align-items: center; text-decoration: none;
}
.k-seg button:hover, .k-seg a:hover { color: var(--ink); }
.k-seg button[aria-pressed="true"], .k-seg a[aria-current="true"] { background: var(--ink); color: var(--on-ink); font-weight: 600; }

/* ── 상태 표시: 도형 + 낱말 + 색 ───────────────────── */
.k-status {
  display: inline-flex; align-items: center; gap: 6px;
  height: 24px; padding: 0 var(--space-2); border-radius: var(--radius-sm);
  font-size: 13px; line-height: 20px; font-weight: 500; white-space: nowrap;
}
.k-status::before { content: ""; flex: none; width: 8px; height: 8px; }
.k-status-ok::before { background: var(--ok); border-radius: var(--radius-full); }
.k-status-warn { background: var(--warn-soft); color: var(--warn); }
.k-status-warn::before { width: 10px; height: 9px; background: var(--warn); clip-path: polygon(50% 0, 100% 100%, 0 100%); }
.k-status-danger { background: var(--danger-soft); color: var(--danger); font-weight: 600; }
.k-status-danger::before { background: var(--danger); }
.k-status-unknown { color: var(--ink-sub); }
.k-status-unknown::before { border: 1.5px solid var(--ink-faint); border-radius: var(--radius-full); }

/* ── 꼬리표 ───────────────────────────────────────── */
.k-tag {
  display: inline-flex; align-items: center; height: 20px; padding: 0 6px;
  border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--ink-sub);
  font-size: 11px; line-height: 14px; font-weight: 500; white-space: nowrap;
}
.k-tag-fill { border-color: transparent; background: var(--surface-subtle); }
.k-tag-estimate { border-style: dashed; border-color: var(--ink-faint); }
.k-tag-strong { border-color: var(--ink); color: var(--ink); }

/* ── 증감: 방향은 기호, 좋고 나쁨은 색 ─────────────── */
.k-delta { display: inline-flex; align-items: baseline; gap: 3px; font-size: 13px; line-height: 20px; font-weight: 500; font-variant-numeric: tabular-nums; white-space: nowrap; color: var(--ink-sub); }
.k-delta i { font-style: normal; font-size: 9px; }
.k-delta-good { color: var(--ok); }
.k-delta-bad { color: var(--danger); }

/* ── 지표 칸 ──────────────────────────────────────── */
.k-metrics {
  display: flex; flex-wrap: wrap; gap: 1px;
  border: 1px solid var(--line-strong); border-radius: var(--radius-md);
  background: var(--line); overflow: hidden;
}
.k-metric { flex: 1 1 180px; min-width: 0; padding: var(--space-4) var(--space-5); background: var(--surface); }
.k-metric-hero { flex: 2 1 300px; }
.k-metric-label { display: flex; align-items: center; gap: 6px; font-size: 13px; line-height: 20px; font-weight: 500; color: var(--ink-sub); }
.k-metric-value { margin-top: 2px; font-size: 28px; line-height: 36px; font-weight: 600; letter-spacing: -0.01em; white-space: nowrap; }
.k-metric-hero .k-metric-value { font-size: 48px; line-height: 56px; letter-spacing: -0.02em; }
.k-metric-value small { margin-left: 3px; font-size: 16px; font-weight: 500; letter-spacing: 0; }
.k-metric-hero .k-metric-value small { font-size: 22px; }
.k-metric-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 2px var(--space-2); margin-top: var(--space-1); font-size: 12px; line-height: 18px; color: var(--ink-sub); }
.k-metric-wide { flex: 1.5 1 240px; }
.k-metric-trend { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: var(--space-1) var(--space-3); }
/* 추이 선: 지난 기간은 ink-faint, 마지막 점만 accent */
.k-spark { flex: none; display: block; max-width: 100%; }
.k-spark polyline { fill: none; stroke: var(--ink-faint); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.k-spark circle { fill: var(--accent); stroke: var(--surface); stroke-width: 2; }

/* ── 표 ───────────────────────────────────────────── */
.k-table-wrap { border: 1px solid var(--line-strong); border-radius: var(--radius-md); background: var(--surface); overflow: hidden; }
.k-table-scroll { overflow-x: auto; }
.k-table-scroll.is-tall { max-height: 260px; overflow-y: auto; }
.k-table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 14px; line-height: 20px; }
.k-table caption { padding: var(--space-3) var(--space-4); border-bottom: 1px solid var(--line-strong); text-align: left; font-size: 16px; line-height: 24px; font-weight: 600; }
.k-table caption small { margin-left: var(--space-2); font-size: 12px; font-weight: 400; color: var(--ink-sub); }
/* 칸 안의 글은 줄을 나누지 않는다. 표가 틀보다 넓어지면 틀 안에서 옆으로 넘긴다(k-table-scroll). */
.k-table th, .k-table td { padding: 0 var(--space-4); text-align: left; vertical-align: middle; white-space: nowrap; }
.k-table thead th {
  position: sticky; top: 0; z-index: 1; height: var(--row-sm);
  background: var(--surface-subtle); border-bottom: 1px solid var(--line-strong);
  font-size: 12px; line-height: 16px; font-weight: 600; color: var(--ink-sub); white-space: nowrap;
}
.k-table tbody td, .k-table tbody th { height: var(--row-md); padding-top: var(--space-2); padding-bottom: var(--space-2); border-bottom: 1px solid var(--line); font-weight: 400; }
.k-table tbody tr:last-child > * { border-bottom: 0; }
.k-table tbody tr { transition: background-color .18s; }
.k-table tbody tr:hover > * { background: var(--surface-subtle); }
.k-table tbody tr[aria-selected="true"] > * { background: var(--accent-soft); }
.k-table .is-num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.k-table .is-end { text-align: right; white-space: nowrap; }
.k-table .is-check { width: 40px; padding-right: 0; }
.k-table .is-check input { display: block; width: 16px; height: 16px; margin: 0; accent-color: var(--ink); }
.k-table .is-name { font-weight: 600; white-space: nowrap; }
.k-table .is-name a { color: inherit; text-decoration: none; }
.k-table .is-name a:hover { text-decoration: underline; text-underline-offset: 2px; }
.k-table .is-name small { display: block; font-size: 12px; line-height: 16px; font-weight: 400; color: var(--ink-sub); }
.k-table .is-clip { max-width: 240px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.k-table .is-empty { color: var(--ink-muted); }
.k-table .is-neg { color: var(--danger); }
.k-table tfoot td, .k-table tfoot th { height: var(--row-md); border-top: 1px solid var(--line-strong); background: var(--surface); font-weight: 600; }
/* 머리의 정렬 단추 */
.k-sort { display: inline-flex; text-decoration: none; align-items: center; gap: var(--space-1); margin: 0; padding: 0; border: 0; background: none; font: inherit; color: inherit; cursor: pointer; }
.k-sort::after { content: "↕"; font-size: 11px; color: var(--ink-faint); }
.k-sort:hover { color: var(--ink); }
th[aria-sort="ascending"] .k-sort, th[aria-sort="descending"] .k-sort { color: var(--ink); }
th[aria-sort="ascending"] .k-sort::after { content: "↑"; color: var(--ink); }
th[aria-sort="descending"] .k-sort::after { content: "↓"; color: var(--ink); }
/* 조밀한 표 */
.k-table-sm { font-size: 13px; }
.k-table-sm th, .k-table-sm td { padding-left: var(--space-3); padding-right: var(--space-3); }
.k-table-sm thead th { height: 32px; }
.k-table-sm tbody td, .k-table-sm tbody th { height: var(--row-sm); padding-top: 6px; padding-bottom: 6px; }
.k-table-sm tfoot td, .k-table-sm tfoot th { height: var(--row-sm); }
/* 옆으로 넘길 때 첫 칸을 붙잡아 둔다 */
.k-table .is-stick { position: sticky; left: 0; z-index: 2; background: var(--surface); box-shadow: 1px 0 0 var(--line); }
.k-table thead .is-stick { z-index: 3; background: var(--surface-subtle); }
.k-table tbody tr:hover .is-stick { background: var(--surface-subtle); }
/* 불러오는 중의 뼈대 줄 */
.k-skel { display: block; height: 10px; border-radius: 2px; background: var(--surface-strong); }
/* 표 자리의 안내(없음, 찾는 것 없음, 오류) */
.k-table-msg { padding: var(--space-12) var(--space-6); text-align: center; }
.k-table-msg strong { display: block; font-size: 16px; line-height: 24px; font-weight: 600; }
.k-table-msg p { margin: var(--space-1) auto 0; max-width: 360px; color: var(--ink-sub); }
.k-table-msg .k-btn { margin-top: var(--space-4); }

/* ── 표 도구 줄 ───────────────────────────────────── */
.k-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-3); padding: var(--space-3) var(--space-4); border-bottom: 1px solid var(--line-strong); }
.k-toolbar .k-input { width: 220px; }
.k-toolbar-end { display: flex; align-items: center; gap: var(--space-3); margin-left: auto; }
.k-toolbar-count { font-size: 13px; color: var(--ink-sub); font-variant-numeric: tabular-nums; white-space: nowrap; }
.k-toolbar.is-selecting { background: var(--accent-soft); }
.k-toolbar.is-selecting strong { font-weight: 600; font-variant-numeric: tabular-nums; }
/* 거르기 묶음과 그것을 펴는 단추. 넓은 화면에서는 고르기들이 도구 줄에 그대로 놓이고 단추는 없다.
   휴대폰에서는 단추 뒤에 접어 둔다(아래 '좁은 화면', fold_controller.js). */
.k-toolbar-more { display: contents; }
.k-toolbar-fold { display: none; }

/* ── 쪽 넘김 ──────────────────────────────────────── */
.k-pager { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--space-3); padding: var(--space-2) var(--space-4); border-top: 1px solid var(--line-strong); font-size: 13px; color: var(--ink-sub); }
.k-pager-range { font-variant-numeric: tabular-nums; }
.k-pager-range b { font-weight: 600; color: var(--ink); }
.k-pager-nav { display: flex; align-items: center; gap: var(--space-2); }

/* ── 이름-값 목록 ─────────────────────────────────── */
.k-dl { margin: 0; border: 1px solid var(--line-strong); border-radius: var(--radius-md); overflow: hidden; }
.k-dl > div { display: grid; grid-template-columns: 148px minmax(0, 1fr); gap: var(--space-4); min-height: var(--row-md); padding: 11px var(--space-4); border-bottom: 1px solid var(--line); }
.k-dl > div:last-child { border-bottom: 0; }
.k-dl dt { font-size: 13px; line-height: 22px; color: var(--ink-sub); }
.k-dl dd { margin: 0; min-width: 0; }

/* ── 알림 띠 ──────────────────────────────────────── */
.k-banner { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2) var(--space-3); padding: 10px var(--space-4); border-radius: var(--radius-md); background: var(--surface-subtle); }
.k-banner::before { content: ""; flex: none; width: 10px; height: 10px; border: 1.5px solid var(--ink-faint); border-radius: var(--radius-full); }
.k-banner strong { font-weight: 600; }
.k-banner .k-banner-end { margin-left: auto; }
.k-banner-danger { background: var(--danger-soft); }
.k-banner-danger::before { border: 0; border-radius: 0; background: var(--danger); }
.k-banner-warn { background: var(--warn-soft); }
.k-banner-warn::before { width: 12px; height: 11px; border: 0; border-radius: 0; background: var(--warn); clip-path: polygon(50% 0, 100% 100%, 0 100%); }
.k-banner-ok { background: var(--ok-soft); }
.k-banner-ok::before { border: 0; background: var(--ok); }

/* ── 화면 제목 줄 ─────────────────────────────────── */
.k-pagehead { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: var(--space-3) var(--space-6); }
.k-pagehead h1 { margin: 0; font-size: 22px; line-height: 30px; font-weight: 600; letter-spacing: -0.01em; }
.k-pagehead p { margin: 2px 0 0; color: var(--ink-sub); }
.k-pagehead-actions { display: flex; align-items: center; gap: var(--space-2); }
.k-crumbs { display: flex; align-items: center; gap: 6px; margin-bottom: var(--space-1); font-size: 13px; color: var(--ink-sub); }
.k-crumbs a { color: inherit; text-decoration: none; }
.k-crumbs a:hover { color: var(--ink); text-decoration: underline; }
.k-section-title { margin: 0 0 var(--space-3); font-size: 16px; line-height: 24px; font-weight: 600; }

/* ── 화면 틀: 옆 메뉴 + 위 막대 + 본문 ─────────────── */
.k-shell { display: grid; grid-template-columns: var(--sidebar) minmax(0, 1fr); min-height: 100vh; }
/* 옆 메뉴는 ink 바탕이다. 메뉴의 글자는 on-ink-sub 로 물려 두고, 마우스를 올린 줄과 지금 있는 줄만 on-ink 로 밝힌다.
   줄의 바탕은 옆 메뉴의 가장자리에서 띄우고, 모서리는 메뉴 항목의 radius-sm 이다. */
.k-side {
  position: sticky; top: 0; align-self: start; height: 100vh; overflow-y: auto;
  display: flex; flex-direction: column; gap: var(--space-1); padding: var(--space-4) var(--space-3); background: var(--ink); color: var(--on-ink);
}
.k-side :focus-visible { outline-color: var(--on-ink); outline-offset: -2px; }
.k-brand { display: flex; align-items: baseline; gap: var(--space-2); height: var(--control-md); padding: 0 var(--space-2); margin-bottom: var(--space-3); font-size: 16px; font-weight: 700; letter-spacing: 0.02em; }
.k-brand small { font-size: 12px; font-weight: 500; letter-spacing: 0; color: var(--ink-sub); }
.k-side .k-brand small { color: var(--on-ink-sub); }
/* 옆 메뉴의 차례: 맨 위 메뉴(대시보드), 구분선, 접고 펴는 묶음들. */
.k-menu { display: grid; gap: var(--space-1); }
.k-nav-rule { height: 1px; margin: var(--space-2); border: 0; background: var(--ink-raised); }
/* 옆 메뉴 맨 아래: 구분선과 로그아웃. 본문을 내려도 옆 메뉴는 화면 높이만큼 제자리에 남아, 로그아웃이 늘 아래 끝에 있다. */
.k-side-foot { display: grid; gap: var(--space-1); margin-top: auto; padding-top: var(--space-4); }
button.k-nav { width: 100%; border: 0; background: none; font: inherit; font-weight: 500; text-align: left; cursor: pointer; }
/* 메뉴의 줄. 맨 위 메뉴, 묶음 이름, 하위 메뉴가 같은 모양을 쓴다. 맨 위 메뉴와 묶음 이름은 한 단계 굵다. */
.k-nav, .k-nav-group { display: flex; align-items: center; gap: var(--space-2); height: var(--control-md); padding: 0 var(--space-2); border-radius: var(--radius-sm); color: var(--on-ink-sub); font-weight: 500; text-decoration: none; white-space: nowrap; transition: background-color .18s, color .18s; }
.k-nav-top, .k-nav-group { font-weight: 600; }
.k-nav:hover, summary.k-nav-group:hover { background: var(--ink-hover); color: var(--on-ink); }
/* 지금 있는 화면: 바탕보다 한 단계 밝은 ink-raised 에 on-ink 글자. */
.k-nav[aria-current="page"], .k-nav[aria-current="page"]:hover { background: var(--ink-raised); color: var(--on-ink); }
/* 묶음 이름(summary)을 눌러 접고 편다. 접고 펴는 표시는 테두리로 그린다. 편 묶음은 아래를, 접은 묶음은 오른쪽을 본다. */
summary.k-nav-group { list-style: none; cursor: pointer; user-select: none; }
summary.k-nav-group::-webkit-details-marker { display: none; }
summary.k-nav-group::after {
  content: ""; width: 6px; height: 6px; margin-left: auto; margin-right: var(--space-1);
  border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor; transform: rotate(-45deg);
}
details[open] > summary.k-nav-group::after { transform: translateY(-2px) rotate(45deg); }
/* 접은 묶음 안에 지금 화면이 있으면 묶음 이름을 밝게 해서 어디에 있는지 알린다. */
details:not([open]):has(.k-nav[aria-current="page"]) > summary.k-nav-group { color: var(--on-ink); }
/* 하위 메뉴: 묶음 이름보다 안쪽에 두고, 왼쪽에 세로줄을 그어 어느 묶음에 속하는지 보인다. */
.k-nav-items { display: grid; gap: var(--space-1); margin: var(--space-1) 0 var(--space-2) var(--space-4); padding-left: var(--space-2); border-left: 1px solid var(--ink-raised); }
.k-nav .k-count { margin-left: auto; min-width: 18px; padding: 0 5px; border-radius: var(--radius-sm); background: var(--danger); color: var(--on-ink); font-size: 12px; line-height: 18px; font-weight: 600; font-variant-numeric: tabular-nums; text-align: center; }
/* 메뉴 이름 옆의 짧은 설명과, /admin 밖으로 나가는 메뉴의 표시. 표시는 오른쪽 끝으로 밀지 않고 글자 바로 뒤에 붙인다. */
.k-nav small { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; font-weight: 400; color: var(--on-ink-sub); }
.k-nav .k-nav-out { flex: none; font-size: 12px; color: var(--on-ink-sub); }
.k-main { min-width: 0; display: flex; flex-direction: column; }
.k-top { display: flex; align-items: center; justify-content: space-between; gap: var(--space-4); height: var(--topbar); padding: 0 var(--space-6); border-bottom: 1px solid var(--line-strong); font-size: 13px; color: var(--ink-sub); }
.k-top b { font-weight: 600; color: var(--ink); }
/* 휴대폰 폭에서 옆 메뉴를 여는 단추(위 막대 오른쪽 끝), 닫는 단추(옆 메뉴 오른쪽 위, 여는 단추와 같은 자리), 메뉴 뒤에서 본문을 가리는 막.
   넓은 화면에서는 옆 메뉴가 늘 보이므로 셋 다 없다. 모양은 아래 '좁은 화면'에서 정한다. */
.k-menu-btn, .k-side-close, .k-scrim { display: none; }
/* 본문의 칸은 남은 폭까지만 쓴다. 넓은 표가 든 구역이 칸을 밀어 화면이 가로로 넘치지 않게 한다. */
/* 맨 아래는 space-24 를 비운다. 모든 화면에 걸리므로 화면마다 따로 여백을 주지 않는다. */
.k-content { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--space-6); align-content: start; padding: var(--space-6) var(--space-6) var(--space-24); }

/* ── 기간 필터 ────────────────────────────────────── */
.k-period { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2) var(--space-3); }
.k-period-text { font-size: 13px; line-height: 20px; color: var(--ink-sub); font-variant-numeric: tabular-nums; white-space: nowrap; }
.k-period-text b { font-weight: 600; color: var(--ink); }
.k-period-range { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); }
.k-period-range .k-input { width: 152px; font-variant-numeric: tabular-nums; }
.k-period-range > span { color: var(--ink-sub); }

/* ── 파일 첨부 ────────────────────────────────────── */
.k-drop {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: var(--space-2) var(--space-3);
  padding: var(--space-5); border: 1px dashed var(--line-control); border-radius: var(--radius-md);
  background: var(--surface); color: var(--ink-sub); text-align: center;
  transition: background-color .18s, border-color .18s;
}
.k-drop:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; }
.k-drop.is-over { border-style: solid; border-color: var(--accent); background: var(--accent-soft); color: var(--ink); }
.k-files { margin: 0; padding: 0; list-style: none; border: 1px solid var(--line-strong); border-radius: var(--radius-md); overflow: hidden; }
.k-file { display: flex; align-items: center; gap: var(--space-3); min-height: var(--row-md); padding: var(--space-1) var(--space-2) var(--space-1) var(--space-4); border-bottom: 1px solid var(--line); }
.k-file:last-child { border-bottom: 0; }
.k-file-name { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.k-file-meta { flex: none; font-size: 12px; line-height: 18px; color: var(--ink-sub); font-variant-numeric: tabular-nums; white-space: nowrap; }
.k-file.is-error .k-file-meta { color: var(--danger); }
.k-files-none { min-height: var(--row-md); padding: 11px var(--space-4); color: var(--ink-sub); }

/* ── 스낵바 ──────────────────────────────────────── */
/* 방금 한 일을 본문의 가운데 아래에 잠깐 알린다. 되돌릴 수 있는 일이면 '되돌리기'를 함께 준다. */
.k-snack {
  position: fixed; z-index: 40; bottom: var(--space-6); left: calc(50% + var(--sidebar) / 2); transform: translateX(-50%);
  display: flex; align-items: center; gap: var(--space-3); width: max-content; max-width: calc(100vw - var(--sidebar) - var(--space-12));
  min-height: var(--control-lg); padding: var(--space-2) var(--space-2) var(--space-2) var(--space-4);
  border-radius: var(--radius-md); background: var(--ink); color: var(--on-ink); box-shadow: var(--shadow-pop);
  animation: k-snack-in .18s ease-out;
}
@keyframes k-snack-in { from { opacity: 0; transform: translate(-50%, 8px); } }
/* 끝난 일의 표시: 밝은 녹색 원에 ink 체크. */
.k-snack-icon { flex: none; }
.k-snack-icon circle { fill: var(--ok-on-ink); }
.k-snack-icon path { fill: none; stroke: var(--ink); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.k-snack-text { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.k-snack-text strong { font-weight: 600; }
.k-snack-text span { margin-left: var(--space-2); color: var(--on-ink-sub); }
.k-snack form { display: flex; flex: none; }
.k-snack-action, .k-snack-close { flex: none; height: var(--control-sm); border: 0; border-radius: var(--radius-sm); background: transparent; color: var(--on-ink); font: inherit; cursor: pointer; transition: background-color .18s; }
.k-snack-action { padding: 0 var(--space-2); font-size: 13px; font-weight: 600; }
.k-snack-close { width: var(--control-sm); font-size: 16px; line-height: 1; color: var(--on-ink-sub); }
.k-snack-action:hover, .k-snack-close:hover { background: var(--ink-hover); color: var(--on-ink); }
.k-snack :focus-visible { outline-color: var(--on-ink); }

/* ── 좁은 화면 ────────────────────────────────────── */
@media (max-width: 720px) {
  .k-snack { left: 50%; bottom: var(--space-4); max-width: calc(100vw - var(--space-8)); }
  .k-btn, .k-input, .k-select { height: var(--control-lg); }
  .k-input, .k-select, .k-textarea { font-size: 16px; }
  .k-affix > span { line-height: var(--control-lg); }
  .k-shell { grid-template-columns: minmax(0, 1fr); }
  /* 옆 메뉴는 화면 오른쪽 밖에 숨겨 두었다가, 메뉴 단추를 누르면 본문 위로 연다(shell_controller.js 가 is-menu-open 을 붙인다).
     단추가 오른쪽 위에 있어 메뉴도 오른쪽에서 연다. 숨긴 동안에는 visibility 로 초점과 읽어 주기에서도 뺀다. */
  .k-side {
    position: fixed; z-index: 60; inset: 0 0 0 auto; width: var(--sidebar); max-width: calc(100vw - var(--space-12)); height: auto;
    overscroll-behavior: contain;
    visibility: hidden; transform: translateX(100%); transition: transform .15s ease-out, visibility 0s .15s;
  }
  .k-scrim { display: block; position: fixed; z-index: 50; inset: 0; background: var(--scrim); visibility: hidden; opacity: 0; transition: opacity .15s, visibility 0s .15s; }
  /* 열 때는 곧바로 보이게 한다(닫는 단추로 초점을 옮길 수 있게). 닫을 때만 움직임이 끝난 뒤에 숨긴다. */
  .is-menu-open .k-side { visibility: visible; transform: none; transition-delay: 0s; }
  .is-menu-open .k-scrim { visibility: visible; opacity: 1; transition-delay: 0s; }
  .k-root:has(.is-menu-open) { overflow: hidden; }
  .k-nav, .k-nav-group { height: var(--control-lg); }
  /* 메뉴 단추: 줄 셋을 CSS 로 그린다. 누르는 자리는 control-lg 이고, 줄의 오른쪽 끝이 본문의 오른쪽 끝과 맞도록 당긴다. */
  .k-menu-btn {
    display: inline-flex; flex: none; align-items: center; justify-content: center;
    width: var(--control-lg); height: var(--control-lg); margin-right: calc(var(--space-3) * -1); padding: 0;
    border: 0; border-radius: var(--radius-sm); background: transparent; color: var(--ink); cursor: pointer;
    transition: background-color .18s;
  }
  .k-menu-btn:hover { background: var(--surface-subtle); }
  .k-menu-btn:active { background: var(--surface-strong); }
  .k-menu-btn span, .k-menu-btn span::before, .k-menu-btn span::after { display: block; width: 18px; height: 2px; background: currentColor; }
  .k-menu-btn span { position: relative; }
  .k-menu-btn span::before, .k-menu-btn span::after { content: ""; position: absolute; left: 0; }
  .k-menu-btn span::before { top: -6px; }
  .k-menu-btn span::after { top: 6px; }
  /* 닫는 단추: KICUBASE 글자와 같은 줄의 오른쪽 끝, 메뉴를 연 단추와 같은 자리에 둔다. 연 자리에서 그대로 닫는다. */
  .k-side-close {
    display: block; position: absolute; top: var(--space-1); right: var(--space-3);
    width: var(--control-lg); height: var(--control-lg); padding: 0;
    border: 0; border-radius: var(--radius-sm); background: transparent; color: var(--on-ink-sub);
    font: inherit; font-size: 22px; line-height: 1; cursor: pointer; transition: background-color .18s, color .18s;
  }
  .k-side-close:hover { background: var(--ink-hover); color: var(--on-ink); }
  .k-dl > div { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .k-form-wide { grid-template-columns: minmax(0, 1fr); }
  .k-grid2 { grid-template-columns: minmax(0, 1fr); }
  .k-check { min-height: var(--control-lg); }
  /* 위치 줄의 링크는 보이는 크기는 두고 눌리는 자리만 넓힌다. */
  .k-crumbs a { position: relative; }
  .k-crumbs a::after { content: ""; position: absolute; inset: calc(var(--space-3) * -1) calc(var(--space-2) * -1); }

  /* 지표 칸: 두 칸씩 놓고 값은 한 단계 작게(text-title) 쓴다. 목록이 첫 화면에 들어오게 한다. */
  .k-metric:not(.k-metric-hero) { flex: 1 1 40%; padding: var(--space-3) var(--space-4); }
  .k-metric:not(.k-metric-hero) .k-metric-value { font-size: 22px; line-height: 30px; }
  .k-metric:not(.k-metric-hero) .k-metric-value small { font-size: 14px; }

  /* 보기 전환(k-seg): 글자를 꺾지 않고 한 줄에 두며, 넘치면 줄 안에서 옆으로 넘긴다. */
  .k-seg { max-width: 100%; overflow-x: auto; scrollbar-width: none; }
  .k-seg button, .k-seg a { flex: none; height: calc(var(--control-lg) - 6px); white-space: nowrap; }
  /* 직접 고르는 기간: 날짜 칸 둘을 나란히 두고(좁으면 쌓는다) 적용 단추는 그 아래 한 줄을 쓴다. */
  .k-period { flex: 1 1 100%; min-width: 0; }
  .k-period-range { flex: 1 1 100%; min-width: 0; }
  .k-period-range .k-input { flex: 1 1 140px; width: auto; min-width: 0; }
  .k-period-range > span { display: none; }
  .k-period-range .k-btn { flex: 1 1 100%; }

  /* 표 도구 줄: 첫 줄은 찾기 칸과 찾기 단추, 둘째 줄은 거르기 단추와 줄 개수다.
     고르기들은 거르기 단추를 눌러야 그 아래에 두 칸씩 펴진다. */
  .k-toolbar { gap: var(--space-2); }
  .k-toolbar > .k-input { order: 1; flex: 1 1 0; width: auto; min-width: 0; }
  .k-toolbar-go { order: 2; }
  .k-toolbar-fold { order: 3; display: inline-flex; }
  .k-toolbar-fold::after {
    content: ""; width: 6px; height: 6px; margin: -3px 0 0 var(--space-1);
    border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor; transform: rotate(45deg);
  }
  .k-toolbar-fold[aria-expanded="true"]::after { margin-top: 3px; transform: rotate(-135deg); }
  .k-toolbar-fold .k-count { font-variant-numeric: tabular-nums; }
  .k-toolbar-end { order: 4; }
  .k-toolbar-more { order: 5; flex: 1 1 100%; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-2); }
  .k-toolbar-fold[aria-expanded="false"] ~ .k-toolbar-more { display: none; }
  /* 찾기 칸과 찾기 단추 뒤에서 줄을 바꾼다. */
  .k-toolbar:has(.k-toolbar-fold)::after { content: ""; order: 2; flex: 0 0 100%; height: 0; margin-top: calc(var(--space-2) * -1); }

  /* 목록 보기(k-table-list): 휴대폰에서는 같은 표를 줄마다 목록으로 그린다.
     첫 줄은 줄의 이름과 금액, 그 아래는 날짜와 분류 같은 덧붙는 값(is-meta), 상태(is-marks), 줄 안의 단추(is-end)다.
     머리는 정렬할 수 있는 칸만 남기고, 줄은 어디를 눌러도 상세로 간다. 칸을 옆으로 넘기지 않는다. */
  .k-table-list, .k-table-list thead, .k-table-list tbody, .k-table-list tfoot { display: block; }
  .k-table-list thead:not(:has([aria-sort])) { display: none; }
  .k-table-list thead tr { display: flex; background: var(--surface-subtle); border-bottom: 1px solid var(--line-strong); }
  .k-table-list thead th { display: none; }
  .k-table-list thead th[aria-sort] { position: static; display: flex; flex: 1 1 0; align-items: center; height: var(--control-lg); border: 0; }
  .k-table-list thead th.is-num { justify-content: flex-end; }
  .k-table-list .k-sort { height: 100%; }
  .k-table-list tbody tr, .k-table-list tfoot tr {
    position: relative; display: flex; flex-wrap: wrap; align-items: center; gap: 2px var(--space-1);
    padding: var(--space-3) var(--space-4); border-bottom: 1px solid var(--line);
  }
  .k-table-list tbody tr:last-child { border-bottom: 0; }
  /* 줄을 바꾸는 자리 둘: 이름·금액 뒤, 덧붙는 값 뒤. 상태와 단추는 늘 마지막 줄에 놓인다. */
  .k-table-list tbody tr::before, .k-table-list tbody tr::after { content: ""; flex: 0 0 100%; }
  .k-table-list tbody tr::before { order: 3; }
  .k-table-list tbody tr::after { order: 5; }
  .k-table-list tbody tr > *, .k-table-list tfoot tr > * { display: block; height: auto; padding: 0; border: 0; }
  .k-table-list tbody tr:hover > * { background: none; }
  .k-table-list tbody tr:active { background: var(--surface-subtle); }
  .k-table-list .is-name { order: 1; flex: 1 1 0; min-width: 0; white-space: normal; }
  .k-table-list .is-name a::after { content: ""; position: absolute; inset: 0; }
  .k-table-list .is-name small { margin-top: 2px; }
  .k-table-list tbody .is-num, .k-table-list tfoot .is-num { order: 2; flex: none; align-self: flex-start; margin-left: var(--space-3); font-weight: 600; }
  .k-table-list [data-unit]::after { content: attr(data-unit); }
  .k-table-list .is-meta { order: 4; font-size: 13px; color: var(--ink-sub); }
  .k-table-list .is-meta.is-empty { display: none; }
  .k-table-list .is-meta ~ .is-meta::before { content: "·"; margin-right: var(--space-1); }
  .k-table-list .is-marks { order: 6; display: flex; flex-wrap: wrap; gap: var(--space-1); margin-top: var(--space-1); }
  .k-table-list .is-end { order: 7; z-index: 1; margin-left: auto; }
  .k-table-list tbody td:not(:has(*)):not(.is-meta, .is-num), .k-table-list tfoot td:not(.is-num) { display: none; }
  .k-table-list tfoot tr { border-top: 1px solid var(--line-strong); border-bottom: 0; }
  .k-table-list tfoot th { order: 1; flex: 1 1 0; }

  /* 폼의 단추 줄: 화면 아래에 붙여 둔다. 긴 폼을 끝까지 내리지 않아도 저장할 수 있다. */
  .k-form-actions {
    position: sticky; bottom: 0; z-index: 5; flex-wrap: nowrap;
    margin: 0 calc(var(--space-6) * -1) calc(var(--space-6) * -1); padding: var(--space-3) var(--space-6);
    border-top: 1px solid var(--line-strong); background: var(--surface);
  }
  .k-form-actions .k-btn-primary { flex: 1 1 auto; }
}
@media (prefers-reduced-motion: reduce) {
  .k-btn, .k-input, .k-select, .k-textarea, .k-tab, .k-seg button, .k-nav, summary.k-nav-group, .k-table tbody tr, .k-drop, .k-snack-action, .k-snack-close, .k-side, .k-scrim, .k-menu-btn, .k-side-close { transition: none; }
  .k-snack { animation: none; }
}

/* ── 폼 안의 묶음 ─────────────────────────────────── */
.k-fieldset { display: grid; gap: var(--space-1); min-width: 0; margin: 0; padding: 0; border: 0; }
.k-fieldset > legend { padding: 0; }

/* ── 들어가는 화면 ────────────────────────────────── */
.k-login { display: grid; place-items: center; min-height: 100vh; padding: var(--space-6); background: var(--surface-subtle); }
.k-login-box { display: grid; gap: var(--space-5); width: 100%; max-width: 380px; padding: var(--space-8) var(--space-6); border: 1px solid var(--line-strong); border-radius: var(--radius-md); background: var(--surface); }
.k-login-box .k-brand { margin: 0; padding: 0; }
.k-login-box .k-form { max-width: none; }
