/* 통합 업무캘린더 — 산뜻하고 읽기 쉬운 화면 */
:root {
  --bg: #f4f6fb;
  --surface: #ffffff;
  --surface-2: #f1f3f9;
  --surface-3: #e9edf6;
  --line: #e3e7f0;
  --line-strong: #cfd6e4;
  --text: #18202f;
  --muted: #5f6b80;
  --faint: #8a94a8;
  --primary: #3b5bdb;
  --primary-2: #5b7cfa;
  --primary-ink: #ffffff;
  --primary-soft: #eaf0ff;
  --today: #ff6b4a;
  --today-soft: #fff1ec;
  --danger: #d63939;
  --danger-soft: #fdecec;
  --warn: #b26a00;
  --warn-soft: #fff5e0;
  --ok: #1f8a5b;
  --ok-soft: #e4f6ed;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 1px 2px rgba(24, 32, 47, .04), 0 4px 16px rgba(24, 32, 47, .06);
  --shadow-lg: 0 18px 48px rgba(24, 32, 47, .18);
  /* 일정 유형 색(항상 이름과 함께 표시) */
  --t-event: #3b5bdb; --t-meeting: #7048e8; --t-apply: #0c8599; --t-deadline: #e8590c;
  --t-edu: #2f9e44; --t-period: #5c6f91; --t-announce: #d6336c; --t-etc: #868e96;
  /* 여러 날 일정 막대 색 */
  --r0: #4c6ef5; --r1: #12b886; --r2: #f76707; --r3: #ae3ec9; --r4: #1c7ed6; --r5: #e64980; --r6: #74b816; --r7: #f59f00;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #0f1420; --surface: #171e2c; --surface-2: #1d2535; --surface-3: #252f42; --line: #2a3448; --line-strong: #3a4660;
  --text: #e8ecf4; --muted: #a3adc2; --faint: #7c8699; --primary: #7b96ff; --primary-2: #9aafff; --primary-ink: #0f1420; --primary-soft: #1f2a48;
  --today: #ff8a6e; --today-soft: #3a2420; --danger: #ff8080; --danger-soft: #3a1f22; --warn: #f2bd5c; --warn-soft: #3a2f17; --ok: #6fd3a0; --ok-soft: #173326;
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1420; --surface: #171e2c; --surface-2: #1d2535; --surface-3: #252f42; --line: #2a3448; --line-strong: #3a4660;
    --text: #e8ecf4; --muted: #a3adc2; --faint: #7c8699; --primary: #7b96ff; --primary-2: #9aafff; --primary-ink: #0f1420; --primary-soft: #1f2a48;
    --today: #ff8a6e; --today-soft: #3a2420; --danger: #ff8080; --danger-soft: #3a1f22; --warn: #f2bd5c; --warn-soft: #3a2f17; --ok: #6fd3a0; --ok-soft: #173326;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--text);
  font-family: "Pretendard Variable", Pretendard, "Apple SD Gothic Neo", "Malgun Gothic", system-ui, sans-serif;
  font-size: 15px; line-height: 1.55; letter-spacing: -0.01em; -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; letter-spacing: inherit; }
a { color: var(--primary); }
[hidden] { display: none !important; }

/* ── 상단 ── */
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 16px;
  padding: 12px 24px; background: color-mix(in srgb, var(--surface) 86%, transparent);
  backdrop-filter: saturate(180%) blur(12px); -webkit-backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 11px; min-width: 0; }
