/* IRUDA 원격 관리 — the same tokens as the control program (theme.rs).
 *
 * Quiet surfaces, loud state: everything is neutral slate; colour is spent
 * only on connection state and the one primary action of a view. */
:root {
  --bg: #121820;          /* sidebar, page canvas */
  --surface: #161d26;     /* main area */
  --raised: #1c2430;      /* panels, tables, inputs */
  --hover: #222c3a;
  --line: #2a3445;
  --line-soft: #222b38;
  --text: #e8edf4;
  --text-2: #a3aebf;
  --text-3: #6f7b8e;
  --accent: #4c8dff;
  --accent-hover: #6a9fff;
  --accent-soft: rgba(76, 141, 255, .14);
  --online: #2fbf71;
  --offline: #5d6879;
  --warn: #e2a63b;
  --danger: #e5534b;
  --danger-soft: rgba(229, 83, 75, .12);
  --r-sm: 6px;
  --r: 10px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--surface);
  color: var(--text);
  font: 14px/1.55 "Pretendard", "Malgun Gothic", "Apple SD Gothic Neo", "Noto Sans KR", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, input, select { font: inherit; color: inherit; }
a { color: var(--accent-hover); text-underline-offset: 2px; }
h1, h2 { letter-spacing: -0.015em; }
.boot { padding: 48px; text-align: center; color: var(--text-3); }
.muted { color: var(--text-2); }
.faint { color: var(--text-3); }
.small { font-size: 12.5px; }
.num { font-variant-numeric: tabular-nums; }
.nowrap { white-space: nowrap; }
.grow { flex: 1; }
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.stack { display: flex; flex-direction: column; gap: 6px; }
.hidden { display: none !important; }

/* ---- Controls ------------------------------------------------------------ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 34px; padding: 0 14px; border-radius: var(--r-sm); cursor: pointer;
  border: 1px solid var(--line); background: var(--raised); color: var(--text);
  font-size: 13.5px; font-weight: 500; white-space: nowrap;
}
.btn:hover { background: var(--hover); }
.btn:disabled { opacity: .4; cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.danger:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn.ghost:hover { color: var(--text); background: var(--hover); }
.btn.ghost.bad { color: #f0837d; }
.btn.sm { height: 28px; padding: 0 10px; font-size: 12.5px; }
.btn.icon { width: 30px; height: 30px; padding: 0; color: var(--text-2); }
.btn:focus-visible, .field:focus-visible, select:focus-visible, .seg button:focus-visible, .nav:focus-visible, .menu button:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}

.field, select.field {
  height: 34px; padding: 0 11px; border-radius: var(--r-sm);
  border: 1px solid var(--line); background: var(--bg); color: var(--text); min-width: 0;
}
.field:hover { border-color: #36425a; }
.field::placeholder { color: var(--text-3); }
.search-box { position: relative; display: inline-flex; align-items: center; }
.search-box svg { position: absolute; left: 10px; color: var(--text-3); pointer-events: none; }
.search-box .field { padding-left: 32px; width: 260px; }
label.lbl { display: block; font-size: 12.5px; color: var(--text-2); margin: 14px 0 6px; }
.check { display: flex; align-items: flex-start; gap: 8px; cursor: pointer; padding: 5px 0; }
.check input { margin-top: 4px; accent-color: var(--accent); }
.check .desc { display: block; font-size: 12.5px; color: var(--text-3); }
input[type="checkbox"] { accent-color: var(--accent); width: 15px; height: 15px; }

/* Segmented filter (status counts double as the legend of the health bar). */
.seg { display: inline-flex; gap: 2px; background: var(--bg); border: 1px solid var(--line-soft); border-radius: 8px; padding: 3px; }
.seg button {
  display: inline-flex; align-items: center; gap: 7px;
  border: 0; background: transparent; color: var(--text-2); padding: 5px 11px; border-radius: 6px;
  cursor: pointer; font-size: 13px;
}
.seg button:hover { color: var(--text); }
.seg button.on { background: var(--raised); color: var(--text); box-shadow: 0 0 0 1px var(--line); }
.seg .n { font-variant-numeric: tabular-nums; color: var(--text-3); }
.seg button.on .n { color: var(--text-2); }

