/* 디자인 토큰: DESIGN-minimax.md 기준 + 법틀 브랜드(로고 오렌지) */
:root {
  --primary: #0a0a0a;
  --on-primary: #ffffff;
  --charcoal: #222222;
  --slate: #45515e;
  --steel: #5f5f5f;
  --stone: #8e8e93;
  --muted: #a8aab2;
  --canvas: #ffffff;
  --surface: #f7f8fa;
  --surface-soft: #f2f3f5;
  --hairline: #e5e7eb;
  --hairline-soft: #eaecf0;
  --blue: #1456f0;
  --blue-deep: #1d4ed8;
  --blue-200: #bfdbfe;
  --purple: #a855f7;
  --coral: #ff5530;
  --buptle: #f6a21e;           /* 법틀 로고 오렌지 — 핵심 리텐션 아이덴티티 */
  --buptle-soft: #fff3df;
  --buptle-ink: #8a5300;
  --success-bg: #e8ffea;
  --success-text: #1ba673;
  --error: #d45656;
  --error-bg: #fdeeee;
  --error-ink: #b33a3a;
  --warn-bg: #fff4e5;
  --warn-ink: #9a5a00;
  --r-sm: 6px; --r-md: 8px; --r-lg: 12px; --r-xl: 16px; --r-hero: 32px; --r-full: 9999px;
  --shadow-modal: 0 12px 16px -4px rgba(36, 36, 36, .08), 0 0 0 1px rgba(0, 0, 0, .04);
  font-family: "DM Sans", "Pretendard Variable", Pretendard, "Malgun Gothic", "Apple SD Gothic Neo", Inter, Arial, sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--canvas); color: var(--charcoal); font-size: 14px; line-height: 1.5; -webkit-font-smoothing: antialiased; }
a { color: var(--primary); text-decoration: none; font-weight: 500; }
a:hover { text-decoration: underline; }
h1 { font-size: 24px; line-height: 1.3; font-weight: 600; color: var(--primary); margin: 0; letter-spacing: -.3px; }
h2 { font-size: 18px; line-height: 1.4; font-weight: 600; color: var(--primary); margin: 0 0 16px; }
h3 { font-size: 14px; font-weight: 600; color: var(--primary); margin: 0 0 8px; }
b { font-weight: 600; color: var(--primary); }
.muted { color: var(--steel); }
.small { font-size: 13px; }
.nowrap { white-space: nowrap; }

