:root {
  --bg: #f3f4f7;
  --surface: #fff;
  --line: #e4e6ec;
  --line-2: #eef0f4;
  --text: #1c2130;
  --text-2: #5b6273;
  --text-3: #8b92a3;
  --primary: #3b5bdb;
  --primary-soft: #edf2ff;
  --teal: #0c8599;
  --teal-soft: #e3fafc;
  --amber: #e8590c;
  --amber-soft: #fff4e6;
  --red: #e03131;
  --red-soft: #fff5f5;
  --green: #2b8a3e;
  --green-soft: #ebfbee;
  --violet: #7048e8;
  --violet-soft: #f3f0ff;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(20, 24, 40, .05), 0 2px 8px rgba(20, 24, 40, .04);
  font-family: "Pretendard Variable", Pretendard, "Malgun Gothic", "맑은 고딕", system-ui, sans-serif;
  color: var(--text);
  font-size: 15px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); }
button { font: inherit; color: inherit; cursor: pointer; }
input, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* 버튼 */
.btn { border: 1px solid var(--line); background: var(--surface); border-radius: 9px; padding: 7px 12px; font-size: 14px; font-weight: 600; transition: background .15s, border-color .15s, transform .1s; }
.btn:hover { background: #f8f9fb; }
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: #3049c4; }
.btn.wide { width: 100%; padding: 11px; font-size: 15px; }
.btn.sm { padding: 5px 10px; font-size: 13px; }
.btn.go { background: var(--primary-soft); border-color: #d0dbff; color: var(--primary); }
.btn.go:hover { background: #dfe7ff; }
.icon-btn { border: 0; background: transparent; width: 36px; height: 36px; border-radius: 9px; display: inline-grid; place-items: center; color: var(--text-2); position: relative; }
.icon-btn:hover { background: var(--line-2); color: var(--text); }

.mark { width: 28px; height: 28px; border-radius: 8px; background: linear-gradient(135deg, #4c6ef5, #15aabf); color: #fff; font-weight: 800; display: inline-grid; place-items: center; font-size: 16px; }

/* 로그인 */
.login { min-height: 100%; display: grid; place-items: center; padding: 24px;
  background: radial-gradient(1200px 600px at 10% -10%, #dbe4ff 0, transparent 60%), radial-gradient(900px 500px at 110% 110%, #c5f6fa 0, transparent 55%), var(--bg); }
.login-card { width: 100%; max-width: 380px; background: var(--surface); border-radius: 18px; padding: 30px 28px 22px; box-shadow: 0 10px 40px rgba(30, 40, 90, .12); display: grid; gap: 14px; }
.brand-lg { display: flex; gap: 12px; align-items: center; margin-bottom: 6px; }
.brand-lg .mark { width: 44px; height: 44px; border-radius: 12px; font-size: 24px; }
.brand-lg b { font-size: 22px; display: block; }
.brand-lg small { color: var(--text-3); }
.login-card label { display: grid; gap: 6px; font-size: 13px; color: var(--text-2); font-weight: 600; }
.login-card input { border: 1px solid var(--line); border-radius: 9px; padding: 10px 12px; font-size: 15px; outline: none; }
.login-card input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.err { color: var(--red); font-size: 13px; margin: 0; min-height: 1em; }
.test-accounts { border-top: 1px dashed var(--line); padding-top: 12px; font-size: 12px; color: var(--text-3); }
.test-accounts > div { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.test-accounts button { border: 1px solid var(--line); background: #fafbfc; border-radius: 999px; padding: 5px 11px; font-size: 13px; }
.test-accounts button:hover { border-color: var(--primary); color: var(--primary); }
.foot { margin: 0; text-align: center; font-size: 12px; color: var(--text-3); }

/* 본 화면 */
.app { height: 100%; display: flex; flex-direction: column; }
.top { height: 54px; flex: none; display: flex; align-items: center; justify-content: space-between; padding: 0 12px 0 14px; background: var(--surface); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 8px; font-size: 16px; }
.pill { font-size: 11px; font-weight: 700; padding: 3px 8px; border-radius: 999px; background: var(--line-2); color: var(--text-3); }
.pill.on { background: var(--green-soft); color: var(--green); }
.pill.off { background: var(--amber-soft); color: var(--amber); }
.top-right { display: flex; align-items: center; gap: 4px; position: relative; }
.online { font-size: 12px; color: var(--text-3); margin-right: 6px; white-space: nowrap; }
.online::before { content: ''; display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: #40c057; margin-right: 5px; vertical-align: 1px; }
.me { display: flex; align-items: center; gap: 7px; font-size: 14px; font-weight: 600; padding: 0 6px; }
.avatar { width: 28px; height: 28px; border-radius: 50%; background: var(--primary-soft); color: var(--primary); display: inline-grid; place-items: center; font-size: 13px; font-weight: 800; }
#bellCount { position: absolute; top: 3px; right: 2px; min-width: 17px; height: 17px; border-radius: 9px; background: var(--red); color: #fff; font-size: 10.5px; font-style: normal; font-weight: 700; display: grid; place-items: center; padding: 0 4px; }
.menu { position: absolute; top: 44px; right: 0; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 8px 28px rgba(20, 24, 40, .14); padding: 5px; z-index: 20; min-width: 170px; }
.menu button { display: block; width: 100%; text-align: left; border: 0; background: none; padding: 9px 11px; border-radius: 7px; font-size: 14px; }
.menu button:hover { background: var(--line-2); }

.tabs { display: none; }
.main { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(330px, 420px) 1fr; }

/* 보드 */
.board { overflow-y: auto; padding: 16px 14px 30px; border-right: 1px solid var(--line); }
.board-head { display: flex; align-items: baseline; gap: 8px; margin: 0 2px 6px; }
.board-head h2 { margin: 0; font-size: 18px; }
.board-head .sub { font-size: 12px; color: var(--text-3); }
.sec { margin-top: 18px; }
.sec h3, .sec summary { font-size: 13px; font-weight: 700; color: var(--text-2); margin: 0 2px 8px; display: flex; align-items: center; gap: 6px; }
.sec summary { cursor: pointer; list-style: none; }
.sec summary::-webkit-details-marker { display: none; }
.sec summary::after { content: '›'; transition: transform .15s; }
.sec[open] summary::after { transform: rotate(90deg); }
.cnt { background: var(--line-2); color: var(--text-2); font-size: 11.5px; border-radius: 999px; padding: 1px 7px; }
.cards { display: grid; gap: 8px; }
.empty { font-size: 13px; color: var(--text-3); padding: 12px; border: 1px dashed var(--line); border-radius: var(--radius); text-align: center; background: rgba(255,255,255,.5); }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 11px 12px 10px; box-shadow: var(--shadow); animation: pop .25s ease; }
.card.fresh { border-color: #bac8ff; box-shadow: 0 0 0 3px var(--primary-soft); }
.card-top { display: flex; align-items: center; gap: 6px; margin-bottom: 4px; }
.kind { font-size: 11px; font-weight: 800; padding: 2px 7px; border-radius: 6px; }
.kind.지시 { background: var(--primary-soft); color: var(--primary); }
.kind.요청 { background: var(--violet-soft); color: var(--violet); }
.kind.협조 { background: var(--teal-soft); color: var(--teal); }
.kind.공유 { background: var(--line-2); color: var(--text-2); }
.dday { margin-left: auto; font-size: 12px; font-weight: 800; padding: 2px 8px; border-radius: 999px; background: var(--line-2); color: var(--text-2); }
.dday.soon { background: var(--amber-soft); color: var(--amber); }
.dday.today { background: #ffe8cc; color: #d9480f; }
.dday.over { background: var(--red-soft); color: var(--red); }
.card-title { font-weight: 700; font-size: 15px; line-height: 1.35; }
.card-meta { font-size: 12.5px; color: var(--text-3); margin-top: 3px; }
.card-detail { font-size: 13px; color: var(--text-2); margin-top: 6px; line-height: 1.45; }
.card-actions { display: flex; gap: 6px; margin-top: 10px; align-items: center; }
.state { font-size: 12px; color: var(--text-3); margin-right: auto; }
.state b { color: var(--text-2); }
.chipset { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 8px; }
.st { font-size: 12px; padding: 2px 8px; border-radius: 999px; background: var(--line-2); color: var(--text-2); }
.st.확인 { background: var(--primary-soft); color: var(--primary); }
.st.진행중 { background: var(--amber-soft); color: var(--amber); }
.st.완료 { background: var(--green-soft); color: var(--green); }

/* 차량 타임라인 */
.cars { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px 8px; box-shadow: var(--shadow); }
.car { display: grid; grid-template-columns: 78px 1fr; align-items: center; gap: 8px; padding: 5px 0; }
.car-name { font-size: 13px; font-weight: 700; }
.car-name small { display: block; font-size: 11px; color: var(--text-3); font-weight: 500; }
.track { position: relative; height: 24px; background: repeating-linear-gradient(90deg, var(--line-2) 0 1px, transparent 1px calc(100% / 11)); border-radius: 6px; background-color: #fafbfc; }
.seg { position: absolute; top: 2px; bottom: 2px; border-radius: 5px; background: #99e9f2; color: #0b7285; font-size: 10.5px; font-weight: 700; padding: 0 5px; overflow: hidden; white-space: nowrap; display: flex; align-items: center; }
.seg.mine { background: #bac8ff; color: #364fc7; }
.now-line { position: absolute; top: -3px; bottom: -3px; width: 2px; background: var(--red); border-radius: 2px; }
.hours { display: grid; grid-template-columns: 78px 1fr; gap: 8px; font-size: 10.5px; color: var(--text-3); }
.hours div:last-child { display: flex; justify-content: space-between; }
.leaves { display: flex; flex-wrap: wrap; gap: 6px; }
.leave { background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 5px 11px; font-size: 13px; }
.leave b { font-weight: 700; }
.leave span { color: var(--text-3); margin-left: 4px; }

/* 대화 */
.chat { display: flex; flex-direction: column; min-height: 0; background: linear-gradient(#f7f8fb, #f3f4f7); }
.msgs { flex: 1; overflow-y: auto; padding: 20px 22px 10px; display: flex; flex-direction: column; gap: 10px; }
.msg { max-width: min(640px, 86%); line-height: 1.55; font-size: 14.5px; animation: pop .2s ease; }
.msg.user { align-self: flex-end; background: var(--primary); color: #fff; padding: 9px 13px; border-radius: 14px 14px 4px 14px; white-space: pre-wrap; }
.msg.assistant { align-self: flex-start; display: flex; gap: 9px; }
.msg.assistant .mark { flex: none; width: 26px; height: 26px; font-size: 13px; border-radius: 8px; margin-top: 2px; }
.msg.assistant .bubble { background: var(--surface); border: 1px solid var(--line); padding: 9px 13px; border-radius: 4px 14px 14px 14px; box-shadow: var(--shadow); }
.bubble p { margin: 0 0 6px; } .bubble p:last-child { margin: 0; }
.bubble ul, .bubble ol { margin: 4px 0 6px; padding-left: 20px; }
.bubble code { background: var(--line-2); padding: 1px 5px; border-radius: 4px; font-size: 13px; }
.bubble table { border-collapse: collapse; font-size: 13px; margin: 4px 0; }
.bubble td, .bubble th { border: 1px solid var(--line); padding: 4px 8px; }
.msg.activity { align-self: flex-start; margin-left: 35px; font-size: 12.5px; color: var(--text-2); background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 4px 11px; display: flex; gap: 8px; align-items: center; }
.msg.activity a { color: var(--primary); cursor: pointer; font-weight: 600; }
.msg.error { align-self: center; font-size: 13px; color: var(--red); background: var(--red-soft); border-radius: 8px; padding: 6px 12px; }
.typing { align-self: flex-start; margin-left: 35px; display: flex; gap: 4px; padding: 10px 12px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; }
.typing i { width: 6px; height: 6px; border-radius: 50%; background: var(--text-3); animation: blink 1.2s infinite; }
.typing i:nth-child(2) { animation-delay: .15s; } .typing i:nth-child(3) { animation-delay: .3s; }
.welcome { margin: auto; text-align: center; color: var(--text-2); max-width: 420px; padding: 20px; }
.welcome .mark { width: 46px; height: 46px; font-size: 24px; border-radius: 14px; margin-bottom: 10px; }
.welcome h3 { margin: 0 0 6px; color: var(--text); }
.welcome p { margin: 0; font-size: 14px; line-height: 1.6; }

.composer { flex: none; padding: 8px 16px 14px; }
.chips { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 8px; scrollbar-width: none; }
.chips button { flex: none; border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 5px 11px; font-size: 13px; color: var(--text-2); }
.chips button:hover { border-color: var(--primary); color: var(--primary); }
.input-row { display: flex; align-items: flex-end; gap: 6px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 6px 6px 6px 12px; box-shadow: var(--shadow); }
.input-row:focus-within { border-color: #91a7ff; box-shadow: 0 0 0 3px var(--primary-soft); }
#input { flex: 1; border: 0; outline: none; resize: none; padding: 7px 0; max-height: 140px; font-size: 15px; line-height: 1.45; background: transparent; }
.send { width: 38px; height: 36px; padding: 0; display: grid; place-items: center; border-radius: 10px; }
.send:disabled { opacity: .45; cursor: default; }
.mic.rec { color: var(--red); background: var(--red-soft); animation: pulse 1.2s infinite; }

/* 알림 서랍 */
.drawer { position: fixed; top: 54px; right: 0; bottom: 0; width: min(360px, 100%); background: var(--surface); border-left: 1px solid var(--line); box-shadow: -8px 0 30px rgba(20, 24, 40, .1); z-index: 15; display: flex; flex-direction: column; }
.drawer-head { display: flex; justify-content: space-between; align-items: center; padding: 10px 14px; border-bottom: 1px solid var(--line); }
#noticeList { overflow-y: auto; padding: 8px; }
.notice { padding: 10px 10px; border-radius: 9px; font-size: 13.5px; line-height: 1.45; }
.notice + .notice { border-top: 1px solid var(--line-2); }
.notice small { display: block; color: var(--text-3); font-size: 11.5px; margin-top: 2px; }

/* 토스트 */
.toasts { position: fixed; right: 16px; bottom: 16px; display: grid; gap: 8px; z-index: 30; }
.toast { background: #1f2433; color: #fff; padding: 11px 14px; border-radius: 11px; font-size: 14px; max-width: 340px; box-shadow: 0 10px 30px rgba(0, 0, 0, .2); animation: slide .25s ease; display: flex; gap: 10px; align-items: flex-start; }
.toast b { color: #91a7ff; }

@keyframes pop { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
@keyframes slide { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: none; } }
@keyframes blink { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }
@keyframes pulse { 50% { box-shadow: 0 0 0 5px rgba(224, 49, 49, .12); } }

/* 좁은 창 (화면 옆에 세워 두는 모드) */
@media (max-width: 860px) {
  .tabs { display: flex; background: var(--surface); border-bottom: 1px solid var(--line); padding: 0 10px; }
  .tabs button { flex: 1; border: 0; background: none; padding: 10px; font-weight: 700; color: var(--text-3); border-bottom: 2px solid transparent; font-size: 14px; }
  .tabs button.on { color: var(--primary); border-color: var(--primary); }
  .tabs i { font-style: normal; background: var(--red); color: #fff; border-radius: 999px; font-size: 11px; padding: 1px 6px; margin-left: 3px; }
  .tabs i:empty { display: none; }
  .main { grid-template-columns: 1fr; }
  .board { border-right: 0; }
  .main[data-tab="board"] .chat, .main[data-tab="chat"] .board { display: none; }
  .online, #meName { display: none; }
  .msgs { padding: 14px 12px 8px; }
  .composer { padding: 6px 10px 10px; }
}

/* 기관 구글 계정 로그인 (클라우드 서버) */
.google-box { display: grid; justify-items: center; gap: 6px; margin: 2px 0 6px; }
#pwBox { display: grid; gap: 14px; }
