:root {
  --color-primary: #1677ff;
  --color-primary-hover: #0e62d6;
  --color-primary-active: #094bb3;
  --color-primary-disabled: #93c5fd;

  --color-text-main: #111827;
  --color-text-muted: #4b5563;
  --color-text-subtle: #9ca3af;

  --color-bg-page: #ffffff;
  --color-surface-card: #ffffff;
  --color-surface-subtle: #f9fafb;
  --color-surface-tabs: #f3f4f6;

  --color-border: #e5e7eb;
  --color-border-input: #d1d5db;
  --color-border-focus: #1677ff;

  --color-danger: #dc2626;
  --color-danger-hover: #b91c1c;
  --color-success: #16a34a;
  --color-warning: #d97706;

  --font-sans: 'Plus Jakarta Sans', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 10px;
  --radius-card: 16px;
  --radius-pill: 9999px;

  --btn-height: 44px;
  --input-height: 44px;

  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-card: 0 4px 20px -2px rgba(16, 24, 40, 0.06), 0 2px 6px -2px rgba(16, 24, 40, 0.04);
  --shadow-popover: 0 10px 25px -3px rgba(16, 24, 40, 0.1), 0 4px 6px -4px rgba(16, 24, 40, 0.05);

  --focus-ring: 0 0 0 3px rgba(22, 119, 255, 0.15);
}

*, *::before, *::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: #ffffff;
  color: var(--color-text-main);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, p, ol, ul {
  margin: 0;
}

[hidden] {
  display: none !important;
}

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

main:focus {
  outline: none;
}

.skip-link {
  position: absolute;
  left: 1rem;
  top: -4rem;
  z-index: 50;
  padding: 0.5rem 1rem;
  background: #ffffff;
  color: var(--color-text-main);
  border: 2px solid var(--color-primary);
  border-radius: var(--radius-md);
  font-weight: 600;
  text-decoration: none;
  box-shadow: var(--shadow-popover);
}
.skip-link:focus {
  top: 1rem;
}

/* TOPBAR */
.topbar {
  width: 100%;
  border-bottom: 1px solid var(--color-border);
  background: #ffffff;
  position: sticky;
  top: 0;
  z-index: 20;
}

.topbar-inner {
  max-width: 68rem;
  margin: 0 auto;
  padding: 0.75rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--color-text-main);
  letter-spacing: -0.01em;
}

.brand-logo-img {
  width: 28px;
  height: 28px;
  object-fit: contain;
  border-radius: 6px;
  display: block;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

/* PILL STATUS */
.pill {
  margin: 0;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0.75rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-pill);
  font-size: 0.8125rem;
  font-weight: 600;
  background: #ffffff;
  color: var(--color-text-main);
}
.pill::before {
  content: "";
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 50%;
  background: var(--color-text-subtle);
  flex-shrink: 0;
}
.pill[data-tone="ok"]::before {
  background: var(--color-success);
}
.pill[data-tone="warn"]::before {
  background: var(--color-warning);
}
.pill[data-tone="bad"]::before {
  background: var(--color-danger);
}

/* MAIN CONTENT */
main {
  flex: 1;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2.5rem 1rem 3.5rem;
  background: #ffffff;
}

.page-container {
  width: 100%;
  max-width: 27rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.5rem;
}

/* HERO BRAND ABOVE CARD (matching contoh.png) */
.hero-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  padding: 0.25rem 0;
}

.hero-logo-img {
  width: 44px;
  height: 44px;
  object-fit: contain;
  display: block;
}

.hero-title {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--color-text-main);
}

/* CARD COMPONENT */
.card {
  width: 100%;
  background: #ffffff;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-card);
  padding: 2rem 2rem 2.25rem;
  box-shadow: var(--shadow-card);
}

.auth-card {
  display: flex;
  flex-direction: column;
  gap: 1.35rem;
}

.center-card {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: stretch;
}

#view-loading {
  align-items: center;
  text-align: center;
  gap: 1rem;
  padding: 3rem 1.5rem;
}

