: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; }
.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;
}
.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); }
.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: 13px; 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 12px; color: var(--ink); outline: none;
}
.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; }

.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)); }
  .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; }
}

/* =====================================================================
   누리워크 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; }
}