/* ---- Login --------------------------------------------------------------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; background: var(--bg); }
.login { width: 100%; max-width: 360px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 17px; letter-spacing: -0.01em; }
.brand .logo { width: 28px; height: 28px; border-radius: 8px; background: var(--accent); color: #fff; display: grid; place-items: center; flex: none; }
.brand .light { font-weight: 400; color: var(--text-2); }
.login .brand { font-size: 20px; }
.login .brand .logo { width: 34px; height: 34px; }
.login .sub { color: var(--text-2); margin: 10px 0 26px; font-size: 14px; }
.login .field { width: 100%; height: 40px; background: var(--raised); }
.login .btn.primary { width: 100%; margin-top: 22px; height: 42px; font-size: 14.5px; }
.login-foot { margin: 18px 0 0; text-align: center; }

/* ---- Public download page (/downloads) ----------------------------------- */
.dl { width: 100%; max-width: 560px; }
.dl h1 { font-size: 22px; margin: 26px 0 0; }
.dl .sub { color: var(--text-2); margin: 4px 0 20px; }
.dl-item { display: flex; align-items: center; gap: 16px; padding: 18px 20px; margin-bottom: 12px;
  background: var(--raised); border: 1px solid var(--line-soft); border-radius: var(--r); }
.dl-item h2 { font-size: 15.5px; margin: 0; }
.dl-item p { margin: 3px 0 0; word-break: keep-all; }
.dl-item .btn { flex: none; text-decoration: none; }
@media (max-width: 480px) { .dl-item { flex-direction: column; align-items: stretch; } }
.alert { margin-top: 14px; padding: 10px 12px; border-radius: 8px; font-size: 13px; }
.alert.bad { background: var(--danger-soft); border: 1px solid rgba(229, 83, 75, .4); color: #f4aaa5; }
.alert.warn { background: rgba(226, 166, 59, .1); border: 1px solid rgba(226, 166, 59, .35); color: #efc77a; }
.alert.info { background: var(--accent-soft); border: 1px solid rgba(76, 141, 255, .35); color: #c4d8ff; }

/* ---- Shell --------------------------------------------------------------- */
.shell { display: grid; grid-template-columns: 232px 1fr; min-height: 100%; }
.side {
  background: var(--bg); border-right: 1px solid var(--line-soft);
  padding: 18px 12px 12px; display: flex; flex-direction: column; gap: 2px;
  position: sticky; top: 0; height: 100vh;
}
.side .brand { padding: 2px 8px 22px; }
.nav {
  display: flex; align-items: center; gap: 11px; width: 100%; height: 38px;
  padding: 0 10px; border: 0; border-radius: 8px; background: transparent;
  color: var(--text-2); cursor: pointer; text-align: left; font-size: 14px;
}
.nav svg { color: var(--text-3); flex: none; }
.nav:hover { background: var(--raised); color: var(--text); }
.nav.on { background: var(--accent-soft); color: var(--text); font-weight: 600; }
.nav.on svg { color: var(--accent-hover); }
.nav .badge { margin-left: auto; font-size: 12px; font-weight: 400; color: var(--text-3); font-variant-numeric: tabular-nums; }
.nav.on .badge { color: var(--accent-hover); }

/* Account block at the bottom of the sidebar. */
.account { margin-top: auto; border-top: 1px solid var(--line-soft); padding: 14px 4px 2px; display: flex; flex-direction: column; gap: 10px; }
.account .me { display: flex; align-items: center; gap: 10px; min-width: 0; }
.avatar {
  width: 32px; height: 32px; border-radius: 50%; flex: none; display: grid; place-items: center;
  background: var(--raised); border: 1px solid var(--line); font-weight: 600; font-size: 13.5px; color: var(--text);
}
.account .who { min-width: 0; flex: 1; }
.account .who b { display: block; font-size: 13.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.account .who span { display: block; font-size: 12px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.role { display: inline-block; font-size: 12px; line-height: 18px; padding: 0 8px; border-radius: 99px; border: 1px solid var(--line); color: var(--text-2); white-space: nowrap; }
.role.admin { color: #c4d8ff; border-color: rgba(76, 141, 255, .45); background: var(--accent-soft); }
.conn { display: flex; align-items: center; gap: 7px; font-size: 12px; color: var(--text-3); padding: 0 2px; }

.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--offline); flex: none; }
.dot.good { background: var(--online); }
.dot.busy { background: var(--accent); }
.dot.warn { background: var(--warn); }
.dot.bad { background: var(--danger); }
.dot.off { background: var(--offline); }

.main { padding: 28px 32px 48px; min-width: 0; max-width: 1440px; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.page-head h1 { font-size: 22px; font-weight: 700; margin: 0; line-height: 1.3; }
.page-head p { margin: 4px 0 0; color: var(--text-2); font-size: 13.5px; }
.banner { margin: 0 0 20px; display: flex; align-items: center; gap: 8px; }

/* Fleet health: one thin bar, proportional to online / remote / offline. */
.health { display: flex; height: 6px; border-radius: 3px; overflow: hidden; background: var(--line-soft); margin: 0 0 16px; gap: 2px; }
.health i { display: block; height: 100%; min-width: 4px; }
.health i.good { background: var(--online); }
.health i.busy { background: var(--accent); }
.health i.off { background: var(--offline); }

.toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.toolbar .spacer { flex: 1; }
.pager { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-top: 14px; }
.pager .row { display: flex; gap: 4px; flex-wrap: wrap; }
.bulk {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 9px 12px; margin-bottom: 12px; border-radius: 8px;
  background: var(--accent-soft); border: 1px solid rgba(76, 141, 255, .3); font-size: 13.5px;
}

/* ---- Tables -------------------------------------------------------------- */
.table-wrap { background: var(--raised); border: 1px solid var(--line-soft); border-radius: var(--r); overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th {
  text-align: left; font-weight: 500; font-size: 12.5px; color: var(--text-3);
  padding: 11px 14px; border-bottom: 1px solid var(--line-soft); white-space: nowrap; background: rgba(0, 0, 0, .08);
}
td { padding: 12px 14px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
table.log td { padding: 9px 14px; font-size: 13.5px; }
table.log td.small { font-size: 12.5px; }
tbody tr:hover td { background: rgba(255, 255, 255, .022); }
tr.sel td { background: rgba(76, 141, 255, .07); }
td.check-col, th.check-col { width: 40px; padding-right: 0; }
td.actions { text-align: right; white-space: nowrap; width: 1%; }
td.actions > * + * { margin-left: 4px; }
.name { font-weight: 600; font-size: 14.5px; }
tr.offline .name { color: var(--text-2); font-weight: 500; }
.sub { font-size: 12.5px; color: var(--text-3); margin-top: 1px; }
.sub .tag { margin-right: 6px; }
.tag {
  display: inline-block; font-size: 12px; line-height: 18px; padding: 0 7px; border-radius: 5px;
  border: 1px solid var(--line); color: var(--text-2); white-space: nowrap;
}
.chip { display: inline-block; font-size: 12px; padding: 1px 8px; border-radius: 99px; background: var(--hover); color: #c9d3e2; margin: 1px 4px 1px 0; white-space: nowrap; }
.chip.accent { background: var(--accent-soft); color: #c4d8ff; }
.chip.good { background: rgba(47, 191, 113, .13); color: #8fe0b4; }
.chip.warn { background: rgba(226, 166, 59, .13); color: #efc77a; }
.chip.bad { background: var(--danger-soft); color: #f4aaa5; }
.status { display: flex; align-items: center; gap: 9px; white-space: nowrap; }
.status .label { font-weight: 500; }
.status.good .label { color: #8fe0b4; }
.status.busy .label { color: #a9c7ff; }
.status.off .label { color: var(--text-2); }
.status .who { color: var(--text-2); }
tr.group-row td { background: rgba(0, 0, 0, .1); padding-top: 9px; padding-bottom: 9px; font-size: 13px; }
.conn-line { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: 13.5px; padding: 1px 0; }
.conn-line .chip { margin: 0; }
.meter { width: 92px; font-variant-numeric: tabular-nums; }
.meter .small { color: var(--text-2); }
.meter .bar { height: 4px; background: var(--line-soft); border-radius: 2px; margin-top: 5px; overflow: hidden; }
.meter .bar i { display: block; height: 100%; background: #7c8ba3; border-radius: 2px; }
.meter .bar i.warn { background: var(--warn); }
.meter .bar i.bad { background: var(--danger); }
.empty { padding: 56px 16px; text-align: center; color: var(--text-2); }
.empty b { display: block; color: var(--text); margin-bottom: 6px; font-size: 15px; }

/* ---- Row menu ------------------------------------------------------------ */
.menu {
  position: fixed; z-index: 40; min-width: 168px; padding: 5px;
  background: #222b38; border: 1px solid var(--line); border-radius: 9px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, .45);
}
.menu button {
  display: flex; width: 100%; align-items: center; gap: 8px; text-align: left;
  border: 0; background: transparent; padding: 8px 10px; border-radius: 6px; cursor: pointer; font-size: 13.5px;
}
.menu button:hover { background: var(--hover); }
.menu button.bad { color: #f0837d; }
.menu hr { border: 0; border-top: 1px solid var(--line); margin: 4px 2px; }

/* ---- Cards (categories, me) ---------------------------------------------- */
.card { background: var(--raised); border: 1px solid var(--line-soft); border-radius: var(--r); padding: 20px 22px; }
.card > b:first-child { font-size: 15px; }
.card .field { width: 100%; }
.card .btn.primary { margin-top: 6px; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; align-items: start; }
.kv { display: grid; grid-template-columns: 96px 1fr; gap: 8px 14px; font-size: 14px; }
.kv dt { color: var(--text-3); }
.kv dd { margin: 0; }

/* ---- Modal --------------------------------------------------------------- */
.overlay {
  position: fixed; inset: 0; background: rgba(5, 8, 12, .62); z-index: 50;
  display: grid; place-items: center; padding: 16px; overflow-y: auto;
}
.modal {
  width: 100%; max-width: 440px; background: var(--raised); border: 1px solid var(--line);
  border-radius: 14px; padding: 24px 24px 20px; box-shadow: 0 24px 60px rgba(0, 0, 0, .5);
}
.modal.wide { max-width: 640px; }
.modal h2 { margin: 0 0 6px; font-size: 18px; }
.modal .desc { color: var(--text-2); font-size: 13.5px; margin: 0 0 6px; white-space: pre-line; }
.modal .buttons { display: flex; justify-content: flex-end; gap: 8px; margin-top: 22px; }
.modal .field { width: 100%; }
.section-title { font-size: 12.5px; color: var(--text-2); font-weight: 600; margin: 20px 0 6px; padding-top: 14px; border-top: 1px solid var(--line-soft); }
.picklist { max-height: 220px; overflow-y: auto; border: 1px solid var(--line-soft); border-radius: 8px; padding: 4px 10px; background: var(--bg); }
.picklist .group { font-size: 12px; color: var(--text-3); margin: 8px 0 2px; }
.picklist .check { padding: 3px 0; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* ---- Toast --------------------------------------------------------------- */
#toast-root { position: fixed; right: 20px; bottom: 20px; z-index: 60; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: #222b38; border: 1px solid var(--line); border-left: 3px solid var(--online);
  border-radius: 8px; padding: 10px 14px; font-size: 13.5px; max-width: 380px; box-shadow: 0 10px 28px rgba(0, 0, 0, .4);
}
.toast.bad { border-left-color: var(--danger); }

@media (prefers-reduced-motion: no-preference) {
  .menu { animation: pop .12s ease-out; }
  @keyframes pop { from { opacity: 0; transform: translateY(-3px); } }
}

/* ---- Small screens ------------------------------------------------------- */
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; padding: 10px 12px; border-right: 0; border-bottom: 1px solid var(--line-soft); gap: 4px; }
  .side .brand { padding: 0 6px; width: 100%; margin-bottom: 8px; }
  .nav { width: auto; height: 34px; }
  .nav .badge { margin-left: 4px; }
  .account { width: 100%; margin-top: 8px; padding-top: 10px; flex-direction: row; align-items: center; justify-content: space-between; }
  .main { padding: 20px 16px 36px; }
  .search-box, .search-box .field { width: 100%; }
  .toolbar .spacer { display: none; }
  .hide-sm { display: none; }
  .two-col { grid-template-columns: 1fr; }
}

/* ---- Devices: store cards, sections of their own ------------------------- */
.quick { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 0 0 18px; font-size: 13px; }
.quick .lbl { color: var(--text-3); font-size: 12.5px; }
.pill { display: inline-flex; align-items: center; gap: 7px; height: 28px; padding: 0 11px; border-radius: 99px; background: var(--raised); border: 1px solid var(--line-soft); cursor: pointer; font-size: 13px; }
.pill:hover { border-color: var(--line); background: var(--hover); }
.pill .dot { width: 7px; height: 7px; }
.dsec { margin-bottom: 24px; }
.dsec h2 { display: inline-flex; align-items: baseline; gap: 8px; font-size: 15px; margin: 0 0 10px; cursor: pointer; user-select: none; }
.dsec h2 .n { font-size: 12.5px; color: var(--text-3); font-weight: 400; }
.dsec h2 .caret { color: var(--text-3); font-size: 11px; display: inline-block; width: 10px; transition: transform .15s; }
.dsec.closed h2 .caret { transform: rotate(-90deg); }
.dgrid { display: grid; gap: 12px; align-items: start; grid-template-columns: repeat(auto-fill, minmax(268px, 1fr)); }
.dgrid.small { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 10px; }
.dcard { background: var(--raised); border: 1px solid var(--line-soft); border-radius: var(--r); padding: 4px 0 6px; }
.dcard:hover { border-color: var(--line); }
.dcard.dim { opacity: .62; }
.dcard .head { display: flex; align-items: center; gap: 8px; padding: 9px 12px 7px 12px; }
.dcard .name { font-weight: 700; font-size: 14.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dcard .count { margin-left: auto; display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-3); font-variant-numeric: tabular-nums; }
.star { border: 0; background: none; padding: 0 2px; cursor: pointer; color: var(--line); font-size: 15px; line-height: 1; }
.star:hover { color: var(--text-2); }
.star.on { color: #f0c24b; }
.drow { display: flex; align-items: center; gap: 9px; min-height: 36px; padding: 0 8px 0 14px; }
.drow:hover { background: rgba(255, 255, 255, .025); }
.drow .kind { min-width: 68px; max-width: 132px; flex: none; font-size: 13px; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.drow .state { flex: 1; min-width: 0; display: flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--text-2); white-space: nowrap; overflow: hidden; }
.drow .state .t { overflow: hidden; text-overflow: ellipsis; }
.drow.off .kind, .drow.off .state { color: var(--text-3); }
.drow .btn.icon, .dmini .btn.icon { width: 28px; height: 28px; }
.dmini { display: flex; align-items: center; gap: 10px; background: var(--raised); border: 1px solid var(--line-soft); border-radius: var(--r); min-height: 52px; padding: 0 8px 0 14px; }
.dmini:hover { border-color: var(--line); }
.dmini.off { opacity: .62; }
.dmini .txt { flex: 1; min-width: 0; line-height: 1.3; }
.dmini .name { font-weight: 700; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dmini .sub { font-size: 12px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin: 0; }
.nomenu { width: 28px; flex: none; }
.pick { width: 16px; height: 16px; accent-color: var(--accent); margin: 0; flex: none; }
.selbar { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 15; display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  background: var(--raised); border: 1px solid var(--line); border-radius: 12px; padding: 9px 10px 9px 16px; box-shadow: 0 14px 34px rgba(0, 0, 0, .5); }
.selbar .field { height: 30px; width: auto; }
@media (max-width: 640px) {
  .dgrid, .dgrid.small { grid-template-columns: 1fr; }
  .selbar { left: 16px; right: 16px; transform: none; }
}
