/* Tertlep — 진짜 반응형. 데스크톱=좌측 레일+대시보드 / 모바일=드로어+스택. */
/* 카톡식 라이트·미니멀: 화이트 배경 + 검은 글씨, 색은 최소(미읽음/강조만). */
:root {
  --bg: #ffffff;
  --surface: #ffffff;
  --surface-2: #f3f4f6;   /* hover/active 옅은 회색 */
  --line: #ececee;
  --text: #191919;
  --muted: #8e949e;
  --accent: #2f6fed;
  --accent-soft: #eaf1fd;
  --good: #18a957;
  --warn: #d97706;
  --bad: #ef4444;
  --unread: #ff3b30;
  --radius: 14px;
  --rail-w: 132px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg); color: var(--text);
  font-family: -apple-system, "Segoe UI", "Malgun Gothic", system-ui, sans-serif;
  font-size: 15px; line-height: 1.5;
}

/* ── 레이아웃 셸 ──────────────────────────────────────── */
.app { display: flex; min-height: 100vh; }
.main-col { flex: 1; min-width: 0; display: flex; flex-direction: column; }

/* 좌측 레일 */
.rail {
  width: var(--rail-w); flex-shrink: 0;
  background: var(--surface); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; gap: 4px;
  padding: 14px 10px; padding-top: calc(14px + env(safe-area-inset-top));
}
.rail-brand { background: none; border: 0; color: var(--text); font-size: 17px; font-weight: 800; letter-spacing: -0.3px; text-align: left; padding: 4px 8px 12px; }
.rail-nav { display: flex; flex-direction: column; gap: 2px; }
.rail-nav button {
  display: flex; align-items: center; gap: 10px;
  background: none; border: 0; color: var(--muted);
  padding: 11px 10px; border-radius: 10px; font-size: 14.5px; font-weight: 600; text-align: left;
}
.rail-nav button .ic { font-size: 17px; line-height: 1; width: 20px; text-align: center; }
.rail-nav button .dot { margin-left: auto; width: 7px; height: 7px; border-radius: 50%; background: var(--bad); }
.rail-nav button:hover { color: var(--text); background: var(--surface-2); }
.rail-nav button.active { color: var(--accent); background: var(--accent-soft); }
.rail-scrim { display: none; }

/* ── 상단 바 ─────────────────────────────────────────── */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px; padding-top: calc(12px + env(safe-area-inset-top));
  background: rgba(255,255,255,0.92); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.org { font-size: 14.5px; color: var(--muted); }
.org b { color: var(--text); font-weight: 700; }
.top-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.icon-btn { background: none; border: 0; color: var(--text); font-size: 20px; line-height: 1; padding: 4px 6px; border-radius: 8px; }
.icon-btn:hover { background: var(--surface-2); }
.hamburger { display: none; }
.mode-badge { font-size: 11px; color: var(--muted); border: 1px solid var(--line); border-radius: 999px; padding: 3px 9px; }
.mode-badge.live { color: var(--good); border-color: var(--good); cursor: pointer; }

/* ── 뷰 ──────────────────────────────────────────────── */
.view { padding: 18px; max-width: 860px; width: 100%; margin: 0 auto; flex: 1; }
.view-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 4px; }
.view-head h1 { font-size: 21px; margin: 0; letter-spacing: -0.3px; }
.view-sub { color: var(--muted); font-size: 13px; margin: 2px 0 16px; }

/* ── 대시보드 홈 ─────────────────────────────────────── */
.home { display: flex; flex-direction: column; gap: 16px; }
.home-sec { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: 0 1px 2px rgba(0,0,0,.04); }
.home-sec .sec-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.home-sec .sec-head h2 { font-size: 17px; margin: 0; }
.home-sec .more { background: none; border: 0; color: var(--accent); font-size: 13px; font-weight: 600; }
.home-row { padding: 9px 0; border-top: 1px solid var(--line); display: flex; gap: 10px; align-items: baseline; }
.home-row:first-of-type { border-top: 0; }
.home-row .when { color: var(--muted); font-size: 12.5px; white-space: nowrap; }
.notice-pin { display: inline-block; font-size: 11px; color: var(--warn); border: 1px solid var(--warn); border-radius: 6px; padding: 1px 6px; margin-right: 6px; }

