/* Layout */
.topbar{
  position: sticky;
  top: 0;
  z-index: 20;
  backdrop-filter: blur(10px);
  background: rgba(11,18,32,0.7);
  border-bottom: 1px solid var(--border);
}

.topbar-inner{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap: var(--gap);
  max-width: var(--max);
  margin: 0 auto;
  padding: 14px 22px;
}

.brand{
  display:flex;
  align-items:center;
  gap: 10px;
  font-weight: 700;
  letter-spacing: 0.2px;
}
.badge{
  font-size: 12px;
  color: var(--muted);
  border: 1px solid var(--border);
  padding: 2px 8px;
  border-radius: 999px;
}

/* Cards */
.card{
  background: linear-gradient(180deg, rgba(255,255,255,0.03), rgba(255,255,255,0.015));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
}

.grid{
  display:grid;
  gap: var(--gap);
}
.grid-2{
  grid-template-columns: 1.1fr 0.9fr;
}
@media (max-width: 900px){
  .grid-2{ grid-template-columns: 1fr; }
}

/* Forms */
.field{ margin-bottom: 14px; }
label{
  display:block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 13px;
}
input[type="text"], input[type="file"], select{
  width: 100%;
  padding: 11px 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.04);
  color: var(--text);
  outline: none;
}
input:focus, select:focus{
  box-shadow: 0 0 0 4px var(--focus);
  border-color: rgba(106,168,255,0.6);
}

/* Buttons */
.btn{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  gap: 10px;
  padding: 11px 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.06);
  color: var(--text);
  cursor:pointer;
  font-weight: 600;
}
.btn:hover{ background: rgba(255,255,255,0.09); }
.btn-primary{
  background: linear-gradient(135deg, rgba(106,168,255,0.9), rgba(114,224,197,0.85));
  border-color: rgba(255,255,255,0.22);
  color: #061018;
}
.btn-primary:hover{
  filter: brightness(1.02);
}

/* Helper text */
.small{ color: var(--muted); font-size: 13px; line-height: 1.45; }
.hr{ height:1px; background: var(--border); margin: 14px 0; }

/* Status badges (Queued / Running / Done / Error) */
.status-badge{
  display:inline-flex;
  align-items:center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.05);
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.2px;
  width: fit-content;
}
.status-badge::before{
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: rgba(255,255,255,0.25);
}

.status-queued{
  border-color: rgba(106,168,255,0.40);
  background: rgba(106,168,255,0.10);
  color: rgba(176,210,255,0.95);
}
.status-queued::before{ background: rgba(106,168,255,0.95); }

.status-running{
  border-color: rgba(114,224,197,0.55);
  background: rgba(114,224,197,0.14);
  color: rgba(201,255,242,0.98);
}
.status-running::before{ background: rgba(114,224,197,0.95); }

.status-done{
  border-color: rgba(66, 214, 126, 0.60);
  background: rgba(66, 214, 126, 0.16);
  color: rgba(212, 255, 230, 0.98);
}
.status-done::before{ background: rgba(66, 214, 126, 0.95); }

.status-error{
  border-color: rgba(255,106,122,0.70);
  background: rgba(255,106,122,0.12);
  color: rgba(255,190,196,0.98);
}
.status-error::before{ background: rgba(255,106,122,0.95); }


/* Progress bar + live log (used on scans/new.html right-side card) */
.progress-wrap{ margin-top: 12px; }
.progress-head{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap: 12px;
}
.progress-title{
  font-weight: 800;
  letter-spacing: 0.2px;
  margin: 0;
}
.progress-sub{
  color: var(--muted);
  font-size: 12px;
  margin-top: 4px;
}

.progress-bar{
  margin-top: 10px;
  height: 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.04);
  overflow:hidden;
}
.progress-fill{
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(106,168,255,0.95), rgba(114,224,197,0.90));
  transition: width 220ms ease;
}

.progress-meta{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap: 10px;
  margin-top: 10px;
}
.progress-step{
  font-size: 13px;
  color: var(--text);
  font-weight: 700;
}
.progress-pct{
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
}

.logbox{
  margin-top: 12px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--panel);
  overflow:hidden;
}
.logbox-header{
  display:flex;
  align-items:center;
  justify-content:space-between;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  background: rgba(255,255,255,0.03);
}
.logbox-title{
  font-size: 12px;
  color: var(--muted);
  font-weight: 800;
  letter-spacing: 0.25px;
  text-transform: uppercase;
}
.logbox-body{
  padding: 10px 12px;
  max-height: 220px;
  overflow:auto;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 12px;
  line-height: 1.45;
  color: rgba(255,255,255,0.90);
  white-space: pre-wrap;
}
.logbox-empty{
  color: rgba(255,255,255,0.60);
}

