:root {
  --bg: #f7f7f8;
  --panel: #ffffff;
  --panel-soft: #fafafa;
  --line: #e4e5e7;
  --line-strong: #d8dade;
  --text: #2f3033;
  --muted: #70737a;
  --muted-soft: #93979f;
  --brand: #f38020;
  --brand-dark: #da6f14;
  --blue: #3f6ff4;
  --blue-soft: #eaf1ff;
  --green: #22a55a;
  --red: #dc4c3f;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.04);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  background: var(--bg);
  letter-spacing: 0;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input {
  font: inherit;
}

svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
  flex: 0 0 auto;
}

.login-body {
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-shell {
  width: min(100%, 420px);
}

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

.brand-row,
.account-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  font-weight: 700;
}

.brand-name {
  font-size: 15px;
}

.brand-logo {
  display: block;
  width: 30px;
  height: 30px;
  flex: 0 0 auto;
  object-fit: cover;
  border-radius: 6px;
}

.login-copy {
  margin: 36px 0 24px;
}

.eyebrow,
.breadcrumb,
.metric-label,
.nav-heading {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

.login-copy h1,
.page-head h1 {
  margin: 8px 0 0;
  font-size: clamp(28px, 4vw, 36px);
  line-height: 1.1;
  letter-spacing: 0;
}

.form-error {
  margin: 0 0 16px;
  padding: 10px 12px;
  color: #9f2a1d;
  background: #fff1ee;
  border: 1px solid #ffd7ce;
  border-radius: 6px;
  font-size: 14px;
}

.form-success {
  margin: 0 0 16px;
  padding: 10px 12px;
  color: #146c36;
  background: #eefbf3;
  border: 1px solid #ccefd9;
  border-radius: 6px;
  font-size: 14px;
}

.portal-message {
  margin-top: 18px;
}

.login-form {
  display: grid;
  gap: 10px;
}

.login-form label {
  color: var(--text);
  font-size: 13px;
  font-weight: 650;
}

.login-form input {
  width: 100%;
  height: 42px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  padding: 0 12px;
  color: var(--text);
  background: #fff;
  outline: none;
}

.login-form input:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(63, 111, 244, 0.14);
}

.primary-button,
.secondary-button,
.add-button,
.placeholder-panel button,
.range-button,
.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--text);
  background: #fff;
  box-shadow: var(--shadow);
  cursor: pointer;
}

.primary-button {
  width: 100%;
  margin-top: 12px;
  color: #fff;
  background: var(--blue);
  border-color: var(--blue);
  font-weight: 700;
}

.primary-button.compact {
  width: auto;
  justify-self: start;
  padding: 0 14px;
}

.secondary-button {
  height: 34px;
  padding: 0 12px;
  color: var(--text);
  font-weight: 700;
}

.secondary-button.danger {
  color: #9f2a1d;
  border-color: #ffd7ce;
  background: #fff7f5;
}

.primary-button:hover,
.add-button:hover {
  filter: brightness(0.97);
}

.app-shell {
  display: grid;
  min-height: 100vh;
  grid-template-columns: 258px minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 0;
  display: flex;
  height: 100vh;
  flex-direction: column;
  gap: 14px;
  padding: 20px 16px;
  background: #fbfbfc;
  border-right: 1px solid var(--line);
}

.account-brand {
  min-height: 34px;
  overflow: hidden;
  white-space: nowrap;
}

.account-brand span:last-child {
  overflow: hidden;
  text-overflow: ellipsis;
}

.search-box {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 34px;
  padding: 0 12px;
  color: var(--muted-soft);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 7px;
  box-shadow: var(--shadow);
  font-size: 13px;
}

.search-box span {
  flex: 1;
}

kbd {
  color: #a4a7ad;
  font-size: 12px;
  font-family: inherit;
}

.nav-stack {
  display: grid;
  gap: 4px;
}

.nav-heading {
  padding: 12px 12px 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 36px;
  padding: 0 12px;
  border-radius: 7px;
  color: #5f6268;
  font-size: 14px;
  font-weight: 650;
}

.nav-item svg {
  color: #9a9da4;
}

.nav-item:hover,
.nav-item.is-active {
  color: var(--text);
  background: #f0f0f1;
}

.nav-item.is-active svg {
  color: var(--brand-dark);
}

