:root {
  --bg: #0f1419;
  --surface: #1a2332;
  --surface2: #243044;
  --border: #2d3f56;
  --text: #e8edf4;
  --muted: #8b9cb3;
  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --success: #22c55e;
  --danger: #ef4444;
  --warning: #f59e0b;
  --radius: 10px;
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.35);
  font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
}

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

a:hover {
  text-decoration: underline;
}

/* Login */
.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(ellipse at 20% 20%, rgba(59, 130, 246, 0.12), transparent 50%),
    radial-gradient(ellipse at 80% 80%, rgba(34, 197, 94, 0.08), transparent 50%),
    var(--bg);
}

.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 36px;
  box-shadow: var(--shadow);
}

.login-card h1 {
  font-size: 1.5rem;
  margin-bottom: 6px;
}

.login-card .sub {
  color: var(--muted);
  font-size: 0.9rem;
  margin-bottom: 28px;
}

.field {
  margin-bottom: 18px;
}

.field label {
  display: block;
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 6px;
}

.field input {
  width: 100%;
  padding: 11px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 1rem;
}

.field input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  border: none;
  border-radius: var(--radius);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
}

.btn:active {
  transform: scale(0.98);
}

.btn-primary {
  background: var(--accent);
  color: #fff;
  width: auto;
  padding: 10px 18px;
}

.btn-primary:hover {
  background: var(--accent-hover);
}

/* 仅登录/注册/强制改密等表单需要通栏主按钮 */
.btn-block,
.login-card .btn-primary,
#passwordModal .btn-primary {
  width: 100%;
  padding: 12px;
}

.btn-secondary {
  background: var(--surface2);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background: var(--border);
}

.btn-danger {
  background: var(--danger);
  color: #fff;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 0.85rem;
}

.error-msg {
  color: var(--danger);
  font-size: 0.88rem;
  margin-top: 12px;
  min-height: 1.2em;
}

/* Layout */
.app-shell {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
}

.brand {
  font-size: 1.1rem;
  font-weight: 700;
  padding: 8px 12px 24px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
}

.brand small {
  display: block;
  font-weight: 400;
  color: var(--muted);
  font-size: 0.75rem;
  margin-top: 4px;
}

.nav a {
  display: block;
  padding: 10px 12px;
  border-radius: var(--radius);
  color: var(--muted);
  margin-bottom: 4px;
}

.nav a:hover,
.nav a.active {
  background: var(--surface2);
  color: var(--text);
  text-decoration: none;
}

.sidebar-footer {
  margin-top: auto;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  font-size: 0.85rem;
  color: var(--muted);
}

.main {
  padding: 24px 28px;
  overflow: auto;
}

/* 宽屏可读宽度：控制页除外（需占满投屏区） */
body:not(.control-page) .main > .panel {
  max-width: 1080px;
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 12px;
}

.page-header h2 {
  font-size: 1.4rem;
}

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

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

.stat-card .label {
  color: var(--muted);
  font-size: 0.85rem;
}

.stat-card .value {
  font-size: 1.8rem;
  font-weight: 700;
  margin-top: 4px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 20px;
}

.card h3 {
  font-size: 1rem;
  margin-bottom: 14px;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  text-align: left;
  padding: 12px 10px;
  border-bottom: 1px solid var(--border);
}

th {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
}

.badge-online {
  background: rgba(34, 197, 94, 0.15);
  color: var(--success);
}

.badge-offline {
  background: rgba(139, 156, 179, 0.15);
  color: var(--muted);
}

.empty {
  text-align: center;
  padding: 48px 20px;
  color: var(--muted);
}

/* Control page — keep stream + panel + logs in one viewport */
body.control-page {
  height: 100vh;
  overflow: hidden;
}

body.control-page .app-shell {
  height: 100vh;
  overflow: hidden;
}

body.control-page .main {
  display: flex;
  flex-direction: column;
  min-height: 0;
  height: 100vh;
  overflow: hidden;
  padding-bottom: 12px;
}

body.control-page .page-header {
  flex-shrink: 0;
  margin-bottom: 12px;
}

