:root {
  --bg: #f4f6f9;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --line: #e3e8ef;
  --line-strong: #cbd3de;
  --text: #1b2430;
  --text-2: #4a5565;
  --muted: #7a8494;
  --brand: #1f3a5f;
  --brand-2: #274b7a;
  --accent: #2563eb;
  --accent-soft: #e8f0fe;
  --danger: #c0392b;
  --danger-soft: #fdecea;
  --warn: #b45309;
  --warn-soft: #fef3c7;
  --ok: #15803d;
  --ok-soft: #dcfce7;
  --st-todo: #6b7280;   --st-todo-bg: #f1f3f6;
  --st-doing: #1d4ed8;  --st-doing-bg: #dbe7fe;
  --st-review: #a16207; --st-review-bg: #fdf1c7;
  --st-done: #15803d;   --st-done-bg: #d9f7e3;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  --shadow-lg: 0 12px 32px rgba(16, 24, 40, .18);
  font-family: "Pretendard", -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Malgun Gothic", "맑은 고딕", "Noto Sans KR", sans-serif;
  font-size: 14px;
  color: var(--text);
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body { background: var(--bg); line-height: 1.5; -webkit-font-smoothing: antialiased; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; line-height: 1.3; }
h1 { font-size: 20px; font-weight: 700; }
h2 { font-size: 16px; font-weight: 700; }
h3 { font-size: 14px; font-weight: 700; }
small, .muted { color: var(--muted); }
.hidden { display: none !important; }
.nowrap { white-space: nowrap; }
.num { font-variant-numeric: tabular-nums; }

/* ------------------------------------------------ top bar */
.topbar { background: var(--brand); color: #fff; position: sticky; top: 0; z-index: 30; box-shadow: 0 1px 0 rgba(0,0,0,.08); }
.topbar-inner { max-width: 1480px; margin: 0 auto; display: flex; align-items: center; gap: 18px; padding: 0 20px; height: 54px; }
.brand { color: #fff; font-weight: 700; font-size: 15px; white-space: nowrap; display: flex; align-items: center; gap: 8px; }
.brand:hover { text-decoration: none; }
.brand-mark { width: 26px; height: 26px; border-radius: 7px; background: #fff; color: var(--brand); display: grid; place-items: center; font-size: 13px; font-weight: 800; }
.nav { display: flex; gap: 2px; overflow-x: auto; flex: 1; scrollbar-width: none; }
.nav::-webkit-scrollbar { display: none; }
.nav a { color: rgba(255,255,255,.78); padding: 7px 11px; border-radius: 7px; white-space: nowrap; font-size: 13.5px; }
.nav a:hover { color: #fff; background: rgba(255,255,255,.1); text-decoration: none; }
.nav a.active { color: #fff; background: rgba(255,255,255,.18); font-weight: 600; }
.nav .sep { width: 1px; background: rgba(255,255,255,.2); margin: 8px 6px; flex: none; }
.userbox { display: flex; align-items: center; gap: 10px; white-space: nowrap; }
.userbox a { color: #fff; font-size: 13px; }
.userbox form { margin: 0; }
.userbox .btn-logout { background: transparent; border: 1px solid rgba(255,255,255,.35); color: #fff; padding: 4px 10px; border-radius: 6px; cursor: pointer; font-size: 12.5px; }
.userbox .btn-logout:hover { background: rgba(255,255,255,.12); }
.userbox .uname-m { display: none; }

.container { max-width: 1480px; margin: 0 auto; padding: 20px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 16px; flex-wrap: wrap; }
.page-head p { margin: 4px 0 0; color: var(--text-2); }

/* ------------------------------------------------ flash / toast */
.flash { padding: 10px 14px; border-radius: 8px; margin-bottom: 14px; border: 1px solid; }
.flash.info { background: var(--accent-soft); border-color: #c7d7fb; color: #1e3a8a; }
.flash.error { background: var(--danger-soft); border-color: #f5c6c0; color: #8a1f13; }
#toasts { position: fixed; right: 18px; bottom: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 100; }
.toast { background: #1b2430; color: #fff; padding: 10px 14px; border-radius: 8px; box-shadow: var(--shadow-lg); max-width: 380px; font-size: 13.5px; animation: toastIn .18s ease-out; }
.toast.error { background: #8a1f13; }
@keyframes toastIn { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ------------------------------------------------ cards & grid */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 16px 0; }
.card-body { padding: 14px 16px 16px; }
.grid { display: grid; gap: 16px; }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-main { grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); }
@media (max-width: 1100px) { .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .grid-main { grid-template-columns: 1fr; } }
@media (max-width: 640px) { .grid-4, .grid-2 { grid-template-columns: 1fr; } }

.deadline-row { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.deadline { flex: 1 1 260px; display: flex; align-items: center; gap: 14px; padding: 12px 16px; border-radius: var(--radius); background: linear-gradient(135deg, #1f3a5f, #2c5282); color: #fff; box-shadow: var(--shadow); }
.deadline .dl-left { font-size: 20px; font-weight: 800; white-space: nowrap; }
.deadline .dl-label { font-weight: 600; }
.deadline .dl-at { font-size: 12.5px; opacity: .8; }
.deadline.urgent { background: linear-gradient(135deg, #8a1f13, #c0392b); }

.stat-card a.stat-title { color: var(--text); font-weight: 700; }
.stat-big { font-size: 26px; font-weight: 800; letter-spacing: -.5px; }
.stat-sub { color: var(--text-2); font-size: 12.5px; }
.progress { height: 8px; background: #edf0f4; border-radius: 99px; overflow: hidden; display: flex; margin: 10px 0 8px; }
.progress > span { display: block; height: 100%; }
.progress .p-done { background: var(--st-done); }
.progress .p-review { background: #e0a800; }
.progress .p-doing { background: #3b82f6; }
.legend { display: flex; flex-wrap: wrap; gap: 4px 10px; font-size: 12px; color: var(--text-2); }
.legend a { color: inherit; }
.legend i { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 4px; vertical-align: 0; }
.alerts { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.alert-chip { font-size: 12px; padding: 2px 8px; border-radius: 99px; background: var(--warn-soft); color: var(--warn); }
.alert-chip.red { background: var(--danger-soft); color: var(--danger); }
.alert-chip:hover { text-decoration: none; filter: brightness(.97); }

.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; gap: 10px; align-items: flex-start; padding: 9px 0; border-top: 1px solid var(--line); }
.list li:first-child { border-top: 0; }
.list .grow { flex: 1; min-width: 0; }
.list .title { font-weight: 600; color: var(--text); display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list .title:hover { color: var(--accent); }
.list .meta { font-size: 12px; color: var(--muted); }
.empty { color: var(--muted); padding: 18px 0; text-align: center; }

.tbl { width: 100%; border-collapse: collapse; }
.tbl th, .tbl td { text-align: left; padding: 8px 10px; border-top: 1px solid var(--line); vertical-align: top; }
.tbl th { font-size: 12px; color: var(--text-2); font-weight: 600; background: var(--surface-2); border-top: 0; }
.tbl td.r, .tbl th.r { text-align: right; }

/* ------------------------------------------------ status pills, chips */
.pill { display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; border-radius: 99px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.st-todo { color: var(--st-todo); background: var(--st-todo-bg); }
.st-doing { color: var(--st-doing); background: var(--st-doing-bg); }
.st-review { color: var(--st-review); background: var(--st-review-bg); }
.st-done { color: var(--st-done); background: var(--st-done-bg); }
.dday { font-size: 11.5px; font-weight: 700; padding: 1px 6px; border-radius: 5px; background: #eef1f5; color: var(--text-2); white-space: nowrap; }
.dday.over { background: var(--danger-soft); color: var(--danger); }
.dday.soon { background: var(--warn-soft); color: var(--warn); }
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 1px 8px 1px 3px; border-radius: 99px; background: #eef2f7; color: var(--text); font-size: 12.5px; white-space: nowrap; max-width: 100%; }
.chip .av { width: 18px; height: 18px; border-radius: 50%; background: var(--brand-2); color: #fff; display: grid; place-items: center; font-size: 10.5px; font-weight: 700; flex: none; }
.chip.org-w .av { background: #7c3aed; }
.chip.org-x .av { background: #64748b; }
.chip.me { background: var(--accent-soft); box-shadow: inset 0 0 0 1px #bcd0fb; }
.chip.inactive { opacity: .55; text-decoration: line-through; }
.chip button { border: 0; background: none; padding: 0 0 0 2px; cursor: pointer; color: var(--muted); font-size: 14px; line-height: 1; }
.chip button:hover { color: var(--danger); }
.chips { display: flex; flex-wrap: wrap; gap: 4px; }
.badge { display: inline-block; font-size: 11px; padding: 1px 6px; border-radius: 5px; background: #eef1f5; color: var(--text-2); white-space: nowrap; }
.badge.blue { background: var(--accent-soft); color: #1e40af; }
.badge.green { background: var(--ok-soft); color: var(--ok); }
.badge.gray { background: #f1f3f6; color: var(--muted); }

/* ------------------------------------------------ buttons & forms */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 34px; padding: 0 14px; border-radius: 8px; border: 1px solid var(--line-strong); background: #fff; color: var(--text); font: inherit; font-size: 13.5px; font-weight: 600; cursor: pointer; white-space: nowrap; }
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn:disabled { opacity: .5; cursor: default; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: #1d4ed8; }
.btn-danger { color: var(--danger); border-color: #f0c2bc; }
.btn-danger:hover { background: var(--danger-soft); }
.btn-sm { height: 28px; padding: 0 10px; font-size: 12.5px; border-radius: 7px; }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-ghost:hover { background: #eef1f5; }
.btn-link { border: 0; background: none; color: var(--accent); cursor: pointer; font: inherit; padding: 0; }
.btn-link:hover { text-decoration: underline; }
.btn-link.danger { color: var(--danger); }

input[type=text], input[type=email], input[type=search], input[type=date], input[type=number], select, textarea {
  font: inherit; color: var(--text); background: #fff; border: 1px solid var(--line-strong); border-radius: 8px; padding: 7px 10px; min-height: 34px; width: 100%;
}
textarea { resize: vertical; min-height: 70px; line-height: 1.5; }
input:focus, select:focus, textarea:focus { outline: 2px solid #bcd0fb; border-color: var(--accent); }
label.field { display: block; margin-bottom: 12px; }
label.field > span { display: block; font-size: 12.5px; font-weight: 600; color: var(--text-2); margin-bottom: 4px; }
.form-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.form-row > * { flex: 1 1 160px; }
.form-row > .btn { flex: 0 0 auto; }

/* ------------------------------------------------ board */
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 12px; }
.toolbar .search { flex: 1 1 220px; max-width: 340px; }
.toolbar select { width: auto; min-width: 130px; }
.seg { display: inline-flex; background: #e9edf2; border-radius: 9px; padding: 3px; gap: 2px; flex-wrap: wrap; }
.seg button { border: 0; background: transparent; padding: 5px 10px; border-radius: 7px; font: inherit; font-size: 13px; color: var(--text-2); cursor: pointer; white-space: nowrap; }
.seg button.on { background: #fff; color: var(--text); font-weight: 700; box-shadow: var(--shadow); }
.seg button .cnt { color: var(--muted); font-weight: 500; margin-left: 3px; font-size: 12px; }
.summary { color: var(--text-2); font-size: 13px; margin: 0 0 10px; display: flex; gap: 14px; flex-wrap: wrap; }
.summary b { color: var(--text); }
.live { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; color: var(--muted); }
.live::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: #22c55e; box-shadow: 0 0 0 3px rgba(34,197,94,.18); }

.table-wrap { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: auto; max-height: calc(100vh - 210px); }
table.board { width: 100%; border-collapse: separate; border-spacing: 0; min-width: 980px; }
table.board th { position: sticky; top: 0; z-index: 2; background: var(--surface-2); text-align: left; font-size: 12px; font-weight: 700; color: var(--text-2); padding: 9px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.board td { padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: top; font-size: 13.5px; }
table.board tr.row { cursor: pointer; }
table.board tr.row:hover td { background: #f7faff; }
table.board tr.row.mine td:first-child { box-shadow: inset 3px 0 0 var(--accent); }
table.board tr.row.flash td { animation: rowFlash 1.6s ease-out; }
@keyframes rowFlash { from { background: #fff7d1; } to { background: transparent; } }
table.board tr.group td { background: #eef2f7; font-weight: 700; color: var(--brand); font-size: 13px; padding: 7px 10px; position: sticky; top: 36px; z-index: 1; }
table.board tr.group .gcount { font-weight: 500; color: var(--muted); margin-left: 6px; font-size: 12px; }
.clamp { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; white-space: pre-line; }
.cell-title { font-weight: 600; }
.cell-sub { color: var(--muted); font-size: 12px; margin-top: 2px; }
.note-cell { color: var(--text-2); font-size: 12.5px; }
.note-cell .ncount { display: inline-block; font-size: 11px; font-weight: 700; color: var(--accent); background: var(--accent-soft); border-radius: 5px; padding: 0 5px; margin-right: 4px; }
select.status-select { width: auto; min-height: 28px; height: 28px; padding: 0 22px 0 9px; border-radius: 99px; font-size: 12.5px; font-weight: 700; border: 0; cursor: pointer; appearance: none; -webkit-appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, currentColor 50%), linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position: right 10px center, right 6px center; background-size: 4px 4px, 4px 4px; background-repeat: no-repeat; }
select.status-select.st-todo { background-color: var(--st-todo-bg); color: var(--st-todo); }
select.status-select.st-doing { background-color: var(--st-doing-bg); color: var(--st-doing); }
select.status-select.st-review { background-color: var(--st-review-bg); color: var(--st-review); }
select.status-select.st-done { background-color: var(--st-done-bg); color: var(--st-done); }
select.status-select option { background: #fff; color: var(--text); }
.unassigned { color: var(--muted); font-size: 12.5px; }

/* ------------------------------------------------ drawer */
.overlay { position: fixed; inset: 0; background: rgba(15, 23, 42, .28); z-index: 40; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(620px, 100vw); background: var(--surface); z-index: 50; box-shadow: var(--shadow-lg); display: flex; flex-direction: column; animation: drawerIn .16s ease-out; }
@keyframes drawerIn { from { transform: translateX(24px); opacity: .6; } to { transform: none; opacity: 1; } }
.drawer-head { padding: 16px 20px 12px; border-bottom: 1px solid var(--line); display: flex; gap: 12px; align-items: flex-start; }
.drawer-head .grow { flex: 1; min-width: 0; }
.drawer-head .kicker { font-size: 12px; color: var(--muted); }
.drawer-head h2 { font-size: 17px; margin-top: 2px; word-break: keep-all; }
.drawer-body { flex: 1; overflow-y: auto; padding: 16px 20px 28px; }
.drawer-foot { padding: 12px 20px; border-top: 1px solid var(--line); display: flex; justify-content: space-between; gap: 10px; background: var(--surface-2); }
.dsec { margin-bottom: 22px; }
.dsec > h3 { margin-bottom: 10px; display: flex; align-items: center; gap: 8px; }
.dsec > h3 .hint { font-weight: 400; color: var(--muted); font-size: 12px; }
.kv { display: grid; grid-template-columns: 92px 1fr; gap: 10px 12px; align-items: center; }
.kv > .k { font-size: 12.5px; color: var(--text-2); font-weight: 600; }
.status-seg { display: flex; gap: 6px; flex-wrap: wrap; }
.status-seg button { border: 1px solid var(--line-strong); background: #fff; border-radius: 99px; padding: 4px 12px; font: inherit; font-size: 13px; cursor: pointer; color: var(--text-2); }
.status-seg button.on.st-todo { background: var(--st-todo-bg); color: var(--st-todo); border-color: transparent; font-weight: 700; }
.status-seg button.on.st-doing { background: var(--st-doing-bg); color: var(--st-doing); border-color: transparent; font-weight: 700; }
.status-seg button.on.st-review { background: var(--st-review-bg); color: var(--st-review); border-color: transparent; font-weight: 700; }
.status-seg button.on.st-done { background: var(--st-done-bg); color: var(--st-done); border-color: transparent; font-weight: 700; }
.picker { position: relative; margin-top: 8px; }
.picker-list { position: absolute; left: 0; right: 0; top: calc(100% + 4px); background: #fff; border: 1px solid var(--line-strong); border-radius: 8px; box-shadow: var(--shadow-lg); max-height: 260px; overflow-y: auto; z-index: 5; }
.picker-list button { display: flex; width: 100%; text-align: left; gap: 8px; align-items: center; padding: 8px 10px; border: 0; background: none; font: inherit; cursor: pointer; }
.picker-list button:hover, .picker-list button.hl { background: var(--accent-soft); }
.picker-list .pe { color: var(--muted); font-size: 12px; }
.picker-list .new { color: var(--accent); font-weight: 600; border-top: 1px solid var(--line); }
.note { padding: 10px 12px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px; margin-bottom: 8px; }
.note-meta { display: flex; justify-content: space-between; gap: 8px; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.note-meta b { color: var(--text); font-weight: 600; }
.note-body { white-space: pre-wrap; word-break: break-word; }
.note-actions { display: flex; gap: 10px; }
.history { list-style: none; margin: 0; padding: 0; font-size: 12.5px; }
.history li { padding: 7px 0; border-top: 1px dashed var(--line); color: var(--text-2); }
.history li:first-child { border-top: 0; }
.history .h-meta { color: var(--muted); font-size: 11.5px; }
.history .old { color: var(--muted); text-decoration: line-through; }
.history .new { color: var(--text); }
.conflict { background: var(--warn-soft); color: var(--warn); border-radius: 8px; padding: 8px 12px; margin-bottom: 12px; font-size: 13px; display: flex; justify-content: space-between; gap: 10px; align-items: center; }

/* ------------------------------------------------ login */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: radial-gradient(1200px 600px at 20% -10%, #dbe7fe 0%, transparent 60%), var(--bg); }
.auth-card { width: min(420px, 100%); padding: 30px 28px; }
.auth-card .brand-mark { width: 40px; height: 40px; font-size: 17px; background: var(--brand); color: #fff; border-radius: 11px; margin-bottom: 14px; }
.auth-card h1 { font-size: 19px; margin-bottom: 6px; }
.auth-card p.lead { color: var(--text-2); margin: 0 0 20px; font-size: 13.5px; }
.auth-card .btn { width: 100%; height: 42px; font-size: 14.5px; }
.code-input { font-size: 26px !important; letter-spacing: 10px; text-align: center; font-weight: 700; font-variant-numeric: tabular-nums; height: 54px; }
.auth-foot { margin-top: 16px; font-size: 12.5px; color: var(--muted); }
.auth-links { display: flex; justify-content: space-between; margin-top: 14px; font-size: 13px; }
.auth-links form { margin: 0; }

/* ------------------------------------------------ log */
.log-filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; align-items: center; }
.log-filters select, .log-filters input[type=search] { width: auto; min-width: 150px; }
.diff-old { color: var(--muted); text-decoration: line-through; white-space: pre-wrap; word-break: break-word; }
.diff-new { white-space: pre-wrap; word-break: break-word; }
.pager { display: flex; gap: 6px; justify-content: center; margin-top: 14px; align-items: center; }

/* ------------------------------------------------ members */
.member-row form { margin: 0; }
.inline-form { display: flex; gap: 6px; align-items: center; }
.inline-form input, .inline-form select { min-height: 30px; padding: 4px 8px; }

@media (max-width: 760px) {
  .topbar-inner { padding: 0 12px; gap: 10px; }
  .brand .brand-text { display: none; }
  .userbox .uname { display: none; }
  .userbox .uname-m { display: inline; }
  .container { padding: 14px 12px; }
  .table-wrap { max-height: none; }
  .kv { grid-template-columns: 1fr; gap: 4px; }
  .kv > .k { margin-top: 6px; }
  /* board rows become cards */
  table.board { min-width: 0; }
  table.board thead { display: none; }
  table.board, table.board tbody, table.board tr, table.board td { display: block; width: 100%; }
  table.board tr.row { padding: 10px 12px 12px; border-bottom: 1px solid var(--line); }
  table.board tr.row td { border: 0; padding: 3px 0; }
  table.board tr.row td:empty { display: none; }
  table.board tr.row td[data-label]::before { content: attr(data-label); display: block; font-size: 11px; color: var(--muted); font-weight: 600; margin-top: 2px; }
  table.board tr.row td.cell-title::before, table.board tr.row td:first-child::before { display: none; }
  table.board tr.row td:first-child { font-size: 14.5px; }
  table.board tr.row.mine td:first-child { box-shadow: none; }
  table.board tr.row.mine { box-shadow: inset 3px 0 0 var(--accent); }
  table.board tr.group td { position: static; }
  .toolbar .search { max-width: none; }
}
