:root {
  --font: "Outfit", "Segoe UI", system-ui, sans-serif;
  --mono: "IBM Plex Mono", "ui-monospace", monospace;
  --bg: #eef2f7;
  --bg-elev: #f7f9fc;
  --surface: #ffffff;
  --ink: #0c1222;
  --ink-soft: #3d4a63;
  --muted: #6b7890;
  --line: #e3e9f2;
  --line-strong: #cfd8e6;
  --sidebar: #07111c;
  --sidebar-2: #0c1a2b;
  --sidebar-line: rgba(255, 255, 255, 0.07);
  --sidebar-text: #9fb0c6;
  --sidebar-strong: #f4f8ff;
  --ice: #5ad2ff;
  --ice-deep: #1494d2;
  --ice-soft: #e7f7ff;
  --ok: #0f9f6e;
  --ok-bg: #e6f8f0;
  --warn: #b45309;
  --warn-bg: #fff6e5;
  --danger: #d42b3d;
  --danger-bg: #fdecef;
  --issued: #5b6578;
  --issued-bg: #eef1f5;
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.04), 0 10px 28px -18px rgba(15, 23, 42, 0.28);
  --radius: 16px;
  --radius-sm: 10px;
  --sidebar-w: 260px;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

img { max-width: 100%; }
a { color: var(--ice-deep); }
button, input, select { font: inherit; }

:focus-visible {
  outline: 2px solid var(--ice);
  outline-offset: 2px;
}

/* ── App shell ─────────────────────────────────────────── */

body.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100%;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 20px 14px 16px;
  background:
    radial-gradient(ellipse at 0% 0%, rgba(90, 210, 255, 0.16), transparent 52%),
    linear-gradient(180deg, var(--sidebar-2), var(--sidebar));
  color: var(--sidebar-text);
  z-index: 30;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 10px 22px;
  color: var(--sidebar-strong);
  text-decoration: none;
}

.brand-mark {
  width: 36px;
  height: 36px;
  flex: none;
  filter: drop-shadow(0 0 12px rgba(90, 210, 255, 0.35));
}

.brand-name {
  display: block;
  font-weight: 700;
  font-size: 16px;
  letter-spacing: -0.03em;
}

.brand-sub {
  display: block;
  margin-top: 1px;
  font-size: 11px;
  font-weight: 500;
  color: var(--sidebar-text);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.nav-section {
  padding: 0 10px 8px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #6d8199;
}

.nav-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 12px;
  color: var(--sidebar-text);
  text-decoration: none;
  font-weight: 500;
  font-size: 14.5px;
  transition: background 0.15s ease, color 0.15s ease;
}

.nav-link svg {
  width: 18px;
  height: 18px;
  flex: none;
  opacity: 0.85;
}

.nav-link:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--sidebar-strong);
}

.nav-link.is-active {
  background: linear-gradient(90deg, rgba(90, 210, 255, 0.16), rgba(90, 210, 255, 0.05));
  color: var(--sidebar-strong);
  box-shadow: inset 0 0 0 1px rgba(90, 210, 255, 0.18);
}

.nav-link.is-active svg { color: var(--ice); opacity: 1; }

.sidebar-foot {
  margin-top: auto;
  padding-top: 16px;
  border-top: 1px solid var(--sidebar-line);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
}

.user-avatar {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: rgba(90, 210, 255, 0.14);
  color: var(--ice);
  font-weight: 700;
  font-size: 13px;
}

.user-name {
  display: block;
  color: var(--sidebar-strong);
  font-weight: 600;
  font-size: 13.5px;
}

.user-role {
  display: block;
  font-size: 11px;
  color: var(--sidebar-text);
}

.nav-link.logout {
  color: #8b9cb0;
}

button.nav-link {
  width: 100%;
  border: 0;
  background: transparent;
  cursor: pointer;
  text-align: left;
}

.logout-form {
  margin: 0;
}

.topbar {
  display: none;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: var(--sidebar);
  color: #fff;
}

.icon-btn {
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
  cursor: pointer;
  display: grid;
  place-items: center;
}

.nav-backdrop {
  display: none;
}

.canvas {
  min-width: 0;
  padding: 28px 32px 48px;
}

.canvas-inner {
  max-width: 1180px;
  margin: 0 auto;
}

/* ── Type ──────────────────────────────────────────────── */

h1, h2, h3 { margin: 0; letter-spacing: -0.03em; }
h1 { font-size: 28px; font-weight: 700; line-height: 1.15; }
h2 { font-size: 18px; font-weight: 650; margin: 28px 0 12px; }