.control-layout {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) minmax(300px, 360px);
  gap: 16px;
  align-items: stretch;
  flex: 1;
  min-height: 0;
}

.control-stream-card,
.control-panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
  max-height: 100%;
  overflow: hidden;
}

.control-stream-card .stream-toolbar {
  flex-shrink: 0;
}

.control-panel-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding-right: 2px;
}

.control-log-dock {
  flex-shrink: 0;
  border-top: 1px solid var(--border);
  margin-top: 10px;
  padding-top: 8px;
}

.control-log-dock .section-title {
  margin-top: 0;
}

.control-a11y-hint {
  font-size: 0.8rem;
  color: var(--warning);
  line-height: 1.55;
  margin: 0 0 8px;
  padding: 8px 10px;
  border: 1px solid rgba(245, 158, 11, 0.35);
  border-radius: 8px;
  background: rgba(245, 158, 11, 0.08);
}

@media (max-width: 960px) {
  body.control-page {
    height: auto;
    overflow: auto;
  }

  body.control-page .app-shell,
  body.control-page .main {
    height: auto;
    overflow: visible;
  }

  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    display: none;
  }

  .control-layout {
    grid-template-columns: 1fr;
    flex: none;
  }

  .control-stream-card,
  .control-panel {
    max-height: none;
    overflow: visible;
  }

  .control-panel-scroll {
    overflow: visible;
  }
}

.phone-frame {
  background: #000;
  border-radius: 16px;
  border: 3px solid var(--border);
  overflow: hidden;
  aspect-ratio: 9 / 16;
  width: min(100%, calc((100vh - 150px) * 9 / 16));
  max-height: calc(100vh - 150px);
  margin: 0 auto;
  position: relative;
  cursor: crosshair;
  user-select: none;
  touch-action: none;
  flex: 1;
  min-height: 0;
}

.phone-frame video,
.phone-frame img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  pointer-events: none;
}

.phone-placeholder {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 0.95rem;
  text-align: center;
  padding: 20px;
}

.stream-toolbar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 12px;
  align-items: center;
}

.view-mode-toggle {
  display: inline-flex;
  gap: 4px;
  padding: 3px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg);
}