.card-header {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.title {
  font-size: 1.4rem;
  font-weight: 700;
  line-height: 1.25;
  letter-spacing: -0.02em;
  color: var(--color-text-main);
}

.subtitle {
  font-size: 1.15rem;
  font-weight: 700;
  line-height: 1.3;
  color: var(--color-text-main);
  letter-spacing: -0.01em;
}

.muted {
  color: var(--color-text-muted);
  font-size: 0.875rem;
  line-height: 1.45;
}

.strong {
  font-weight: 600;
  color: var(--color-text-main);
}

.hint {
  color: var(--color-text-muted);
  font-size: 0.8125rem;
  line-height: 1.4;
}

.hint-counter {
  color: var(--color-text-subtle);
  font-size: 0.8125rem;
  font-family: var(--font-mono);
}

.mono {
  font-family: var(--font-mono);
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

/* NOTICE BANNER */
.notice {
  padding: 0.75rem 1rem;
  border-radius: var(--radius-md);
  background: #fff7ed;
  color: #9a3412;
  border: 1px solid #ffedd5;
  font-size: 0.875rem;
  font-weight: 600;
  line-height: 1.4;
}

/* SEGMENTED TABS (Peserta / Perusahaan style from contoh.png) */
.tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 4px;
  background: var(--color-surface-tabs);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
}

.tab {
  height: 38px;
  border: 1px solid transparent;
  border-radius: calc(var(--radius-lg) - 3px);
  background: transparent;
  color: var(--color-text-muted);
  font-family: var(--font-sans);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
}

.tab:hover:not([aria-selected="true"]) {
  color: var(--color-text-main);
}

.tab[aria-selected="true"] {
  background: #ffffff;
  color: var(--color-text-main);
  font-weight: 600;
  border-color: var(--color-border);
  box-shadow: var(--shadow-sm);
}

.tab-panel {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  align-items: stretch;
}

/* QR FRAME */
.qr-frame {
  align-self: center;
  width: 100%;
  max-width: 260px;
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  background: #ffffff;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.qr-image {
  width: 100%;
  height: 100%;
  display: block;
  image-rendering: pixelated;
  padding: 8px;
  background: #ffffff;
}

.qr-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  padding: 1.5rem;
  text-align: center;
  color: var(--color-text-muted);
}

.tab-panel > .hint {
  text-align: center;
}

/* FORM FIELDS & INPUTS (contoh.png style) */
.field {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
}

.field-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.field label {
  font-weight: 600;
  font-size: 0.875rem;
  color: var(--color-text-main);
}

.input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

input, textarea {
  width: 100%;
  min-height: var(--input-height);
  padding: 0.625rem 0.875rem;
  border: 1px solid var(--color-border-input);
  border-radius: var(--radius-md);
  background: #ffffff;
  color: var(--color-text-main);
  font-family: var(--font-sans);
  font-size: 0.9375rem;
  line-height: 1.4;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.input-wrap input {
  padding-right: 2.75rem;
}

textarea {
  resize: vertical;
  min-height: 6.5rem;
  padding: 0.75rem 0.875rem;
}

input::placeholder, textarea::placeholder {
  color: var(--color-text-subtle);
}

input:focus, textarea:focus {
  outline: none;
  border-color: var(--color-border-focus);
  box-shadow: var(--focus-ring);
}

[aria-invalid="true"] {
  border-color: var(--color-danger) !important;
}

.btn-input-icon {
  position: absolute;
  right: 0.5rem;
  top: 50%;
  transform: translateY(-50%);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  border: 0;
  background: transparent;
  color: var(--color-text-subtle);
  border-radius: var(--radius-sm);
  cursor: pointer;
  padding: 0;
}
.btn-input-icon:hover {
  color: var(--color-text-main);
}

/* REMEMBER ME ROW (contoh.png style) */
.remember-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.remember-label {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--color-text-muted);
  cursor: pointer;
  user-select: none;
}

.remember-label input[type="checkbox"] {
  width: 1.125rem;
  min-height: 1.125rem;
  height: 1.125rem;
  border-radius: 4px;
  accent-color: var(--color-primary);
  cursor: pointer;
  margin: 0;
}

.field-error {
  color: var(--color-danger);
  font-size: 0.8125rem;
  font-weight: 600;
  line-height: 1.35;
}
.field-error[data-tone="ok"] {
  color: var(--color-success);
}

