/* 텔레그램 클라우드 드라이브 — 스타일 */
:root {
  --bg: #f4f6fb;
  --bg-elev: #ffffff;
  --bg-soft: #eef1f8;
  --bg-hover: #e9edf7;
  --text: #1b2333;
  --text-soft: #5b6577;
  --muted: #8a93a6;
  --line: #e2e6f0;
  --brand: #2aabee;
  --brand-strong: #1e96d6;
  --brand-soft: #e4f4fd;
  --accent: #6c5ce7;
  --danger: #e5484d;
  --danger-soft: #fdecec;
  --ok: #17a673;
  --warn: #b7791f;
  --warn-soft: #fff5e0;
  --shadow: 0 10px 30px rgba(24, 39, 75, .08);
  --shadow-lg: 0 24px 60px rgba(24, 39, 75, .18);
  --radius: 14px;
  --radius-sm: 10px;
  --sidebar-w: 264px;
}
[data-theme="dark"] {
  --bg: #0f131b;
  --bg-elev: #171c26;
  --bg-soft: #1e2430;
  --bg-hover: #242b39;
  --text: #e9edf5;
  --text-soft: #aab3c5;
  --muted: #7d879b;
  --line: #2a313f;
  --brand: #37b2f0;
  --brand-strong: #5cc4f7;
  --brand-soft: #10293a;
  --accent: #9b8cff;
  --danger: #ff6b6f;
  --danger-soft: #35191b;
  --ok: #38d39f;
  --warn: #e3b341;
  --warn-soft: #33280f;
  --shadow: 0 10px 30px rgba(0, 0, 0, .35);
  --shadow-lg: 0 24px 60px rgba(0, 0, 0, .55);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Pretendard",
    "Malgun Gothic", "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  font-size: 15px;
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.block { width: 100%; }

/* ---------------------------------------------------------------- 로그인 */
.login-screen {
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(1000px 600px at 10% -10%, rgba(42, 171, 238, .22), transparent 60%),
    radial-gradient(800px 500px at 100% 100%, rgba(108, 92, 231, .18), transparent 55%),
    var(--bg);
}
.login-card {
  width: min(420px, 100%);
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 34px 30px 28px;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.login-logo { display: flex; justify-content: center; margin-bottom: 6px; }
.login-card h1 { font-size: 21px; margin: 0; text-align: center; letter-spacing: -.3px; }
.login-card .muted { text-align: center; margin: 0 0 14px; font-size: 13.5px; line-height: 1.5; }
.login-card label { font-size: 13px; font-weight: 600; color: var(--text-soft); margin-top: 6px; }
.login-card input {
  width: 100%;
  padding: 13px 14px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--bg-soft);
  outline: none;
}
.login-card input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.form-error { color: var(--danger); font-size: 13px; min-height: 18px; margin: 4px 0 0; text-align: center; }

/* 로그인 2단계 — 관리자 2차 인증 */
#twofa-form input#twofa-code {
  text-align: center;
  font-size: 22px;
  letter-spacing: .32em;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  padding: 14px 10px 14px 20px;
}
.twofa-login-actions {
  display: flex;
  gap: 8px;
  justify-content: space-between;
  margin-top: 2px;
}
.twofa-note {
  margin: 2px 0 0;
  font-size: 12px;
  line-height: 1.5;
  color: var(--muted);
  text-align: center;
}

/* 관리자 2차 인증 모달 */
.twofa-modal { width: min(470px, 100%); }
.twofa-head { display: flex; align-items: center; gap: 8px; }
.twofa-status {
  font-size: 12px; font-weight: 800; padding: 3px 10px; border-radius: 999px;
  border: 1px solid var(--line);
}
.twofa-status.on { background: #e7f7ee; color: #10804a; border-color: #b7e5cb; }
.twofa-status.off { background: var(--bg-soft); color: var(--muted); }
html[data-theme="dark"] .twofa-status.on { background: rgba(24, 160, 96, .18); color: #6ee7a8; border-color: rgba(110, 231, 168, .35); }
.twofa-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.twofa-codes {
  display: flex; flex-direction: column; gap: 8px;
  padding: 12px; border-radius: 12px;
  border: 1px dashed var(--brand);
  background: var(--brand-soft);
}
.twofa-codes-title { margin: 0; font-size: 12.5px; font-weight: 800; color: var(--brand-strong); }
.twofa-code-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 6px 10px;
}
.twofa-code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 13px; letter-spacing: .06em; color: var(--text);
  background: var(--bg-elev); border: 1px solid var(--line);
  border-radius: 8px; padding: 5px 8px;
}
.twofa-warn { margin: 0; font-size: 11.5px; line-height: 1.5; color: var(--danger); }
@media (max-width: 420px) {
  .twofa-code-grid { grid-template-columns: 1fr; }
}

/* ---------------------------------------------------------------- 버튼 */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 9px 14px;
  border-radius: 11px;
  border: 1px solid var(--line);
  background: var(--bg-elev);
  color: var(--text);
  font-weight: 600;
  font-size: 13.5px;
  white-space: nowrap;
  transition: background .15s, border-color .15s, transform .05s;
}
.btn:hover { background: var(--bg-hover); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-strong); border-color: var(--brand-strong); }
.btn.sync { background: var(--brand-soft); border-color: transparent; color: var(--brand-strong); }
.btn.sync:hover { filter: brightness(.97); }
.btn.ghost { background: transparent; }
.btn.ghost:hover { background: var(--bg-hover); }
.btn.small { padding: 7px 10px; font-size: 12.5px; }
.btn.danger { color: var(--danger); border-color: transparent; background: var(--danger-soft); }
.btn[disabled] { opacity: .55; pointer-events: none; }
.icon-btn {
  width: 38px; height: 38px;
  display: inline-grid; place-items: center;
  border-radius: 10px; font-size: 17px; color: var(--text-soft);
}
.icon-btn:hover { background: var(--bg-hover); }
.icon-btn.small { width: 28px; height: 28px; font-size: 15px; }
.chip {
  font-size: 11px; font-weight: 700;
  padding: 3px 8px; border-radius: 999px;
  background: var(--brand-soft); color: var(--brand-strong);
}

/* ---------------------------------------------------------------- 레이아웃 */
.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  height: 100dvh;
  overflow: hidden;
}
.sidebar {
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 20px 16px;
  background: var(--bg-elev);
  border-right: 1px solid var(--line);
  overflow-y: auto;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 6px; }
.brand strong { display: block; font-size: 14.5px; letter-spacing: -.2px; }
.brand .small { display: block; margin-top: 1px; }
.nav { display: flex; flex-direction: column; gap: 3px; }

