/* Ptero remote-monitoring platform shell. The HMI's day palette and radii,
   one font family (Pretendard Variable, served beside this file), and the
   night palette only for the fleet view, which is an instrument. */

@font-face {
  font-family: "Pretendard Variable";
  src: url("/static/fonts/pretendard-var.woff2") format("woff2-variations");
  font-weight: 45 920;
  font-style: normal;
  font-display: swap;
}

:root {
  color-scheme: light;
  --font: "Pretendard Variable", Pretendard, "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans KR", system-ui, sans-serif;
  --background: #eef1f5;
  --surface: #ffffff;
  --panel: #f4f6f9;
  --elevated: #e6eaf0;
  --border: #d7dde5;
  --line: #c9d1db;
  --foreground: #16202b;
  --muted: #5d6f80;
  --faint: #8091a2;
  --primary: #0066cc;
  --primary-soft: #e3eefb;
  --destructive: #d70015;
  --destructive-soft: #fde5e6;
  --run: #1e8a4a;
  --run-soft: #e3f4ea;
  --warn: #b35c00;
  --warn-soft: #fdf1de;
  --rail: #16202b;
  --rail-active: #263341;
  --night-surface: #0b1017;
  --night-panel: #0e141c;
  --night-elevated: #1c2532;
  --night-line: #33404f;
  --night-foreground: #f2f7fc;
  --night-muted: #8ea3b5;
  --night-primary: #3ba7ff;
  --night-run: #35d97c;
  --night-warn: #ffb020;
  --radius-panel: 16px;
  --radius-control: 12px;
  --text-micro: 11px;
  --text-label: 12.5px;
  --text-body: 13.5px;
  --text-title: 16px;
  --shadow: 0 1px 2px rgb(22 32 43 / 0.06);
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
  background: var(--background);
  color: var(--foreground);
  font-family: var(--font);
  font-size: var(--text-body);
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  font-variant-numeric: tabular-nums;
}

button,
input,
select,
textarea {
  color: inherit;
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: default;
  opacity: 0.55;
}

a {
  color: var(--primary);
  text-decoration: none;
}

a:hover {
  color: #004d99;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
a:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

[hidden] {
  display: none !important;
}

/* ------------------------------------------------------------------ app --- */

.app {
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr);
  min-height: 100%;
}

.rail {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  height: 100vh;
  padding: 16px 0 14px;
  background: var(--rail);
  color: var(--night-muted);
}

.rail-brand {
  margin-bottom: 12px;
  color: #ffffff;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.rail-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  width: 54px;
  padding: 7px 0;
  border-radius: 10px;
  color: var(--night-muted);
  text-align: center;
}

.rail-item span {
  font-size: 10px;
  line-height: 1.2;
}

.rail-item svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.rail-item:hover {
  color: var(--night-foreground);
}

.rail-item.active {
  background: var(--rail-active);
  color: var(--night-foreground);
}

.rail-item.disabled {
  opacity: 0.4;
  pointer-events: none;
}

.rail-bottom {
  margin-top: auto;
}

.content {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 0;
  padding: 18px 22px 24px;
}

.content.sandbox-page {
  height: 100vh;
  padding: 12px 14px 12px;
}

