/* ============ 디자인 토큰 ============ */
:root {
  --navy-950: #08162b;
  --navy-900: #0b1f3a;
  --navy-800: #12305a;
  --navy-700: #1b4378;
  --navy-100: #e6edf7;
  --navy-50: #f1f5fb;
  --gold: #c9a45c;
  --gold-soft: #f6efdd;
  --ink: #1b2536;
  --muted: #667389;
  --line: #e1e7f0;
  --bg: #f4f6fa;
  --card: #ffffff;
  --danger: #b4282f;
  --danger-soft: #fdeceb;
  --ok: #1d7a4d;
  --ok-soft: #e7f5ee;
  --warn: #9a6a12;
  --warn-soft: #fbf3e0;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(11, 31, 58, .06), 0 6px 20px rgba(11, 31, 58, .06);
  --font: "Pretendard", "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans KR", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: ui-monospace, "Cascadia Code", "D2Coding", Consolas, Menlo, monospace;
  --topbar-h: 60px;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--font); color: var(--ink); background: var(--bg); line-height: 1.6; font-size: 15px; }
h1, h2, h3 { line-height: 1.3; margin: 0; letter-spacing: -.01em; }
a { color: var(--navy-700); }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.inline { display: inline; margin: 0; }
.sr-copy { position: fixed; left: -9999px; top: 0; opacity: 0; }

