:root {
  --tg-bg: var(--tg-theme-bg-color, #f5f7fb);
  --tg-card: var(--tg-theme-secondary-bg-color, #ffffff);
  --tg-text: var(--tg-theme-text-color, #101828);
  --tg-muted: var(--tg-theme-hint-color, #667085);
  --tg-link: var(--tg-theme-link-color, #2481cc);
  --tg-button: var(--tg-theme-button-color, #2aabee);
  --tg-button-text: var(--tg-theme-button-text-color, #ffffff);
  --ok: #12b76a;
  --warn: #f79009;
  --bad: #f04438;
  --line: rgba(127, 127, 127, 0.18);
  --shadow: 0 10px 30px rgba(15, 23, 42, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--tg-text);
  background: var(--tg-bg);
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

a {
  color: var(--tg-link);
  text-decoration: underline;
  text-underline-offset: 2px;
}

button,
input,
textarea,
select {
  font: inherit;
}

.app-shell {
  min-height: 100vh;
  padding: calc(env(safe-area-inset-top) + 14px) 14px calc(env(safe-area-inset-bottom) + 86px);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.eyebrow {
  margin: 0 0 2px;
  color: var(--tg-link);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 28px;
  line-height: 1.1;
}

h2 {
  margin-bottom: 12px;
  font-size: 20px;
}

h3 {
  margin-bottom: 8px;
  font-size: 16px;
}

.content {
  display: grid;
  gap: 14px;
}

.office-home {
  display: grid;
  gap: 18px;
  margin: -2px -2px 0;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 18px;
  padding: 18px 16px 20px;
  background: linear-gradient(145deg, rgba(31, 34, 44, 0.98), rgba(12, 14, 20, 0.98));
  color: #ffffff;
  box-shadow: 0 18px 45px rgba(0, 0, 0, 0.28);
}

.tasks-board {
  display: grid;
  gap: 14px;
}

.new-task-board {
  display: grid;
  gap: 14px;
}

.server-board {
  display: grid;
  gap: 14px;
  margin: -2px -2px 0;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 18px;
  padding: 16px;
  background: linear-gradient(145deg, rgba(31, 34, 44, 0.98), rgba(12, 14, 20, 0.98));
  color: #ffffff;
  box-shadow: 0 18px 45px rgba(0, 0, 0, 0.28);
}

.tts-board {
  display: grid;
  gap: 14px;
}

.tts-hero,
.tts-panel,
.tts-form,
.tts-list {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--tg-card);
  box-shadow: var(--shadow);
}

.tts-hero {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 16px;
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--tg-card), #12b76a 8%), var(--tg-card)),
    var(--tg-card);
}

.tts-hero h2 {
  margin-bottom: 6px;
  font-size: 26px;
}

.tts-hero p {
  margin-bottom: 0;
  color: var(--tg-muted);
}

.tts-metrics {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.tts-metric {
  min-height: 84px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: color-mix(in srgb, var(--tg-card), #12b76a 5%);
}

.tts-metric span {
  display: block;
  color: var(--tg-muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.tts-metric strong {
  display: block;
  margin-top: 8px;
  font-size: 24px;
  line-height: 1;
  overflow-wrap: anywhere;
}

.tts-panel,
.tts-form,
.tts-list {
  display: grid;
  gap: 12px;
  padding: 14px;
}

.tts-grid {
  display: grid;
  gap: 14px;
}

.tts-overview-stack {
  display: grid;
  gap: 14px;
}

.tts-intake-form {
  border-color: color-mix(in srgb, var(--tg-link), var(--line) 58%);
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--tg-link), transparent 10%), transparent 42%),
    var(--tg-card);
}

.tts-intake-form h3 {
  margin: 6px 0;
  font-size: 20px;
}

.tts-intake-form .button {
  min-height: 48px;
}

.tts-attachment-box {
  display: grid;
  gap: 10px;
}

.tts-attachment-box .attachment-heading span:first-child {
  color: var(--tg-text);
}

.tts-attachment-picker {
  border-color: color-mix(in srgb, var(--tg-link), var(--line) 36%);
  background: color-mix(in srgb, var(--tg-link), var(--tg-card) 90%);
  color: var(--tg-text);
}

.tts-attachment-picker small,
.tts-selected-file small {
  color: var(--tg-muted);
}

.tts-attachment-picker .attachment-plus {
  background: var(--tg-button);
  color: var(--tg-button-text);
}

.tts-selected-file {
  border-color: var(--line);
  background: color-mix(in srgb, var(--tg-card), var(--tg-link) 5%);
  color: var(--tg-text);
}

.tts-selected-file button {
  color: #f04438;
  background: rgba(240, 68, 56, 0.12);
}

.tts-recognition-status {
  border: 1px solid color-mix(in srgb, var(--tg-button), transparent 55%);
  border-radius: 8px;
  padding: 10px;
  background: color-mix(in srgb, var(--tg-button), transparent 88%);
  color: var(--tg-text);
  font-size: 13px;
}

.tts-recognition-status[hidden] {
  display: none;
}

.tts-recognition-result {
  display: grid;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 11px;
  font-size: 13px;
}

.tts-recognition-result.success {
  border-color: rgba(18, 183, 106, 0.35);
  background: rgba(18, 183, 106, 0.1);
}

.tts-recognition-result.error {
  border-color: rgba(240, 68, 56, 0.35);
  background: rgba(240, 68, 56, 0.1);
  color: var(--tg-text);
}

.tts-recognition-result p {
  margin: 0;
  color: var(--tg-muted);
}

.tts-recognition-fields {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tts-recognition-fields span {
  border-radius: 999px;
  padding: 5px 8px;
  background: color-mix(in srgb, var(--tg-card), var(--tg-link) 8%);
}

.tts-ocr-preview {
  border-top: 1px solid var(--line);
  padding-top: 8px;
}

.tts-ocr-preview summary {
  cursor: pointer;
  color: var(--tg-link);
  font-weight: 700;
}

.tts-ocr-preview pre {
  max-height: 180px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px;
  background: color-mix(in srgb, var(--tg-card), #000 4%);
  color: var(--tg-text);
}

.tts-manual-button {
  justify-self: start;
}

.tts-review-screen {
  display: grid;
  gap: 14px;
}

.tts-review-head {
  display: grid;
  gap: 10px;
}

.tts-review-head .button {
  justify-self: start;
}

.tts-review-form {
  gap: 12px;
}

.tts-review-totals {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.tts-total-card,
.tts-readiness,
.tts-line-cost {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: color-mix(in srgb, var(--tg-card), var(--tg-link) 4%);
}

.tts-review-totals.has-warning .tts-total-card:last-child,
.tts-readiness.blocked {
  border-color: rgba(240, 68, 56, 0.35);
  background: rgba(240, 68, 56, 0.1);
}

.tts-readiness.ready {
  border-color: rgba(18, 183, 106, 0.35);
  background: rgba(18, 183, 106, 0.1);
}

.tts-total-card,
.tts-line-cost {
  display: grid;
  gap: 4px;
}

.tts-total-card span,
.tts-line-cost span {
  color: var(--tg-muted);
  font-size: 12px;
  font-weight: 800;
}

.tts-review-lines {
  display: grid;
  gap: 10px;
}

.tts-review-line {
  display: grid;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: color-mix(in srgb, var(--tg-card), #fff 3%);
}

.tts-review-line-grid {
  display: grid;
  grid-template-columns: minmax(180px, 1.4fr) minmax(84px, 0.5fr) minmax(120px, 0.8fr) minmax(120px, 0.8fr);
  gap: 8px;
}

.tts-review-line select,
.tts-review-line input {
  min-width: 0;
}

.tts-line-meta,
.tts-review-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.tts-doc-preview {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: color-mix(in srgb, var(--tg-card), var(--tg-link) 3%);
}

.tts-doc-preview pre {
  max-height: 220px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px;
}

.tts-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: color-mix(in srgb, var(--tg-card), var(--tg-link) 3%);
}

.tts-row p {
  margin: 4px 0 0;
  color: var(--tg-muted);
  font-size: 13px;
}

.tts-summary-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.tts-summary-row span {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: color-mix(in srgb, var(--tg-card), var(--tg-button) 4%);
}

.tts-table {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.tts-table table {
  width: 100%;
  min-width: 620px;
  border-collapse: collapse;
}

.tts-table th,
.tts-table td {
  border-bottom: 1px solid var(--line);
  padding: 9px 10px;
  text-align: left;
  vertical-align: top;
}

.tts-table th {
  background: color-mix(in srgb, var(--tg-card), var(--tg-link) 6%);
  color: var(--tg-muted);
  font-size: 12px;
  font-weight: 850;
}

.tts-table td {
  font-size: 13px;
}

.tts-table tr:last-child td {
  border-bottom: 0;
}

.tts-form-error {
  border: 1px solid rgba(240, 68, 56, 0.28);
  border-radius: 8px;
  padding: 10px;
  background: rgba(240, 68, 56, 0.1);
  color: var(--bad);
}

.tts-form-error[hidden] {
  display: none;
}

@media (max-width: 720px) {
  .tts-review-totals,
  .tts-review-line-grid {
    grid-template-columns: 1fr;
  }
}

.agents-board {
  display: grid;
  gap: 14px;
  margin: -2px -2px 0;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 18px;
  padding: 16px;
  background: linear-gradient(145deg, rgba(31, 34, 44, 0.98), rgba(12, 14, 20, 0.98));
  color: #ffffff;
  box-shadow: 0 18px 45px rgba(0, 0, 0, 0.28);
}

.tasks-hero,
.tasks-panel,
.new-task-hero,
.new-task-panel {
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 18px;
  padding: 16px;
  background: linear-gradient(145deg, rgba(31, 34, 44, 0.98), rgba(12, 14, 20, 0.98));
  color: #ffffff;
  box-shadow: 0 18px 45px rgba(0, 0, 0, 0.2);
}

.tasks-hero,
.new-task-hero {
  display: grid;
  justify-items: start;
  gap: 8px;
}

.server-hero {
  display: grid;
  justify-items: start;
  gap: 8px;
  padding: 4px 2px 8px;
}

.agents-hero {
  display: grid;
  justify-items: start;
  gap: 8px;
  padding: 4px 2px 8px;
}

.tasks-hero h2,
.new-task-hero h2,
.server-hero h2,
.agents-hero h2 {
  margin-bottom: 0;
  font-size: 32px;
  line-height: 1.05;
}

.tasks-hero p,
.new-task-hero p,
.server-hero p,
.agents-hero p {
  margin-bottom: 0;
  color: rgba(255, 255, 255, 0.66);
}

.server-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.server-metric,
.server-panel {
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.05);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.server-metric {
  display: grid;
  gap: 10px;
  min-height: 132px;
  padding: 14px;
}

.server-metric-head {
  display: grid;
  gap: 6px;
}

.server-metric-head span {
  color: rgba(255, 255, 255, 0.58);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.server-metric-head strong {
  font-size: 25px;
  line-height: 1;
  overflow-wrap: anywhere;
}

.server-metric p,
.server-panel p {
  margin-bottom: 0;
  color: rgba(255, 255, 255, 0.62);
  font-size: 13px;
}

.server-board .progress {
  background: rgba(255, 255, 255, 0.1);
}

.server-panel {
  display: grid;
  gap: 12px;
  padding: 14px;
}

.server-panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.server-panel h3 {
  margin-bottom: 2px;
  color: #ffffff;
}

.server-auth {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  max-width: 45%;
  border-radius: 999px;
  padding: 6px 10px;
  background: rgba(247, 144, 9, 0.16);
  color: #ffe0a6;
  font-size: 12px;
  font-weight: 850;
  text-align: center;
}

.server-auth.ok {
  background: rgba(18, 183, 106, 0.16);
  color: #bff2d1;
}

.server-details {
  overflow: auto;
  max-height: 92px;
  border-radius: 12px;
  padding: 10px;
  background: rgba(0, 0, 0, 0.16);
  white-space: pre-wrap;
  word-break: break-word;
}

.server-empty {
  border: 1px dashed rgba(255, 255, 255, 0.14);
  border-radius: 12px;
  padding: 14px;
  color: rgba(255, 255, 255, 0.62);
  text-align: center;
}

.tasks-panel,
.new-task-panel {
  display: grid;
  gap: 12px;
}

.tasks-panel .field span,
.new-task-panel .field span {
  color: rgba(255, 255, 255, 0.62);
}

.tasks-panel input,
.tasks-panel select,
.new-task-panel input,
.new-task-panel select,
.new-task-panel textarea {
  border-color: rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.07);
  color: #ffffff;
}

.new-task-panel textarea::placeholder,
.new-task-panel input::placeholder {
  color: rgba(255, 255, 255, 0.42);
}

.selected-agent {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin-top: 6px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 16px;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.06);
}

.selected-agent span:not(.agent-icon) {
  display: block;
  color: rgba(255, 255, 255, 0.6);
  font-size: 12px;
  font-weight: 700;
}

.selected-agent strong {
  display: block;
  color: #ffffff;
  font-size: 16px;
}

.task-tips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.task-tips span {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border-radius: 999px;
  padding: 5px 10px;
  background: rgba(255, 255, 255, 0.08);
  color: rgba(255, 255, 255, 0.68);
  font-size: 12px;
  font-weight: 800;
}

.new-task-actions {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 10px;
}

.new-task-actions .button {
  width: 100%;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

.attachment-composer {
  display: grid;
  gap: 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  padding-top: 13px;
}

.attachment-heading,
.upload-progress > div:first-child {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.attachment-heading span {
  color: #ffffff;
  font-size: 14px;
  font-weight: 850;
}

.attachment-heading small,
.attachment-picker small,
.selected-file small,
.detail-file small {
  display: block;
  color: rgba(255, 255, 255, 0.55);
  font-size: 11px;
}

.attachment-count {
  min-width: 42px;
  border-radius: 999px;
  padding: 5px 9px;
  background: rgba(92, 121, 255, 0.18);
  color: #d9dfff !important;
  text-align: center;
}

.attachment-picker {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  border: 1px dashed rgba(121, 145, 255, 0.7);
  border-radius: 14px;
  padding: 13px;
  background: rgba(92, 121, 255, 0.09);
  color: #ffffff;
  cursor: pointer;
  text-align: left;
}

.attachment-picker:active {
  transform: translateY(1px);
}

.attachment-plus {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  border-radius: 12px;
  background: rgba(92, 121, 255, 0.24);
  color: #ffffff;
  font-size: 24px;
}

.selected-files,
.detail-file-list {
  display: grid;
  gap: 8px;
}

.selected-file,
.detail-file {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  padding: 9px;
  background: rgba(255, 255, 255, 0.055);
}

.selected-file > div,
.detail-file > div {
  min-width: 0;
  flex: 1;
}

.selected-file strong,
.detail-file strong {
  display: block;
  overflow: hidden;
  color: inherit;
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.selected-file button {
  width: 32px;
  height: 32px;
  flex: 0 0 auto;
  border: 0;
  border-radius: 9px;
  background: rgba(240, 68, 56, 0.14);
  color: #ffc8c4;
  cursor: pointer;
  font-size: 20px;
}

.file-type {
  display: grid;
  place-items: center;
  width: 42px;
  height: 38px;
  flex: 0 0 auto;
  border-radius: 10px;
  background: linear-gradient(145deg, #7387ff, #4d5fc7);
  color: #ffffff;
  font-size: 9px;
  font-weight: 900;
}

.attachment-error {
  border: 1px solid rgba(240, 68, 56, 0.3);
  border-radius: 11px;
  padding: 9px 11px;
  background: rgba(240, 68, 56, 0.12);
  color: #ffc8c4;
  font-size: 12px;
}

.attachment-error[hidden],
.upload-progress[hidden] {
  display: none;
}

.upload-progress {
  display: grid;
  gap: 7px;
  border-radius: 12px;
  padding: 10px;
  background: rgba(42, 171, 238, 0.12);
  color: #d5f2ff;
  font-size: 12px;
}

.attachment-detail .detail-file {
  color: var(--tg-text);
  background: color-mix(in srgb, var(--tg-card), var(--tg-link) 4%);
}

.attachment-detail .detail-file small {
  color: var(--tg-muted);
}

.voice-button {
  border-color: rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff;
}

.voice-hint {
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  padding: 10px 12px;
  background: rgba(247, 144, 9, 0.14);
  color: #ffe6b8;
  font-size: 13px;
}

.voice-hint.info {
  background: rgba(42, 171, 238, 0.14);
  color: #c4edff;
}

.voice-hint.success {
  background: rgba(18, 183, 106, 0.14);
  color: #c8f7d8;
}

.voice-hint[hidden] {
  display: none;
}

.task-filter-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.office-hero {
  position: relative;
  display: grid;
  justify-items: center;
  gap: 8px;
  padding: 8px 4px 2px;
  text-align: center;
}

.office-hero h2 {
  margin-bottom: 0;
  font-size: 34px;
  line-height: 1.06;
}

.office-hero p {
  max-width: 320px;
  margin-bottom: 0;
  color: rgba(255, 255, 255, 0.72);
  font-size: 16px;
}

.control-badge,
.office-status,
.live-pill {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  border-radius: 999px;
  padding: 6px 12px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(92, 121, 255, 0.18);
  color: rgba(255, 255, 255, 0.88);
  font-size: 12px;
  font-weight: 800;
}

.office-status {
  background: rgba(18, 183, 106, 0.16);
}

.office-status.status-running {
  background: rgba(42, 171, 238, 0.18);
  color: #bfeaff;
}

.office-status.status-failed {
  background: rgba(240, 68, 56, 0.18);
  color: #ffd1ce;
}

.office-section-title {
  margin: 0 0 12px;
  color: #ffffff;
  font-size: 20px;
}

.agent-tile-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.agent-tile {
  display: grid;
  align-content: space-between;
  min-height: 150px;
  width: 100%;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 18px;
  padding: 14px;
  color: #ffffff;
  cursor: pointer;
  text-align: left;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.22), 0 12px 24px rgba(0, 0, 0, 0.24);
}

.agent-tile:active {
  transform: translateY(1px);
}

.agent-green {
  background: linear-gradient(145deg, #96f75c, #39d978);
}

.agent-blue {
  background: linear-gradient(145deg, #53b8ff, #4987ff);
}

.agent-pink {
  background: linear-gradient(145deg, #ff8aa8, #f05291);
}

.agent-violet {
  background: linear-gradient(145deg, #8d7bff, #5868ee);
}

.agent-orange {
  background: linear-gradient(145deg, #ffd16a, #ff8d36);
}

.agent-mint {
  background: linear-gradient(145deg, #72f2d6, #4ab7ff);
}

.agent-icon {
  display: inline-grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.92);
  color: #151821;
  font-size: 13px;
  font-weight: 900;
}

.agent-name {
  display: block;
  align-self: end;
  margin-top: 20px;
  font-size: 18px;
  font-weight: 900;
  line-height: 1.05;
  overflow-wrap: anywhere;
  text-shadow: 0 1px 12px rgba(0, 0, 0, 0.22);
}

.agent-state {
  margin-top: 6px;
  color: rgba(255, 255, 255, 0.82);
  font-size: 14px;
  font-weight: 800;
}

.agent-state.running {
  color: #e6f8ff;
}

.agent-state.queued {
  color: #fff5d6;
}

.agent-profile-list {
  display: grid;
  gap: 12px;
}

.agent-profile-card {
  display: grid;
  gap: 14px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 18px;
  padding: 14px;
  background: rgba(255, 255, 255, 0.05);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.agent-profile-top,
.agent-profile-identity,
.agent-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.agent-profile-top {
  justify-content: space-between;
}

.agent-profile-identity {
  min-width: 0;
}

.agent-profile-identity h3 {
  margin-bottom: 2px;
  color: #ffffff;
  line-height: 1.08;
}

.agent-profile-identity p,
.agent-profile-description {
  margin-bottom: 0;
  color: rgba(255, 255, 255, 0.62);
}

.agent-status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  border-radius: 999px;
  padding: 6px 10px;
  background: rgba(18, 183, 106, 0.16);
  color: #bff2d1;
  font-size: 12px;
  font-weight: 850;
  white-space: nowrap;
}

.agent-status-pill.running {
  background: rgba(42, 171, 238, 0.18);
  color: #bfeaff;
}

.agent-status-pill.queued {
  background: rgba(247, 144, 9, 0.16);
  color: #ffe0a6;
}

.agent-profile-glow {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  min-height: 94px;
  border-radius: 18px;
  padding: 14px;
  color: #ffffff;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.18), 0 14px 28px rgba(0, 0, 0, 0.22);
}

.agent-profile-glow span {
  display: inline-grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.9);
  color: #151821;
  font-size: 13px;
  font-weight: 900;
}

.agent-profile-glow strong {
  max-width: 66%;
  text-align: right;
  font-size: 20px;
  line-height: 1.05;
  overflow-wrap: anywhere;
}

.agent-mini-stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.agent-mini-stats span {
  display: grid;
  gap: 2px;
  min-height: 58px;
  border-radius: 14px;
  padding: 9px 10px;
  background: rgba(255, 255, 255, 0.06);
  color: rgba(255, 255, 255, 0.6);
  font-size: 12px;
  font-weight: 800;
}

.agent-mini-stats strong {
  color: #ffffff;
  font-size: 18px;
  line-height: 1.05;
  overflow-wrap: anywhere;
}

.agent-actions {
  align-items: stretch;
}

.agent-actions .button {
  flex: 1 1 0;
  min-width: 0;
}

.office-summary {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 18px;
  padding: 18px;
  background: rgba(255, 255, 255, 0.04);
}

.office-summary p {
  margin-bottom: 0;
}

.office-summary .muted {
  color: rgba(255, 255, 255, 0.58);
}

.office-summary strong {
  display: block;
  margin: 8px 0;
  color: #ffffff;
  font-size: 48px;
  line-height: 0.95;
}

.live-pill {
  flex: 0 0 auto;
  background: rgba(47, 198, 102, 0.18);
  color: #baf7c8;
}

.card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--tg-card);
  box-shadow: var(--shadow);
  padding: 14px;
}

.row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.metric {
  min-height: 86px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: color-mix(in srgb, var(--tg-card), var(--tg-link) 3%);
}

.metric strong {
  display: block;
  font-size: 28px;
  line-height: 1;
}

.muted {
  color: var(--tg-muted);
}

.status-pill,
.chip,
.badge {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border-radius: 999px;
  padding: 5px 10px;
  border: 1px solid var(--line);
  background: color-mix(in srgb, var(--tg-card), var(--tg-link) 5%);
  color: var(--tg-text);
  font-size: 12px;
  font-weight: 700;
}

.status-running,
.status-queued {
  color: var(--tg-link);
}

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

.status-failed {
  color: var(--bad);
}

.status-cancelled {
  color: var(--tg-muted);
}

.chips {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 2px;
}

.chip {
  white-space: nowrap;
  background: var(--tg-card);
}

.chip.active {
  border-color: var(--tg-button);
  color: var(--tg-button);
}

.task-list,
.agent-list {
  display: grid;
  gap: 10px;
}

.task-card,
.agent-card {
  display: block;
  width: 100%;
  text-align: left;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--tg-card);
  color: var(--tg-text);
  padding: 12px;
}

.task-card {
  cursor: pointer;
}

.task-card:active,
.agent-card:active,
.button:active,
.icon-button:active {
  transform: translateY(1px);
}

.task-title {
  margin-bottom: 4px;
  font-weight: 750;
}

.task-preview {
  display: -webkit-box;
  overflow: hidden;
  color: var(--tg-muted);
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.agent-task-tag {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 3px 8px;
  background: color-mix(in srgb, var(--tg-button), transparent 88%);
  color: var(--tg-button);
  font-size: 12px;
  font-weight: 800;
}

.task-card-actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

.task-card-actions .button {
  min-height: 36px;
  padding: 0 12px;
  font-size: 13px;
}

.filters {
  display: grid;
  gap: 8px;
}

.field {
  display: grid;
  gap: 7px;
}

.field span {
  color: var(--tg-muted);
  font-size: 13px;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--tg-card);
  color: var(--tg-text);
  padding: 12px;
  outline: none;
}

textarea {
  min-height: 150px;
  resize: vertical;
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--tg-button);
}

.button,
.icon-button {
  border: 0;
  border-radius: 8px;
  background: var(--tg-button);
  color: var(--tg-button-text);
  cursor: pointer;
  font-weight: 750;
}

.button {
  min-height: 46px;
  padding: 0 14px;
}

.button.secondary {
  border: 1px solid var(--line);
  background: var(--tg-card);
  color: var(--tg-text);
}

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

.button:disabled {
  cursor: default;
  opacity: 0.55;
}

.icon-button {
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  font-size: 20px;
}

.tabbar {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 2px;
  padding: 8px 8px calc(env(safe-area-inset-bottom) + 8px);
  border-top: 1px solid var(--line);
  background: color-mix(in srgb, var(--tg-card), var(--tg-bg) 20%);
}

.tab {
  display: grid;
  gap: 2px;
  min-width: 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--tg-muted);
  padding: 7px 2px;
  font-size: 11px;
  font-weight: 700;
}

.tab span {
  font-size: 18px;
  line-height: 1;
}

.tab.active {
  background: color-mix(in srgb, var(--tg-button), transparent 86%);
  color: var(--tg-button);
}

.tab-primary span {
  color: var(--tg-button);
}

.timeline {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.timeline li {
  border-left: 3px solid var(--tg-button);
  padding-left: 10px;
}

.clarify-panel {
  display: grid;
  gap: 10px;
}

.clarify-panel textarea {
  min-height: 110px;
}

.pre {
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

.answer-links {
  display: grid;
  gap: 8px;
  margin-top: 14px;
}

.artifact-viewer {
  display: grid;
  gap: 10px;
}

.artifact-downloads {
  display: grid;
  gap: 6px;
  margin-bottom: 12px;
}

#artifact-preview {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: contain;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: color-mix(in srgb, var(--tg-card), var(--tg-link) 4%);
}

.artifact-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.artifact-select {
  min-height: 38px;
  padding: 0 10px;
  font-size: 13px;
}

.artifact-select.active {
  border-color: var(--tg-button);
  color: var(--tg-button);
}

.link-button {
  width: 100%;
  border: 1px solid color-mix(in srgb, var(--tg-button), transparent 35%);
  border-radius: 8px;
  padding: 10px 12px;
  background: color-mix(in srgb, var(--tg-button), transparent 88%);
  color: var(--tg-text);
  cursor: pointer;
  text-align: left;
}

.link-button span {
  display: block;
  font-weight: 750;
}

.link-button small {
  display: block;
  overflow-wrap: anywhere;
  color: var(--tg-muted);
}

.empty,
.error {
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--tg-muted);
  padding: 18px;
  text-align: center;
}

.error {
  color: var(--bad);
}

.progress {
  width: 100%;
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: color-mix(in srgb, var(--tg-muted), transparent 80%);
}

.progress span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--tg-button);
}

@media (min-width: 760px) {
  .app-shell {
    max-width: 820px;
    margin: 0 auto;
  }

  .grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .agent-tile-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .new-task-actions {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .tts-grid {
    grid-template-columns: minmax(280px, 0.8fr) minmax(0, 1.2fr);
    align-items: start;
  }

  .tts-metrics {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}