.view-mode-toggle .btn.is-active {
  background: var(--accent, #2563eb);
  border-color: transparent;
  color: #fff;
}

.reading-status {
  font-size: 0.82rem;
  color: var(--muted);
  margin: -4px 0 10px;
  min-height: 1.2em;
}

.reading-status[data-type="ok"] {
  color: var(--ok, #22c55e);
}

.reading-status[data-type="err"] {
  color: var(--danger, #ef4444);
}

.phone-frame .reading-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  pointer-events: none;
  z-index: 2;
}

.phone-frame.reading-active {
  cursor: pointer;
}

.phone-frame.reading-active .reading-canvas {
  pointer-events: none;
}

.control-panel .row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 10px;
}

.control-panel .section-title {
  font-size: 0.82rem;
  color: var(--muted);
  margin: 12px 0 8px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.control-panel > h3 {
  flex-shrink: 0;
  margin-bottom: 4px;
}

.log-box {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px;
  max-height: 150px;
  overflow-y: auto;
  font-family: ui-monospace, monospace;
  font-size: 0.78rem;
  color: var(--muted);
  margin-top: 6px;
}

.control-log-dock .log-box {
  max-height: 132px;
  margin-top: 0;
}

.log-box .line {
  margin-bottom: 4px;
}

.log-box .line.err {
  color: var(--danger);
}

.log-box .line.ok {
  color: var(--success);
}

.token-box {
  background: var(--bg);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  padding: 12px;
  font-family: ui-monospace, monospace;
  font-size: 0.82rem;
  word-break: break-all;
  margin: 10px 0;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: grid;
  place-items: center;
  z-index: 100;
  padding: 20px;
}

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 24px;
  max-width: 520px;
  width: 100%;
  box-shadow: var(--shadow);
}

.modal h3 {
  margin-bottom: 12px;
}

.hidden {
  display: none !important;
}

.badge-role-admin {
  background: rgba(245, 158, 11, 0.18);
  color: var(--warning);
}

.badge-role-distributor {
  background: rgba(59, 130, 246, 0.18);
  color: #93c5fd;
}

.badge-role-member {
  background: rgba(34, 197, 94, 0.15);
  color: var(--success);
}

.badge-disabled {
  background: rgba(239, 68, 68, 0.15);
  color: var(--danger);
}

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

.form-row input,
.form-row select {
  width: 100%;
  padding: 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
}

.activate-fields {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 12px;
}

@media (max-width: 560px) {
  .activate-fields {
    grid-template-columns: 1fr;
  }
}

.input-with-unit {
  display: flex;
  align-items: center;
  gap: 8px;
}

.input-with-unit input {
  flex: 1;
  min-width: 0;
  padding: 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
}

.input-unit {
  flex-shrink: 0;
  color: var(--muted);
  font-size: 0.9rem;
  min-width: 2em;
}

.cloud-version {
  color: var(--muted);
  font-size: 0.8rem;
  margin-top: 6px;
}

.login-version {
  text-align: center;
  margin-top: 16px;
  font-size: 0.85rem;
  color: var(--muted);
}

.panel {
  display: none;
}

.panel.active {
  display: block;
}

.actions-inline {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.modal.wide {
  max-width: 720px;
}

.user-meta {
  font-size: 0.82rem;
  color: var(--muted);
  margin-top: 2px;
}

/* 应用打包页内分区跳转 */
.apps-jump {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 16px;
}

.apps-jump a {
  display: inline-flex;
  align-items: center;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text);
  font-size: 0.82rem;
  text-decoration: none;
}

.apps-jump a:hover {
  border-color: var(--accent);
  color: var(--accent);
  text-decoration: none;
}

.apps-jump a.hidden {
  display: none;
}

#appsInjectBlock {
  display: flex;
  flex-direction: column;
  gap: 0;
}

#appsInjectBlock.hidden {
  display: none;
}

/* 列表行：文件名与操作贴在一起，避免宽屏左右分离 */
.entity-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}

.entity-row:last-child {
  border-bottom: none;
}

.entity-row .entity-main {
  flex: 1 1 220px;
  min-width: 0;
}

.entity-row .entity-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  flex: 0 0 auto;
}

.entity-row .entity-title {
  font-size: 0.95rem;
  word-break: break-word;
}

.progress-track {
  height: 8px;
  max-width: 420px;
  background: var(--border);
  border-radius: 4px;
  overflow: hidden;
}

.progress-track > div {
  height: 100%;
  background: var(--accent);
  transition: width 0.35s ease;
}

.job-card {
  margin-bottom: 10px;
  padding: 12px 14px;
}

.job-card .progress-track {
  margin: 8px 0;
  max-width: 100%;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 999px;
}

.job-card .progress-track > div {
  background: linear-gradient(90deg, #4f8cff, #7c5cff);
}

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

.file-field {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 14px;
}

.file-field input[type="file"] {
  max-width: 100%;
}

/* 独立设备文件管理器 */
.file-manager-page {
  overflow-x: hidden;
}

.file-manager-shell {
  min-height: 100vh;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.file-manager-header,
.file-manager-header-actions,
.file-manager-toolbar,
.file-search-bar,
.file-path-bar,
.file-taskbar {
  display: flex;
  align-items: center;
  gap: 10px;
}

.file-manager-header {
  justify-content: space-between;
}

.file-manager-header h2 {
  margin-bottom: 3px;
}

.file-manager-toolbar,
.file-search-bar,
.file-taskbar {
  padding: 12px;
}

.file-path-bar {
  flex: 1;
}

.file-path-bar input,
.file-search-bar input {
  min-width: 0;
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--bg);
  color: var(--text);
}

.file-path-bar input {
  flex: 1;
  font-family: Consolas, monospace;
}

.file-search-bar input:first-child {
  flex: 1;
}

.file-search-bar #extensionInput {
  width: 170px;
}

.file-upload-label {
  white-space: nowrap;
}

