:root {
  color-scheme: light;
  --bg: #f5f7fb;
  --panel: #ffffff;
  --text: #172033;
  --muted: #647084;
  --line: #dfe5ef;
  --primary: #1267d8;
  --primary-dark: #0c4fa8;
  --danger: #b42318;
  --warning: #b7791f;
  --ok: #047857;
  --shadow: 0 10px 30px rgba(23, 32, 51, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
}

body.auth-locked .shell {
  display: none;
}

button,
input,
textarea {
  font: inherit;
}

button {
  min-height: 40px;
  border: 0;
  border-radius: 6px;
  background: var(--primary);
  color: #fff;
  padding: 0 16px;
  cursor: pointer;
}

button:hover {
  background: var(--primary-dark);
}

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

button.secondary {
  background: #e8eef8;
  color: #183152;
}

button.secondary:hover {
  background: #d8e3f4;
}

button.danger {
  background: var(--danger);
}

button.ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--line);
}

.shell {
  width: min(1240px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 24px 0;
}

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

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 24px;
  line-height: 1.2;
}

h2 {
  font-size: 16px;
  margin-bottom: 16px;
}

.topbar p {
  color: var(--muted);
  margin-top: 4px;
}

.status-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.metric,
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.metric {
  padding: 14px;
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 8px;
}

.metric strong {
  display: block;
  min-width: 0;
  overflow-wrap: anywhere;
  font-size: 18px;
}

.layout {
  display: grid;
  grid-template-columns: minmax(340px, 420px) minmax(300px, 1fr);
  gap: 16px;
  align-items: start;
}

.panel {
  padding: 18px;
}

.right-column {
  display: grid;
  gap: 16px;
  align-items: start;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  margin-bottom: 14px;
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--text);
  background: #fff;
  padding: 10px 12px;
  outline: none;
}

input:focus,
textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(18, 103, 216, 0.12);
}

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

.button-row {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-top: 8px;
}

fieldset {
  border: 1px solid var(--line);
  border-radius: 8px;
  margin: 0 0 14px;
  padding: 12px;
}

legend {
  color: var(--muted);
  padding: 0 6px;
}

label.check {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
  margin: 8px 0;
}

label.check input {
  width: 16px;
  height: 16px;
}

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

.stack.single-action {
  grid-template-columns: 1fr;
}

.login-wizard {
  display: grid;
  gap: 12px;
  margin: 0 0 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #f8fafc;
}

.login-wizard.hidden {
  display: none;
}

.wizard-step {
  display: grid;
  gap: 8px;
}

.wizard-step strong {
  color: var(--text);
}

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

.credential-grid label {
  margin-bottom: 0;
}

.wizard-status {
  min-height: 20px;
  color: var(--muted);
}

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

.wizard-status.error {
  color: var(--danger);
}

.screenshot-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 16px 0 10px;
}

.screenshot-header strong {
  font-size: 14px;
}

.screenshot-header button {
  min-height: 32px;
}

.browser-screenshot {
  display: grid;
  place-items: center;
  min-height: 260px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #101828;
}

.browser-screenshot img {
  display: block;
  width: 100%;
  max-height: 520px;
  object-fit: contain;
}

.browser-screenshot img.hidden,
#screenshotPlaceholder.hidden {
  display: none;
}

#screenshotPlaceholder {
  color: #8ea0bb;
  text-align: center;
  padding: 18px;
}

.details {
  display: grid;
  gap: 10px;
  margin: 0;
}

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

dt {
  color: var(--muted);
}

dd {
  margin: 0;
  min-width: 0;
  overflow-wrap: anywhere;
}

.logs {
  height: 340px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #0e1626;
  color: #d8e2f2;
  padding: 10px;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 12px;
  line-height: 1.5;
}

.log-entry {
  display: grid;
  grid-template-columns: 82px 48px minmax(0, 1fr);
  gap: 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  padding: 4px 0;
}

.log-entry.warn {
  color: #ffd68a;
}

.log-entry.error {
  color: #ffb4ad;
}

.log-entry.info {
  color: #d8e2f2;
}

.overlay {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(14, 22, 38, 0.45);
  padding: 16px;
}

.overlay.hidden {
  display: none;
}

.login-card {
  width: min(420px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 22px;
}

#loginError {
  min-height: 20px;
  margin-top: 10px;
  color: var(--danger);
}

@media (max-width: 860px) {
  .status-grid,
  .layout {
    grid-template-columns: 1fr;
  }

  .logs-panel {
    grid-column: auto;
  }
}

@media (max-width: 520px) {
  .shell {
    width: min(100vw - 20px, 1240px);
    padding: 12px 0;
  }

  .field-row,
  .button-row,
  .stack,
  .credential-grid {
    grid-template-columns: 1fr;
  }
}
