:root {
  --bg: #f4f2ee;
  --panel: #ffffff;
  --ink: #1f2329;
  --muted: #6b7280;
  --line: #e3dfd7;
  --accent: #3b5bdb;
  --danger: #c92a2a;
  --ok: #2b8a3e;
  --warn: #e67700;
  --mock: #7048e8;
  --real: #0b7285;
  --radius: 10px;
  font-family: "Malgun Gothic", "Apple SD Gothic Neo", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink); }
body { display: flex; flex-direction: column; font-size: 14px; }

.topbar {
  display: flex; align-items: center; gap: 16px; padding: 10px 16px;
  background: #1f2329; color: #f8f9fa; flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand h1 { font-size: 17px; margin: 0; letter-spacing: .2px; }
.logo { color: #ffd43b; font-size: 18px; }
.top-stats { display: flex; gap: 14px; flex: 1; color: #ced4da; font-size: 13px; flex-wrap: wrap; }
.top-stats b { color: #fff; }
.top-actions { display: flex; gap: 8px; align-items: center; }

.layout { flex: 1; display: flex; min-height: 0; }
.office { position: relative; flex: 1; min-width: 0; background: #e9e5dc; }
#office { width: 100%; height: 100%; display: block; cursor: grab; touch-action: none; }
#office.dragging { cursor: grabbing; }

.legend {
  position: absolute; left: 12px; top: 12px; display: flex; flex-wrap: wrap; gap: 10px;
  background: rgba(255,255,255,.92); border: 1px solid var(--line); border-radius: 8px;
  padding: 6px 10px; font-size: 12px; max-width: calc(100% - 24px);
}
.legend span { display: inline-flex; align-items: center; gap: 5px; }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.st-working { background: #2f9e44; }
.st-presenting { background: #1c7ed6; }
.st-idle { background: #adb5bd; }
.st-dormant { background: #495057; opacity: .5; }
.cam-controls { position: absolute; right: 12px; top: 12px; display: flex; gap: 4px; }
.hint { position: absolute; left: 12px; bottom: 6px; margin: 0; font-size: 12px; color: var(--muted); }

.detail {
  position: absolute; right: 12px; top: 52px; width: 300px; max-height: calc(100% - 70px); overflow: auto;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: 0 6px 24px rgba(0,0,0,.12); padding: 12px 14px;
}
.detail h3 { margin: 0 0 4px; font-size: 16px; }
.detail .close { float: right; }
.detail table { width: 100%; border-collapse: collapse; font-size: 12px; margin-top: 6px; }
.detail td, .detail th { text-align: left; padding: 3px 4px; border-bottom: 1px solid var(--line); vertical-align: top; }

.sidebar {
  width: 400px; max-width: 45vw; overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 12px;
  border-left: 1px solid var(--line); background: #faf9f6;
}
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; }
.card h2 { font-size: 14px; margin: 0 0 8px; }
.card-head { display: flex; justify-content: space-between; align-items: center; }
.card-head h2 { margin: 0; white-space: nowrap; }
.card-head select { width: auto; }

.form { display: flex; flex-direction: column; gap: 6px; }
.form .row { display: flex; gap: 8px; }
.form label { display: flex; flex-direction: column; font-size: 12px; color: var(--muted); flex: 1; gap: 2px; }
input, textarea, select {
  font: inherit; padding: 6px 8px; border: 1px solid #cfc9bd; border-radius: 6px; background: #fff; color: var(--ink);
  width: 100%;
}
textarea { resize: vertical; }

.btn {
  font: inherit; border: 1px solid #cfc9bd; background: #fff; color: var(--ink);
  border-radius: 6px; padding: 6px 10px; cursor: pointer;
}
.btn:hover { background: #f1efe9; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: #3049b8; }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { background: #a61e1e; }
.btn-ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn-sm { padding: 3px 8px; font-size: 12px; }

.pill { padding: 2px 8px; border-radius: 999px; font-size: 12px; }
.pill-muted { background: #495057; color: #fff; }
.pill-ok { background: var(--ok); color: #fff; }
.pill-danger { background: var(--danger); color: #fff; }

.badge { white-space: nowrap; flex-shrink: 0; display: inline-block; padding: 1px 6px; border-radius: 4px; font-size: 11px; font-weight: 700; }
.badge-mock { background: #f3f0ff; color: var(--mock); border: 1px solid #d0bfff; }
.badge-real { background: #e3fafc; color: var(--real); border: 1px solid #99e9f2; }
.badge-status { background: #f1f3f5; color: #343a40; border: 1px solid #dee2e6; font-weight: 600; }
.badge-status.s-completed { background: #ebfbee; color: var(--ok); border-color: #b2f2bb; }
.badge-status.s-rejected, .badge-status.s-failed, .badge-status.s-cancelled { background: #fff5f5; color: var(--danger); border-color: #ffc9c9; }
.badge-status.s-escalated, .badge-status.s-blocked { background: #fff4e6; color: var(--warn); border-color: #ffd8a8; }
.badge-status.s-awaiting_ceo_approval { background: #e7f5ff; color: #1c7ed6; border-color: #a5d8ff; }

.missions { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.mission { border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; background: #fff; }
.mission.terminal { background: #fbfaf8; }
.mission-head { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.mission-title { font-weight: 700; flex: 1 1 100%; }
.mission-meta { color: var(--muted); font-size: 12px; margin: 4px 0; }
.mission-actions { display: flex; flex-direction: column; gap: 6px; margin-top: 6px; }
.mission-actions .btns { display: flex; gap: 6px; flex-wrap: wrap; }
.mission-actions .sub { border-top: 1px dashed var(--line); padding-top: 6px; }
.empty { color: var(--muted); font-size: 13px; }

.proposal { border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; margin-top: 8px; font-size: 13px; }
.proposal .btns { display: flex; gap: 6px; margin-top: 4px; }

.events { list-style: none; padding: 0; margin: 0; max-height: 260px; overflow: auto; font-size: 12px; }
.events li { padding: 4px 0; border-bottom: 1px solid #f1efe9; display: flex; gap: 6px; }
.events .seq { color: var(--muted); min-width: 32px; font-variant-numeric: tabular-nums; }

.toast {
  position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); background: #1f2329; color: #fff;
  padding: 10px 16px; border-radius: 8px; max-width: 80vw; box-shadow: 0 6px 20px rgba(0,0,0,.25); z-index: 10;
}
.toast.error { background: var(--danger); }
.hidden { display: none !important; }

@media (max-width: 900px) {
  body { height: auto; min-height: 100%; }
  .layout { flex-direction: column; }
  .office { height: 62vh; min-height: 360px; flex: none; }
  .sidebar { width: 100%; max-width: none; border-left: 0; border-top: 1px solid var(--line); overflow: visible; }
  .topbar { gap: 8px; padding: 8px 10px; }
  .brand h1 { font-size: 15px; }
  .top-stats { order: 3; flex-basis: 100%; gap: 10px; }
  .legend { font-size: 11px; gap: 6px; padding: 4px 8px; right: 12px; max-width: none; }
  .legend .mock-note { display: none; }
  .cam-controls { top: auto; bottom: 26px; }
  .detail { left: 8px; right: 8px; width: auto; top: auto; bottom: 8px; max-height: 60%; }
  .btn-sm { padding: 6px 10px; font-size: 13px; }
  input, textarea, select { font-size: 16px; }   /* iOS 확대 방지 */
}

/* 로그인 화면 */
.login-page { align-items: center; justify-content: center; padding: 16px; }
.login-box {
  width: 100%; max-width: 360px; background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 24px; box-shadow: 0 6px 24px rgba(0,0,0,.08);
}
.brand-login { font-weight: 700; font-size: 18px; margin-bottom: 16px; display: flex; gap: 8px; align-items: center; }
.login-box label { font-size: 13px; color: var(--muted); }
.login-box input { font-size: 16px; padding: 10px; }
.login-box .btn { padding: 10px; font-size: 15px; }
.login-msg { color: var(--danger); min-height: 1.2em; margin: 4px 0 0; font-size: 13px; }
.login-note { color: var(--muted); font-size: 12px; margin: 12px 0 0; }
