/* 1code.id — Phase 2.0b monochrome brand.
   Black & white minimalism. No red. Visual register: ChatGPT /
   Grok / Linear. */

:root {
  --bg: #000000;
  --surface: #0a0a0a;
  --surface-2: #141414;
  --border: #262626;
  --border-strong: #3a3a3a;
  --text: #fafafa;
  --text-soft: #e5e5e5;
  --muted: #a3a3a3;
  --muted-2: #737373;

  /* status colors — all monochrome / text-only signaling per the
     Phase 2.0b palette lock. */
  --status-ok-text: #fafafa;
  --status-ok-bg: #1a1a1a;
  --status-ok-border: #3a3a3a;
  --status-err-text: #fafafa;
  --status-err-bg: #1a1a1a;
  --status-err-border: #525252;
  --status-pending-text: #a3a3a3;
  --status-pending-bg: #0f0f0f;
  --status-pending-border: #2a2a2a;

  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 1px 0 rgba(255, 255, 255, 0.04) inset, 0 8px 24px rgba(0, 0, 0, 0.6);
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, system-ui, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.55 var(--sans);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
}

/* ── main card ──────────────────────────────────────────────── */

main.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 32px;
  width: 100%;
  max-width: 520px;
}

main.wide {
  max-width: 920px;
}

/* ── brand row ──────────────────────────────────────────────── */

.brand {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

.logo {
  font-weight: 600;
  letter-spacing: -0.02em;
  font-size: 16px;
  color: var(--text);
}

.phase {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

/* ── typography ─────────────────────────────────────────────── */

h1 {
  font-size: 30px;
  line-height: 1.15;
  margin: 0 0 12px;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--text);
}

h2 {
  font-size: 18px;
  margin: 28px 0 10px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text);
}

