:root {
  --bg: #f4f6fa;
  --card: #ffffff;
  --primary: #2b5797;
  --primary-d: #1f3f6e;
  --accent: #0a7d3b;
  --danger: #c0392b;
  --warn: #e08a00;
  --text: #1f2733;
  --muted: #6b7785;
  --border: #dde3ec;
  --shadow: 0 2px 10px rgba(30, 50, 90, 0.08);
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "Malgun Gothic", "맑은 고딕", system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
}
a { color: var(--primary); }
button {
  font-family: inherit; font-size: 14px; cursor: pointer;
  border: none; border-radius: 8px; padding: 9px 16px;
  background: var(--primary); color: #fff; transition: background .15s;
}
button:hover { background: var(--primary-d); }
button:disabled { background: #b9c2d0; cursor: not-allowed; }
button.ghost { background: #eef1f6; color: var(--text); }
button.ghost:hover { background: #e2e7f0; }
button.success { background: var(--accent); }
button.success:hover { background: #086230; }
button.danger { background: var(--danger); }
button.danger:hover { background: #99291c; }
button.sm { padding: 5px 10px; font-size: 13px; border-radius: 6px; }
input, select, textarea {
  font-family: inherit; font-size: 14px; padding: 9px 11px;
  border: 1px solid var(--border); border-radius: 8px; width: 100%;
  background: #fff; color: var(--text);
}
input:focus, textarea:focus, select:focus { outline: 2px solid #aac3ec; border-color: var(--primary); }
label { font-size: 13px; color: var(--muted); display: block; margin-bottom: 4px; font-weight: 600; }
.field { margin-bottom: 14px; }

/* 레이아웃 */
header.topbar {
  background: var(--primary); color: #fff; padding: 12px 20px;
  display: flex; align-items: center; justify-content: space-between;
  box-shadow: var(--shadow); position: sticky; top: 0; z-index: 50;
}
header.topbar .brand { font-weight: 700; font-size: 17px; display: flex; align-items: center; gap: 8px; }
header.topbar .user { font-size: 13px; display: flex; align-items: center; gap: 12px; }
header.topbar .user button { background: rgba(255,255,255,.18); padding: 6px 12px; }
header.topbar .user button:hover { background: rgba(255,255,255,.3); }
header.topbar .user .notif-btn.on { background: #ddf3e5; color: #0a7d3b; }
header.topbar .user .notif-btn.on:hover { background: #c8ebd5; }
.notif-btn { position: relative; }
.app-red-dot { display: none; position: absolute; top: 4px; right: 6px; width: 9px; height: 9px; border-radius: 50%; background: var(--danger); box-shadow: 0 0 0 2px #fff; }
.app-red-dot.show { display: block; }
.app-version { opacity: .8; font-size: 12px; }

/* 관리자 홈 운영 주의 배너 */
.ops-notice {
  background: #fff4e5; border: 1.5px solid #f0b86c; border-left: 6px solid #e8821e;
  border-radius: 10px; padding: 14px 18px; margin-bottom: 16px;
  box-shadow: 0 1px 4px rgba(232,130,30,.15);
}
.ops-notice .ops-head { font-weight: 800; color: #b5530a; font-size: 15.5px; margin-bottom: 8px; }
.ops-notice ul { margin: 0; padding-left: 20px; font-size: 13.5px; line-height: 1.85; color: #5a4632; }
.ops-notice ul b { color: #9a4408; }
.ops-notice .muted { color: #9b8a76; }

.container { max-width: 920px; margin: 0 auto; padding: 20px; }
.center-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.card { background: var(--card); border-radius: 14px; box-shadow: var(--shadow); padding: 24px; }
.card.tight { padding: 18px; }
.card + .card { margin-top: 18px; }
.auth-card { width: 100%; max-width: 400px; }
.auth-card h1 { font-size: 20px; margin: 0 0 4px; }
.auth-card .sub { color: var(--muted); font-size: 13px; margin-bottom: 20px; }

h2.section { font-size: 17px; margin: 0 0 14px; display: flex; align-items: center; justify-content: space-between; }
.tabs { display: flex; gap: 8px; margin-bottom: 18px; flex-wrap: wrap; }
.tabs button { background: #e7ecf4; color: var(--text); }
.tabs button.active { background: var(--primary); color: #fff; }

/* 브랜드 로고 */
.brand-logo { height: 26px; width: 26px; vertical-align: middle; margin-right: 8px; }
.auth-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 18px; font-weight: 700; color: var(--primary); font-size: 16px; }
.auth-brand img { height: 34px; width: 34px; }

/* 메뉴 토글(모바일) */
.menu-toggle { display: none; background: rgba(255,255,255,.18); padding: 4px 10px; font-size: 18px; margin-right: 6px; line-height: 1; }
.menu-toggle:hover { background: rgba(255,255,255,.3); }

/* 사이드바 레이아웃 */
.layout { display: flex; align-items: flex-start; min-height: calc(100vh - 56px); }
.sidebar { width: 210px; flex-shrink: 0; background: var(--card); border-right: 1px solid var(--border); padding: 16px 12px; min-height: calc(100vh - 56px); }
.nav-item { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; background: transparent; color: var(--text); padding: 12px 14px; border-radius: 9px; margin-bottom: 6px; font-size: 14.5px; }
.nav-item:hover { background: #eef2f8; }
.nav-item.active { background: var(--primary); color: #fff; }
.nav-item .ic { font-size: 16px; }
.sidebar-backdrop { display: none; }
.content { flex: 1; min-width: 0; padding: 20px; max-width: 940px; }

/* 사용방법 안내 */
.guide { margin-top: 8px; }
.guide-step { display: flex; gap: 14px; padding: 12px 0; border-bottom: 1px dashed var(--border); }
.guide-step:last-child { border-bottom: none; }
.gnum { flex-shrink: 0; width: 30px; height: 30px; border-radius: 50%; background: var(--primary); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; }
.gtitle { font-weight: 700; margin-bottom: 3px; }
.gtxt { font-size: 14px; line-height: 1.6; }

@media (max-width: 760px) {
  .menu-toggle { display: inline-block; }
  .layout { display: block; }
  .sidebar { position: fixed; top: 0; left: 0; height: 100vh; z-index: 110; transform: translateX(-100%); transition: transform .2s; box-shadow: 2px 0 16px rgba(0,0,0,.2); }
  .sidebar.open { transform: translateX(0); }
  .sidebar-backdrop.show { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 105; }
  .content { padding: 14px; max-width: none; }
}

/* 테이블 */
/* 좁은 화면(휴대폰)에서 표가 잘리지 않고 옆으로 스크롤되게 감싼다 */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table-wrap table { min-width: 560px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 9px 8px; border-bottom: 1px solid var(--border); }
th { color: var(--muted); font-weight: 600; font-size: 12.5px; }
td.num, th.num { text-align: right; }
tr.clickable { cursor: pointer; }
tr.clickable:hover { background: #f6f9fd; }

/* 뱃지 */
.badge { display: inline-block; padding: 2px 9px; border-radius: 20px; font-size: 12px; font-weight: 600; }
.badge.draft { background: #eceff3; color: #62707f; }
.badge.pending { background: #fff3da; color: #a96a00; }
.badge.approved { background: #ddf3e5; color: #0a7d3b; }
.badge.rejected { background: #fbe0dc; color: #c0392b; }
.badge.dot { background: var(--danger); color: #fff; border-radius: 20px; padding: 1px 8px; font-size: 11px; margin-left: 6px; }

/* 결재라인 미니 */
.line-mini { display: flex; gap: 6px; flex-wrap: wrap; }
.line-mini .step { font-size: 11px; padding: 2px 7px; border-radius: 6px; background: #eef1f6; color: #62707f; }
.line-mini .step.approved { background: #ddf3e5; color: #0a7d3b; }
.line-mini .step.rejected { background: #fbe0dc; color: #c0392b; }
.line-mini .step.current { background: #fff3da; color: #a96a00; outline: 1.5px solid #e6b450; }

.row { display: flex; gap: 12px; flex-wrap: wrap; }
.row > * { flex: 1; min-width: 0; }
.muted { color: var(--muted); }
.right { text-align: right; }
.spacer { flex: 1; }
.toolbar { display: flex; gap: 8px; align-items: center; margin-bottom: 14px; flex-wrap: wrap; }
.empty { text-align: center; color: var(--muted); padding: 40px 10px; }
.hint { font-size: 12.5px; color: var(--muted); margin-top: 6px; }
.output-card { margin-bottom: 16px; }
.output-path { padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; background: #f7f9fc; font-size: 13px; word-break: break-all; }
.output-actions { display: grid; grid-template-columns: 1fr auto auto; gap: 8px; margin-top: 10px; align-items: center; }

/* 결재자 카드 리스트 */
.approver-item {
  display: flex; align-items: center; gap: 12px; padding: 12px;
  border: 1px solid var(--border); border-radius: 10px; margin-bottom: 10px; background: #fff;
}
.approver-item .ord { width: 28px; height: 28px; border-radius: 50%; background: var(--primary); color: #fff;
  display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 13px; flex-shrink: 0; }
.approver-item .info { flex: 1; }
.approver-item .info .nm { font-weight: 600; }
.approver-item .info .meta { font-size: 12.5px; color: var(--muted); }
.approver-item .actions { display: flex; gap: 6px; }

/* 모달 */
.modal-bg { position: fixed; inset: 0; background: rgba(20,30,50,.45); display: flex; align-items: center; justify-content: center; z-index: 100; padding: 16px; }
.modal { background: #fff; border-radius: 14px; max-width: 540px; width: 100%; max-height: 90vh; overflow: auto; box-shadow: 0 12px 40px rgba(0,0,0,.25); }
.modal .mhead { padding: 16px 20px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; }
.modal .mhead h3 { margin: 0; font-size: 17px; }
.modal .mbody { padding: 20px; }
.modal .mfoot { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; }
.close-x { background: none; color: var(--muted); padding: 4px 8px; font-size: 18px; }
.close-x:hover { background: #eee; }

/* 지출내역 입력 행 */
.item-row { display: grid; grid-template-columns: 1fr 2fr 1.2fr auto; gap: 8px; margin-bottom: 8px; align-items: start; }
.item-row .del { background: #f3dada; color: var(--danger); padding: 8px 10px; }
.item-row .del:hover { background: #ecc5c5; }

/* 초대/결재 링크 복사 줄 */
.linkbox { display: flex; gap: 6px; margin-top: 12px; align-items: stretch; }
/* input의 width:100% 때문에 버튼이 글자보다 작게 찌그러지면 버튼 밖으로 삐져나온 글자를
   눌렀을 때 복사가 안 된다. 버튼은 줄이지 말고 입력칸만 줄인다. */
.linkbox input { font-size: 12.5px; flex: 1 1 auto; min-width: 0; }
.linkbox button { flex: 0 0 auto; white-space: nowrap; }

.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: #1f2733; color: #fff; padding: 11px 20px; border-radius: 10px; font-size: 14px;
  box-shadow: 0 6px 20px rgba(0,0,0,.3); z-index: 200; opacity: 0; transition: opacity .2s, transform .2s; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(-4px); }
.toast.err { background: #c0392b; }

.kv { display: grid; grid-template-columns: 130px 1fr; gap: 8px 12px; font-size: 14px; }
.kv .k { color: var(--muted); font-weight: 600; }

.signrow { padding: 10px 12px; border: 1px solid var(--border); border-radius: 9px; margin-bottom: 8px; }
.signrow .top { display: flex; justify-content: space-between; align-items: center; }
.signrow .hash { font-size: 10.5px; color: #9aa5b1; word-break: break-all; margin-top: 4px; font-family: monospace; }
.attachment-preview { border: 1px solid var(--border); border-radius: 9px; padding: 10px; margin-bottom: 10px; background: #f7f9fc; }
.attachment-title { display: flex; justify-content: space-between; gap: 10px; font-size: 13px; font-weight: 600; margin-bottom: 8px; }
.attachment-preview img { max-width: 100%; border-radius: 8px; border: 1px solid var(--border); display: block; }
.attachment-preview iframe { width: 100%; height: 420px; border: 1px solid var(--border); border-radius: 8px; background: #fff; }

@media (max-width: 600px) {
  .item-row { grid-template-columns: 1fr 1fr; }
  .item-row .del { grid-column: 2; justify-self: end; }
  .kv { grid-template-columns: 100px 1fr; }
  .container { padding: 14px; }
  .output-actions { grid-template-columns: 1fr; }

  /* 관리자도 휴대폰에서 상신할 수 있도록 좁은 화면 정리 */
  header.topbar { flex-wrap: wrap; gap: 8px; padding: 10px 12px; }
  header.topbar .brand { font-size: 15px; }
  header.topbar .user { flex-wrap: wrap; gap: 6px; font-size: 12px; }
  header.topbar .user button { padding: 6px 9px; font-size: 12.5px; }
  .card { padding: 16px; border-radius: 12px; }
  h2.section { flex-wrap: wrap; gap: 8px; }
  .modal-bg { padding: 0; align-items: flex-end; }
  .modal { max-width: none; max-height: 94vh; border-radius: 14px 14px 0 0; }
  .modal .mbody { padding: 16px; }
  .modal .mfoot { position: sticky; bottom: 0; background: #fff; }
  .modal .mfoot button { flex: 1; }
  .approver-item { flex-wrap: wrap; }
  .approver-item .actions { width: 100%; justify-content: flex-end; }
}
