:root {
  --bg: #ffffff;
  --panel: #f6f7f8;
  --line: #e4e6e8;
  --text: #161616;
  --muted: #6b7280;
  --red: #cf2424;
  --red-dark: #9f1d1d;
  --red-soft: #fde8e8;
  --green: #16803a;
  --blue: #2563eb;
  --amber: #b45309;
  --radius: 8px;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--text); font-family: "Segoe UI", "Noto Sans KR", Arial, sans-serif; font-size: 14px; line-height: 1.45; }
button, input, select, textarea { font: inherit; }
input, select, textarea { width: 100%; border: 1px solid var(--line); border-radius: var(--radius); padding: 9px 10px; background: #fff; color: var(--text); }
textarea { resize: vertical; }
button { cursor: pointer; }
a { color: var(--blue); word-break: break-all; }
ul { list-style: none; margin: 0; padding: 0; }
h1, h2, h3, p { margin: 0; }
h1 { font-size: 24px; line-height: 1.25; }
h2 { font-size: 17px; }
h3 { font-size: 14px; }
.muted { color: var(--muted); font-size: 12px; }
.preline { white-space: pre-wrap; word-break: break-word; }
.grow { flex: 1; min-width: 0; }
.row { display: flex; align-items: center; }
.gap8 { gap: 8px; }
.wrap { flex-wrap: wrap; }
.mobile-only { display: none; }

.topbar { height: 52px; display: flex; align-items: center; gap: 12px; padding: 0 16px; background: #111; color: #fff; position: sticky; top: 0; z-index: 40; }
.brand { font-size: 17px; font-weight: 700; }
.top-user { margin-left: auto; display: flex; align-items: center; gap: 8px; min-width: 0; }
.icon-btn { border: 0; background: transparent; color: inherit; font-size: 20px; padding: 4px; }

.layout { display: grid; grid-template-columns: 270px minmax(0, 1fr); min-height: calc(100vh - 52px); }
.sidebar { border-right: 1px solid var(--line); background: var(--panel); padding: 14px; }
.sidebar-backdrop { display: none; }
.side-panel { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; margin-bottom: 12px; }
.side-label { font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.side-title { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 10px; font-weight: 700; }
.group-list { display: flex; flex-direction: column; gap: 6px; }
.group-item { display: flex; justify-content: space-between; gap: 8px; padding: 10px; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; cursor: pointer; min-width: 0; }
.group-item.active { border-color: var(--red); background: var(--red-soft); color: var(--red-dark); }
.group-item small { color: var(--muted); }
.group-label { display: inline-flex; align-items: center; gap: 6px; min-width: 0; }
.count-badge { display: inline-flex; align-items: center; justify-content: center; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px; background: var(--red); color: #fff; font-size: 11px; line-height: 1; }

.main { padding: 18px 18px 72px; min-width: 0; }
.group-header { display: block; border-bottom: 1px solid var(--line); padding-bottom: 14px; margin-bottom: 16px; }
.group-heading { min-width: 0; }
.group-desc { color: var(--muted); margin-top: 4px; }
.group-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: flex-start; }
.work-surface { display: grid; grid-template-columns: minmax(0, 1.45fr) minmax(360px, .75fr); gap: 16px; align-items: start; }
.tasks-section, .detail-section { min-width: 0; }
.section-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 10px; }
.filter { width: 150px; }
.schedule-rail { display: flex; gap: 7px; overflow-x: auto; padding: 8px 2px 12px; margin-bottom: 14px; scrollbar-width: thin; }
.schedule-chip { flex: 0 0 64px; min-height: 58px; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; color: var(--text); display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 1px; padding: 5px; }
.schedule-chip.all { flex-basis: 54px; font-weight: 700; position: sticky; left: 0; z-index: 2; box-shadow: 5px 0 8px rgba(255,255,255,.9); }
.schedule-chip.month-nav { color: var(--red-dark); border-color: #fecaca; font-weight: 700; }
.schedule-chip.active { border-color: var(--red); background: var(--red-soft); color: var(--red-dark); }
.schedule-chip.holiday { border-color: #fecaca; color: var(--red-dark); }
.schedule-chip.holiday .schedule-day, .schedule-chip.holiday .schedule-count { color: var(--red-dark); }
.schedule-chip.has-task { box-shadow: inset 0 -3px 0 var(--red); }
.schedule-day { color: var(--muted); font-size: 11px; }
.schedule-chip strong { font-size: 18px; line-height: 1; }
.schedule-count { color: var(--muted); font-size: 11px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; color: var(--text); padding: 8px 12px; text-decoration: none; min-height: 36px; }
.btn:hover { background: #f9fafb; }
.btn-primary { background: var(--red); border-color: var(--red); color: #fff; }
.btn-primary:hover { background: var(--red-dark); }
.btn.is-loading { opacity: .78; cursor: wait; }
.btn-danger { color: var(--red); border-color: #efb4b4; }
.btn-dark { background: #222; border-color: #333; color: #fff; }
.btn-sm { padding: 5px 9px; min-height: 30px; font-size: 12px; }
.btn-block { width: 100%; margin-top: 14px; }

.role-tag, .badge { display: inline-flex; align-items: center; width: fit-content; border-radius: 999px; border: 1px solid var(--line); padding: 2px 8px; font-size: 11px; font-weight: 700; white-space: nowrap; }
.role-tag.owner { background: #fee2e2; color: #991b1b; border-color: #fecaca; }
.role-tag.admin { background: #dbeafe; color: #1d4ed8; border-color: #bfdbfe; }
.role-tag.member { background: #dcfce7; color: #166534; border-color: #bbf7d0; }
.role-tag.viewer, .role-tag.none { background: #f1f5f9; color: #475569; }
.badge.s-todo { background: #f1f5f9; color: #334155; }
.badge.s-acknowledged { background: #e0f2fe; color: #075985; }
.badge.s-in_progress { background: #fef3c7; color: #92400e; }
.badge.s-waiting_material, .badge.s-waiting_reply, .badge.s-waiting_approval, .badge.s-revise_requested { background: #ffedd5; color: #9a3412; }
.badge.s-done { background: #dcfce7; color: #166534; }
.badge.s-hold { background: #eeeeee; color: #525252; }
.badge.p-urgent, .badge.p-high { background: #fee2e2; color: #991b1b; }
.badge.p-normal { background: #f1f5f9; color: #334155; }
.badge.p-low { background: #f8fafc; color: #64748b; }

.tasks-table { width: 100%; border-collapse: separate; border-spacing: 0; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: #fff; }
.tasks-table th, .tasks-table td { padding: 10px 9px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; font-size: 13px; }
.tasks-table th { background: var(--panel); color: var(--muted); font-size: 12px; }
.tasks-table tr:last-child td { border-bottom: 0; }
.action-cell { display: flex; flex-wrap: wrap; gap: 5px; }
.comment-btn.has-new { border-color: var(--red); color: var(--red-dark); background: var(--red-soft); }
.tasks-mobile { display: none; flex-direction: column; gap: 10px; }
.task-card, .item-card { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; }
.task-card { display: flex; flex-direction: column; gap: 8px; }
.card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.meta-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; color: var(--muted); font-size: 12px; }
.meta-grid > span:not(.badge) { display: inline-flex; align-items: center; gap: 4px; width: fit-content; min-width: 84px; max-width: 100%; padding: 3px 8px; border-radius: 999px; background: #f8fafc; border: 1px solid var(--line); color: #475569; font-weight: 700; white-space: nowrap; }
.mobile-actions { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 12px; overflow-x: auto; }
.tab { border: 0; background: transparent; padding: 10px 12px; color: var(--muted); border-bottom: 2px solid transparent; white-space: nowrap; }
.tab.active { color: var(--red); border-bottom-color: var(--red); font-weight: 700; }
.mobile-ai-tab { display: none; }
.tab-panel { border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; background: #fff; min-height: 430px; margin-bottom: 48px; }
.note-writer, .admin-box { border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; margin-bottom: 12px; background: #fff; display: flex; flex-direction: column; gap: 8px; min-width: 0; overflow: hidden; }
.tab-panel .note-writer, .tab-panel .admin-box { background: #fafafa; }
.stack-list { display: flex; flex-direction: column; gap: 9px; }
.member-card { display: flex; align-items: center; gap: 8px; }
.member-card select { width: 130px; }
.crew-strip { min-height: 74px; display: flex; align-items: flex-end; align-content: flex-end; gap: 14px; flex-wrap: wrap; margin-top: 10px; padding: 10px 12px 16px; border: 1px dashed var(--line); border-radius: var(--radius); background: #fff; overflow: hidden; }
.crew-strip.drop-ready { border-color: var(--red); background: var(--red-soft); }
.crew-pool { display: grid; grid-template-columns: repeat(auto-fill, minmax(132px, 1fr)); gap: 12px; align-items: end; overflow: visible; min-width: 0; }
.crew-pool.compact { padding-top: 4px; }
.crew-empty { color: var(--muted); font-size: 12px; align-self: center; white-space: normal; word-break: keep-all; }
.crew-avatar { width: 62px; min-height: 78px; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 3px; user-select: none; justify-self: center; position: relative; min-width: 0; }
.crew-avatar.has-actions { width: 100%; max-width: 112px; min-height: 136px; border: 1px solid var(--line); border-radius: var(--radius); padding: 8px 6px; background: #fff; }
.crew-avatar[draggable="true"] { cursor: grab; }
.crew-avatar[draggable="true"]:active { cursor: grabbing; }
.crew-name { max-width: 100%; min-height: 18px; font-size: 12px; font-weight: 700; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--text); }
.crew-role { max-width: 100%; border: 1px solid var(--line); border-radius: 999px; padding: 1px 6px; font-size: 10px; font-weight: 700; color: var(--muted); background: #fff; line-height: 1.4; }
.crew-role.admin { background: #dbeafe; color: #1d4ed8; border-color: #bfdbfe; }
.crew-role.member { background: #dcfce7; color: #166534; border-color: #bbf7d0; }
.crew-role.viewer { background: #f1f5f9; color: #475569; }
.crew-img { width: 42px; height: 42px; object-fit: contain; display: block; filter: drop-shadow(0 3px 5px rgba(0,0,0,.12)); }
.crew-avatar.has-actions .crew-img { width: 50px; height: 50px; }
.crew-body { position: relative; width: 44px; height: 58px; border-radius: 20px 20px 14px 14px; background: var(--crew-color); border: 2px solid #111; box-shadow: inset -5px -8px 0 rgba(0,0,0,.16); }
.crew-visor { position: absolute; top: 11px; right: 5px; width: 25px; height: 15px; border-radius: 999px; background: #bde7f3; border: 2px solid #111; box-shadow: inset -4px -3px 0 rgba(0,0,0,.12); }
.crew-pack { position: absolute; left: -10px; top: 22px; width: 13px; height: 25px; border-radius: 8px 0 0 8px; background: var(--crew-color); border: 2px solid #111; border-right: 0; }
.crew-headgear { position: absolute; left: 9px; top: -14px; width: 25px; height: 14px; display: none; }
.crew-mark { position: absolute; display: none; }
.crew-avatar.v0 .crew-mark { display: block; right: -6px; top: 22px; width: 12px; height: 8px; border-radius: 0 8px 8px 0; background: #f59e0b; border: 2px solid #111; border-left: 0; }
.crew-avatar.v1 .crew-headgear { display: block; border-radius: 12px 12px 2px 2px; background: #111; }
.crew-avatar.v2 .crew-headgear { display: block; top: -13px; left: 14px; width: 14px; height: 14px; border-radius: 50%; background: #facc15; border: 2px solid #111; }
.crew-avatar.v3 .crew-body { border-radius: 14px 24px 14px 14px; }
.crew-avatar.v3 .crew-mark { display: block; right: 6px; bottom: 14px; width: 9px; height: 9px; border-radius: 50%; background: rgba(255,255,255,.75); border: 1px solid #111; }
.crew-avatar.v4 .crew-visor { right: 10px; width: 20px; height: 20px; }
.crew-avatar.v4 .crew-headgear { display: block; top: -12px; left: 6px; width: 32px; height: 10px; border-radius: 999px; background: #fff; border: 2px solid #111; }
.crew-avatar.v5 .crew-body { height: 54px; width: 48px; border-radius: 24px 17px 14px 14px; }
.crew-avatar.v5 .crew-mark { display: block; left: 8px; bottom: 12px; width: 16px; height: 5px; border-radius: 999px; background: rgba(0,0,0,.18); }
.crew-leg { position: absolute; bottom: -11px; width: 15px; height: 16px; background: var(--crew-color); border: 2px solid #111; border-top: 0; border-radius: 0 0 7px 7px; }
.crew-leg.left { left: 7px; }
.crew-leg.right { right: 7px; }
.crew-actions { display: flex; flex-direction: column; gap: 5px; margin-top: 6px; width: 100%; align-items: stretch; min-width: 0; }
.crew-actions select { width: 100%; min-width: 0; padding: 5px 6px; font-size: 12px; }
.crew-actions .btn { width: 100%; min-width: 0; padding-left: 6px; padding-right: 6px; white-space: normal; line-height: 1.2; word-break: keep-all; }
.ops-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.ops-tabs { margin-bottom: 12px; }
.ops-panel[hidden] { display: none; }
.ai-results-section { margin-top: 16px; border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; background: #fff; }
.inline-ai { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); }
.section-mini-title { font-size: 13px; font-weight: 700; margin-bottom: 8px; color: var(--muted); }
.pager { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; margin-top: 10px; }
.page-btn.active { background: var(--red); color: #fff; border-color: var(--red); }
.avatar-picker { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.avatar-picker-title { color: var(--muted); font-size: 12px; font-weight: 700; }
.avatar-grid { display: flex; gap: 8px; overflow-x: auto; overflow-y: hidden; padding: 2px 2px 8px; max-width: 100%; }
.avatar-option { width: 54px; height: 54px; border: 1px solid var(--line); border-radius: var(--radius); display: grid; place-items: center; background: #fff; cursor: pointer; }
.avatar-option { flex: 0 0 54px; }
.avatar-option.selected { border-color: var(--red); box-shadow: inset 0 0 0 2px var(--red-soft); }
.avatar-option input { position: absolute; opacity: 0; pointer-events: none; width: 1px; height: 1px; }
.avatar-option img { width: 46px; height: 46px; object-fit: contain; display: block; }
.compact-picker .avatar-grid { gap: 6px; }
.compact-picker .avatar-option { width: 46px; height: 46px; }
.compact-picker .avatar-option { flex-basis: 46px; }
.compact-picker .avatar-option img { width: 39px; height: 39px; }
.comment-list { max-height: 42vh; overflow: auto; padding-right: 2px; }
.comment-card .card-head { margin-bottom: 6px; }
.user-admin-card { display: flex; flex-direction: column; gap: 10px; }
.user-admin-head { display: flex; flex-direction: column; gap: 2px; }
.user-admin-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.user-admin-grid label span { display: block; color: var(--muted); font-size: 12px; margin-bottom: 4px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.ai-candidate { border: 1px dashed #d1d5db; border-radius: var(--radius); padding: 10px; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-top: 8px; }
.ai-candidate label span { display: block; color: var(--muted); font-size: 12px; margin-bottom: 4px; }
.ai-candidate .full { grid-column: 1 / -1; }
.questions { list-style: disc; padding-left: 20px; color: var(--muted); }
.applied { opacity: .72; }
.empty { color: var(--muted); text-align: center; padding: 18px; white-space: normal; word-break: keep-all; }
.notice { border: 1px solid #fed7aa; background: #fff7ed; color: #9a3412; border-radius: var(--radius); padding: 9px 10px; font-size: 12px; }
.source-note { margin-top: 8px; border: 1px solid var(--line); border-radius: var(--radius); background: #fafafa; padding: 8px 10px; }
.source-note summary { cursor: pointer; color: var(--red-dark); font-weight: 700; }
.source-note p { margin-top: 8px; max-height: 260px; overflow: auto; color: #374151; }
.note-preview { max-height: 7.5em; overflow: hidden; color: #374151; }

.modal { position: fixed; inset: 0; z-index: 100; background: rgba(17, 24, 39, .45); display: flex; align-items: center; justify-content: center; padding: 18px; }
.modal[hidden] { display: none; }
.modal-card { width: min(100%, 520px); max-height: 90vh; overflow: auto; background: #fff; border-radius: var(--radius); padding: 18px; display: flex; flex-direction: column; gap: 8px; }
.modal-card.wide { width: min(100%, 680px); }
.ops-modal { width: min(100%, 760px); max-height: 88vh; overflow: auto; }
.ops-modal #userCreateBox { position: static; box-shadow: none; }
.ops-modal #userManageList { max-height: 56vh; overflow: auto; padding-right: 2px; }
.modal-card label { font-size: 12px; color: var(--muted); }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 200; background: #111; color: #fff; border-radius: var(--radius); padding: 10px 14px; box-shadow: 0 10px 30px rgba(0,0,0,.2); max-width: 92vw; }

.login-body { min-height: 100vh; display: grid; place-items: center; background: var(--panel); padding: 18px; }
.login-card { width: min(100%, 380px); background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; display: flex; flex-direction: column; gap: 10px; }
.login-card h1 { color: var(--red); }
.login-card label { font-size: 12px; color: var(--muted); margin-top: 4px; }

@media (max-width: 1080px) {
  .work-surface { grid-template-columns: 1fr; }
}
@media (max-width: 820px) {
  .mobile-only { display: inline-flex; }
  .top-user #currentUserLabel { display: none; }
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: fixed; top: 52px; bottom: 0; left: 0; width: 84vw; max-width: 320px; z-index: 60; transform: translateX(-102%); transition: transform .16s ease; box-shadow: 10px 0 24px rgba(0,0,0,.12); }
  .sidebar.open { transform: translateX(0); }
  .sidebar-backdrop { position: fixed; top: 52px; right: 0; bottom: 0; left: 0; z-index: 50; background: rgba(17,24,39,.28); display: block; }
  .sidebar-backdrop[hidden] { display: none; }
  .main { padding: 14px 14px 96px; }
  .group-header { margin-bottom: 8px; padding-bottom: 8px; }
  .group-kicker, .group-desc { display: none; }
  .group-heading h1 { font-size: 22px; }
  .work-surface { display: flex; flex-direction: column; gap: 14px; }
  .detail-section { order: -1; }
  .group-header { flex-direction: column; align-items: stretch; }
  .section-head { flex-direction: row; align-items: center; gap: 8px; }
  .section-head h2 { white-space: nowrap; }
  .section-head .row { flex: 1; justify-content: flex-end; }
  .section-head .btn { padding-left: 9px; padding-right: 9px; }
  .crew-strip { min-height: 68px; gap: 10px; padding: 8px; margin-top: 8px; }
  .crew-pool { grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); gap: 10px; }
  .crew-avatar { width: 58px; min-height: 82px; }
  .crew-avatar.has-actions { width: 100%; max-width: 112px; min-height: 142px; }
  .crew-img { width: 48px; height: 48px; }
  .crew-avatar.has-actions .crew-img { width: 54px; height: 54px; }
  .avatar-grid { display: flex; }
  .crew-body { width: 36px; height: 50px; border-radius: 17px 17px 12px 12px; }
  .crew-visor { width: 21px; height: 13px; }
  .crew-name { max-width: 66px; font-size: 11px; }
  .schedule-chip { flex-basis: 58px; min-height: 54px; }
  .schedule-rail { margin-bottom: 10px; padding-top: 4px; padding-bottom: 10px; }
  .tasks-pc { display: none; }
  .tasks-mobile { display: flex; }
  body:not([data-active-tab="notes"]) .tasks-section { display: none; }
  .tasks-section, .detail-section, .tab-panel, .note-writer, .tasks-mobile, .task-card, .item-card { width: 100%; }
  .tab-panel { min-height: 0; margin-bottom: 72px; }
  .tasks-section { order: 0; }
  .detail-section { order: -1; }
  .tasks-section .section-head { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; }
  .tasks-section .section-head .row { display: grid; grid-template-columns: minmax(108px, 1fr) auto; justify-content: stretch; }
  .tasks-section .filter, .tasks-section .btn-primary { width: 100%; min-height: 44px; }
  .tasks-mobile .empty { min-height: 90px; display: grid; place-items: center; font-size: 18px; }
  .task-card { padding: 14px; }
  .task-card .card-head strong { font-size: 16px; line-height: 1.35; }
  .meta-grid { gap: 8px; font-size: 13px; }
  .meta-grid > span:not(.badge) { min-width: 96px; padding: 5px 9px; color: #334155; }
  .mobile-ai-tab { display: inline-flex; }
  .desktop-ai-results { display: none; }
  #noteList { display: none; }
  #panel-ai .source-note p { max-height: 210px; }
  .mobile-actions { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .form-grid { grid-template-columns: 1fr; }
  .ai-candidate { grid-template-columns: 1fr 1fr; padding: 8px; gap: 6px; }
  .ai-candidate label span { font-size: 11px; margin-bottom: 2px; }
  .ai-candidate input, .ai-candidate select { padding: 7px 8px; font-size: 13px; }
  .note-writer { padding: 10px; }
  .tabs { margin-bottom: 10px; }
  .tab { padding: 9px 10px; }
  .ai-results-section { margin-top: 14px; padding: 10px; }
  .user-admin-grid { grid-template-columns: 1fr; }
  .filter { width: min(100%, 120px); }
}