h3 {
  font-size: 14px;
  margin: 20px 0 8px;
  font-weight: 600;
  color: var(--text);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

p.lede {
  color: var(--muted);
  margin: 0 0 24px;
  font-size: 15px;
  line-height: 1.55;
}

p.meta { color: var(--muted); margin-top: 16px; font-size: 13px; }

a {
  color: var(--text);
  text-decoration: none;
  border-bottom: 1px solid var(--border-strong);
  transition: border-color 0.12s ease;
}
a:hover { border-bottom-color: var(--text); }

/* ── form controls ─────────────────────────────────────────── */

label {
  display: block;
  margin-bottom: 14px;
}
label > .field-label {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 6px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
label > small.field-help {
  display: block;
  color: var(--muted-2);
  font-size: 12px;
  margin-top: 6px;
}
p.field-help {
  color: var(--muted);
  font-size: 13px;
  margin: 6px 0 14px;
  line-height: 1.5;
}

input[type="text"],
input[type="email"],
input[type="password"],
select {
  display: block;
  width: 100%;
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 11px 14px;
  font: inherit;
  font-size: 15px;
  margin: 0;
  transition: border-color 0.12s ease;
}
input:focus, select:focus {
  outline: none;
  border-color: var(--border-strong);
}
input::placeholder { color: var(--muted-2); }

fieldset {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  margin: 18px 0;
  background: rgba(255, 255, 255, 0.01);
}
fieldset legend {
  padding: 0 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
fieldset input[type="email"] { margin-bottom: 10px; }

/* ── buttons ───────────────────────────────────────────────── */

button.primary,
button.secondary,
button.ghost {
  display: block;
  width: 100%;
  padding: 12px 18px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font: inherit;
  font-weight: 500;
  font-size: 14px;
  cursor: pointer;
  margin-top: 12px;
  transition: background 0.12s ease, border 0.12s ease, color 0.12s ease, opacity 0.12s ease;
  letter-spacing: 0.01em;
}
button.primary {
  background: var(--text);
  color: var(--bg);
  border-color: var(--text);
}
button.primary:hover:not(:disabled) {
  background: var(--text-soft);
  border-color: var(--text-soft);
}
button.primary:disabled { opacity: 0.4; cursor: not-allowed; }

button.secondary {
  background: transparent;
  color: var(--text);
  border-color: var(--border-strong);
}
button.secondary:hover:not(:disabled) {
  background: var(--surface-2);
  border-color: var(--text);
}
button.secondary:disabled { opacity: 0.4; cursor: not-allowed; }

button.ghost {
  background: transparent;
  color: var(--muted);
  border-color: transparent;
}
button.ghost:hover { color: var(--text); }

/* compact inline button */
button.inline {
  display: inline-block;
  width: auto;
  padding: 8px 14px;
  font-size: 13px;
  margin: 0;
}

/* ── status pills (monochrome) ──────────────────────────────── */

.status {
  margin: 16px 0;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  border: 1px solid;
  line-height: 1.5;
}
.status-pending {
  background: var(--status-pending-bg);
  border-color: var(--status-pending-border);
  color: var(--status-pending-text);
}
.status-ok {
  background: var(--status-ok-bg);
  border-color: var(--status-ok-border);
  color: var(--status-ok-text);
}
.status-ok::before {
  content: "✓  ";
  font-weight: 600;
}
.status-err {
  background: var(--status-err-bg);
  border-color: var(--status-err-border);
  color: var(--status-err-text);
}
.status-err::before {
  content: "!  ";
  font-weight: 600;
  letter-spacing: 0.05em;
}

/* ── QR display ─────────────────────────────────────────────── */

.qr-frame {
  background: #fff;
  padding: 16px;
  border-radius: var(--radius);
  margin: 18px 0;
  display: flex;
  justify-content: center;
}
#qr-image { width: 100%; height: auto; display: block; }
.countdown {
  text-align: center;
  font-family: var(--mono);
  color: var(--muted);
  font-size: 13px;
  margin: 8px 0 16px;
}

/* ── key-value grid (account dashboard) ─────────────────────── */

dl.kv {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 10px 18px;
  font-size: 14px;
  margin: 16px 0;
}
dl.kv dt {
  color: var(--muted);
  font-weight: 500;
  font-size: 13px;
}
dl.kv dd { margin: 0; word-break: break-all; color: var(--text); }

/* ── contact / device rows ─────────────────────────────────── */

.contactRow,
.device-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.contactRow:last-child, .device-row:last-child { border-bottom: none; }
.contactEmail { color: var(--text); font-size: 14px; }
/* Compact row-action button. Sized to match button.inline (8px 14px /
   13px) so "Make key holder" and the Revoke/Decline/Copy buttons that
   sit beside it are the same height. */
.contactRemove {
  background: transparent;
  border: 1px solid var(--border-strong);
  color: var(--muted);
  font-size: 13px;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  cursor: pointer;
}
.contactRemove:hover { color: var(--text); border-color: var(--text); }

/* ── empty-state callout for "coming soon" sections ────────── */

.empty {
  background: var(--surface-2);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  padding: 24px;
  text-align: center;
  color: var(--muted);
  font-size: 14px;
  margin: 12px 0;
}

/* ── landing-page specific ─────────────────────────────────── */

.hero {
  text-align: center;
  padding: 64px 24px 24px;
}
.hero h1 {
  font-size: 44px;
  line-height: 1.1;
  margin-bottom: 16px;
  letter-spacing: -0.03em;
}
.hero p.lede {
  font-size: 17px;
  max-width: 520px;
  margin: 0 auto 32px;
}
.hero .cta-row {
  display: flex;
  gap: 12px;
  justify-content: center;
  max-width: 360px;
  margin: 0 auto;
}
.hero .cta-row button { margin-top: 0; }

.features {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 20px;
  padding: 32px 24px 64px;
  max-width: 920px;
  margin: 0 auto;
}
.feature {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
}
.feature h3 {
  margin: 0 0 10px;
  text-transform: none;
  letter-spacing: -0.005em;
  font-size: 15px;
  color: var(--text);
}
.feature p { margin: 0; color: var(--muted); font-size: 14px; line-height: 1.55; }

.site-nav {
  position: fixed;
  top: 0; left: 0; right: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 24px;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  z-index: 10;
}
.site-nav .logo { font-size: 15px; }
.site-nav .nav-links { display: flex; gap: 18px; align-items: center; }
.site-nav .nav-links a {
  font-size: 13px;
  color: var(--muted);
  border: none;
}
.site-nav .nav-links a:hover { color: var(--text); }
.site-nav button.inline { margin: 0; }

body.landing-body {
  padding: 0;
  display: block;
  min-height: auto;
  background: var(--bg);
}

/* ── dashboard app shell (signed-in SaaS layout) ───────────────
   The logged-OUT sign-in card (#login-shell) keeps the default
   centered body layout. The signed-IN view (#dashboard-view) is a
   full-bleed [ sidebar | right column ] shell. When the dashboard is
   active we drop the body's centering + padding and hide the empty
   sign-in card so the shell can fill the viewport. */

body.dashboard-body:has(#dashboard-view:not(.hidden)) {
  display: block;
  padding: 0;
  align-items: stretch;
  justify-content: flex-start;
}
body.dashboard-body:has(#dashboard-view:not(.hidden)) #login-shell {
  display: none;
}

.app-shell {
  display: flex;
  flex-direction: row;
  align-items: stretch;
  min-height: 100vh;
  width: 100%;
  background: var(--bg);
  color: var(--text);
}

/* ── sidebar ───────────────────────────────────────────────── */

.app-sidebar {
  flex: 0 0 210px;
  width: 210px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 20px 12px;
  position: sticky;
  top: 0;
  align-self: flex-start;
  height: 100vh;
  overflow-y: auto;
}

/* Brand lockup — mirrors the 1code Books header: the white "1code" mark
   (image) · 1px divider · sublabel. Centre-aligned so the mark and the
   sublabel ("ID") sit on the same midline. */
.app-wordmark {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  padding: 4px 12px 18px;
}
.app-wordmark img {
  height: 30px;
  width: auto;
  display: block;
  /* the PNG carries transparent top padding; nudge it onto the midline */
  transform: translateY(3px);
}
.app-wordmark-div {
  width: 1px;
  height: 22px;
  background: var(--border-strong);
}
.app-wordmark-sub {
  color: var(--text);
  font-size: 1.1rem;
  font-weight: 500;
  letter-spacing: -0.01em;
  line-height: 1;
  /* pull "ID" a touch closer to the divider, like Books' "Books" */
  margin-left: -4px;
}

.app-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 12px;
  border: none;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 14px;
  font-weight: 500;
  text-align: left;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease;
}
.nav-item svg {
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
}
.nav-item:hover { color: var(--text); background: rgba(255, 255, 255, 0.03); }
.nav-item.active {
  background: var(--surface-2);
  color: var(--text);
}

.nav-group-label {
  font-size: 11px;
  color: var(--muted-2);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 500;
  padding: 16px 12px 6px;
}

/* ── right column ──────────────────────────────────────────── */

.app-right {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

/* Full-width top bar: title pinned left, user/Log out pinned far right.
   (Only .app-main centers — the bar deliberately spans edge to edge.) */
.app-topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 14px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}
.app-topbar-title {
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.app-topbar-user {
  display: flex;
  align-items: center;
  gap: 12px;
}
.app-avatar {
  flex: 0 0 30px;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
}
.app-username {
  font-size: 14px;
  color: var(--text);
  font-weight: 500;
}
button.secondary.app-logout {
  width: auto;
  margin: 0;
  padding: 8px 14px;
  font-size: 13px;
}

/* ── notification bell + panel (monochrome — no red badge) ──────── */
.app-bell-wrap { position: relative; display: inline-flex; }
.app-bell {
  background: transparent;
  border: none;
  color: var(--muted);
  cursor: pointer;
  padding: 6px;
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  position: relative;
}
.app-bell:hover { color: var(--text); }
.app-bell svg { width: 20px; height: 20px; }
.app-bell-badge {
  position: absolute;
  top: -1px;
  right: -1px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  background: var(--text);
  color: var(--bg);
  border-radius: 8px;
  font-size: 10px;
  font-weight: 700;
  line-height: 16px;
  text-align: center;
}
.app-bell-panel {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 320px;
  max-height: 380px;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  z-index: 50;
  padding: 6px;
}
.app-bell-head {
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
}
.app-notif {
  padding: 10px;
  border-bottom: 1px solid var(--border);
}
.app-notif:last-child { border-bottom: none; }
.app-notif.unread { background: rgba(255, 255, 255, 0.04); }
.app-notif-title { font-size: 13px; color: var(--text); font-weight: 500; }
.app-notif-body { font-size: 12px; color: var(--muted); margin-top: 2px; line-height: 1.4; }
.app-notif-time { font-size: 11px; color: var(--muted-2); margin-top: 4px; }

/* ── invite landing page (/invite/{token}) — logo top-center, content
   pulled to the vertical middle, two store buttons ─────────────────── */
.invite-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 32px 24px;
  box-sizing: border-box;
}
.invite-logo {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
}
.invite-logo img {
  height: 36px;
  width: auto;
  display: block;
  transform: translateY(3px);
}
/* Slightly larger "ID" + divider on the invite page only (scoped so the
   sidebar wordmark stays its own size). */
.invite-logo .app-wordmark-sub { font-size: 1.3rem; }
.invite-logo .app-wordmark-div { height: 26px; }
.invite-center {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  max-width: 520px;
  /* Sit a little above dead-center, not pinned to the middle. */
  padding-bottom: 10vh;
}
.invite-center h1 { font-size: 34px; line-height: 1.1; margin: 0 0 14px; }
.invite-center .lede { margin: 0; color: var(--muted); }
.invite-cta {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 32px;
}
.invite-store {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 12px 22px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
}
.invite-store:hover { border-color: var(--text); background: var(--surface-2); }
.invite-store svg { width: 20px; height: 20px; flex: 0 0 20px; }
.invite-foot { padding-top: 24px; color: var(--muted-2); }

.app-main {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 24px;
  max-width: 920px;
  width: 100%;
  /* Center the content column inside the wide right pane on big screens
     (it used to hug the left). Only the content centers — the top bar
     deliberately stays full-width (title left, user/Log out far right). */
  margin-left: auto;
  margin-right: auto;
}

/* ── panels ────────────────────────────────────────────────── */

.panel { display: block; }
.panel.hidden { display: none !important; }
/* First heading in a panel shouldn't push a big top margin under the
   topbar — the panel's own padding already spaces it. */
.panel > h3:first-child,
.panel > h1:first-child { margin-top: 0; }

/* ── get-started cards (overview landing) ──────────────────── */

.getstarted-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 14px;
  margin: 12px 0 8px;
}
.getstarted-card {
  display: block;
  text-align: left;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  color: var(--text);
  font: inherit;
  cursor: pointer;
  transition: border-color 0.12s ease, background 0.12s ease;
}
.getstarted-card:hover {
  border-color: var(--border-strong);
  background: var(--surface-2);
}
.getstarted-card svg {
  width: 22px;
  height: 22px;
  color: var(--text);
  margin-bottom: 12px;
}
.getstarted-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
}
.getstarted-sub {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.45;
}

