:root {
  --bg: #f5f6f7;
  --surface: #ffffff;
  --ink: #212425;
  --muted: #929596;
  --line: #e9ebec;
  --line-strong: #d8dadc;
  --brand-hot: #0f766e;
  --brand-hot-hover: #0d9488;
  --brand: #1d84f4;
  --brand-soft: #eef6ff;
  --ok: #1f7a4d;
  --ok-bg: #e7f6ee;
  --warn: #9a6b12;
  --warn-bg: #fff4d6;
  --danger: #b42318;
  --danger-bg: #fdecea;
  --closed-bg: #eceff3;
  --sidebar-w: 220px;
  --appbar-h: 56px;
  --font: "Pretendard", "Malgun Gothic", "Apple SD Gothic Neo", "Noto Sans KR", sans-serif;
  --mono: "Cascadia Mono", "Consolas", monospace;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  font-size: 13px;
  line-height: 1.45;
}
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

/* legacy app shell kept for compatibility; global pages use rms-ui shell */
.app-bar { background: var(--brand-hot); }
.side-nav a:hover { background: #fafbfc; color: var(--brand); }
.side-nav a.active {
  background: var(--brand-soft);
  color: var(--brand);
  border-left-color: var(--brand);
}

/* —— full-page app shell —— */
.app {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}
.app-bar {
  height: var(--appbar-h);
  min-height: var(--appbar-h);
  background: var(--brand-hot);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  position: sticky;
  top: 0;
  z-index: 40;
}
.app-brand {
  color: #fff;
  font-weight: 800;
  font-size: 18px;
  letter-spacing: -0.02em;
  text-decoration: none;
}
.app-brand em { font-style: normal; font-weight: 500; opacity: 0.9; }
.app-bar-meta { font-size: 12px; opacity: 0.85; }

.app-body {
  flex: 1;
  display: flex;
  min-height: 0;
  min-height: calc(100vh - var(--appbar-h));
  min-height: calc(100dvh - var(--appbar-h));
}
.side-nav {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  background: #fff;
  border-right: 1px solid var(--line);
  padding: 12px 0 24px;
  position: sticky;
  top: var(--appbar-h);
  height: calc(100vh - var(--appbar-h));
  height: calc(100dvh - var(--appbar-h));
  overflow-y: auto;
}
.side-section {
  padding: 14px 16px 6px;
  font-size: 11px;
  font-weight: 700;
  color: #aaa;
  letter-spacing: 0.04em;
}
.side-nav a {
  display: block;
  padding: 10px 16px;
  color: #444;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  border-left: 3px solid transparent;
}
.side-nav a:hover { background: #fafafa; color: var(--brand-hot); }
.side-nav a.active {
  background: var(--brand-soft);
  color: var(--brand-hot);
  border-left-color: var(--brand-hot);
}

.main {
  flex: 1;
  min-width: 0;
  padding: 20px 24px 40px;
  background: var(--bg);
}

/* —— page title / search (ddnayo list) —— */
.page-title-row { margin-bottom: 16px; }
.page-title {
  margin: 0;
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.search-panel {
  background: #fff;
  border: 1px solid var(--line);
  padding: 16px 18px;
  margin-bottom: 14px;
}
.search-radios {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 12px;
}
.search-radios label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: #444;
  font-weight: 600;
  cursor: pointer;
}
.search-radios input { margin: 0; accent-color: var(--brand-hot); }
.search-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
.search-row input[type="text"] {
  flex: 1;
  min-width: 220px;
  max-width: 480px;
  height: 36px;
  padding: 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: 2px;
  font: inherit;
  background: #fff;
}
.search-row input[type="text"]:focus {
  outline: none;
  border-color: var(--brand-hot);
}
.search-opts {
  margin-top: 10px;
  color: var(--muted);
  font-size: 12px;
}
.search-opts label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
}

.btn-pink {
  height: 36px;
  padding: 0 18px;
  border: none;
  border-radius: 2px;
  background: var(--brand-hot);
  color: #fff;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}
.btn-pink:hover { background: var(--brand-hot-hover); }
.btn-ghost {
  height: 36px;
  padding: 0 12px;
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--line-strong);
  border-radius: 2px;
  background: #fff;
  color: #555;
  font-weight: 600;
  text-decoration: none;
}
.btn-ghost:hover { border-color: var(--brand-hot); color: var(--brand-hot); text-decoration: none; }

.list-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 8px;
  font-size: 13px;
  color: #444;
}
.list-head strong { color: var(--brand-hot); }
.list-head-hint { color: var(--muted); font-size: 12px; }

