/* OnSystem 공용 UI — 허브와 모든 모듈 화면이 함께 사용합니다.
   모듈에서: <link rel="stylesheet" href="/hub/ui.css"> */
:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #f0f2f5;
  --border: #e3e6eb;
  --text: #1c2129;
  --muted: #6b7380;
  --primary: #2f6fed;
  --primary-ink: #ffffff;
  --primary-soft: #e8f0fe;
  --danger: #d93a3a;
  --danger-soft: #fdecec;
  --ok: #1f8f55;
  --ok-soft: #e6f6ed;
  --warn: #b7791f;
  --warn-soft: #fdf4e3;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  --font: "Pretendard", "Apple SD Gothic Neo", "Malgun Gothic", system-ui, -apple-system, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #111418;
    --surface: #1a1e24;
    --surface-2: #232830;
    --border: #2e343d;
    --text: #e7eaee;
    --muted: #9aa3ae;
    --primary: #5b8ef5;
    --primary-soft: #1f2b42;
    --danger: #f06363;
    --danger-soft: #3a1e20;
    --ok: #3cbf7c;
    --ok-soft: #173326;
    --warn: #e0a84a;
    --warn-soft: #3a2d17;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #111418; --surface: #1a1e24; --surface-2: #232830; --border: #2e343d; --text: #e7eaee; --muted: #9aa3ae;
  --primary: #5b8ef5; --primary-soft: #1f2b42; --danger: #f06363; --danger-soft: #3a1e20; --ok: #3cbf7c; --ok-soft: #173326;
  --warn: #e0a84a; --warn-soft: #3a2d17; --shadow: 0 1px 2px rgba(0, 0, 0, .3); color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--text); font: 14px/1.55 var(--font); -webkit-font-smoothing: antialiased; }
h1, h2, h3 { margin: 0 0 .5em; line-height: 1.3; }
h1 { font-size: 22px; } h2 { font-size: 17px; } h3 { font-size: 15px; }
a { color: var(--primary); }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.err { color: var(--danger); margin: 8px 0 0; }

/* 레이아웃 */
.wrap { max-width: 1100px; margin: 0 auto; padding: 24px 16px 48px; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.spacer { flex: 1; }
.stack > * + * { margin-top: 12px; }
.grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }

/* 카드 */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; }
.card.flush { padding: 0; overflow: hidden; }

/* 버튼 */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 36px; padding: 0 14px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); font: inherit; font-weight: 600; cursor: pointer;
  text-decoration: none; white-space: nowrap;
}
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.btn.primary:hover { filter: brightness(1.06); }
.btn.danger { color: var(--danger); }
.btn.danger:hover { background: var(--danger-soft); }
.btn.sm { height: 30px; padding: 0 10px; font-size: 13px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* 폼 */
.field { display: block; margin: 0 0 12px; }
.field > span { display: block; font-size: 13px; font-weight: 600; margin-bottom: 5px; }
input, select, textarea {
  width: 100%; font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; min-height: 36px;
}
textarea { min-height: 90px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--primary-soft); border-color: var(--primary); }
input[type="checkbox"] { width: auto; min-height: 0; }
.check { display: inline-flex; gap: 6px; align-items: center; cursor: pointer; }

/* 표 */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { font-size: 12.5px; color: var(--muted); font-weight: 600; background: var(--surface-2); white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
td.actions { text-align: right; white-space: nowrap; }

/* 배지 */
.badge { display: inline-block; padding: 2px 8px; border-radius: 99px; font-size: 12px; font-weight: 600; background: var(--surface-2); color: var(--muted); }
.badge.primary { background: var(--primary-soft); color: var(--primary); }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.danger { background: var(--danger-soft); color: var(--danger); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }

/* 빈 상태 */
.empty { text-align: center; padding: 40px 16px; color: var(--muted); }

/* 토스트 */
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 1000;
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 8px; box-shadow: var(--shadow);
  font-weight: 600; max-width: calc(100% - 32px); animation: toast-in .18s ease-out;
}
.toast.error { background: var(--danger); color: #fff; }
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 8px); } }

/* 대화상자 */
dialog.dlg { border: 1px solid var(--border); border-radius: 14px; padding: 22px; width: min(440px, calc(100% - 32px)); background: var(--surface); color: var(--text); box-shadow: 0 20px 50px rgba(0,0,0,.25); }
dialog.dlg::backdrop { background: rgba(10, 14, 20, .45); }
.dlg-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