.brand-mark {
  width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; font-weight: 800; font-size: 14px;
  color: #fff; background: linear-gradient(135deg, var(--primary-2), var(--primary)); box-shadow: 0 4px 12px color-mix(in srgb, var(--primary) 35%, transparent);
}
.brand-mark.admin { background: linear-gradient(135deg, #ff8f6b, #e8590c); box-shadow: 0 4px 12px rgba(232, 89, 12, .3); }
.brand-text { display: flex; flex-direction: column; line-height: 1.25; }
.brand-text strong { font-size: 16px; font-weight: 750; }
.brand-text small { color: var(--muted); font-size: 12px; }
.nav { display: flex; gap: 4px; flex: 1; overflow-x: auto; scrollbar-width: none; }
.nav a { padding: 8px 14px; border-radius: 999px; text-decoration: none; color: var(--muted); white-space: nowrap; font-weight: 600; font-size: 14px; display: inline-flex; gap: 6px; align-items: center; }
.nav a.active { background: var(--primary-soft); color: var(--primary); }
.nav a:hover { color: var(--text); background: var(--surface-2); }
.nav .count { background: var(--danger); color: #fff; border-radius: 999px; font-size: 11px; padding: 0 7px; line-height: 18px; }
.user { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); white-space: nowrap; }

.app { max-width: 1320px; margin: 0 auto; padding: 24px; }
h1 { font-size: 24px; margin: 0 0 4px; font-weight: 800; letter-spacing: -0.02em; }
h2 { font-size: 18px; margin: 28px 0 12px; font-weight: 750; }
h3 { font-size: 15px; margin: 16px 0 8px; font-weight: 700; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }

/* ── 공통 컨트롤 ── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 8px 15px; border: 1px solid var(--line-strong);
  background: var(--surface); border-radius: 999px; cursor: pointer; white-space: nowrap; min-height: 38px; font-weight: 600; font-size: 14px;
  transition: background .15s, border-color .15s, transform .05s;
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); box-shadow: 0 4px 12px color-mix(in srgb, var(--primary) 28%, transparent); }
.btn.primary:hover { background: var(--primary-2); }
.btn.danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 45%, transparent); }
.btn.danger:hover { background: var(--danger-soft); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.small { padding: 4px 11px; min-height: 30px; font-size: 13px; }
.btn.icon { width: 38px; padding: 0; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.seg { display: inline-flex; background: var(--surface-2); border-radius: 999px; padding: 3px; border: 1px solid var(--line); }
.seg button { border: 0; background: transparent; padding: 6px 14px; border-radius: 999px; cursor: pointer; font-weight: 600; font-size: 14px; color: var(--muted); }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: 0 1px 4px rgba(24, 32, 47, .12); }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], input[type=time], input[type=month], input[type=search], select, textarea {
  border: 1px solid var(--line-strong); border-radius: var(--radius-sm); padding: 8px 12px; background: var(--surface); min-height: 40px; width: 100%;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 18%, transparent); }
textarea { min-height: 72px; resize: vertical; }
.btn:focus-visible, a:focus-visible, button:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
label.field { display: flex; flex-direction: column; gap: 5px; font-size: 13px; color: var(--muted); }
label.field > span { font-weight: 650; color: var(--text); }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 14px; }
.form-grid .wide { grid-column: 1 / -1; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.notice { border-radius: var(--radius-sm); padding: 11px 14px; font-size: 14px; background: var(--surface-2); border: 1px solid var(--line); }
.notice.warn { background: var(--warn-soft); border-color: transparent; color: var(--warn); }
.notice.danger { background: var(--danger-soft); border-color: transparent; color: var(--danger); }
.notice.ok { background: var(--ok-soft); border-color: transparent; color: var(--ok); }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }

/* ── 배지 ── */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.badge.status-pending { background: var(--surface-3); }
.badge.status-processing { background: var(--primary-soft); color: var(--primary); }
.badge.status-done, .badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.status-failed, .badge.danger { background: var(--danger-soft); color: var(--danger); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.type-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--tc, var(--t-etc)); flex: none; }
[data-type="행사"] { --tc: var(--t-event); }
[data-type="회의"] { --tc: var(--t-meeting); }
[data-type="접수 기간"] { --tc: var(--t-apply); }
[data-type="제출 마감"] { --tc: var(--t-deadline); }
[data-type="교육·연수"] { --tc: var(--t-edu); }
[data-type="운영 기간"] { --tc: var(--t-period); }
[data-type="발표"] { --tc: var(--t-announce); }
[data-type="업무·기타"] { --tc: var(--t-etc); }

/* ── 오늘 카드 ── */
.hero { display: grid; grid-template-columns: auto 1fr; gap: 18px; align-items: center; margin-bottom: 18px; padding: 18px 22px;
  background: linear-gradient(120deg, color-mix(in srgb, var(--primary) 10%, var(--surface)), var(--surface) 60%); }
.today-date { display: flex; align-items: center; gap: 14px; }
.today-num { width: 64px; height: 64px; border-radius: 18px; background: var(--today); color: #fff; display: grid; place-items: center; text-align: center; line-height: 1.05; box-shadow: 0 8px 20px color-mix(in srgb, var(--today) 35%, transparent); }
.today-num b { font-size: 26px; display: block; }
.today-num small { font-size: 11px; font-weight: 700; opacity: .9; }
.today-label small { display: block; color: var(--today); font-weight: 750; font-size: 13px; letter-spacing: .02em; }
.today-label strong { font-size: 20px; font-weight: 800; }
.today-list { display: flex; gap: 8px; overflow-x: auto; padding: 2px; scrollbar-width: thin; }
.today-chip { flex: none; max-width: 260px; text-align: left; border: 1px solid var(--line); background: var(--surface); border-radius: 12px; padding: 8px 12px; cursor: pointer; border-left: 4px solid var(--tc, var(--t-etc)); }
.today-chip:hover { border-color: var(--line-strong); }
.today-chip .t { font-weight: 650; font-size: 14px; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.today-chip .m { font-size: 12px; color: var(--muted); }
.today-empty { color: var(--muted); font-size: 14px; }

/* ── 캘린더 툴바·필터 ── */
.cal-toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 12px; }
.cal-title { font-size: 24px; font-weight: 800; margin: 0 10px; min-width: 150px; letter-spacing: -0.02em; }
.filters { display: grid; grid-template-columns: 2fr 1.3fr 1fr 1fr 1fr; gap: 8px; margin-bottom: 10px; }
.search { position: relative; }
.search input { padding-left: 36px; }
.search::before { content: ''; position: absolute; left: 13px; top: 50%; width: 12px; height: 12px; border: 2px solid var(--faint); border-radius: 50%; transform: translateY(-62%); }
.search::after { content: ''; position: absolute; left: 24px; top: 58%; width: 6px; height: 2px; background: var(--faint); transform: rotate(45deg); }
.filter-result { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 10px 14px; margin-bottom: 12px; border-radius: var(--radius-sm); background: var(--primary-soft); color: var(--primary); font-weight: 600; font-size: 14px; }
.filter-result .spacer { flex: 1; }
.legend { display: flex; flex-wrap: wrap; gap: 12px; font-size: 12px; color: var(--muted); margin: 4px 2px 12px; }
.legend span { display: inline-flex; align-items: center; gap: 5px; }
.long-bar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.long-bar span { flex: 1; min-width: 200px; }

/* ── 월간·주간 ── */
.month { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.dow { display: grid; grid-template-columns: repeat(7, 1fr); border-bottom: 1px solid var(--line); font-size: 12px; font-weight: 700; text-align: center; color: var(--muted); letter-spacing: .04em; }
.dow div { padding: 10px 0; }
.dow .sun, .daynum.sun .num { color: #e03131; }
.dow .sat, .daynum.sat .num { color: #1c7ed6; }
.week { display: grid; grid-template-columns: repeat(7, 1fr); grid-auto-rows: min-content; position: relative; border-bottom: 1px solid var(--line); min-height: 124px; padding-bottom: 6px; }
.week:last-child { border-bottom: 0; }
.week .cellbg { grid-row: 1 / span 30; border-right: 1px solid var(--line); }
.week .cellbg:nth-child(7) { border-right: 0; }
.week .cellbg.other { background: var(--surface-2); }
.week .cellbg.today { background: var(--today-soft); box-shadow: inset 0 0 0 2px var(--today); }
.daynum { grid-row: 1; padding: 6px 8px 4px; font-size: 13px; z-index: 1; display: flex; align-items: center; gap: 6px; }
.daynum .num { font-weight: 700; }
.daynum.other .num { color: var(--faint); font-weight: 500; }
.daynum .today-pill { background: var(--today); color: #fff; border-radius: 999px; min-width: 26px; height: 26px; padding: 0 7px; display: inline-grid; place-items: center; font-weight: 800; box-shadow: 0 3px 8px color-mix(in srgb, var(--today) 40%, transparent); }
.daynum .today-word { font-size: 11px; font-weight: 800; color: var(--today); }
/* 하루 일정: 점 + 글자 */
.ev { z-index: 1; margin: 1px 4px; padding: 2px 6px; font-size: 12.5px; line-height: 1.45; border-radius: 6px; cursor: pointer; text-align: left;
  background: transparent; border: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; color: var(--text); display: flex; align-items: center; gap: 5px; }
.ev:hover { background: var(--surface-2); }
.ev .tm { color: var(--muted); font-variant-numeric: tabular-nums; font-size: 12px; }
.ev .t { font-weight: 600; overflow: hidden; text-overflow: ellipsis; }
.ev.cancelled { text-decoration: line-through; opacity: .55; }
.ev .tag { font-size: 11px; font-weight: 700; color: var(--warn); }
/* 여러 날 일정: 색 막대(시작과 끝이 둥글게) */
.span { z-index: 2; margin: 2px 0; padding: 3px 10px; font-size: 12.5px; line-height: 1.4; cursor: pointer; text-align: left; border: 0; min-width: 0;
  color: #fff; background: var(--rc); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 600; display: flex; align-items: center; gap: 6px; }
.span.start { border-top-left-radius: 999px; border-bottom-left-radius: 999px; margin-left: 5px; }
.span.end { border-top-right-radius: 999px; border-bottom-right-radius: 999px; margin-right: 5px; }
.span:not(.start) { padding-left: 8px; }
.span .range { font-weight: 500; opacity: .9; font-size: 11.5px; }
.span:hover { filter: brightness(1.06); }
.span.cancelled { opacity: .5; text-decoration: line-through; }
:is(.span, .span-color).c0 { --rc: var(--r0); } :is(.span, .span-color).c1 { --rc: var(--r1); } :is(.span, .span-color).c2 { --rc: var(--r2); } :is(.span, .span-color).c3 { --rc: var(--r3); }
:is(.span, .span-color).c4 { --rc: var(--r4); } :is(.span, .span-color).c5 { --rc: var(--r5); } :is(.span, .span-color).c6 { --rc: var(--r6); } :is(.span, .span-color).c7 { --rc: var(--r7); }
.more { z-index: 1; margin: 2px 6px; font-size: 12px; color: var(--primary); background: none; border: 0; text-align: left; cursor: pointer; padding: 0 4px; font-weight: 700; }
.weekview .week { min-height: 360px; }
.weekview .ev { white-space: normal; align-items: flex-start; }

/* ── 목록 ── */
.list { display: flex; flex-direction: column; gap: 16px; }
.list-day h3 { margin: 0 0 8px; font-size: 15px; display: flex; gap: 8px; align-items: center; }
.list-day.today h3 { color: var(--today); }
.list-day.today h3::after { content: '오늘'; font-size: 12px; background: var(--today); color: #fff; padding: 1px 9px; border-radius: 999px; }
.list-item { display: grid; grid-template-columns: 130px 1fr; gap: 12px; padding: 13px 16px; background: var(--surface); border: 1px solid var(--line); border-left: 5px solid var(--tc, var(--t-etc)); border-radius: 12px; cursor: pointer; text-align: left; width: 100%; box-shadow: var(--shadow); }
.list-item.multi { border-left-color: var(--rc, var(--r0)); }
.list-item:hover { border-color: var(--line-strong); }
.list-item .when { font-size: 13px; color: var(--muted); font-weight: 600; }
.list-item .title { font-weight: 700; font-size: 15px; }
.list-item .meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; font-size: 13px; color: var(--muted); align-items: center; }
.empty { text-align: center; padding: 48px 12px; color: var(--muted); background: var(--surface); border: 1px dashed var(--line-strong); border-radius: var(--radius); }

/* ── 표 ── */
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
table { border-collapse: collapse; width: 100%; font-size: 14px; }
th, td { padding: 10px 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
tr:last-child td { border-bottom: 0; }
th { background: var(--surface-2); font-size: 12px; color: var(--muted); font-weight: 700; white-space: nowrap; position: sticky; top: 0; letter-spacing: .02em; }
tr.sel td { background: var(--primary-soft); }
tr.prio td:first-child { box-shadow: inset 4px 0 0 var(--danger); }
td.nowrap { white-space: nowrap; }
.reasons { margin: 0; padding-left: 16px; font-size: 13px; color: var(--warn); }
.src { white-space: pre-wrap; font-family: inherit; font-size: 13px; background: var(--surface-2); border-radius: 10px; padding: 10px 12px; margin: 0; }
.diff td.changed { background: var(--warn-soft); }

/* ── 요일 확인 카드 ── */
.wd-list { display: grid; gap: 14px; }
.wd-card { display: grid; gap: 10px; }
.wd-card .head { display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; }
.wd-card .head strong { font-size: 16px; }
.wd-choices { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.wd-choice { border: 2px solid var(--line); background: var(--surface); border-radius: 12px; padding: 12px 14px; cursor: pointer; text-align: left; display: grid; gap: 2px; transition: border-color .15s, background .15s; }
.wd-choice:hover { border-color: var(--primary); background: var(--primary-soft); }
.wd-choice small { color: var(--muted); font-weight: 600; font-size: 12px; }
.wd-choice b { font-size: 18px; font-weight: 800; }
.wd-choice span { font-size: 12.5px; color: var(--muted); }

/* ── 모달 ── */
.modal-backdrop { position: fixed; inset: 0; background: rgba(15, 20, 32, .45); backdrop-filter: blur(3px); z-index: 50; display: flex; align-items: flex-start; justify-content: center; padding: 48px 16px; overflow-y: auto; }
.modal { background: var(--surface); border-radius: 18px; width: min(720px, 100%); box-shadow: var(--shadow-lg); overflow: hidden; }
.modal.wide { width: min(1080px, 100%); }
.modal-head { display: flex; align-items: flex-start; gap: 12px; padding: 18px 22px; border-bottom: 1px solid var(--line); }
.modal-head h2 { margin: 0; font-size: 19px; flex: 1; }
.modal-body { padding: 18px 22px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 22px; border-top: 1px solid var(--line); flex-wrap: wrap; background: var(--surface-2); }
dl.detail { display: grid; grid-template-columns: 100px 1fr; gap: 10px 14px; margin: 0; }
dl.detail dt { color: var(--muted); font-size: 14px; font-weight: 600; }
dl.detail dd { margin: 0; white-space: pre-wrap; }
.range-banner { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-radius: 12px; color: #fff; background: var(--rc, var(--r0)); font-weight: 700; margin-bottom: 12px; }

.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: #18202f; color: #fff; padding: 11px 18px; border-radius: 12px; z-index: 60; max-width: 90vw; box-shadow: var(--shadow-lg); font-weight: 600; }
.toast.err { background: var(--danger); }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; overflow-x: auto; }
.tabs button { background: none; border: 0; padding: 9px 14px; cursor: pointer; color: var(--muted); border-bottom: 2px solid transparent; white-space: nowrap; font-weight: 600; }
.tabs button[aria-selected="true"] { color: var(--primary); border-color: var(--primary); }
.footer { text-align: center; color: var(--faint); font-size: 12px; padding: 24px 0 8px; }

@media (max-width: 960px) {
  .filters { grid-template-columns: 1fr 1fr; }
  .filters .search { grid-column: 1 / -1; }
  .hero { grid-template-columns: 1fr; }
}
@media (max-width: 720px) {
  .topbar { flex-wrap: wrap; padding: 10px 16px; gap: 8px; }
  .nav { order: 3; flex: 1 1 100%; }
  .brand-text small { display: none; }
  .app { padding: 16px; }
  .cal-title { font-size: 20px; min-width: 0; margin: 0 4px; }
  .week { min-height: 84px; }
  .ev .tm, .ev .type-dot { display: none; }
  .ev { font-size: 11px; padding: 1px 3px; margin: 1px 2px; }
  .span { font-size: 11px; padding: 2px 6px; }
  .span .range { display: none; }
  .daynum { padding: 4px; font-size: 12px; }
  .daynum .today-word { display: none; }
  .list-item { grid-template-columns: 1fr; gap: 2px; }
  dl.detail { grid-template-columns: 1fr; gap: 0; }
  dl.detail dd { margin-bottom: 10px; }
  .wd-choices { grid-template-columns: 1fr; }
  .modal-backdrop { padding: 0; }
  .modal { border-radius: 0; min-height: 100vh; }
  .today-num { width: 54px; height: 54px; }
}
