@import url("https://fonts.googleapis.com/css2?family=Noto+Sans+SC:wght@400;500;600;700&display=swap");

:root {
  --bg: #eef2f7;
  --side: #f5f5f5;
  --side-hover: #ebebeb;
  --side-active: #ffffff;
  --ink: #0f0f0f;
  --muted: #8a8a8a;
  --muted-2: #5c5c5c;
  --surface: #ffffff;
  --surface-soft: #f7f7f8;
  --line: rgba(0, 0, 0, 0.06);
  --line-strong: rgba(0, 0, 0, 0.1);
  --accent: #3b6ef5;
  --accent-ink: #ffffff;
  --accent-soft: rgba(59, 110, 245, 0.12);
  --danger: #e24b4a;
  --danger-soft: #fff1f0;
  --ok: #18a058;
  --ok-soft: #e8f8ef;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow: 0 10px 28px rgba(20, 40, 80, 0.08);
  --shadow-nav: 0 1px 3px rgba(0, 0, 0, 0.06);
  --font: "Noto Sans SC", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --radius: 16px;
  --radius-sm: 12px;
  --radius-pill: 999px;
  --side-w: 200px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
}

body {
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(1000px 480px at 12% -10%, rgba(59, 110, 245, 0.12), transparent 55%),
    radial-gradient(800px 420px at 90% 0%, rgba(120, 160, 255, 0.08), transparent 50%),
    var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button, select, input, textarea {
  font: inherit;
  color: inherit;
}

/* —— Layout (Doubao-like) —— */
.layout {
  display: grid;
  grid-template-columns: var(--side-w) 1fr;
  height: 100vh;
  overflow: hidden;
  background: transparent;
}

.side {
  background: rgba(255, 255, 255, 0.55);
  backdrop-filter: blur(14px);
  padding: 10px 8px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  border-right: 1px solid rgba(255, 255, 255, 0.4);
  overflow: hidden;
}

.brand {
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 6px 8px 10px;
}

.brand-mark {
  width: 24px;
  height: 24px;
  border-radius: 8px;
  background:
    radial-gradient(circle at 28% 28%, #5b8cff 0%, #3b6ef5 42%, #1f3fbf 100%);
  box-shadow: inset 0 -1px 0 rgba(255, 255, 255, 0.25);
  flex-shrink: 0;
}

.brand strong {
  display: block;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.brand span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 500;
}

.nav-label {
  margin: 6px 10px 2px;
  font-size: 11px;
  font-weight: 500;
  color: var(--muted);
}

.nav {
  display: grid;
  gap: 2px;
  flex: 1;
  align-content: start;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 8px;
  text-align: left;
  border: 0;
  background: transparent;
  color: var(--ink);
  padding: 8px 10px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  transition: background 0.15s ease, box-shadow 0.15s ease;
}

.nav-item svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  opacity: 0.72;
}

.nav-item:hover {
  background: var(--side-hover);
}

.nav-item.active {
  background: var(--side-active);
  box-shadow: var(--shadow-nav);
}

.nav-item.active svg {
  opacity: 1;
}

.side-foot {
  margin-top: auto;
  padding-top: 8px;
}

.logout {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 0;
  background: transparent;
  color: var(--muted-2);
  border-radius: 12px;
  padding: 10px 12px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
}

.logout:hover {
  background: var(--side-hover);
  color: var(--ink);
}

.main {
  padding: 10px 12px;
  background: transparent;
  min-width: 0;
  height: 100vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.view {
  display: none;
  flex: 1;
  min-height: 0;
  overflow: auto;
}

.view.active {
  display: flex;
  flex-direction: column;
  animation: fadeIn 0.22s ease;
}

#view-tasks.active,
#view-dispatch.active,
#view-windows.active {
  overflow: hidden;
}

.win-workspace {
  grid-template-columns: 220px 1fr !important;
}

.win-bind-list {
  flex: 1;
  min-height: 0;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.win-bind-row {
  border: 1px solid #e8e8e8;
  border-radius: 12px;
  background: #fff;
  padding: 10px 12px;
}

.win-bind-main {
  display: flex;
  align-items: center;
  gap: 10px;
}

.win-bind-fields {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 0;
}

.win-bind-fields .win-hwid,
.win-bind-fields .win-alias {
  width: auto;
  min-width: 160px;
  max-width: 240px;
  flex: 1;
  padding: 6px 10px;
  height: 32px;
  border-radius: 8px;
  font-size: 12px;
}

.win-bind-fields .win-title {
  font-size: 13px;
  margin-right: 4px;
}

.win-bind-fields .win-hwid-text {
  font-size: 11px;
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.win-bind-fields .primary,
.win-bind-fields .ghost {
  padding: 6px 12px;
  font-size: 12px;
  flex-shrink: 0;
}


.dispatch-workspace {
  grid-template-columns: 1.1fr 1fr !important;
}

.dispatch-groups {
  max-height: 180px;
  overflow: auto;
  margin-bottom: 8px;
}

.dispatch-g-item {
  align-items: flex-start;
}

.dispatch-g-item strong {
  display: block;
  font-size: 13px;
}

.dispatch-g-item small {
  display: block;
  margin-top: 2px;
  font-weight: 400;
  font-size: 11px;
  line-height: 1.35;
}

.dispatch-detail {
  flex: 1;
  min-height: 0;
  overflow: auto;
  border-top: 1px solid var(--line);
  padding-top: 8px;
}

.dispatch-detail-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.dispatch-win-list {
  display: grid;
  gap: 6px;
}

.dispatch-win-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid #e8e8e8;
  border-radius: 10px;
  background: #fff;
}

.dispatch-win-row .title {
  font-size: 13px;
  font-weight: 600;
}

.dispatch-win-row .meta {
  font-size: 11px;
  color: var(--muted);
  margin-top: 2px;
}

.dispatch-online-pick {
  display: grid;
  gap: 4px;
  max-height: 160px;
  overflow: auto;
  padding: 6px;
  background: var(--surface-soft);
  border-radius: 8px;
}


@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: none; }
}