.file-manager-grid {
  flex: 1;
  min-height: 480px;
  display: grid;
  grid-template-columns: 190px minmax(460px, 1fr) 310px;
  gap: 12px;
}

.file-places,
.file-browser,
.file-details {
  min-height: 0;
  padding: 14px;
}

.file-places nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.file-places nav button,
.file-breadcrumbs button {
  border: 0;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  text-align: left;
}

.file-places nav button {
  padding: 9px 10px;
  border-radius: 7px;
}

.file-places nav button:hover {
  background: var(--surface2);
}

.file-scope-note {
  margin-top: 20px;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.65;
}

.file-scope-note code {
  color: var(--text);
}

.file-browser {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.file-breadcrumbs {
  min-height: 38px;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 5px;
  padding: 0 4px 10px;
  border-bottom: 1px solid var(--border);
}

.file-breadcrumbs button {
  color: var(--accent);
  padding: 3px 4px;
}

.file-breadcrumb-separator {
  color: var(--muted);
}

.file-table-wrap {
  flex: 1;
  overflow: auto;
}

.file-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

.file-table th,
.file-table td {
  padding: 11px 12px;
  border-bottom: 1px solid rgba(45, 63, 86, 0.65);
  text-align: left;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--surface);
  color: var(--muted);
  font-size: 0.78rem;
}

.file-table th:first-child {
  width: 46%;
}

.file-table th:nth-child(2) {
  width: 15%;
}

.file-table th:nth-child(3) {
  width: 13%;
}

.file-table tbody tr {
  cursor: pointer;
}

.file-table tbody tr:hover,
.file-table tbody tr.is-selected {
  background: var(--surface2);
}

.file-table tbody tr.is-selected {
  outline: 1px solid var(--accent);
  outline-offset: -1px;
}

.file-name-cell {
  font-weight: 600;
}

.file-name-cell span {
  margin-right: 9px;
}

.file-empty {
  padding: 30px 12px !important;
  text-align: center !important;
  color: var(--muted);
}

.file-details {
  overflow: auto;
}

.file-detail-icon {
  margin: 12px 0 5px;
  font-size: 2.4rem;
}

.file-details h3 {
  overflow-wrap: anywhere;
}

.file-details dl {
  margin-top: 14px;
}

.file-details dt {
  margin-top: 10px;
  color: var(--muted);
  font-size: 0.75rem;
}

.file-details dd {
  margin-top: 2px;
  overflow-wrap: anywhere;
  font-size: 0.86rem;
}

.file-detail-actions,
.file-apk-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 18px;
}

.file-apk-panel {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.file-hash {
  font-family: Consolas, monospace;
  font-size: 0.72rem !important;
}

.file-permissions {
  max-height: 120px;
  overflow: auto;
  padding: 7px;
  background: var(--bg);
  border-radius: 6px;
  font-family: Consolas, monospace;
  font-size: 0.7rem !important;
}

.file-taskbar {
  justify-content: space-between;
  min-height: 50px;
}

.file-taskbar strong {
  margin-right: 12px;
}

.file-taskbar span {
  color: var(--muted);
}

.file-taskbar progress {
  width: min(360px, 35vw);
  accent-color: var(--accent);
}

.file-task-error {
  color: var(--danger) !important;
}

@media (max-width: 1050px) {
  .file-manager-grid {
    grid-template-columns: 150px minmax(420px, 1fr);
  }

  .file-details {
    grid-column: 1 / -1;
    min-height: 230px;
  }
}

@media (max-width: 720px) {
  .file-manager-shell {
    padding: 10px;
  }

  .file-manager-header,
  .file-manager-header-actions,
  .file-manager-toolbar,
  .file-search-bar,
  .file-taskbar {
    align-items: stretch;
    flex-wrap: wrap;
  }

  .file-path-bar {
    flex-basis: 100%;
    order: -1;
  }

  .file-search-bar input,
  .file-search-bar #extensionInput {
    width: 100%;
    flex-basis: 100%;
  }

  .file-manager-grid {
    display: flex;
    flex-direction: column;
  }

  .file-places nav {
    flex-direction: row;
    flex-wrap: wrap;
  }

  .file-table {
    min-width: 620px;
  }
}

