@font-face {
  font-family: "AntennaRegularLocal";
  src: url("fonts/Antenna-Regular.otf") format("opentype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

:root {
  color-scheme: light;
  --bg: #f4f6fa;
  --surface: #ffffff;
  --text: #172026;
  --muted: #66717a;
  --line: #dce2e6;
  --accent: #5c00f0;
  --accent-dark: #3b0a8f;
  --accent-soft: #efe7ff;
  --accent-2: #ff852f;
  --teal: #0f766e;
  --danger: #b42318;
  --warning: #b76e00;
  --ok: #1f7a3f;
  --shadow: 0 18px 45px rgba(23, 32, 38, 0.08);
  --font-body: "AntennaRegularLocal", "Segoe UI", Roboto, Arial, sans-serif;
  --font-brand: "Sony Sketch EF", "Sony_Sketch", "Antenna", "Segoe UI", sans-serif;
  --font-title: "AntennaRegularLocal", "Segoe UI", Roboto, Arial, sans-serif;
  --font-heading: "AntennaRegularLocal", "Segoe UI", Roboto, Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(180deg, #ffffff 0, #f8f9fc 240px, var(--bg) 100%);
  color: var(--text);
  font-family: var(--font-body);
}

[hidden] {
  display: none !important;
}

.login-screen {
  display: grid;
  align-content: center;
  min-height: 100vh;
  justify-items: center;
  padding: 18px 16px;
  background: #f3f5f8;
}

.login-card {
  width: min(620px, 100%);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: clamp(24px, 5vw, 38px) clamp(28px, 6vw, 52px);
  background: var(--surface);
  box-shadow: 0 24px 70px rgba(23, 32, 38, 0.13), 0 2px 10px rgba(23, 32, 38, 0.05);
}

.login-card > .brand-mark,
.login-card > h1,
.login-card > p {
  text-align: center;
}

.brand-mark {
  display: block;
  width: 104px;
  height: 104px;
  margin: 0 auto 14px;
  border-radius: 0;
  object-fit: contain;
  box-shadow: none;
}

.login-card h1 {
  max-width: none;
  margin-bottom: 34px;
  font-family: var(--font-title);
  font-size: clamp(28px, 3.4vw, 36px);
  font-weight: 400;
  line-height: 1.06;
  white-space: nowrap;
}

.login-card p {
  max-width: 460px;
  margin: 0 auto 28px;
  color: var(--muted);
  line-height: 1.5;
}

.field-line {
  position: relative;
  display: block;
  margin-bottom: 18px;
  color: var(--text);
  font-size: clamp(17px, 3vw, 20px);
  font-weight: 400;
}

.field-line span {
  display: block;
  margin-bottom: 8px;
  font-weight: 400;
}

.field-line input {
  min-height: 54px;
  padding: 0;
  border: 0;
  border-bottom: 1px solid #cfd7dd;
  border-radius: 0;
  color: #66717a;
  font-size: clamp(17px, 3vw, 20px);
  font-family: var(--font-body);
  font-weight: 400;
  outline: none;
}

.field-line input::placeholder {
  color: transparent;
  opacity: 0;
}

.field-line input:focus {
  border-bottom-color: #5c00f0;
}

.primary-action {
  width: 100%;
  min-height: 52px;
  margin-top: 4px;
  border-color: #5c00f0;
  background: #5c00f0;
  color: #ffffff;
}

.login-footer {
  margin-top: 14px;
  color: #a3adb5;
  font-size: 13px;
  text-align: center;
}

.secondary-action {
  width: 100%;
  min-height: 44px;
  margin-bottom: 8px;
  border-color: #d8c8ff;
  background: #fbf8ff;
  color: var(--accent-dark);
}

.modal-layer {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(23, 32, 38, 0.28);
  backdrop-filter: blur(9px);
  opacity: 1;
  transition: opacity 0.22s ease;
}

.modal-layer.is-closing {
  opacity: 0;
}

.code-modal,
.not-found-modal {
  width: min(460px, 100%);
  border: 1px solid #e4dcff;
  border-radius: 22px;
  padding: 34px;
  background: #ffffff;
  box-shadow: 0 30px 80px rgba(23, 32, 38, 0.22);
  text-align: center;
  transform: translateY(0) scale(1);
  animation: modalIn 0.26s ease both;
}

.modal-layer.is-closing .code-modal,
.modal-layer.is-closing .not-found-modal {
  animation: modalOut 0.2s ease both;
}

.not-found-spinner {
  width: 82px;
  height: 82px;
  margin: 0 auto 14px;
  border-radius: 50%;
  background:
    radial-gradient(circle at center, #ffffff 0 53%, transparent 54%),
    conic-gradient(from 0deg, var(--accent) var(--progress), rgba(92, 0, 240, 0.08) 0);
  filter: drop-shadow(0 14px 24px rgba(92, 0, 240, 0.2));
  animation: spinnerFill 1.18s ease-in-out infinite;
}

.not-found-modal h2 {
  margin-bottom: 10px;
}

.not-found-modal p {
  margin: 0 0 22px;
  color: var(--muted);
  line-height: 1.45;
}

.not-found-modal button {
  min-width: 128px;
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.not-found-modal button:hover {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
  box-shadow: 0 10px 20px rgba(92, 0, 240, 0.18);
}

.code-icon {
  width: 70px;
  height: 70px;
  margin: 0 auto 18px;
  border-radius: 50%;
  background:
    radial-gradient(circle at center, #ffffff 0 28%, transparent 29%),
    conic-gradient(from 0deg, var(--accent), #a855f7, var(--accent-2), var(--accent));
  animation: iconPulse 1.5s ease-in-out infinite;
}

.code-icon.is-ok {
  background:
    radial-gradient(circle at center, #ffffff 0 28%, transparent 29%),
    conic-gradient(from 0deg, #22a06b, #70d49d, #22a06b);
  animation: iconSuccess 0.55s ease both;
}

.code-modal h2 {
  margin-bottom: 10px;
}

.code-help {
  max-width: 360px;
  margin: 0 auto 22px;
  color: var(--muted);
  line-height: 1.45;
}

.code-inputs {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 10px;
  margin-bottom: 16px;
}

.code-inputs input {
  width: 100%;
  min-height: 58px;
  border: 1px solid #d8c8ff;
  border-radius: 12px;
  padding: 0;
  text-align: center;
  font-size: 26px;
}

.code-inputs input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(92, 0, 240, 0.12);
  outline: none;
}

.code-status {
  min-height: 22px;
}

.process-layer {
  z-index: 30;
}

.process-modal {
  width: min(420px, 100%);
  border: 1px solid #e4dcff;
  border-radius: 22px;
  padding: 38px 34px;
  background: #ffffff;
  box-shadow: 0 30px 90px rgba(23, 32, 38, 0.24);
  text-align: center;
  animation: processZoomIn 0.24s ease both;
}

.modal-layer.is-closing .process-modal {
  animation: processZoomOut 0.2s ease both;
}

.process-icon {
  display: grid;
  width: 104px;
  height: 104px;
  margin: 0 auto 14px;
  place-items: center;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  animation: sendFloat 1.25s ease-in-out infinite;
}

.process-icon img {
  width: 96px;
  height: 96px;
  object-fit: contain;
  filter: drop-shadow(0 14px 24px rgba(92, 0, 240, 0.22));
}

.process-icon.is-done {
  background: transparent;
  animation: iconSuccess 0.55s ease both;
}

.process-modal.is-updating h2,
.process-modal.is-updating p {
  animation: processTextSwap 0.32s ease both;
}

.process-modal h2 {
  margin-bottom: 10px;
  font-weight: 400;
}

.process-modal p {
  margin: 0;
  color: var(--muted);
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 400;
  line-height: 1.35;
  text-align: center;
}

.process-modal p span {
  display: block;
  white-space: nowrap;
}

.process-steps {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  width: min(250px, 100%);
  margin: 24px auto 0;
}

.process-steps span {
  height: 5px;
  overflow: hidden;
  border-radius: 999px;
  background: #ede8f8;
}

.process-steps span::before {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), #9b5cff);
  content: "";
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.32s ease;
}

.process-steps span.active::before {
  transform: scaleX(1);
}

.process-modal.is-complete .process-steps span::before {
  background: #22a06b;
  transform: scaleX(1);
}

.process-modal.is-complete h2 {
  color: #176b3a;
}

.document-layer {
  z-index: 30;
}

.document-modal,
.history-modal {
  width: min(1040px, 100%);
  max-height: calc(100vh - 40px);
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 14px;
  background: #ffffff;
  box-shadow: 0 30px 80px rgba(23, 32, 38, 0.24);
  animation: modalIn 0.26s ease both;
}

.history-modal {
  width: min(760px, 100%);
}

.modal-layer.is-closing .document-modal,
.modal-layer.is-closing .history-modal {
  animation: modalOut 0.2s ease both;
}

.document-modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.document-modal-head strong {
  font-family: var(--font-heading);
  font-weight: 400;
}

.document-modal-head button {
  min-height: 34px;
  border-radius: 8px;
}

.scanner-layer {
  padding: 16px;
}

.scanner-modal {
  width: min(780px, 100%);
  max-height: calc(100vh - 32px);
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: #ffffff;
  box-shadow: 0 30px 80px rgba(23, 32, 38, 0.24);
  animation: modalIn 0.26s ease both;
}

.modal-layer.is-closing .scanner-modal {
  animation: modalOut 0.2s ease both;
}

.scanner-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}

.scanner-head strong {
  font-family: var(--font-heading);
  font-weight: 400;
}

.scanner-head button,
.scanner-actions button {
  min-height: 38px;
  border-radius: 8px;
}

.scanner-view {
  position: relative;
  display: grid;
  min-height: min(66vh, 540px);
  overflow: hidden;
  background: #111827;
}

.scanner-view video {
  width: 100%;
  height: 100%;
  min-height: min(66vh, 540px);
  object-fit: cover;
}

.scanner-guide {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  pointer-events: none;
}

.scanner-guide span {
  width: min(72%, 390px);
  max-height: min(76%, 560px);
  aspect-ratio: 0.71;
  border: 3px solid rgba(255, 255, 255, 0.94);
  border-radius: 16px;
  box-shadow:
    0 0 0 999px rgba(0, 0, 0, 0.34),
    0 0 28px rgba(255, 255, 255, 0.32);
}

.scanner-guide.is-ready span {
  border-color: #22c55e;
  box-shadow:
    0 0 0 999px rgba(0, 0, 0, 0.28),
    0 0 30px rgba(34, 197, 94, 0.52);
}

.scanner-status {
  position: absolute;
  right: 16px;
  bottom: 16px;
  left: 16px;
  border-radius: 999px;
  padding: 10px 14px;
  background: rgba(17, 24, 39, 0.82);
  color: #ffffff;
  font-size: 13px;
  line-height: 1.35;
  text-align: center;
}

.scanner-actions {
  display: flex;
  justify-content: center;
  gap: 12px;
  padding: 14px 16px 16px;
  border-top: 1px solid var(--line);
}

.scanner-actions button:last-child {
  border-color: var(--accent);
  background: var(--accent);
  color: #ffffff;
}

.scanner-actions button:last-child:hover {
  border-color: var(--accent);
  background: var(--accent);
  color: #ffffff;
}

.document-viewer {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fbfcfd;
}

.document-viewer img,
.document-viewer iframe {
  display: block;
  width: 100%;
  border: 0;
}

.document-viewer img {
  height: auto;
  min-height: 0;
}

.document-viewer iframe {
  min-height: 68vh;
}

.history-list {
  display: grid;
  gap: 10px;
}

.history-item {
  display: grid;
  grid-template-columns: 90px 1fr auto;
  gap: 12px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
  background: #fbfcfd;
}

.history-item strong,
.history-item span {
  display: block;
}

.history-item small {
  color: var(--muted);
}

@keyframes processZoomIn {
  from {
    opacity: 0;
    transform: scale(0.86);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes processZoomOut {
  from {
    opacity: 1;
    transform: scale(1);
  }
  to {
    opacity: 0;
    transform: scale(0.92);
  }
}

@keyframes processTextSwap {
  0% {
    opacity: 0;
    transform: translateY(8px);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes sendFloat {
  0%,
  100% {
    transform: translateY(0) scale(1);
  }
  50% {
    transform: translateY(-8px) scale(1.04);
  }
}

@keyframes modalIn {
  from {
    opacity: 0;
    transform: translateY(18px) scale(0.96);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes modalOut {
  from {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
  to {
    opacity: 0;
    transform: translateY(12px) scale(0.97);
  }
}

@keyframes iconShake {
  0%,
  100% {
    transform: rotate(0deg) scale(1);
  }
  18% {
    transform: rotate(-7deg) scale(1.04);
  }
  36% {
    transform: rotate(7deg) scale(1.04);
  }
  54% {
    transform: rotate(-5deg) scale(1.02);
  }
  72% {
    transform: rotate(5deg) scale(1.02);
  }
}

@property --progress {
  syntax: "<percentage>";
  inherits: false;
  initial-value: 0%;
}

@keyframes spinnerFill {
  0% {
    --progress: 0%;
    transform: rotate(0deg);
  }
  70% {
    --progress: 100%;
    transform: rotate(240deg);
  }
  100% {
    --progress: 100%;
    transform: rotate(360deg);
  }
}

@keyframes iconPulse {
  0%,
  100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.08);
  }
}

@keyframes iconSuccess {
  0% {
    transform: scale(0.92);
  }
  55% {
    transform: scale(1.14);
  }
  100% {
    transform: scale(1);
  }
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 24px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(10px);
}

.topbar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.section-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  justify-content: flex-end;
  gap: 10px;
}

.section-actions label {
  gap: 4px;
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.section-actions input {
  min-height: 40px;
  width: 150px;
}

.app-logo {
  width: 46px;
  height: 46px;
  border-radius: 0;
  object-fit: contain;
  box-shadow: none;
}

.topbar strong {
  display: block;
  font-family: var(--font-heading);
  font-size: 16px;
  font-weight: 400;
  line-height: 1.2;
}

.topbar span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.2;
}

#employee-name-label {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

#session-label {
  margin-top: 2px;
}

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

button,
.tab,
select {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
}

button {
  cursor: pointer;
  padding: 0 14px;
  font-family: var(--font-heading);
  font-size: 14px;
  font-weight: 400;
}

button[type="submit"],
.tab.active {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.tab.active:hover {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.tab:not(.active):hover,
button:not([type="submit"]):not(.active):hover {
  border-color: #c9b7ff;
  background: #faf8ff;
}

main {
  width: min(1120px, calc(100% - 32px));
  margin: 28px auto 56px;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.capture-grid {
  display: grid;
  grid-template-columns: minmax(0, 820px);
  justify-content: center;
  gap: 20px;
  align-items: stretch;
}

.panel,
.record {
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.panel {
  padding: clamp(20px, 3vw, 30px);
}

.panel.is-locked {
  background: #f8fafc;
}

.panel.is-locked label,
.panel.is-locked .panel-title p {
  color: #8a96a3;
}

.panel.is-locked input,
.panel.is-locked select,
.panel.is-locked .file-picker-control {
  background: #f1f4f7;
  color: #8a96a3;
  cursor: not-allowed;
}

.panel.is-locked .file-picker-control span {
  color: #8a96a3;
  cursor: not-allowed;
  transform: none;
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
}

.form-actions [data-edit-cancel] {
  border-color: #cfd7dd;
  background: #ffffff;
  color: var(--text);
}

.form-actions [data-edit-save][hidden],
.form-actions [data-edit-cancel][hidden] {
  display: none;
}

h1,
h2 {
  margin: 0 0 18px;
  letter-spacing: 0;
}

h1 {
  font-family: var(--font-title);
  font-size: clamp(26px, 3.2vw, 38px);
  font-weight: 400;
  line-height: 1.08;
}

h2 {
  font-family: var(--font-heading);
  font-size: 19px;
  font-weight: 400;
}

.hero-strip {
  display: flex;
  justify-content: center;
  width: min(100%, 820px);
  gap: 24px;
  margin: 0 auto 20px;
  padding: clamp(22px, 4vw, 36px);
  border: 1px solid #e2d9ff;
  border-radius: 22px;
  background:
    linear-gradient(135deg, rgba(92, 0, 240, 0.09), rgba(255, 133, 47, 0.08)),
    #ffffff;
  box-shadow: var(--shadow);
}

.hero-strip > div {
  width: min(100%, 820px);
}

.hero-strip p {
  max-width: 680px;
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.55;
}

.hero-strip h1 {
  margin-bottom: 10px;
}

.eyebrow {
  margin-bottom: 8px !important;
  color: var(--accent) !important;
  font-size: 11px;
  font-weight: 400;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.hero-steps {
  display: none;
  min-width: 170px;
  align-content: center;
  gap: 8px;
}

.step {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 12px;
  background: #fff;
  color: var(--muted);
  font-family: var(--font-heading);
  font-size: 12px;
  font-weight: 400;
  text-transform: uppercase;
}

.step.active {
  border-color: #c9b7ff;
  background: var(--accent-soft);
  color: var(--accent-dark);
}

.panel-title {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.panel-title h2 {
  margin-bottom: 6px;
  font-size: 18px;
  line-height: 1.2;
  font-weight: 400;
}

.panel-title p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
}

.template-download,
.history-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 36px;
  border: 1px solid #cfd7dd;
  border-radius: 8px;
  padding: 0 10px;
  background: #ffffff;
  color: var(--accent-dark);
  font-family: var(--font-heading);
  font-size: 14px;
  text-decoration: none;
}

.template-download:hover,
.history-button:hover {
  border-color: #c9b7ff;
  background: #faf8ff;
}

.template-download span {
  display: grid;
  width: 22px;
  height: 22px;
  place-items: center;
  color: var(--accent);
  font-size: 22px;
  line-height: 1;
}

.file-picker input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.file-picker {
  position: relative;
}

.file-picker-control {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 5px 12px 5px 5px;
  background: var(--surface);
  cursor: pointer;
}

.file-picker-control span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  border-radius: 8px;
  border: 1px solid #cfd7dd;
  padding: 0 14px;
  background: linear-gradient(180deg, #ffffff, #eef2f6);
  color: var(--text);
  font-size: 14px;
  font-weight: 400;
  box-shadow: 0 1px 2px rgba(23, 32, 38, 0.08), inset 0 1px 0 rgba(255, 255, 255, 0.85);
  cursor: pointer;
  user-select: none;
  transition: transform 0.12s ease, box-shadow 0.12s ease, background 0.12s ease, border-color 0.12s ease;
}

.file-picker-control:hover span {
  border-color: #b8c4cc;
  background: linear-gradient(180deg, #ffffff, #e4eaf0);
  box-shadow: 0 2px 6px rgba(23, 32, 38, 0.12), inset 0 1px 0 rgba(255, 255, 255, 0.9);
  transform: translateY(-1px);
}

.file-picker-control:active span {
  background: #e4eaf0;
  box-shadow: inset 0 2px 4px rgba(23, 32, 38, 0.12);
  transform: translateY(0);
}

.file-picker-control span:focus-visible {
  outline: 2px solid rgba(92, 0, 240, 0.22);
  outline-offset: 2px;
}

.file-picker-control small {
  min-width: 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

label {
  display: grid;
  gap: 8px;
  margin-bottom: 14px;
  color: var(--muted);
  font-size: 14px;
}

input {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0 12px;
  font: inherit;
}

.camera-box {
  position: relative;
  display: grid;
  grid-template-rows: 1fr;
  min-height: 320px;
  place-items: center;
  overflow: hidden;
  border: 1px dashed #b8c4cc;
  border-radius: 18px;
  background:
    linear-gradient(180deg, rgba(92, 0, 240, 0.05), rgba(15, 118, 110, 0.06)),
    #fbfcfd;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.18s ease, transform 0.18s ease, box-shadow 0.18s ease;
}

.camera-box.is-valid {
  border-color: #22a06b;
  background:
    linear-gradient(180deg, rgba(34, 160, 107, 0.08), rgba(34, 160, 107, 0.03)),
    #fbfffd;
}

.camera-box.is-invalid {
  border-color: var(--danger);
  background:
    linear-gradient(180deg, rgba(180, 35, 24, 0.08), rgba(180, 35, 24, 0.03)),
    #fffbfb;
}

.camera-box.is-valid .frame {
  border-color: #22a06b;
  box-shadow: 0 0 0 999px rgba(240, 255, 247, 0.5);
}

.camera-box.is-invalid .frame {
  border-color: var(--danger);
  box-shadow: 0 0 0 999px rgba(255, 246, 246, 0.5);
}

.camera-box.is-valid .upload-icon {
  background: #22a06b;
}

.camera-box:hover {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px rgba(92, 0, 240, 0.1);
  transform: translateY(-1px);
}

.camera-box.is-valid:hover {
  border-color: #22a06b;
  box-shadow: inset 0 0 0 1px rgba(34, 160, 107, 0.16);
}

.camera-box.is-invalid:hover {
  border-color: var(--danger);
  box-shadow: inset 0 0 0 1px rgba(180, 35, 24, 0.16);
}

.camera-box input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.frame {
  position: relative;
  display: block;
  width: min(74%, 500px);
  aspect-ratio: 1.55;
  overflow: hidden;
  border: 2px solid rgba(92, 0, 240, 0.72);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.52);
  box-shadow: 0 0 0 999px rgba(255, 255, 255, 0.36);
}

.frame img,
.frame iframe {
  display: block;
  width: 100%;
  height: 100%;
  background: #ffffff;
}

.frame img {
  object-fit: contain;
}

.frame iframe {
  border: 0;
  pointer-events: none;
}

.upload-icon {
  display: grid;
  width: 54px;
  height: 54px;
  position: absolute;
  top: 50%;
  left: 50%;
  z-index: 2;
  margin: 0;
  place-items: center;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 34px;
  line-height: 1;
  transform: translate(-50%, -50%);
  box-shadow: 0 10px 24px rgba(92, 0, 240, 0.25);
}

.camera-box strong,
.camera-box small {
  display: none;
}

.camera-box strong {
  margin-top: 12px;
  color: var(--text);
  font-family: var(--font-heading);
  font-size: 14px;
  font-weight: 400;
}

.camera-box small {
  color: var(--muted);
  font-size: 12px;
}

.check {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-top: 18px;
  padding: 14px;
  border: 1px solid #e7ebef;
  border-radius: 14px;
  background: #fbfcfd;
  color: var(--text);
  font-size: 14px;
  font-weight: 400;
}

.check input {
  width: 18px;
  min-height: 18px;
  margin-top: 2px;
}

.status,
.note {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
}

.note strong {
  display: inline-flex;
  align-items: center;
  margin-bottom: 6px;
  line-height: 1;
}

.note strong .flag {
  align-items: center;
  justify-content: center;
  min-height: 32px;
  padding: 0 14px;
  line-height: 1;
}

.note span {
  display: block;
  text-align: justify;
}

.facts ul {
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
  line-height: 1.65;
}

.control-list {
  display: grid;
  gap: 12px;
}

.control-list div {
  border: 1px solid #edf0f3;
  border-radius: 14px;
  padding: 14px;
  background: #fbfcfd;
}

.control-list span {
  display: inline-flex;
  margin-bottom: 6px;
  color: var(--accent-dark);
  font-size: 13px;
  font-weight: 400;
}

.control-list p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.42;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.list,
.medical-layout {
  display: grid;
  gap: 14px;
}

.record {
  padding: 22px;
}

.record-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 18px;
}

.record-head strong {
  font-family: var(--font-heading);
  font-size: 16px;
  font-weight: 400;
  line-height: 1.25;
}

.badge,
.flag {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  position: relative;
  min-height: 26px;
  border-radius: 999px;
  padding: 2px 10px;
  background: #edf3f7;
  color: #32414b;
  font-family: var(--font-heading);
  font-size: 12px;
  font-weight: 400;
  line-height: 1;
}

.flag[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  left: 0;
  bottom: calc(100% + 8px);
  z-index: 30;
  width: max-content;
  max-width: min(360px, 72vw);
  padding: 9px 11px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 8px;
  background: rgba(17, 24, 39, 0.88);
  color: #fff;
  font-family: var(--font-body);
  font-size: 12px;
  font-weight: 400;
  line-height: 1.35;
  white-space: normal;
  text-transform: none;
  opacity: 0;
  pointer-events: none;
  transform: translateY(4px);
  transition: opacity 0.14s ease, transform 0.14s ease;
  box-shadow: 0 14px 34px rgba(17, 24, 39, 0.24);
  backdrop-filter: blur(8px);
}

.flag[data-tooltip]:hover::after {
  opacity: 1;
  transform: translateY(0);
}

.flag.warn {
  background: #fff2d6;
  color: var(--warning);
}

.badge.danger,
.flag.danger {
  background: #ffe7e4;
  color: var(--danger);
}

.badge.ok,
.flag.ok {
  background: #e2f4e8;
  color: var(--ok);
}

.badge.pulse,
.flag.pulse {
  animation: pulse-danger 1.25s ease-in-out infinite;
}

.flag.info {
  background: #e8f1ff;
  color: #1d4ed8;
}

.flag.info.pulse {
  animation: pulse-info 1.25s ease-in-out infinite;
}

.flag.neutral {
  background: #edf3f7;
  color: #32414b;
}

dl {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px 28px;
  margin: 0;
}

dt {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.25;
}

dd {
  margin: 5px 0 0;
  overflow-wrap: anywhere;
  color: var(--text);
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 400;
  line-height: 1.35;
}

dd.truncate-field {
  position: relative;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  overflow-wrap: normal;
}

dd.truncate-field:hover {
  overflow: visible;
}

dd.truncate-field:hover::after {
  content: attr(data-tooltip);
  position: absolute;
  left: 0;
  top: calc(100% + 8px);
  z-index: 20;
  width: max-content;
  max-width: min(420px, 70vw);
  padding: 9px 11px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 8px;
  background: rgba(17, 24, 39, 0.88);
  color: #fff;
  font-size: 12px;
  line-height: 1.35;
  white-space: normal;
  box-shadow: 0 14px 34px rgba(17, 24, 39, 0.24);
  backdrop-filter: blur(8px);
}

dd.field-danger {
  color: var(--danger);
}

dd.field-ok {
  color: var(--ok);
}

dd.field-info {
  color: #175cd3;
}

@keyframes pulse-danger {
  0%,
  100% {
    box-shadow: 0 0 0 0 rgba(214, 57, 45, 0.28);
  }
  50% {
    box-shadow: 0 0 0 7px rgba(214, 57, 45, 0);
  }
}

@keyframes pulse-info {
  0%,
  100% {
    box-shadow: 0 0 0 0 rgba(29, 78, 216, 0.26);
  }
  50% {
    box-shadow: 0 0 0 7px rgba(29, 78, 216, 0);
  }
}

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

.flags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.flags:empty {
  display: none;
}

.image-flags {
  grid-column: 1;
  display: flex;
  flex-wrap: wrap;
  align-self: start;
  gap: 8px;
  margin-top: -4px;
}

.history-button {
  width: fit-content;
  margin-top: 12px;
}

.rh-card-footer {
  display: flex;
  justify-content: flex-start;
  margin-top: 12px;
}

.rh-card-footer .history-button {
  margin-top: 0;
}

.medical-record {
  display: grid;
  grid-template-columns: minmax(260px, 0.85fr) minmax(0, 1.15fr);
  gap: 16px;
}

.medical-record .image-stage {
  grid-column: 1;
}

.medical-body {
  grid-column: 2;
  grid-row: 1 / span 2;
}

.image-stage {
  position: relative;
  align-self: start;
  overflow: hidden;
  min-height: 260px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #e9eef1;
}

.image-stage.is-processing::before {
  content: "";
  position: absolute;
  top: 12px;
  left: 12px;
  right: 12px;
  z-index: 4;
  display: block;
  min-height: 48px;
  border: 1px solid rgba(29, 78, 216, 0.28);
  border-radius: 8px;
  background: rgba(232, 241, 255, 0.96);
  box-shadow: 0 12px 24px rgba(23, 32, 38, 0.16);
}

.image-stage.is-processing::after {
  content: attr(data-processing-label) "\A" attr(data-processing-detail);
  white-space: pre-line;
  position: absolute;
  top: 20px;
  left: 58px;
  right: 26px;
  z-index: 5;
  color: #1d4ed8;
  font-size: 13px;
  line-height: 1.25;
}

.image-stage.is-processing .view-document-button {
  opacity: 0.72;
  color: #7a6d94;
  background: rgba(241, 241, 244, 0.94);
  cursor: not-allowed;
}

.image-stage.is-processing .overlay::before {
  content: "";
  position: absolute;
  top: 27px;
  left: 26px;
  z-index: 6;
  width: 18px;
  height: 18px;
  border: 2px solid rgba(29, 78, 216, 0.22);
  border-top-color: #1d4ed8;
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}

.suspicion-note {
  display: none;
  margin-top: 12px;
}

.suspicion-note.is-visible {
  display: grid;
  gap: 8px;
}

.suspicion-note .flag {
  width: fit-content;
  min-height: 32px;
  padding: 0 14px;
}

.suspicion-note p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
  text-align: justify;
}

.review-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 14px;
}

.review-actions .history-button {
  margin-top: 0;
}

.review-actions select {
  width: min(220px, 100%);
}

.pending-blur {
  filter: blur(4px);
  opacity: 0.42;
  user-select: none;
}

.is-processing-record .badge {
  filter: blur(4px);
  opacity: 0.42;
}

.is-processing-record .flag.info {
  filter: none;
  opacity: 1;
}

.image-stage img,
.image-stage iframe {
  display: block;
  width: 100%;
  border: 0;
  background: #fbfcfd;
}

.image-stage img {
  height: auto;
}

.image-stage iframe {
  height: 260px;
}

.view-document-button {
  position: absolute;
  right: 10px;
  bottom: 10px;
  z-index: 2;
  min-height: 34px;
  border-color: rgba(92, 0, 240, 0.24);
  background: rgba(255, 255, 255, 0.94);
  color: var(--accent-dark);
  box-shadow: 0 10px 20px rgba(23, 32, 38, 0.12);
}

.overlay,
.box {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.box {
  inset: auto;
  border: 2px solid var(--accent-2);
  background: rgba(159, 77, 28, 0.14);
}

.box span {
  position: absolute;
  left: 0;
  bottom: 100%;
  max-width: 220px;
  padding: 5px 8px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 8px 8px 8px 2px;
  background: rgba(17, 24, 39, 0.82);
  color: #fff;
  font-size: 12px;
  line-height: 1.15;
  box-shadow: 0 10px 24px rgba(17, 24, 39, 0.24);
  backdrop-filter: blur(8px);
}

select {
  width: 100%;
  padding: 0 10px;
}

.unit-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 16px;
}

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

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

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

.stat-card span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.stat-card strong {
  display: block;
  margin-top: 6px;
  font-size: 24px;
  font-weight: 400;
}

.unit-grid label {
  margin-bottom: 0;
  color: var(--text);
  font-weight: 400;
}

.unit-grid select {
  min-height: 44px;
  margin-top: 8px;
  font-family: var(--font-body);
  font-weight: 400;
}

.unit-grid option {
  font-family: var(--font-body);
  font-weight: 400;
}

.submission-switch {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  width: fit-content;
  max-width: 100%;
  margin: 6px auto 20px;
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 5px;
  background: #fbfcfd;
  box-shadow: 0 1px 2px rgba(23, 32, 38, 0.03);
}

.submission-label {
  flex: 0 0 auto;
  min-width: 154px;
  min-height: 44px;
  margin: 0;
  border: 0;
  border-radius: 14px;
  padding: 0 20px;
  background: transparent;
  color: #667085;
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 400;
  text-align: center;
  cursor: pointer;
  transition: background 0.18s ease, color 0.18s ease, box-shadow 0.18s ease;
}

#upload-form > button[type="submit"] {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 180px;
  min-height: 44px;
  line-height: 1;
  margin: 18px auto 0;
}

.submission-label.active {
  background: #ffffff;
  color: #0068df;
  box-shadow: 0 10px 22px rgba(20, 75, 140, 0.08);
}

.submission-label:focus-visible {
  outline: 2px solid rgba(0, 104, 223, 0.24);
  outline-offset: 2px;
}

@media (max-width: 760px) {
  .topbar,
  .section-head {
    align-items: stretch;
    flex-direction: column;
  }

  .tabs {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
  }

  main {
    width: min(100% - 20px, 1180px);
    margin-top: 14px;
  }

  .capture-grid,
  .hero-strip,
  .medical-record,
  .unit-grid,
  .admin-grid,
  .stats-grid,
  dl {
    grid-template-columns: 1fr;
  }

  .medical-record .image-stage,
  .image-flags,
  .medical-body {
    grid-column: 1;
    grid-row: auto;
  }

  .submission-switch {
    width: 100%;
  }

  .submission-label {
    flex: 1 1 0;
    min-width: 0;
    padding: 0 12px;
  }

  .hero-strip {
    display: grid;
  }

  .hero-steps {
    min-width: 0;
  }
}

@media (max-width: 430px) {
  .login-card h1 {
    font-size: 29px;
    white-space: normal;
  }
}