/* ---------- layout ---------- */
.shell { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.side { background: var(--canvas); border-right: 1px solid var(--hairline-soft); padding: 24px 12px; display: flex; flex-direction: column; gap: 2px; position: sticky; top: 0; height: 100vh; }
.side .logo { padding: 0 12px 24px; }
.side .logo img { height: 26px; display: block; }
.side .logo span { display: block; margin-top: 8px; font-size: 12px; color: var(--steel); letter-spacing: .2px; }
.side a { color: var(--charcoal); font-weight: 400; padding: 8px 16px; border-radius: var(--r-sm); display: block; }
.side a:hover { background: var(--surface); text-decoration: none; }
.side a.on { background: var(--surface); color: var(--primary); font-weight: 500; }
.side .who { margin-top: auto; padding: 16px; border-top: 1px solid var(--hairline-soft); font-size: 12px; color: var(--steel); }
.side .who b { display: block; font-size: 14px; }
.main { padding: 32px 40px 80px; min-width: 0; max-width: 1440px; }
.head { display: flex; align-items: center; gap: 12px; margin-bottom: 24px; flex-wrap: wrap; }
.head .grow { flex: 1; }
.panel { background: var(--canvas); border: 1px solid var(--hairline); border-radius: var(--r-xl); padding: 24px; margin-bottom: 16px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }

/* 프로그램 아이덴티티 카드 (product-card) */
.prog-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-bottom: 16px; }
.prog-card { border-radius: var(--r-hero); padding: 28px 32px; color: #fff; cursor: pointer; min-height: 168px; display: flex; flex-direction: column; justify-content: space-between; position: relative; overflow: hidden; }
.prog-card::after { content: ""; position: absolute; right: -40px; top: -40px; width: 180px; height: 180px; border-radius: 50%; background: rgba(255, 255, 255, .12); }
.prog-card .t { font-size: 14px; font-weight: 500; opacity: .9; }
.prog-card .n { font-size: 56px; font-weight: 600; line-height: 1.1; letter-spacing: -1.5px; }
.prog-card .n small { font-size: 18px; font-weight: 500; letter-spacing: 0; margin-left: 4px; }
.prog-card .d { font-size: 13px; opacity: .85; }
.prog-card.NEW { background: linear-gradient(135deg, var(--blue) 0%, #3daeff 100%); }
.prog-card.EXP { background: linear-gradient(135deg, #7c3aed 0%, var(--purple) 100%); }
.prog-card.CORE { background: linear-gradient(135deg, #f08c00 0%, var(--buptle) 100%); }

.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 16px; }
.kpi { background: var(--canvas); border: 1px solid var(--hairline); border-radius: var(--r-xl); padding: 20px 24px; }
.kpi[data-go] { cursor: pointer; }
.kpi .n { font-size: 32px; font-weight: 600; line-height: 1.25; letter-spacing: -.5px; color: var(--primary); }
.kpi .l { color: var(--steel); font-size: 13px; }
.kpi.bad .n { color: var(--error); }
.kpi.warn .n { color: var(--warn-ink); }

/* ---------- controls ---------- */
button, .btn { font: inherit; font-size: 14px; font-weight: 600; line-height: 1.4; border: 1px solid var(--hairline); background: var(--canvas); color: var(--primary); padding: 9px 20px; border-radius: var(--r-full); cursor: pointer; white-space: nowrap; transition: background .15s ease; }
button:hover { background: var(--surface); }
button.primary { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
button.primary:hover, button.primary:active { background: var(--charcoal); }
button.secondary { background: transparent; border-color: var(--primary); }
button.danger { color: var(--error-ink); border-color: #f1c4c4; }
button.sm { padding: 5px 14px; font-size: 13px; }
button.link { border: 0; background: none; color: var(--primary); padding: 4px 0; font-weight: 500; text-decoration: underline; }
button:disabled { background: var(--hairline); color: var(--muted); border-color: var(--hairline); cursor: default; }
input, select, textarea { font: inherit; font-size: 14px; border: 1px solid var(--hairline); border-radius: var(--r-md); padding: 0 14px; height: 40px; background: var(--canvas); color: var(--primary); width: 100%; }
textarea { min-height: 84px; resize: vertical; padding: 10px 14px; height: auto; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--blue-deep); box-shadow: 0 0 0 1px var(--blue-deep); }
input[type=checkbox], input[type=radio] { width: auto; height: auto; }
label.f { display: block; font-size: 13px; color: var(--slate); margin-bottom: 6px; font-weight: 600; }
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px 20px; }
.form-grid .full { grid-column: 1 / -1; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; align-items: center; }
.filters > input, .filters > select { width: auto; min-width: 140px; height: 36px; background: var(--surface); }
.tabs { display: flex; gap: 6px; }
.tabs button { font-weight: 500; color: var(--steel); padding: 7px 16px; }
.tabs button.on { background: var(--primary); color: var(--on-primary); border-color: var(--primary); }
.req::after { content: " *"; color: var(--error); }

/* ---------- table ---------- */
.tbl-wrap { overflow-x: auto; border: 1px solid var(--hairline); border-radius: var(--r-md); }
table { border-collapse: collapse; width: 100%; }
th, td { text-align: left; padding: 14px 16px; border-bottom: 1px solid var(--hairline-soft); vertical-align: middle; }
th { font-size: 13px; color: var(--steel); font-weight: 600; background: var(--surface); padding: 12px 16px; white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
td { color: var(--charcoal); }
tr.click { cursor: pointer; }
tr.click:hover td { background: var(--surface); }
tr.left td { color: var(--stone); }
.panel > table { border: 1px solid var(--hairline); border-radius: var(--r-md); border-collapse: separate; border-spacing: 0; overflow: hidden; }

/* ---------- badges ---------- */
.chip { display: inline-block; padding: 3px 10px; border-radius: var(--r-full); font-size: 12px; font-weight: 600; line-height: 1.5; background: var(--surface-soft); color: var(--steel); white-space: nowrap; vertical-align: middle; }
.chip.done { background: var(--success-bg); color: var(--success-text); }
.chip.open, .chip.draft { background: var(--blue-200); color: var(--blue-deep); }
.chip.overdue { background: var(--error-bg); color: var(--error-ink); }
.chip.upcoming, .chip.past, .chip.skip { background: var(--surface-soft); color: var(--steel); }
.chip.NEW { background: #e3ecff; color: var(--blue); }
.chip.EXP { background: #f3e8ff; color: #7c3aed; }
.chip.NONE { background: var(--surface-soft); color: var(--stone); }
.chip.core { background: var(--buptle-soft); color: var(--buptle-ink); }
.risk-high { background: var(--error-bg); color: var(--error-ink); }
.risk-mid { background: var(--warn-bg); color: var(--warn-ink); }
.risk-low { background: var(--success-bg); color: var(--success-text); }

/* ---------- matrix ---------- */
.matrix td, .matrix th { text-align: center; padding: 8px; border-bottom: 1px solid var(--hairline-soft); }
.matrix td.name, .matrix th.name { text-align: left; white-space: nowrap; position: sticky; left: 0; background: var(--canvas); z-index: 1; padding-left: 16px; }
.matrix th.name { background: var(--surface); }
.matrix th { font-size: 12px; }
.cell { display: block; min-width: 78px; border-radius: var(--r-md); padding: 6px 4px; font-size: 11px; cursor: pointer; line-height: 1.35; }
.cell b { display: block; font-size: 12px; color: inherit; }
.cell.done { background: var(--success-bg); color: var(--success-text); }
.cell.open, .cell.draft { background: var(--blue-200); color: var(--blue-deep); }
.cell.overdue { background: var(--error-bg); color: var(--error-ink); }
.cell.upcoming { background: var(--canvas); color: var(--stone); border: 1px dashed var(--hairline); }
.cell.past, .cell.skip { background: var(--surface-soft); color: var(--stone); }
.cell.cur { box-shadow: 0 0 0 2px var(--primary); }
.legend { display: flex; gap: 10px; flex-wrap: wrap; font-size: 12px; color: var(--steel); margin-bottom: 16px; align-items: center; }
.legend .cell { display: inline-block; min-width: 0; padding: 2px 10px; cursor: default; border-radius: var(--r-full); }

/* ---------- timeline ---------- */
.tl { list-style: none; margin: 0; padding: 0; }
.tl li { display: grid; grid-template-columns: 20px 1fr auto; gap: 14px; padding: 16px 0; border-bottom: 1px solid var(--hairline-soft); }
.tl li:last-child { border-bottom: 0; }
.dot { width: 12px; height: 12px; border-radius: 50%; margin-top: 5px; background: var(--hairline); }
.dot.done { background: var(--success-text); }
.dot.open, .dot.draft { background: var(--blue); }
.dot.overdue { background: var(--error); }
.tl li.cur { background: var(--surface); margin: 0 -24px; padding-left: 24px; padding-right: 24px; }
.tl .meta { color: var(--steel); font-size: 13px; margin-top: 2px; }
.rec { margin-top: 10px; background: var(--surface); border-radius: var(--r-lg); padding: 12px 16px; font-size: 13px; }
.rec .row { display: flex; gap: 14px; flex-wrap: wrap; color: var(--steel); font-size: 12px; margin-bottom: 6px; align-items: center; }
.steps { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 8px; }
.steps span { font-size: 11px; padding: 2px 8px; border-radius: var(--r-full); background: var(--surface-soft); color: var(--steel); }
.steps span.on { background: var(--success-bg); color: var(--success-text); }
.info-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px 24px; }
.info-grid div span { display: block; font-size: 12px; color: var(--steel); margin-bottom: 2px; }
.notice { background: var(--warn-bg); color: var(--warn-ink); border-radius: var(--r-lg); padding: 10px 16px; font-size: 13px; margin-bottom: 16px; }
.bar { display: flex; align-items: center; gap: 10px; margin: 8px 0; font-size: 13px; }
.bar .lbl { width: 200px; flex: none; color: var(--charcoal); }
.bar .track { flex: 1; background: var(--surface-soft); border-radius: var(--r-full); height: 8px; overflow: hidden; }
.bar .fill { height: 100%; background: var(--primary); border-radius: var(--r-full); }
.bar .v { width: 28px; text-align: right; font-weight: 600; color: var(--primary); }

/* ---------- record form ---------- */
.points { display: grid; gap: 10px; }
.point { display: grid; grid-template-columns: 170px 200px 1fr; gap: 10px; align-items: center; }
.seg { display: inline-flex; gap: 4px; }
.seg label { padding: 6px 14px; cursor: pointer; font-size: 13px; font-weight: 500; border: 1px solid var(--hairline); border-radius: var(--r-full); color: var(--steel); user-select: none; }
.seg input { display: none; }
.seg label:has(input:checked) { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.checks { display: flex; flex-wrap: wrap; gap: 8px 18px; }
.checks label { display: flex; gap: 6px; align-items: center; font-size: 13px; cursor: pointer; }
.section { border-top: 1px solid var(--hairline-soft); padding-top: 20px; margin-top: 20px; }
.guide { background: var(--surface); border-radius: var(--r-lg); padding: 12px 16px; font-size: 13px; color: var(--slate); margin-bottom: 16px; }

/* ---------- modal / toast ---------- */
.overlay { position: fixed; inset: 0; background: rgba(10, 10, 10, .4); display: flex; align-items: flex-start; justify-content: center; padding: 48px 16px; overflow-y: auto; z-index: 50; }
.modal { background: var(--canvas); border-radius: var(--r-xl); width: 100%; max-width: 760px; padding: 32px; box-shadow: var(--shadow-modal); }
.modal.wide { max-width: 920px; }
.modal h2 { font-size: 20px; }
.modal .foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 24px; flex-wrap: wrap; }
.modal .foot .grow { flex: 1; }
#toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); z-index: 100; text-align: center; }
#toast div { background: var(--primary); color: var(--on-primary); padding: 10px 20px; border-radius: var(--r-full); margin-top: 8px; font-size: 14px; font-weight: 500; }
#toast div.err { background: var(--error-ink); }

/* ---------- login ---------- */
.login { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; background: var(--surface); }
.login .box { background: var(--canvas); border: 1px solid var(--hairline); border-radius: var(--r-xl); padding: 40px; width: 100%; max-width: 400px; }
.login .brand-logo { height: 30px; display: block; margin-bottom: 24px; }
.login h1 { margin-bottom: 4px; }
.login .box > * + * { margin-top: 14px; }
.login button.primary { width: 100%; padding: 11px 24px; margin-top: 20px; }
.err-text { color: var(--error); font-size: 13px; min-height: 18px; }

@media (max-width: 1100px) {
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .info-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .side { flex-direction: row; flex-wrap: wrap; padding: 12px; height: auto; position: static; border-right: 0; border-bottom: 1px solid var(--hairline-soft); }
  .side .logo { width: 100%; padding-bottom: 8px; }
  .side .who { margin-top: 0; border: 0; width: 100%; padding: 8px 16px; }
  .main { padding: 20px 16px 60px; }
  .prog-cards, .grid2, .form-grid { grid-template-columns: 1fr; }
  .point { grid-template-columns: 1fr; }
  input, select, button { min-height: 44px; }
}
.review { margin-top: 8px; font-size: 13px; color: var(--slate); }

/* ---------- 추가: 한글 줄바꿈, 미니 타임라인, 페이저 ---------- */
html, body { word-break: keep-all; }
.mtl { display: flex; gap: 3px; margin-bottom: 5px; }
.mtl i { width: 9px; height: 9px; border-radius: 50%; background: var(--hairline); flex: none; }
.mtl i.done { background: var(--success-text); }
.mtl i.open, .mtl i.draft { background: var(--blue); }
.mtl i.overdue { background: var(--error); }
.mtl i.skip, .mtl i.past { background: var(--stone); }
.mtl i.cur { box-shadow: 0 0 0 2px var(--primary); }
tr.act > td:first-child { box-shadow: inset 3px 0 0 var(--blue); }
.cell.past { cursor: default; }
.kpi[data-kf], .kpi[data-kgo] { cursor: pointer; }
.kpi[data-kf]:hover, .kpi[data-kgo]:hover, .kpi[data-go]:hover { background: var(--surface); }
.pager { display: flex; align-items: center; gap: 10px; margin-top: 14px; }
.pager select { width: auto; height: 34px; }
th.sv { cursor: pointer; user-select: none; } th.sv::after { content: " " attr(data-dir); color: var(--stone); font-size: 10px; }
.steps span.fu { background: var(--error-bg); color: var(--error-ink); }

.chip.doing, .cell.doing { background: #dff3ee; color: #0f766e; }
.dot.doing { background: #0f9b82; }
.mtl i.doing { background: #0f9b82; }

.cell.mark, .chip.mark { background: #fff; color: var(--primary); border: 1.5px solid var(--primary); cursor: default; }
.dot.mark, .mtl i.mark { background: #fff; box-shadow: inset 0 0 0 2px var(--primary); }
