/* PSD — 다크 네이비/차콜 + 청록 강조. 외부 폰트·이미지 없음. */
:root {
  --bg: #0d1721;
  --bg-top: #0f1b26;
  --side: #101c27;
  --panel: #13202c;
  --panel-2: #172634;
  --row-hover: #1a2a39;
  --line: #22313f;
  --line-2: #2b3c4c;
  --text: #e4ebf1;
  --text-2: #b9c6d2;
  --muted: #8395a6;
  --accent: #19b3ad;
  --accent-2: #13a19c;
  --accent-soft: rgba(25, 179, 173, .14);
  --danger: #e5675f;
  --star: #f4b63f;
  --focus: #4fd8cf;
  --radius: 8px;
  --top-h: 64px;
  --side-w: 248px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 14px/1.45 "Pretendard", "Malgun Gothic", "Apple SD Gothic Neo", "Noto Sans KR", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased; overflow: hidden;
}
body.auth-mode { overflow: auto; }
a { color: inherit; text-decoration: none; }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
[hidden] { display: none !important; }
.boot { padding: 40px; color: var(--muted); text-align: center; }
.muted { color: var(--muted); margin: 0; }
.small { font-size: 12.5px; }
.grow { flex: 1; }

.ic { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.7;
  stroke-linecap: round; stroke-linejoin: round; }
.ic.sm { width: 16px; height: 16px; }
.ic.xl { width: 44px; height: 44px; stroke-width: 1.3; color: var(--muted); }

/* ---------- 버튼 ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 38px; padding: 0 16px;
  border-radius: 7px; border: 1px solid var(--line-2); background: var(--panel-2); cursor: pointer; white-space: nowrap;
  font-weight: 500; transition: background .12s, border-color .12s; }
.btn:hover { background: #1d2f40; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.btn.primary:hover { background: var(--accent-2); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn.ghost:hover { background: var(--panel-2); color: var(--text); }
.btn.danger { background: #b9433c; border-color: #b9433c; color: #fff; }
.btn.small { height: 30px; padding: 0 10px; font-size: 13px; gap: 5px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .5; cursor: default; }
.danger-text { color: var(--danger) !important; }
.icon-btn { display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 7px; cursor: pointer;
  border: 1px solid var(--line-2); background: transparent; color: var(--text-2); padding: 0; }
.icon-btn:hover:not(:disabled) { background: var(--panel-2); color: var(--text); }
.icon-btn:disabled { opacity: .35; cursor: default; }
.icon-btn .ic { width: 18px; height: 18px; }

/* ---------- 셸 ---------- */
.shell { display: grid; height: 100vh; height: 100dvh; grid-template-columns: var(--side-w) minmax(0, 1fr);
  grid-template-rows: var(--top-h) minmax(0, 1fr); grid-template-areas: "top top" "side main"; }
.topbar { grid-area: top; display: flex; align-items: center; gap: 20px; padding: 0 20px 0 22px;
  background: var(--bg-top); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 12px; flex: none; min-width: calc(var(--side-w) - 42px); white-space: nowrap; }
