:root {
  color: #182220;
  background: #f4f7f7;
  font-family:
    Inter,
    ui-sans-serif,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
  font-synthesis: none;
  --ink: #182220;
  --muted: #64716e;
  --line: #d6dfdc;
  --surface: #ffffff;
  --surface-2: #edf2f1;
  --dark: #17201f;
  --green: #18845f;
  --green-soft: #d9f6ec;
  --cyan: #167a97;
  --cyan-soft: #dff4fa;
  --amber: #9a6409;
  --amber-soft: #fff0cc;
  --red: #b43b45;
  --red-soft: #fde7e9;
  --shadow: 0 12px 36px rgb(23 32 31 / 10%);
}

* {
  box-sizing: border-box;
  letter-spacing: 0;
}

html {
  min-height: 100%;
  background: #f4f7f7;
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  background: #f4f7f7;
}

button,
input,
textarea {
  font: inherit;
}

button {
  color: inherit;
}

button:focus-visible,
input:focus-visible,
textarea:focus-visible {
  outline: 3px solid #79cbe1;
  outline-offset: 2px;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.shell {
  width: min(100%, 920px);
  min-height: 100vh;
  margin: 0 auto;
  background: #f4f7f7;
}

.topbar {
  position: sticky;
  z-index: 20;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 70px;
  padding: max(12px, env(safe-area-inset-top)) 20px 12px;
  border-bottom: 1px solid #2c3735;
  color: #f6fbf9;
  background: var(--dark);
}

.brand {
  display: flex;
  gap: 10px;
  align-items: center;
  color: inherit;
  text-decoration: none;
}

.brand img {
  border: 1px solid #52625e;
  border-radius: 8px;
}

.brand span {
  display: grid;
  line-height: 1.05;
}

.brand strong {
  font-size: 19px;
}

.brand small {
  margin-top: 3px;
  color: #a8b8b3;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

.presence {
  display: flex;
  gap: 7px;
  align-items: center;
  color: #cedad6;
  font-size: 12px;
  font-weight: 700;
}

.presence-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #f2b84b;
}

.presence-dot.is-online {
  background: #44d19b;
}

.presence-dot.is-offline {
  background: #ef6972;
}

.tabs {
  position: sticky;
  z-index: 15;
  top: 70px;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  min-height: 58px;
  border-bottom: 1px solid var(--line);
  background: rgb(255 255 255 / 96%);
}

.tab {
  position: relative;
  display: flex;
  gap: 6px;
  align-items: center;
  justify-content: center;
  min-width: 0;
  border: 0;
  border-bottom: 3px solid transparent;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 13px;
  font-weight: 750;
}

.tab svg {
  width: 18px;
  height: 18px;
}

.tab.is-active {
  border-bottom-color: var(--green);
  color: var(--ink);
}

.tab-count {
  min-width: 18px;
  height: 18px;
  padding: 1px 5px;
  border-radius: 9px;
  color: white;
  background: var(--red);
  font-size: 10px;
  line-height: 16px;
}

.view {
  padding: 22px 20px calc(40px + env(safe-area-inset-bottom));
}

.status-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.status-strip > div {
  display: grid;
  gap: 5px;
  min-width: 0;
  padding: 13px 14px;
  border-right: 1px solid var(--line);
}

.status-strip > div:last-child {
  border-right: 0;
}

.status-strip span,
.section-heading span,
.page-heading span {
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
}

.status-strip strong {
  overflow: hidden;
  font-size: 14px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.capture-section {
  margin-top: 20px;
  padding: 18px;
  border: 1px solid #b8c8c3;
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

label {
  display: block;
  margin-bottom: 7px;
  color: #43504d;
  font-size: 12px;
  font-weight: 800;
}

.capture-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 44px;
  gap: 9px;
  align-items: end;
}

textarea,
input {
  width: 100%;
  border: 1px solid #bdcbc7;
  border-radius: 6px;
  color: var(--ink);
  background: #fbfdfc;
}

textarea {
  min-height: 50px;
  padding: 12px;
  resize: vertical;
}

input {
  height: 44px;
  padding: 0 12px;
}

.icon-command {
  display: inline-grid;
  width: 40px;
  height: 40px;
  flex: 0 0 40px;
  place-items: center;
  border: 1px solid #b8c7c3;
  border-radius: 6px;
  background: var(--surface);
  cursor: pointer;
}

.icon-command svg {
  width: 18px;
  height: 18px;
}

.primary-icon {
  width: 44px;
  height: 44px;
  color: white;
  border-color: var(--green);
  background: var(--green);
}

.quick-actions {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-top: 14px;
}

.quick-actions button {
  display: grid;
  gap: 7px;
  min-width: 0;
  min-height: 62px;
  place-items: center;
  padding: 9px 6px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-2);
  cursor: pointer;
  font-size: 11px;
  font-weight: 750;
}

.quick-actions svg {
  width: 19px;
  height: 19px;
  color: var(--cyan);
}

.content-section {
  margin-top: 28px;
}

.section-heading,
.page-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.section-heading h2,
.page-heading h1 {
  margin: 3px 0 0;
  font-size: 19px;
  line-height: 1.2;
}

.page-heading h1 {
  font-size: 25px;
}

.count-badge {
  min-width: 28px;
  padding: 5px 8px;
  border-radius: 7px;
  color: #7c4c00 !important;
  background: var(--amber-soft);
  text-align: center;
}

.item-list {
  display: grid;
  gap: 9px;
}

.job-item,
.approval-item,
.device-item {
  width: 100%;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
  text-align: left;
}

button.job-item {
  cursor: pointer;
}

.job-topline,
.approval-topline,
.device-item {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  justify-content: space-between;
}

.job-main,
.approval-main {
  min-width: 0;
}

.job-item strong,
.approval-item strong,
.device-item strong {
  display: block;
  overflow-wrap: anywhere;
  font-size: 14px;
  line-height: 1.35;
}

.job-item p,
.approval-item p {
  display: -webkit-box;
  overflow: hidden;
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.job-meta {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-top: 10px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 750;
  text-transform: uppercase;
}

.status-badge {
  flex: 0 0 auto;
  padding: 4px 7px;
  border-radius: 6px;
  color: #3a4a46;
  background: var(--surface-2);
  font-size: 10px;
  font-weight: 850;
  text-transform: uppercase;
}

.status-badge.is-running,
.status-badge.is-completed {
  color: #0e6748;
  background: var(--green-soft);
}

.status-badge.is-waiting_for_approval,
.status-badge.is-needs_input {
  color: #835300;
  background: var(--amber-soft);
}

.status-badge.is-failed,
.status-badge.is-cancelled {
  color: #9b2933;
  background: var(--red-soft);
}

.approval-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 12px;
}

.approval-actions button,
.filter-bar button {
  min-height: 36px;
  padding: 0 13px;
  border: 1px solid #b6c5c1;
  border-radius: 6px;
  background: white;
  cursor: pointer;
  font-size: 12px;
  font-weight: 800;
}

.approval-actions .approve-command {
  color: white;
  border-color: var(--green);
  background: var(--green);
}

.approval-actions .reject-command {
  color: var(--red);
  border-color: #edb8bd;
}

.empty-state {
  margin: 0;
  padding: 20px 4px;
  color: var(--muted);
  font-size: 13px;
}

.voice-view {
  min-height: calc(100vh - 128px);
}

.voice-stage {
  position: relative;
  display: grid;
  min-height: 330px;
  place-items: center;
  align-content: center;
  overflow: hidden;
  border-bottom: 1px solid var(--line);
}

.voice-command {
  z-index: 2;
  display: grid;
  width: 92px;
  height: 92px;
  place-items: center;
  border: 2px solid #384945;
  border-radius: 50%;
  color: #e9f7f2;
  background: var(--dark);
  box-shadow: 0 12px 32px rgb(23 32 31 / 20%);
  cursor: pointer;
}

.voice-command svg {
  width: 34px;
  height: 34px;
}

.voice-stage.is-live .voice-command {
  color: #15201e;
  border-color: #2ca878;
  background: #62d8ad;
}

.voice-stage > strong {
  z-index: 2;
  margin-top: 22px;
  font-size: 18px;
}

.voice-stage > small {
  z-index: 2;
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
}

.voice-orbit {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 250px;
  height: 250px;
  transform: translate(-50%, -58%);
}

.voice-orbit span {
  position: absolute;
  inset: 0;
  border: 1px solid #bfd3cd;
  border-radius: 50%;
}

.voice-orbit span:nth-child(2) {
  inset: 28px;
  border-color: #acdbe7;
}

.voice-orbit span:nth-child(3) {
  inset: 55px;
  border-color: #89cdb4;
}

.voice-stage.is-live .voice-orbit span {
  animation: pulse 2.2s ease-in-out infinite;
}

.voice-stage.is-live .voice-orbit span:nth-child(2) {
  animation-delay: 0.3s;
}

.voice-stage.is-live .voice-orbit span:nth-child(3) {
  animation-delay: 0.6s;
}

@keyframes pulse {
  0%,
  100% {
    opacity: 0.35;
    transform: scale(0.96);
  }
  50% {
    opacity: 1;
    transform: scale(1.04);
  }
}

.transcript {
  display: grid;
  gap: 10px;
  max-height: 42vh;
  padding: 18px 0;
  overflow-y: auto;
}

.transcript-entry {
  max-width: 88%;
  padding: 10px 12px;
  border-left: 3px solid var(--green);
  border-radius: 0 6px 6px 0;
  background: white;
  font-size: 13px;
  line-height: 1.45;
}

.transcript-entry.is-user {
  margin-left: auto;
  border-right: 3px solid var(--cyan);
  border-left: 0;
  border-radius: 6px 0 0 6px;
}

.transcript-entry.is-system {
  max-width: 100%;
  color: var(--muted);
  border-left-color: #aebbb8;
  background: transparent;
  font-size: 11px;
}

.filter-bar {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
}

.filter-bar button.is-active {
  color: white;
  border-color: var(--dark);
  background: var(--dark);
}

.work-list {
  padding-bottom: 20px;
}

.settings-band {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
}

.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 70px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
}

