:root {
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #18201b;
  background: #f4f6f5;
  font-synthesis: none;
  --green: #16784a;
  --green-soft: #e8f5ee;
  --red: #b42318;
  --red-soft: #fef3f2;
  --amber: #8a5700;
  --amber-soft: #fff7e0;
  --line: #dfe5e1;
  --muted: #657169;
}

* { box-sizing: border-box; }

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

body {
  min-width: 320px;
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0;
  background: radial-gradient(circle at 15% 0%, rgba(22, 120, 74, 0.08), transparent 38%), #f4f6f5;
}

button, input { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
h1, h2, p { margin-top: 0; }

.app-shell {
  width: min(100%, 760px);
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0 auto;
  padding: max(20px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(28px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
}

.login-view {
  min-height: calc(100vh - 48px);
  min-height: calc(100dvh - 48px);
  display: grid;
  place-items: center;
}

.login-card {
  width: min(100%, 420px);
  padding: 30px 24px;
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid rgba(223, 229, 225, 0.9);
  border-radius: 24px;
  box-shadow: 0 18px 55px rgba(24, 32, 27, 0.08);
}

.brand-mark {
  display: grid;
  width: 48px;
  height: 48px;
  place-items: center;
  margin-bottom: 22px;
  color: white;
  background: var(--green);
  border-radius: 15px;
  font-weight: 750;
  box-shadow: 0 8px 18px rgba(22, 120, 74, 0.25);
}

.login-card h1 {
  margin-bottom: 8px;
  font-size: 1.7rem;
  letter-spacing: -0.03em;
}

.login-copy {
  margin-bottom: 28px;
  color: var(--muted);
  line-height: 1.6;
}

label {
  display: block;
  margin-bottom: 8px;
  font-size: 0.92rem;
  font-weight: 650;
}

input {
  width: 100%;
  min-height: 48px;
  padding: 11px 13px;
  color: #18201b;
  background: white;
  border: 1px solid #cbd4ce;
  border-radius: 12px;
  outline: none;
}

input:focus-visible {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(22, 120, 74, 0.14);
}

.form-error, .page-error {
  color: var(--red);
  background: var(--red-soft);
  border: 1px solid #fecdca;
  border-radius: 11px;
  line-height: 1.45;
}

.form-error {
  margin: 10px 0 0;
  padding: 9px 11px;
  font-size: 0.9rem;
}

.primary-button {
  width: 100%;
  min-height: 48px;
  margin-top: 18px;
  color: white;
  background: var(--green);
  border: 0;
  border-radius: 12px;
  font-weight: 700;
  cursor: pointer;
}

.primary-button:hover { background: #12673f; }

.primary-button:focus-visible,
.text-button:focus-visible,
.screenshot-button:focus-visible,
.dialog-close:focus-visible {
  outline: 3px solid rgba(22, 120, 74, 0.28);
  outline-offset: 3px;
}

button:disabled { cursor: wait; opacity: 0.62; }
.viewer-view { padding-bottom: 24px; }

.topbar, .status-heading, .screenshot-heading, .dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.topbar { margin: 4px 2px 22px; }

.topbar h1 {
  margin: 2px 0 0;
  font-size: 1.5rem;
  letter-spacing: -0.025em;
}

.eyebrow, .section-label {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 750;
  letter-spacing: 0.12em;
}

.text-button, .dialog-close {
  min-height: 42px;
  padding: 8px 13px;
  color: #35423a;
  background: rgba(255, 255, 255, 0.8);
  border: 1px solid var(--line);
  border-radius: 11px;
  cursor: pointer;
}

.page-error {
  margin-bottom: 14px;
  padding: 11px 13px;
  font-size: 0.92rem;
}

.status-card, .screenshot-card {
  overflow: hidden;
  background: white;
  border: 1px solid var(--line);
  border-radius: 20px;
  box-shadow: 0 10px 30px rgba(24, 32, 27, 0.045);
}

.status-card {
  margin-bottom: 14px;
  padding: 19px;
}

.status-heading h2, .screenshot-heading h2, .dialog-header h2 {
  margin: 3px 0 0;
  font-size: 1.08rem;
}

.status-pill {
  display: inline-flex;
  flex: none;
  align-items: center;
  gap: 7px;
  padding: 7px 10px;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 700;
}

.status-dot {
  width: 7px;
  height: 7px;
  background: currentColor;
  border-radius: 50%;
}

.status-online { color: var(--green); background: var(--green-soft); }
.status-offline { color: var(--red); background: var(--red-soft); }
.status-unknown { color: var(--amber); background: var(--amber-soft); }

.device-details {
  display: grid;
  gap: 11px;
  margin: 18px 0 0;
  padding-top: 16px;
  border-top: 1px solid #edf0ee;
}

.device-details > div {
  display: grid;
  grid-template-columns: 88px minmax(0, 1fr);
  gap: 12px;
}

.device-details dt {
  color: var(--muted);
  font-size: 0.85rem;
}

.device-details dd {
  min-width: 0;
  margin: 0;
  font-size: 0.88rem;
  text-align: right;
  overflow-wrap: anywhere;
}

.screenshot-heading { padding: 18px 19px 16px; }

.capture-time {
  color: var(--muted);
  font-size: 0.8rem;
  text-align: right;
}

.empty-state {
  display: grid;
  min-height: 270px;
  place-items: center;
  align-content: center;
  padding: 34px 20px 42px;
  color: var(--muted);
  background: #f8faf9;
  border-top: 1px solid #edf0ee;
  text-align: center;
}

.empty-icon {
  width: 54px;
  height: 38px;
  margin-bottom: 17px;
  border: 2px solid #aeb9b2;
  border-radius: 7px;
  box-shadow: inset 0 -7px 0 #e6ebe8;
}

.empty-state p {
  margin-bottom: 6px;
  color: #35423a;
  font-weight: 680;
}

.empty-state span { font-size: 0.86rem; }

.screenshot-button {
  position: relative;
  display: block;
  width: 100%;
  padding: 0;
  background: #111714;
  border: 0;
  border-top: 1px solid #edf0ee;
  cursor: zoom-in;
}

.screenshot-button img {
  display: block;
  width: 100%;
  max-height: 62vh;
  object-fit: contain;
}

.zoom-hint {
  position: absolute;
  right: 12px;
  bottom: 12px;
  padding: 7px 10px;
  color: white;
  background: rgba(16, 24, 20, 0.75);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 999px;
  font-size: 0.74rem;
  backdrop-filter: blur(8px);
}

.image-dialog {
  width: 100vw;
  max-width: none;
  height: 100vh;
  height: 100dvh;
  max-height: none;
  margin: 0;
  padding: max(12px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
  color: white;
  background: #0d120f;
  border: 0;
}

.image-dialog::backdrop { background: rgba(0, 0, 0, 0.82); }

.image-dialog[open] {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
}

.dialog-header { padding: 4px 2px 13px; }

.dialog-header p {
  margin: 4px 0 0;
  color: #aeb9b2;
  font-size: 0.78rem;
}

.dialog-close {
  color: white;
  background: #26302a;
  border-color: #3e4b43;
}

.dialog-image-wrap {
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
  display: grid;
  place-items: center;
}

.dialog-image-wrap img {
  display: block;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

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

@media (min-width: 620px) {
  .app-shell { padding-top: 36px; }
  .status-card { padding: 22px; }
  .screenshot-heading { padding: 20px 22px 17px; }
}

@media (prefers-reduced-motion: no-preference) {
  .primary-button, .text-button, .dialog-close {
    transition: background-color 140ms ease, opacity 140ms ease;
  }
}

.controls-grid {
  display: grid;
  gap: 14px;
  margin-top: 14px;
}

.control-card {
  padding: 19px;
  background: white;
  border: 1px solid var(--line);
  border-radius: 20px;
  box-shadow: 0 10px 30px rgba(24, 32, 27, 0.045);
}

.control-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 16px;
}

.control-heading h2 {
  margin: 3px 0 0;
  font-size: 1.08rem;
}

.request-badge {
  flex: none;
  padding: 6px 9px;
  border-radius: 999px;
  color: var(--muted);
  background: #f0f3f1;
  font-size: 0.76rem;
  font-weight: 700;
}

.request-pending {
  color: var(--amber);
  background: var(--amber-soft);
}

.request-succeeded {
  color: var(--green);
  background: var(--green-soft);
}

.request-failed,
.request-expired {
  color: var(--red);
  background: var(--red-soft);
}

.control-status {
  margin-bottom: 6px;
  color: #35423a;
  font-size: 0.92rem;
  line-height: 1.5;
}

.control-detail,
.setting-feedback {
  margin: 0;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.5;
}

.control-button {
  margin-top: 16px;
}

.number-field {
  position: relative;
}

.number-field input {
  padding-right: 50px;
}

.number-field span {
  position: absolute;
  top: 50%;
  right: 14px;
  color: var(--muted);
  font-size: 0.85rem;
  transform: translateY(-50%);
  pointer-events: none;
}

.number-field input[aria-invalid="true"] {
  border-color: var(--red);
  box-shadow: 0 0 0 3px rgba(180, 35, 24, 0.1);
}

.setting-feedback {
  min-height: 1.25rem;
  margin-top: 7px;
}

.setting-feedback.is-error {
  color: var(--red);
}

.setting-feedback.is-success {
  color: var(--green);
}

@media (min-width: 700px) {
  .controls-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
