/* MediSynapse 통합관리 SPA의 전체 스타일. 다크 차콜 + 샴페인 골드 테마와 애니메이션 정의. */
* { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
  height: 100%;
}
:root {
  --bg: #0F0E0C;
  --panel: #1A1815;
  --panel-2: #211E1A;
  --panel-3: #17150F;
  --border: rgba(212,180,131,.14);
  --border-strong: rgba(212,180,131,.28);
  --gold: #D4B483;
  --gold-light: #E8D4A8;
  --text: #EDE7DC;
  --muted: #9A9488;
  --green: #7FC08A;
  --red: #E08A7A;
  --shadow-gold: 0 8px 40px rgba(212,180,131,.10);
}
body {
  background:
    radial-gradient(1200px 600px at 80% -10%, rgba(212,180,131,.06), transparent 60%),
    var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ── 스크롤바 ── */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(212,180,131,.18); border-radius: 8px; }
::-webkit-scrollbar-thumb:hover { background: rgba(212,180,131,.32); }

/* ── 애니메이션 ── */
@keyframes pop {
  0% { opacity: 0; transform: translateY(8px) scale(.98); }
  100% { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes fade {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes toast {
  0% { opacity: 0; transform: translateY(16px); }
  12% { opacity: 1; transform: translateY(0); }
  88% { opacity: 1; transform: translateY(0); }
  100% { opacity: 0; transform: translateY(8px); }
}
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes glow {
  0%,100% { box-shadow: 0 0 0 0 rgba(212,180,131,.0); }
  50% { box-shadow: 0 0 0 4px rgba(212,180,131,.10); }
}

/* ── 공통 텍스트 ── */
.grad-text {
  background: linear-gradient(100deg, var(--gold), var(--gold-light));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
h1, h2, h3 { margin: 0; font-weight: 700; }
a { color: var(--gold); }

/* ── 버튼 ── */
.btn {
  appearance: none;
  border: 1px solid var(--border-strong);
  background: var(--panel-2);
  color: var(--text);
  font: inherit;
  font-weight: 600;
  padding: 9px 16px;
  border-radius: 10px;
  cursor: pointer;
  transition: transform .12s ease, background .18s ease, border-color .18s ease, box-shadow .18s ease;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  white-space: nowrap;
}
.btn:hover { background: #2a261f; border-color: var(--border-strong); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary {
  background: linear-gradient(100deg, var(--gold), var(--gold-light));
  color: #241f16;
  border-color: transparent;
  box-shadow: 0 6px 22px rgba(212,180,131,.20);
}
.btn-primary:hover { filter: brightness(1.05); background: linear-gradient(100deg, var(--gold-light), var(--gold)); }
.btn-ghost { background: transparent; border-color: var(--border); }
.btn-ghost:hover { background: rgba(212,180,131,.06); }
.btn-danger { border-color: rgba(224,138,122,.4); color: var(--red); }
.btn-danger:hover { background: rgba(224,138,122,.10); }
.btn-sm { padding: 6px 11px; font-size: 12.5px; border-radius: 8px; }
.btn-block { width: 100%; justify-content: center; }

/* ── 입력 ── */
input[type="text"], input[type="password"], textarea {
  appearance: none;
  width: 100%;
  background: var(--panel-3);
  border: 1px solid var(--border);
  color: var(--text);
  font: inherit;
  padding: 10px 13px;
  border-radius: 10px;
  transition: border-color .16s ease, box-shadow .16s ease;
}
input:focus, textarea:focus {
  outline: none;
  border-color: var(--border-strong);
  box-shadow: 0 0 0 3px rgba(212,180,131,.10);
}
textarea { resize: vertical; min-height: 84px; line-height: 1.55; }
label.field { display: block; margin-bottom: 14px; }
label.field > span { display: block; color: var(--muted); font-size: 12.5px; margin-bottom: 6px; }

/* ── 뱃지 ── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: .02em;
  padding: 3px 9px;
  border-radius: 999px;
  border: 1px solid transparent;
}
.badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-active { color: var(--green); background: rgba(127,192,138,.10); border-color: rgba(127,192,138,.28); }
.badge-suspended { color: var(--red); background: rgba(224,138,122,.10); border-color: rgba(224,138,122,.28); }
.badge-warn { color: var(--gold); background: rgba(212,180,131,.10); border-color: var(--border-strong); }
.badge-warn::before { display: none; }

/* ── 로그인 ── */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.login-card {
  width: 100%;
  max-width: 420px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 40px 36px;
  box-shadow: var(--shadow-gold);
  animation: pop .4s ease both;
  text-align: center;
}
.login-logo {
  width: 60px; height: 60px;
  margin: 0 auto 18px;
  border-radius: 16px;
  display: grid; place-items: center;
  font-size: 32px; font-weight: 800;
  background: linear-gradient(135deg, rgba(212,180,131,.16), rgba(232,212,168,.06));
  border: 1px solid var(--border-strong);
  color: var(--gold);
}
.login-card h1 { font-size: 22px; margin-bottom: 6px; }
.login-sub { color: var(--muted); margin: 0 0 26px; font-size: 13px; }
.login-msg { min-height: 20px; font-size: 12.5px; margin-top: 14px; }
.msg-error { color: var(--red); }
.msg-ok { color: var(--green); }
.msg-muted { color: var(--muted); }
.countdown { font-variant-numeric: tabular-nums; color: var(--gold-light); font-weight: 700; }

/* 코드 입력 6칸 */
.code-inputs {
  display: flex;
  gap: 9px;
  justify-content: center;
  margin: 8px 0 4px;
}
.code-inputs input {
  width: 46px;
  height: 56px;
  text-align: center;
  font-size: 24px;
  font-weight: 700;
  padding: 0;
  font-variant-numeric: tabular-nums;
}

/* ── 셸 레이아웃 ── */
.shell { min-height: 100vh; display: flex; flex-direction: column; }
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 26px;
  border-bottom: 1px solid var(--border);
  background: rgba(26,24,21,.7);
  backdrop-filter: blur(8px);
  position: sticky; top: 0; z-index: 20;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 9px;
  display: grid; place-items: center;
  font-weight: 800; font-size: 18px; color: var(--gold);
  background: linear-gradient(135deg, rgba(212,180,131,.16), rgba(232,212,168,.05));
  border: 1px solid var(--border-strong);
}
.brand-title { font-size: 16px; font-weight: 700; }
.brand-title small { display: block; font-size: 11px; color: var(--muted); font-weight: 500; letter-spacing: .04em; }

.shell-body { display: flex; flex: 1; min-height: 0; }
.nav {
  width: 210px;
  flex-shrink: 0;
  border-right: 1px solid var(--border);
  padding: 20px 14px;
  display: flex; flex-direction: column; gap: 4px;
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 13px;
  border-radius: 10px;
  color: var(--muted);
  cursor: pointer;
  font-weight: 600;
  border: 1px solid transparent;
  transition: background .15s ease, color .15s ease;
}
.nav-item:hover { background: rgba(212,180,131,.05); color: var(--text); }
.nav-item.active {
  background: rgba(212,180,131,.10);
  color: var(--gold-light);
  border-color: var(--border);
}
.main {
  flex: 1;
  min-width: 0;
  padding: 30px 34px;
  overflow: auto;
}
.container { max-width: 1080px; margin: 0 auto; animation: fade .3s ease both; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 24px; flex-wrap: wrap; }
.page-head h2 { font-size: 24px; }
.page-head p { color: var(--muted); margin: 4px 0 0; font-size: 13px; }

/* ── 통계 카드 ── */
.stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-bottom: 28px; }
.stat-card {
  background: linear-gradient(160deg, var(--panel-2), var(--panel));
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 20px 22px;
  box-shadow: var(--shadow-gold);
  animation: pop .35s ease both;
}
.stat-card .label { color: var(--muted); font-size: 12.5px; font-weight: 600; letter-spacing: .02em; }
.stat-card .value { font-size: 32px; font-weight: 800; margin-top: 8px; }
.stat-card .value.text { font-size: 20px; }
.stat-card .sub { color: var(--muted); font-size: 11.5px; margin-top: 4px; }

/* ── 패널 ── */
.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  overflow: hidden;
  animation: pop .35s ease both;
}
.panel + .panel { margin-top: 20px; }
.panel-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.panel-head h3 { font-size: 15px; }
.panel-body { padding: 18px 20px; }

/* ── 테이블 ── */
.table-wrap { overflow-x: auto; }
table.grid { width: 100%; border-collapse: collapse; }
table.grid th, table.grid td {
  text-align: left;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  white-space: nowrap;
}
table.grid th { color: var(--muted); font-weight: 600; font-size: 12px; letter-spacing: .03em; text-transform: uppercase; }
table.grid tbody tr { transition: background .14s ease; }
table.grid tbody tr.clickable { cursor: pointer; }
table.grid tbody tr.clickable:hover { background: rgba(212,180,131,.05); }
table.grid tbody tr:last-child td { border-bottom: none; }
.cell-actions { display: flex; gap: 7px; }
.mono { font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace; letter-spacing: .02em; }

.empty {
  text-align: center;
  color: var(--muted);
  padding: 44px 20px;
  font-size: 13.5px;
}

/* ── 검색바 ── */
.toolbar { display: flex; gap: 12px; align-items: center; margin-bottom: 20px; flex-wrap: wrap; }
.search { flex: 1; min-width: 220px; position: relative; }
.search input { padding-left: 38px; }
.search .ic { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }

/* ── 상세: 접속코드 박스 ── */
.code-box {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  background: var(--panel-3);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
}
.code-box .code {
  font-size: 20px; font-weight: 700; letter-spacing: .06em;
  color: var(--gold-light);
}
.kv { display: flex; flex-wrap: wrap; gap: 24px 40px; }
.kv > div .k { color: var(--muted); font-size: 12px; margin-bottom: 4px; }
.kv > div .v { font-size: 15px; font-weight: 600; }
.back-link {
  display: inline-flex; align-items: center; gap: 6px;
  color: var(--muted); cursor: pointer; font-weight: 600; font-size: 13px;
  margin-bottom: 16px; background: none; border: none; padding: 0;
}
.back-link:hover { color: var(--gold); }

/* ── 모달 ── */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(6,5,4,.66);
  backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center;
  padding: 24px; z-index: 100;
  animation: fade .18s ease both;
}
.modal {
  width: 100%; max-width: 440px;
  background: var(--panel);
  border: 1px solid var(--border-strong);
  border-radius: 18px;
  box-shadow: 0 24px 70px rgba(0,0,0,.5), var(--shadow-gold);
  animation: pop .28s ease both;
  overflow: hidden;
}
.modal-head { padding: 20px 22px 4px; }
.modal-head h3 { font-size: 18px; }
.modal-head p { color: var(--muted); font-size: 12.5px; margin: 6px 0 0; }
.modal-body { padding: 16px 22px 6px; }
.modal-foot { padding: 14px 22px 20px; display: flex; gap: 10px; justify-content: flex-end; }