.setting-row:last-child {
  border-bottom: 0;
}

.setting-row div {
  display: grid;
  gap: 4px;
}

.setting-row small,
.device-item small {
  color: var(--muted);
  font-size: 11px;
}

.switch {
  width: 48px;
  height: 28px;
  padding: 3px;
  border: 0;
  border-radius: 15px;
  background: #bdc8c5;
  cursor: pointer;
}

.switch span {
  display: block;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: white;
  transition: transform 160ms ease;
}

.switch[aria-checked="true"] {
  background: var(--green);
}

.switch[aria-checked="true"] span {
  transform: translateX(20px);
}

.device-item {
  align-items: center;
}

.device-item .icon-command {
  width: 36px;
  height: 36px;
  flex-basis: 36px;
  color: var(--red);
}

.auth-screen {
  display: grid;
  min-height: calc(100vh - 70px);
  place-items: center;
  padding: 28px 20px;
}

.auth-panel {
  width: min(100%, 400px);
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  box-shadow: var(--shadow);
}

.auth-mark {
  display: block;
  width: 72px;
  height: 72px;
  margin: 0 auto;
  border-radius: 8px;
}

.auth-panel h1 {
  margin: 14px 0 24px;
  text-align: center;
  font-size: 30px;
}

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

.auth-panel label:not(:first-child) {
  margin-top: 6px;
}