/* 顶部短信弹窗 */
.sms-send-modal {
  width: min(620px, calc(100vw - 32px));
}

.sms-modal-header,
.sms-modal-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.sms-modal-header {
  margin-bottom: 20px;
}

.sms-modal-header p {
  margin-top: 5px;
  color: var(--muted);
  font-size: 0.84rem;
}

.sms-send-modal textarea,
.ai-ops-page textarea,
.ai-ops-page select,
.ai-ops-page input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
}

.sms-send-modal textarea,
.ai-ops-page textarea {
  resize: vertical;
}

/* 独立 AI 运维页面 */
.ai-ops-shell {
  min-height: 100vh;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.ai-ops-grid {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(300px, 360px) minmax(520px, 1fr);
  gap: 14px;
}

.ai-config-panel,
.ai-task-panel {
  padding: 18px;
  min-height: 0;
}

.ai-help {
  margin: 5px 0 18px;
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.65;
}

.ai-config-status {
  margin-top: 10px;
  overflow-wrap: anywhere;
}

.ai-history-title {
  margin-top: 30px;
}

.ai-task-history {
  margin-top: 8px;
  max-height: 320px;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.ai-task-history button {
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  text-align: left;
  cursor: pointer;
}

.ai-task-history button:hover {
  border-color: var(--accent);
}

.ai-task-history strong,
.ai-task-history span {
  display: block;
}

.ai-task-history strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ai-task-history span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.73rem;
}

.ai-goal-compose {
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
}

.ai-goal-compose textarea {
  min-height: 110px;
  border: 0;
  padding: 4px;
}

.ai-goal-compose textarea:focus {
  outline: none;
}

.ai-goal-actions,
.ai-steps-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.ai-goal-actions {
  justify-content: flex-end;
  margin-top: 8px;
}

.ai-task-status {
  margin: 14px 0;
  padding: 11px 13px;
  border-radius: 8px;
  background: var(--surface2);
  color: var(--muted);
}

.ai-status-running,
.ai-status-pending {
  color: var(--accent);
}

.ai-status-done {
  color: var(--success);
}

.ai-status-failed,
.ai-status-cancelled {
  color: var(--danger);
}

.ai-status-awaiting_confirm {
  color: var(--warning);
}

.ai-confirm-box {
  margin-bottom: 15px;
  padding: 14px;
  border: 1px solid var(--warning);
  border-radius: 9px;
  background: rgba(245, 158, 11, 0.08);
}

.ai-confirm-box strong {
  color: var(--warning);
}

.ai-confirm-box #aiConfirmText {
  margin: 9px 0 12px;
  overflow-wrap: anywhere;
}

.ai-steps-header {
  margin-top: 18px;
}

.ai-steps-box {
  height: min(52vh, 560px);
  margin-top: 8px;
  padding: 8px;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--bg);
}

.ai-step {
  display: grid;
  grid-template-columns: 34px 1fr;
  gap: 10px;
  padding: 12px 8px;
  border-bottom: 1px solid var(--border);
}

.ai-step:last-child {
  border-bottom: 0;
}

.ai-step-index {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--surface2);
  color: var(--accent);
  font-size: 0.76rem;
}

.ai-step-data,
.ai-step-result {
  margin-top: 6px;
  padding: 7px 9px;
  border-radius: 6px;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
  font: 0.76rem/1.5 Consolas, monospace;
}

.ai-step-data {
  background: var(--surface2);
  color: var(--muted);
}

.ai-step-result {
  background: rgba(34, 197, 94, 0.07);
}

@media (max-width: 900px) {
  .ai-ops-grid {
    grid-template-columns: 1fr;
  }

  .ai-steps-box {
    height: 480px;
  }
}

@media (max-width: 600px) {
  .ai-ops-shell {
    padding: 10px;
  }

  .sms-modal-header,
  .sms-modal-actions {
    align-items: stretch;
    flex-direction: column;
  }
}