.secret-box {
  background: var(--panel-3);
  border: 1px dashed var(--border-strong);
  border-radius: 12px;
  padding: 16px;
  text-align: center;
  margin: 6px 0 4px;
}
.secret-box .pw {
  font-size: 22px; font-weight: 700; letter-spacing: .05em;
  color: var(--gold-light); user-select: all;
}
.warn-text { color: var(--red); font-size: 12.5px; margin-top: 10px; }

/* ── 토스트 ── */
#overlay-toast {
  position: fixed; left: 50%; bottom: 30px; transform: translateX(-50%);
  z-index: 200; display: flex; flex-direction: column; gap: 10px; align-items: center;
  pointer-events: none;
}
.toast {
  background: var(--panel-2);
  border: 1px solid var(--border-strong);
  color: var(--text);
  padding: 12px 20px;
  border-radius: 12px;
  font-weight: 600; font-size: 13px;
  box-shadow: 0 10px 34px rgba(0,0,0,.45);
  animation: toast 2.6s ease forwards;
  display: flex; align-items: center; gap: 9px;
}
.toast.ok { border-color: rgba(127,192,138,.4); }
.toast.err { border-color: rgba(224,138,122,.4); }

/* ── 로딩 ── */
.spinner {
  width: 20px; height: 20px;
  border: 2.5px solid rgba(212,180,131,.2);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: spin .8s linear infinite;
  display: inline-block;
}
.loading-wrap { display: flex; align-items: center; justify-content: center; gap: 12px; padding: 60px; color: var(--muted); }