/* ── 업무 런처 (구글 설정 스타일) ────────────────────── */
.work-list { display: flex; flex-direction: column; gap: 4px; }
.work-item {
  display: flex; align-items: center; gap: 14px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px;
  padding: 13px 14px; cursor: pointer; width: 100%; text-align: left; color: var(--text);
  box-shadow: 0 1px 2px rgba(0,0,0,.04);
}
.work-item:hover, .work-item:active { background: var(--surface-2); }
.work-ic { width: 38px; height: 38px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 19px; flex-shrink: 0; }
.work-item .w-label { font-size: 15px; font-weight: 600; }
.work-item .w-note { font-size: 12px; color: var(--muted); }
.work-item .w-chev { margin-left: auto; color: var(--muted); }
@media (min-width: 620px) { .work-list { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; } }

/* ── 카드/리스트 (기능 뷰) ───────────────────────────── */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 15px; margin-bottom: 10px; box-shadow: 0 1px 2px rgba(0,0,0,.04); }
/* 그룹 리스트 — 설정/카톡식 깔끔한 행 묶음(기능 목록에 사용). 박스 카드 대신. */
.list-group { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: 0 1px 2px rgba(0,0,0,.04); }
.list-row { display: flex; flex-direction: column; gap: 3px; padding: 13px 15px; cursor: pointer; }
.list-row + .list-row { border-top: 1px solid var(--line); }
.list-row:hover, .list-row:active { background: var(--surface-2); }
.list-row h3 { margin: 0; font-size: 15.5px; font-weight: 600; }
.list-row .meta { color: var(--muted); font-size: 12.5px; }
.list-row .body { color: var(--text); font-size: 13.5px; white-space: pre-wrap; }
.card-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.card h3 { margin: 0 0 4px; font-size: 16px; }
.card .meta { color: var(--muted); font-size: 12.5px; }
.card .body { margin-top: 6px; color: var(--text); font-size: 14px; white-space: pre-wrap; }
.empty { text-align: center; color: var(--muted); padding: 48px 16px; }
.empty .big { font-size: 15px; color: var(--text); margin-bottom: 6px; }

/* ── 배지 ────────────────────────────────────────────── */
.badge { font-size: 11px; padding: 2px 8px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); white-space: nowrap; }
.badge.scope { color: var(--accent); border-color: var(--accent-soft); background: var(--accent-soft); }
.badge.planned { color: var(--accent); }
.badge.done { color: var(--good); border-color: var(--good); }
.badge.canceled, .badge.dropped { color: var(--muted); text-decoration: line-through; }
.badge.open { color: var(--warn); border-color: var(--warn); }
.badge.in_progress { color: var(--accent); border-color: var(--accent); }

/* ── 버튼/입력 ───────────────────────────────────────── */
.btn { appearance: none; border: 1px solid var(--line); background: var(--surface-2); color: var(--text); font-size: 14px; font-weight: 600; padding: 10px 14px; border-radius: 10px; cursor: pointer; }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.ghost { background: none; }
.btn.sm { padding: 6px 10px; font-size: 13px; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }
.fab { position: fixed; right: 22px; bottom: 22px; z-index: 20; width: 54px; height: 54px; border-radius: 50%; background: var(--accent); color: #08101f; border: 0; font-size: 28px; line-height: 1; box-shadow: 0 6px 20px rgba(79,140,255,.4); }

label.field { display: block; margin-bottom: 12px; }
label.field > span { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 5px; }
input, textarea, select { width: 100%; background: var(--bg); color: var(--text); border: 1px solid var(--line); border-radius: 10px; padding: 11px 12px; font-size: 15px; font-family: inherit; }
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--accent); }
textarea { min-height: 90px; resize: vertical; }
.sensitive-zone { border: 1px dashed var(--bad); border-radius: 12px; padding: 12px; margin-top: 8px; }
.sensitive-zone .tag { color: var(--bad); font-size: 11.5px; font-weight: 700; }

/* ── 이력 타임라인 ───────────────────────────────────── */
.timeline { border-left: 2px solid var(--line); margin-left: 6px; padding-left: 14px; }
.timeline .ev { position: relative; padding-bottom: 14px; }
.timeline .ev::before { content: ''; position: absolute; left: -21px; top: 4px; width: 9px; height: 9px; border-radius: 50%; background: var(--accent); border: 2px solid var(--bg); }
.timeline .ev .when { font-size: 12px; color: var(--muted); }
.timeline .ev .what { font-size: 14px; }
.timeline .ev .reason { font-size: 12.5px; color: var(--warn); margin-top: 2px; }

