:root {
  color-scheme: light;
  font-family: Arial, Helvetica, sans-serif;
  background: #f4f7fb;
  color: #1d2735;
  --command-summary-top: 72px;
  --list-header-top: 72px;
  --install-banner-offset: 0px;
  --brand: #22324a;
  --accent: #0f8b8d;
  --danger: #b42318;
  --muted: #667085;
  --line: #d9e2ee;
  --surface: #ffffff;
  --surface-soft: #eef4f8;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: linear-gradient(180deg, #e9f1f6 0, #f7f9fc 42%, #f4f7fb 100%);
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

.app-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  min-height: 72px;
  padding: calc(env(safe-area-inset-top) + 12px) 16px 12px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  background: var(--brand);
  color: #ffffff;
  box-shadow: 0 2px 14px rgba(23, 38, 55, 0.18);
}

.topbar-left {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 10px;
}

.top-title {
  min-width: 0;
}

.topbar h1 {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
  line-height: 1.2;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topbar p {
  margin: 2px 0 0;
  color: #c8d8e8;
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.icon-button {
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.12);
  color: #ffffff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  font-size: 34px;
  line-height: 1;
}

.logout-button {
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.12);
  color: #ffffff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

.logout-button svg {
  width: 22px;
  height: 22px;
}

.top-actions {
  display: inline-flex;
  gap: 8px;
  justify-self: end;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.command-summary {
  position: sticky;
  top: var(--command-summary-top);
  z-index: 29;
  min-height: 42px;
  padding: 8px 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px;
  background: #fff7e6;
  border-bottom: 1px solid #efd49a;
  color: #344054;
}

.command-counter {
  min-height: 28px;
  border-radius: 8px;
  padding: 4px 9px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(255, 255, 255, 0.68);
  font-size: 13px;
  font-weight: 700;
}

.command-counter strong {
  font-size: 15px;
}

.command-counter.pending strong {
  color: #a15c00;
}

.command-counter.done strong {
  color: #067647;
}

.command-counter.error strong {
  color: var(--danger);
}

@media (max-width: 420px) {
  .topbar {
    gap: 8px;
    padding-left: 10px;
    padding-right: 10px;
  }

  .topbar-left {
    gap: 8px;
  }

  .icon-button {
    width: 40px;
    height: 40px;
  }

  .logout-button {
    width: 40px;
    height: 40px;
  }

  .top-actions {
    gap: 6px;
  }
}

main {
  width: min(840px, 100%);
  margin: 0 auto;
  padding: 0 14px 28px;
  flex: 1;
}

.hidden {
  display: none !important;
}

.view {
  min-height: calc(100vh - 120px);
  padding-top: 18px;
}

.empty-state {
  min-height: calc(100vh - 160px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 12px;
  padding: 28px 18px;
}

.empty-state img {
  width: 92px;
  height: 92px;
  border-radius: 18px;
  box-shadow: 0 14px 34px rgba(32, 45, 62, 0.16);
}

.empty-state h2 {
  margin: 8px 0 0;
  font-size: 24px;
}

.empty-state p {
  max-width: 460px;
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}

.primary-action,
.secondary-action,
.refresh-button {
  min-height: 44px;
  border: 0;
  border-radius: 8px;
  padding: 0 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  font-weight: 700;
  cursor: pointer;
}

.primary-action {
  color: #ffffff;
  background: var(--accent);
}

.help-text {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.4;
}

.secondary-action,
.refresh-button {
  color: var(--brand);
  background: #dce9f2;
}

.list-header {
  position: sticky;
  top: var(--list-header-top);
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: -18px -14px 10px;
  padding: 14px 16px 12px;
  background: linear-gradient(180deg, #edf4f8 0, #f7f9fc 100%);
  border-bottom: 1px solid rgba(217, 226, 238, 0.78);
}

.list-header h2 {
  margin: 0;
  font-size: 18px;
}

.list-header span {
  color: var(--muted);
  font-size: 14px;
}

.list {
  display: grid;
  gap: 10px;
}

.row-button {
  width: 100%;
  min-height: 70px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: inherit;
  text-align: left;
  padding: 12px;
  display: grid;
  grid-template-columns: 48px 1fr auto;
  align-items: center;
  gap: 12px;
  box-shadow: 0 8px 20px rgba(31, 49, 67, 0.06);
  cursor: pointer;
}

.row-button img {
  width: 42px;
  height: 42px;
  object-fit: contain;
}

.row-button strong {
  display: block;
  font-size: 16px;
  line-height: 1.25;
}

.row-button small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.3;
}

.row-button .chevron {
  color: #9aa8b5;
  font-size: 28px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  border-radius: 999px;
  padding: 2px 9px;
  background: #e9f7f5;
  color: #08706e;
  font-size: 12px;
  font-weight: 700;
}

dialog {
  width: min(440px, calc(100% - 28px));
  border: 0;
  border-radius: 10px;
  padding: 0;
  box-shadow: 0 24px 70px rgba(12, 25, 39, 0.32);
}

dialog::backdrop {
  background: rgba(16, 31, 49, 0.55);
}

.door-dialog {
  position: relative;
  padding: 22px;
  background: var(--surface);
}

.dialog-close {
  position: absolute;
  top: 10px;
  right: 10px;
  min-width: 72px;
  height: 38px;
  border: 0;
  border-radius: 8px;
  background: var(--surface-soft);
  color: var(--brand);
  padding: 0 12px;
  font-size: 13px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
}

.door-dialog h2 {
  margin: 4px 92px 4px 0;
  font-size: 22px;
}

.door-meta {
  margin: 0 0 14px;
  color: var(--muted);
}

.status-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.status-grid div {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fbfdff;
}

.status-grid span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.status-grid strong {
  display: block;
  margin-top: 4px;
  font-size: 15px;
}

.permission-note {
  margin: 14px 0 0;
  padding: 10px 12px;
  border-radius: 8px;
  color: #7a2e0e;
  background: #fff1df;
}

.command-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 16px;
}

.command-button {
  min-height: 92px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f7fbfd;
  color: var(--brand);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-weight: 700;
  cursor: pointer;
}

.command-button img {
  width: 42px;
  height: 42px;
  object-fit: contain;
}

.command-button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
  filter: grayscale(1);
}

.install-banner {
  position: fixed;
  left: 50%;
  bottom: calc(env(safe-area-inset-bottom) + 12px);
  z-index: 35;
  width: min(560px, calc(100vw - 24px));
  border: 1px solid #cfe0ea;
  border-radius: 8px;
  padding: 12px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 10px;
  background: #ffffff;
  box-shadow: 0 18px 44px rgba(16, 31, 49, 0.22);
  transform: translateX(-50%);
}

.install-copy {
  min-width: 0;
}

.install-copy strong {
  display: block;
  color: var(--brand);
  font-size: 15px;
  line-height: 1.2;
}

.install-copy p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.install-action,
.install-close {
  min-height: 38px;
  border: 0;
  border-radius: 8px;
  padding: 0 12px;
  font-weight: 700;
  cursor: pointer;
}

.install-action {
  color: #ffffff;
  background: var(--accent);
}

.install-close {
  color: var(--brand);
  background: var(--surface-soft);
}

.toast-region {
  position: fixed;
  left: 50%;
  bottom: calc(env(safe-area-inset-bottom) + 18px + var(--install-banner-offset));
  transform: translateX(-50%);
  display: grid;
  gap: 8px;
  z-index: 40;
}

.toast {
  max-width: min(440px, calc(100vw - 28px));
  border-radius: 8px;
  padding: 12px 14px;
  color: #ffffff;
  background: #172635;
  box-shadow: 0 12px 28px rgba(18, 32, 48, 0.24);
}

@media (min-width: 720px) {
  main {
    padding-top: 28px;
  }

  .topbar {
    padding-left: max(22px, calc((100vw - 840px) / 2));
    padding-right: max(22px, calc((100vw - 840px) / 2));
  }
}

@media (max-width: 520px) {
  .install-banner {
    grid-template-columns: 1fr 1fr;
  }

  .install-copy {
    grid-column: 1 / -1;
  }
}