.brand img { width: 34px; height: 34px; }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-main { display: flex; align-items: center; gap: 8px; font-size: 19px; font-weight: 500; letter-spacing: .2px; }
.brand-main b { font-weight: 700; }
.brand-main i { width: 1px; height: 16px; background: var(--muted); display: inline-block; }
.brand small { color: var(--muted); font-size: 12px; }
.search { position: relative; flex: 1; max-width: 580px; margin: 0 auto; display: flex; align-items: center; }
.search > .ic { position: absolute; left: 14px; color: var(--muted); pointer-events: none; }
.search-input { width: 100%; height: 42px; padding: 0 40px 0 44px; border-radius: 8px; border: 1px solid var(--line-2);
  background: #0c151e; outline: none; }
.search-input::placeholder { color: var(--muted); }
.search-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.search-input::-webkit-search-cancel-button { display: none; }
.search-clear { position: absolute; right: 6px; width: 30px; height: 30px; border: 0; background: transparent;
  color: var(--muted); border-radius: 6px; cursor: pointer; display: none; place-items: center; }
.search.has-value .search-clear { display: grid; }
.search-clear:hover { color: var(--text); background: var(--panel-2); }
.top-actions { display: flex; align-items: center; gap: 8px; flex: none; }
.top-actions .divider { width: 1px; height: 26px; background: var(--line-2); margin: 0 4px; }
.user-btn { display: flex; align-items: center; gap: 8px; border: 0; background: transparent; cursor: pointer;
  padding: 4px 6px; border-radius: 8px; color: var(--text-2); }
.user-btn:hover { background: var(--panel-2); color: var(--text); }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: #c9d3dc; color: #1a2836; display: grid; place-items: center; }
.avatar .ic { width: 20px; height: 20px; stroke-width: 2; }
.user-name { max-width: 110px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.sidebar { grid-area: side; background: var(--side); border-right: 1px solid var(--line); overflow-y: auto;
  padding: 18px 12px; display: flex; flex-direction: column; gap: 4px; }
.nav-group { display: flex; flex-direction: column; gap: 4px; }
.nav-item { display: flex; align-items: center; gap: 14px; min-height: 46px; padding: 8px 14px; border-radius: 8px;
  color: var(--text-2); font-size: 15px; }
.nav-item:hover { background: var(--panel-2); color: var(--text); }
.nav-item.active { background: #1b3346; color: #fff; font-weight: 600; }
.nav-item.active > .ic { color: var(--accent); }
.nav-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.count { min-width: 28px; padding: 2px 7px; border-radius: 6px; background: #1c2a37; color: var(--text-2);
  font-size: 12.5px; text-align: center; }
.nav-item.active .count { background: #26445a; color: #fff; }
.nav-sep { height: 1px; background: var(--line); margin: 12px 6px; }
.nav-title { color: var(--muted); font-size: 13px; padding: 0 14px 6px; }
.nav-empty { color: var(--muted); font-size: 12.5px; padding: 4px 14px; margin: 0; }
.nav-item.manage { align-items: flex-start; }
.nav-item.manage .nav-label { display: flex; flex-direction: column; white-space: normal; }
.nav-item.manage small { color: var(--muted); font-size: 12px; font-weight: 400; margin-top: 2px; }

.main { grid-area: main; min-width: 0; min-height: 0; display: flex; flex-direction: column; padding: 18px 22px 18px 28px; }
.main-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 14px; flex: none; }
.main-head h1 { margin: 0 0 4px; font-size: 26px; font-weight: 700; display: flex; align-items: baseline; gap: 10px; }
.result-count { font-size: 14px; font-weight: 500; color: var(--accent); }
.head-tools { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }
.sort-select, select, input[type=text], input[type=password], input[type=search]:not(.search-input) {
  height: 38px; border-radius: 7px; border: 1px solid var(--line-2); background: #0c151e; padding: 0 10px; outline: none; }
select:focus, input[type=text]:focus, input[type=password]:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.filter-chip { display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 4px 0 10px; border-radius: 16px;
  background: var(--accent-soft); color: #bff3ee; font-size: 13px; max-width: 420px; }
.filter-chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip-x { border: 0; background: transparent; color: inherit; cursor: pointer; width: 24px; height: 24px; border-radius: 12px; display: grid; place-items: center; }
.chip-x:hover { background: rgba(255,255,255,.1); }

/* ---------- 목록 표 ---------- */
.table-wrap { flex: 1; min-height: 0; overflow: auto; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); }
.svc-table { width: 100%; border-collapse: collapse; table-layout: fixed; }
.svc-table th { position: sticky; top: 0; z-index: 1; background: var(--panel-2); text-align: left; font-weight: 500;
  color: var(--text-2); font-size: 14px; height: 46px; padding: 0 10px; border-bottom: 1px solid var(--line); }
.svc-table th .ic { color: var(--text-2); }
.svc-table td { height: 52px; padding: 0 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.svc-table tbody tr:last-child td { border-bottom: 0; }
.svc-table tbody tr:hover { background: var(--row-hover); }
.c-grip { width: 50px; text-align: center; padding-left: 12px !important; }
.c-star { width: 48px; text-align: center; }
.c-name { width: 23%; }
.c-desc { width: auto; color: var(--text-2); }
.c-cat { width: 104px; }
.c-url { width: 25%; }
.c-act { width: 148px; }
.c-order { width: 92px; }
.c-date { width: 180px; }
.svc-table.manage .c-name { width: 28%; }
.svc-table.manage .c-url { width: auto; }
.svc-table.manage .c-act { width: 200px; }
.grip { border: 0; color: var(--muted); cursor: grab; width: 28px; }
.grip:disabled { opacity: .25; cursor: default; }
.star { border: 0; color: var(--muted); }
.star.on { color: var(--star); }
.star.on .ic { fill: var(--star); }
.svc-link { display: flex; align-items: center; gap: 14px; min-width: 0; }
.svc-link:not(.static):hover .svc-name { color: #7fe8df; text-decoration: underline; text-underline-offset: 3px; }
.svc-name { font-size: 16px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.svc-icon { width: 36px; height: 36px; flex: none; border-radius: 8px; display: grid; place-items: center; color: #fff; }
.svc-icon .ic { width: 20px; height: 20px; stroke-width: 1.9; }
.svc-icon .initial { font-weight: 700; font-size: 16px; }
.ellipsis { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.url { color: #6fb3f5; }
.url:hover { text-decoration: underline; text-underline-offset: 3px; }
.url.plain { color: var(--text-2); }
.url.plain:hover { text-decoration: none; }
.acts { display: flex; align-items: center; gap: 8px; }
.badge { display: inline-block; max-width: 100%; padding: 3px 12px; border-radius: 6px; font-size: 13px; font-weight: 500;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: middle; border: 1px solid transparent; }
tr.dragging { opacity: .45; }
tr.drop-before td { box-shadow: inset 0 2px 0 var(--accent); }
tr.drop-after td { box-shadow: inset 0 -2px 0 var(--accent); }

/* 톤(아이콘 배경, 분류 배지) */
.svc-icon.tone-blue { background: #4f8df0; } .badge.tone-blue { background: #173a63; color: #8fc0ff; border-color: #2a5689; }
.svc-icon.tone-teal { background: #2bb8a6; } .badge.tone-teal { background: #12403c; color: #6ee3cf; border-color: #1d5d56; }
.svc-icon.tone-green { background: #46a85a; } .badge.tone-green { background: #1b3f25; color: #8ddc9b; border-color: #2b5a36; }
.svc-icon.tone-orange { background: #ef8a3c; } .badge.tone-orange { background: #4a2f17; color: #ffbd85; border-color: #6a4322; }
.svc-icon.tone-red { background: #e5675f; } .badge.tone-red { background: #4a2020; color: #ffa39c; border-color: #6c2f2d; }
.svc-icon.tone-pink { background: #e0628f; } .badge.tone-pink { background: #4a1f33; color: #ff9fc2; border-color: #6a2d48; }
.svc-icon.tone-purple { background: #8c6ff0; } .badge.tone-purple { background: #2f2560; color: #c2b2ff; border-color: #463a86; }
.svc-icon.tone-yellow { background: #e7b53a; color: #3b2c06; } .badge.tone-yellow { background: #46391a; color: #f5d27a; border-color: #66542a; }
.svc-icon.tone-slate { background: #5d6b7b; } .badge.tone-slate { background: #2a3540; color: #c1ccd6; border-color: #3c4a57; }
.svc-icon.tone-none { background: #3a4756; } .badge.tone-none { background: transparent; color: var(--muted); border-color: var(--line-2); }

.empty { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px;
  border: 1px dashed var(--line-2); border-radius: 10px; color: var(--text-2); padding: 40px 16px; text-align: center; }
.empty p { margin: 0; }

/* ---------- 메뉴·대화상자·토스트 ---------- */
.menu { position: fixed; z-index: 50; min-width: 180px; padding: 6px; background: #182837; border: 1px solid var(--line-2);
  border-radius: 9px; box-shadow: 0 12px 32px rgba(0,0,0,.45); display: flex; flex-direction: column; }
.menu-item { display: flex; align-items: center; gap: 10px; height: 36px; padding: 0 10px; border: 0; background: transparent;
  border-radius: 6px; cursor: pointer; text-align: left; color: var(--text-2); }
.menu-item .ic { width: 17px; height: 17px; }
.menu-item:hover:not(:disabled), .menu-item:focus-visible { background: var(--row-hover); color: var(--text); outline: none; }
.menu-item:disabled { opacity: .4; cursor: default; }
.menu-item.danger { color: var(--danger); }
.dialog { border: 1px solid var(--line-2); border-radius: 12px; background: var(--panel); color: var(--text); padding: 22px 24px;
  width: min(520px, calc(100vw - 32px)); max-height: calc(100dvh - 32px); overflow: auto; box-shadow: 0 24px 60px rgba(0,0,0,.55); }
.dialog::backdrop { background: rgba(3, 8, 14, .66); }
.dialog.confirm { width: min(440px, calc(100vw - 32px)); }
.dialog h2 { margin: 0 0 8px; font-size: 19px; }
.dlg-head { display: flex; align-items: center; justify-content: space-between; }
.dlg-head .icon-btn { border: 0; }
.dlg-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.field { display: flex; flex-direction: column; gap: 6px; margin-top: 14px; }
.field label, .label-like { font-size: 13px; color: var(--text-2); font-weight: 500; display: flex; align-items: center; gap: 8px; }
.field input, .field select { width: 100%; }
.field input[aria-invalid] { border-color: var(--danger); }
.hint { margin: 0; color: var(--muted); font-size: 12px; }
.err { margin: 0; color: #ff8f86; font-size: 12.5px; min-height: 0; }
.err:empty { display: none; }
.form-error { margin: 12px 0 0; color: #ff8f86; font-size: 13px; }
.form-error:empty { display: none; }
.notice { margin: 8px 0 0; padding: 8px 12px; border-radius: 7px; background: var(--accent-soft); color: #bff3ee; font-size: 13px; }
.new-cat { margin-top: 6px; }
.check { display: flex; align-items: center; gap: 8px; margin-top: 14px; cursor: pointer; color: var(--text-2); }
.check input { width: 17px; height: 17px; accent-color: var(--accent); }
.icon-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(36px, 1fr)); gap: 6px; }
.icon-opt { height: 36px; border-radius: 7px; border: 1px solid var(--line-2); background: #0f1a24; cursor: pointer;
  display: grid; place-items: center; color: var(--text-2); }
.icon-opt.letter { font-weight: 700; }
.icon-opt[aria-checked=true], .color-opt[aria-checked=true] { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); color: #fff; }
.color-row { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.color-opt { width: 28px; height: 28px; border-radius: 50%; border: 2px solid transparent; cursor: pointer; padding: 0; }
.color-opt.auto { width: auto; padding: 0 10px; border-radius: 14px; background: #0f1a24; border-color: var(--line-2); font-size: 12px; color: var(--text-2); }
.color-opt.tone-blue { background: #4f8df0; } .color-opt.tone-teal { background: #2bb8a6; } .color-opt.tone-green { background: #46a85a; }
.color-opt.tone-orange { background: #ef8a3c; } .color-opt.tone-red { background: #e5675f; } .color-opt.tone-pink { background: #e0628f; }
.color-opt.tone-purple { background: #8c6ff0; } .color-opt.tone-yellow { background: #e7b53a; } .color-opt.tone-slate { background: #5d6b7b; }
.color-opt[aria-checked=true] { border-color: #fff; }
.icon-preview .svc-icon { width: 28px; height: 28px; }
.icon-preview .svc-icon .ic { width: 16px; height: 16px; }
.dup-warn { margin-top: 8px; padding: 8px 10px; border-radius: 7px; background: #3d3017; color: #f5d27a; font-size: 13px;
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.toasts { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 100; }
.toast { padding: 10px 16px; border-radius: 8px; background: #1d3b3a; border: 1px solid #2a5c59; color: #d7fbf7; font-size: 13.5px;
  box-shadow: 0 8px 24px rgba(0,0,0,.4); transition: opacity .3s; }
.toast.bad { background: #462020; border-color: #6c2f2d; color: #ffd0cc; }
.toast.out { opacity: 0; }

/* ---------- 관리·설정 ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 14px; flex: none; }
.tab { border: 0; background: transparent; padding: 10px 16px; cursor: pointer; color: var(--text-2); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tab.active { color: #fff; border-bottom-color: var(--accent); font-weight: 600; }
.manage-panel { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 12px; }
.inline-form { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.inline-form input { width: 240px; }
.inline-form .err { flex-basis: 100%; }
.cat-list { list-style: none; margin: 0; padding: 0; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); overflow: auto; }
.cat-list li { display: flex; align-items: center; gap: 12px; padding: 8px 12px; border-bottom: 1px solid var(--line); }
.cat-list li:last-child { border-bottom: 0; }
.settings-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; overflow: auto; align-content: start; min-height: 0; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 18px 20px; }
.card h2 { margin: 0 0 6px; font-size: 17px; }
.card > .btn { margin-top: 14px; }
.kv { display: grid; grid-template-columns: 90px 1fr; gap: 6px 10px; margin: 8px 0 12px; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; }

/* ---------- 인증 ---------- */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.auth-card { width: min(400px, 100%); background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 28px; }
.auth-card h1 { font-size: 22px; margin: 18px 0 6px; }
.auth-card .btn { margin-top: 20px; height: 42px; }
.auth-brand { display: flex; align-items: center; gap: 12px; }
.auth-brand img { width: 38px; height: 38px; }
.auth-brand div { display: flex; flex-direction: column; line-height: 1.15; }
.auth-brand strong { font-size: 20px; }
.auth-brand span { color: var(--muted); font-size: 13px; }

/* ---------- 반응형 ---------- */
@media (max-width: 1500px) { .c-url { width: 22%; } }
@media (max-width: 1280px) {
  :root { --side-w: 228px; }
  .top-actions .btn.ghost .lbl { display: none; }
  .c-cat { width: 92px; }
  .c-act { width: 136px; } .acts { gap: 6px; }
  .main { padding: 16px 18px 16px 20px; }
}
@media (max-width: 1100px) {
  .svc-table:not(.manage) .c-url { display: none; }
  .c-name { width: 32%; }
}
@media (max-width: 860px) {
  .svc-table .c-desc, .svc-table.manage .c-url, .c-date { display: none; }
  .c-name, .svc-table.manage .c-name { width: auto; }
}
@media (max-width: 760px) {
  :root { --top-h: 112px; }
  body { overflow: hidden; }
  .shell { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto auto minmax(0, 1fr);
    grid-template-areas: "top" "side" "main"; }
  .topbar { flex-wrap: wrap; gap: 10px; padding: 10px 16px; }
  .brand { min-width: 0; flex: 1; }
  .brand small { display: none; }
  .search { order: 3; flex-basis: 100%; max-width: none; }
  .top-actions .btn .lbl, .user-name, .top-actions .divider, .top-actions .btn.ghost { display: none; }
  .top-actions .btn.primary { width: 40px; padding: 0; }
  .sidebar { flex-direction: row; overflow-x: auto; overflow-y: hidden; padding: 8px 12px; gap: 6px; border-right: 0; border-bottom: 1px solid var(--line); }
  .nav-group { flex-direction: row; gap: 6px; }
  .nav-sep, .nav-title, .nav-empty, .nav-item.manage small { display: none; }
  .nav-item { min-height: 36px; padding: 4px 12px; gap: 8px; font-size: 14px; white-space: nowrap; flex: none; }
  .nav-item .ic { width: 17px; height: 17px; }
  .nav-label { overflow: visible; }
  .main { padding: 12px 12px 12px 16px; }
  .main-head { flex-direction: column; align-items: stretch; gap: 8px; }
  .main-head h1 { font-size: 21px; }
  .main-head .muted { display: none; }
  .head-tools { justify-content: flex-start; }
  .svc-table th.c-grip, .svc-table td.c-grip, .svc-table .c-cat { display: none; }
  .c-star { width: 40px; }
  .c-act { width: 96px; }
  .svc-table:not(.manage) .c-act .acts > button:not(:last-child) { display: none; }
  .svc-table.manage .c-act { width: 104px; }
  .svc-table.manage .c-act .btn { padding: 0 8px; }
  .svc-table.manage .c-act .btn .ic { display: none; }
  .c-order { width: 80px; }
  .svc-name { font-size: 15px; }
  .svc-icon { width: 32px; height: 32px; }
  .settings-grid { grid-template-columns: 1fr; }
  .inline-form input { width: 100%; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
