:root {
  --stone-50: #fafaf9;
  --stone-100: #f5f5f4;
  --stone-200: #e7e5e4;
  --stone-300: #d6d3d1;
  --stone-500: #78716c;
  --stone-600: #57534e;
  --stone-700: #44403c;
  --stone-900: #1c1917;
  --white: #ffffff;
  --green-50: #f0fdf4;
  --green-600: #16a34a;
  --red-50: #fef2f2;
  --red-600: #dc2626;
  --radius: 6px;
  --sidebar: 232px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--stone-900);
  background: var(--stone-50);
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; background: var(--stone-50); color: var(--stone-900); font-size: 14px; letter-spacing: 0; }
button, input, select { font: inherit; letter-spacing: 0; }
a { color: inherit; text-decoration: none; }
.icon { width: 16px; height: 16px; stroke-width: 1.8; flex: 0 0 auto; }
.auth-body { display: grid; place-items: center; padding: 20px; background: var(--stone-100); }
.auth-shell { width: 100%; max-width: 380px; }
.auth-card { padding: 24px; background: var(--white); border: 1px solid var(--stone-200); border-radius: var(--radius); box-shadow: 0 10px 30px rgba(28, 25, 23, .06); }
.auth-heading { display: flex; gap: 12px; align-items: center; margin-bottom: 24px; }
.auth-heading h1 { margin: 0 0 4px; font-size: 20px; line-height: 1.25; }
.auth-heading p, .page-heading p, .section-heading p { margin: 0; color: var(--stone-500); }
.brand-mark { width: 30px; height: 30px; display: grid; place-items: center; border-radius: var(--radius); background: var(--stone-900); color: white; }
.brand-mark.large { width: 40px; height: 40px; }
.brand-mark.large .icon { width: 20px; height: 20px; }
.stack-form { display: grid; gap: 14px; }
.field { display: grid; gap: 6px; min-width: 0; }
.field label { font-size: 13px; font-weight: 600; }
input, select { width: 100%; height: 38px; padding: 0 11px; border: 1px solid var(--stone-300); border-radius: var(--radius); background: var(--white); color: var(--stone-900); outline: none; }
input::placeholder { color: #a8a29e; }
input:focus, select:focus { border-color: var(--stone-700); box-shadow: 0 0 0 3px rgba(68, 64, 60, .1); }
.button { min-height: 38px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 0 14px; border: 1px solid transparent; border-radius: var(--radius); font-weight: 600; cursor: pointer; white-space: nowrap; }
.button-primary { background: var(--stone-900); color: white; }
.button-primary:hover { background: var(--stone-700); }
.button-secondary { background: var(--white); border-color: var(--stone-300); color: var(--stone-900); }
.alert { display: flex; gap: 9px; align-items: flex-start; padding: 10px 12px; margin-bottom: 14px; border: 1px solid var(--stone-200); border-radius: var(--radius); background: var(--white); font-size: 13px; }
.alert-error { border-color: #fecaca; background: var(--red-50); color: #991b1b; }
.alert-success { border-color: #bbf7d0; background: var(--green-50); color: #166534; }
.app-shell { min-height: 100vh; }
.sidebar { display: none; }
.mobile-header { height: 56px; display: flex; align-items: center; justify-content: space-between; padding: 0 16px; border-bottom: 1px solid var(--stone-200); background: rgba(255, 255, 255, .96); position: sticky; top: 0; z-index: 20; }
.brand { display: flex; gap: 10px; align-items: center; }
.brand > span:last-child { display: grid; }
.brand strong { font-size: 14px; }
.brand small, .user-copy small { color: var(--stone-500); font-size: 11px; margin-top: 1px; }
.avatar { width: 30px; height: 30px; display: grid; place-items: center; border-radius: 50%; background: var(--stone-200); font-size: 12px; font-weight: 700; }
.mobile-nav { position: fixed; z-index: 30; left: 0; right: 0; bottom: 0; min-height: 58px; display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; border-top: 1px solid var(--stone-200); background: rgba(255,255,255,.98); padding-bottom: env(safe-area-inset-bottom); }
.mobile-nav form { display: contents; }
.nav-item { display: flex; align-items: center; gap: 9px; color: var(--stone-600); border: 0; background: transparent; cursor: pointer; }
.mobile-nav .nav-item { min-width: 0; flex-direction: column; justify-content: center; gap: 3px; padding: 7px 4px; font-size: 11px; }
.nav-item.active { color: var(--stone-900); font-weight: 600; }
.main-content { width: 100%; max-width: 1120px; margin: 0 auto; padding: 22px 16px 84px; }
.page-heading { display: flex; justify-content: space-between; margin-bottom: 18px; }
.page-heading h1 { margin: 2px 0 5px; font-size: 22px; line-height: 1.25; }
.eyebrow { font-size: 11px; font-weight: 700; text-transform: uppercase; color: var(--stone-500); }
.lookup-panel { padding: 16px; border: 1px solid var(--stone-200); background: var(--white); border-radius: var(--radius); margin-bottom: 16px; }
.input-action { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; }
.panel { padding: 16px; border: 1px solid var(--stone-200); border-radius: var(--radius); background: var(--white); }
.section-heading { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; margin-bottom: 14px; }
.section-heading h2 { margin: 0 0 3px; font-size: 14px; }
.result-section { display: grid; gap: 12px; margin-bottom: 22px; }
.result-status { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border: 1px solid var(--stone-200); border-radius: var(--radius); background: var(--white); }
.result-status.success { border-color: #bbf7d0; background: var(--green-50); color: #166534; }
.result-status.not-found { border-color: #fed7aa; background: #fff7ed; color: #9a3412; }
.result-status > .icon { width: 20px; height: 20px; }
.result-status div { display: grid; gap: 2px; min-width: 0; }
.result-status span { font-size: 12px; }
.attempt-badge { margin-left: auto; padding: 3px 7px; border-radius: var(--radius); background: rgba(255,255,255,.7); white-space: nowrap; }
.result-grid { display: grid; gap: 12px; }
.detail-list { margin: 0; display: grid; gap: 0; }
.detail-list > div { display: grid; grid-template-columns: 120px minmax(0, 1fr); gap: 12px; padding: 9px 0; border-top: 1px solid var(--stone-100); }
.detail-list > div:first-child { border-top: 0; }
.detail-list dt { color: var(--stone-500); font-size: 12px; }
.detail-list dd { margin: 0; font-weight: 500; word-break: break-word; }
.history-section { margin-top: 22px; }
.history-list { border: 1px solid var(--stone-200); border-radius: var(--radius); background: var(--white); overflow: hidden; }
.history-row { display: grid; grid-template-columns: 30px minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 11px 12px; border-top: 1px solid var(--stone-100); }
.history-row:first-child { border-top: 0; }
.history-row > div { display: grid; gap: 2px; }
.history-row small { color: var(--stone-500); font-size: 11px; }
.history-icon { width: 26px; height: 26px; display: grid; place-items: center; border-radius: 50%; background: var(--stone-100); color: var(--stone-500); }
.history-icon.found { background: var(--green-50); color: var(--green-600); }
.badge { display: inline-flex; width: fit-content; padding: 3px 7px; border-radius: var(--radius); background: var(--stone-100); color: var(--stone-600); font-size: 11px; font-weight: 600; white-space: nowrap; }
.badge-success { background: var(--green-50); color: var(--green-600); }
.badge-muted { background: var(--stone-100); color: var(--stone-500); }
.text-muted { color: var(--stone-500); }
.nric-link { font: inherit; color: var(--stone-900); background: transparent; border: 0; padding: 0; cursor: pointer; text-align: left; }
.nric-link:hover strong { text-decoration: underline; color: #000; }
.history-table { min-width: 680px; }
.empty-state { min-height: 100px; display: grid; place-items: center; align-content: center; gap: 7px; border: 1px dashed var(--stone-300); border-radius: var(--radius); color: var(--stone-500); }
.table-panel .empty-state { margin: 16px; }
.users-layout { display: grid; gap: 14px; }
.table-panel { min-width: 0; padding: 0; overflow: hidden; }
.table-panel > .section-heading { padding: 16px 16px 0; }
.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 560px; }
th, td { padding: 10px 12px; text-align: left; border-top: 1px solid var(--stone-100); font-size: 12px; }
th { color: var(--stone-500); font-weight: 600; background: var(--stone-50); }
td:first-child { display: grid; gap: 2px; }
td small { color: var(--stone-500); }
.status-dot { display: inline-block; width: 7px; height: 7px; margin-right: 6px; border-radius: 50%; background: var(--stone-300); }
.status-dot.online { background: var(--green-600); }
.icon-button { width: 30px; height: 30px; display: grid; place-items: center; border: 0; border-radius: var(--radius); background: transparent; color: var(--stone-500); cursor: pointer; }
.icon-button:hover { background: var(--stone-100); color: var(--stone-900); }
.button-sm { min-height: 28px; padding: 0 8px; font-size: 11px; gap: 4px; border-radius: 4px; }
.button-sm .icon { width: 13px; height: 13px; }
.button-danger { background: var(--red-50); border-color: #fecaca; color: #b91c1c; }
.button-danger:hover { background: #fee2e2; border-color: #f87171; color: #991b1b; }
.action-cell { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.inline-form { display: inline-flex; margin: 0; }
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(28, 25, 23, 0.45);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 16px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .15s ease;
}
.modal-backdrop.is-open {
  opacity: 1;
  pointer-events: auto;
}
.modal-card {
  width: 100%;
  max-width: 420px;
  background: var(--white);
  border: 1px solid var(--stone-200);
  border-radius: var(--radius);
  box-shadow: 0 16px 36px rgba(28, 25, 23, .12);
  padding: 22px;
}
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 16px;
}
.modal-header h3 {
  margin: 0 0 4px;
  font-size: 16px;
}
.modal-header p {
  margin: 0;
  color: var(--stone-500);
  font-size: 12px;
}
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 18px;
}

@media (max-width: 879px) {
  input, select { font-size: 16px; }
}

@media (min-width: 720px) {
  .result-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .users-layout { grid-template-columns: minmax(260px, 320px) minmax(0, 1fr); align-items: start; }
}

@media (min-width: 880px) {
  .mobile-header, .mobile-nav { display: none; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: var(--sidebar); display: flex; flex-direction: column; padding: 18px 12px; border-right: 1px solid var(--stone-200); background: var(--white); }
  .sidebar .brand { padding: 0 8px 18px; border-bottom: 1px solid var(--stone-100); }
  .nav-list { display: grid; gap: 3px; margin-top: 14px; }
  .sidebar .nav-item { min-height: 36px; padding: 0 10px; border-radius: var(--radius); }
  .sidebar .nav-item:hover, .sidebar .nav-item.active { background: var(--stone-100); }
  .sidebar-user { margin-top: auto; display: grid; grid-template-columns: 30px minmax(0, 1fr) 30px; gap: 9px; align-items: center; padding: 12px 8px 0; border-top: 1px solid var(--stone-100); }
  .user-copy { display: grid; min-width: 0; }
  .user-copy strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; }
  .main-content { margin-left: var(--sidebar); width: calc(100% - var(--sidebar)); padding: 30px 34px 40px; }
  .page-heading h1 { font-size: 24px; }
  .lookup-panel { padding: 18px; }
}
