/* ============================================================================
 * PAD·LINK 控制台 — 只写 agentcss 没覆盖的部分
 *
 * 这里刻意不重新定义任何 agentcss 已有的组件（.card / .btn / .metric / .badge /
 * .timeline / .sparkline / .shell）。改样式改令牌，不覆盖组件选择器。
 *
 * 唯一"新的"视觉系统是 .screen-* —— 它是板子那 808×552 画布的等比复刻，
 * 尺寸与 docs/PAD_UI_SPEC.md 完全一致（14/18/24/32 字面，20/26/35/46 行高），
 * 所以它溢出的地方，板子也会溢出。
 * ========================================================================= */

:root {
  --screen-canvas: #f2f6fb;
  --screen-card: #ffffff;
  --screen-ink: #122033;
  --screen-muted: #6b7c90;
  --screen-accent: #147efb;
  --screen-line: #d9e3f0;
  --screen-pad: 14px;
  --screen-gap: 10px;
}

body.page {
  margin: 0;
}

/* agentcss 的 .card / .btn 自带 display，会把 hidden 属性盖掉 ——
   `hidden` 只是 UA 样式 `display:none`，特异性低于 `.card{display:flex}`。
   登录卡与「退出」按钮都踩过这一条：元素该藏的时候还看得见。 */
[hidden] {
  display: none !important;
}

.shell {
  min-height: 100dvh;
  /* 这是一个工具型控制台，不是阅读型页面：52rem 的正文列宽会把
     指标行挤成两行、预览缩到 450px。令牌是可以改的，组件选择器不可以。 */
  --measure-page: 88rem;
}

/* ---------------------------------------------------------------- layout */

.shell__content > * + * {
  margin-top: var(--sp-4);
}

.console-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr);
  gap: var(--sp-4);
  align-items: start;
}

.console-side {
  display: grid;
  gap: var(--sp-4);
}

@media (max-width: 68rem) {
  .console-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

.preview-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  flex-wrap: wrap;
}

.preview-tags {
  display: flex;
  gap: var(--sp-2);
  flex-wrap: wrap;
}

.row-gap {
  display: flex;
  gap: var(--sp-2);
  flex-wrap: wrap;
}

/* 顶栏右侧的状态灯：idle 灰、live 绿、down 红 */
#connPill[data-state='live'] {
  color: var(--success, #2f6b3a);
  border-color: currentColor;
}
#connPill[data-state='down'] {
  color: var(--danger, #c0392b);
  border-color: currentColor;
}

/* ------------------------------------------------------------------ login */

.login-card {
  max-width: 34rem;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
  align-items: flex-start;
  margin-top: var(--sp-2);
}

.login-form .field {
  width: 100%;
}

/* ------------------------------------------------------- screen replica */

.screen-frame {
  position: relative;
  width: 100%;
  overflow: hidden;
  border: 1px solid var(--border-decor);
  border-radius: var(--r-md);
  background: var(--screen-canvas);
}

.screen-stage {
  width: 808px;
  height: 552px;
  transform-origin: top left;
  display: flex;
  flex-direction: column;
  gap: var(--screen-gap);
  padding: var(--screen-pad);
  background: var(--screen-canvas);
  color: var(--screen-ink);
  font-family: system-ui, -apple-system, 'Segoe UI', 'Noto Sans SC', sans-serif;
  font-size: 14px;
  line-height: 20px;
  font-weight: 300;
}

/* 页头 = 板子上那一行 32px 标题 + 右侧状态（46px 高，与审计模型同一项） */
.sc-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  height: 46px;
  flex: 0 0 auto;
}

.sc-head h3 {
  margin: 0;
  font-size: 32px;
  line-height: 46px;
  font-weight: 400;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sc-head .sc-head-meta {
  font-size: 14px;
  line-height: 20px;
  color: var(--screen-muted);
  white-space: nowrap;
}

.sc-card {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: var(--screen-pad);
  border-radius: 12px;
  background: var(--screen-card);
  flex: 0 0 auto;
}

.sc-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-width: 0;
}

.sc-label {
  font-size: 14px;
  line-height: 20px;
  color: var(--screen-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sc-value {
  font-size: 32px;
  line-height: 46px;
  white-space: nowrap;
}

.sc-delta {
  font-size: 24px;
  line-height: 35px;
  color: var(--screen-accent);
  white-space: nowrap;
}

.sc-note {
  font-size: 14px;
  line-height: 20px;
  color: var(--screen-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sc-grid {
  display: grid;
  gap: var(--screen-gap);
}

.sc-cell {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: var(--screen-pad);
  border-radius: 12px;
  background: var(--screen-card);
  min-width: 0;
}

.sc-cell-value {
  font-size: 24px;
  line-height: 35px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sc-bar {
  height: 8px;
  border-radius: 4px;
  background: var(--screen-line);
  overflow: hidden;
}

.sc-bar > i {
  display: block;
  height: 100%;
  background: var(--screen-accent);
}

.sc-kv {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-size: 18px;
  line-height: 26px;
  min-width: 0;
}

.sc-kv > span:first-child {
  color: var(--screen-muted);
  flex: 0 0 58%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sc-kv > span:last-child {
  flex: 1 1 38%;
  text-align: right;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sc-body {
  margin: 0;
  font-size: 18px;
  line-height: 26px;
  white-space: pre-wrap;
  word-break: break-word;
}

.sc-body--muted {
  font-size: 14px;
  line-height: 20px;
  color: var(--screen-muted);
}

.sc-actions {
  display: flex;
  gap: var(--screen-gap);
  height: 48px;
  flex: 0 0 auto;
}

.sc-btn {
  flex: 1 1 0;
  height: 48px;
  border: 0;
  border-radius: 10px;
  background: var(--screen-accent);
  color: #fff;
  font-family: inherit;
  font-size: 18px;
  line-height: 26px;
  font-weight: 400;
  cursor: pointer;
}

.sc-btn:hover {
  background: #0d6ad4;
}

.sc-btn:focus-visible {
  outline: 2px solid var(--screen-ink);
  outline-offset: 2px;
}

/* 预览里的按钮点下去，和板子上按下去走同一条 action 语义 */
.preview-actions {
  display: flex;
  gap: var(--sp-2);
  flex-wrap: wrap;
  margin-top: var(--sp-3);
}

/* -------------------------------------------------------------- captures */

.shot-frame {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 7rem;
  border: 1px dashed var(--border-decor-str);
  border-radius: var(--r-md);
  background: var(--surface-sunken);
  overflow: hidden;
}

.shot {
  display: block;
  width: 100%;
  height: auto;
  image-rendering: auto;
}

.shot-empty {
  font-size: var(--fs-sm);
  color: var(--text-tertiary);
}

/* ---------------------------------------------------------------- device */

.table-wrap {
  overflow-x: auto;
}

.dev-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--fs-sm);
}

.dev-table th,
.dev-table td {
  padding: var(--sp-2) var(--sp-3);
  text-align: left;
  border-bottom: 1px solid var(--border-decor);
  white-space: nowrap;
}

.dev-table th {
  font-weight: 500;
  color: var(--text-secondary);
}

.dev-table td.num {
  font-variant-numeric: tabular-nums;
  font-family: var(--mono, ui-monospace, monospace);
}

/* ---------------------------------------------------------------- ledger */

#ledger {
  max-height: 22rem;
  overflow-y: auto;
}