/* BUTTONS (contoh.png: Solid, sharp, NO gradients) */
.btn {
  min-height: var(--btn-height);
  padding: 0 1.25rem;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  font-family: var(--font-sans);
  font-size: 0.9375rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  text-decoration: none;
  transition: background-color 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.btn-block {
  width: 100%;
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

/* PRIMARY BUTTON (Solid sharp blue like contoh.png) */
.btn-primary {
  background-color: var(--color-primary);
  color: #ffffff;
  border-color: var(--color-primary);
  box-shadow: var(--shadow-sm);
}

.btn-primary:hover:not(:disabled) {
  background-color: var(--color-primary-hover);
  border-color: var(--color-primary-hover);
}

.btn-primary:active:not(:disabled) {
  background-color: var(--color-primary-active);
  border-color: var(--color-primary-active);
}

/* SECONDARY BUTTON */
.btn-secondary {
  background-color: #ffffff;
  color: var(--color-text-main);
  border-color: var(--color-border-input);
  box-shadow: var(--shadow-sm);
}

.btn-secondary:hover:not(:disabled) {
  background-color: var(--color-surface-subtle);
  border-color: var(--color-border);
}

/* DANGER BUTTON */
.btn-danger {
  background-color: var(--color-danger);
  color: #ffffff;
  border-color: var(--color-danger);
  box-shadow: var(--shadow-sm);
}

.btn-danger:hover:not(:disabled) {
  background-color: var(--color-danger-hover);
  border-color: var(--color-danger-hover);
}

/* GHOST BUTTON */
.btn-ghost {
  background-color: transparent;
  color: var(--color-text-muted);
  border-color: var(--color-border);
  min-height: 2.25rem;
  padding: 0 0.875rem;
  font-size: 0.8125rem;
  border-radius: var(--radius-md);
}

.btn-ghost:hover:not(:disabled) {
  background-color: var(--color-surface-subtle);
  color: var(--color-text-main);
}

.card-actions {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

/* PAIRING RESULT BOX */
.pairing-result {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  align-items: center;
  text-align: center;
  padding: 1.25rem;
  background: var(--color-surface-subtle);
  border: 1px dashed var(--color-border-input);
  border-radius: var(--radius-lg);
}

.pairing-code {
  font-family: var(--font-mono);
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: 0.15em;
  color: var(--color-text-main);
  user-select: all;
  padding: 0.25rem 0.5rem;
}

/* GUIDE BOX */
.guide-box {
  margin-top: 0.5rem;
  padding: 1rem;
  background: var(--color-surface-subtle);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
}

.guide-title {
  font-weight: 600;
  font-size: 0.8125rem;
  color: var(--color-text-main);
  margin-bottom: 0.5rem;
}

.steps {
  padding-left: 1.2rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.8125rem;
  color: var(--color-text-muted);
  line-height: 1.4;
}

/* CONNECTED VIEW LAYOUT */
.connected-layout {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.profile-card {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.profile-header {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.avatar {
  width: 3.5rem;
  height: 3.5rem;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--color-primary);
  color: #ffffff;
  font-size: 1.35rem;
  font-weight: 700;
  flex-shrink: 0;
}

.profile-meta {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  overflow: hidden;
}

.badge-status-online {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--color-success);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.badge-status-online::before {
  content: "";
  width: 0.45rem;
  height: 0.45rem;
  border-radius: 50%;
  background: var(--color-success);
}

.title-connected {
  font-size: 1.2rem;
  margin: 0;
}

/* DIALOG */
.dialog {
  max-width: 26rem;
  width: calc(100% - 2rem);
  padding: 1.5rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-card);
  background: #ffffff;
  color: var(--color-text-main);
  box-shadow: var(--shadow-popover);
}

.dialog::backdrop {
  background: rgba(17, 24, 39, 0.45);
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  margin-top: 0.5rem;
}

/* TOAST */
.toast {
  position: fixed;
  left: 50%;
  bottom: 1.75rem;
  transform: translateX(-50%);
  max-width: calc(100% - 2rem);
  padding: 0.75rem 1.25rem;
  border-radius: var(--radius-md);
  background: var(--color-text-main);
  color: #ffffff;
  font-size: 0.875rem;
  font-weight: 600;
  box-shadow: var(--shadow-popover);
  z-index: 100;
}

/* SPINNER */
.spinner {
  width: 2rem;
  height: 2rem;
  border: 3px solid var(--color-border);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* RESPONSIVE LAYOUT */
@media (min-width: 48rem) {
  .page-container {
    max-width: 28rem;
  }
  .connected-layout {
    max-width: 32rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition: none !important;
  }
}