/* --------------------------------------------------------------- shared --- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-panel);
}

.card-body {
  padding: 14px 18px;
}

.eyebrow {
  color: var(--muted);
  font-size: var(--text-micro);
  font-weight: 600;
  letter-spacing: 0.05em;
}

.page-head {
  display: flex;
  align-items: center;
  gap: 14px;
}

.page-head .titles {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.page-head h1 {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.page-head .crumb {
  color: var(--muted);
  font-size: var(--text-label);
  font-weight: 400;
}

.page-head .sub {
  color: var(--muted);
  font-size: var(--text-label);
}

.page-head .actions {
  display: flex;
  gap: 8px;
  margin-left: auto;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 36px;
  padding: 0 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-control);
  background: var(--surface);
  font-size: var(--text-label);
  font-weight: 600;
  white-space: nowrap;
}

.btn:hover:not(:disabled) {
  background: var(--panel);
}

.btn.primary {
  border-color: var(--primary);
  background: var(--primary);
  color: #ffffff;
}

.btn.primary:hover:not(:disabled) {
  background: #0059b3;
}

.btn.danger {
  border-color: #f2b8bd;
  color: var(--destructive);
}

.btn.small {
  height: 30px;
  padding: 0 11px;
  font-weight: 500;
}

.link {
  padding: 0;
  border: 0;
  background: none;
  color: var(--primary);
  font-size: var(--text-label);
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 22px;
  padding: 0 9px;
  border-radius: 999px;
  background: var(--elevated);
  color: var(--muted);
  font-size: var(--text-micro);
  font-weight: 600;
  white-space: nowrap;
}

.chip::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.chip.ok {
  background: var(--run-soft);
  color: var(--run);
}

.chip.warn {
  background: var(--warn-soft);
  color: var(--warn);
}

.chip.bad {
  background: var(--destructive-soft);
  color: var(--destructive);
}

.chip.info {
  background: var(--primary-soft);
  color: var(--primary);
}

.placeholder {
  color: var(--warn);
  font-weight: 500;
}

.muted {
  color: var(--muted);
}

.empty {
  padding: 28px 18px;
  color: var(--muted);
  font-size: var(--text-label);
  text-align: center;
}

.toast-region {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 70;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: min(420px, calc(100vw - 36px));
}

.toast {
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-control);
  background: var(--surface);
  box-shadow: 0 10px 30px rgb(22 32 43 / 0.18);
  font-size: var(--text-label);
}

.toast.error {
  border-color: #f2b8bd;
  color: var(--destructive);
}

/* ---------------------------------------------------------------- login --- */

.login {
  display: grid;
  place-items: center;
  min-height: 70vh;
}

.login-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: min(400px, 100%);
  padding: 30px;
}

.login-card h1 {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
}

.login-card p {
  margin: 0;
  color: var(--muted);
  font-size: var(--text-label);
  line-height: 1.55;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 0;
}

.field > span {
  color: var(--muted);
  font-size: var(--text-micro);
  font-weight: 600;
}

.field > span em {
  margin-left: 6px;
  color: var(--faint);
  font-style: normal;
  font-weight: 400;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  height: 36px;
  padding: 0 11px;
  border: 1px solid var(--border);
  border-radius: var(--radius-control);
  background: var(--surface);
  font-size: var(--text-label);
}

.field textarea {
  height: auto;
  min-height: 72px;
  padding: 9px 11px;
  resize: vertical;
}

.field input:user-invalid {
  border-color: #f2b8bd;
}

.form-error {
  color: var(--destructive);
  font-size: var(--text-label);
}

.form-error:empty {
  display: none;
}

/* ---------------------------------------------------------------- sites --- */

.sites {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
  padding-top: 32px;
}

.sites-head {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  text-align: center;
}

.sites-head .wordmark {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.sites-head .tagline {
  color: var(--muted);
  font-size: var(--text-label);
}

.sites-head h1 {
  margin: 8px 0 0;
  font-size: 20px;
  font-weight: 600;
}

.sites-head p {
  margin: 0;
  color: var(--muted);
}

.site-grid {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 18px;
}

.site-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 360px;
  padding: 18px 20px 20px;
}

.site-card .name {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 18px;
  font-weight: 700;
}

.site-card .facts {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  color: var(--muted);
  font-size: var(--text-label);
}

.site-card .facts b {
  color: var(--foreground);
  font-weight: 600;
}

.site-card .actions {
  display: flex;
  gap: 8px;
  margin-top: 6px;
}

.site-card .actions .btn:first-child {
  flex: 1;
}

.site-add {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 360px;
  min-height: 160px;
  border: 1.5px dashed var(--line);
  border-radius: var(--radius-panel);
  background: transparent;
  color: var(--muted);
}

.site-add b {
  font-weight: 600;
}

/* -------------------------------------------------------------- monitor --- */

.facts-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 0;
  overflow: hidden;
}

.facts-strip > div {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  padding: 12px 18px;
  border-left: 1px solid var(--panel);
}