.sidebar-footer {
  margin-top: auto;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.nav-item.subtle {
  color: var(--muted);
}

.workspace {
  min-width: 0;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 58px;
  padding: 0 28px;
  background: #fff;
  border-bottom: 1px solid var(--line);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 20px;
}

.topbar-link {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: #4f5258;
  font-size: 14px;
  font-weight: 700;
}

.avatar {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 50% 34%, #787c84 0 4px, transparent 4px),
    radial-gradient(circle at 50% 110%, #787c84 0 8px, transparent 8px);
}

.content {
  width: min(1300px, calc(100% - 48px));
  margin: 0 auto;
  padding: 12px 0 48px;
}

.notice-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  min-height: 44px;
  margin: 0 0 42px;
  padding: 0 16px;
  color: #2850bd;
  background: #e9f0ff;
  border-radius: 7px;
  font-size: 14px;
  font-weight: 650;
}

.notice-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.notice-left span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.notice-banner a {
  flex: 0 0 auto;
  font-size: 13px;
  font-weight: 750;
}

.page-head,
.analytics-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
}

.head-actions {
  display: flex;
  gap: 8px;
}

.icon-button {
  width: 38px;
  padding: 0;
}

.add-button {
  padding: 0 14px;
  color: #fff;
  background: var(--blue);
  border-color: var(--blue);
  font-weight: 700;
}

.analytics-head {
  margin: 28px 0 10px;
}

.analytics-head h2 {
  margin: 0;
  font-size: 17px;
}

.range-button {
  padding: 0 12px;
  font-weight: 650;
}

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.metric-card,
.panel-card {
  overflow: hidden;
  min-height: 138px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.metric-card.wide {
  grid-column: span 1;
}

.metric-card header,
.panel-card header {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding: 0 16px;
  color: var(--muted);
  background: var(--panel-soft);
  border-bottom: 1px solid var(--line);
  font-weight: 700;
}

.panel-card header {
  justify-content: space-between;
}

.metric-split {
  display: grid;
  grid-template-columns: minmax(120px, 0.86fr) minmax(130px, 1fr);
  min-height: 98px;
}

.metric-split > div:first-child {
  padding: 18px 16px;
}

.metric-label {
  margin-bottom: 4px;
  font-size: 12px;
}

.metric-split strong {
  display: inline-block;
  margin-right: 8px;
  color: #18191b;
  font-size: 24px;
  line-height: 1;
}

.positive,
.negative {
  font-size: 13px;
  font-weight: 750;
}

.positive {
  color: var(--green);
}

.negative {
  color: var(--red);
}

.sparkline {
  align-self: stretch;
  border-left: 1px solid var(--line);
  background-repeat: no-repeat;
  background-size: 100% 100%;
}

.sparkline.blue {
  background-image:
    linear-gradient(to top, rgba(78, 134, 255, 0.22), rgba(78, 134, 255, 0)),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 180 96'%3E%3Cpath d='M0 65 L12 62 L24 68 L36 52 L48 69 L60 46 L72 72 L84 42 L96 58 L108 50 L120 74 L132 38 L144 64 L156 55 L168 60 L180 47' fill='none' stroke='%234e86ff' stroke-width='3'/%3E%3C/svg%3E");
}

.sparkline.orange {
  background-image:
    linear-gradient(to top, rgba(243, 128, 32, 0.18), rgba(243, 128, 32, 0)),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 180 96'%3E%3Cpath d='M0 72 L14 76 L28 45 L42 78 L56 60 L70 67 L84 52 L98 69 L112 64 L126 57 L140 66 L154 41 L168 62 L180 58' fill='none' stroke='%23f38020' stroke-width='3'/%3E%3C/svg%3E");
}

.sparkline.green {
  background-image:
    linear-gradient(to top, rgba(34, 165, 90, 0.18), rgba(34, 165, 90, 0)),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 180 96'%3E%3Cpath d='M0 76 L12 52 L24 64 L36 48 L48 70 L60 58 L72 62 L84 43 L96 68 L108 57 L120 63 L132 40 L144 56 L156 52 L168 67 L180 46' fill='none' stroke='%2322a55a' stroke-width='3'/%3E%3C/svg%3E");
}

.panel-card {
  min-height: 238px;
}

.placeholder-panel {
  display: grid;
  min-height: 197px;
  place-items: center;
  align-content: center;
  gap: 10px;
  padding: 26px;
  text-align: center;
}

.placeholder-panel > svg {
  width: 32px;
  height: 32px;
  color: #7d8087;
}

.placeholder-panel h2 {
  margin: 4px 0 0;
  font-size: 18px;
}

.placeholder-panel p {
  max-width: 360px;
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}

.placeholder-panel button {
  margin-top: 8px;
  padding: 0 16px;
  font-weight: 700;
}

.activity-list {
  display: grid;
  gap: 0;
  margin: 0;
  padding: 0;
  list-style: none;
}

.activity-list li {
  display: flex;
  gap: 12px;
  min-height: 64px;
  padding: 13px 16px;
  border-bottom: 1px solid var(--line);
}

.activity-list li:last-child {
  border-bottom: 0;
}

.activity-list strong {
  font-size: 14px;
}

.activity-list p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.status-dot {
  width: 16px;
  height: 16px;
  margin-top: 2px;
  border: 2px solid var(--blue);
  border-radius: 50%;
}

.status-dot.good {
  border-color: var(--green);
  background: radial-gradient(circle, var(--green) 0 3px, transparent 3px);
}

.status-dot.warn {
  border-color: var(--brand);
}

.user-workflow-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-top: 22px;
}

