/* ==========================================================
   Roop 통합 Admin (PC 웹)
   1. 토큰 · 기본값  2. 레이아웃(사이드바 · 상단바)  3. 카드 · KPI
   4. 탭 · 검색 · 버튼  5. 표  6. 배지  7. 서랍(폼) · 대화상자
   8. 폼 요소  9. 지도 위치 고르기  10. 반응형
   ========================================================== */

/* 1. 토큰 · 기본값 */
:root {
  --blue: #1F4FE0; --blue-weak: #EAF0FF; --ink: #0B0B0F; --sub: #5B6472; --muted: #8A93A3;
  --line: #E4E8EF; --surface: #F5F7FA; --white: #FFFFFF;
  --red: #C4271B; --red-weak: #FDECEC; --amber: #B26A00; --amber-weak: #FFF4E0; --green: #13804B; --green-weak: #E5F5EC;
  --radius: 14px; --shadow: 0 1px 2px rgba(11, 11, 15, .04), 0 4px 16px rgba(11, 11, 15, .04);
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: 'Noto Sans KR', system-ui, sans-serif; font-size: 14px; line-height: 1.5; color: var(--ink); background: var(--surface); }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; }
h1, h2, h3, p { margin: 0; }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }

/* 2. 레이아웃 */
.adm { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.adm-side { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 4px; padding: 22px 14px; background: var(--white); border-right: 1px solid var(--line); }
.adm-brand { display: flex; align-items: center; gap: 10px; padding: 0 10px 18px; text-decoration: none; }
.adm-brand__mark { display: flex; align-items: center; justify-content: center; width: 32px; height: 32px; border-radius: 10px; background: var(--blue); }
.adm-brand__mark img { width: 12px; height: 16px; }
.adm-brand__name { font-size: 15px; font-weight: 700; }
.adm-brand__name small { display: block; font-size: 11px; font-weight: 500; color: var(--muted); }
.adm-nav { display: flex; flex-direction: column; gap: 2px; }
.adm-nav a { display: flex; align-items: center; gap: 10px; height: 40px; padding: 0 12px; border-radius: 10px; text-decoration: none; color: var(--sub); font-weight: 500; }
.adm-nav a:hover { background: var(--surface); color: var(--ink); }
.adm-nav a[aria-current="page"] { background: var(--blue-weak); color: var(--blue); font-weight: 700; }
.adm-nav__count { margin-left: auto; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; background: var(--red); color: var(--white); font-size: 11px; font-weight: 700; line-height: 20px; text-align: center; }
.adm-side__foot { margin-top: auto; display: flex; flex-direction: column; gap: 6px; padding: 14px 10px 0; border-top: 1px solid var(--line); font-size: 12px; color: var(--muted); }
.adm-side__foot a { color: var(--sub); text-decoration: none; }
.adm-side__foot a:hover { color: var(--blue); }

.adm-main { min-width: 0; padding: 28px 32px 60px; }
.adm-top { display: flex; align-items: center; gap: 12px; margin-bottom: 22px; }
.adm-top h1 { font-size: 22px; line-height: 30px; font-weight: 700; }
.adm-top__code { font-size: 12px; font-weight: 700; color: var(--muted); letter-spacing: .02em; }
.adm-top__actions { margin-left: auto; display: flex; gap: 8px; }
.adm-desc { margin: -14px 0 22px; color: var(--sub); }

/* 3. 카드 · KPI */
.card { padding: 20px 22px; border-radius: var(--radius); background: var(--white); box-shadow: var(--shadow); }
.card + .card { margin-top: 16px; }
.card__head { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.card__head h2 { font-size: 16px; font-weight: 700; }
.card__head .muted { font-size: 12px; }
.card__head > :last-child:not(h2) { margin-left: auto; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-2 > .card + .card { margin-top: 0; }
.grid-2 + .card, .kpis + .card { margin-top: 16px; }
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 16px; }
.kpi { display: flex; flex-direction: column; gap: 6px; padding: 18px 20px; border-radius: var(--radius); background: var(--white); box-shadow: var(--shadow); text-decoration: none; }
.kpi__label { font-size: 13px; color: var(--sub); }
.kpi__value { font-size: 26px; line-height: 34px; font-weight: 700; letter-spacing: -.01em; }
.kpi__value small { margin-left: 2px; font-size: 14px; font-weight: 500; color: var(--sub); }
.kpi__hint { font-size: 12px; color: var(--muted); }
a.kpi:hover { box-shadow: 0 0 0 1.5px var(--blue), var(--shadow); }
.muted { color: var(--muted); }
.flow { display: flex; flex-direction: column; gap: 10px; margin: 0; padding: 0; list-style: none; counter-reset: flow; }
.flow li { display: flex; gap: 10px; align-items: flex-start; color: var(--sub); }
.flow li::before { counter-increment: flow; content: counter(flow); flex-shrink: 0; width: 22px; height: 22px; border-radius: 11px; background: var(--blue-weak); color: var(--blue); font-size: 12px; font-weight: 700; line-height: 22px; text-align: center; }
.flow b { color: var(--ink); }
.flow a { color: var(--blue); font-weight: 700; }

/* 4. 탭 · 검색 · 버튼 */
.toolbar { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.tabs { display: flex; gap: 4px; padding: 4px; border-radius: 12px; background: var(--white); box-shadow: var(--shadow); }
.tabs button { height: 34px; padding: 0 14px; border: 0; border-radius: 9px; background: none; color: var(--sub); font-weight: 500; }
.tabs button[aria-pressed="true"] { background: var(--ink); color: var(--white); font-weight: 700; }
.tabs b { margin-left: 4px; font-weight: 700; }
.search { display: flex; align-items: center; gap: 8px; height: 42px; margin-left: auto; padding: 0 14px; width: 260px; border-radius: 12px; background: var(--white); box-shadow: var(--shadow); color: var(--muted); }
.search input { flex: 1; min-width: 0; border: 0; outline: 0; background: none; color: var(--ink); }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 40px; padding: 0 16px; border: 1px solid var(--line); border-radius: 10px; background: var(--white); font-weight: 700; text-decoration: none; white-space: nowrap; }
.btn:hover { border-color: #C9CFDA; }
.btn--primary { border-color: var(--blue); background: var(--blue); color: var(--white); }
.btn--primary:hover { border-color: #1A44C4; background: #1A44C4; }
.btn--danger { border-color: var(--red-weak); background: var(--red-weak); color: var(--red); }
.btn--ghost { border-color: transparent; background: none; color: var(--sub); }
.btn--ghost:hover { background: var(--surface); border-color: transparent; }
.btn--sm { height: 32px; padding: 0 11px; border-radius: 8px; font-size: 13px; }
.btn:disabled { opacity: .45; cursor: default; }
.btn-row { display: flex; gap: 6px; justify-content: flex-end; }

/* 5. 표 */
.table-wrap { overflow-x: auto; border-radius: var(--radius); background: var(--white); box-shadow: var(--shadow); }
.table { width: 100%; border-collapse: collapse; white-space: nowrap; }
.table th { position: sticky; top: 0; padding: 12px 14px; border-bottom: 1px solid var(--line); background: #FAFBFC; text-align: left; font-size: 12px; font-weight: 700; color: var(--sub); }
.table td { padding: 13px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: #FAFBFD; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table .actions { text-align: right; }
.cell-title { font-weight: 700; }
.cell-sub { display: block; font-size: 12px; color: var(--muted); }
.table-empty { padding: 40px 16px !important; text-align: center; color: var(--muted); }
.row-flash td { animation: flash 1.4s ease; }
@keyframes flash { from { background: var(--blue-weak); } to { background: transparent; } }

/* 6. 배지 */
.badge { display: inline-flex; align-items: center; height: 24px; padding: 0 9px; border-radius: 12px; font-size: 12px; font-weight: 700; background: var(--surface); color: var(--sub); }
.badge--blue { background: var(--blue-weak); color: var(--blue); }
.badge--green { background: var(--green-weak); color: var(--green); }
.badge--amber { background: var(--amber-weak); color: var(--amber); }
.badge--red { background: var(--red-weak); color: var(--red); }
.badge--ink { background: var(--ink); color: var(--white); }
.badge + .badge { margin-left: 4px; }

/* 7. 서랍(폼) · 대화상자 */
.overlay { position: fixed; inset: 0; z-index: 100; background: rgba(11, 11, 15, .32); animation: fade .2s ease; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; z-index: 101; display: flex; flex-direction: column; width: min(560px, 100vw); background: var(--white); box-shadow: -12px 0 40px rgba(11, 11, 15, .14); animation: slide-in .26s cubic-bezier(.22, 1, .36, 1); }
.drawer__head { display: flex; align-items: center; gap: 10px; padding: 20px 24px; border-bottom: 1px solid var(--line); }
.drawer__head h2 { font-size: 18px; font-weight: 700; }
.drawer__body { flex: 1; overflow-y: auto; padding: 20px 24px 32px; }
.drawer__foot { display: flex; gap: 8px; justify-content: flex-end; padding: 14px 24px; border-top: 1px solid var(--line); }
.icon-btn { display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px; margin-left: auto; border: 0; border-radius: 10px; background: none; color: var(--sub); }
.icon-btn:hover { background: var(--surface); }
.dialog { position: fixed; left: 50%; top: 50%; z-index: 102; width: min(420px, calc(100vw - 32px)); padding: 24px; border-radius: 18px; background: var(--white); box-shadow: 0 24px 60px rgba(11, 11, 15, .22); transform: translate(-50%, -50%); animation: pop .2s ease; }
.dialog h2 { margin-bottom: 8px; font-size: 18px; font-weight: 700; }
.dialog p { color: var(--sub); }
.dialog .btn-row { margin-top: 20px; }
.dialog textarea { margin-top: 14px; }
@keyframes fade { from { opacity: 0; } }
@keyframes slide-in { from { transform: translateX(40px); opacity: .4; } }
@keyframes pop { from { transform: translate(-50%, -46%); opacity: 0; } }

/* 8. 폼 요소 */
.form-section { padding: 4px 0 18px; }
.form-section + .form-section { padding-top: 18px; border-top: 1px solid var(--line); }
.form-section h3 { margin-bottom: 12px; font-size: 14px; font-weight: 700; }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field > span { font-size: 13px; font-weight: 500; color: var(--sub); }
.field small { font-size: 12px; color: var(--muted); }
.fields-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.input, .select, .textarea { width: 100%; height: 42px; padding: 0 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--white); outline: 0; }
.textarea { height: 84px; padding: 10px 12px; resize: vertical; }
.input:focus, .select:focus, .textarea:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(31, 79, 224, .12); }
.input:disabled { background: var(--surface); color: var(--muted); }
.input-unit { position: relative; }
.input-unit .input { padding-right: 34px; text-align: right; }
.input-unit em { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); font-style: normal; color: var(--muted); }
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 48px; }
.switch-row b { display: block; font-size: 14px; font-weight: 500; }
.switch-row small { font-size: 12px; color: var(--muted); }
.switch { position: relative; flex-shrink: 0; width: 44px; height: 26px; border: 0; border-radius: 13px; background: #C9CFDA; transition: background .18s ease; }
.switch::after { content: ""; position: absolute; left: 3px; top: 3px; width: 20px; height: 20px; border-radius: 10px; background: var(--white); box-shadow: 0 1px 3px rgba(11, 11, 15, .2); transition: left .18s ease; }
.switch[aria-checked="true"] { background: var(--blue); }
.switch[aria-checked="true"]::after { left: 21px; }
.checks { display: flex; flex-wrap: wrap; gap: 6px; }
.check { display: inline-flex; align-items: center; height: 34px; padding: 0 12px; border: 1px solid var(--line); border-radius: 17px; background: var(--white); font-size: 13px; color: var(--sub); }
.check[aria-pressed="true"] { border-color: var(--blue); background: var(--blue-weak); color: var(--blue); font-weight: 700; }
.seg { display: flex; gap: 4px; padding: 3px; border-radius: 11px; background: var(--surface); }
.seg button { flex: 1; height: 36px; border: 0; border-radius: 8px; background: none; color: var(--sub); font-weight: 500; }
.seg button[aria-pressed="true"] { background: var(--white); color: var(--ink); font-weight: 700; box-shadow: 0 1px 3px rgba(11, 11, 15, .1); }
.photo-pick { display: flex; gap: 8px; }
.photo-pick button { position: relative; width: 96px; height: 72px; padding: 0; overflow: hidden; border: 2px solid transparent; border-radius: 12px; background: var(--surface); }
.photo-pick button[aria-pressed="true"] { border-color: var(--blue); }
.photo-pick img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo-pick button[aria-pressed="true"]::after { content: "✓"; position: absolute; right: 4px; top: 4px; width: 20px; height: 20px; border-radius: 10px; background: var(--blue); color: var(--white); font-size: 12px; line-height: 20px; text-align: center; }
.note { padding: 12px 14px; border-radius: 12px; background: var(--surface); font-size: 13px; color: var(--sub); }
.note--amber { background: var(--amber-weak); color: var(--amber); }

/* 9. 지도 위치 고르기 (사용자 앱 지도 390×844 축소) */
.map-pick { position: relative; width: 195px; height: 422px; overflow: hidden; border-radius: 14px; background: #E6EAF0; cursor: crosshair; flex-shrink: 0; }
.map-pick__road-h, .map-pick__road-v { position: absolute; background: #FFFFFF; }
.map-pick__dot { position: absolute; width: 10px; height: 10px; border-radius: 5px; background: #9AA3B2; border: 2px solid #FFFFFF; transform: translate(-50%, -50%); pointer-events: none; }
.map-pick__dot--me { width: 18px; height: 18px; border-radius: 9px 9px 9px 2px; background: var(--blue); transform: translate(-50%, -100%) rotate(-45deg); box-shadow: 0 3px 8px rgba(31, 79, 224, .35); }
.map-row { display: flex; gap: 16px; align-items: flex-start; }

/* 10. 반응형 (PC 기준, 좁은 창 대응만) */
@media (max-width: 1100px) { .kpis { grid-template-columns: repeat(2, 1fr); } .grid-2 { grid-template-columns: 1fr; } }
@media (max-width: 860px) {
  .adm { grid-template-columns: 1fr; }
  .adm-side { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; padding: 12px 16px; }
  .adm-brand { padding: 0 10px 0 0; }
  .adm-nav { flex-direction: row; flex-wrap: wrap; }
  .adm-side__foot { display: none; }
  .adm-main { padding: 20px 16px 40px; }
  .search { width: 100%; margin-left: 0; }
  .toolbar { flex-wrap: wrap; }
}
@media (prefers-reduced-motion: reduce) { .overlay, .drawer, .dialog, .row-flash td { animation: none; } .switch, .switch::after { transition: none; } }

/* 토스트 (공통 ui.js가 만드는 요소) */
#todo-toast { position: fixed; left: 50%; bottom: 40px; z-index: 9999; transform: translate(-50%, 12px); padding: 12px 20px; border-radius: 24px; background: rgba(11, 11, 15, .88); color: #FFFFFF; font: 500 14px/20px 'Noto Sans KR', system-ui, sans-serif; white-space: nowrap; opacity: 0; pointer-events: none; transition: opacity .2s ease, transform .2s ease; }
#todo-toast.on { opacity: 1; transform: translate(-50%, 0); }