/* 저장소(채널) 전환 */
.channel-card {
  background: var(--bg-soft);
  border-radius: var(--radius);
  padding: 10px 12px;
  display: flex; flex-direction: column; gap: 6px;
}
.channel-top { display: flex; align-items: center; justify-content: space-between; }
.channel-top-actions { display: flex; align-items: center; gap: 2px; }
.icon-btn.danger { color: var(--danger); }
.icon-btn.danger:hover { background: var(--danger-soft); }
.channel-select {
  width: 100%; padding: 9px 10px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--bg-elev); color: var(--text);
  font-size: 13.5px; font-weight: 600; outline: none; text-overflow: ellipsis;
}
.channel-select:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.channel-meta { line-height: 1.4; }
.channel-block { display: flex; flex-direction: column; gap: 6px; padding-top: 4px; border-top: 1px solid var(--line); }
.channel-block:first-of-type { border-top: 0; padding-top: 0; }
.channel-modal .modal-actions { justify-content: space-between; align-items: center; }
.nav-item {
  display: flex; align-items: center; gap: 11px;
  padding: 10px 12px; border-radius: 11px;
  color: var(--text-soft); font-weight: 600; font-size: 14px;
  text-align: left; width: 100%;
}
.nav-item:hover { background: var(--bg-hover); color: var(--text); }
.nav-item.active { background: var(--brand-soft); color: var(--brand-strong); }
.nav-ico { width: 20px; text-align: center; font-size: 15px; }
.logout { margin-top: auto; color: var(--muted); }

.storage-card {
  background: var(--bg-soft);
  border-radius: var(--radius);
  padding: 14px;
  display: flex; flex-direction: column; gap: 8px;
}
.storage-top { display: flex; align-items: center; justify-content: space-between; }
.storage-size { font-size: 22px; font-weight: 700; letter-spacing: -.5px; }
.meter { height: 7px; background: var(--bg-elev); border-radius: 999px; overflow: hidden; }
.meter span {
  display: block; height: 100%; width: 18%;
  background: linear-gradient(90deg, var(--brand), var(--accent));
  border-radius: 999px;
  transition: width .4s ease;
}
.stat-list { margin: 4px 0 6px; display: grid; gap: 5px; }
.stat-list div { display: flex; justify-content: space-between; font-size: 12.5px; }
.stat-list dt { color: var(--muted); margin: 0; }
.stat-list dd { margin: 0; font-weight: 600; color: var(--text-soft); }