/* Optional: error callout inside progress card */
.alert{
  margin-top: 12px;
  border-radius: 14px;
  border: 1px solid var(--border);
  padding: 10px 12px;
  font-size: 13px;
}
.alert-error{
  border-color: rgba(255,106,122,0.70);
  background: rgba(255,106,122,0.12);
  color: rgba(255,220,224,0.98);
}

/* Card header row utility (title + badge) */
.card-head{
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap: 12px;
}
.card-head h3{ margin: 0; }

/* Dropzone */
.dropzone{
  border: 1.5px dashed rgba(255,255,255,0.18);
  background: rgba(255,255,255,0.03);
  border-radius: 16px;
  padding: 18px;
  cursor: pointer;
  outline: none;
  transition: transform 0.08s ease, background 0.12s ease, border-color 0.12s ease;
  position: relative;
  overflow: hidden;
  isolation: isolate;
}
.dropzone:hover{
  background: rgba(255,255,255,0.045);
}
.dropzone:focus{
  box-shadow: 0 0 0 4px var(--focus);
  border-color: rgba(106,168,255,0.6);
}
.dropzone-active{
  border-color: rgba(114,224,197,0.6);
  background: rgba(114,224,197,0.06);
  transform: translateY(-1px);
}
.dropzone-title{
  font-weight: 700;
  margin-bottom: 6px;
}
.dropzone-subtitle{
  color: var(--muted);
  font-size: 13px;
}

/* Premium: drag shimmer + status pill */
.dropzone::before{
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  opacity: 0;
  background: linear-gradient(
    110deg,
    transparent 0%,
    rgba(255,255,255,0.06) 18%,
    transparent 36%
  );
  transform: translateX(-60%);
}

@keyframes dzShimmer{
  0% { transform: translateX(-60%); }
  100% { transform: translateX(60%); }
}

.dropzone-active::before{
  opacity: 1;
  animation: dzShimmer 1.1s linear infinite;
}

.dropzone-pill{
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
  margin-bottom: 12px;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.05);
  color: var(--muted);
  font-size: 12px;
  width: fit-content;
}

.dropzone-pill strong{
  color: var(--text);
  font-weight: 700;
}

.dropzone-pill-error{
  border-color: rgba(255,106,122,0.55);
  background: rgba(255,106,122,0.10);
  color: rgba(255,190,196,0.95);
}

.dropzone-pill-success{
  border-color: rgba(114,224,197,0.75);
  background: rgba(114,224,197,0.18);
  color: #c9fff2;
}

.dropzone-error{
  border-color: rgba(255,106,122,0.75) !important;
  background: rgba(255,106,122,0.08) !important;
}