.facts-strip > div:first-child {
  border-left: 0;
}

.facts-strip span {
  color: var(--muted);
  font-size: var(--text-micro);
  font-weight: 600;
}

.facts-strip b {
  overflow: hidden;
  font-size: 15px;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.facts-strip b small {
  color: var(--muted);
  font-size: var(--text-micro);
  font-weight: 500;
}

.monitor-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr);
  gap: 14px;
}

.monitor-column {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 0;
}

.card-head {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 12px 18px 0;
}

.card-head b {
  font-size: 14px;
  font-weight: 600;
}

.card-head span {
  color: var(--muted);
  font-size: var(--text-label);
}

.card-head .right {
  margin-left: auto;
  font-size: var(--text-micro);
}

.fleet {
  background: var(--night-surface);
  border-color: var(--night-elevated);
  color: var(--night-foreground);
  overflow: hidden;
}

.fleet .card-head b {
  color: var(--night-foreground);
}

.fleet .card-head span {
  color: var(--night-muted);
}

.fleet canvas {
  display: block;
  width: 100%;
  height: 340px;
}

.fleet-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 14px;
  padding: 0 18px 10px;
  color: var(--night-muted);
  font-size: var(--text-micro);
}

.fleet-legend i {
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-right: 5px;
  border-radius: 50%;
}

.robot-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.robot {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px 18px;
}

.robot .head {
  display: flex;
  align-items: center;
  gap: 10px;
}

.robot .head b {
  font-size: var(--text-title);
  font-weight: 700;
}

.robot .head .model {
  color: var(--muted);
  font-size: var(--text-label);
}

.robot .head .seen {
  margin-left: auto;
  color: var(--muted);
  font-size: var(--text-label);
}

.robot .head .seen b {
  color: var(--foreground);
  font-size: var(--text-label);
  font-weight: 600;
}

.robot .stats {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
}

.stat {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.stat span {
  color: var(--muted);
  font-size: var(--text-micro);
  font-weight: 600;
}

.stat b {
  overflow: hidden;
  font-size: 14px;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stat small {
  overflow: hidden;
  color: var(--muted);
  font-size: var(--text-micro);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.battery {
  height: 5px;
  margin-top: 3px;
  border-radius: 999px;
  background: var(--elevated);
  overflow: hidden;
}

.battery i {
  display: block;
  height: 100%;
  background: var(--run);
}

.battery i.low {
  background: var(--warn);
}

.robot .foot {
  display: flex;
  align-items: center;
  gap: 8px;
}

.robot .foot .note {
  margin-left: auto;
  color: var(--faint);
  font-size: var(--text-micro);
}

.chart {
  padding: 8px 18px 14px;
}

.chart svg {
  display: block;
  width: 100%;
  height: auto;
}

.legend {
  display: flex;
  gap: 12px;
  color: var(--muted);
  font-size: var(--text-micro);
}

.legend i {
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-right: 4px;
  border-radius: 2px;
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-label);
}

.table th {
  padding: 8px 18px;
  border-top: 1px solid var(--panel);
  color: var(--muted);
  font-size: var(--text-micro);
  font-weight: 600;
  text-align: left;
}

.table td {
  padding: 8px 18px;
  border-top: 1px solid var(--panel);
}

.table td.num,
.table th.num {
  text-align: right;
}

.table tr.total td {
  font-weight: 600;
  background: var(--panel);
}

.map-card {
  overflow: hidden;
}

.map-stage {
  position: relative;
  height: 260px;
  background: #e6ecea;
}

.map-stage .gmap {
  width: 100%;
  height: 100%;
}

.map-fallback {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 100%;
  padding: 20px;
  color: var(--muted);
  font-size: var(--text-label);
  text-align: center;
}

.map-fallback b {
  color: var(--foreground);
  font-weight: 600;
}

.map-address {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px 12px;
  font-size: var(--text-label);
}

.map-address .right {
  margin-left: auto;
  color: var(--muted);
  font-size: var(--text-micro);
}

/* ------------------------------------------------------------- settings --- */

.settings-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 14px;
  align-items: start;
}

.form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px 18px 18px;
}

