:root {
  --bg: #f4f7f3;
  --panel: #ffffff;
  --panel-soft: #f8fbf8;
  --ink: #1f2b2a;
  --muted: #66736f;
  --line: #dfe8e2;
  --brand: #25685a;
  --brand-dark: #174b41;
  --brand-soft: #e6f3ef;
  --accent: #e7ad3c;
  --danger: #c74949;
  --ok: #2f855a;
  --warn: #b7791f;
  --radius-xl: 24px;
  --radius: 16px;
  --shadow: 0 18px 45px rgba(37, 104, 90, 0.12);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans KR", "Apple SD Gothic Neo", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: var(--font);
  background: radial-gradient(circle at top left, #e6f3ef 0, transparent 30%), var(--bg);
  color: var(--ink);
}
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
textarea { resize: vertical; }
/* ── a 태그 전역 기본 — 브라우저 기본 파란색/밑줄 리셋 ── */
a { color: var(--brand); text-decoration: none; }
a:hover { color: var(--brand-dark); text-decoration: underline; }
.hidden { display: none !important; }
.full { width: 100%; }
.muted { color: var(--muted); }
.nowrap { white-space: nowrap; }

.app-shell { display: grid; grid-template-columns: 280px 1fr; min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh; padding: 24px 18px;
  background: rgba(255,255,255,0.86); border-right: 1px solid var(--line); backdrop-filter: blur(16px);
  display: flex; flex-direction: column; gap: 22px;
  overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; /* 화면 짧을 때 메뉴 스크롤 */
}
/* 사이드바 스크롤바 살짝 얇게 */
.sidebar::-webkit-scrollbar { width: 8px; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(37,104,90,0.18); border-radius: 8px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }
.brand { display: flex; gap: 12px; align-items: center; padding: 8px; }
.brand-mark {
  width: 48px; height: 48px; border-radius: 15px; background: linear-gradient(135deg, var(--brand), #3b8c72);
  color: #fff; display: grid; place-items: center; font-weight: 900; font-size: 24px; box-shadow: var(--shadow);
}
.brand span { display: block; color: var(--muted); font-size: 13px; margin-top: 4px; }
.nav-list { display: grid; gap: 8px; }
.nav-item {
  display: flex; align-items: center; gap: 12px; width: 100%; border: 0; background: transparent; color: var(--ink);
  padding: 13px 14px; border-radius: 16px; text-align: left; transition: 0.18s ease;
}
.nav-item:hover { background: var(--brand-soft); }
.nav-item.active { background: var(--brand); color: #fff; box-shadow: 0 10px 24px rgba(37, 104, 90, 0.18); }
.nav-item .icon { width: 28px; height: 28px; display: grid; place-items: center; border-radius: 10px; background: rgba(37,104,90,0.08); }
.nav-item.active .icon { background: rgba(255,255,255,0.18); }
.sidebar-footer { margin-top: auto; display: grid; gap: 10px; color: var(--muted); }

.main { min-width: 0; position: relative; }
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; justify-content: space-between; align-items: center;
  padding: 22px 32px; border-bottom: 1px solid var(--line); background: rgba(244,247,243,0.88); backdrop-filter: blur(18px);
}
.eyebrow { margin: 0 0 5px; color: var(--brand); font-size: 12px; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; }
h1 { margin: 0; font-size: clamp(24px, 3vw, 36px); letter-spacing: -0.04em; }
.top-actions { display: flex; align-items: center; gap: 12px; }
.user-switch { display: flex; align-items: center; gap: 8px; background: var(--panel); border: 1px solid var(--line); border-radius: 999px; padding: 7px 8px 7px 14px; box-shadow: 0 8px 20px rgba(0,0,0,0.04); }
.user-switch span { font-size: 13px; color: var(--muted); }
.user-switch select { border: 0; background: transparent; color: var(--ink); outline: none; max-width: 210px; }
.notification-button { position: relative; border: 1px solid var(--line); background: var(--panel); border-radius: 16px; padding: 11px 13px; box-shadow: 0 8px 20px rgba(0,0,0,0.04); }
/* 상단바 전용 버튼 — 앱 설치 / 알림 켜기 */
#pwaInstallBtn, #pushToggleBtn {
  border: 1px solid var(--line); background: var(--panel); border-radius: 16px;
  padding: 9px 14px; font-size: 13px; font-weight: 700; color: var(--ink);
  box-shadow: 0 8px 20px rgba(0,0,0,0.04); cursor: pointer; min-width: 80px;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}
#pwaInstallBtn:hover, #pushToggleBtn:hover { transform: translateY(-1px); }
.badge { position: absolute; top: -7px; right: -7px; min-width: 21px; height: 21px; border-radius: 999px; background: var(--danger); color: #fff; font-size: 12px; display: grid; place-items: center; padding: 0 6px; }

.content { padding: 28px 32px 60px; }
.grid { display: grid; gap: 18px; }
.grid.two { grid-template-columns: repeat(2, minmax(0,1fr)); }
.grid.three { grid-template-columns: repeat(3, minmax(0,1fr)); }
.grid.four { grid-template-columns: repeat(4, minmax(0,1fr)); }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-xl); box-shadow: var(--shadow); padding: 22px; }
.card.compact { padding: 16px; border-radius: var(--radius); box-shadow: none; }
.card-head { display: flex; justify-content: space-between; align-items: start; gap: 14px; margin-bottom: 16px; }
.card-head h2, .card-head h3 { margin: 0; letter-spacing: -0.03em; }
.card-head p { margin: 5px 0 0; color: var(--muted); }
.kpi { display: flex; align-items: center; gap: 16px; min-height: 118px; }
.kpi-icon { width: 54px; height: 54px; border-radius: 18px; background: var(--brand-soft); display: grid; place-items: center; font-size: 26px; }
.kpi strong { display: block; font-size: 30px; letter-spacing: -0.05em; }
.kpi span { color: var(--muted); }