.workflow-panel,
.qr-result,
.credential-callout,
.users-table-section {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.workflow-panel header {
  min-height: 42px;
  padding: 0 16px;
  background: var(--panel-soft);
  border-bottom: 1px solid var(--line);
}

.workflow-panel h2,
.qr-result h2,
.credential-callout h2 {
  margin: 0;
  font-size: 17px;
}

.workflow-panel header {
  display: flex;
  align-items: center;
}

.portal-form {
  display: grid;
  gap: 10px;
  padding: 16px;
}

.portal-form label {
  color: var(--text);
  font-size: 13px;
  font-weight: 650;
}

.portal-form input {
  width: 100%;
  height: 40px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  padding: 0 12px;
  color: var(--text);
  background: #fff;
  outline: none;
}

.portal-form input:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(63, 111, 244, 0.14);
}

.qr-result {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 22px;
  align-items: center;
  margin-top: 22px;
  padding: 20px;
}

.credential-callout {
  margin-top: 22px;
  padding: 20px;
}

.credential-callout p:last-child {
  margin-bottom: 0;
}

.muted-text {
  margin: 8px 0 0;
  color: var(--muted);
  line-height: 1.45;
}

code {
  padding: 2px 5px;
  color: #1d2738;
  background: #eef2f8;
  border: 1px solid #dbe2ee;
  border-radius: 4px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 0.93em;
}

.qr-code {
  width: 280px;
  height: 280px;
  justify-self: end;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.users-table-section {
  overflow: auto;
  margin-top: 14px;
}

.users-table {
  width: 100%;
  min-width: 760px;
  border-collapse: collapse;
  background: #fff;
}

.users-table th,
.users-table td {
  padding: 13px 14px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
  font-size: 14px;
}

.users-table th {
  color: var(--muted);
  background: var(--panel-soft);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.users-table tr:last-child td {
  border-bottom: 0;
}

.row-action {
  width: 1%;
  white-space: nowrap;
}

.row-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.portal-modal {
  width: min(440px, calc(100vw - 32px));
  border: 0;
  border-radius: 8px;
  padding: 0;
  color: var(--text);
  background: transparent;
}

.portal-modal::backdrop {
  background: rgba(15, 23, 42, 0.42);
}

.modal-panel {
  display: grid;
  gap: 18px;
  padding: 22px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.modal-header h2 {
  margin: 0;
  font-size: 18px;
}

.modal-header p {
  margin: 8px 0 0;
  color: var(--muted);
  line-height: 1.45;
  white-space: normal;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.modal-actions .primary-button {
  margin-top: 0;
}

.modal-qr-code {
  justify-self: center;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  margin-left: 6px;
  padding: 0 8px;
  color: #4f5258;
  background: #f1f2f4;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 750;
}

.status-pill.good {
  color: #146c36;
  background: #e8f8ee;
}

.status-pill.warn {
  color: #9a5a00;
  background: #fff4df;
}

.status-pill.danger {
  color: #9f2a1d;
  background: #fff1ee;
}

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
    padding: 14px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .nav-stack {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .nav-heading,
  .search-box,
  .sidebar-footer {
    display: none;
  }

  .nav-item {
    justify-content: center;
  }

  .content {
    width: min(100% - 28px, 920px);
    padding-top: 18px;
  }

  .notice-banner {
    margin-bottom: 28px;
  }

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

  .user-workflow-grid,
  .qr-result {
    grid-template-columns: 1fr;
  }

  .qr-code {
    justify-self: start;
  }
}

@media (max-width: 640px) {
  .topbar {
    height: 50px;
    padding: 0 14px;
  }

  .topbar-link {
    font-size: 0;
    gap: 0;
  }

  .topbar-link svg {
    width: 20px;
    height: 20px;
  }

  .account-brand {
    justify-content: center;
  }

  .page-head,
  .analytics-head,
  .notice-banner {
    align-items: stretch;
    flex-direction: column;
  }

  .head-actions {
    display: grid;
    grid-template-columns: 38px 38px 1fr;
  }

  .range-button,
  .add-button {
    width: 100%;
  }

  .notice-left span {
    white-space: normal;
  }

  .nav-item {
    padding: 0 8px;
    font-size: 13px;
  }

  .metric-split {
    grid-template-columns: 1fr;
  }

  .sparkline {
    min-height: 74px;
    border-top: 1px solid var(--line);
    border-left: 0;
  }
}