/* ── 모달 ────────────────────────────────────────────── */
.modal-bg { position: fixed; inset: 0; z-index: 50; background: rgba(0,0,0,.55); display: flex; align-items: flex-end; justify-content: center; }
.modal { background: var(--surface); width: 100%; max-width: 560px; border-radius: 18px 18px 0 0; border: 1px solid var(--line); padding: 18px 18px calc(18px + env(safe-area-inset-bottom)); max-height: 88vh; overflow-y: auto; }
.modal h2 { margin: 0 0 14px; font-size: 18px; }
@media (min-width: 600px) { .modal-bg { align-items: center; } .modal { border-radius: 18px; } }

/* ── 캐시플로우 ─────────────────────────────────────── */
.cash-summary { display: flex; gap: 12px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 12px; box-shadow: 0 1px 2px rgba(0,0,0,.04); }
.cash-summary > div { flex: 1; }
.cash-summary .cs-label { font-size: 12px; color: var(--muted); }
.cash-summary .cs-val { font-size: 20px; font-weight: 700; margin-top: 4px; }
.cash-summary .cs-val.muted { color: var(--muted); font-weight: 600; }
.cash-amt { font-size: 15px; font-weight: 700; white-space: nowrap; }
.cash-amt.in { color: var(--good); }
.cash-amt.out { color: var(--text); }
.cash-planned { color: var(--warn); }
.badge.actual { color: var(--muted); }
.inv-bal { font-size: 15px; font-weight: 700; white-space: nowrap; }
.inv-bal.low { color: var(--bad); }

.coming { color: var(--muted); font-size: 13px; border: 1px dashed var(--line); border-radius: 12px; padding: 16px; }
.coming b { color: var(--text); }
.stub-hero { text-align: center; padding: 40px 16px; }
.stub-hero .ic { font-size: 40px; }
.stub-hero .ph { display: inline-block; margin-top: 10px; font-size: 12px; color: var(--accent); border: 1px solid var(--accent-soft); background: var(--accent-soft); border-radius: 999px; padding: 4px 12px; }

/* ── 채팅 리스트 (카톡식: 선 없는 살짝 떨어진 구분, 2줄, 좌측 아바타) ──── */
.chat-wrap { max-width: 720px; margin: 0 auto; }
.chat-search { width: 100%; background: var(--surface-2); border: 0; border-radius: 10px; padding: 10px 13px; font-size: 14px; margin-bottom: 6px; }
.chat-row { display: flex; align-items: center; gap: 12px; padding: 11px 6px; border-radius: 12px; cursor: pointer; }
.chat-row:hover, .chat-row:active { background: var(--surface-2); }
.avatar { width: 48px; height: 48px; border-radius: 16px; flex-shrink: 0; display: flex; align-items: center; justify-content: center; color: #fff; font-weight: 700; font-size: 19px; font-family: -apple-system, "Segoe UI", "Malgun Gothic", sans-serif; }
.chat-mid { flex: 1; min-width: 0; }
.chat-title { display: flex; align-items: baseline; gap: 6px; }
.chat-name { font-size: 15.5px; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-count { font-size: 12.5px; color: var(--muted); flex-shrink: 0; }
.chat-preview { font-size: 13.5px; color: var(--muted); margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-right { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; flex-shrink: 0; }
.chat-time { font-size: 11.5px; color: var(--muted); }
.chat-badge { background: var(--unread); color: #fff; font-size: 11px; font-weight: 700; min-width: 18px; height: 18px; border-radius: 9px; padding: 0 5px; display: flex; align-items: center; justify-content: center; }
.chat-lock { font-size: 11.5px; color: var(--muted); }
/* PC: 더 크게 펼쳐 더 많은 정보 */
@media (min-width: 769px) {
  .chat-row { padding: 14px 10px; gap: 15px; }
  .avatar { width: 54px; height: 54px; font-size: 21px; }
  .chat-name { font-size: 16px; }
  .chat-preview { font-size: 14.5px; margin-top: 4px; }
}

/* ── 모바일 (≤768px): 레일 → 드로어 ──────────────────── */
@media (max-width: 768px) {
  .rail {
    position: fixed; left: 0; top: 0; bottom: 0; z-index: 60;
    width: 230px; display: none;        /* 닫힘 = 화면에서 제거(견고) */
  }
  .rail.open { display: flex; }          /* 열림 = 드로어 표시 */
  .rail-scrim.open { display: block; position: fixed; inset: 0; z-index: 55; background: rgba(0,0,0,.5); }
  .hamburger { display: block; }
  .view { padding: 16px; }
}