.page-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 16px;
  margin-bottom: 22px;
}

.page-head h1 { margin-bottom: 6px; }

.lede, .muted { color: var(--muted); }
.lede { margin: 0; font-size: 14.5px; }
.small { font-size: 12px; }
.mono { font-family: var(--mono); font-size: 12.5px; }

.crumb {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 10px;
  font-size: 13px;
}

.crumb a { color: var(--muted); text-decoration: none; }
.crumb a:hover { color: var(--ink); }

/* ── Surfaces ──────────────────────────────────────────── */

.card, table.accounts, .chat-list, .issuance-form, .form-card, .thread-shell {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.panel {
  padding: 22px;
}

/* ── Stats ─────────────────────────────────────────────── */

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

.stat {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px 18px 16px 20px;
  box-shadow: var(--shadow);
}

.stat::before {
  content: "";
  position: absolute;
  left: 0;
  top: 12px;
  bottom: 12px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--ice);
}

.stat:nth-child(2)::before { background: var(--ok); }
.stat:nth-child(3)::before { background: var(--danger); }
.stat:nth-child(4)::before { background: #6f86ff; }

.stat-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.stat-value {
  margin-top: 6px;
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.04em;
}

.live-meta {
  display: flex;
  align-items: center;
  gap: 8px;
}

.live-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #22c55e;
  box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.7);
  animation: pulse 1.8s infinite;
}

@keyframes pulse {
  70% { box-shadow: 0 0 0 8px rgba(34, 197, 94, 0); }
}

/* ── Tables ────────────────────────────────────────────── */

.table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

table.accounts {
  width: 100%;
  border-collapse: collapse;
  overflow: hidden;
  min-width: 740px;
}

table.accounts.props { min-width: 0; }

table.accounts th,
table.accounts td {
  padding: 13px 16px;
  text-align: left;
  vertical-align: middle;
  border-bottom: 1px solid var(--line);
  word-break: break-word;
}

table.accounts th {
  background: var(--bg-elev);
  font-size: 11.5px;
  font-weight: 650;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  white-space: nowrap;
}

table.accounts tbody tr:hover { background: #f8fbff; }
table.accounts tbody tr:last-child td { border-bottom: 0; }

.account-cell {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.account-cell a {
  color: var(--ink);
  font-weight: 650;
  text-decoration: none;
}

.account-cell a:hover { color: var(--ice-deep); }

.cell-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.reaction {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-variant-numeric: tabular-nums;
  font-weight: 650;
}

/* ── Status / tags ─────────────────────────────────────── */

.status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 9px 3px 7px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 650;
}

.status::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.status-active { background: var(--ok-bg); color: var(--ok); }
.status-error { background: var(--danger-bg); color: var(--danger); }
.status-issued { background: var(--issued-bg); color: var(--issued); }

.tag {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  margin-left: 6px;
  border-radius: 999px;
  background: var(--ice-soft);
  color: #0b6d99;
  font-size: 11px;
  font-weight: 650;
}

.tag-issued {
  background: #eef0ff;
  color: #4c57a8;
}

/* ── Buttons ───────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 14px;
  border: 0;
  border-radius: var(--radius-sm);
  background: var(--ink);
  color: #fff;
  font-size: 13.5px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.12) inset;
  transition: transform 0.12s ease, background 0.12s ease, box-shadow 0.12s ease;
}

.btn:hover { background: #1b2538; }
.btn:active { transform: translateY(1px); }

.btn-primary {
  background: linear-gradient(180deg, #3ec4f5, #168fc9);
  color: #042433;
}

.btn-primary:hover { background: linear-gradient(180deg, #58d0ff, #1a9ad6); }

.btn-ghost {
  background: #fff;
  color: var(--ink);
  border: 1px solid var(--line-strong);
  box-shadow: none;
}

.btn-ghost:hover { background: var(--bg-elev); }

.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #b71f31; }

.btn-sm { padding: 6px 10px; font-size: 12.5px; }

.btn-row { display: flex; flex-wrap: wrap; gap: 10px; }

/* ── Forms ─────────────────────────────────────────────── */

.issuance-form, .form-card {
  display: flex;
  flex-direction: column;
  gap: 14px;
  max-width: 440px;
  padding: 20px;
}

.issuance-form label, .form-card label, .field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-soft);
}

.issuance-form input, .form-card input, .field input, .login-form input, input[type="file"] {
  padding: 10px 12px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
}

.issuance-form input:focus, .form-card input:focus, .login-form input:focus {
  outline: none;
  border-color: var(--ice);
  box-shadow: 0 0 0 4px rgba(90, 210, 255, 0.2);
}