/* ── desktop form polish ────────────────────────────────────────
   Inside the dashboard panels, form fields, buttons, and body text read
   as a tidy left-aligned column sized to their content — not full-width
   "mobile" bars stretched across the whole 920px pane. */

/* explanatory text kept to a readable line length */
.app-main .lede,
.app-main p.meta { max-width: 620px; }

/* form fields sized to their content type */
.app-main input[type="text"],
.app-main input[type="email"],
.app-main input[type="password"],
.app-main select,
.app-main textarea { max-width: 440px; }            /* default: company, app name… */
#profile-surname,
#person-username { max-width: 260px; }              /* short identifiers */
#profile-address,
#conn-discovery,
#rp-site-url { max-width: 560px; }                  /* addresses + URLs */

/* action buttons sit content-sized + left-aligned, not full-width.
   Compact row buttons (.inline) and copy buttons (.contactRemove) keep
   their own size. */
.app-main button.primary:not(.inline),
.app-main button.secondary:not(.inline) {
  display: inline-block;
  width: auto;
  min-width: 150px;
}
/* the Add/Cancel pairs stay side-by-side but within a tidy column */
#add-connection-form,
#add-person-form { max-width: 440px; }

/* Narrow viewports: stack the sidebar above the content. */
@media (max-width: 720px) {
  .app-shell { flex-direction: column; }
  .app-sidebar {
    flex-basis: auto;
    width: 100%;
    height: auto;
    position: static;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
  .app-nav { flex-direction: row; flex-wrap: wrap; }
  .nav-group-label { width: 100%; }
  /* On phones, forms + text return to comfortable full-width. */
  .app-main .lede, .app-main p.meta,
  .app-main input[type="text"], .app-main input[type="email"],
  .app-main input[type="password"], .app-main select, .app-main textarea,
  #profile-surname, #person-username,
  #profile-address, #conn-discovery, #rp-site-url,
  #add-connection-form, #add-person-form { max-width: none; }
  .app-main button.primary:not(.inline),
  .app-main button.secondary:not(.inline) { display: block; width: 100%; }
}

/* ── misc ──────────────────────────────────────────────────── */

.hidden { display: none !important; }

footer {
  margin-top: 32px;
  color: var(--muted-2);
  font-size: 11px;
  text-align: center;
}

details { margin: 12px 0; }
details summary {
  cursor: pointer;
  color: var(--muted);
  font-size: 13px;
}
details p {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
  margin-top: 8px;
}

code {
  font-family: var(--mono);
  background: var(--surface-2);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 12px;
  color: var(--text-soft);
  border: 1px solid var(--border);
}
