:root {
  --bg: #f5f7fb;
  --panel: #ffffff;
  --panel-soft: #eef4f8;
  --text: #17202a;
  --muted: #647181;
  --line: #dfe6ee;
  --accent: #12736d;
  --accent-strong: #0f5f5a;
  --warning: #b7791f;
  --danger: #b42318;
  --ok: #137333;
  --shadow: 0 12px 30px rgba(25, 42, 70, 0.08);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  scroll-padding-top: 14px;
}

body {
  margin: 0;
  min-width: 320px;
  color: var(--text);
  background: var(--bg);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

[hidden] {
  display: none !important;
}

body.auth-pending {
  min-height: 100vh;
  display: grid;
  place-items: center;
}

button,
input,
textarea {
  font: inherit;
}

button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 14px;
  color: var(--text);
  background: #ffffff;
  cursor: pointer;
  transition:
    border-color 160ms ease,
    background 160ms ease,
    transform 160ms ease;
}

button:hover:not(:disabled) {
  border-color: #a8bac9;
  background: #f8fbfd;
}

button:active:not(:disabled) {
  transform: translateY(1px);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

button svg {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
}

.primary {
  border-color: var(--accent);
  color: #ffffff;
  background: var(--accent);
}

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

.shell {
  width: min(1440px, 100%);
  margin: 0 auto;
  padding: 28px;
}

.mobile-quicknav {
  display: none;
}

.login-view {
  width: min(100%, 440px);
  padding: 18px;
}

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

.login-copy {
  margin: 10px 0 22px;
  color: var(--muted);
  line-height: 1.5;
}

.login-submit {
  width: 100%;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 20px;
}

.topbar-side {
  display: grid;
  gap: 10px;
}

.session {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 10px;
}

.session span {
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(30px, 4vw, 48px);
  line-height: 1;
}

h2 {
  margin-bottom: 0;
  font-size: 18px;
}

.summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(88px, 1fr));
  gap: 10px;
}

.summary div {
  min-width: 88px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.summary span {
  display: block;
  font-size: 26px;
  font-weight: 800;
  line-height: 1;
}

.summary small,
.muted {
  color: var(--muted);
}

.workspace,
.scanner-grid {
  display: grid;
  grid-template-columns: 360px 1fr;
  gap: 18px;
  margin-bottom: 18px;
}

.scanner-grid {
  grid-template-columns: minmax(360px, 0.85fr) minmax(320px, 1fr);
}

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

.controls,
.guest-panel,
.scanner-panel,
.result-panel,
.qr-panel {
  padding: 18px;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  min-height: 42px;
  margin-bottom: 16px;
}

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

.field {
  display: grid;
  gap: 8px;
  margin-bottom: 14px;
}

.field span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 11px 12px;
  color: var(--text);
  background: #ffffff;
  outline: none;
}

textarea {
  min-height: 152px;
  resize: vertical;
}

input:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(18, 115, 109, 0.14);
}

.button-row,
.result-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 10px;
}

.button-row button,
.result-actions button {
  flex: 1 1 150px;
}