.primary-command {
  display: inline-flex;
  gap: 8px;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  margin-top: 8px;
  padding: 0 16px;
  border: 1px solid var(--green);
  border-radius: 6px;
  color: white;
  background: var(--green);
  cursor: pointer;
  font-size: 13px;
  font-weight: 800;
}

.primary-command svg {
  width: 18px;
  height: 18px;
}

.text-command {
  min-height: 38px;
  padding: 0 10px;
  border: 0;
  color: var(--cyan);
  background: transparent;
  cursor: pointer;
  font-size: 12px;
  font-weight: 800;
}

#login-actions {
  display: grid;
}

.form-error {
  min-height: 20px;
  margin: 12px 0 0;
  color: var(--red);
  font-size: 12px;
  line-height: 1.4;
}

dialog {
  width: min(calc(100% - 32px), 520px);
  max-height: calc(100vh - 40px);
  padding: 20px;
  overflow-y: auto;
  border: 1px solid #adbbb7;
  border-radius: 8px;
  color: var(--ink);
  background: white;
  box-shadow: 0 24px 80px rgb(23 32 31 / 28%);
}

dialog::backdrop {
  background: rgb(17 24 22 / 58%);
}

.dialog-heading {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 16px;
}

.dialog-heading svg {
  color: var(--green);
}

.dialog-heading h2 {
  margin: 0;
  font-size: 19px;
}

#new-recovery-code {
  display: block;
  padding: 16px;
  border: 1px dashed #82938e;
  border-radius: 6px;
  background: var(--surface-2);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 17px;
  font-weight: 800;
  text-align: center;
  overflow-wrap: anywhere;
}

#job-dialog-content {
  color: #44514e;
  font-size: 13px;
  line-height: 1.55;
}

#job-dialog-content pre {
  max-height: 280px;
  padding: 12px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f5f8f7;
  font-size: 11px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.download-command {
  display: inline-flex;
  gap: 8px;
  min-height: 40px;
  align-items: center;
  margin: 4px 0 10px;
  padding: 0 12px;
  border: 1px solid var(--green);
  border-radius: 6px;
  color: #116746;
  text-decoration: none;
  font-weight: 800;
}

.download-command svg {
  width: 17px;
  height: 17px;
}

#job-input-form {
  margin-top: 16px;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 12px;
}

.toast {
  position: fixed;
  z-index: 50;
  right: 16px;
  bottom: calc(18px + env(safe-area-inset-bottom));
  left: 16px;
  width: min(calc(100% - 32px), 480px);
  margin: 0 auto;
  padding: 12px 14px;
  border: 1px solid #40514c;
  border-radius: 7px;
  color: white;
  background: #26322f;
  box-shadow: var(--shadow);
  font-size: 13px;
}

[hidden] {
  display: none !important;
}

@media (max-width: 620px) {
  .topbar {
    min-height: 64px;
    padding-right: 14px;
    padding-left: 14px;
  }

  .tabs {
    top: 64px;
  }

  .view {
    padding-right: 14px;
    padding-left: 14px;
  }

  .tab {
    display: grid;
    gap: 3px;
    place-items: center;
    padding: 6px 2px;
    font-size: 10px;
  }

  .status-strip > div {
    padding: 11px 9px;
  }

  .status-strip strong {
    font-size: 12px;
  }

  .capture-section {
    padding: 14px;
  }

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

  .quick-actions button {
    display: flex;
    min-height: 44px;
  }

  .voice-view {
    min-height: calc(100vh - 122px);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}
