:root {
  --mci-navy: #082c50;
  --mci-blue: #0d6efd;
  --mci-teal: #12864c;
  --mci-bg: #f3f7fc;
  --mci-card: #ffffff;
  --mci-ink: #102a43;
  --mci-muted: #5b7083;
  --mci-line: #dce7f3;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  background: var(--mci-bg);
  color: var(--mci-ink);
  -webkit-tap-highlight-color: transparent;
}

.scanner-topbar {
  background: linear-gradient(100deg, #082c50, #0d4fa3);
  color: #fff;
  position: sticky;
  top: 0;
  z-index: 40;
  box-shadow: 0 4px 16px rgba(8, 44, 80, 0.18);
}

.scanner-topbar-inner {
  max-width: 1120px;
  margin: 0 auto;
  padding: 10px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.scanner-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.scanner-brand img {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: #fff;
  padding: 3px;
  object-fit: contain;
  flex-shrink: 0;
}

.scanner-brand-title {
  font-weight: 800;
  font-size: 0.98rem;
  line-height: 1.15;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.scanner-brand-sub {
  font-size: 0.72rem;
  opacity: 0.85;
  display: block;
}

.scanner-top-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.btn-pill {
  border: 0;
  border-radius: 999px;
  padding: 7px 13px;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  text-decoration: none;
  transition: transform 0.12s ease, opacity 0.15s ease;
}

.btn-pill:active {
  transform: scale(0.97);
}

.btn-pill-light {
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
}

.btn-pill-install {
  background: #f2a51a;
  color: #082c50;
}

.scanner-tabs-wrap {
  background: #fff;
  border-bottom: 1px solid var(--mci-line);
  position: sticky;
  top: 58px;
  z-index: 35;
}

.scanner-tabs {
  max-width: 1120px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
}

.scanner-tab {
  border: 0;
  background: transparent;
  padding: 12px 8px;
  font-size: 0.86rem;
  font-weight: 700;
  color: var(--mci-muted);
  border-bottom: 3px solid transparent;
  cursor: pointer;
}

.scanner-tab.active {
  color: var(--mci-blue);
  border-bottom-color: var(--mci-blue);
  background: #f7fbff;
}

.scanner-main {
  max-width: 1120px;
  margin: 0 auto;
  padding: 16px 14px 86px;
}

.panel-card {
  background: var(--mci-card);
  border: 1px solid var(--mci-line);
  border-radius: 16px;
  padding: 16px;
  box-shadow: 0 8px 22px rgba(16, 42, 67, 0.05);
  margin-bottom: 14px;
}

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

.action-tile {
  border: 1px solid #cfe0f5;
  background: linear-gradient(180deg, #ffffff, #f3f9ff);
  border-radius: 14px;
  padding: 14px 10px;
  text-align: center;
  cursor: pointer;
  color: var(--mci-navy);
  font-weight: 800;
  font-size: 0.85rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.action-tile.primary {
  background: linear-gradient(135deg, #0d6efd, #0a4fa3);
  color: #fff;
  border-color: transparent;
}

.action-tile .tile-icon {
  font-size: 1.5rem;
  line-height: 1;
}

.action-tile small {
  font-size: 0.7rem;
  font-weight: 600;
  opacity: 0.82;
}

.doc-meta-grid {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr;
  gap: 10px;
  margin-top: 12px;
}

.field-label {
  display: block;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--mci-muted);
  margin-bottom: 4px;
}

.field-input,
.field-select {
  width: 100%;
  border: 1px solid #cad8e6;
  border-radius: 10px;
  padding: 9px 11px;
  font-size: 0.88rem;
  background: #fff;
  color: var(--mci-ink);
}

.preset-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.chip-btn {
  border: 1px solid #d4e3f3;
  background: #f4f9ff;
  color: #164b77;
  border-radius: 999px;
  padding: 5px 11px;
  font-size: 0.74rem;
  font-weight: 700;
  cursor: pointer;
}

.pages-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(175px, 1fr));
  gap: 12px;
}

.page-card {
  border: 1px solid var(--mci-line);
  border-radius: 14px;
  overflow: hidden;
  background: #fff;
  display: flex;
  flex-direction: column;
}

.page-thumb-wrap {
  position: relative;
  background: #e9eff7;
  aspect-ratio: 3 / 4;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.page-thumb-wrap img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.page-badge {
  position: absolute;
  top: 8px;
  left: 8px;
  background: rgba(8, 44, 80, 0.86);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 800;
  padding: 3px 8px;
  border-radius: 999px;
}

.page-filter-badge {
  position: absolute;
  bottom: 8px;
  right: 8px;
  background: rgba(255, 255, 255, 0.92);
  color: #082c50;
  font-size: 0.68rem;
  font-weight: 800;
  padding: 2px 7px;
  border-radius: 999px;
}

.page-card-body {
  padding: 9px;
  display: grid;
  gap: 7px;
}

.page-label-input {
  width: 100%;
  border: 1px solid #e1ebf5;
  border-radius: 8px;
  padding: 5px 8px;
  font-size: 0.78rem;
  font-weight: 700;
}

.page-card-actions {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 5px;
}

.mini-btn {
  border: 1px solid #d4e1ef;
  background: #f8fbff;
  color: var(--mci-navy);
  border-radius: 8px;
  padding: 6px 4px;
  font-size: 0.74rem;
  font-weight: 700;
  cursor: pointer;
}

.mini-btn.edit {
  background: #e8f2ff;
  border-color: #b9d6ff;
  color: #0a58ca;
}

.mini-btn.danger {
  background: #fff2f2;
  border-color: #f6c8c8;
  color: #b42318;
}

.empty-state {
  text-align: center;
  padding: 36px 16px;
  color: var(--mci-muted);
}

.empty-state strong {
  display: block;
  color: var(--mci-navy);
  font-size: 1.05rem;
  margin-bottom: 6px;
}

.sticky-export-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(8px);
  border-top: 1px solid var(--mci-line);
  z-index: 38;
  padding: 10px 14px;
}

.sticky-export-inner {
  max-width: 1120px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.export-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.btn-main {
  border: 0;
  border-radius: 11px;
  padding: 10px 16px;
  font-size: 0.85rem;
  font-weight: 800;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.btn-main-primary {
  background: linear-gradient(100deg, #0d6efd, #12864c);
  color: #fff;
}

.btn-main-secondary {
  background: #eaf3ff;
  color: #0a4fa3;
}

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

/* Modal Editor (Crop + Filters) & Live Camera */
.scanner-modal {
  position: fixed;
  inset: 0;
  background: rgba(6, 20, 38, 0.92);
  z-index: 100;
  display: none;
  flex-direction: column;
}

.scanner-modal.open {
  display: flex;
}

.modal-header-bar {
  padding: 10px 14px;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.14);
}

.modal-canvas-stage {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px;
  overflow: hidden;
  position: relative;
}

#cropCanvas,
#previewCanvas {
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  touch-action: none;
  border-radius: 8px;
  box-shadow: 0 12px 35px rgba(0, 0, 0, 0.45);
}

.modal-controls-bar {
  background: #0d233d;
  color: #fff;
  padding: 10px 14px 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.14);
}

.filter-strip {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 8px;
}

.filter-pill {
  border: 1px solid rgba(255, 255, 255, 0.25);
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 0.78rem;
  font-weight: 700;
  white-space: nowrap;
  cursor: pointer;
}

.filter-pill.active {
  background: #0d6efd;
  border-color: #6ea8fe;
}

.sliders-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 6px;
  font-size: 0.75rem;
}

.sliders-row input[type="range"] {
  width: 100%;
}

.editor-bottom-btns {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  flex-wrap: wrap;
}

/* PDF Reader & Saved Docs */
.reader-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 12px;
}

.reader-pages-container {
  background: #dde6f0;
  border-radius: 12px;
  padding: 12px;
  min-height: 420px;
  max-height: 75vh;
  overflow: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.reader-pages-container canvas {
  max-width: 100%;
  height: auto;
  background: #fff;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
  border-radius: 4px;
}

.saved-doc-item {
  border: 1px solid var(--mci-line);
  border-radius: 12px;
  padding: 12px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
  background: #fff;
}

.camera-video {
  max-width: 100%;
  max-height: 100%;
  border-radius: 10px;
  background: #000;
}

.toast-banner {
  position: fixed;
  right: 16px;
  bottom: 78px;
  background: #082c50;
  color: #fff;
  padding: 11px 16px;
  border-radius: 12px;
  font-size: 0.84rem;
  font-weight: 700;
  z-index: 120;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.25);
  display: none;
}

.toast-banner.show {
  display: block;
}

@media (max-width: 720px) {
  .action-tiles {
    grid-template-columns: 1fr;
  }
  .doc-meta-grid {
    grid-template-columns: 1fr;
  }
  .sticky-export-inner {
    flex-direction: column;
    align-items: stretch;
  }
  .export-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }
}