.message {
  min-height: 22px;
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.message.error {
  color: var(--danger);
}

.message.success {
  color: var(--ok);
}

.search {
  position: relative;
  width: min(320px, 100%);
}

.search-stack {
  display: grid;
  gap: 6px;
  width: min(360px, 100%);
}

.search svg {
  position: absolute;
  top: 50%;
  left: 11px;
  width: 17px;
  height: 17px;
  color: var(--muted);
  transform: translateY(-50%);
}

.search input {
  padding-left: 36px;
  padding-right: 42px;
}

.search-clear {
  position: absolute;
  top: 50%;
  right: 6px;
  display: none;
  width: 30px;
  min-height: 30px;
  border: 0;
  padding: 0;
  color: var(--muted);
  background: transparent;
  transform: translateY(-50%);
}

.search-clear.visible {
  display: inline-flex;
}

.search-clear svg {
  position: static;
  width: 16px;
  height: 16px;
  transform: none;
}

.search-count {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.table-wrap {
  position: relative;
  overflow: auto;
  max-height: 430px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

table {
  width: 100%;
  min-width: 720px;
  border-collapse: collapse;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 12px;
  text-align: left;
  vertical-align: middle;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  color: var(--muted);
  background: var(--panel-soft);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

td {
  font-size: 14px;
}

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

.id-code {
  font-family: "Cascadia Mono", "SFMono-Regular", Consolas, monospace;
  font-weight: 700;
}

.status {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border-radius: 999px;
  padding: 0 10px;
  font-size: 12px;
  font-weight: 800;
}

.status.ok {
  color: #0d4f25;
  background: #dcfce7;
}

.status.pending {
  color: #6b4d10;
  background: #fef3c7;
}

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

.row-actions button {
  min-height: 34px;
  padding: 0 10px;
}

.empty-state {
  display: none;
  place-items: center;
  gap: 10px;
  min-height: 220px;
  color: var(--muted);
}

.empty-state svg {
  width: 42px;
  height: 42px;
}

.empty-state.visible {
  display: grid;
}

.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.segmented button {
  min-height: 36px;
  border: 0;
  border-radius: 0;
  padding: 0 12px;
  background: #ffffff;
}

.segmented button.active {
  color: #ffffff;
  background: var(--accent);
}

.camera-frame {
  position: relative;
  aspect-ratio: 16 / 10;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #141b20;
}

.camera-frame video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.scan-guide {
  position: absolute;
  inset: 20%;
  border: 3px solid rgba(255, 255, 255, 0.9);
  border-radius: 8px;
  box-shadow: 0 0 0 999px rgba(0, 0, 0, 0.32);
  pointer-events: none;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  border-radius: 999px;
  padding: 0 12px;
  color: var(--accent-strong);
  background: #d8f2ef;
  font-size: 13px;
  font-weight: 800;
}

.scan-result {
  display: grid;
  grid-template-columns: 42px 1fr;
  gap: 14px;
  align-items: start;
  min-height: 176px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  background: #fafcfe;
}

.scan-result svg {
  width: 38px;
  height: 38px;
  color: var(--muted);
}

.scan-result h3 {
  margin: 0 0 4px;
  font-size: 22px;
}

.scan-result p {
  margin-bottom: 8px;
  color: var(--muted);
}

.scan-result.success {
  border-color: #b7e4c7;
  background: #f0fdf4;
}

.scan-result.warning {
  border-color: #f4cf8b;
  background: #fff8eb;
}

.scan-result.error {
  border-color: #f4b4ac;
  background: #fff4f2;
}

.qr-panel {
  margin-top: 18px;
}

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

.qr-card {
  display: grid;
  gap: 8px;
  place-items: center;
  border: 1px dashed #b8c5d2;
  border-radius: 8px;
  padding: 14px;
  min-height: 260px;
  text-align: center;
  background: #ffffff;
}

.qr-card canvas,
.qr-card img {
  width: 148px !important;
  height: 148px !important;
}

.qr-card strong {
  max-width: 100%;
  overflow-wrap: anywhere;
  font-size: 15px;
}

.qr-card span {
  font-family: "Cascadia Mono", "SFMono-Regular", Consolas, monospace;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

@media (max-width: 980px) {
  .shell {
    padding: 18px;
  }

  .topbar,
  .workspace,
  .scanner-grid {
    grid-template-columns: 1fr;
  }

  .topbar {
    display: grid;
  }

  .session {
    justify-content: flex-start;
  }

  .summary {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (max-width: 560px) {
  body:not(.auth-pending) {
    padding-right: 58px;
  }

  .shell {
    padding: 12px 10px 22px;
  }

  .mobile-quicknav {
    position: fixed;
    top: 50%;
    right: 8px;
    z-index: 30;
    display: grid;
    gap: 8px;
    padding: 7px;
    border: 1px solid rgba(18, 115, 109, 0.18);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.94);
    box-shadow: 0 14px 30px rgba(25, 42, 70, 0.16);
    transform: translateY(-50%);
    backdrop-filter: blur(10px);
  }

  .mobile-quicknav a {
    display: grid;
    place-items: center;
    gap: 2px;
    width: 44px;
    min-height: 48px;
    border-radius: 999px;
    color: var(--accent-strong);
    text-decoration: none;
    font-size: 10px;
    font-weight: 800;
  }

  .mobile-quicknav a:active,
  .mobile-quicknav a:focus-visible {
    background: #d8f2ef;
  }

  .mobile-quicknav svg {
    width: 19px;
    height: 19px;
  }

  .topbar {
    gap: 12px;
    margin-bottom: 12px;
  }

  h1 {
    font-size: 30px;
    line-height: 1.05;
  }

  .session {
    display: grid;
    grid-template-columns: 1fr auto;
    justify-content: stretch;
  }

  .session button {
    min-height: 36px;
    padding: 0 10px;
  }

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

  .summary div {
    min-width: 0;
    padding: 10px;
  }

  .summary span {
    font-size: 22px;
  }

  .workspace,
  .scanner-grid {
    gap: 12px;
    margin-bottom: 12px;
  }

  .controls,
  .guest-panel,
  .scanner-panel,
  .result-panel,
  .qr-panel {
    padding: 14px;
  }

  .panel-header {
    align-items: stretch;
    flex-direction: column;
    gap: 10px;
    min-height: 0;
    margin-bottom: 12px;
  }

  .search,
  .search-stack,
  .segmented {
    width: 100%;
  }

  .search input {
    min-height: 46px;
    font-size: 16px;
  }

  .button-row,
  .result-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  .button-row button,
  .result-actions button {
    min-width: 0;
    flex: initial;
    padding: 0 10px;
  }

  .camera-frame {
    aspect-ratio: 4 / 5;
  }

  .scan-guide {
    inset: 16%;
  }

  .scan-result {
    grid-template-columns: 1fr;
    min-height: auto;
    padding: 14px;
  }

  .scan-result svg {
    width: 30px;
    height: 30px;
  }

  .scan-result h3 {
    font-size: 18px;
    line-height: 1.25;
  }

  .table-wrap {
    max-height: none;
    border: 0;
    overflow: visible;
  }

  table,
  thead,
  tbody,
  tr,
  td {
    display: block;
    width: 100%;
    min-width: 0;
  }

  thead {
    display: none;
  }

  tr {
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 10px;
    background: #ffffff;
    box-shadow: 0 8px 20px rgba(25, 42, 70, 0.06);
  }

  td {
    display: grid;
    grid-template-columns: 82px 1fr;
    gap: 10px;
    border-bottom: 0;
    padding: 6px 0;
    align-items: center;
  }

  td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
  }

  td[data-label="Aksi"] {
    grid-template-columns: 1fr;
  }

  td[data-label="Aksi"]::before {
    display: none;
  }

  .row-actions {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    justify-content: stretch;
    gap: 7px;
  }

  .row-actions button {
    width: 100%;
    min-height: 40px;
    padding: 0;
  }

  .row-actions button svg {
    width: 17px;
    height: 17px;
  }

  .qr-panel {
    margin-top: 12px;
  }

  .qr-grid {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .qr-card {
    grid-template-columns: 124px 1fr;
    place-items: center start;
    min-height: 150px;
    text-align: left;
  }

  .qr-card canvas,
  .qr-card img {
    width: 116px !important;
    height: 116px !important;
    grid-row: span 2;
  }
}

@media print {
  body {
    background: #ffffff;
  }

  .topbar,
  .workspace,
  .scanner-grid,
  .qr-panel > .panel-header {
    display: none !important;
  }

  .shell,
  .qr-panel {
    width: 100%;
    padding: 0;
    margin: 0;
    border: 0;
    box-shadow: none;
  }

  .qr-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 10mm;
  }

  .qr-card {
    break-inside: avoid;
    min-height: 62mm;
  }
}
