:root {
  --bg: #111214; --side: #15161A; --surface: #1A1B1E; --raised: #1F2024; --chip: #24252A;
  --line: #2A2B30; --line2: #3A3C42; --text: #F3F2EE; --muted: #A4A7AE; --dim: #8C8F96;
  --accent: #F0A43A; --accent-bg: #2B2418; --ok: #7FD6A8; --danger: #FF8A7A;
  --mono: 'IBM Plex Mono', ui-monospace, monospace;
  --r: 16px; --tab-h: 64px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body { font-family: 'IBM Plex Sans KR', system-ui, sans-serif; font-size: 15px; line-height: 1.45; -webkit-tap-highlight-color: transparent; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
.num { font-family: var(--mono); }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.boot { min-height: 100dvh; display: grid; place-items: center; color: var(--muted); }

/* ---------- shell ---------- */
.shell { min-height: 100dvh; display: flex; }
.side { display: none; }
.main { flex: 1; min-width: 0; padding: calc(24px + env(safe-area-inset-top)) 20px calc(var(--tab-h) + 32px + env(safe-area-inset-bottom)); }
.wrap { max-width: 1280px; margin: 0 auto; display: flex; flex-direction: column; gap: 24px; }
.tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; display: grid; grid-template-columns: repeat(4, 1fr); background: var(--side); border-top: 1px solid var(--line); padding: 6px 8px calc(8px + env(safe-area-inset-bottom)); }
.tabbar a { display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 8px 0; font-size: 11px; color: var(--muted); }
.tabbar a.on { color: var(--accent); font-weight: 600; }
@media (min-width: 900px) {
  .tabbar { display: none; }
  .side { display: flex; flex-direction: column; gap: 28px; width: 232px; flex: none; position: sticky; top: 0; height: 100dvh; background: var(--side); border-right: 1px solid var(--line); padding: 28px 16px; }
  .side .brand { padding: 0 10px; display: flex; flex-direction: column; gap: 2px; }
  .side .brand b { font-size: 19px; letter-spacing: -0.3px; }
  .side nav { display: flex; flex-direction: column; gap: 4px; }
  .side nav a { display: flex; align-items: center; gap: 12px; height: 44px; padding: 0 12px; border-radius: 10px; color: var(--muted); font-weight: 500; }
  .side nav a.on { background: var(--chip); color: var(--accent); font-weight: 600; }
  .main { padding: 32px 40px 56px; }
}

/* ---------- common ---------- */
.head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; }
.head h1 { margin: 0; font-size: 28px; letter-spacing: -0.6px; line-height: 1.2; }
.head .sub { font-size: 13px; color: var(--muted); margin-bottom: 4px; }
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.between { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
h2 { margin: 0; font-size: 17px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 18px; display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.empty { border: 1px dashed var(--line2); border-radius: var(--r); padding: 22px 18px; text-align: center; color: var(--muted); font-size: 14px; }
.empty b { display: block; color: var(--text); font-size: 15px; margin-bottom: 4px; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 20px; }
.split { display: flex; flex-wrap: wrap; gap: 20px; align-items: flex-start; }
.split > .a { flex: 999 1 420px; min-width: 0; display: flex; flex-direction: column; gap: 20px; }
.split > .b { flex: 1 1 320px; min-width: 0; display: flex; flex-direction: column; gap: 20px; }
.kv { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 12px; }
.kv div span { display: block; font-size: 12px; color: var(--muted); margin-bottom: 2px; }
.list-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; min-height: 44px; border-top: 1px solid var(--line); }
.list-row .v { font-family: var(--mono); font-size: 13px; text-align: right; word-break: break-all; }
.list-row a.v { color: var(--accent); }

/* buttons */
.btn { height: 44px; padding: 0 16px; border-radius: 12px; border: 1px solid var(--line); background: transparent; font-size: 14px; font-weight: 600; display: inline-flex; align-items: center; justify-content: center; gap: 6px; white-space: nowrap; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #111214; font-weight: 700; }
.btn.outline { border-color: var(--accent); color: var(--accent); }
.btn.ghost { border-color: transparent; color: var(--accent); padding: 0 8px; }
.btn.danger { color: var(--danger); border-color: var(--line); }
.btn.block { width: 100%; }
.icon-btn { width: 44px; height: 44px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); color: var(--muted); display: inline-flex; align-items: center; justify-content: center; flex: none; }
.tag { flex: none; font-size: 12px; font-weight: 600; padding: 3px 9px; border-radius: 8px; background: var(--chip); color: var(--muted); }
.tag.client { background: var(--accent-bg); color: var(--accent); }
.pill { height: 34px; padding: 0 12px; border-radius: 17px; border: 1px solid var(--line2); background: var(--chip); color: #D6D5D0; font-size: 12px; font-weight: 600; }
.pill.extra { border-color: var(--accent); background: var(--accent-bg); color: var(--accent); }
.pill.done { color: var(--ok); background: transparent; }
.seg { display: inline-flex; gap: 4px; padding: 4px; border-radius: 12px; background: var(--surface); border: 1px solid var(--line); }
.seg button { height: 36px; padding: 0 14px; border-radius: 9px; border: 0; background: transparent; color: var(--muted); font-size: 13px; font-weight: 600; }
.seg button.on { background: #2E3036; color: var(--text); }

/* inputs */
.search { display: flex; align-items: center; gap: 8px; height: 44px; padding: 0 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); color: var(--muted); width: 300px; max-width: 100%; }
.search input { flex: 1; min-width: 0; background: transparent; border: 0; outline: 0; color: var(--text); font-size: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 13px; color: var(--muted); }
.field input, .field select, .field textarea { width: 100%; min-height: 44px; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line2); background: var(--bg); color: var(--text); font-size: 15px; }
.field textarea { min-height: 88px; resize: vertical; }
.inline-add { display: flex; gap: 8px; }
.inline-add input { flex: 1; min-width: 0; height: 44px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--line2); background: var(--bg); color: var(--text); }

