/* ==============================
   GLOBAL RESET
============================== */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  background: #0b1020;
  color: #e5e7eb;
}

/* ==============================
   APP LAYOUT
============================== */
.app {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

/* ==============================
   TOPBAR
============================== */
.topbar {
  height: 56px;
  background: linear-gradient(90deg, #0f172a, #020617);
  border-bottom: 1px solid #1f2937;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
}

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

.logo {
  font-size: 20px;
}

.brand-title {
  font-weight: 600;
  font-size: 15px;
}

.brand-sub {
  font-size: 12px;
  color: #9ca3af;
}

.topbar-right {
  display: flex;
  gap: 10px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  font-size: 12px;
  border-radius: 999px;
}

.chip-soft {
  background: #020617;
  border: 1px solid #1f2937;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #22c55e;
}

.dot-live {
  background: #22c55e;
}

/* ==============================
   MAIN LAYOUT
============================== */
.main {
  flex: 1;
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 0;
  overflow: hidden;
}

/* ==============================
   PANELS
============================== */
.panel {
  overflow: auto;
  padding: 16px;
}

.panel-left {
  border-right: 1px solid #1f2937;
}

.panel-right {
  background: #020617;
  display: flex;
  flex-direction: column;
}

/* ==============================
   TABS
============================== */
.tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 12px;
}

.tab-btn {
  background: #020617;
  border: 1px solid #1f2937;
  color: #e5e7eb;
  padding: 8px 12px;
  font-size: 13px;
  border-radius: 8px;
  cursor: pointer;
}

.tab-btn.active {
  background: #1e293b;
  border-color: #3b82f6;
}

/* ==============================
   TAB PAGES
============================== */
.tab-page.hidden {
  display: none;
}

/* ==============================
   CARDS
============================== */
.card {
  background: #020617;
  border: 1px solid #1f2937;
  border-radius: 12px;
  padding: 14px;
  margin-bottom: 14px;
}

.scan-log {
  background: #020617;
  border: 1px solid #1f2937;
  border-radius: 10px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 160px;
  overflow-y: auto;
}

.scan-log-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 10px;
  border-radius: 10px;
  background: #0f172a;
  border: 1px solid #1f2937;
  font-size: 12px;
}

.scan-log-index {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  background: #1e293b;
  border: 1px solid #111b2a;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
}

.scan-log-main {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.scan-log-file {
  font-size: 13px;
  font-weight: 600;
}

.scan-log-status {
  font-size: 12px;
  color: #9ca3af;
}

.scan-log-item.log-ok .scan-log-status {
  color: #22c55e;
}

.scan-log-item.log-fail .scan-log-status {
  color: #fb923c;
}

.scan-log-item.log-error .scan-log-status {
  color: #ef4444;
}

.scan-log-placeholder {
  font-size: 12px;
  color: #9ca3af;
}

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

.card-head.tight {
  margin-bottom: 6px;
}

.card-title {
  font-weight: 600;
  font-size: 14px;
}

.card-sub {
  font-size: 12px;
  color: #9ca3af;
}

.stats {
  display: flex;
  gap: 14px;
}

.stat {
  text-align: center;
}

.stat-num {
  font-size: 18px;
  font-weight: 700;
}

.stat-num.ok {
  color: #22c55e;
}

.stat-num.fail {
  color: #ef4444;
}

.stat-label {
  font-size: 11px;
  color: #9ca3af;
}

/* ==============================
   FORMS
============================== */
.form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.form-row {
  display: flex;
  gap: 10px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.form-group.grow {
  flex: 1;
}

label {
  font-size: 12px;
  color: #cbd5f5;
}

input, select {
  background: #020617;
  border: 1px solid #1f2937;
  border-radius: 8px;
  padding: 8px 10px;
  color: #e5e7eb;
  font-size: 13px;
}

input:focus, select:focus {
  outline: none;
  border-color: #3b82f6;
}

.hint {
  font-size: 11px;
  color: #64748b;
}

/* ==============================
   BUTTONS
============================== */
.btn {
  border: 1px solid #1f2937;
  background: #020617;
  color: #e5e7eb;
  padding: 8px 12px;
  font-size: 13px;
  border-radius: 8px;
  cursor: pointer;
}

.btn:hover {
  background: #020617;
  border-color: #3b82f6;
}

.btn-primary {
  background: #2563eb;
  border-color: #2563eb;
}

.btn-primary:hover {
  background: #1d4ed8;
}

.btn-muted {
  background: #020617;
}

.btn-xs {
  padding: 4px 8px;
  font-size: 11px;
}

/* ==============================
   TABLE
============================== */
.table-wrap {
  overflow: auto;
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.table th {
  text-align: left;
  font-size: 12px;
  color: #9ca3af;
  border-bottom: 1px solid #1f2937;
  padding: 8px;
}

.table td {
  padding: 8px;
  border-bottom: 1px solid #020617;
}

.table tbody tr {
  cursor: pointer;
  transition: background 0.15s;
}

.table tbody tr:hover {
  background: #0f172a;
}

.table tbody tr.selected {
  background: #1e293b;
  border-left: 3px solid #3b82f6;
}

.col-narrow {
  width: 36px;
}

.col-no {
  width: 160px;
}

.col-status {
  width: 90px;
}

.col-action {
  width: 80px;
}

.col-no-edit {
  width: 220px;
}

.col-reason {
  max-width: 300px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.status-ok {
  color: #22c55e;
  font-weight: 600;
}

.status-fail {
  color: #ef4444;
  font-weight: 600;
}

/* ==============================
   PREVIEW
============================== */
.preview-card {
  position: sticky;
  top: 16px;
  height: fit-content;
}

.preview-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 400px;
  background: #0b1020;
  border-radius: 8px;
  padding: 16px;
}

.preview-img {
  max-width: 100%;
  max-height: calc(100vh - 150px);
  object-fit: contain;
  border-radius: 8px;
  border: 1px solid #1f2937;
  cursor: zoom-in;
  transition: transform 0.2s;
  transform-origin: center center;
}

.preview-img:hover {
  /* Removed auto-zoom on hover, using wheel instead */
}

.preview-img.muted {
  opacity: 0.3;
  cursor: default;
}

.preview-img.muted:hover {
  transform: none;
}

.preview-meta {
  margin-top: 12px;
  font-size: 12px;
  color: #9ca3af;
  text-align: center;
  line-height: 1.5;
}

.manual-row {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

/* ==============================
   MODAL
============================== */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 999;
}

.modal.hidden {
  display: none;
}

.modal-card {
  background: #020617;
  padding: 10px;
  border-radius: 12px;
  max-width: 95vw;
  max-height: 95vh;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.modal-img {
  max-width: 100%;
  max-height: 90vh;
  object-fit: contain;
}

.modal-close {
  background: none;
  border: none;
  color: #e5e7eb;
  font-size: 18px;
  cursor: pointer;
}

/* ==============================
   TOAST
============================== */
.toast {
  position: fixed;
  right: 16px;
  bottom: 16px;
  background: #020617;
  border: 1px solid #1f2937;
  border-radius: 8px;
  padding: 10px 14px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: #e5e7eb;
}