/* File list */
.filelist{
  margin-top: 12px;
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
  background: var(--panel);
}
.filelist-item{
  display:flex;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border-top: 1px solid var(--border);
}
.filelist-item:first-child{
  border-top: none;
}
.filelist-name{
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 75%;
}
.filelist-meta{
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

/* Theme: light mode overrides (driven by html[data-theme] OR body[data-theme]) */
:is(html[data-theme="light"], body[data-theme="light"]){
  --bg: #f6f7fb;
  --panel: rgba(0,0,0,0.03);
  --text: #0b1220;
  --muted: rgba(11,18,32,0.65);
  --border: rgba(11,18,32,0.12);
  --shadow: 0 10px 35px rgba(11,18,32,0.10);
  --focus: rgba(106,168,255,0.25);
}

:is(html[data-theme="light"], body[data-theme="light"]) body{
  background: var(--bg);
}

:is(html[data-theme="light"], body[data-theme="light"]) .topbar{
  background: rgba(246,247,251,0.85);
}

:is(html[data-theme="light"], body[data-theme="light"]) .card{
  background: linear-gradient(180deg, rgba(255,255,255,0.95), rgba(255,255,255,0.86));
}

:is(html[data-theme="light"], body[data-theme="light"]) input[type="text"],
:is(html[data-theme="light"], body[data-theme="light"]) input[type="file"],
:is(html[data-theme="light"], body[data-theme="light"]) select{
  background: rgba(255,255,255,0.92);
}

:is(html[data-theme="light"], body[data-theme="light"]) .btn{
  background: rgba(0,0,0,0.03);
}

:is(html[data-theme="light"], body[data-theme="light"]) .btn:hover{
  background: rgba(0,0,0,0.06);
}

:is(html[data-theme="light"], body[data-theme="light"]) .dropzone{
  border: 1.5px dashed rgba(11,18,32,0.18);
  background: rgba(11,18,32,0.02);
}

:is(html[data-theme="light"], body[data-theme="light"]) .dropzone:hover{
  background: rgba(11,18,32,0.03);
}

:is(html[data-theme="light"], body[data-theme="light"]) .dropzone::before{
  background: linear-gradient(
    110deg,
    transparent 0%,
    rgba(11,18,32,0.05) 18%,
    transparent 36%
  );
}

:is(html[data-theme="light"], body[data-theme="light"]) .dropzone-pill{
  background: rgba(11,18,32,0.035);
  border-color: rgba(11,18,32,0.14);
}

:is(html[data-theme="light"], body[data-theme="light"]) .dropzone-pill strong{
  color: rgba(11,18,32,0.92);
}

:is(html[data-theme="light"], body[data-theme="light"]) .dropzone-pill-success{
  border-color: rgba(16, 122, 92, 0.65);
  background: rgba(16, 122, 92, 0.22);
  color: rgba(6, 53, 41, 0.98);
}

:is(html[data-theme="light"], body[data-theme="light"]) .filelist{
  background: rgba(255,255,255,0.85);
}

:is(html[data-theme="light"], body[data-theme="light"]) .crumb:hover,
:is(html[data-theme="light"], body[data-theme="light"]) .crumb-current{
  background: rgba(11,18,32,0.03);
}

/* Light mode: clean clinical primary action (Process button) */
:is(html[data-theme="light"], body[data-theme="light"]) .btn-primary{
  background: #2563eb; /* clean medical blue */
  border-color: rgba(37, 99, 235, 0.85);
  color: #ffffff;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.30);
}

:is(html[data-theme="light"], body[data-theme="light"]) .btn-primary:hover{
  background: #1d4ed8;
  box-shadow: 0 6px 16px rgba(37, 99, 235, 0.38);
}

:is(html[data-theme="light"], body[data-theme="light"]) .btn-primary:focus{
  box-shadow:
    0 0 0 4px rgba(37, 99, 235, 0.30),
    0 6px 16px rgba(37, 99, 235, 0.38);
}

/* Light mode: progress + log readability */
:is(html[data-theme="light"], body[data-theme="light"]) .status-badge{
  background: rgba(11,18,32,0.035);
  border-color: rgba(11,18,32,0.14);
}

:is(html[data-theme="light"], body[data-theme="light"]) .status-queued{
  border-color: rgba(37, 99, 235, 0.45);
  background: rgba(37, 99, 235, 0.12);
  color: rgba(17, 56, 148, 0.98);
}
:is(html[data-theme="light"], body[data-theme="light"]) .status-queued::before{ background: rgba(37, 99, 235, 0.90); }

:is(html[data-theme="light"], body[data-theme="light"]) .status-running{
  border-color: rgba(16, 122, 92, 0.55);
  background: rgba(16, 122, 92, 0.14);
  color: rgba(6, 53, 41, 0.98);
}
:is(html[data-theme="light"], body[data-theme="light"]) .status-running::before{ background: rgba(16, 122, 92, 0.90); }

:is(html[data-theme="light"], body[data-theme="light"]) .status-done{
  border-color: rgba(22, 163, 74, 0.55);
  background: rgba(22, 163, 74, 0.14);
  color: rgba(10, 70, 30, 0.98);
}
:is(html[data-theme="light"], body[data-theme="light"]) .status-done::before{ background: rgba(22, 163, 74, 0.90); }

:is(html[data-theme="light"], body[data-theme="light"]) .status-error{
  border-color: rgba(220, 38, 38, 0.55);
  background: rgba(220, 38, 38, 0.12);
  color: rgba(92, 12, 12, 0.98);
}
:is(html[data-theme="light"], body[data-theme="light"]) .status-error::before{ background: rgba(220, 38, 38, 0.90); }

:is(html[data-theme="light"], body[data-theme="light"]) .progress-bar{
  background: rgba(11,18,32,0.04);
}
:is(html[data-theme="light"], body[data-theme="light"]) .progress-fill{
  background: linear-gradient(90deg, #2563eb, #16a34a);
}

:is(html[data-theme="light"], body[data-theme="light"]) .logbox{
  background: rgba(255,255,255,0.92);
}
:is(html[data-theme="light"], body[data-theme="light"]) .logbox-header{
  background: rgba(11,18,32,0.02);
}
:is(html[data-theme="light"], body[data-theme="light"]) .logbox-body{
  color: rgba(11,18,32,0.92);
}
:is(html[data-theme="light"], body[data-theme="light"]) .logbox-empty{
  color: rgba(11,18,32,0.55);
}

:is(html[data-theme="light"], body[data-theme="light"]) .alert-error{
  background: rgba(220, 38, 38, 0.08);
  color: rgba(92, 12, 12, 0.98);
}

/* Exam selection (used on scans/new.html right-side card)
   Goal: selectable “choice cards” (not primary action buttons).
*/
.exam-select{
  margin-top: 14px;
}

.exam-select-head{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.exam-select-title{
  font-weight: 900;
  letter-spacing: 0.2px;
  margin: 0;
}

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

.exam-grid{
  display:grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
}

/* Exam “button-card” */
.exam-btn{
  -webkit-appearance: none;
  appearance: none;

  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap: 12px;

  width: 100%;
  text-align: left;
  cursor: pointer;

  border-radius: 14px;
  padding: 13px 14px;

  border: 1.5px solid var(--border);
  background: rgba(255,255,255,0.04);
  color: var(--text);

  box-shadow:
    0 1px 0 rgba(255,255,255,0.06) inset,
    0 2px 10px rgba(0,0,0,0.10);

  transition:
    transform 0.08s ease,
    border-color 0.12s ease,
    background 0.12s ease,
    box-shadow 0.12s ease;
}

.exam-btn:hover{
  transform: translateY(-1px);
  background: rgba(255,255,255,0.06);
  box-shadow:
    0 1px 0 rgba(255,255,255,0.07) inset,
    0 4px 16px rgba(0,0,0,0.14);
}

.exam-btn:focus{
  outline: none;
  border-color: rgba(106,168,255,0.55);
  box-shadow:
    0 0 0 4px var(--focus),
    0 4px 16px rgba(0,0,0,0.14);
}

/* Inner content */
.exam-btn-main{
  min-width: 0;
}

.exam-btn-eye{
  font-size: 14px;
  font-weight: 950;
  letter-spacing: 0.25px;
  line-height: 1.2;
}

.exam-btn-dt{
  margin-top: 4px;
  font-size: 12px;
  color: var(--muted);
  font-weight: 800;
  line-height: 1.2;
}

/* Right-side indicator (check circle) */
.exam-btn-ind{
  flex: 0 0 auto;
  width: 18px;
  height: 18px;
  border-radius: 999px;
  border: 2px solid rgba(255,255,255,0.22);
  background: rgba(255,255,255,0.03);
  margin-top: 1px;
}

.exam-btn-selected{
  border-color: rgba(106,168,255,0.65);
  background: rgba(106,168,255,0.12);
  box-shadow:
    0 0 0 3px rgba(106,168,255,0.18),
    0 6px 18px rgba(0,0,0,0.16);
}

.exam-btn-selected .exam-btn-ind{
  border-color: rgba(106,168,255,0.95);
  background: rgba(106,168,255,0.55);
}

/* Light mode: ensure these always feel like bright “choice cards”, not dark buttons */
:is(html[data-theme="light"], body[data-theme="light"]) .exam-btn{
  border-color: rgba(11,18,32,0.14);
  background: linear-gradient(180deg, rgba(255,255,255,0.98), rgba(255,255,255,0.92));
  color: rgba(11,18,32,0.96);
  box-shadow:
    0 1px 0 rgba(255,255,255,0.65) inset,
    0 6px 18px rgba(11,18,32,0.10);
}

:is(html[data-theme="light"], body[data-theme="light"]) .exam-btn:hover{
  background: linear-gradient(180deg, rgba(255,255,255,1.0), rgba(255,255,255,0.96));
  box-shadow:
    0 1px 0 rgba(255,255,255,0.75) inset,
    0 10px 24px rgba(11,18,32,0.14);
}

:is(html[data-theme="light"], body[data-theme="light"]) .exam-btn-ind{
  border-color: rgba(11,18,32,0.18);
  background: rgba(11,18,32,0.02);
}

:is(html[data-theme="light"], body[data-theme="light"]) .exam-btn-selected{
  border-color: rgba(37, 99, 235, 0.55);
  background: linear-gradient(180deg, rgba(37, 99, 235, 0.10), rgba(37, 99, 235, 0.06));
  box-shadow:
    0 0 0 3px rgba(37, 99, 235, 0.16),
    0 10px 24px rgba(11,18,32,0.14);
}

:is(html[data-theme="light"], body[data-theme="light"]) .exam-btn-selected .exam-btn-ind{
  border-color: rgba(37, 99, 235, 0.75);
  background: rgba(37, 99, 235, 0.35);
}