:root {
  color-scheme: light;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #1d252c;
  background: #f4f6f7;
  line-height: 1.4;
  letter-spacing: 0;
  --line: #dce1e5;
  --muted: #68747d;
  --green: #147b66;
  --blue: #2767b2;
  --red: #b13a3a;
  --amber: #9b6714;
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; }
button, input, select, textarea { font: inherit; letter-spacing: 0; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .48; }
input, select, textarea { width: 100%; border: 1px solid #c9d0d5; border-radius: 5px; background: #fff; color: #1d252c; }
input, select { height: 36px; padding: 0 10px; }
textarea { min-height: 132px; padding: 10px; resize: vertical; line-height: 1.5; }
input:focus, select:focus, textarea:focus { outline: 2px solid #b6d9f4; border-color: #3479ba; }

.admin-login { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 20px; background: #eef1f3; }
.admin-login-panel { width: min(390px, 100%); padding: 28px; border: 1px solid var(--line); border-radius: 7px; background: #fff; box-shadow: 0 18px 54px rgba(29, 37, 44, .16); }
.admin-login-panel .brand { padding: 0 0 28px; }
.admin-login-panel h1 { margin: 0; font-size: 20px; }
.admin-login-panel p { margin: 7px 0 22px; color: var(--muted); font-size: 13px; }
.admin-login-panel label { margin-bottom: 6px; }
.admin-password-confirmation { margin-top: 14px; }
.admin-login-panel .button { width: 100%; margin-top: 10px; }
.admin-login-error { min-height: 20px; padding-top: 5px; color: var(--red); font-size: 12px; }

.shell { min-height: 100vh; display: grid; grid-template-columns: 196px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100vh; border-right: 1px solid var(--line); background: #fff; padding: 18px 12px; }
.brand { display: flex; align-items: center; gap: 9px; padding: 0 8px 20px; font-weight: 750; }
.brand-mark { width: 25px; height: 25px; border-radius: 5px; background: #202a32; box-shadow: inset 5px 0 #25b7a1, inset -4px 0 #e15368; }
.side-label { padding: 8px 10px 6px; color: #929ba2; font-size: 11px; }
nav { display: grid; gap: 4px; }
.nav-item { height: 40px; border: 0; border-radius: 5px; padding: 0 11px; text-align: left; color: #4b5862; background: transparent; font-weight: 650; }
.nav-link { display: flex; align-items: center; text-decoration: none; }
.nav-link:focus-visible { outline: 2px solid #b6d9f4; outline-offset: 1px; }
.nav-item.active { color: #126553; background: #e9f5f1; box-shadow: none; }
.api-path { position: absolute; bottom: 16px; left: 20px; color: #849099; font: 11px ui-monospace, SFMono-Regular, Menlo, monospace; }

.main { min-width: 0; }
.topbar { height: 58px; display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 0 24px; border-bottom: 1px solid var(--line); background: #fff; }
.topbar h1 { margin: 0; font-size: 17px; }
.connection { display: inline-flex; align-items: center; gap: 7px; color: var(--muted); font-size: 12px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: #b8c0c5; }
.dot.active { background: #28a17d; }

.section { display: none; }
.active-section { display: block; }
.inline-admin-form { display: grid; grid-template-columns: minmax(180px, 260px) minmax(260px, 1fr) auto; gap: 12px; align-items: start; padding: 16px; border-bottom: 1px solid var(--line); }
.inline-admin-form input { min-height: 40px; }
.choice-list { display: flex; flex-wrap: wrap; gap: 8px 14px; min-height: 40px; align-items: center; }
.choice-list label { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; }
.choice-list input { min-height: auto; }
.view-head { min-height: 76px; display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 14px 24px; border-bottom: 1px solid var(--line); background: #fff; }
.view-title h2 { margin: 0; font-size: 16px; }
.view-title p { margin: 5px 0 0; color: var(--muted); font-size: 12px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }
.button, .primary, .secondary { height: 36px; border: 1px solid #c5cdd2; border-radius: 5px; padding: 0 13px; background: #fff; color: #253039; font-weight: 650; white-space: nowrap; }
.button.primary, .primary { border-color: var(--green); background: var(--green); color: #fff; }
.button.danger, .danger { border-color: #e3b8b8; color: var(--red); }

.toolbar { min-height: 58px; display: flex; align-items: center; gap: 9px; padding: 10px 24px; border-bottom: 1px solid var(--line); background: #fafbfb; }
.search { width: min(360px, 100%); }
.summary { margin-left: auto; color: var(--muted); font-size: 12px; }
.summary span { font-weight: 750; color: #253039; }

.task-workspace { display: grid; grid-template-columns: minmax(0, 1fr) 380px; min-height: calc(100vh - 134px); }
.task-results { min-width: 0; border-right: 1px solid var(--line); }
.table-wrap { width: 100%; overflow: auto; background: #fff; }
table { width: 100%; min-width: 840px; border-collapse: collapse; }
th { height: 40px; padding: 0 12px; border-bottom: 1px solid var(--line); color: #748089; background: #f8f9fa; text-align: left; font-size: 11px; font-weight: 700; }
td { padding: 11px 12px; border-bottom: 1px solid #e9edef; font-size: 12px; vertical-align: middle; }
tbody tr:hover { background: #f8fbfa; }
.empty { padding: 56px 24px; color: #7d8991; text-align: center; background: #fff; }
.task-toolbar { align-items: center; }
.task-toolbar .search { min-width: 220px; }
.task-filter { width: 148px; flex: 0 0 148px; }
.task-table { min-width: 1120px; table-layout: fixed; }
.task-table th:nth-child(1) { width: 24%; }
.task-table th:nth-child(2) { width: 15%; }
.task-table th:nth-child(3) { width: 17%; }
.task-table th:nth-child(4) { width: 16%; }
.task-table th:nth-child(5) { width: 14%; }
.task-table th:nth-child(6) { width: 14%; }
.task-main-cell, .task-status-cell { min-width: 0; }
.task-prompt { display: -webkit-box; overflow: hidden; color: #1d252c; font-size: 12px; font-weight: 700; line-height: 1.45; overflow-wrap: anywhere; -webkit-box-orient: vertical; -webkit-line-clamp: 3; }
.task-meta { display: flex; align-items: center; flex-wrap: wrap; gap: 5px 9px; margin-top: 7px; color: var(--muted); font-size: 10px; }
.task-meta span:first-child { color: #376072; font-weight: 700; }
.task-meta span:last-child { overflow: hidden; max-width: 100%; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; text-overflow: ellipsis; white-space: nowrap; }
.task-progress { width: 100%; height: 4px; overflow: hidden; margin-top: 8px; border-radius: 2px; background: #e7ebee; }
.task-progress span { display: block; height: 100%; border-radius: inherit; background: #4c8d7e; }
.task-status-message { margin-top: 6px; color: #5e6b74; font-size: 11px; line-height: 1.4; overflow-wrap: anywhere; }
.credit-flow { display: grid; gap: 5px; }
.credit-flow > div { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.credit-flow span { color: var(--muted); font-size: 10px; }
.credit-flow strong { color: #263139; font-size: 11px; font-variant-numeric: tabular-nums; }
.credit-flow .credit-spent { margin-top: 2px; padding-top: 6px; border-top: 1px solid #e5e9ec; }
.credit-flow .credit-spent strong { color: #9b531b; }
.credit-note { color: var(--amber); font-size: 10px; line-height: 1.35; }
.task-config { color: #34414a; font-size: 11px; line-height: 1.45; overflow-wrap: anywhere; }
.task-result-cell { min-height: 28px; margin-bottom: 5px; }

.composer { padding: 18px; background: #fff; }
.seedance-composer { background: #f7f9fc; }
.composer-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.composer-head h3 { margin: 0; color: #172033; font-size: 17px; }
.composer-head p { margin: 5px 0 0; color: #68758a; font-size: 12px; line-height: 1.4; }
.composer-badge { display: inline-flex; align-items: center; min-height: 24px; padding: 0 8px; border-radius: 999px; color: #1264ff; background: #eaf0ff; font-size: 11px; font-weight: 700; white-space: nowrap; }
.composer-badge.ready { color: #126651; background: #e7f5f0; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
label { display: grid; gap: 5px; color: #59656e; font-size: 11px; }
.full { grid-column: 1 / -1; }
.dropzone { min-height: 116px; display: grid; place-items: center; border: 1px dashed #aeb8bf; border-radius: 6px; background: #fafbfb; color: #5d6972; text-align: center; }
.dropzone.dragging { border-color: var(--green); background: #eef8f5; }
.upload-button { border: 0; color: var(--blue); background: transparent; font-weight: 700; }
.drop-hint { margin-top: 7px; color: #8491a4; font-size: 11px; }
.submit-row { display: flex; align-items: center; gap: 10px; margin-top: 12px; }
.submit-row .button { flex: 1; }

.task-asset-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 7px; }
.task-asset-card { display: grid; grid-template-columns: 48px minmax(0, 1fr) auto; align-items: center; gap: 8px; padding: 7px; border: 1px solid var(--line); border-radius: 6px; background: #fff; }
.task-asset-preview { width: 48px; height: 40px; object-fit: cover; border-radius: 4px; background: #eef1f3; }
.task-asset-meta { min-width: 0; }
.task-asset-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 11px; font-weight: 700; }
.task-asset-size { margin-top: 2px; color: var(--muted); font-size: 10px; }
.task-asset-remove { width: 24px; height: 24px; border: 0; border-radius: 50%; color: #fff; background: rgba(20, 25, 29, .78); font-size: 16px; line-height: 1; }

.account-name { font-weight: 700; }
.account-identity { min-width: 150px; max-width: 260px; overflow-wrap: anywhere; }
.account-phone, .account-id, .muted { color: var(--muted); font-size: 11px; margin-top: 3px; }
.status { display: inline-flex; align-items: center; min-height: 23px; gap: 6px; border-radius: 999px; padding: 0 7px; color: #54616a; background: #eef1f3; font-size: 11px; font-weight: 700; white-space: nowrap; }
.status.available { color: #126651; background: #e7f5f0; }
.status.revoked { color: #9f3030; background: #fbeaea; }
.status.pending { color: #8b5a0d; background: #fbf1db; }
.status.neutral { color: #54616a; background: #eef1f3; }
.status-dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.row-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.row-actions button, .task-result-link { min-height: 28px; display: inline-flex; align-items: center; border: 1px solid #c5cdd2; border-radius: 5px; padding: 0 9px; color: #253039; background: #fff; font-size: 11px; font-weight: 650; text-decoration: none; }
.row-actions button.danger { border-color: #e3b8b8; color: var(--red); }
.task-result-actions { display: flex; gap: 6px; flex-wrap: wrap; }

.notice { position: fixed; right: 18px; bottom: 18px; z-index: 30; max-width: 360px; padding: 11px 14px; border-radius: 6px; color: #fff; background: #26323a; font-size: 12px; box-shadow: 0 8px 28px rgba(31, 42, 50, .2); }
.notice.error { background: #9f3434; color: #fff; }
.notice.success { background: #26323a; color: #fff; }
.hidden { display: none !important; }

.result-policy, .result-form, .result-preview-wrap, .log-list { margin: 18px 24px; }
.result-policy { display: flex; flex-wrap: wrap; gap: 8px 18px; padding: 12px 14px; border: 1px solid #ead9a8; border-radius: 6px; background: #fffaf0; color: #705518; font-size: 12px; }
.result-form { display: grid; grid-template-columns: minmax(160px, 1fr) minmax(180px, 1fr) minmax(140px, .7fr) auto; gap: 10px; align-items: end; }
.result-form-actions, .login-actions { display: flex; gap: 8px; }
.json-preview { min-height: 190px; max-height: 280px; overflow: auto; margin: 0; padding: 14px; border: 1px solid var(--line); border-radius: 6px; background: #f8faf9; color: #3b5d52; font: 12px/1.55 ui-monospace, SFMono-Regular, Menlo, monospace; white-space: pre-wrap; }
.preview-label { margin-bottom: 6px; color: #7b8985; font-size: 12px; font-weight: 700; }
.log-list { display: grid; gap: 8px; }
.log-item { background: #fff; border: 1px solid var(--line); border-radius: 6px; padding: 13px 15px; display: flex; justify-content: space-between; gap: 16px; }
.log-detail { color: var(--muted); margin-top: 3px; font-size: 12px; }
.log-time { color: #9aa6a2; font-size: 11px; white-space: nowrap; }

.login-modal { position: fixed; inset: 0; background: rgba(31, 39, 45, .38); display: grid; place-items: center; padding: 20px; z-index: 20; }
.login-dialog { width: min(720px, 100%); background: #fff; border: 1px solid var(--line); border-radius: 7px; box-shadow: 0 18px 60px rgba(31, 42, 50, .22); overflow: hidden; }
.login-dialog-head { display: flex; justify-content: space-between; align-items: center; padding: 16px 18px; border-bottom: 1px solid var(--line); }
.login-dialog-head h2 { margin: 4px 0 0; font-size: 15px; }
.eyebrow { color: #929ba2; font-size: 11px; }
.icon-close { width: 31px; height: 31px; border: 0; border-radius: 50%; background: #eef1f3; color: #4f5a62; font-size: 18px; }
.login-dialog-body, .account-form { padding: 18px; }
.login-info { display: flex; gap: 14px; padding: 12px; border: 1px solid var(--line); background: #fafbfb; border-radius: 6px; }
.login-info p, .account-form p { margin: 6px 0 0; color: var(--muted); font-size: 12px; }
.secure-icon { width: 28px; height: 28px; border-radius: 5px; background: #e9f5f1; color: var(--green); display: grid; place-items: center; font-weight: 800; }
.account-dialog { width: min(520px, 100%); }
.account-form label { margin-bottom: 7px; }
.account-form input + label { margin-top: 14px; }
.account-form textarea { min-height: 220px; }

.vnc-modal { position: fixed; inset: 0; background: rgba(31, 39, 45, .52); display: grid; place-items: center; padding: 18px; z-index: 25; }
.vnc-dialog { width: min(1180px, 100%); height: min(780px, calc(100vh - 36px)); background: #fff; border-radius: 7px; box-shadow: 0 18px 60px rgba(31, 42, 50, .3); overflow: hidden; display: grid; grid-template-rows: auto minmax(0, 1fr) auto auto; }
.vnc-dialog-head { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.vnc-dialog-head h2 { margin: 3px 0 0; font-size: 15px; }
.vnc-head-actions { display: flex; align-items: center; gap: 8px; }
.vnc-frame-wrap { position: relative; min-height: 0; background: #1d252c; }
.vnc-frame-wrap iframe { width: 100%; height: 100%; border: 0; display: block; background: #1d252c; }
.vnc-offline { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; padding: 20px; text-align: center; color: #d9e2df; }
.vnc-offline p { max-width: 100%; margin: 8px 0 0; color: #9eaaa6; font-size: 13px; line-height: 1.5; overflow-wrap: anywhere; }
.vnc-login-controls { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 11px 16px; border-top: 1px solid var(--line); background: #f8faf9; }
.vnc-login-copy { min-width: 0; display: grid; gap: 3px; font-size: 12px; }
.vnc-login-copy span { color: var(--muted); line-height: 1.4; }
.vnc-login-actions { display: flex; flex: 0 0 auto; gap: 8px; }
.vnc-footer { padding: 9px 16px; border-top: 1px solid var(--line); color: var(--muted); font-size: 12px; }

@media (max-width: 1100px) {
  .task-workspace { grid-template-columns: 1fr; }
  .task-results { border-right: 0; }
  .composer { border-top: 1px solid var(--line); }
}

@media (max-width: 720px) {
  .inline-admin-form { grid-template-columns: 1fr; }
  .notice { inset: 116px 12px auto; max-width: none; }
  .shell { grid-template-columns: 1fr; padding-bottom: 58px; }
  .sidebar { position: fixed; inset: auto 0 0 0; z-index: 8; width: auto; height: 58px; display: block; border: 1px solid var(--line); padding: 5px; }
  .brand, .side-label, .api-path { display: none; }
  nav { display: flex; overflow-x: auto; }
  .nav-item { flex: 0 0 90px; height: 46px; text-align: center; font-size: 12px; }
  .nav-link { justify-content: center; }
  .topbar { height: 52px; padding: 0 14px; }
  .view-head { min-height: 68px; padding: 10px 14px; }
  .toolbar { flex-wrap: wrap; padding: 9px 14px; }
  .search { flex: 1 1 140px; width: auto; }
  .task-toolbar .search { flex-basis: 100%; min-width: 0; }
  .task-filter { width: auto; flex: 1 1 130px; }
  .task-toolbar .summary { width: 100%; margin-left: 0; }
  .composer { padding: 14px; }
  .form-grid { grid-template-columns: 1fr; }
  .result-form { grid-template-columns: 1fr; }
  .vnc-modal { padding: 0; }
  .vnc-dialog { width: 100%; height: 100vh; border-radius: 0; }
  .vnc-dialog-head, .vnc-login-controls { align-items: flex-start; }
  .vnc-dialog-head, .vnc-login-controls { flex-direction: column; gap: 8px; }
  .vnc-head-actions { width: 100%; overflow-x: auto; }
  .vnc-login-copy span { overflow-wrap: anywhere; }
  .vnc-login-actions { width: 100%; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .vnc-login-actions button { width: 100%; min-width: 0; padding: 0 8px; white-space: normal; line-height: 1.25; }
  .vnc-login-actions .primary { grid-column: 1 / -1; grid-row: 1; }
  .vnc-footer { display: none; }
}