.form h2 {
  margin: 0;
  font-size: var(--text-title);
  font-weight: 600;
}

.form .row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
}

.form .actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.form .actions .note {
  margin-left: auto;
  color: var(--faint);
  font-size: var(--text-micro);
}

.robot-rows {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.robot-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-control);
  background: var(--panel);
}

.robot-row b {
  font-weight: 600;
}

.robot-row .meta {
  color: var(--muted);
  font-size: var(--text-micro);
  word-break: break-all;
}

.robot-row .tools {
  display: flex;
  gap: 6px;
  align-items: start;
}

/* -------------------------------------------------------------- sandbox --- */

.sandbox-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 12px;
  flex: none;
  padding: 10px 16px;
}

.sandbox-head > * {
  flex: none;
}

.sandbox-head h1 {
  margin: 0;
  font-size: var(--text-title);
  font-weight: 700;
  white-space: nowrap;
}

.sandbox-head .sub {
  color: var(--muted);
  font-size: var(--text-label);
  white-space: nowrap;
}

.tabs {
  display: inline-flex;
  padding: 3px;
  border-radius: var(--radius-control);
  background: var(--elevated);
  gap: 3px;
}

.tabs a {
  height: 30px;
  padding: 0 14px;
  border-radius: 9px;
  color: var(--muted);
  font-size: var(--text-label);
  font-weight: 500;
  line-height: 30px;
}

.tabs a.active {
  background: var(--surface);
  color: var(--foreground);
  font-weight: 600;
  box-shadow: var(--shadow);
}

.tabs a {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.tab-chip .chip {
  height: 18px;
  padding: 0 7px;
  font-size: 10px;
}

.share {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
  color: var(--muted);
  font-size: var(--text-micro);
  white-space: nowrap;
}

.share code {
  padding: 5px 9px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--foreground);
  font-family: inherit;
  font-size: var(--text-micro);
}

.frame {
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.frame iframe {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
  background: var(--surface);
}

@media (max-width: 1100px) {
  .monitor-grid,
  .settings-grid {
    grid-template-columns: 1fr;
  }

  .robot .stats {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

/* ---------------------------------------------------------------- admin --- */

.admin-grid {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  gap: 14px;
  align-items: start;
}

.admin-tables {
  position: sticky;
  top: 18px;
}

.admin-table-list {
  display: flex;
  flex-direction: column;
  padding: 6px 8px 10px;
}

.admin-tools {
  border-top: 1px solid var(--panel);
}

.admin-table {
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: 8px 10px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  text-align: left;
}

.admin-table:hover {
  background: var(--panel);
}

.admin-table.active {
  background: var(--primary-soft);
}

.admin-table b {
  font-size: var(--text-label);
  font-weight: 600;
}

.admin-table span {
  color: var(--muted);
  font-size: var(--text-micro);
}

.admin-main {
  min-width: 0;
  padding-bottom: 12px;
}

.admin-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 10px 18px 6px;
}

.admin-toolbar input,
.admin-toolbar select {
  height: 32px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  font-size: var(--text-label);
}

.admin-toolbar input {
  min-width: 220px;
}

.grid-scroll {
  overflow-x: auto;
  padding: 0 18px;
}

.table.grid th,
.table.grid td {
  padding: 6px 10px;
  white-space: nowrap;
  font-size: var(--text-micro);
}

.table.grid td.null {
  color: var(--faint);
}

.table.grid tr.clickable {
  cursor: pointer;
}

.table.grid tr.clickable:hover td {
  background: var(--primary-soft);
}

.row-editor,
.admin-query {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 8px 18px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-control);
  background: var(--panel);
}

.row-editor-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 10px;
  font-size: var(--text-label);
}

.row-editor textarea,
.admin-query textarea {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  font-size: var(--text-label);
  line-height: 1.5;
  resize: vertical;
}

.row-editor .actions,
.admin-query .actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

@media (max-width: 1100px) {
  .admin-grid {
    grid-template-columns: 1fr;
  }
}

