:root {
  --bg: #0f171e;
  --panel: #15212b;
  --panel-alt: #1a2732;
  --text: #e7f0f7;
  --muted: #9ab0c1;
  --accent: #0ab7de;
  --accent-2: #0383a2;
  --danger: #dc5d59;
  --border: #2e3f4d;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: radial-gradient(circle at top, #1d2e3c 0%, var(--bg) 55%);
  color: var(--text);
  font-family: "Avenir Next", "Segoe UI", sans-serif;
  padding: 18px;
}

.page {
  max-width: 1100px;
  margin: 0 auto;
  display: grid;
  gap: 14px;
  position: relative;
}

.top-controls {
  position: absolute;
  top: 0;
  right: 10px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
  max-width: calc(100% - 20px);
  z-index: 10;
}

.signed-in-chip {
  position: static;
  display: flex;
  align-items: center;
  gap: 10px;
  background: #151d23;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 10px;
  z-index: 10;
  max-width: 100%;
}

.signed-in-chip-user {
  font-size: 12px;
  color: var(--muted);
  max-width: 320px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.panel {
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px;
  background: linear-gradient(180deg, var(--panel-alt), var(--panel));
  box-shadow: 0 14px 26px rgba(0, 0, 0, 0.25);
}

.hero h1 {
  margin: 0 0 6px;
  font-size: clamp(28px, 3.5vw, 40px);
}

.hero-head {
  display: flex;
  align-items: flex-end;
  justify-content: flex-start;
  flex-wrap: wrap;
  gap: 12px;
}

.settings-link {
  color: #92e6f7;
  text-decoration: none;
  font-weight: 600;
  font-size: 14px;
  white-space: nowrap;
}

.settings-link-top {
  display: inline-block;
  padding-right: 4px;
  text-align: right;
}

.settings-link:hover,
.settings-link:focus-visible {
  text-decoration: underline;
}

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

h2 {
  margin: 0 0 10px;
  font-size: 18px;
}

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

.auth-grid {
  grid-template-columns: 1fr 1fr auto auto;
}

.local-grid {
  grid-template-columns: 1fr auto auto;
}

.create-grid {
  grid-template-columns: 1fr 1fr;
}

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

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

.field.full {
  grid-column: 1 / -1;
}

.field.checkbox {
  display: flex;
  align-items: center;
  gap: 10px;
}

.field.checkbox > span {
  color: var(--text);
}

input,
select,
button {
  min-height: 40px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #111a22;
  color: var(--text);
  padding: 8px 11px;
  font-size: 14px;
}

a.button-link {
  min-height: 40px;
  border-radius: 10px;
  border: none;
  background: linear-gradient(180deg, var(--accent), var(--accent-2));
  color: #08202a;
  padding: 8px 11px;
  font-size: 14px;
  font-weight: 700;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

a.button-link[aria-disabled="true"] {
  opacity: 0.55;
  cursor: not-allowed;
  pointer-events: none;
}

input:focus,
select:focus {
  outline: 2px solid rgba(10, 183, 222, 0.35);
  border-color: var(--accent);
}

button {
  border: none;
  cursor: pointer;
  background: linear-gradient(180deg, var(--accent), var(--accent-2));
  color: #08202a;
  font-weight: 700;
}

button.secondary {
  border: 1px solid var(--border);
  background: #263642;
  color: var(--text);
}

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

.actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
  flex-wrap: wrap;
}

.onboarding-actions {
  margin-top: 10px;
}

.pairing-box {
  margin-top: 12px;
  border: 1px solid #2f4050;
  border-radius: 10px;
  background: #151f27;
  padding: 10px;
}

.pairing-title {
  font-size: 13px;
  color: var(--muted);
}

.pairing-key {
  margin-top: 6px;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.3px;
  word-break: break-all;
  padding: 10px;
  border-radius: 8px;
  border: 1px solid #314657;
  background: #0f1820;
}

.pairing-actions {
  margin-top: 8px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.result {
  margin-top: 12px;
  padding: 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #151d23;
  display: none;
}

.result.show {
  display: block;
}

.url-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  margin: 9px 0;
}

.url-row input {
  background: #0f1418;
  border-color: #2f3d4b;
}

.qr-box {
  display: inline-flex;
  border: 8px solid #fff;
  border-radius: 8px;
  margin-top: 6px;
  background: #fff;
}

.qr-box img {
  width: min(280px, 100%);
  height: auto;
  display: block;
  cursor: zoom-in;
}

.qr-project-name {
  margin-top: 8px;
  text-align: center;
  font-weight: 700;
  word-break: break-word;
}

.qr-inline-actions {
  margin-top: 10px;
  display: flex;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
}

.status {
  margin-top: 8px;
  min-height: 18px;
  font-size: 13px;
}

.status.error {
  color: #ff9f9b;
}

.status.success {
  color: #86e8fb;
}

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

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  border-bottom: 1px solid #2a3742;
  padding: 8px 6px;
  text-align: left;
  vertical-align: middle;
  font-size: 14px;
}

th {
  color: var(--muted);
  font-weight: 600;
}

td a {
  color: #92e6f7;
}

.action-cell {
  display: flex;
  gap: 8px;
  align-items: stretch;
}

.row-actions {
  display: grid;
  gap: 6px;
  min-width: 96px;
}

.row-actions button {
  min-height: 32px;
  font-size: 12px;
  padding: 6px 9px;
}

.row-qr-box {
  width: auto;
  min-width: 32px;
  height: auto;
  min-height: 32px;
  aspect-ratio: 1 / 1;
  border: 1px solid #d8d8d8;
  background: #fff;
  border-radius: 8px;
  padding: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  align-self: stretch;
  cursor: pointer;
  appearance: none;
}

.row-qr-box:hover {
  filter: brightness(0.97);
}

.row-qr-box:focus-visible {
  outline: 2px solid rgba(10, 183, 222, 0.45);
}

.row-qr-box img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.qr-modal {
  position: fixed;
  inset: 0;
  background: rgba(7, 11, 14, 0.72);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 22px;
  z-index: 9999;
}

.qr-modal.show {
  display: flex;
}

.qr-modal-card {
  width: min(560px, 100%);
  background: linear-gradient(180deg, #1b232a, var(--panel));
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px;
  box-shadow: 0 22px 38px rgba(0, 0, 0, 0.4);
}

.qr-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.qr-modal-title {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.2px;
  word-break: break-word;
}

.qr-modal-image-wrap {
  margin: 12px 0;
  border-radius: 10px;
  background: #fff;
  padding: 14px;
  display: flex;
  justify-content: center;
}

.qr-modal-image-wrap img {
  width: min(360px, 100%);
  height: auto;
  display: block;
}

.qr-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

body.modal-open {
  overflow: hidden;
}

@media (max-width: 900px) {
  .top-controls {
    position: static;
    margin-bottom: 10px;
    align-items: stretch;
    gap: 8px;
  }

  .auth-grid,
  .local-grid,
  .create-grid {
    grid-template-columns: 1fr;
  }

  .signed-in-chip {
    position: static;
    margin-bottom: 0;
    justify-content: space-between;
    border-radius: 10px;
  }

  .settings-link-top {
    text-align: left;
  }

  .actions {
    flex-direction: column;
  }

  .actions > * {
    width: 100%;
  }

  .hero-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .url-row {
    grid-template-columns: 1fr;
  }
}