.page-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-end;
  margin-bottom: 22px;
}

.page-head h1 {
  margin: 0;
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.2;
}

.page-head p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 14px;
  font-weight: 400;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.toolbar.tight {
  margin-bottom: 14px;
}

.toolbar select {
  width: auto;
  min-width: 160px;
}

/* —— Controls —— */
button {
  border: 0;
  background: var(--surface-soft);
  color: var(--ink);
  border-radius: var(--radius-pill);
  padding: 8px 16px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  transition: background 0.15s ease, color 0.15s ease, transform 0.1s ease;
}

button:hover {
  background: #ececed;
}

button:active {
  transform: scale(0.98);
}

button.primary {
  background: var(--accent);
  color: var(--accent-ink);
}

button.primary:hover {
  background: #2f5de0;
}

button.danger {
  background: var(--danger-soft);
  color: var(--danger);
}

button.danger:hover {
  background: #ffe4e2;
}

button.ghost {
  background: transparent;
  color: var(--muted-2);
}

button.ghost:hover {
  background: var(--surface-soft);
  color: var(--ink);
}

button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
}

input, select, textarea {
  border: 1px solid transparent;
  border-radius: 14px;
  padding: 10px 14px;
  background: var(--surface-soft);
  color: var(--ink);
  width: 100%;
  outline: none;
  transition: box-shadow 0.15s ease, background 0.15s ease, border-color 0.15s ease;
}

input:hover, select:hover, textarea:hover {
  background: #f0f0f1;
}

input:focus, select:focus, textarea:focus {
  background: #fff;
  border-color: var(--line-strong);
  box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.04);
}

input[type="search"] {
  max-width: 280px;
}

textarea {
  resize: vertical;
  min-height: 96px;
  line-height: 1.5;
}

/* —— Panels / cards —— */
.split {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 14px;
  min-height: 480px;
}

.pane {
  background: var(--surface-soft);
  border: 1px solid transparent;
  border-radius: var(--radius);
  padding: 10px;
}

.pane.grow {
  min-width: 0;
  background: var(--surface);
  border: 1px solid var(--line);
}

.list-pane {
  padding: 8px;
}

.group-item {
  display: block;
  width: 100%;
  text-align: left;
  border: 0;
  background: transparent;
  padding: 10px 12px;
  border-radius: 12px;
  cursor: pointer;
  color: var(--ink);
  font-size: 14px;
  font-weight: 500;
}

.group-item:hover {
  background: rgba(0, 0, 0, 0.04);
}

.group-item.active {
  background: #fff;
  box-shadow: var(--shadow-nav);
  font-weight: 600;
}

.group-item small {
  display: block;
  color: var(--muted);
  font-weight: 400;
  margin-top: 2px;
  font-size: 12px;
}

.table-wrap {
  overflow: auto;
  max-height: 620px;
  border-radius: 12px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}

th, td {
  padding: 12px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
}

th {
  color: var(--muted);
  font-weight: 500;
  font-size: 12px;
  position: sticky;
  top: 0;
  background: #fff;
}

tr:hover td {
  background: rgba(0, 0, 0, 0.015);
}

.cards {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
}

.card {
  background: var(--surface-soft);
  border: 1px solid transparent;
  border-radius: var(--radius);
  padding: 16px 18px;
  transition: background 0.15s ease, box-shadow 0.15s ease;
}

.card:hover {
  background: #f0f0f1;
}

