:root {
  color-scheme: light;
  font: 14px/1.5 "Segoe UI", "Microsoft YaHei UI", "Microsoft YaHei", sans-serif;
  --ink: #1d2129;
  --muted: #5e6673;
  --line: #e3e5e8;
  --stroke: #d8dbe0;
  --canvas: #f1f2f5;
  --surface: #fff;
  --surface-subtle: #f7f9fc;
  --radius: 8px;
  --accent: #0052d9;
  --accent-hover: #0044b5;
  --soft: #eaf2ff;
  --green: #087553;
  --green-bg: #e4f4ee;
  --orange: #945214;
  --orange-bg: #fff0df;
  --red: #ae2736;
  --red-bg: #fcebed;
  background: var(--canvas);
  color: var(--ink);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body, h1, h2, h3, p { margin: 0; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { opacity: 0.48; cursor: default; }
a { color: var(--accent); }
label { min-width: 0; }
code, .mono, pre { font-family: Consolas, monospace; }
.ui-icon { width: 18px; height: 18px; flex: none; vertical-align: middle; }

input, select {
  width: 100%;
  min-width: 0;
  height: 36px;
  padding: 0 10px;
  border: 1px solid var(--stroke);
  border-radius: 4px;
  background: var(--surface);
  color: var(--ink);
}
select {
  appearance: none;
  padding-inline-end: 36px;
  background-image: linear-gradient(45deg, transparent 38%, var(--muted) 39% 61%, transparent 62%),
    linear-gradient(135deg, transparent 38%, var(--muted) 39% 61%, transparent 62%);
  background-size: 6px 6px;
  background-position: right 19px center, right 13px center;
  background-repeat: no-repeat;
}
@media (forced-colors: active) { select { appearance: auto; background-image: none; } }
textarea {
  display: block;
  width: 100%;
  min-width: 0;
  padding: 9px 11px;
  border: 1px solid var(--stroke);
  border-radius: 4px;
  background: var(--surface);
  color: var(--ink);
  resize: vertical;
}
:is(input, textarea)::placeholder { color: #687284; }
input[type="checkbox"] { flex: none; width: 15px; height: 15px; margin: 0; padding: 0; accent-color: var(--accent); }
:is(input, select, textarea):not(:disabled):hover { border-color: #a9b3c2; }
:is(input, select, textarea):focus-visible { border-color: var(--accent); outline: 2px solid #bed6ff; outline-offset: 0; }
:is(button, a, summary, [tabindex]):focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
:is(input, textarea, select):user-invalid { border-color: var(--red); }

.button {
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 4px 13px;
  border: 1px solid var(--stroke);
  border-radius: 4px;
  background: var(--surface);
  color: var(--ink);
  white-space: nowrap;
}
.button:not(:disabled):hover { background: #f3f5f8; }
.button.primary { border-color: var(--accent); background: var(--accent); color: #fff; font-weight: 600; }
.button.primary:not(:disabled):hover { background: var(--accent-hover); }
.button.ghost { border-color: transparent; background: transparent; color: var(--accent); }
.button.danger { color: var(--red); }
.button.small { min-height: 30px; padding: 3px 10px; font-size: 13px; }
.button .ui-icon { width: 16px; height: 16px; }
.button.icon-button { width: 36px; padding: 0; border-color: transparent; background: transparent; }
.button.icon-button .ui-icon { width: 19px; height: 19px; }

.layout {
  --sidebar-width: 232px;
  --header-height: 56px;
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
  grid-template-rows: auto 1fr;
  min-height: 100vh;
  min-height: 100dvh;
}
.layout.menu-collapsed { --sidebar-width: 64px; }
.bar {
  position: sticky;
  z-index: 5;
  top: 0;
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: var(--sidebar-width) 40px minmax(0, 1fr) auto auto;
  grid-template-rows: calc(var(--header-height) - 1px);
  align-items: center;
  column-gap: 10px;
  padding-right: 20px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}
.bar-brand { display: flex; min-width: 0; align-self: stretch; padding-inline: 18px 12px; }
.brand { display: flex; min-width: 0; align-items: center; gap: 9px; }
.brand-mark {
  flex: none;
  display: block;
  width: 32px;
  height: 32px;
}
.brand-copy { display: grid; min-width: 0; gap: 1px; }
.brand-copy strong { overflow: hidden; font-size: 15px; font-weight: 650; line-height: 1.25; text-overflow: ellipsis; white-space: nowrap; }
.brand-copy small { color: var(--muted); font-size: 11px; line-height: 1.35; white-space: nowrap; }
.menu-collapsed .bar-brand { justify-content: center; padding: 0; }
.menu-collapsed .bar-brand .brand-copy { display: none; }
#menu-toggle { justify-self: center; }
.breadcrumbs, .bar-account, .account-chip, .config-actions, .actions {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 8px;
}
.breadcrumbs { color: var(--muted); font-size: 13px; white-space: nowrap; }
.breadcrumbs .ui-icon { width: 13px; height: 13px; color: #8b929c; }
.breadcrumbs strong { overflow: hidden; color: var(--ink); font-weight: 600; text-overflow: ellipsis; }
.bar-account { grid-column: 5; position: relative; }
.account-chip.button { padding-inline: 5px; min-width: 36px; gap: 7px; }
.account-chip > .ui-icon { width: 13px; height: 13px; color: var(--muted); }
.account-avatar { display: grid; width: 26px; height: 26px; place-items: center; border-radius: 50%; background: var(--soft); color: var(--accent); }
.account-avatar .ui-icon { width: 16px; height: 16px; }
.account-name { max-width: 100px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-dropdown {
  position: absolute;
  inset: calc(100% + 6px) 0 auto auto;
  min-width: 132px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  box-shadow: 0 4px 16px rgb(20 32 51 / 14%);
}
.account-dropdown .button { width: 100%; justify-content: flex-start; white-space: nowrap; }
.account-dropdown .button + .button { margin-top: 2px; }
.config-actions { grid-column: 4; }
.actions { flex-wrap: wrap; }

.sidebar {
  position: sticky;
  z-index: 3;
  top: var(--header-height);
  grid-column: 1;
  grid-row: 2;
  align-self: start;
  min-width: 0;
  height: calc(100vh - var(--header-height));
  height: calc(100dvh - var(--header-height));
  padding: 13px 8px;
  overflow: auto;
  border-right: 1px solid var(--line);
  background: var(--surface);
}
.nav { display: grid; gap: 3px; }
.nav-group { min-width: 0; position: relative; }
.nav .button {
  width: 100%;
  min-height: 36px;
  justify-content: flex-start;
  border: 0;
  border-radius: 4px;
  padding: 6px 11px;
  background: transparent;
  color: var(--ink);
  text-align: left;
}
.nav .button:hover { background: #f2f4f7; }
.nav-group-button { gap: 9px; color: var(--muted); }
.nav-group-button .ui-icon:first-child { width: 18px; height: 18px; }
.nav-group-button .ui-icon:last-child { margin-left: auto; width: 14px; height: 14px; }
.nav-group-button[aria-expanded="true"] .ui-icon:last-child { transform: rotate(180deg); }
.nav .nav-group-button.selected { color: var(--accent); font-weight: 650; }
.nav-children { display: grid; gap: 2px; list-style: none; padding: 2px 0; margin: 0; }
.nav-flyout-title { display: none; }
.nav .nav-child { padding-left: 38px; color: var(--muted); }
.nav .nav-child.active { background: var(--soft); color: var(--accent); font-weight: 650; }
.menu-collapsed .sidebar { overflow: visible; padding-inline: 7px; }
.menu-collapsed .nav-group-button { justify-content: center; padding-inline: 0; }
.menu-collapsed .nav-group-label, .menu-collapsed .nav-group-button .ui-icon:last-child { display: none; }
.menu-collapsed .nav-group-button.selected { background: var(--soft); }
.menu-collapsed .nav-children {
  position: absolute;
  top: 0;
  left: calc(100% + 8px);
  width: 180px;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  box-shadow: 0 5px 18px #18243b24;
}
.menu-collapsed .nav-flyout-title { display: block; padding: 6px 10px; color: var(--muted); font-size: 12px; }
.menu-collapsed .nav-child { padding-left: 10px; }
.menu-backdrop { display: none; }

.workspace { grid-column: 2; grid-row: 2; min-width: 0; }
.workspace main { width: min(100%, 1640px); margin-inline: auto; padding: 26px; }
.heading {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px 20px;
  margin-bottom: 18px;
}
.heading h1 { font-size: 24px; font-weight: 650; line-height: 1.35; }
.heading p { margin-top: 4px; color: var(--muted); }
.pill { display: inline-flex; align-items: center; padding: 3px 7px; border-radius: 3px; background: #f0f1f3; color: #434a56; font-size: 12px; white-space: nowrap; }
.pill.live { background: var(--green-bg); color: var(--green); }
.pill.warn { background: var(--orange-bg); color: var(--orange); }

.split { display: grid; grid-template-columns: minmax(175px, 23%) minmax(0, 1fr); align-items: start; gap: 16px; }
.panel, .card { min-width: 0; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.panel { overflow: hidden; }
.panel-head, .card-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 7px 12px;
}
.panel-head { padding: 12px 14px; border-bottom: 1px solid var(--line); }
.card { padding: 20px; }
.card-head { padding-bottom: 14px; }
.card-head h2, .panel-head h2 { display: flex; align-items: center; gap: 7px; font-size: 16px; line-height: 1.4; font-weight: 650; overflow-wrap: anywhere; }
.card-head h2 .ui-icon { color: var(--accent); }
.items { display: grid; gap: 3px; padding: 6px; }
.item { border: 0; border-radius: 4px; padding: 8px 10px; background: transparent; color: var(--ink); text-align: left; overflow-wrap: anywhere; }
.item:hover, .item.active { background: var(--soft); color: var(--accent); }
.item small { display: block; margin-top: 2px; color: var(--muted); }
.editor { display: grid; min-width: 0; gap: 14px; }
.nested { border-left: 3px solid #a6c5fd; }
.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.field { display: grid; min-width: 0; align-content: start; gap: 6px; }
.field > span, .field-legend { font-weight: 550; }
.field.full, .rows.full { grid-column: 1 / -1; }
.muted { color: var(--muted); }
.hint { color: var(--muted); font-size: 13px; line-height: 1.55; }
.check { display: flex; align-items: center; min-width: 0; gap: 8px; overflow-wrap: anywhere; }
.rows { display: grid; min-width: 0; gap: 8px; }
.rows-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 7px; }
.row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)) auto; align-items: center; gap: 6px; }
.row.filters { grid-template-columns: repeat(4, minmax(65px, 1fr)) auto auto; }
.empty { padding: 5px 0; color: var(--muted); }
.secret { padding: 10px; overflow-wrap: anywhere; border: 1px solid #d3e2ff; border-radius: 4px; background: var(--soft); }

.table-wrap { min-width: 0; overflow: auto; border: 1px solid var(--line); border-radius: 6px; }
table { width: 100%; border-collapse: collapse; text-align: left; }
th, td { padding: 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { background: #f4f6f8; color: #424b58; font-weight: 600; }
.table-wrap tbody tr:hover { background: var(--surface-subtle); }
.table-wrap tbody tr:last-child td { border-bottom: 0; }
.status { color: var(--green); font-weight: 650; }
.status.error { color: var(--red); }
dialog { width: min(840px, 94vw); max-height: 86dvh; padding: 22px; overflow: auto; overscroll-behavior: contain;
  border: 1px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--ink); box-shadow: 0 16px 55px #0f1a2b28; }
dialog::backdrop { background: #0f1a2b68; }
pre { max-height: 48vh; padding: 12px; overflow: auto; border-radius: 4px; background: var(--canvas); white-space: pre-wrap; overflow-wrap: anywhere; font-size: 13px; }
#notice { position: fixed; z-index: 8; right: 16px; bottom: 16px; max-width: min(460px, 90vw); padding: 10px 14px; border-radius: 5px; background: #253952; color: #fff; box-shadow: 0 6px 20px #15233728; }
#notice.error { background: var(--red); }

.login-wrap { display: grid; min-height: 100vh; min-height: 100dvh; place-items: center; padding: 18px; background: radial-gradient(ellipse at 80% 10%, #fff1e5 0%, transparent 56%), var(--canvas); }
.login { width: min(100%, 400px); padding: 27px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); box-shadow: 0 12px 36px #18243b14; }
.login-brand { gap: 12px; margin-bottom: 24px; }
.login-brand .brand-mark { width: 42px; height: 42px; }
.login-brand h1 { font-size: clamp(17px, 4.4vw, 22px); line-height: 1.3; font-weight: 650; }
.login-brand small { font-size: 12px; }
.login form { display: grid; gap: 14px; }
.login :is(input, .button) { min-height: 42px; }
.login .button { margin-top: 4px; }
.login > .registration-back { display: inline-block; margin-top: 14px; }

@media (max-width: 1180px) {
  .layout { --sidebar-width: 206px; }
  .bar-brand { padding-inline: 12px; }
  .bar { column-gap: 6px; padding-right: 12px; }
  .workspace main { padding: 20px; }
}
@media (max-width: 980px) {
  .breadcrumb-parent, .breadcrumbs > .ui-icon { display: none; }
  .config-actions .pill:not(.warn):not(.live) { display: none; }
  .account-name { max-width: 64px; }
  .workspace main { padding: 16px; }
  .split { grid-template-columns: minmax(140px, 24%) minmax(0, 1fr); gap: 11px; }
  .row.filters { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 760px) {
  .layout {
    --header-height: 54px;
    grid-template-columns: minmax(0, 1fr);
  }
  .layout.has-config-actions { --header-height: 99px; }
  .bar {
    grid-template-columns: 42px minmax(0, 1fr) auto;
    grid-template-rows: 53px;
    padding-inline: 9px;
  }
  .has-config-actions .bar { grid-template-rows: 53px 45px; }
  .bar-brand { grid-column: 2; grid-row: 1; padding: 0; }
  #menu-toggle { grid-column: 1; grid-row: 1; width: 40px; min-height: 40px; }
  .bar-account { grid-column: 3; grid-row: 1; }
  .account-name, .account-chip > .ui-icon, .breadcrumbs { display: none; }
  .config-actions { grid-column: 1 / -1; grid-row: 2; justify-content: flex-end; border-top: 1px solid var(--line); align-self: stretch; }
  .config-actions .pill { margin-right: auto; }
  .config-actions .pill + .pill { display: none; }
  .config-actions:has(#draft-status.warn) #publication-status { display: none; }
  .config-actions #draft-status.warn { display: inline-flex; }
  .sidebar {
    position: fixed;
    top: var(--header-height);
    left: 0;
    width: min(246px, 82vw);
    height: calc(100vh - var(--header-height));
    height: calc(100dvh - var(--header-height));
    overscroll-behavior: contain;
    visibility: hidden;
    transform: translateX(-100%);
  }
  .sidebar .nav .button { min-height: 42px; }
  .drawer-open .sidebar { visibility: visible; transform: none; }
  .drawer-open .menu-backdrop { position: fixed; z-index: 2; inset: var(--header-height) 0 0; display: block; border: 0; border-radius: 0; background: #18263760; }
  body:has(.drawer-open) { overflow: hidden; }
  .workspace { grid-column: 1; }
  .workspace main { padding: 14px; }
  .heading { gap: 10px; margin-bottom: 14px; }
  .heading h1 { font-size: 21px; }
  .split { grid-template-columns: minmax(0, 1fr); }
  .panel .items { max-height: 29vh; overflow: auto; }
  .panel-head, .card { padding: 12px; }
  .card-head { padding-bottom: 12px; }
  dialog { padding: 16px; }
  .bar-account .account-chip { min-height: 40px; min-width: 40px; }
}

.frp-info { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; padding: 10px 14px; margin-bottom: 16px; background: #f4f7fb; border-radius: 6px; }
.frp-info svg { width: 16px; height: 16px; }
.frp-table table { min-width: 640px; }
.frp-table td { vertical-align: middle; }
.frp-device-name { display: grid; gap: 5px; }
.frp-device-name code { font-size: 12px; overflow-wrap: anywhere; }
.frp-ports { display: flex; flex-wrap: wrap; gap: 5px; }
.frp-port { padding: 2px 7px; color: #20579b; background: #edf3fb; border-radius: 4px; }
.pill.frp-status { gap: 5px; }
.frp-status::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill.frp-status.online { background: var(--green-bg); color: var(--green); }
.pill.frp-status.offline { background: #edf0f4; color: #4b5a6c; }
.pill.frp-status.disabled { background: var(--orange-bg); color: var(--orange); }
.frp-filter-bar { display: grid; grid-template-columns: minmax(110px, .65fr) repeat(3, minmax(0, 1fr)) auto; align-items: end; gap: 12px; }
.frp-filter-bar-tenant { grid-template-columns: minmax(110px, .65fr) repeat(2, minmax(0, 1fr)) auto; margin-bottom: 16px; }
.frp-filter-bar .field { min-width: 0; }
.frp-filter-bar .actions { flex-wrap: nowrap; }
@media (max-width: 950px) {
  .frp-filter-bar { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 420px) {
  .frp-filter-bar { gap: 8px; }
  .frp-filter-bar input { padding-inline: 8px; }
}
.frp-actions { gap: 6px; }
.frp-empty { display: grid; justify-items: center; gap: 8px; padding: 28px 16px; text-align: center; }
.frp-empty svg { width: 26px; height: 26px; color: #517bb2; }
.frp-empty p { margin: 0; }
.frp-editor { width: min(calc(100% - 32px), 440px); }
.frp-editor-actions { justify-content: flex-end; margin-top: 4px; }
.frp-install-dialog { width: min(860px, 94vw); }
.frp-install-content { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: start; gap: 12px; }
.frp-install-command[readonly] { min-width: 0; width: 100%; padding: 14px; border-color: #222c43; background: #1b2335;
  color: #f3f6fb; font: 12px/1.6 Consolas, "Liberation Mono", monospace; overflow-wrap: anywhere; resize: vertical; }
.button.frp-install-copy { border-color: var(--green); background: var(--green); color: #fff; white-space: nowrap; }
.button.frp-install-copy:hover:not(:disabled) { border-color: #075f47; background: #075f47; color: #fff; }
.frp-install-feedback { min-height: 1.5em; }
@media (max-width: 560px) {
  .frp-install-content { grid-template-columns: minmax(0, 1fr); }
  .frp-install-content .frp-install-copy { justify-self: end; }
}

@media (max-width: 760px) {
  .frp-table { border: 0; }
  .frp-table table { display: block; min-width: 0; }
  .frp-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .frp-table tbody { display: grid; gap: 12px; }
  .frp-table tbody tr { display: grid; gap: 8px; padding: 12px; border: 1px solid var(--line); border-radius: 6px; }
  .frp-table tbody td { display: grid; grid-template-columns: minmax(72px, 26%) minmax(0, 1fr); align-items: start;
    gap: 8px; padding: 0; border: 0; white-space: normal; }
  .frp-table tbody td::before { content: attr(data-label); font-size: 12px; color: var(--muted); }
  .frp-table tbody td[data-label="操作"]:empty { display: none; }
  .frp-table .actions { flex-wrap: wrap; }
  .frp-table .pill { justify-self: start; }
}