.table-wrap {
  background: #fff;
  border: 1px solid var(--line);
  overflow: auto;
}
.panel .table-wrap {
  border: none;
  background: transparent;
  border-radius: 0;
}
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.data-table th,
.data-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
  white-space: nowrap;
}
.data-table th {
  background: #fafafa;
  color: #666;
  font-size: 12px;
  font-weight: 700;
  position: sticky;
  top: 0;
  z-index: 2;
}
.data-table tbody tr:hover td { background: #fff8fb; }
.data-table .col-id { width: 64px; color: #888; }
.data-table .col-num { text-align: right; font-variant-numeric: tabular-nums; }
.data-table .col-actions { text-align: center; }
.name-link {
  color: #222;
  font-weight: 700;
  text-decoration: none;
}
.name-link:hover { color: var(--brand-hot); text-decoration: underline; }
.cell-sub {
  margin-top: 2px;
  font-size: 11px;
  color: #999;
  max-width: 280px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.mono { font-family: var(--mono); font-size: 12px; }
.tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 2px;
  font-size: 11px;
  font-weight: 700;
}
.tag.open { background: var(--ok-bg); color: var(--ok); }
.tag.closed { background: var(--closed-bg); color: #777; }
.link-btn {
  display: inline-block;
  margin: 0 2px;
  padding: 3px 8px;
  border: 1px solid var(--line-strong);
  border-radius: 2px;
  color: #555;
  font-size: 12px;
  font-weight: 600;
  text-decoration: none;
}
.link-btn:hover {
  border-color: var(--brand-hot);
  color: var(--brand-hot);
  text-decoration: none;
}
.empty-cell {
  text-align: center !important;
  color: var(--muted);
  padding: 40px 12px !important;
}

.pager {
  display: flex;
  gap: 14px;
  align-items: center;
  justify-content: center;
  margin-top: 16px;
  color: var(--muted);
  font-weight: 600;
}
.pager a {
  color: #444;
  padding: 6px 12px;
  border: 1px solid var(--line-strong);
  background: #fff;
  border-radius: 2px;
  text-decoration: none;
}
.pager a:hover { border-color: var(--brand-hot); color: var(--brand-hot); }

/* —— shared detail pages —— */
.page-head { margin: 0 0 16px; }
.page-head h1 { margin: 0 0 6px; font-size: 20px; font-weight: 800; }
.page-head .sub { margin: 0; color: var(--muted); }

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: end;
  margin-bottom: 14px;
  padding: 14px;
  background: #fff;
  border: 1px solid var(--line);
}
label.field, .toolbar > label {
  display: flex;
  flex-direction: column;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}
input, select, button, .btn {
  font: inherit;
  border-radius: 2px;
  border: 1px solid var(--line-strong);
  background: #fff;
  color: var(--ink);
  padding: 8px 12px;
}
input:focus, select:focus { outline: none; border-color: var(--brand-hot); }
button, .btn {
  background: var(--brand-hot);
  color: #fff;
  border: none;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
button.secondary, .btn.secondary {
  background: #fff;
  color: #444;
  border: 1px solid var(--line-strong);
}

.panel {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
}
.panel-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  background: #fafafa;
}
.panel-head h2 { margin: 0; font-size: 14px; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 9px 12px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
th {
  color: #666;
  font-size: 12px;
  font-weight: 700;
  background: #fafafa;
  white-space: nowrap;
}
tr:hover td { background: #fff8fb; }
.dense th, .dense td { padding: 7px 10px; font-size: 12px; vertical-align: middle; }
.num { font-variant-numeric: tabular-nums; text-align: right; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 2px;
  font-size: 11px;
  font-weight: 700;
  background: #f0f0f0;
  color: #666;
  white-space: nowrap;
}
.badge.open { background: var(--ok-bg); color: var(--ok); }
.badge.closed { background: var(--closed-bg); color: #777; }
.badge.forced { background: var(--warn-bg); color: var(--warn); }
.badge.fee { background: #fff7ed; color: #c2410c; }
.badge.partial-cancel { background: #fff1f2; color: #be123c; }
.badge.payment-pending { background: #fef3c7; color: #b45309; }
.badge.memo {
  background: #ecfeff;
  color: #0e7490;
  width: 22px;
  min-width: 22px;
  height: 22px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0;
  line-height: 0;
  vertical-align: middle;
}
.badge.memo::before {
  content: "";
  width: 13px;
  height: 13px;
  background: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath fill='black' d='M3.5 1.5h6.2L13.5 5.3v9.2h-10V1.5zm6.2.3v3.4h3.4M5.2 8.1h5.6v1H5.2zm0 2.3h5.6v1H5.2z'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath fill='black' d='M3.5 1.5h6.2L13.5 5.3v9.2h-10V1.5zm6.2.3v3.4h3.4M5.2 8.1h5.6v1H5.2zm0 2.3h5.6v1H5.2z'/%3E%3C/svg%3E") center / contain no-repeat;
}
.badge.markup { background: #f5f3ff; color: #6d28d9; }
.badge.danger { background: var(--danger-bg); color: var(--danger); }
.badge.brand { background: var(--brand-soft); color: var(--brand); }
.badge.channel {
  background: var(--brand-soft);
  color: var(--brand);
  text-transform: none;
  letter-spacing: 0;
}
.badge.channel.ch-naver { background: #e8f8ef; color: #03C75A; }
.badge.channel.ch-yeogi { background: #fff8d6; color: #a16207; }
.badge.channel.ch-onda { background: #e8f0fe; color: #2563EB; }
.badge.channel.ch-yanolja { background: #f1f5f9; color: #6B7280; }
.badge.channel.ch-ddnayo { background: #fff1e6; color: #ea580c; }
.badge.channel.ch-bank { background: #e6fffa; color: #0d9488; }
.badge.channel.ch-other { background: #f1f5f9; color: #64748b; }
.channel-badges { display: inline-flex; flex-wrap: wrap; gap: 4px; align-items: center; max-width: 220px; }

.tabs {
  display: flex;
  gap: 0;
  flex-wrap: nowrap;
  margin: 0 0 16px;
  border-bottom: 1px solid var(--line);
  background: #fff;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
}
.tabs a {
  padding: 12px 16px;
  color: #666;
  font-weight: 650;
  font-size: 13px;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  white-space: nowrap;
  flex: 0 0 auto;
}
.tabs a.active {
  color: var(--brand-hot);
  border-bottom-color: var(--brand-hot);
  text-decoration: none;
}

.stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 8px;
  margin-bottom: 16px;
}
.stat-chip {
  background: #fff;
  border: 1px solid var(--line);
  padding: 10px 12px;
}
.stat-chip .k { color: var(--muted); font-size: 11px; font-weight: 650; }
.stat-chip .v { font-size: 16px; font-weight: 800; margin-top: 2px; }

.mapping-list { display: flex; flex-direction: column; gap: 12px; }
.listing-card {
  border: 1px solid var(--line);
  overflow: hidden;
  background: #fff;
}
.listing-card > header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 12px 14px;
  background: var(--brand-soft);
  border-bottom: 1px solid var(--line);
}
.listing-card .body { padding: 0; }
.map-row {
  display: grid;
  grid-template-columns: 1.2fr 24px 1fr 24px 1fr;
  gap: 8px;
  align-items: center;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
}
.map-row:last-child { border-bottom: none; }
.map-node {
  background: #f7f7f7;
  border-radius: 2px;
  padding: 8px 10px;
  min-height: 44px;
}
.map-node.ok { background: var(--ok-bg); }
.map-node.bad { background: var(--danger-bg); }
.map-node .t { font-size: 11px; color: var(--muted); font-weight: 650; }
.map-node .v { font-size: 13px; font-weight: 700; margin-top: 2px; word-break: break-all; }
.map-arrow { text-align: center; color: var(--muted); font-weight: 700; }

.alert {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 12px 14px;
  margin-bottom: 14px;
  border: 1px solid var(--line);
  background: #fff;
}
.alert.warn { background: var(--warn-bg); border-color: #f0d48a; }
.alert.ok { background: var(--ok-bg); border-color: #b7e3c8; }
.alert .title { font-weight: 800; }
.alert .desc { color: var(--muted); font-size: 12px; margin-top: 2px; }

.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  padding: 6px 12px;
  border: 1px solid var(--line-strong);
  background: #fff;
  color: #666;
  font-weight: 700;
  font-size: 12px;
  border-radius: 2px;
}
.chip.active { background: var(--brand-hot); color: #fff; border-color: var(--brand-hot); text-decoration: none; }

.empty { color: var(--muted); padding: 28px; text-align: center; }

/* calendar */
.cal-toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.cal-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  background: #fff;
}
.cal {
  border-collapse: separate;
  border-spacing: 0;
  min-width: max-content;
  font-size: 12px;
}
.cal th, .cal td {
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  padding: 0;
  text-align: center;
  vertical-align: middle;
}
.cal th:last-child, .cal td:last-child { border-right: none; }
.cal thead th {
  position: sticky;
  top: 0;
  z-index: 3;
  background: #fafafa;
  min-width: 54px;
  padding: 8px 4px;
}
.cal .room-col {
  position: sticky;
  left: 0;
  z-index: 4;
  background: #fafafa;
  min-width: 140px;
  max-width: 180px;
  text-align: left;
  padding: 8px 10px;
  font-weight: 700;
}
.cal thead .room-col { z-index: 5; }
.cal .wd { display: block; color: var(--muted); font-size: 10px; text-transform: uppercase; }
.cal .dn { font-weight: 800; font-size: 13px; }
.cal .cell {
  width: 54px;
  height: 52px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 2px;
}
.cal .cell.open { background: #eaf8f0; color: var(--ok); }
.cal .cell.closed { background: #f2f4f7; color: #7a8694; }
.cal .cell.forced { background: #fff2d9; color: var(--warn); }
.cal .cell.empty { background: #fff; color: #c0c8d0; }
.cal .cell .p { font-weight: 800; font-variant-numeric: tabular-nums; }
.cal .cell .s { font-size: 10px; font-weight: 700; }
.cal tr:hover .room-col { background: #fff0f5; }
.legend { display: flex; gap: 12px; flex-wrap: wrap; color: var(--muted); font-size: 12px; margin-top: 10px; }
.legend i {
  display: inline-block;
  width: 12px;
  height: 12px;
  margin-right: 4px;
  vertical-align: -1px;
  border: 1px solid var(--line);
}
.legend .l-open { background: #eaf8f0; }
.legend .l-closed { background: #f2f4f7; }
.legend .l-forced { background: #fff2d9; }
.legend .l-empty { background: #fff; }

@media (max-width: 900px) {
  .app-body { flex-direction: column; }
  .side-nav {
    width: 100%;
    min-width: 0;
    height: auto;
    position: static;
    display: flex;
    flex-wrap: nowrap;
    gap: 4px;
    border-right: none;
    border-bottom: 1px solid var(--line);
    padding: 8px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .side-section { display: none; }
  .side-nav a {
    border-left: none;
    border-radius: 2px;
    padding: 8px 12px;
    white-space: nowrap;
    flex: 0 0 auto;
  }
  .map-row { grid-template-columns: 1fr; }
  .map-arrow { display: none; }
  .main { padding: 14px 12px 32px; }
  .table-wrap { -webkit-overflow-scrolling: touch; }
}

@media (max-width: 720px) {
  .topbar { padding: 0 12px; }
  .stats-row { grid-template-columns: repeat(2, 1fr); }
  .search-panel .search-row input,
  .search-panel .search-row button { width: 100%; }
}

.map-id-form { display: flex; flex-direction: column; gap: 6px; margin-bottom: 4px; min-width: 180px; }
.map-field { display: flex; flex-direction: column; gap: 2px; font-size: 11px; color: var(--muted); font-weight: 600; }
.map-field input {
  width: 100%;
  padding: 5px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 12px;
  font-family: ui-monospace, Consolas, monospace;
  box-sizing: border-box;
}
.map-assign-form { display: flex; flex-direction: column; gap: 6px; min-width: 160px; }
.map-su-select {
  width: 100%;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 13px;
  box-sizing: border-box;
}
.rms-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  border-radius: 6px;
  background: #1d84f4;
  color: #fff;
  font-weight: 700;
  font-size: 12px;
  text-decoration: none;
  border: none;
  cursor: pointer;
}
.rms-btn.sm { padding: 5px 10px; }
.rms-btn.ghost {
  background: #fff;
  color: #333;
  border: 1px solid var(--line);
}
.muted { color: var(--muted); }
tr.row-unmatched td { background: #fff8f8; }