.card h3 {
  margin: 0 0 6px;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.card .meta {
  color: var(--muted-2);
  font-size: 13px;
  line-height: 1.55;
}

.card .row-actions {
  margin-top: 14px;
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

/* —— VF-style task workspace —— */
.vf-workspace {
  display: grid;
  grid-template-columns: 260px minmax(200px, 0.9fr) minmax(280px, 1.3fr);
  gap: 10px;
  align-items: stretch;
  flex: 1;
  min-height: 0;
  height: 100%;
  overflow: hidden;
}

.vf-col {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

.vf-col-left {
  overflow: auto;
}

.vf-card {
  background: #ffffff;
  border: 1px solid rgba(20, 40, 80, 0.08);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 10px 12px;
  min-height: 0;
}

.vf-card-fill {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

.vf-card-title {
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 8px;
  letter-spacing: -0.01em;
}

.vf-form {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px 8px;
  align-content: start;
}

.vf-form .span-2,
.vf-form-foot.span-2 {
  grid-column: 1 / -1;
}

.vf-form label {
  display: grid;
  gap: 2px;
  font-size: 11px;
  color: var(--muted);
  font-weight: 500;
}

.vf-form label[hidden],
.vf-form .is-hidden {
  display: none !important;
}

.vf-form input,
.vf-form select {
  width: 100%;
  max-width: 100%;
  border-radius: 8px;
  padding: 4px 8px;
  background: #f3f5f9;
  font-size: 12px;
  height: 28px;
}

.vf-form-foot {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 2px;
  padding-top: 6px;
  border-top: 1px solid var(--line);
}

.vf-form-foot .primary {
  margin-left: auto;
  padding: 6px 14px;
  font-size: 12px;
}

.vf-group-create {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 6px;
}

.vf-group-create input {
  flex: 1;
  min-width: 100px;
  padding: 5px 8px;
  font-size: 12px;
  border-radius: 8px;
}

.vf-group-create button {
  padding: 5px 10px;
  font-size: 12px;
}

.vf-group-list {
  display: grid;
  gap: 4px;
  flex: 0 0 auto;
  min-height: 0;
  overflow: visible;
}

.vf-group-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  width: 100%;
  height: auto;
  border: 1px solid #e8ecf3;
  background: #fff;
  border-radius: 10px;
  padding: 6px 10px;
  cursor: pointer;
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  text-align: left;
}

.vf-group-item em {
  font-style: normal;
  color: var(--accent);
  background: var(--accent-soft);
  border-radius: 999px;
  padding: 1px 7px;
  font-size: 11px;
}

.vf-group-item:hover {
  border-color: #c9d4f0;
}

.vf-group-item.active {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent);
  background: #f5f8ff;
}

.vf-panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 6px;
  flex-shrink: 0;
}

.vf-panel-head.tight {
  margin-bottom: 6px;
}

.vf-panel-head select,
.vf-panel-head input[type="search"] {
  width: auto;
  min-width: 90px;
  flex: 1;
  padding: 5px 8px;
  font-size: 12px;
  border-radius: 8px;
}

.vf-panel-head button {
  padding: 5px 10px;
  font-size: 12px;
}

.vf-acc-list,
.vf-task-list {
  flex: 1;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-height: 0;
  max-height: none;
  padding-right: 2px;
}

.vf-acc-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 8px;
  align-items: center;
  padding: 6px 10px;
  border: 1px solid #e8ecf3;
  border-radius: 10px;
  background: #fff;
  cursor: pointer;
}

.vf-acc-row input {
  width: auto;
  margin: 0;
  accent-color: var(--accent);
}

.vf-acc-name {
  font-size: 12px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
}

.vf-panel {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.vf-pager {
  display: flex;
  align-items: center;
  gap: 6px;
}

.vf-pager button {
  padding: 5px 10px;
  font-size: 12px;
}

.vf-task-row {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 8px;
  align-items: center;
  padding: 7px 10px;
  border: 1px solid #e8e8e8;
  border-radius: 10px;
  background: #fff;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.vf-task-row:hover {
  border-color: #c9d4f0;
  box-shadow: var(--shadow-sm);
}

.vf-task-check {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  user-select: none;
}

.vf-task-check input {
  width: auto;
  margin: 0;
  accent-color: var(--accent);
}

.vf-task-idx {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted-2);
  font-variant-numeric: tabular-nums;
  min-width: 1.4em;
}

.vf-task-body {
  min-width: 0;
  cursor: pointer;
}

.vf-task-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--ink);
  line-height: 1.25;
  margin-bottom: 2px;
}