/* ---------- home ---------- */
.stages { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
@media (min-width: 900px) { .stages { grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 10px; } }
.stage-cell { border-radius: 12px; padding: 10px 10px 8px; display: flex; flex-direction: column; gap: 2px; background: var(--surface); border: 1px solid var(--line); color: var(--dim); text-align: left; }
.stage-cell.has { background: var(--chip); border-color: var(--accent); color: var(--text); }
.stage-cell span { font-size: 12px; font-weight: 500; }
.stage-cell b { font-family: var(--mono); font-size: 22px; font-weight: 600; }
.todo { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); }
.todo .check { flex: none; width: 24px; height: 24px; border-radius: 12px; border: 2px solid #5A5D65; background: transparent; padding: 0; }
.todo .check:hover { border-color: var(--accent); }
.todo.is-done .text { color: var(--dim); text-decoration: line-through; }
.todo.is-done .check { border-color: var(--accent); background: var(--accent); color: #111214; display: flex; align-items: center; justify-content: center; }
.done-label { font-size: 12px; color: var(--muted); padding-top: 14px; }
.results { display: flex; flex-direction: column; }
.results a { display: flex; justify-content: space-between; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line); }
.table-box { overflow-x: auto; }
table { width: 100%; min-width: 520px; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font-size: 12px; font-weight: 500; color: var(--muted); padding: 8px 10px; }
td { padding: 12px 10px; border-top: 1px solid var(--line); }
td.mono { font-family: var(--mono); font-size: 13px; color: var(--muted); }

/* ---------- board ---------- */
.chips { display: flex; gap: 8px; overflow-x: auto; margin: 0 -20px; padding: 0 20px 4px; scrollbar-width: none; }
.chips button { flex: none; height: 44px; padding: 0 14px; border-radius: 22px; border: 1px solid var(--line); background: var(--surface); font-size: 14px; font-weight: 600; display: flex; align-items: center; gap: 6px; }
.chips button.on { background: var(--accent); border-color: var(--accent); color: #111214; }
.chips .num { font-size: 13px; opacity: .85; }
.pcard { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.pcard .t { font-size: 17px; font-weight: 700; }
.cols { display: flex; gap: 10px; overflow-x: auto; align-items: stretch; padding-bottom: 8px; }
.col { min-height: 520px; border-radius: 14px; padding: 10px; display: flex; flex-direction: column; gap: 8px; background: var(--side); border: 1px solid var(--line); flex: 1 0 210px; transition: border-color .15s; }
.col.narrow { flex: 0 0 48px; border-style: dashed; border-color: #2E3036; }
.col.narrow .vlabel { writing-mode: vertical-rl; font-size: 13px; font-weight: 600; color: var(--dim); letter-spacing: 2px; margin: 4px auto 0; }
.col.over { border-color: var(--accent); }
.col .ch { display: flex; justify-content: space-between; align-items: center; padding: 2px 4px 6px; font-size: 14px; font-weight: 700; }
.kcard { border-radius: 12px; background: var(--raised); border: 1px solid #2E3036; cursor: grab; text-align: left; padding: 14px; display: flex; flex-direction: column; gap: 6px; width: 100%; }
.kcard.sel { border-color: var(--accent); }
.kcard .t { font-size: 15px; font-weight: 700; }
.kcard .n { font-size: 13px; color: #D6D5D0; }
.board-area { position: relative; }
.peek { position: absolute; top: 0; right: 0; width: 360px; max-width: 100%; background: var(--surface); border: 1px solid #34363C; border-radius: 18px; box-shadow: 0 24px 60px rgba(0,0,0,.45); padding: 24px; display: flex; flex-direction: column; gap: 18px; z-index: 5; }

/* ---------- project ---------- */
.progress { display: grid; grid-template-columns: repeat(9, minmax(0, 1fr)); gap: 4px; }
.progress button { border: 0; background: transparent; padding: 10px 0 0; display: flex; flex-direction: column; gap: 8px; align-items: stretch; min-height: 44px; }
.progress i { display: block; height: 6px; border-radius: 3px; background: #2E3036; }
.progress .done i, .progress .cur i { background: var(--accent); }
.progress small { display: none; font-size: 12px; color: #7C7F86; text-align: center; }
.progress .done small { color: #D6D5D0; }
.progress .cur small { color: var(--accent); font-weight: 700; }
@media (min-width: 900px) { .progress { gap: 6px; } .progress small { display: block; } }
.ticket { display: flex; flex-direction: column; gap: 10px; padding: 12px 0; border-top: 1px solid var(--line); }
.timeline { display: flex; flex-direction: column; }
.ev { display: flex; gap: 12px; }
.ev .dot { display: flex; flex-direction: column; align-items: center; width: 12px; flex: none; }
.ev .dot::before { content: ''; width: 10px; height: 10px; border-radius: 5px; background: #5A5D65; margin-top: 5px; }
.ev:first-child .dot::before { background: var(--accent); }
.ev .dot::after { content: ''; flex: 1; width: 2px; background: var(--line); }
.ev .body { padding-bottom: 16px; min-width: 0; }
.ev .body div { font-size: 14px; font-weight: 500; overflow-wrap: anywhere; }
.back { font-size: 13px; color: var(--muted); display: inline-flex; align-items: center; min-height: 44px; }
.avatar { flex: none; width: 56px; height: 56px; border-radius: 28px; background: var(--accent-bg); color: var(--accent); display: flex; align-items: center; justify-content: center; font-size: 22px; font-weight: 700; }
.quick { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.quick > * { height: 60px; border-radius: 14px; border: 1px solid var(--line); background: var(--surface); font-size: 12px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; }
.quick .off { opacity: .4; pointer-events: none; }
.client-row { display: flex; align-items: center; gap: 14px; padding: 14px 0; border-top: 1px solid var(--line); }
.client-row .avatar { width: 44px; height: 44px; font-size: 17px; }

/* ---------- login ---------- */
.login { min-height: 100dvh; display: grid; place-items: center; padding: 24px; }
.login .box { width: 100%; max-width: 380px; display: flex; flex-direction: column; gap: 16px; }
.login h1 { margin: 0 0 4px; font-size: 30px; letter-spacing: -0.6px; }
.divider { display: flex; align-items: center; gap: 12px; color: var(--dim); font-size: 12px; }
.divider::before, .divider::after { content: ''; flex: 1; height: 1px; background: var(--line); }
.linkish { background: none; border: 0; color: var(--muted); font-size: 13px; padding: 10px 0; text-decoration: underline; }

/* ---------- dialog / toast ---------- */
dialog { width: min(520px, calc(100% - 24px)); max-height: calc(100dvh - 48px); background: var(--surface); color: var(--text); border: 1px solid #34363C; border-radius: 18px; padding: 0; }
dialog::backdrop { background: rgba(0,0,0,.6); }
dialog form { display: flex; flex-direction: column; gap: 14px; padding: 22px; }
dialog h3 { margin: 0 0 4px; font-size: 19px; }
dialog .actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 6px; position: sticky; bottom: 0; }
dialog .grp { font-size: 12px; color: var(--accent); font-weight: 600; margin-top: 6px; }
#toast { position: fixed; left: 50%; bottom: calc(var(--tab-h) + 24px + env(safe-area-inset-bottom)); transform: translate(-50%, 20px); opacity: 0; pointer-events: none; background: #2E3036; color: var(--text); border-radius: 12px; padding: 12px 16px; font-size: 14px; max-width: calc(100% - 32px); transition: opacity .2s, transform .2s; z-index: 100; }
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#toast.has-action { pointer-events: auto; display: flex; align-items: center; gap: 12px; padding-right: 8px; }
#toast button { border: 0; background: transparent; color: var(--accent); font-weight: 700; min-height: 36px; padding: 0 8px; }
@media (min-width: 900px) { #toast { bottom: 32px; } }