/* ============ 상단바 ============ */
.topbar {
  position: sticky; top: 0; z-index: 40; height: var(--topbar-h);
  display: flex; align-items: center; gap: 14px; padding: 0 20px;
  background: linear-gradient(100deg, var(--navy-950), var(--navy-800));
  color: #fff; box-shadow: 0 2px 12px rgba(8, 22, 43, .35);
}
.brand { display: flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; font-weight: 700; font-size: 17px; min-width: 0; }
.brand-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 38vw; }
.logo-mark {
  display: inline-block; width: 28px; height: 28px; border-radius: 8px; flex: none;
  background: linear-gradient(135deg, var(--gold), #e8d3a0);
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, .35);
}
.logo-mark.big { width: 52px; height: 52px; border-radius: 14px; margin-bottom: 14px; }
.top-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.code-chip { background: rgba(255, 255, 255, .1); border: 1px solid rgba(255, 255, 255, .22); color: #fff; padding: 4px 12px; border-radius: 999px; text-decoration: none; font-size: 13px; white-space: nowrap; }
.code-chip strong { color: var(--gold); letter-spacing: .12em; font-variant-numeric: tabular-nums; margin-left: 4px; }
.role-chip { font-size: 13px; padding: 3px 12px; border-radius: 999px; background: rgba(255, 255, 255, .12); }
.icon-btn { display: none; background: none; border: 0; color: #fff; width: 40px; height: 40px; border-radius: 10px; cursor: pointer; }
.icon-btn:hover { background: rgba(255, 255, 255, .12); }
.bars, .bars::before, .bars::after { display: block; width: 20px; height: 2px; background: #fff; border-radius: 2px; position: relative; margin: 0 auto; }
.bars::before, .bars::after { content: ""; position: absolute; left: 0; }
.bars::before { top: -6px; } .bars::after { top: 6px; }

/* ============ 레이아웃 ============ */
.shell { display: grid; grid-template-columns: 268px minmax(0, 1fr); min-height: calc(100vh - var(--topbar-h)); }
.sidebar { background: var(--card); border-right: 1px solid var(--line); padding: 20px 14px; position: sticky; top: var(--topbar-h); align-self: start; height: calc(100vh - var(--topbar-h)); overflow-y: auto; }
.side-title { font-size: 12px; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); padding: 0 10px 8px; }
.side-nav { display: flex; flex-direction: column; gap: 2px; margin-bottom: 14px; }
.side-link { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 10px; color: var(--ink); text-decoration: none; }
.side-link:hover { background: var(--navy-50); }
.side-link.active { background: var(--navy-900); color: #fff; }
.side-link .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--gold); flex: none; }
.side-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-empty { color: var(--muted); padding: 6px 10px; margin: 0; font-size: 14px; }
.scrim { display: none; }
.main { padding: 28px clamp(16px, 3vw, 40px) 60px; max-width: 1180px; width: 100%; }
.bare { min-height: 100vh; display: flex; flex-direction: column; justify-content: center; padding: 24px; }

/* ============ 공통 컴포넌트 ============ */
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 14px; margin-bottom: 18px; }
.page-head h1 { font-size: 28px; color: var(--navy-900); }
.eyebrow { margin: 0 0 4px; font-size: 12px; letter-spacing: .14em; text-transform: uppercase; color: var(--gold); font-weight: 700; }
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 16px; border-radius: 10px; border: 1px solid var(--line); background: #fff; color: var(--ink);
  font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; line-height: 1.2;
  transition: background .15s, border-color .15s, transform .05s, box-shadow .15s;
}
.btn:hover { background: var(--navy-50); border-color: #cfd8e6; }
.btn:active { transform: translateY(1px); }
.btn:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, .tab:focus-visible, a:focus-visible { outline: 3px solid rgba(201, 164, 92, .55); outline-offset: 2px; }
.btn.primary { background: linear-gradient(180deg, var(--navy-800), var(--navy-900)); color: #fff; border-color: var(--navy-900); }
.btn.primary:hover { background: var(--navy-700); }
.btn.danger { color: var(--danger); border-color: #f0c9c7; background: #fff; }
.btn.danger:hover { background: var(--danger-soft); }
.btn.sm { padding: 6px 12px; font-size: 13px; border-radius: 8px; }
.btn.lg { padding: 13px 20px; font-size: 16px; }
.btn.block { width: 100%; }
.btn.ghost-light { background: rgba(255, 255, 255, .08); border-color: rgba(255, 255, 255, .25); color: #fff; }
.btn.ghost-light:hover { background: rgba(255, 255, 255, .18); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.linklike { background: none; border: 0; padding: 0; color: var(--navy-700); text-decoration: underline; cursor: pointer; font: inherit; }

.badge { display: inline-block; font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 999px; vertical-align: middle; }
.badge.hid { background: var(--warn-soft); color: var(--warn); border: 1px solid #ecd9a8; }
.badge.sm { margin-left: 6px; font-size: 10px; padding: 1px 6px; }
.side-link.active .badge.hid { background: rgba(255, 255, 255, .15); color: #f4e6bf; border-color: rgba(255, 255, 255, .25); }
.chip { display: inline-block; font-size: 12px; padding: 1px 10px; border-radius: 999px; background: var(--navy-100); color: var(--navy-800); font-weight: 600; }

.flashes { display: grid; gap: 8px; margin-bottom: 16px; }
.flash { padding: 11px 16px; border-radius: 10px; font-weight: 500; border: 1px solid; }
.flash-ok { background: var(--ok-soft); border-color: #bfe3cf; color: var(--ok); }
.flash-err { background: var(--danger-soft); border-color: #f2c4c2; color: var(--danger); }
.notice { background: var(--navy-50); border: 1px solid var(--navy-100); color: var(--navy-800); padding: 10px 14px; border-radius: 10px; margin: 0 0 16px; font-size: 14px; }
.notice.warn { background: var(--warn-soft); border-color: #ecd9a8; color: var(--warn); }
.hint { color: var(--muted); font-size: 13px; margin: 6px 0 0; }
.empty { text-align: center; padding: 56px 20px; background: var(--card); border: 1px dashed #cdd6e4; border-radius: var(--radius); color: var(--muted); }
.empty .btn { margin-top: 8px; }

/* ============ 폼 ============ */
.field { display: grid; gap: 6px; margin-bottom: 14px; }
.field > span { font-size: 13px; font-weight: 700; color: var(--navy-800); }
input[type=text], input[type=password], input[type=search], input[type=number], select, textarea {
  width: 100%; padding: 10px 12px; border: 1px solid #cfd8e6; border-radius: 10px; background: #fff; font: inherit; color: inherit;
}
textarea { resize: vertical; min-height: 280px; font-family: var(--mono); font-size: 14px; line-height: 1.65; }
input:focus, select:focus, textarea:focus { border-color: var(--navy-700); }
.form-grid { display: grid; gap: 4px; max-width: 560px; }
.form-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 8px; }
.check { display: flex; gap: 8px; align-items: center; font-size: 14px; margin: 10px 0; }
.radio-row { display: flex; gap: 20px; margin: 12px 0; }
.radio { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; }

/* ============ 입장/로그인 ============ */
.gate { display: grid; place-items: center; }
.gate-card { width: min(420px, 100%); background: var(--card); border-radius: 20px; padding: 36px 30px 26px; box-shadow: var(--shadow); text-align: center; border-top: 5px solid var(--navy-900); }
.gate-card h1 { color: var(--navy-900); font-size: 24px; margin-bottom: 6px; }
.gate-card .field { text-align: left; }
.gate-card form { margin-top: 18px; }
.code-input { text-align: center; font-size: 34px !important; letter-spacing: .4em; padding: 14px 10px !important; font-weight: 700; margin-bottom: 14px; font-variant-numeric: tabular-nums; }
.gate-admin { display: inline-block; margin-top: 18px; font-size: 13px; color: var(--muted); }

/* ============ 홈 ============ */
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 16px; }
.company-card { display: grid; gap: 4px; padding: 22px; background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); text-decoration: none; color: var(--ink); border: 1px solid transparent; transition: transform .15s, border-color .15s; }
.company-card:hover { transform: translateY(-3px); border-color: var(--gold); }
.company-card.is-hidden { background: repeating-linear-gradient(135deg, #fff, #fff 10px, #fbf8ef 10px, #fbf8ef 20px); }
.company-initial { width: 46px; height: 46px; border-radius: 12px; display: grid; place-items: center; background: linear-gradient(135deg, var(--navy-900), var(--navy-700)); color: var(--gold); font-weight: 800; font-size: 20px; margin-bottom: 8px; }
.company-name { font-size: 18px; font-weight: 700; color: var(--navy-900); overflow-wrap: anywhere; }
.company-meta { font-size: 13px; color: var(--muted); }

/* ============ 탭/메뉴바 ============ */
.tabs { display: flex; gap: 6px; overflow-x: auto; padding: 0 0 2px; margin-bottom: 18px; border-bottom: 2px solid var(--line); scrollbar-width: thin; }
.tab { flex: none; padding: 10px 16px; border: 0; background: none; color: var(--muted); font: inherit; font-weight: 600; text-decoration: none; cursor: pointer; border-bottom: 3px solid transparent; margin-bottom: -2px; white-space: nowrap; }
.tab:hover { color: var(--navy-900); }
.tab.active { color: var(--navy-900); border-bottom-color: var(--gold); }
.tab.add { color: var(--navy-700); }
.menu-bar { display: flex; flex-wrap: wrap; gap: 12px; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.menu-bar > .muted { margin: 0; flex: 1 1 320px; font-size: 14px; }
.search { display: flex; gap: 6px; }
.search input { width: 240px; }

/* ============ 게시글 ============ */
.post-list { display: grid; gap: 12px; }
.post-card { display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: center; justify-content: space-between; background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px 20px; border-left: 4px solid var(--navy-800); }
.post-card.is-hidden { border-left-color: var(--gold); background: #fffdf7; }
.post-main { flex: 1 1 320px; min-width: 0; text-decoration: none; color: inherit; }
.post-main h3 { font-size: 17px; color: var(--navy-900); overflow-wrap: anywhere; }
.post-main:hover h3 { text-decoration: underline; }
.preview { margin: 4px 0 6px; color: var(--muted); font-size: 14px; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow-wrap: anywhere; }
.meta { display: flex; gap: 12px; align-items: center; font-size: 13px; color: var(--muted); }
.post-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.pager { display: flex; justify-content: center; align-items: center; gap: 14px; margin-top: 22px; }
.pager-info { color: var(--muted); font-size: 14px; }

.post { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 26px clamp(18px, 3vw, 36px) 32px; }
.post-head { border-bottom: 1px solid var(--line); padding-bottom: 16px; margin-bottom: 20px; display: grid; gap: 8px; }
.post-head h2 { font-size: 26px; color: var(--navy-900); overflow-wrap: anywhere; }
.back { font-size: 14px; text-decoration: none; color: var(--muted); }
.back:hover { color: var(--navy-900); }
.attachments { background: var(--navy-50); border: 1px solid var(--navy-100); border-radius: 12px; padding: 14px 18px; margin-bottom: 22px; }
.attachments h3 { font-size: 15px; margin-bottom: 8px; }
.attachments ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.attachments li { display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: center; }
.attachments .fname { font-weight: 600; overflow-wrap: anywhere; flex: 1 1 200px; }
.post-body { white-space: pre-wrap; overflow-wrap: anywhere; word-break: break-word; font-size: 16px; line-height: 1.8; }
.post-body a { color: var(--navy-700); }
.codeblock { margin: 14px 0; border-radius: 12px; overflow: hidden; background: var(--navy-950); white-space: normal; }
.codebar { display: flex; justify-content: space-between; align-items: center; padding: 6px 12px; background: rgba(255, 255, 255, .07); color: #aab8d0; font-size: 12px; font-family: var(--mono); }
.copy-btn { background: rgba(255, 255, 255, .12); color: #fff; border: 0; border-radius: 6px; padding: 3px 10px; cursor: pointer; font: inherit; font-size: 12px; }
.copy-btn:hover { background: rgba(255, 255, 255, .25); }
.codeblock pre { margin: 0; padding: 14px 16px; overflow-x: auto; color: #e8eefb; font-family: var(--mono); font-size: 13.5px; line-height: 1.6; white-space: pre; tab-size: 4; }
code.inline { background: var(--navy-100); color: var(--navy-900); border-radius: 5px; padding: 1px 6px; font-family: var(--mono); font-size: .9em; }

/* ============ 편집기 ============ */
.editor { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 24px clamp(16px, 3vw, 32px); }
.editor h2 { margin-bottom: 16px; font-size: 20px; color: var(--navy-900); }
.attach-box { border: 1px dashed #b9c6da; border-radius: 12px; padding: 14px 16px; background: var(--navy-50); margin-bottom: 14px; }
.attach-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.chips { list-style: none; display: flex; flex-wrap: wrap; gap: 8px; padding: 0; margin: 10px 0 0; }
.chips li { display: inline-flex; align-items: center; gap: 8px; background: #fff; border: 1px solid var(--navy-100); border-radius: 999px; padding: 4px 6px 4px 14px; font-size: 14px; }
.chips li .x { border: 0; background: var(--navy-100); border-radius: 50%; width: 22px; height: 22px; cursor: pointer; line-height: 1; color: var(--navy-800); }
.chips li .x:hover { background: var(--danger-soft); color: var(--danger); }
.chips:empty::before { content: "선택된 첨부파일이 없습니다."; color: var(--muted); font-size: 14px; }

/* ============ 파일 목록/업로드 ============ */
.dropzone { border: 2px dashed #b9c6da; border-radius: var(--radius); padding: 22px; text-align: center; background: #fff; margin-bottom: 18px; transition: background .15s, border-color .15s; }
.dropzone.drag { background: var(--navy-50); border-color: var(--navy-700); }
.dropzone input[type=file], .picker-upload input[type=file] { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.upload-progress { width: 100%; height: 10px; margin-top: 10px; accent-color: var(--navy-800); }
.upload-status { font-size: 14px; color: var(--muted); margin: 6px 0 0; min-height: 1.2em; }
.table-wrap { overflow-x: auto; background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); }
.table { width: 100%; border-collapse: collapse; min-width: 560px; }
.table th, .table td { padding: 12px 16px; text-align: left; border-bottom: 1px solid var(--line); }
.table th { background: var(--navy-50); font-size: 13px; color: var(--navy-800); }
.table tr:last-child td { border-bottom: 0; }
.table .num { text-align: right; white-space: nowrap; }
.table .fname { overflow-wrap: anywhere; font-weight: 600; }
.row-actions { display: flex; gap: 6px; justify-content: flex-end; }

/* ============ 다이얼로그 ============ */
dialog.dlg { border: 0; padding: 0; border-radius: 16px; width: min(460px, calc(100vw - 28px)); box-shadow: 0 24px 70px rgba(8, 22, 43, .45); color: var(--ink); }
dialog.dlg.wide { width: min(640px, calc(100vw - 28px)); }
dialog.dlg::backdrop { background: rgba(8, 22, 43, .55); backdrop-filter: blur(2px); }
.dlg-body { padding: 24px; }
.dlg-body h2 { font-size: 20px; margin-bottom: 8px; color: var(--navy-900); }
.dlg-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; }
.dlg-actions.center, .center { justify-content: center; text-align: center; }
.picker-search { margin: 8px 0 10px; }
.picker-list { list-style: none; margin: 0; padding: 0; max-height: 46vh; overflow-y: auto; border: 1px solid var(--line); border-radius: 10px; }
.picker-list li { border-bottom: 1px solid var(--line); }
.picker-list li:last-child { border-bottom: 0; }
.picker-list label { display: flex; align-items: center; gap: 10px; padding: 10px 14px; cursor: pointer; }
.picker-list label:hover { background: var(--navy-50); }
.picker-list .pname { flex: 1; min-width: 0; overflow-wrap: anywhere; font-weight: 600; }
.picker-list .psize { color: var(--muted); font-size: 13px; white-space: nowrap; }
.picker-upload { margin-top: 12px; position: relative; display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.picker-upload .upload-progress { flex: 1 1 100%; margin-top: 0; }

/* ============ 접속 관리 ============ */
.panel-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 18px; margin-bottom: 18px; }
.panel { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 22px 24px; margin-bottom: 18px; }
.panel-grid .panel { margin-bottom: 0; }
.panel h2 { font-size: 18px; color: var(--navy-900); margin-bottom: 12px; }
.big-code { font-size: clamp(40px, 8vw, 64px); font-weight: 800; letter-spacing: .22em; color: var(--navy-900); background: var(--navy-50); border: 1px solid var(--navy-100); border-radius: 14px; text-align: center; padding: 16px 8px 16px 20px; margin-bottom: 12px; font-variant-numeric: tabular-nums; }
.qr-panel { text-align: center; }
.qr-img { max-width: 100%; height: auto; border: 1px solid var(--line); border-radius: 12px; padding: 8px; background: #fff; }
.url-line { word-break: break-all; font-family: var(--mono); font-size: 14px; margin: 8px 0; }
.giant-code { font-size: clamp(56px, 14vw, 120px); font-weight: 800; letter-spacing: .2em; color: var(--navy-900); padding-left: .2em; margin: 4px 0 14px; font-variant-numeric: tabular-nums; }
.big-dlg { width: min(720px, calc(100vw - 28px)); }
.qr-panel .toolbar { justify-content: center; }

/* ============ 오류 페이지 ============ */
.errpage { text-align: center; padding: 60px 16px; }
.errcode { font-size: 72px; font-weight: 800; color: var(--gold); margin: 0; }
.errpage h1 { font-size: 20px; margin: 6px 0 22px; color: var(--navy-900); }

/* ============ 반응형 ============ */
@media (max-width: 860px) {
  .icon-btn { display: inline-grid; place-items: center; }
  .shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: fixed; z-index: 60; top: var(--topbar-h); left: 0; bottom: 0; width: 280px; height: auto; align-self: stretch; transform: translateX(-102%); transition: transform .22s ease; box-shadow: 10px 0 30px rgba(8, 22, 43, .25); }
  body.side-open .sidebar { transform: none; }
  body.side-open .scrim { display: block; position: fixed; inset: var(--topbar-h) 0 0 0; z-index: 55; background: rgba(8, 22, 43, .45); }
  .brand-name { max-width: 30vw; }
  .code-chip { display: none; }
  .page-head h1 { font-size: 23px; }
  .search { width: 100%; } .search input { flex: 1; width: auto; }
  .post-card { padding: 14px 16px; }
}
@media (max-width: 520px) {
  .topbar { padding: 0 12px; gap: 8px; }
  .main { padding: 18px 12px 48px; }
  .role-chip { display: none; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
@media print { .topbar, .sidebar, .toolbar, .post-actions, .tabs { display: none !important; } .shell { display: block; } }