.vf-task-meta {
  font-size: 11px;
  color: var(--muted);
  line-height: 1.35;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.vf-task-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

/* left: both cards hug content — do not stretch 默认分组 */
.vf-col-left > .vf-card:first-child,
.vf-col-left > .vf-card:last-child {
  flex: 0 0 auto;
}

.vf-col-left > .vf-card:last-child {
  display: block;
}

@media (max-width: 1200px) {
  .vf-workspace {
    grid-template-columns: 1fr 1fr;
  }
  .vf-col-left {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: 1.2fr 0.8fr;
    overflow: hidden;
  }
}

@media (max-width: 900px) {
  html, body {
    overflow: auto;
    height: auto;
  }
  .layout {
    height: auto;
    overflow: visible;
  }
  .main {
    height: auto;
    overflow: visible;
  }
  .vf-workspace,
  .vf-col-left {
    grid-template-columns: 1fr;
    height: auto;
    overflow: visible;
  }
  .vf-task-meta {
    white-space: normal;
  }
}

.device-grid {
  display: grid;
  gap: 8px;
}

.device {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 12px;
  align-items: center;
  background: var(--surface-soft);
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  cursor: pointer;
  transition: background 0.15s ease, box-shadow 0.15s ease;
}

.device:hover {
  background: #efefef;
}

.device.selected {
  background: #fff;
  box-shadow: inset 0 0 0 1.5px var(--ink);
}

.device .title {
  font-weight: 600;
  font-size: 14px;
}

.device .meta {
  color: var(--muted);
  font-size: 12px;
  margin-top: 3px;
  word-break: break-all;
}

.badge {
  border-radius: var(--radius-pill);
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 600;
}

.badge.online {
  background: var(--ok-soft);
  color: var(--ok);
}

.badge.offline {
  background: #f0f0f0;
  color: var(--muted);
}

.form-card {
  display: grid;
  grid-template-columns: 1.2fr 1fr auto;
  gap: 12px;
  align-items: end;
  margin-bottom: 14px;
  background: var(--surface-soft) !important;
}

.form-card:hover {
  background: var(--surface-soft) !important;
}

.form-card label {
  display: grid;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
  font-weight: 500;
}

.log {
  margin-top: 16px;
  max-height: 240px;
  overflow: auto;
  background: #111111;
  color: #d6d6d6;
  border-radius: var(--radius);
  padding: 14px 16px;
  font-size: 12px;
  font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
  white-space: pre-wrap;
  line-height: 1.5;
}

.muted { color: var(--muted); font-size: 13px; }
.empty { color: var(--muted); padding: 28px 8px; font-size: 14px; }

/* —— Dialogs —— */
dialog {
  border: 0;
  border-radius: 20px;
  padding: 0;
  box-shadow: var(--shadow);
  width: min(520px, calc(100% - 2rem));
  background: #fff;
}

dialog::backdrop {
  background: rgba(0, 0, 0, 0.28);
  backdrop-filter: blur(2px);
}

.dlg {
  padding: 22px 22px 18px;
  display: grid;
  gap: 12px;
}

.dlg h3 {
  margin: 0 0 4px;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.dlg label {
  display: grid;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
  font-weight: 500;
}

.dlg .check {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--ink);
  font-size: 13px;
}

.dlg .check input {
  width: auto;
}

.dlg .toolbar {
  margin-top: 4px;
  justify-content: flex-end;
}

/* —— Login —— */
.login-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background:
    radial-gradient(900px 480px at 50% -20%, rgba(59, 110, 245, 0.08), transparent 60%),
    #f7f7f8;
}

.login-shell {
  width: min(400px, calc(100% - 2rem));
}

.login-card {
  display: grid;
  gap: 12px;
  background: #fff !important;
  border-radius: 20px !important;
  padding: 28px 26px !important;
  box-shadow: var(--shadow);
}

.login-card:hover {
  background: #fff !important;
}

.login-card h1 {
  margin: 0;
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.03em;
}

.login-card .primary {
  width: 100%;
  margin-top: 6px;
  padding: 12px 16px;
  font-size: 14px;
}

.login-card label {
  display: grid;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
  font-weight: 500;
}

.eyebrow {
  margin: 0;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
}

.error {
  color: var(--danger);
  margin: 0;
  font-size: 13px;
}

@media (max-width: 960px) {
  .layout {
    grid-template-columns: 1fr;
  }
  .side {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    padding: 10px;
  }
  .brand {
    padding: 6px 8px;
  }
  .nav {
    display: flex;
    flex-wrap: wrap;
    flex: 1;
  }
  .nav-label, .side-foot {
    width: 100%;
  }
  .main {
    padding: 20px 16px 32px;
  }
  .page-head {
    flex-direction: column;
    align-items: stretch;
  }
  .page-head h1 {
    font-size: 24px;
  }
  .split {
    grid-template-columns: 1fr;
  }
  .form-card {
    grid-template-columns: 1fr;
  }
  .cards {
    grid-template-columns: 1fr;
  }
}
