:root {
  --brand: #1f2b6c;
  --brand-2: #273889;
  --brand-soft: #eef1fb;
  --text: #14203b;
  --muted: #667085;
  --line: #dfe5ef;
  --line-soft: #edf1f6;
  --page: #f7f9fc;
  --card: #ffffff;
  --danger: #dc2626;
  --leave: #21c55d;
  --trip: #ff8a00;
  --meeting: #2463df;
  --deadline: #f04444;
  --other: #7c3aed;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; font-family: Inter, Pretendard, "Noto Sans KR", "Apple SD Gothic Neo", Arial, sans-serif; color: var(--text); background: var(--page); }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

.login-screen { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: radial-gradient(circle at 50% 0%, #ffffff 0, #f7f9fc 48%, #eef2f8 100%); }
.login-card { width: min(420px, 100%); background: #fff; border: 1px solid var(--line); border-radius: 18px; padding: 40px 36px 34px; text-align: center; box-shadow: 0 18px 55px rgba(31,43,108,.10); }
.login-logo { width: 210px; max-width: 80%; height: auto; margin-bottom: 18px; }
.login-card h1 { margin: 0 0 8px; font-size: 27px; letter-spacing: -.7px; }
.login-card p { margin: 0 0 20px; color: var(--muted); font-size: 14px; line-height: 1.6; }
.pin-input { width: 100%; height: 60px; border: 1px solid #cfd7e5; border-radius: 10px; text-align: center; font-size: 28px; letter-spacing: 14px; padding-left: 14px; outline: none; }
.pin-input:focus { border-color: var(--brand-2); box-shadow: 0 0 0 3px rgba(39,56,137,.12); }
.login-btn { width: 100%; margin-top: 14px; height: 48px; }
.form-message { min-height: 20px; margin-top: 10px; color: var(--danger); font-size: 13px; }

.app { min-height: 100vh; background: #fff; }
.topbar { height: 94px; display: grid; grid-template-columns: 288px 1fr auto; align-items: center; border-bottom: 1px solid var(--line); background: #fff; position: sticky; top: 0; z-index: 20; }
.topbar-brand { height: 100%; display: flex; align-items: center; padding: 10px 26px; border-right: 1px solid var(--line); }
.topbar-brand img { width: 205px; max-height: 70px; object-fit: contain; }
.topbar-title { font-size: 27px; font-weight: 800; letter-spacing: -.7px; padding-left: 64px; }
.topbar-actions { display: flex; align-items: center; gap: 12px; padding-right: 28px; color: #475467; font-size: 14px; }
.status-dot, .online-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: #22c55e; }
.icon-text-btn { border: 0; background: transparent; color: #667085; padding: 7px 8px; border-radius: 7px; }
.icon-text-btn:hover { background: #f2f4f7; }

.app-body { display: grid; grid-template-columns: 288px minmax(0, 1fr); min-height: calc(100vh - 94px); }
.sidebar { border-right: 1px solid var(--line); background: #fbfcfe; padding: 18px; }
.side-card { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 18px 20px; margin-bottom: 16px; }
.connection-line { display: flex; align-items: center; gap: 10px; font-size: 15px; }
.connection-sub { margin-top: 18px; color: #667085; font-size: 14px; }
.side-heading { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 13px; }
.side-card h2 { margin: 0; font-size: 17px; letter-spacing: -.3px; }
.people-list { display: flex; flex-direction: column; gap: 3px; }
.person-row { display: grid; grid-template-columns: 14px minmax(0,1fr) 28px; align-items: center; min-height: 38px; padding: 4px 1px; border-bottom: 1px solid #f2f4f7; }
.person-row:last-child { border-bottom: 0; }
.person-dot { width: 14px; height: 14px; border-radius: 50%; }
.person-name { padding-left: 8px; font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.person-delete { width: 28px; height: 28px; border: 0; background: transparent; color: #98a2b3; border-radius: 6px; font-size: 19px; line-height: 1; }
.person-delete:hover { color: var(--danger); background: #fff1f1; }
.side-hint { margin: 12px 0 0; color: #7c879b; font-size: 11.5px; line-height: 1.6; }
.legend-card { padding-bottom: 20px; }
.legend-card h2 { margin-bottom: 16px; }
.legend-row { display: flex; align-items: center; gap: 12px; font-size: 14px; margin: 13px 0; }
.legend-square { width: 14px; height: 14px; border-radius: 3px; }
.type-leave { background: var(--leave); }
.type-trip { background: var(--trip); }
.type-meeting { background: var(--meeting); }
.type-deadline { background: var(--deadline); }
.type-other { background: var(--other); }

.workspace { min-width: 0; padding: 34px 30px 20px; background: #fff; }
.toolbar-row { display: flex; align-items: center; justify-content: space-between; gap: 18px; margin: 0 0 30px; }
.month-controls { display: flex; align-items: center; gap: 16px; white-space: nowrap; }
.month-title { font-size: 28px; margin: 0 3px; min-width: 160px; text-align: center; letter-spacing: -.7px; }
.filters { display: flex; align-items: center; justify-content: flex-end; gap: 10px; flex-wrap: wrap; }
.btn, .filter-control { height: 44px; border-radius: 8px; border: 1px solid #cfd7e5; background: #fff; color: #344054; padding: 0 15px; transition: .15s ease; }
.btn:hover, .filter-control:hover { border-color: #aeb8cb; }
.btn-primary { background: var(--brand); color: #fff; border-color: var(--brand); font-weight: 700; }
.btn-primary:hover { background: var(--brand-2); border-color: var(--brand-2); }
.btn-neutral { background: #fff; }
.btn-outline { color: #2555d8; border-color: #8eabfa; background: #fff; font-weight: 600; }
.btn-small { height: 36px; padding: 0 10px; font-size: 12px; }
.btn-icon { width: 54px; padding: 0; font-size: 34px; font-weight: 300; line-height: 1; }
.btn-danger { background: #fff; color: var(--danger); border-color: #f3b4b4; font-weight: 700; }
.btn-danger:hover { background: #fff4f4; border-color: #ee8f8f; }
.filter-control { min-width: 165px; outline: none; }
.filter-control:focus { border-color: var(--brand-2); box-shadow: 0 0 0 3px rgba(39,56,137,.10); }
.search-filter { width: 150px; min-width: 130px; }
.sync-notice { min-height: 18px; color: #7c879b; font-size: 12px; text-align: right; margin: -18px 2px 7px; }

.calendar-shell { width: 100%; overflow-x: auto; border: 1px solid var(--line); background: #fff; }
.calendar { min-width: 980px; width: 100%; display: block; }
.weekday-row, .week-row { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.weekday-row { position: relative; z-index: 4; }
.weekday { height: 57px; display: flex; align-items: center; justify-content: center; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); font-size: 16px; font-weight: 800; background: #fff; }
.weekday:last-child { border-right: 0; }
.weekday.sun { color: #ef1f1f; }
.weekday.sat { color: #135ad8; }
.week-row { position: relative; --range-space: 0px; }
.day-cell { min-height: calc(139px + var(--range-space)); padding: 12px 13px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); background: #fff; position: relative; overflow: hidden; }
.week-row .day-cell:last-of-type { border-right: 0; }
.day-cell.outside { background: #fbfcfe; color: #a7b0c0; }
.day-cell.today { background: linear-gradient(135deg, rgba(31,43,108,.07), rgba(255,255,255,1) 58%); }
.day-number { width: 28px; height: 28px; display: inline-flex; align-items: center; justify-content: center; font-size: 15px; font-weight: 600; border-radius: 50%; margin-bottom: 7px; position: relative; z-index: 3; }
.day-cell.sun .day-number { color: #ef1f1f; }
.day-cell.sat .day-number { color: #135ad8; }
.day-cell.today .day-number { background: var(--brand); color: #fff; font-weight: 800; }
.event-list { display: flex; flex-direction: column; gap: 6px; margin-top: var(--range-space); position: relative; z-index: 1; }
.event-card { width: 100%; border: 0; border-radius: 6px; padding: 6px 8px; text-align: left; font-size: 12px; font-weight: 700; overflow: hidden; cursor: pointer; }
.event-title { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.event-person { display: flex; align-items: center; gap: 5px; margin-top: 5px; font-size: 11px; font-weight: 500; color: #475467; }
.event-person-dot { width: 8px; height: 8px; border-radius: 50%; flex: 0 0 auto; }
.event-leave { background: #dff8e7; color: #10913d; }
.event-trip { background: #fff0da; color: #db7200; }
.event-meeting { background: #dfe8ff; color: #1c57c9; }
.event-deadline { background: #ffe0e0; color: #db2f2f; }
.event-other { background: #eadcff; color: #6d32c9; }
.more-events { font-size: 11px; color: #667085; padding: 2px 5px; }
.week-range-layer { position: absolute; inset: 0; z-index: 3; pointer-events: none; }
.range-event { position: absolute; height: 42px; border: 0; border-radius: 6px; padding: 5px 8px 4px; display: flex; flex-direction: column; align-items: flex-start; justify-content: center; gap: 3px; overflow: hidden; text-align: left; font-size: 12px; font-weight: 800; cursor: pointer; pointer-events: auto; box-shadow: inset 0 0 0 1px rgba(15,23,42,.035); }
.range-event.continues-left { border-top-left-radius: 0; border-bottom-left-radius: 0; padding-left: 10px; }
.range-event.continues-right { border-top-right-radius: 0; border-bottom-right-radius: 0; padding-right: 10px; }
.range-event.continues-left::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: currentColor; opacity: .2; }
.range-event.continues-right::after { content: ""; position: absolute; right: 0; top: 0; bottom: 0; width: 3px; background: currentColor; opacity: .2; }
.range-event-title { display:block; width:100%; min-width:0; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; line-height:1.15; }
.range-event-people { display:flex; align-items:center; gap:8px; width:100%; min-width:0; color:#475467; font-size:10.5px; font-weight:600; line-height:1.05; white-space:nowrap; overflow:hidden; }
.range-person-item { display:inline-flex; align-items:center; gap:4px; min-width:0; }
.range-person-item .event-person-dot { width:7px; height:7px; }
.range-person-more { color:#667085; flex:0 0 auto; }
.range-event-people-empty { color:#98a2b3; font-weight:500; }
.range-people { display: inline-flex; align-items: center; gap: 3px; flex: 0 0 auto; }
.range-more { font-size: 9px; line-height: 1; opacity: .8; }
.calendar-help { text-align: center; color: #7b879b; font-size: 12px; margin: 25px 0 0; }

.modal { border: 0; padding: 0; border-radius: 14px; width: min(480px, calc(100% - 32px)); box-shadow: 0 28px 80px rgba(16,24,40,.22); }
.modal::backdrop { background: rgba(15,23,42,.42); backdrop-filter: blur(2px); }
.modal-card { padding: 24px; }
.event-modal-card { width: 100%; }
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 19px; }
.modal-head h2 { margin: 0; font-size: 22px; letter-spacing: -.4px; }
.modal-x { border: 0; background: transparent; width: 34px; height: 34px; border-radius: 7px; color: #667085; font-size: 25px; }
.modal-x:hover { background: #f2f4f7; }
.field-label { display: block; margin: 12px 0 6px; font-size: 13px; font-weight: 700; color: #475467; }
.field-control { width: 100%; border: 1px solid #cfd7e5; border-radius: 8px; padding: 10px 11px; outline: none; background: #fff; color: #182230; }
.field-control:focus { border-color: var(--brand-2); box-shadow: 0 0 0 3px rgba(39,56,137,.10); }
textarea.field-control { resize: vertical; min-height: 95px; }
.field-help { color: #7c879b; font-size: 12px; line-height: 1.5; margin: 8px 0 0; }
.field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 9px; margin-top: 22px; }
.split-actions { align-items: center; }
.action-spacer { flex: 1; }

.toast { position: fixed; right: 24px; bottom: 24px; z-index: 100; background: #172554; color: #fff; border-radius: 10px; padding: 12px 16px; box-shadow: 0 12px 35px rgba(15,23,42,.25); font-size: 13px; max-width: 360px; }

@media (max-width: 1180px) {
  .topbar { grid-template-columns: 240px 1fr auto; }
  .topbar-title { padding-left: 28px; font-size: 22px; }
  .topbar-brand img { width: 180px; }
  .app-body { grid-template-columns: 240px minmax(0,1fr); }
  .toolbar-row { align-items: flex-start; flex-direction: column; }
  .filters { width: 100%; justify-content: flex-start; }
}
@media (max-width: 820px) {
  .topbar { height: auto; min-height: 76px; grid-template-columns: 160px 1fr; padding: 0; }
  .topbar-brand { border-right: 1px solid var(--line); padding: 10px 14px; }
  .topbar-brand img { width: 140px; }
  .topbar-title { padding: 0 12px; font-size: 17px; }
  .topbar-actions { grid-column: 1 / -1; justify-content: flex-end; padding: 7px 13px; border-top: 1px solid var(--line-soft); font-size: 12px; }
  .app-body { display: block; }
  .sidebar { border-right: 0; border-bottom: 1px solid var(--line); padding: 12px; display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
  .side-card { margin: 0; padding: 14px; }
  .people-card { grid-row: span 2; }
  .legend-card { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(5, 1fr); gap: 5px 10px; align-items: center; }
  .legend-card h2 { grid-column: 1 / -1; margin-bottom: 4px; }
  .legend-row { margin: 4px 0; font-size: 12px; }
  .workspace { padding: 20px 12px; }
  .month-controls { gap: 8px; width: 100%; }
  .month-title { font-size: 22px; min-width: 130px; }
  .btn, .filter-control { height: 42px; }
  .filters { gap: 7px; }
  .filter-control, .search-filter { flex: 1 1 140px; min-width: 0; }
  .filters .btn { flex: 1 1 135px; }
  .calendar { min-width: 860px; }
}
@media (max-width: 520px) {
  .sidebar { grid-template-columns: 1fr; }
  .people-card { grid-row: auto; }
  .legend-card { grid-column: auto; grid-template-columns: repeat(2, 1fr); }
  .field-grid { grid-template-columns: 1fr; gap: 0; }
  .topbar-title { font-size: 15px; }
}

/* v4: 본인 선택 및 기간 일정 */
.identity-label { text-align: left; margin-top: 4px; }
.identity-select { height: 50px; }
.identity-back { width: 100%; margin-top: 9px; height: 44px; }
.person-mini-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; background: #98a2b3; }
.person-row { grid-template-columns: 14px minmax(0,1fr) 30px 28px; }
.person-row-me { background: var(--brand-soft); border-radius: 7px; padding-left: 6px; padding-right: 3px; border-bottom-color: transparent; }
.me-badge { display: inline-flex; align-items: center; justify-content: center; min-width: 25px; height: 21px; padding: 0 6px; border-radius: 999px; background: var(--brand); color: #fff; font-size: 10px; font-weight: 800; }
.field-control:disabled { background: #f6f8fb; color: #667085; cursor: not-allowed; }
.range-mark { display: inline-block; margin-right: 4px; font-weight: 900; opacity: .72; }

/* v5: 이름 + 생일 로그인 / 관리자 권한 */
.login-label { text-align: left; margin-top: 12px; }
.login-select { height: 50px; font-size: 15px; }
.compact-pin { height: 54px; font-size: 24px; letter-spacing: 8px; padding-left: 8px; }
.login-help { margin: 7px 0 0 !important; text-align: left; font-size: 11.5px !important; color: #7c879b !important; }
.setup-chip { display: inline-flex; align-items: center; height: 26px; padding: 0 10px; margin: 0 0 13px; border-radius: 999px; background: var(--brand-soft); color: var(--brand); font-size: 11px; font-weight: 800; }
.admin-badge { display: inline-flex; align-items: center; height: 23px; padding: 0 8px; border-radius: 999px; background: #fff4d6; color: #9a6700; border: 1px solid #f1d18a; font-size: 10px; font-weight: 800; }
.person-row { grid-template-columns: 14px minmax(0,1fr) auto auto; gap: 6px; }
.person-badges { display: flex; align-items: center; justify-content: flex-end; gap: 4px; min-width: 0; }
.person-actions { display: flex; align-items: center; gap: 1px; }
.person-edit, .person-delete { width: 28px; height: 28px; border: 0; background: transparent; color: #98a2b3; border-radius: 6px; font-size: 16px; line-height: 1; }
.person-edit:hover { color: var(--brand); background: var(--brand-soft); }
.person-delete { font-size: 19px; }
.person-delete:hover { color: var(--danger); background: #fff1f1; }
.admin-mini-badge, .birth-missing-badge { display: inline-flex; align-items: center; height: 20px; padding: 0 6px; border-radius: 999px; white-space: nowrap; font-size: 9px; font-weight: 800; }
.admin-mini-badge { background: #fff4d6; color: #9a6700; }
.birth-missing-badge { background: #fff1f1; color: #b42318; }
.birth-field { letter-spacing: 3px; }
@media (max-width: 520px) {
  .person-row { grid-template-columns: 14px minmax(0,1fr) auto; }
  .person-actions { grid-column: 2 / -1; justify-content: flex-end; }
  .person-badges { justify-content: flex-start; }
}

.build-version{margin-top:10px;text-align:center;font-size:10px;color:#98a2b3;letter-spacing:.02em}


/* v5.3: 공동 일정 참여 / 관리자 일정 관리 / 관리자 변경 */
.side-admin-actions { display:flex; align-items:center; gap:6px; flex-wrap:wrap; justify-content:flex-end; }
.participants-block { margin-top:14px; padding:12px; border:1px solid var(--line); border-radius:9px; background:#fafbfe; }
.participants-head { display:flex; align-items:center; justify-content:space-between; gap:10px; margin-bottom:8px; }
.participants-label { margin:0; }
.participant-list { display:flex; flex-wrap:wrap; gap:6px; }
.participant-chip { display:inline-flex; align-items:center; gap:6px; min-height:28px; padding:4px 9px; border-radius:999px; background:#fff; border:1px solid #dfe5ef; color:#344054; font-size:12px; font-weight:650; }
.participant-chip small { margin-left:2px; color:#7c879b; font-size:9px; font-weight:800; }
.participant-dot { width:9px; height:9px; border-radius:50%; flex:0 0 auto; }
.participant-empty { color:#98a2b3; font-size:12px; }
.event-person { gap:4px; }
.event-participant-names { white-space:nowrap; overflow:hidden; text-overflow:ellipsis; min-width:0; }
.transfer-warning { margin:0 0 12px; padding:10px 12px; background:#fff8e6; border:1px solid #f5d98a; border-radius:8px; color:#805b00; }
@media (max-width:520px) { .side-admin-actions { width:100%; justify-content:flex-start; margin-top:6px; } }

/* v5.6: 기간 일정은 연속 막대로 표시하고, 막대 안에서 제목 아래 참여자 이름을 표시 */

/* v5.7: 마감 D-Day 상단 요약 */
.deadline-panel { margin: 0 0 18px; border: 1px solid #f2c7c7; border-radius: 12px; background: linear-gradient(180deg,#fffafa 0%,#fff 100%); padding: 13px 14px 14px; box-shadow: 0 2px 10px rgba(176,31,31,.04); }
.deadline-panel-head { display:flex; align-items:center; justify-content:space-between; gap:12px; margin-bottom:10px; }
.deadline-panel-title { display:flex; align-items:center; gap:8px; color:#9f2424; font-size:14px; }
.deadline-title-icon { width:20px; height:20px; display:inline-flex; align-items:center; justify-content:center; border-radius:50%; background:#f04444; color:#fff; font-size:12px; font-weight:900; }
.deadline-count { color:#9b6a6a; font-size:11px; font-weight:700; }
.deadline-list { display:flex; align-items:stretch; gap:8px; flex-wrap:wrap; }
.deadline-item { min-width:190px; flex:1 1 210px; max-width:300px; border:1px solid #f0d3d3; border-radius:10px; background:#fff; padding:9px 11px; display:flex; align-items:center; gap:10px; text-align:left; color:var(--text); transition:.15s ease; }
.deadline-item:hover { border-color:#e7aaaa; box-shadow:0 4px 14px rgba(176,31,31,.08); transform:translateY(-1px); }
.deadline-dday { flex:0 0 auto; min-width:52px; height:30px; padding:0 8px; border-radius:8px; display:inline-flex; align-items:center; justify-content:center; font-size:12px; font-weight:900; background:#f4f6f8; color:#475467; }
.deadline-dday.upcoming { background:#fff1f1; color:#c73535; }
.deadline-dday.urgent { background:#ffe1e1; color:#b42318; }
.deadline-dday.today { background:#e43131; color:#fff; }
.deadline-dday.overdue { background:#f2f4f7; color:#8a3f3f; }
.deadline-main { min-width:0; display:flex; flex-direction:column; gap:5px; }
.deadline-event-title { font-size:12.5px; font-weight:800; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.deadline-meta { display:flex; align-items:center; gap:5px; min-width:0; color:#667085; font-size:10.5px; font-weight:600; }
.deadline-author-dot { width:7px; height:7px; border-radius:50%; flex:0 0 auto; }
.deadline-date { margin-left:auto; color:#98a2b3; font-weight:600; }
.deadline-more { display:flex; align-items:center; padding:0 4px; color:#8b6b6b; font-size:11px; }
@media (max-width:820px) { .deadline-item { min-width:180px; max-width:none; } }
@media (max-width:520px) { .deadline-list { display:grid; grid-template-columns:1fr; } .deadline-item { width:100%; max-width:none; } }

/* v5.8: manual data refresh */
#refreshBtn { white-space: nowrap; }
#refreshBtn:disabled { opacity:.72; cursor:wait; }