.btn-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.primary, .secondary, .ghost, .danger, .success {
  border: 0; border-radius: 13px; padding: 10px 14px; font-weight: 800; transition: transform 0.12s ease, box-shadow 0.12s ease, opacity 0.12s ease;
}
.primary { background: var(--brand); color: #fff; box-shadow: 0 12px 24px rgba(37,104,90,0.20); }
.secondary { background: var(--brand-soft); color: var(--brand-dark); }
.ghost { background: transparent; color: var(--brand); border: 1px solid var(--line); }
.danger { background: #fdecec; color: var(--danger); }
.success { background: #e8f5ee; color: var(--ok); }
.primary:hover, .secondary:hover, .ghost:hover, .danger:hover, .success:hover { transform: translateY(-1px); }
button:disabled { opacity: 0.45; cursor: not-allowed; transform: none !important; }

.form { display: grid; gap: 12px; }
.form.two { grid-template-columns: repeat(2, minmax(0,1fr)); }
.form.three { grid-template-columns: repeat(3, minmax(0,1fr)); }
.form label { display: grid; gap: 6px; color: var(--muted); font-size: 14px; font-weight: 700; }
.form input, .form select, .form textarea, .search-input {
  width: 100%; border: 1px solid var(--line); border-radius: 13px; background: #fff; padding: 11px 13px; color: var(--ink); outline: none;
  font-size: 15px; /* 목록 본문 수준으로 확대(입력값이 라벨 13px를 상속하던 문제 해결) */
}
.form textarea { min-height: 92px; }
.form input:focus, .form select:focus, .form textarea:focus, .search-input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(37,104,90,0.12); }
.field-span { grid-column: 1 / -1; }

.list { display: grid; gap: 10px; }
.item { border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel-soft); padding: 14px; display: grid; gap: 10px; }
.item-top { display: flex; justify-content: space-between; align-items: start; gap: 12px; }
.item-title { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.item-title strong { font-size: 16px; }
.meta { display: flex; gap: 8px; flex-wrap: wrap; color: var(--muted); font-size: 13px; }
.chip { display: inline-flex; align-items: center; gap: 6px; border-radius: 999px; padding: 5px 9px; font-size: 12px; font-weight: 800; background: #eef3ef; color: var(--muted); }
.chip.brand { background: var(--brand-soft); color: var(--brand-dark); }
.chip.ok { background: #e8f5ee; color: var(--ok); }
.chip.warn { background: #fff7e7; color: var(--warn); }
.chip.danger { background: #fdecec; color: var(--danger); }
.chip.dark { background: #233936; color: #fff; }

.notification-panel { position: fixed; z-index: 50; top: 84px; right: 32px; width: min(420px, calc(100vw - 32px)); background: var(--panel); border: 1px solid var(--line); border-radius: 22px; box-shadow: 0 25px 80px rgba(0,0,0,0.18); padding: 16px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.notification-list { display: grid; gap: 8px; max-height: 430px; overflow: auto; }
.notification { border: 1px solid var(--line); border-radius: 15px; padding: 12px; background: var(--panel-soft); }
.notification.unread { border-color: rgba(37,104,90,0.45); background: var(--brand-soft); }
.notification p { margin: 0 0 6px; }
.notification small { color: var(--muted); }
.toast-area { position: fixed; z-index: 80; bottom: 22px; right: 22px; display: grid; gap: 10px; }
.toast { max-width: 360px; background: #1f2b2a; color: #fff; border-radius: 16px; padding: 14px 16px; box-shadow: 0 16px 44px rgba(0,0,0,0.22); animation: toastIn 0.18s ease; }
@keyframes toastIn { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }

.calendar-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.calendar-title { font-size: 22px; font-weight: 900; letter-spacing: -0.04em; }
.calendar-grid { display: grid; grid-template-columns: repeat(7, minmax(0,1fr)); gap: 8px; }
.day-label { color: var(--muted); font-weight: 800; text-align: center; padding: 8px; }
.day-cell { min-height: 126px; border: 1px solid var(--line); border-radius: 16px; background: #fff; padding: 10px; display: flex; flex-direction: column; gap: 8px; overflow: hidden; }
.day-cell.dim { opacity: 0.42; background: #f4f4f4; }
.day-cell.today { border-color: var(--brand); box-shadow: inset 0 0 0 2px rgba(37,104,90,0.16); }
.day-num { font-weight: 900; }
.event-pill { display: block; border: 0; border-radius: 10px; padding: 7px 8px; background: var(--brand-soft); color: var(--brand-dark); text-align: left; font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.event-pill.all { background: #fff2d5; color: #694600; }
.event-pill.private { background: #eeeeee; color: #444; }
/* 일정 유형별 자동 색상 (현장/행정/전사/개인/팀) */
.event-pill.type-field    { background: #e3f2ea; color: #15503f; }
.event-pill.type-admin    { background: #e7edf7; color: #274690; }
.event-pill.type-all      { background: #fff2d5; color: #694600; }
.event-pill.type-personal { background: #f0eef6; color: #4b3d76; }
.event-pill.type-team     { background: #eaf4ef; color: #2f7a5f; }
.event-pill.type-project  { background: #efe6f7; color: #5b3b8c; font-weight: 700; }
.event-pill.type-partner  { background: #e6f0f7; color: #2b5f8c; font-weight: 700; }
.lunar-num { font-size: 10px; color: var(--muted); font-weight: 400; margin-left: 3px; white-space: nowrap; }
/* 티켓/에디터 본문(정화된 HTML) */
.ticket-body img { max-width: 100%; height: auto; border-radius: 8px; }
.ticket-body table { border-collapse: collapse; max-width: 100%; }
.ticket-body td, .ticket-body th { border: 1px solid var(--line); padding: 6px 9px; }
.ticket-body a { color: var(--green-d); text-decoration: underline; }
.ticket-body ul, .ticket-body ol { margin: 8px 0 8px 20px; }
/* 2일 이상 연속 일정: 시작/중간/끝에 따라 모서리를 각지게 하여 연속 바로 표현 */
.event-pill.m-start { border-top-right-radius: 0; border-bottom-right-radius: 0; border-right: 2px solid rgba(0,0,0,.06); }
.event-pill.m-mid   { border-radius: 0; color: transparent; }
.event-pill.m-end   { border-top-left-radius: 0; border-bottom-left-radius: 0; color: transparent; }
.event-pill.m-mid::after, .event-pill.m-end::after { content: "\00a0"; }
/* 개인화 보기 설정: 글자 크기(콘텐츠 배율) */
body.fs-sm .content { zoom: 0.92; }
body.fs-lg .content { zoom: 1.12; }
@supports not (zoom: 1) { /* Firefox 등 zoom 미지원 대비 폰트 보정 */
  body.fs-sm .content { font-size: 13px; }
  body.fs-lg .content { font-size: 17px; }
}
/* 개인화 보기 설정: 화면 밀도(컴팩트) */
body.density-compact .card { padding: 14px; }
body.density-compact .grid { gap: 12px; }
body.density-compact .list { gap: 8px; }
body.density-compact .item { padding: 10px 12px; }
body.density-compact .card-head { margin-bottom: 10px; }
body.density-compact .content { padding: 18px 24px 40px; }
/* 보기 설정 활성 버튼 + 마커 숨김 */
.vp-fs.vp-on, .vp-den.vp-on, .vp-mode.vp-on { background: var(--brand); color: #fff; }
.view-pref summary::-webkit-details-marker { display: none; }

/* 이지모드: 핵심만 크게 (고연령·저숙련 사용자 배려) */
body.mode-easy .nav-item { padding: 16px 16px; font-size: 17px; }
body.mode-easy .nav-item .icon svg { width: 24px; height: 24px; }
body.mode-easy .content { zoom: 1.06; }
body.mode-easy .btn-row .primary, body.mode-easy .btn-row .secondary { padding: 12px 20px; font-size: 15px; }
body.mode-easy h1 { font-size: clamp(26px, 3vw, 34px); }
body.mode-easy .kpi strong { font-size: 34px; }
@media (max-width: 720px) { body.mode-easy .nav-list a span:not(.icon) { font-size: 13px; } }

/* 신규 알림 팝업 토스트 */
.nw-toast-wrap { position: fixed; top: 16px; right: 16px; z-index: 9500; display: flex; flex-direction: column; gap: 8px; max-width: 320px; }
.nw-toast { display: block; text-decoration: none; background: #fff; border: 1px solid var(--line); border-left: 4px solid var(--brand); border-radius: 12px; padding: 11px 14px; box-shadow: 0 10px 30px rgba(0,0,0,0.14); transition: opacity .35s, transform .35s; animation: nwToastIn .3s ease; }
.nw-toast strong { display: block; color: var(--ink); font-size: 13px; margin-bottom: 2px; }
.nw-toast span { display: block; color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nw-toast.urgent { border-left-color: var(--danger); background: #fff6f6; }
.nw-toast.hide { opacity: 0; transform: translateX(20px); }
@keyframes nwToastIn { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: none; } }
@media (max-width: 720px) { .nw-toast-wrap { left: 12px; right: 12px; max-width: none; top: 10px; } }

/* 주간 보기 */
.week-grid { display: grid; grid-template-columns: repeat(7, minmax(0,1fr)); gap: 8px; }
.week-cell { min-height: 300px; border: 1px solid var(--line); border-radius: 16px; background: #fff; padding: 10px; display: flex; flex-direction: column; gap: 6px; }
.week-cell.today { border-color: var(--brand); box-shadow: inset 0 0 0 2px rgba(37,104,90,0.16); }
@media (max-width: 720px) { .week-grid { grid-template-columns: 1fr; } .week-cell { min-height: auto; } }

.messenger-layout { display: grid; grid-template-columns: 290px 1fr; gap: 18px; min-height: 640px; }
.channel-list { display: grid; gap: 8px; align-content: start; }
.channel-button { border: 1px solid var(--line); background: var(--panel-soft); border-radius: 15px; padding: 12px; text-align: left; display: grid; gap: 5px; }
.channel-button.active { border-color: var(--brand); background: var(--brand-soft); }
.chat-box { display: grid; grid-template-rows: auto 1fr auto; min-height: 640px; }
.message-list { overflow: auto; max-height: 500px; display: grid; gap: 12px; padding: 6px; align-content: start; }
.message { display: grid; gap: 4px; max-width: 84%; padding: 12px; border-radius: 16px; background: var(--panel-soft); border: 1px solid var(--line); }
.message.mine { margin-left: auto; background: var(--brand-soft); border-color: rgba(37,104,90,0.24); }
.message-head { display: flex; justify-content: space-between; gap: 12px; font-size: 12px; color: var(--muted); }
.message p { margin: 0; line-height: 1.45; white-space: pre-wrap; }
.chat-input { display: grid; grid-template-columns: 1fr auto; gap: 10px; margin-top: 14px; }
.chat-input textarea { min-height: 50px; max-height: 120px; }

.org-tree { display: grid; gap: 14px; }
.org-node { border: 1px solid var(--line); background: #fff; border-radius: 18px; padding: 14px; }
.org-node.manager { background: var(--brand-soft); }
.org-children { margin-left: 20px; padding-left: 18px; border-left: 2px dashed var(--line); display: grid; gap: 10px; margin-top: 10px; }
.member-table { width: 100%; border-collapse: collapse; overflow: hidden; border-radius: 16px; }
.member-table th, .member-table td { border-bottom: 1px solid var(--line); padding: 11px 9px; text-align: left; vertical-align: top; }
.member-table th { color: var(--muted); font-size: 12px; background: var(--panel-soft); }
.member-table tr:hover td { background: #fbfdfb; }
.permission-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 8px; }
.permission-grid label { display: flex; gap: 8px; align-items: center; border: 1px solid var(--line); border-radius: 12px; padding: 8px; color: var(--ink); }

.attendance-card { display: grid; grid-template-columns: 1fr auto; gap: 14px; align-items: center; }
.time-big { font-size: 36px; font-weight: 900; letter-spacing: -0.05em; }
.approval-flow { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.approval-step { border-radius: 999px; padding: 6px 10px; background: #eef3ef; color: var(--muted); font-size: 12px; font-weight: 800; }
.approval-step.active { background: var(--brand); color: #fff; }

.file-drop { border: 2px dashed var(--line); border-radius: 20px; background: var(--panel-soft); padding: 20px; text-align: center; }
.file-drop.drag { border-color: var(--brand); background: var(--brand-soft); }
.file-name { font-weight: 900; word-break: break-all; }

.modal { border: 0; padding: 0; background: transparent; width: min(760px, calc(100vw - 32px)); }
.modal::backdrop { background: rgba(0,0,0,0.38); backdrop-filter: blur(3px); }
.modal-card { position: relative; margin: 0; border-radius: 24px; background: var(--panel); border: 1px solid var(--line); box-shadow: 0 30px 100px rgba(0,0,0,0.25); padding: 26px; }
.modal-close { position: absolute; top: 14px; right: 14px; width: 34px; height: 34px; border-radius: 999px; border: 1px solid var(--line); background: #fff; font-size: 20px; }
.feedback-box { border-left: 4px solid var(--brand); background: #fbfdfb; border-radius: 13px; padding: 10px 12px; display: grid; gap: 7px; }
.feedback-box.unacked { border-left-color: var(--accent); background: #fffaf0; }
.empty { border: 1px dashed var(--line); border-radius: 18px; padding: 24px; text-align: center; color: var(--muted); background: var(--panel-soft); }

@media (max-width: 1080px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; border-right: 0; border-bottom: 1px solid var(--line); }
  .nav-list { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .sidebar-footer { display: none; }
  .grid.four, .grid.three { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .messenger-layout { grid-template-columns: 1fr; }
}
@media (max-width: 720px) {
  .topbar { align-items: stretch; flex-direction: column; padding: 18px; }
  .top-actions { justify-content: space-between; }
  .content { padding: 18px; }
  .grid.two, .grid.three, .grid.four, .form.two, .form.three { grid-template-columns: 1fr; }
  .calendar-grid { gap: 4px; }
  .day-cell { min-height: 92px; border-radius: 12px; padding: 7px; }
  .event-pill { padding: 5px; font-size: 11px; }
  .nav-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  /* 사이드바 오버레이(열린 상태)에서는 1열로 */
  .sidebar.open .nav-list { grid-template-columns: 1fr; }
  .user-switch { width: 100%; }
  .user-switch select { max-width: none; flex: 1; }
  .notification-panel { top: 120px; right: 16px; }
  .member-table { display: block; overflow-x: auto; }
  .chat-input { grid-template-columns: 1fr; }
}

/* =====================================================================
   SONAP v2.0 추가 스타일 (MVP styles.css 계승 + 서버형/모바일 확장)
   ===================================================================== */

/* 사이드바를 a 태그 nav로 사용 */
.nav-item { text-decoration: none; }
a.ghost, a.primary, a.secondary { text-decoration: none; display: inline-flex; align-items: center; gap: 6px; }
.user-name { font-weight: 800; color: var(--brand-dark); }
.notification-button { text-decoration: none; color: var(--ink); }

/* 햄버거 버튼 (모바일 전용) */
.hamburger { display: none; border: 1px solid var(--line); background: var(--panel); border-radius: 12px; padding: 8px 12px; font-size: 18px; }

/* 페이징 */
.paging { display: flex; gap: 6px; justify-content: center; margin-top: 16px; }
.paging a { border: 1px solid var(--line); border-radius: 10px; padding: 7px 12px; text-decoration: none; color: var(--ink); background: #fff; font-weight: 700; }
.paging a.active { background: var(--brand); color: #fff; border-color: var(--brand); }

/* 로그인 화면 */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login-card { width: min(420px, 100%); background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-xl); box-shadow: var(--shadow); padding: 32px; display: grid; gap: 18px; }
.login-card .brand { justify-content: center; }

/* 모바일 하단 탭바 */
.bottom-tab { display: none; }

@media (max-width: 720px) {
  .hamburger { display: block; }
  .sidebar { display: none; }            /* 햄버거로 토글 */
  .sidebar.open { display: flex; position: fixed; inset: 0 25% 0 0; z-index: 90; height: 100vh; background: #fff; }
  .app-shell { grid-template-columns: 1fr; }
  .topbar { flex-direction: row; align-items: center; gap: 10px; }
  .content { padding-bottom: 90px; }     /* 하단 탭바 공간 */
  .bottom-tab {
    display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; bottom: 0; left: 0; right: 0; z-index: 70;
    background: rgba(255,255,255,0.96); border-top: 1px solid var(--line); backdrop-filter: blur(14px); padding: 6px 0 max(6px, env(safe-area-inset-bottom));
  }
  .bottom-tab a { display: grid; place-items: center; gap: 2px; text-decoration: none; color: var(--muted); font-size: 18px; padding: 6px 0; min-height: 44px; }
  .bottom-tab a span { font-size: 11px; font-weight: 700; }
}

/* =====================================================================
   디자인 다듬기 (v1.1) — 일관성·반응형·접근성 보강
   ===================================================================== */

/* 아이콘 정렬: 메뉴/버튼 SVG 세로 중앙 */
.nav-item .icon svg, .notification-button svg, .bottom-tab a svg, .kpi-icon svg { display: block; }
.btn-row svg, .chip svg { vertical-align: middle; }

/* 버튼/링크 포커스 접근성 (키보드 탭) */
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--brand); outline-offset: 2px;
}

/* KPI 카드 숫자 가독성 */
.kpi strong { line-height: 1.1; }
.card.compact.kpi { min-height: 92px; }

/* 상단바 액션 영역 줄바꿈 허용 + 설치/알림 버튼 톤 */
.top-actions { flex-wrap: wrap; }
#pwaInstallBtn, #pushOnBtn { font-size: 13px; padding: 8px 12px; }

/* 칩 안의 작은 배지(읽음 등) 정렬 */
.message-head .chip { vertical-align: middle; }

/* 테이블: 헤더 고정 느낌 + 행 구분 강화 */
.member-table th { position: sticky; top: 0; z-index: 1; }
.member-table td { font-size: 14px; }

/* 폼 도움말 텍스트 */
.form small.muted { font-weight: 500; font-size: 12px; }

/* details 토글(부서 수정/멤버 초대 등) 기본 마커 정리 */
details > summary { outline: none; }
details > summary::-webkit-details-marker { display: none; }

/* 빈 상태 아이콘 여백 */
.empty { line-height: 1.5; }

/* 로딩 스피너 (ajax 영역용 유틸) */
.spinner { width: 22px; height: 22px; border: 3px solid var(--line); border-top-color: var(--brand); border-radius: 50%; animation: spin 0.7s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }

/* 상태 배지를 사이드바 채널 목록에서 인라인 표시 */
.channel-button .badge { position: static; display: inline-grid; min-width: 18px; height: 18px; font-size: 11px; margin-left: 4px; }

/* 토스트: 모바일에서 하단 탭바 위로 */
@media (max-width: 720px) {
  .toast-area { bottom: 96px; right: 12px; left: 12px; }
  .toast { max-width: none; }
  h1 { font-size: 22px; }
  .card { padding: 18px; border-radius: 18px; }
  .card-head { flex-direction: column; align-items: flex-start; gap: 10px; }
  .approval-flow { font-size: 11px; }
  /* 모바일 사이드바 오픈 시 어둡게 */
  .sidebar.open { inset: 0 20% 0 0; box-shadow: 0 0 0 100vmax rgba(0,0,0,0.35); }
}

/* 태블릿: 4열 KPI → 2열 */
@media (max-width: 1080px) and (min-width: 721px) {
  .grid.four { grid-template-columns: repeat(2, minmax(0,1fr)); }
}

/* 인쇄 시 사이드바/탭바 숨김 (근태표·보고 출력 대비) */
@media print {
  .sidebar, .topbar, .bottom-tab, .btn-row, .paging { display: none !important; }
  .app-shell { display: block; }
  .card { box-shadow: none; border: 1px solid #ccc; }
}

/* =====================================================================
   모바일 UX/UI 최적화 v2.1
   - 상단바 간소화, 출퇴근 카드, 날짜 범위 검색, 구성원 테이블 카드화
   ===================================================================== */

/* 날짜 범위 검색바 (공통) */
.date-range-bar {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.date-range-bar .date-field {
  flex: 1;
  min-width: 130px;
  display: grid;
  gap: 5px;
}
.date-range-bar .date-field small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}
.date-range-bar .date-field input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 13px;
  padding: 10px 12px;
  background: #fff;
  color: var(--ink);
  outline: none;
}
.date-range-bar .date-field input:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(37,104,90,0.12);
}
.date-range-bar .sep {
  color: var(--muted);
  padding-bottom: 10px;
  flex-shrink: 0;
  font-size: 16px;
}
.date-range-bar .submit-btn {
  flex-shrink: 0;
  align-self: flex-end;
}

/* 사이드바 하단 — 사용자 정보 (모바일에서만 표시) */
.sidebar-user-mobile { display: none; }

@media (max-width: 720px) {
  /* ── 상단바 간소화 ── */
  /* PWA 설치·알림 버튼은 모바일 상단바에서 숨기고 사이드바로 이동 */
  #pwaInstallBtn, #pushToggleBtn { display: none !important; }
  /* 사용자명·로그아웃 → 사이드바 하단에서 접근 */
  .topbar-user-name { display: none; }
  .topbar-logout    { display: none; }

  /* ── 사이드바 하단: 사용자 정보 + 로그아웃 표시 ── */
  .sidebar-user-mobile {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-top: 1px solid var(--line);
    padding-top: 12px;
    margin-bottom: 6px;
    gap: 10px;
  }
  .sidebar-user-mobile .su-name {
    font-weight: 800;
    color: var(--brand-dark);
    font-size: 14px;
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .sidebar-user-mobile .su-logout {
    font-size: 13px;
    padding: 7px 12px;
    white-space: nowrap;
    flex-shrink: 0;
  }

  /* ── 출퇴근 카드: 세로 배치, 시계·버튼 크게 ── */
  .attendance-card {
    grid-template-columns: 1fr;
    text-align: center;
    gap: 20px;
  }
  .time-big {
    font-size: 54px;
    letter-spacing: -0.06em;
  }
  .attendance-card .meta     { justify-content: center; }
  .attendance-card p.muted   { text-align: center; font-size: 13px; }
  .attendance-card .btn-row  { flex-direction: column; gap: 10px; }
  /* 폼 감싸진 버튼도 전체 너비 */
  .attendance-card .btn-row form { width: 100%; }
  .attendance-card .btn-row .primary,
  .attendance-card .btn-row a.ghost {
    display: block;
    width: 100%;
    text-align: center;
    padding: 15px;
    border-radius: 18px;
    font-size: 16px;
    box-sizing: border-box;
  }

  /* ── 날짜 범위 검색바 모바일 ── */
  .date-range-bar .date-field { min-width: 0; }
  .date-range-bar .submit-btn { width: 100%; justify-content: center; }

  /* ── 구성원 현황 테이블 → 카드형 ── */
  .member-table             { display: block; }
  .member-table thead       { display: none; }
  .member-table tbody       { display: grid; gap: 10px; }
  .member-table tr {
    display: grid;
    grid-template-columns: 1fr 1fr;
    column-gap: 16px;
    row-gap: 4px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 14px;
    background: var(--panel-soft);
  }
  .member-table td {
    display: flex;
    flex-direction: column;
    gap: 3px;
    border: 0;
    padding: 4px 0;
    font-size: 13px;
    vertical-align: top;
  }
  /* data-label 을 컬럼 제목으로 표시 */
  .member-table td[data-label]::before {
    content: attr(data-label);
    color: var(--muted);
    font-weight: 700;
    font-size: 11px;
    letter-spacing: 0.04em;
    text-transform: uppercase;
  }
  /* 이름 셀: 전체 너비 + 하단 구분선 */
  .member-table td.col-name {
    grid-column: 1 / -1;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 6px;
    border-bottom: 1px solid var(--line);
    padding-bottom: 10px;
    margin-bottom: 2px;
  }
  .member-table td.col-name::before { display: none; }
  /* 상태·위치 셀: 전체 너비 + 가로 배치 */
  .member-table td.col-status,
  .member-table td.col-loc {
    grid-column: 1 / -1;
    flex-direction: row;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
  }
  /* 출·퇴근 셀: 폰트 키우기 */
  .member-table td.col-in,
  .member-table td.col-out { font-size: 15px; font-weight: 700; }
  /* col-name에서 근무형태 칩으로 이미 표시 → 별도 열 숨기기 */
  .member-table td.col-wtype { display: none; }
  /* 카드 호버 효과 */
  .member-table tr:hover td { background: transparent; }
  .member-table tr:hover     { background: #f3f8f5; border-color: rgba(37,104,90,0.25); }
}

/* 안내 박스 — 운영 콘솔·폼 상단 주의문구 (legal.php .note 와 동일 톤) */
.note {
  background: var(--panel-soft);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 13px 15px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.6;
}
.note strong { color: var(--ink); }