.muted { color: var(--muted); }
.mt-0 { margin-top: 0; }
.row-gap { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }

/* ── 유휴 세션 경고 배너 ── */
@keyframes idleDrop {
  from { opacity: 0; transform: translateY(-100%); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes idlePulse {
  0%, 100% { opacity: .55; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.35); }
}
#idle-banner {
  position: fixed; top: 0; left: 0; right: 0; z-index: 250;
  display: none; align-items: center; justify-content: center; gap: 14px;
  padding: 11px 20px;
  background: linear-gradient(180deg, rgba(33,30,26,.98), rgba(23,21,15,.98));
  border-bottom: 1px solid var(--gold);
  box-shadow: 0 6px 28px rgba(0,0,0,.45), 0 0 0 1px rgba(212,180,131,.12) inset;
  color: var(--text); font-size: 14px; letter-spacing: .1px;
  backdrop-filter: blur(6px);
}
#idle-banner.show { display: flex; animation: idleDrop .32s cubic-bezier(.2,.7,.3,1); }
#idle-banner .idle-dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--gold); box-shadow: 0 0 10px rgba(212,180,131,.7);
  animation: idlePulse 1.6s ease-in-out infinite; flex: none;
}
#idle-banner .idle-text { font-weight: 500; }
#idle-banner .idle-stay-btn {
  border: 1px solid var(--gold); background: rgba(212,180,131,.14);
  color: var(--gold-light); font-weight: 600; font-size: 13px;
  padding: 6px 16px; border-radius: 8px; cursor: pointer;
  transition: background .15s ease, transform .1s ease;
}
#idle-banner .idle-stay-btn:hover { background: rgba(212,180,131,.26); }
#idle-banner .idle-stay-btn:active { transform: translateY(1px); }
/* 남은 시간 1분 이하: 붉은 톤으로 전이 */
#idle-banner.danger {
  background: linear-gradient(180deg, rgba(58,30,26,.98), rgba(40,20,16,.98));
  border-bottom-color: var(--red);
}
#idle-banner.danger .idle-dot { background: var(--red); box-shadow: 0 0 10px rgba(224,138,122,.8); }
#idle-banner.danger .idle-stay-btn {
  border-color: var(--red); background: rgba(224,138,122,.16); color: #F1B6AB;
}
#idle-banner.danger .idle-stay-btn:hover { background: rgba(224,138,122,.28); }