/* 오라클 서버 자원 카드(관리자 전용) — '사용량' 카드와 별개 박스 */
.server-card {
  background: var(--bg-soft);
  border-radius: var(--radius);
  padding: 12px 14px 13px;
  display: flex; flex-direction: column; gap: 9px;
}
.server-top { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.server-spec { white-space: nowrap; font-variant-numeric: tabular-nums; }
.server-row { display: flex; flex-direction: column; gap: 5px; }
.server-line {
  display: flex; align-items: baseline; justify-content: space-between; gap: 8px;
  font-size: 12.5px; line-height: 1.2;
}
.server-key { color: var(--muted); font-weight: 600; letter-spacing: .2px; }
.server-val {
  color: var(--text-soft); font-weight: 700; white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.server-detail { margin-left: 4px; color: var(--muted); font-weight: 500; font-size: 11.5px; }
.server-gauge { height: 6px; border-radius: 999px; background: var(--bg-elev); overflow: hidden; }
.server-gauge span {
  display: block; height: 100%; width: 0; border-radius: 999px;
  background: linear-gradient(90deg, var(--brand), var(--accent));
  transition: width .45s ease, background .3s ease;
}
.server-gauge span.warn { background: linear-gradient(90deg, #f0b429, #dd8b1a); }
.server-gauge span.hot { background: linear-gradient(90deg, #f08a29, var(--danger)); }
.server-card[data-state="error"] .server-val { color: var(--muted); font-weight: 500; }

.main { display: flex; flex-direction: column; min-width: 0; overflow: hidden; }
.topbar {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 22px;
  border-bottom: 1px solid var(--line);
  background: var(--bg-elev);
}
.search-wrap { position: relative; flex: 1; max-width: 520px; }
.search-wrap input {
  width: 100%;
  padding: 10px 34px 10px 36px;
  border-radius: 11px;
  border: 1px solid var(--line);
  background: var(--bg-soft);
  outline: none;
  font-size: 14px;
}
.search-wrap input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.search-ico { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); font-size: 13px; opacity: .7; }
.search-clear { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); color: var(--muted); font-size: 16px; width: 24px; height: 24px; border-radius: 6px; }
.search-clear:hover { background: var(--bghover, var(--bg-hover)); }
.topbar-actions { display: flex; gap: 8px; margin-left: auto; }

.content { flex: 1; overflow-y: auto; padding: 18px 22px 80px; position: relative; }
.toolbar {
  display: flex; align-items: center; gap: 12px;
  flex-wrap: wrap; margin-bottom: 14px;
}
.breadcrumb { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; min-width: 0; flex: 1; }
.crumb {
  padding: 6px 9px; border-radius: 8px; font-weight: 600; font-size: 13.5px;
  color: var(--text-soft); max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.crumb:hover { background: var(--bg-hover); color: var(--text); }
.crumb.current { color: var(--text); font-size: 16px; padding-left: 0; }
.crumb-sep { color: var(--muted); font-size: 12px; }
.toolbar-actions { display: flex; align-items: center; gap: 8px; }
.seg { display: inline-flex; background: var(--bg-soft); border-radius: 10px; padding: 3px; gap: 2px; }
.seg-btn {
  padding: 6px 10px; border-radius: 8px; font-size: 13px; color: var(--text-soft);
  font-weight: 600; min-width: 34px;
}
.seg-btn:hover { color: var(--text); }
.seg-btn.active { background: var(--bg-elev); color: var(--text); box-shadow: 0 1px 3px rgba(0, 0, 0, .08); }

/* ---------------------------------------------------------------- 목록 */
.listing { display: flex; flex-direction: column; gap: 4px; }
.list-head {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr) 96px 128px 40px;
  gap: 12px; padding: 2px 12px 6px;
  font-size: 11.5px; font-weight: 700; color: var(--muted);
  letter-spacing: .04em;
}
.list-head .col-meta { text-align: right; }
.head-check { display: flex; align-items: center; justify-content: flex-start; }
.master-box { width: 17px; height: 17px; margin: 0; accent-color: var(--brand); cursor: pointer; }
.listing.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(158px, 1fr));
  gap: 12px;
}
.section-label {
  font-size: 12px; font-weight: 700; color: var(--muted);
  margin: 14px 2px 8px; text-transform: uppercase; letter-spacing: .06em;
}
.listing.grid .section-label { grid-column: 1 / -1; margin: 6px 2px 0; }
.card .row-more { opacity: 1; }
.row {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr) 96px 128px 40px;
  align-items: center; gap: 12px;
  padding: 9px 12px; border-radius: 11px;
  border: 1px solid transparent;
  cursor: pointer;
  user-select: none;
}
.row:hover { background: var(--bg-elev); border-color: var(--line); }
.row.selected { background: var(--brand-soft); border-color: var(--brand); }
.row-name { display: flex; align-items: center; gap: 10px; min-width: 0; }
.row-name .name {
  font-weight: 600; font-size: 14px; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap;
}
.row-name .sub { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-meta { font-size: 12.5px; color: var(--muted); white-space: nowrap; text-align: right; }
.row-actions { display: flex; justify-content: flex-end; }
.row-more { width: 32px; height: 32px; border-radius: 8px; color: var(--muted); font-size: 17px; opacity: 0; }
.row:hover .row-more { opacity: 1; }
.row-more:hover { background: var(--bg-hover); color: var(--text); }

.icon {
  width: 38px; height: 38px; border-radius: 10px;
  display: grid; place-items: center; font-size: 19px;
  background: var(--bg-soft); flex: none;
}
.icon.folder { background: #fff3d6; }
[data-theme="dark"] .icon.folder { background: #33280f; }
.icon.image { background: #e6f7ec; }
[data-theme="dark"] .icon.image { background: #123326; }
.icon.video { background: #eae4ff; }
[data-theme="dark"] .icon.video { background: #241f45; }
.icon.pdf { background: #ffe6e6; }
[data-theme="dark"] .icon.pdf { background: #3a1a1c; }
.icon.text { background: #e4f0ff; }
[data-theme="dark"] .icon.text { background: #10243a; }
.icon.audio { background: #fdeaf6; }
[data-theme="dark"] .icon.audio { background: #331b2b; }

.card {
  display: flex; flex-direction: column; gap: 10px;
  padding: 14px; border-radius: var(--radius);
  background: var(--bg-elev); border: 1px solid var(--line);
  cursor: pointer; min-width: 0;
  transition: transform .12s, box-shadow .12s;
}
.card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.card .icon { width: 46px; height: 46px; font-size: 23px; }
.card .name { font-weight: 600; font-size: 13.5px; line-height: 1.35; word-break: break-all; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card .sub { font-size: 12px; color: var(--muted); margin-top: -4px; }
.card-actions { display: flex; justify-content: flex-end; gap: 2px; margin-top: auto; }
/* 격자 보기 그림 영역: 썸네일·아이콘 타일 모두 같은 크기(16:10)로 줄을 고르게 */
.card .card-thumb,
.card .card-thumb-tile,
.card .card-thumb-fallback {
  width: 100%; height: auto; aspect-ratio: 16 / 10;
  border-radius: 9px; object-fit: cover;
  background: var(--bg-soft); flex: none; display: block;
}
.card .card-thumb { min-height: 0; }
.card .card-thumb-tile,
.card .card-thumb-fallback { display: grid; place-items: center; font-size: 40px; }
.card .card-thumb-fallback[hidden] { display: none; }
/* 사진·동영상 썸네일 틀 — 재생 배지를 겹치거나 아이콘으로 돌아갈 때도 같은 크기 */
.card .card-thumb-wrap {
  position: relative; width: 100%; aspect-ratio: 16 / 10;
  border-radius: 9px; overflow: hidden; flex: none;
  background: var(--bg-soft);
}
.card .card-thumb-wrap > .card-thumb,
.card .card-thumb-wrap > .card-thumb-fallback {
  width: 100%; height: 100%; aspect-ratio: auto;
  border-radius: 0; object-fit: cover; display: block;
}
.card .card-thumb-wrap > .card-thumb-fallback { display: grid; place-items: center; font-size: 40px; }
.card .card-thumb-wrap > .card-thumb-fallback[hidden] { display: none; }
.card .card-play-badge {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: 44px; height: 44px; border-radius: 50%;
  display: grid; place-items: center; padding-left: 3px;
  font-size: 15px; line-height: 1; color: #fff;
  background: rgba(12, 18, 28, .55);
  border: 1px solid rgba(255, 255, 255, .38);
  box-shadow: 0 1px 6px rgba(0, 0, 0, .25);
  pointer-events: none;
}
.card.selected { border-color: var(--brand); box-shadow: 0 0 0 2px var(--brand-soft); }

/* ---------------------------------------------------------------- 선택 모드 */
.select-box {
  width: 17px; height: 17px; margin: 0;
  accent-color: var(--brand); cursor: pointer;
}
.row.selecting,
.list-head.selecting { grid-template-columns: 22px 38px minmax(0, 1fr) 96px 128px 40px; }
.row.selecting.selected { background: var(--brand-soft); }
.card-check { display: flex; align-items: center; margin-right: auto; padding-left: 2px; }
.selection-bar {
  position: sticky; bottom: 0; z-index: 40;
  margin-top: 16px;
  display: flex; align-items: center; gap: 12px;
  padding: 10px 14px;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
  animation: pop .16s ease;
}
.selection-count { font-weight: 700; font-size: 13.5px; }
.selection-actions { margin-left: auto; display: flex; gap: 8px; }
.btn.active { background: var(--brand-soft); border-color: transparent; color: var(--brand-strong); }

.empty { text-align: center; padding: 64px 20px; color: var(--muted); }
.empty .big { font-size: 40px; margin-bottom: 10px; }
.empty h3 { margin: 0 0 6px; color: var(--text-soft); font-size: 16px; }
.empty p { margin: 0; font-size: 13.5px; line-height: 1.6; }

.drop-hint {
  position: absolute; inset: 10px;
  border: 2px dashed var(--brand);
  border-radius: 18px;
  background: var(--brand-soft);
  color: var(--brand-strong);
  display: none; place-items: center;
  font-weight: 700; font-size: 16px;
  pointer-events: none;
  z-index: 30;
}
.content.dragging .drop-hint { display: grid; }

/* ---------------------------------------------------------------- 메뉴 */
.context-menu {
  position: fixed; z-index: 60;
  min-width: 194px;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  padding: 6px;
  display: flex; flex-direction: column;
}
.context-menu button {
  display: flex; align-items: center; gap: 9px;
  padding: 9px 11px; border-radius: 8px; font-size: 13.5px; text-align: left;
}
.context-menu button:hover { background: var(--bg-hover); }
.context-menu .danger { color: var(--danger); }
.context-menu .sep { height: 1px; background: var(--line); margin: 5px 4px; }

/* ---------------------------------------------------------------- 모달 */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 80;
  background: rgba(10, 15, 25, .55);
  display: grid; place-items: center;
  padding: 20px;
}
.modal {
  background: var(--bg-elev);
  border-radius: 18px;
  box-shadow: var(--shadow-lg);
  width: min(460px, 100%);
  padding: 22px;
  display: flex; flex-direction: column; gap: 12px;
  max-height: 90dvh;
}
.modal h2 { margin: 0; font-size: 17px; }
.modal label { font-size: 12.5px; font-weight: 700; color: var(--text-soft); }
.modal input[type="text"] {
  width: 100%; padding: 11px 12px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--bg-soft); outline: none;
}
.modal input[type="text"]:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }
.modal-error { color: var(--danger); font-size: 12.5px; min-height: 16px; margin: 0; }

/* 관리자 비밀번호 변경 모달 */
.pw-modal { width: min(430px, 100%); }
.pw-form { display: flex; flex-direction: column; gap: 10px; }
.pw-field { display: flex; flex-direction: column; gap: 4px; }
.pw-row { position: relative; display: flex; align-items: center; }
.pw-row input {
  width: 100%; padding: 11px 42px 11px 12px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--bg-soft); outline: none;
  letter-spacing: .04em;
}
.pw-row input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.pw-eye {
  position: absolute; right: 5px; padding: 5px 7px; border-radius: 8px;
  font-size: 15px; line-height: 1; opacity: .6;
}
.pw-eye:hover, .pw-eye:focus-visible { opacity: 1; background: var(--bg-hover); }
.pw-eye.on { opacity: 1; }
.pw-note { margin: 0; font-size: 12px; line-height: 1.55; color: var(--muted); }

.preview-modal {
  width: min(1080px, 96vw);
  max-height: 92dvh;
  padding: 0;
  overflow: hidden;
  background: var(--bg-elev);
}
.preview-head {
  display: flex; align-items: center; gap: 12px;
  padding: 13px 16px; border-bottom: 1px solid var(--line);
}
.preview-title { font-weight: 700; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.preview-sub { font-size: 12px; color: var(--muted); white-space: nowrap; }
.preview-body {
  display: grid; place-items: center;
  background: #0c0f14;
  min-height: 240px; max-height: calc(92dvh - 116px);
  overflow: auto;
}
.preview-body img, .preview-body video { max-width: 100%; max-height: calc(92dvh - 116px); display: block; }
.preview-body iframe { width: min(1000px, 92vw); height: 78dvh; border: 0; background: #fff; }
.preview-body pre {
  margin: 0; padding: 18px; color: #dfe6f3; background: #0c0f14;
  font-size: 12.5px; line-height: 1.6; white-space: pre-wrap; word-break: break-word;
  width: 100%; max-height: calc(92dvh - 116px); overflow: auto;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}
.preview-fallback { color: #cfd8e6; text-align: center; padding: 40px 20px; }
.preview-foot { display: flex; gap: 8px; justify-content: flex-end; padding: 10px 14px; border-top: 1px solid var(--line); }

/* 이동 트리 */
.tree { max-height: 300px; overflow: auto; border: 1px solid var(--line); border-radius: 12px; padding: 8px; background: var(--bg-soft); }
.tree button {
  display: flex; align-items: center; gap: 8px; width: 100%; text-align: left;
  padding: 8px 10px; border-radius: 8px; font-size: 13.5px;
}
.tree button:hover { background: var(--bg-hover); }
.tree button.active { background: var(--brand-soft); color: var(--brand-strong); font-weight: 700; }
.tree button:disabled { opacity: .38; cursor: not-allowed; }
.tree button:disabled:hover { background: none; }

/* ---------------------------------------------------------------- 업로드 패널 */
.upload-panel {
  position: fixed; right: 20px; bottom: 20px; z-index: 70;
  width: min(420px, calc(100vw - 24px));
  max-height: min(78dvh, 640px);
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
  padding: 12px;
  display: flex; flex-direction: column; gap: 8px;
  overflow: hidden;
}
.upload-head { display: flex; align-items: center; gap: 8px; flex: none; }
.upload-head strong { font-size: 13.5px; }
.upload-head span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-variant-numeric: tabular-nums; }
.upload-cancel {
  padding: 5px 10px; font-size: 12px; font-weight: 700;
  color: var(--danger); background: var(--danger-soft); border-color: transparent;
}
.upload-cancel:hover { background: var(--danger-soft); filter: brightness(.96); }

/* 중지된 상태 */
.upload-panel.canceled .upload-stats { background: rgba(229, 72, 77, .07); border-color: rgba(229, 72, 77, .22); }
.upload-panel.canceled .us-percent { color: var(--danger); }
.upload-panel.canceled .us-bar span { background: linear-gradient(90deg, #b9c0cd, #8a93a6); }

/* 요약 헤더 (고정) */
.upload-stats {
  flex: none;
  display: flex; flex-direction: column; gap: 7px;
  padding: 9px 10px 8px;
  border-radius: 12px;
  background: var(--bg-soft);
  border: 1px solid transparent;
}
.upload-panel.done .upload-stats { background: rgba(23, 166, 115, .09); border-color: rgba(23, 166, 115, .22); }
[data-theme="dark"] .upload-panel.done .upload-stats { background: rgba(56, 211, 159, .1); border-color: rgba(56, 211, 159, .24); }
.us-progress { display: flex; flex-direction: column; gap: 6px; }
.us-line { display: flex; align-items: baseline; gap: 8px; }
.us-count {
  flex: 1; min-width: 0; font-size: 12.5px; font-weight: 700; color: var(--text);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.us-percent {
  font-size: 13.5px; font-weight: 800; color: var(--brand-strong);
  font-variant-numeric: tabular-nums; letter-spacing: -.2px;
}
.upload-panel.done .us-percent { color: var(--ok); }
.us-bar { height: 8px; background: var(--bg-elev); }
.us-bar span { transition: width .25s ease; }
.upload-panel.done .us-bar span { background: linear-gradient(90deg, var(--ok), #35c48d); }
.us-meta {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 5px 10px; margin: 0;
}
.us-meta > div { min-width: 0; display: flex; align-items: baseline; gap: 6px; }
.us-meta > .us-dest { grid-column: 1 / -1; }
.us-meta dt { font-size: 10.5px; font-weight: 700; color: var(--muted); letter-spacing: .01em; flex: none; }
.us-meta dd {
  margin: 0; font-size: 12.5px; font-weight: 700; color: var(--text-soft);
  font-variant-numeric: tabular-nums; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis; min-width: 0;
}
.us-current {
  display: flex; align-items: baseline; min-width: 0;
  font-size: 11.5px; color: var(--text-soft); font-weight: 600;
  overflow: hidden; white-space: nowrap;
  border-top: 1px dashed var(--line); padding-top: 6px;
}
.us-current .us-cur-lead { flex: none; color: var(--muted); font-weight: 600; white-space: nowrap; }
/* 폴더 부분만 줄이고 파일명은 끝까지 남긴다 */
.us-current .us-cur-dir {
  flex: 0 1 auto; min-width: 0; color: var(--muted); font-weight: 600;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.us-current .us-cur-name {
  flex: 0 0 auto; max-width: 100%;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.upload-panel.done .us-current { color: var(--ok); }
.upload-panel.canceled .us-current { color: var(--text-soft); }

.upload-hidden-note { flex: none; font-size: 11px; color: var(--muted); text-align: center; }

/* 스크롤 목록 */
.upload-list {
  flex: 1 1 auto; min-height: 0;
  display: flex; flex-direction: column; gap: 7px;
  overflow-y: auto; overscroll-behavior: contain;
  padding-right: 2px;
}
.upload-item {
  display: flex; flex-direction: column; gap: 4px;
  padding: 7px 9px; border-radius: 10px;
  border: 1px solid transparent; background: var(--bg-soft);
}
.upload-item .u-top { display: flex; justify-content: space-between; gap: 8px; font-size: 12.5px; min-width: 0; }
.upload-item .u-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; min-width: 0; }
.upload-item .u-status { color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; font-weight: 600; }
/* 파일이 어느 폴더의 것인지 — 작은 보조 줄(긴 경로는 말줄임, 전체는 툴팁·title) */
.upload-item .u-path {
  min-width: 0; font-size: 10.5px; line-height: 1.3; color: var(--muted);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.upload-item .u-path::before { content: "\1F4C1"; margin-right: 4px; font-size: 10px; }
.upload-item.uploading .u-path { color: var(--brand-strong); }
.bar { height: 6px; border-radius: 999px; background: var(--bg-elev); overflow: hidden; }
.bar span { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--brand), var(--accent)); transition: width .2s; }

/* 상태별 표시: 대기 / 업로드 중 / 완료 / 실패 */
.upload-item.waiting { background: transparent; border-color: var(--line); opacity: .6; }
.upload-item.waiting .bar { display: none; }
.upload-item.uploading {
  background: var(--brand-soft);
  border-color: var(--brand);
  box-shadow: 0 0 0 2px var(--brand-soft);
}
.upload-item.uploading .u-status { color: var(--brand-strong); }
.upload-item.uploading .u-status::before {
  content: ""; display: inline-block; width: 6px; height: 6px; margin-right: 5px;
  border-radius: 50%; background: var(--brand); vertical-align: 1px;
  animation: up-pulse 1s ease-in-out infinite;
}
@keyframes up-pulse { 0%, 100% { opacity: 1 } 50% { opacity: .25 } }
.upload-item.done { background: transparent; border-color: var(--line); }
.upload-item.done .u-status { color: var(--ok); }
.upload-item.done .bar span { background: var(--ok); }
.upload-item.dup { background: var(--warn-soft); border-color: transparent; }
.upload-item.dup .u-status { color: var(--warn); }
.upload-item.dup .bar span { background: var(--warn); }
.upload-item.error { background: var(--danger-soft); border-color: transparent; }
.upload-item.error .u-status { color: var(--danger); }
.upload-item.error .bar span { background: var(--danger); }
.upload-item.folder .u-name { color: var(--text-soft); }
.upload-item.canceled { background: transparent; border-color: var(--line); opacity: .55; }
.upload-item.canceled .u-status { color: var(--muted); }
.upload-item.canceled .bar span { background: var(--muted); }

/* 최소화 배지 (업로드 중 패널을 닫았을 때 우측 하단) */
.upload-pill {
  position: fixed; right: 20px; bottom: 20px; z-index: 72;
  display: inline-flex; align-items: center; gap: 8px;
  max-width: calc(100vw - 40px);
  padding: 10px 14px 12px;
  border-radius: 999px;
  background: var(--bg-elev); border: 1px solid var(--brand);
  box-shadow: var(--shadow-lg);
  color: var(--text); font-size: 12.5px; font-weight: 700;
  font-variant-numeric: tabular-nums; white-space: nowrap;
  animation: pop .16s ease;
  transition: transform .12s, box-shadow .12s;
}
.upload-pill:hover { transform: translateY(-1px); box-shadow: var(--shadow-lg); }
.upload-pill .pill-ico { font-size: 14px; line-height: 1; }
.upload-pill .pill-text { overflow: hidden; text-overflow: ellipsis; }
.upload-pill .pill-bar {
  position: absolute; left: 13px; right: 13px; bottom: 5px;
  height: 3px; border-radius: 999px; background: var(--bg-soft); overflow: hidden;
}
.upload-pill .pill-bar span {
  display: block; height: 100%; width: 0;
  background: linear-gradient(90deg, var(--brand), var(--accent));
  transition: width .25s ease;
}
.upload-pill.done { border-color: var(--ok); }
.upload-pill.done .pill-bar span { background: var(--ok); }
.upload-pill.canceled { border-color: var(--line); }
.upload-pill.canceled .pill-bar span { background: var(--muted); }

/* ---------------------------------------------------------------- 토스트 */
.toast-root {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  z-index: 120; display: flex; flex-direction: column; gap: 8px; align-items: center;
  pointer-events: none; width: min(480px, calc(100vw - 32px));
}
.toast {
  background: #1d2533; color: #f2f5fb;
  padding: 11px 16px; border-radius: 12px;
  font-size: 13.5px; box-shadow: var(--shadow-lg);
  animation: pop .16s ease;
  max-width: 100%;
}
.toast.error { background: #7f1d20; }
.toast.ok { background: #0f5132; }

@keyframes fade { from { opacity: 0 } to { opacity: 1 } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}
@keyframes pop { from { opacity: 0; transform: translateY(6px) } to { opacity: 1; transform: none } }

.spin { display: inline-block; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg) } }

/* ---------------------------------------------------------------- 반응형 */
.mobile-only { display: none; }
@media (max-width: 860px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .sidebar {
    position: fixed; inset: 0 auto 0 0; width: 82vw; max-width: 320px;
    z-index: 90; transform: translateX(-102%);
    transition: transform .2s ease;
    box-shadow: var(--shadow-lg);
  }
  .sidebar.open { transform: none; }
  .scrim { position: fixed; inset: 0; background: rgba(0, 0, 0, .42); z-index: 85; }
  .mobile-only { display: inline-grid; }
  .topbar { padding: 11px 14px; gap: 8px; }
  .topbar-actions .sync-label { display: none; }
  .btn.sync { padding: 9px 11px; }
  .content { padding: 14px 14px 90px; }
  .row { grid-template-columns: 34px minmax(0, 1fr) 34px; padding: 8px 8px; gap: 8px; }
  .row.selecting { grid-template-columns: 20px 34px minmax(0, 1fr) 34px; }
  .folder-upload .folder-label { display: none; }
  .folder-upload { padding: 9px 11px; }
  .row-meta { display: none; }
  .row-more { opacity: 1; }
  .list-head { display: none; }
  .toolbar { gap: 8px; }
  .crumb.current { font-size: 15px; }
  .listing.grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
  .upload-panel { right: 10px; bottom: 10px; width: calc(100vw - 20px); max-height: min(64dvh, 540px); padding: 10px; }
  .upload-pill { right: 10px; bottom: 10px; max-width: calc(100vw - 20px); font-size: 12px; padding: 9px 12px 11px; }
  .us-meta { gap: 4px 8px; }
  .us-meta dt { font-size: 10px; }
  .us-meta dd { font-size: 12px; }
  .upload-item { padding: 6px 8px; }
  .upload-item .u-path { font-size: 10px; }
  .preview-body iframe { height: 70dvh; }
  .modal { padding: 18px; }
}
@media (max-width: 560px) {
  .selection-bar {
    flex-wrap: wrap; gap: 8px;
    padding: 9px 11px; border-radius: 12px;
  }
  .selection-count { flex: 1 1 100%; }
  .selection-actions { margin-left: 0; width: 100%; gap: 6px; flex-wrap: wrap; }
  .selection-actions .btn { flex: 1 1 calc(50% - 3px); min-width: 0; padding: 8px 6px; font-size: 12.5px; white-space: nowrap; }
}

@media (max-width: 420px) {
  .toolbar-actions .seg:last-child { display: none; }
  .listing.grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .card { padding: 11px; }
}

/* ---------------------------------------------------------------- 위치 추적 */
.app.location-mode .topbar { display: none; }
.location-view {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--bg);
}
.loc-head {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 18px;
  background: var(--bg-elev);
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}
.loc-title { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.loc-title strong { font-size: 16.5px; letter-spacing: -.3px; white-space: nowrap; }
.loc-title span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.loc-head-actions { margin-left: auto; display: flex; gap: 8px; }

.loc-controls {
  display: flex; align-items: flex-end; gap: 14px; flex-wrap: wrap;
  padding: 10px 18px;
  background: var(--bg-elev);
  border-bottom: 1px solid var(--line);
}
.loc-field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.loc-field > span { font-size: 11.5px; font-weight: 700; color: var(--muted); }
.loc-field select {
  padding: 8px 10px; border-radius: 10px; min-width: 210px; max-width: 320px;
  border: 1px solid var(--line); background: var(--bg-soft); color: var(--text);
  font-size: 13.5px; font-weight: 600; outline: none;
}
.loc-field select:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
/* 기기 선택 + 목록에서 삭제 */
.loc-device-row { display: flex; align-items: center; gap: 6px; min-width: 0; }
.loc-device-row select { flex: 1 1 auto; }
.loc-device-delete {
  white-space: nowrap; color: var(--danger); background: var(--danger-soft); border-color: transparent;
}
.loc-device-delete:hover { filter: brightness(.97); }
.loc-device-delete.hidden { display: none; }
.loc-date-row { display: flex; align-items: center; gap: 4px; }
.loc-date-row input[type="date"] {
  padding: 7px 9px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--bg-soft); color: var(--text); font-size: 13.5px; outline: none;
}
.loc-date-row input[type="date"]:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.loc-status { margin-left: auto; font-size: 12.5px; color: var(--muted); text-align: right; line-height: 1.5; }
.loc-status b { color: var(--text-soft); }

.loc-body {
  flex: 1; display: grid; grid-template-columns: minmax(0, 1fr) 344px;
  min-height: 0;
}
.loc-map-wrap { position: relative; min-height: 0; background: var(--bg-soft); }
#loc-map { position: absolute; inset: 0; }
.leaflet-container { font: inherit; background: var(--bg-soft); }
.loc-map-note {
  position: absolute; left: 12px; bottom: 12px; z-index: 500;
  max-width: calc(100% - 24px);
  background: rgba(22, 28, 40, .86); color: #fff;
  padding: 8px 12px; border-radius: 11px; font-size: 12.5px; line-height: 1.45;
}
.loc-map-fallback {
  position: absolute; inset: 0; z-index: 400; overflow: auto;
  display: flex; flex-direction: column; gap: 10px;
  padding: 16px; background: var(--bg-soft);
}
.loc-map-fallback svg { width: 100%; height: auto; max-height: 62%; flex: 0 1 auto; }
.loc-map-fallback p { margin: 0; font-size: 13px; line-height: 1.55; }
.loc-fallback-list { display: flex; flex-direction: column; gap: 3px; font-size: 12.5px; color: var(--text-soft); }

/* 지도 위 마커 */
.loc-marker { background: none; border: 0; }
.loc-marker .pin {
  display: grid; place-items: center;
  width: 30px; height: 30px; border-radius: 50%;
  font-size: 11px; font-weight: 800; color: #fff;
  border: 2px solid #fff; box-shadow: 0 2px 8px rgba(15, 23, 42, .35);
}
.loc-marker.start .pin { background: var(--ok); }
.loc-marker.end .pin { background: var(--brand-strong); }
.loc-marker.now .pin { background: var(--accent); animation: locPulse 1.8s ease-out infinite; }
@keyframes locPulse {
  0% { box-shadow: 0 0 0 0 rgba(108, 92, 231, .55); }
  70% { box-shadow: 0 0 0 14px rgba(108, 92, 231, 0); }
  100% { box-shadow: 0 0 0 0 rgba(108, 92, 231, 0); }
}
.loc-zone-label {
  background: var(--accent); color: #fff; border: 0;
  font-size: 11.5px; font-weight: 700; padding: 3px 8px; border-radius: 999px;
  box-shadow: 0 2px 6px rgba(15, 23, 42, .25);
}
.loc-zone-label::before { display: none; }
[data-theme="dark"] .leaflet-tile { filter: brightness(.78) contrast(1.07) saturate(.9); }

/* 하단 타임스탬프 슬라이더(둥근 플로팅 카드) */
.loc-timeline {
  position: absolute; left: 14px; right: 14px; bottom: 14px; z-index: 560;
  display: flex; flex-direction: column; gap: 5px;
  padding: 10px 16px 9px;
  border-radius: 20px;
  background: rgba(255, 255, 255, .95);
  border: 1px solid var(--line);
  box-shadow: 0 12px 30px rgba(15, 23, 42, .18), 0 2px 6px rgba(15, 23, 42, .08);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}
[data-theme="dark"] .loc-timeline { background: rgba(24, 28, 38, .93); }
.loc-timeline-head { display: flex; align-items: baseline; gap: 8px; }
.loc-timeline-clock {
  font-size: 19px; font-weight: 800; letter-spacing: -.4px; color: var(--text);
  font-variant-numeric: tabular-nums;
}
.loc-timeline-pos {
  margin-left: auto; font-size: 12px; font-weight: 800; color: var(--brand-strong);
  background: var(--brand-soft); border-radius: 999px; padding: 2px 9px;
  font-variant-numeric: tabular-nums; white-space: nowrap;
}
.loc-timeline-range {
  -webkit-appearance: none; appearance: none;
  width: 100%; height: 22px; margin: 0; background: transparent; cursor: pointer;
  touch-action: pan-y;
}
.loc-timeline-range::-webkit-slider-runnable-track {
  height: 6px; border-radius: 999px;
  background: linear-gradient(90deg, #a99cff, var(--brand) 65%, #d9d4ff);
}
.loc-timeline-range::-webkit-slider-thumb {
  -webkit-appearance: none; width: 20px; height: 20px; margin-top: -7px;
  border-radius: 50%; background: #fff; border: 2.5px solid var(--brand);
  box-shadow: 0 2px 7px rgba(15, 23, 42, .32);
}
.loc-timeline-range::-moz-range-track {
  height: 6px; border-radius: 999px;
  background: linear-gradient(90deg, #a99cff, var(--brand) 65%, #d9d4ff);
}
.loc-timeline-range::-moz-range-thumb {
  width: 18px; height: 18px; border-radius: 50%; background: #fff;
  border: 2.5px solid var(--brand); box-shadow: 0 2px 7px rgba(15, 23, 42, .32);
}
.loc-timeline-range:focus-visible { outline: 2px solid var(--brand); outline-offset: 3px; }
.loc-timeline-meta {
  display: flex; align-items: center; gap: 8px; min-width: 0;
  font-size: 12.5px; color: var(--text-soft);
}
.loc-timeline-addr {
  min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-weight: 600;
}
.loc-timeline-addr .addr-sub { color: var(--muted); font-weight: 500; }
.loc-timeline-batt {
  margin-left: auto; white-space: nowrap; font-weight: 700; font-size: 11.5px;
  color: var(--muted);
}
.loc-timeline-ends {
  display: flex; justify-content: space-between;
  font-size: 10.5px; font-weight: 700; color: var(--muted); margin-top: -2px;
}
@media (max-width: 640px) {
  .loc-timeline { left: 10px; right: 10px; bottom: 10px; padding: 9px 13px 8px; border-radius: 17px; }
  .loc-timeline-clock { font-size: 17.5px; }
}
.loc-pick-marker { background: none; border: 0; }
.loc-pick-marker .bubble {
  position: relative; display: inline-flex; flex-direction: column; gap: 1px;
  padding: 7px 11px; border-radius: 13px;
  background: #fff; border: 2px solid var(--brand);
  box-shadow: 0 6px 18px rgba(15, 23, 42, .25);
  transform: translate(-50%, -100%);
  min-width: 96px; max-width: min(250px, 64vw);
}
.loc-pick-marker .bubble::after {
  content: ''; position: absolute; left: 50%; bottom: -7px; transform: translateX(-50%) rotate(45deg);
  width: 11px; height: 11px; background: #fff;
  border-right: 2px solid var(--brand); border-bottom: 2px solid var(--brand);
}
.loc-pick-marker .bubble b { font-size: 13px; font-weight: 800; letter-spacing: -.2px; }
.loc-pick-marker .bubble .addr {
  font-size: 11.5px; color: var(--text-soft); line-height: 1.35;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden; word-break: break-all;
}
.loc-pick-marker .bubble .meta { font-size: 10.5px; color: var(--muted); font-weight: 700; }

/* 요약 패널 */
.loc-side {
  border-left: 1px solid var(--line); background: var(--bg-elev);
  padding: 14px; display: flex; flex-direction: column; gap: 12px;
  overflow-y: auto; min-height: 0;
}
.loc-summary { display: flex; flex-direction: column; gap: 10px; }
.loc-device-name { font-weight: 800; font-size: 15px; letter-spacing: -.2px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.loc-badge {
  font-size: 11px; font-weight: 800; padding: 2px 8px; border-radius: 999px;
  background: var(--bg-soft); color: var(--text-soft);
}
.loc-badge.live { background: rgba(23, 166, 115, .14); color: var(--ok); }
.loc-badge.off { background: var(--bg-soft); color: var(--muted); }
.loc-badge.warn { background: var(--warn-soft); color: var(--warn); }
.loc-badge.version { background: transparent; color: var(--muted); border: 1px solid var(--line); padding: 1px 7px; font-variant-numeric: tabular-nums; }
.loc-summary-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.loc-stat { background: var(--bg-soft); border-radius: 12px; padding: 9px 11px; min-width: 0; }
.loc-stat .k { font-size: 11.5px; color: var(--muted); font-weight: 700; display: block; }
.loc-stat .v { font-size: 15px; font-weight: 800; letter-spacing: -.2px; display: block; margin-top: 1px; word-break: break-word; }
.loc-stat .v.small-v { font-size: 13px; font-weight: 700; }
.loc-empty { font-size: 12.5px; color: var(--muted); line-height: 1.55; margin: 0; }

.loc-links { display: grid; gap: 6px; grid-template-columns: 1fr 1fr; }
.loc-links .btn { text-decoration: none; font-size: 12.5px; padding: 9px 8px; }

.loc-zone-box { border: 1px solid var(--line); border-radius: 12px; padding: 10px 11px; display: flex; flex-direction: column; gap: 7px; }
.loc-zone-head { display: flex; align-items: center; justify-content: space-between; }
.loc-zone-head strong { font-size: 13.5px; }
.loc-zone-list { display: flex; flex-direction: column; gap: 6px; }
.loc-zone-row {
  display: flex; align-items: center; gap: 8px;
  background: var(--bg-soft); border-radius: 10px; padding: 7px 9px; font-size: 12.5px;
}
.loc-zone-row .zname { font-weight: 700; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.loc-zone-row .zmeta { color: var(--muted); font-size: 11.5px; white-space: nowrap; }
.loc-empty-row { font-size: 12px; color: var(--muted); padding: 4px 2px; }
.loc-hint { margin: 0; line-height: 1.6; }
.link-btn { color: var(--brand-strong); font-weight: 700; text-decoration: underline; padding: 0; font-size: inherit; }

/* 위치 설정 모달 */
.loc-settings { width: min(560px, 100%); max-height: min(88dvh, 780px); overflow-y: auto; }
.loc-settings section { display: flex; flex-direction: column; gap: 7px; padding: 12px 0; border-top: 1px solid var(--line); }
.loc-settings section:first-of-type { border-top: 0; padding-top: 2px; }
.loc-settings h3 { margin: 0; font-size: 13px; color: var(--text-soft); letter-spacing: -.1px; }
.loc-settings .row-line { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.loc-settings .row-line.grow { justify-content: space-between; }
.loc-settings select, .loc-settings input[type="text"], .loc-settings input[type="number"] {
  padding: 9px 10px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--bg-soft); color: var(--text); font-size: 13.5px; outline: none; width: 100%;
}
.loc-settings select:focus, .loc-settings input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.loc-switch { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 13.5px; color: var(--text); }
.loc-switch input { width: 18px; height: 18px; accent-color: var(--brand); }
.loc-mini { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
.loc-mini label { font-size: 11.5px; font-weight: 700; color: var(--muted); display: flex; flex-direction: column; gap: 3px; }
.loc-backup-info { font-size: 12px; color: var(--muted); line-height: 1.55; }
.loc-zone-form { display: flex; flex-direction: column; gap: 7px; background: var(--bg-soft); border-radius: 12px; padding: 10px; }
.loc-zone-form .mini-actions { display: flex; gap: 6px; flex-wrap: wrap; }

@media (max-width: 860px) {
  .loc-head { padding: 9px 12px; gap: 8px; }
  .loc-title strong { font-size: 15px; }
  .loc-title span { display: none; }
  .loc-head-actions .btn { padding: 8px 10px; }
  .loc-controls { padding: 9px 12px; gap: 10px; }
  .loc-field select { min-width: 0; width: 100%; max-width: none; }
  .loc-field { flex: 1 1 160px; }
  .loc-date-field { flex: 1 1 100%; }
  .loc-device-field { flex: 1 1 100%; }
  .loc-device-row { flex-wrap: wrap; }
  .loc-device-row select { flex: 1 1 140px; }
  .loc-device-delete { flex: 0 0 auto; }
  .loc-status { margin-left: 0; text-align: left; flex: 1 1 100%; }
  .loc-body { grid-template-columns: minmax(0, 1fr); grid-template-rows: 50dvh minmax(0, 1fr); overflow-y: auto; }
  .loc-map-wrap { min-height: 260px; }
  .loc-side { border-left: 0; border-top: 1px solid var(--line); overflow-y: visible; }
}

.loc-status .loc-status-error { color: var(--danger); font-weight: 700; }

/* 기기 목록에서 삭제 확인 모달 */
.loc-device-delete-modal { max-width: 460px; }
.loc-device-delete-modal .loc-delete-target { margin: 0 0 10px; font-weight: 600; line-height: 1.55; }
.loc-device-delete-modal .loc-delete-note {
  display: flex; flex-direction: column; gap: 6px;
  padding: 11px 13px; border-radius: 12px;
  background: var(--bg-soft); border: 1px solid var(--line);
}
.loc-device-delete-modal .loc-delete-note p { margin: 0; line-height: 1.5; }
.loc-device-delete-modal .loc-delete-keep { font-weight: 700; color: var(--text); font-size: 13px; }
.loc-device-delete-modal .loc-delete-keep::before { content: '\2139\FE0F  '; }
.loc-device-delete-modal .loc-delete-note .small { font-size: 12px; color: var(--muted); }
.loc-device-delete-modal .modal-actions { margin-top: 14px; }
.loc-links .btn.disabled { opacity: .5; pointer-events: auto; }

/* Leaflet 은 내부 pane·control 의 z-index 가 400~1000 이라, 위치 화면에서는
   모달·토스트·안내가 지도에 가리지 않도록 그 위로 올린다. */
body.location-mode .modal-backdrop { z-index: 1100; }
body.location-mode .toast-root { z-index: 1150; }
body.location-mode #context-menu { z-index: 1120; }
body.location-mode .upload-pill { z-index: 1100; }
body.location-mode .loc-map-note { z-index: 1100; }
body.location-mode .loc-map-fallback { z-index: 1050; }
@media (max-width: 860px) {
  .app.location-mode .sidebar { z-index: 1200; }
  .app.location-mode .scrim { z-index: 1190; }
}

/* ------------------------------------------------- 관리자 3메뉴 (권한·단말기·보안) */
.app.admin-mode .topbar { display: none; }
.admin-view {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--bg);
}
.admin-head {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 18px;
  background: var(--bg-elev);
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}
.admin-title { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.admin-title strong { font-size: 16.5px; letter-spacing: -.3px; white-space: nowrap; }
.admin-title span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.admin-title span.error { color: var(--danger); }
.admin-title span.ok { color: var(--ok); }
.admin-head-actions { margin-left: auto; display: flex; gap: 8px; }
.admin-body {
  flex: 1; min-height: 0; overflow-y: auto;
  padding: 16px 18px 40px;
  display: flex; flex-direction: column; gap: 14px;
}
.admin-card {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px 16px;
  display: flex; flex-direction: column; gap: 8px;
}
.admin-card-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.admin-card-head strong { font-size: 15px; }
.admin-card-head > .muted { margin-left: auto; }
.admin-card > label { font-size: 12px; font-weight: 700; color: var(--muted); }
.admin-card input[type="password"],
.admin-card input[type="text"] {
  padding: 9px 11px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--bg-soft); color: var(--text); font-size: 14px; outline: none;
  width: 100%;
}
.admin-card input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.switch-line { margin-left: auto; display: inline-flex; align-items: center; gap: 7px; font-weight: 700; font-size: 13.5px; }
.switch-line input { width: 18px; height: 18px; accent-color: var(--brand); }
.access-tree-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.access-tree {
  border: 1px solid var(--line); border-radius: 12px;
  background: var(--bg-soft);
  padding: 8px; max-height: 54vh; overflow: auto;
}
.access-tree.flat .access-node-wrap { display: contents; }
.access-channel {
  font-size: 11.5px; font-weight: 800; letter-spacing: .2px; color: var(--muted);
  padding: 6px 8px 2px;
}
.access-node {
  display: flex; align-items: center; gap: 7px;
  padding: 5px 8px; border-radius: 9px; cursor: pointer;
  font-size: 13.5px; line-height: 1.35;
}
.access-node:hover { background: var(--bg-hover); }
.access-node input { width: 16px; height: 16px; accent-color: var(--brand); flex: 0 0 auto; }
.access-node .access-ico { font-size: 13px; }
.term-summary { display: flex; gap: 6px; flex-wrap: wrap; }
.chip.warn { background: var(--warn-soft); color: var(--warn); }
.chip.danger { background: var(--danger-soft); color: var(--danger); }
.chip.admin { background: var(--brand-soft); color: var(--brand-strong); }
.term-list { display: flex; flex-direction: column; gap: 10px; }
.term-card {
  background: var(--bg-elev); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 13px 15px;
  display: flex; flex-direction: column; gap: 9px;
}
.term-card.pending { border-color: var(--warn); }
.term-card.locked { border-color: var(--danger); }
.term-title { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.term-name { font-size: 15px; letter-spacing: -.2px; }
.term-nick { font-size: 13px; color: var(--brand-strong); font-weight: 700; }
.role-badge, .status-badge {
  font-size: 11px; font-weight: 800; padding: 3px 8px; border-radius: 999px;
  background: var(--bg-soft); color: var(--text-soft); border: 1px solid var(--line);
}
.role-badge.admin { background: var(--brand-soft); color: var(--brand-strong); border-color: transparent; }
.status-badge.approved { background: rgba(23, 166, 115, .12); color: var(--ok); border-color: transparent; }
.status-badge.pending { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.status-badge.locked, .status-badge.blocked { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.term-nick-form { display: flex; gap: 6px; align-items: center; }
.term-nick-input {
  flex: 1 1 auto; min-width: 0; padding: 8px 10px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--bg-soft); color: var(--text);
  font-size: 13.5px; outline: none;
}
.term-nick-input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.term-meta { display: flex; gap: 6px; flex-wrap: wrap; }
.term-chip {
  font-size: 11.5px; font-weight: 700; color: var(--text-soft);
  background: var(--bg-soft); border-radius: 999px; padding: 4px 9px;
}
.term-chip.loc-on { background: rgba(23, 166, 115, .12); color: var(--ok); }
.term-chip.loc-off { background: var(--bg-soft); color: var(--muted); }
.term-chip.loc-unknown { background: var(--warn-soft); color: var(--warn); }
.term-pin { font-size: 12.5px; font-weight: 800; }
.term-pin.pin-ok { color: var(--ok); }
.term-pin.pin-warn { color: var(--warn); }
.term-pin.pin-bad { color: var(--danger); }
.term-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.sec-tabs { align-self: flex-start; flex-wrap: wrap; }
.sec-panel {
  background: var(--bg-elev); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 6px 4px;
  max-height: calc(100dvh - 210px); overflow: auto;
}
.sec-row { padding: 9px 13px; border-bottom: 1px solid var(--line); }
.sec-row:last-child { border-bottom: 0; }
.sec-row-main { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.sec-row-main strong { font-size: 13.5px; font-weight: 700; }
.sec-row-main .muted { margin-left: auto; font-size: 11.5px; text-align: right; }
.sec-detail { margin: 3px 0 0; font-size: 12px; color: var(--muted); line-height: 1.5; word-break: break-all; }
.sec-row.sec-ok strong { color: var(--ok); }
.sec-row.sec-warn strong { color: var(--warn); }
.sec-row.sec-bad strong { color: var(--danger); }

@media (max-width: 860px) {
  .admin-head { padding: 9px 12px; gap: 8px; }
  .admin-title strong { font-size: 15px; }
  .admin-title span { display: none; }
  .admin-head-actions .btn { padding: 8px 10px; }
  .admin-body { padding: 12px 12px 32px; }
  .admin-card { padding: 12px 13px; }
  .term-card { padding: 12px; }
  .term-nick-form { flex-wrap: wrap; }
  .term-nick-input { flex: 1 1 100%; }
  .sec-panel { max-height: none; }
  .sec-row-main .muted { margin-left: 0; text-align: left; flex: 1 1 100%; }
}
body.admin-mode .modal-backdrop { z-index: 1100; }
body.admin-mode .toast-root { z-index: 1150; }