.issuance-form button, .form-card button { align-self: flex-start; }
.form-card h2 { margin: 0; }

.add-methods {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.add-methods .form-card {
  max-width: none;
}

.add-steps {
  margin: 0 0 16px;
  padding-left: 18px;
  color: var(--ink-soft);
  font-size: 14px;
}

.add-phone-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.phone-status { margin-top: 14px; }

input[type="file"] {
  padding: 14px;
  background: var(--bg-elev);
  border-style: dashed;
  cursor: pointer;
}

/* ── Alerts ────────────────────────────────────────────── */

.error, .alert {
  margin: 0 0 14px;
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 14px;
}

.error, .alert-error {
  color: #8f1d2c;
  background: var(--danger-bg);
  border: 1px solid #f5c4cb;
}

.alert-ok {
  color: #0b6b4a;
  background: var(--ok-bg);
  border: 1px solid #b7ead4;
}

.warning-box {
  background: var(--warn-bg);
  border: 1px solid #f1d7a4;
  border-radius: var(--radius);
  padding: 18px 20px;
  margin: 8px 0 20px;
  max-width: 760px;
  color: #6b3f08;
}

.warning-box p { margin: 0 0 10px; }
.warning-box p:last-child { margin: 0; }

/* ── Empty ─────────────────────────────────────────────── */

.empty {
  text-align: center;
  padding: 48px 24px;
  background: var(--surface);
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
}

.empty-icon {
  width: 52px;
  height: 52px;
  margin: 0 auto 12px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  background: var(--ice-soft);
  color: var(--ice-deep);
}

.empty p { margin: 0; color: var(--muted); }
.empty a { font-weight: 650; }

/* ── Tabs ──────────────────────────────────────────────── */

.tabs {
  display: inline-flex;
  gap: 4px;
  margin: 22px 0 14px;
  padding: 4px;
  background: #e7edf5;
  border-radius: 12px;
}

.tab {
  padding: 7px 14px;
  border-radius: 9px;
  text-decoration: none;
  color: var(--ink-soft);
  font-size: 13.5px;
  font-weight: 600;
}

.tab-active {
  background: #fff;
  color: var(--ink);
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.08);
}

/* ── Chats ─────────────────────────────────────────────── */

.chat-list {
  list-style: none;
  padding: 6px;
  margin: 0;
}

.chat-list li { border: 0; }

.chat-list a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 12px;
  border-radius: 12px;
  text-decoration: none;
  color: inherit;
}

.chat-list a:hover { background: #f3f7fc; }

.avatar {
  width: 42px;
  height: 42px;
  flex: none;
  border-radius: 14px;
  display: grid;
  place-items: center;
  background: linear-gradient(180deg, #d7ecff, #b9d8f5);
  color: #165f8a;
  font-weight: 700;
}

.chat-copy { min-width: 0; }
.chat-title { display: block; font-weight: 650; }
.chat-preview {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.thread-shell {
  padding: 8px;
  background: #0e1621;
  border-color: #0e1621;
}

.thread {
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 8px;
  max-width: none;
  min-height: 62vh;
  padding: 18px 16px 22px;
  border-radius: 12px;
  background:
    radial-gradient(ellipse at 12% 0%, rgba(90, 210, 255, 0.12), transparent 42%),
    radial-gradient(circle at 1px 1px, rgba(255, 255, 255, 0.035) 1px, transparent 0),
    #0e1621;
  background-size: auto, 18px 18px, auto;
}

.msg { display: flex; }
.msg-in { justify-content: flex-start; }
.msg-out { justify-content: flex-end; }

.bubble {
  max-width: min(75%, 560px);
  padding: 9px 12px 7px;
  border-radius: 16px;
  box-shadow: 0 8px 18px -14px rgba(0, 0, 0, 0.7);
}

.msg-in .bubble {
  background: #182533;
  color: #e7eef5;
  border-bottom-left-radius: 5px;
}

.msg-out .bubble {
  background: linear-gradient(180deg, #3d8ecc, #2b6fa8);
  color: #fff;
  border-bottom-right-radius: 5px;
}

.msg-text { white-space: pre-wrap; word-break: break-word; }

.msg-date {
  display: block;
  text-align: right;
  font-size: 11px;
  opacity: 0.72;
  margin-top: 4px;
}

.msg-media {
  display: inline-block;
  margin-bottom: 4px;
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  font-size: 11px;
}

#load-older { text-align: center; margin-bottom: 10px; }
#load-older .btn { background: rgba(255, 255, 255, 0.1); color: #d5e6f5; }

.thread .muted { color: #8ea0b3; text-align: center; }

/* ── Snapshots / details ───────────────────────────────── */

.snapshots {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
}

.snapshot-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
  box-shadow: var(--shadow);
}

.snapshot-card img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  display: block;
}

.snapshot-card .snap-body { padding: 12px; }

.snapshot-thumb {
  width: 48px;
  height: 48px;
  object-fit: cover;
  border-radius: 10px;
  border: 1px solid var(--line);
}

.props {
  width: 100%;
  max-width: 720px;
}

.split {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(260px, 0.85fr);
  gap: 16px;
  align-items: start;
}

.steps {
  display: grid;
  gap: 10px;
  max-width: 560px;
  margin: 0 0 20px;
  padding: 18px 20px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.step {
  display: grid;
  grid-template-columns: 28px 1fr;
  gap: 10px;
  align-items: start;
  font-size: 14px;
  color: var(--ink-soft);
}

.step-n {
  width: 28px;
  height: 28px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  background: var(--ice-soft);
  color: var(--ice-deep);
  font-size: 12px;
  font-weight: 700;
}

.qr-wrap {
  display: inline-block;
  margin-top: 18px;
  padding: 18px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
  text-align: center;
}

.qr-wrap img {
  display: block;
  width: 260px;
  height: 260px;
  background: #fff;
}

/* ── Login ─────────────────────────────────────────────── */

.login-page {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(280px, 42%) 1fr;
  background: var(--bg);
}

.login-hero {
  position: relative;
  overflow: hidden;
  padding: 48px 44px;
  color: #eef7ff;
  background:
    radial-gradient(ellipse at 20% 15%, rgba(90, 210, 255, 0.22), transparent 46%),
    radial-gradient(ellipse at 90% 90%, rgba(36, 99, 180, 0.35), transparent 42%),
    linear-gradient(165deg, #07111c 0%, #0c1a2b 55%, #071018 100%);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.login-hero h1 {
  font-size: 40px;
  max-width: 12ch;
  margin: 18px 0 12px;
}

.login-hero p { margin: 0; color: #9fb0c6; max-width: 36ch; }

.hero-points {
  display: grid;
  gap: 10px;
  margin-top: 36px;
}

.hero-point {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  color: #c5d4e4;
  font-size: 14px;
}

.hero-point span {
  width: 22px;
  height: 22px;
  flex: none;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: rgba(90, 210, 255, 0.15);
  color: var(--ice);
  font-size: 12px;
}

.login-panel {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px 20px;
}

.login-form {
  width: min(100%, 380px);
  display: flex;
  flex-direction: column;
  gap: 14px;
  background: #fff;
  padding: 32px;
  border-radius: 20px;
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.login-form h1 { font-size: 26px; }
.login-form .lede { margin-bottom: 6px; }
.login-password {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.login-form button {
  margin-top: 6px;
  padding: 12px;
  background: linear-gradient(180deg, #3ec4f5, #168fc9);
  color: #042433;
  border: 0;
  border-radius: 12px;
  font-weight: 700;
  cursor: pointer;
}

.login-form button:hover { filter: brightness(1.05); }

.login-sso {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px;
  border-radius: 12px;
  background: var(--ink);
  color: #fff;
  font-weight: 700;
  text-decoration: none;
}

.login-sso:hover { background: #1b2538; color: #fff; }

.login-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.login-divider::before,
.login-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--line);
}

/* ── Responsive ────────────────────────────────────────── */

@media (max-width: 960px) {
  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .page-head { flex-direction: column; align-items: stretch; }
  .split { grid-template-columns: 1fr; }
  .add-methods { grid-template-columns: 1fr; }
}

@media (max-width: 860px) {
  body.app { grid-template-columns: 1fr; }
  .topbar { display: flex; }
  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: min(86vw, var(--sidebar-w));
    transform: translateX(-104%);
    transition: transform 0.22s ease;
    box-shadow: 20px 0 40px rgba(0, 0, 0, 0.25);
  }
  body.nav-open .sidebar { transform: none; }
  .nav-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(4, 10, 18, 0.45);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
    z-index: 20;
  }
  body.nav-open .nav-backdrop {
    opacity: 1;
    pointer-events: auto;
  }
  .canvas { padding: 18px 16px 36px; }
  .login-page { grid-template-columns: 1fr; }
  .login-hero { min-height: 220px; padding: 28px 24px; }
  .hero-points { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
  }
}
