/* Any element toggled via the HTML `hidden` attribute must actually stay hidden,
   no matter what other display rule a class sets (flex/grid/inline-flex/etc). This
   one rule, with !important, guarantees that — closing off a recurring bug class
   where an authored `display:` value silently beat the browser's own default
   [hidden]{display:none} rule at equal specificity, leaving supposedly-hidden UI
   (a dropdown menu, a logo preview, a thumbnail grid) visible regardless of what
   the JS correctly set the `hidden` property to. */
[hidden] { display: none !important; }

:root {
  --primary: #2BA6DE;
  --primary-dark: #1E88C2;
  --primary-bright: #1B84C4;
  --ink: #16284F;
  --muted: #64748B;
  --border: #C7D2E0;
  --card-bg: #FFFFFF;
  --card-bg-alt: #F1F5F9;
  --bg: #F4F7FB;
  --organize: #1B5FA6;
  --edit: #1B5FA6;
  --convert: #1B5FA6;
}

/* PDF Editor custom fonts — the exact same font files get embedded into the output
   PDF (see EDITOR_FONTS / getFont in app.js), so what you see on screen here matches
   what downloads. */
@font-face { font-family: 'PdfEditorInter'; src: url('vendor/fonts/Inter-Regular.ttf'); font-weight: 400; }
@font-face { font-family: 'PdfEditorInter'; src: url('vendor/fonts/Inter-Bold.ttf'); font-weight: 700; }
@font-face { font-family: 'PdfEditorMerriweather'; src: url('vendor/fonts/Merriweather-Regular.ttf'); font-weight: 400; }
@font-face { font-family: 'PdfEditorMerriweather'; src: url('vendor/fonts/Merriweather-Bold.ttf'); font-weight: 700; }
@font-face { font-family: 'PdfEditorCaveat'; src: url('vendor/fonts/Caveat-Regular.ttf'); font-weight: 400; }
@font-face { font-family: 'PdfEditorCaveat'; src: url('vendor/fonts/Caveat-Bold.ttf'); font-weight: 700; }
@font-face { font-family: 'PdfEditorCalibri'; src: url('vendor/fonts/Carlito-Regular.ttf'); font-weight: 400; }
@font-face { font-family: 'PdfEditorCalibri'; src: url('vendor/fonts/Carlito-Bold.ttf'); font-weight: 700; }
@font-face { font-family: 'PdfEditorCambria'; src: url('vendor/fonts/Caladea-Regular.ttf'); font-weight: 400; }
@font-face { font-family: 'PdfEditorCambria'; src: url('vendor/fonts/Caladea-Bold.ttf'); font-weight: 700; }


* { box-sizing: border-box; }
/* Buttons have their own default text color in the browser's UA stylesheet and don't
   inherit it from the page automatically — this single rule is what actually fixes
   readability everywhere in the app, not just on the home screen tool cards. */
button { color: inherit; font-family: inherit; }
html, body {
  margin: 0; padding: 0;
  font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background:
    radial-gradient(circle at 95% 10%, rgba(255, 244, 209, 0.62) 0, rgba(255, 244, 209, 0) 24%),
    linear-gradient(90deg, #EAF8FF 0%, #F4FAFD 48%, #FFFFFF 100%);
  color: var(--ink);
  min-height: 100%;
}

.bg-color-3 { background-color: #FFFFFF; }
.header-section {
  position: relative;
  z-index: 99;
  border-bottom: 1px solid rgba(22, 40, 79, 0.04);
}
.container-fluid {
  width: 100%;
  margin: 0 auto;
  padding: 0 10px;
}
.header-wrapper {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  min-height: 82px;
}
.header-wrapper .logo a {
  display: inline-flex;
  align-items: center;
}
.header-wrapper .logo a img {
  display: block;
  width: auto;
  max-width: 220px;
  height: 60px;
  object-fit: contain;
}
.menu-area {
  display: flex;
  align-items: center;
}
.menu {
  display: flex;
  align-items: center;
  gap: 34px;
  list-style: none;
  margin: 0;
  padding: 0;
}
.menu--style1 li a {
  color: #16284F;
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  line-height: 1.2;
  transition: color .16s ease;
}
.menu--style1 li a:hover,
.menu--style1 li a:focus {
  color: #F58A75;
}
.header-bar {
  display: none;
  width: 30px;
  cursor: pointer;
}
.header-bar span {
  display: block;
  height: 2px;
  margin: 6px 0;
  background: #16284F;
  border-radius: 2px;
}

.home {
  min-height: calc(100vh - 82px);
  padding: 34px 0 70px;
}

.hero {
  position: relative;
  text-align: center;
  max-width: 1180px;
  min-height: 292px;
  margin: 0 auto;
  padding: 78px 36px 90px;
  overflow: hidden;
  border-radius: 22px;
  background:
    radial-gradient(circle at 94% 8%, rgba(250, 201, 77, 0.38) 0, rgba(250, 201, 77, 0.08) 14%, rgba(250, 201, 77, 0) 28%),
    linear-gradient(128deg, #24B9E8 0%, #1979B5 42%, #213D71 100%);
  box-shadow: 0 18px 38px rgba(22, 40, 79, 0.12);
}
.hero h1 {
  max-width: 860px;
  margin: 0 auto 16px;
  font-size: 52px;
  line-height: 1.08;
  font-weight: 900;
  letter-spacing: 0;
  color: #FFFFFF;
}
.hero p {
  color: rgba(255, 255, 255, 0.86);
  font-size: 16px;
  margin: 0;
}

.tool-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 22px;
  max-width: 1140px;
  margin: -38px auto 0;
  padding: 0 24px;
  position: relative;
  z-index: 2;
}

.tool-card {
  min-height: 152px;
  background: rgba(255, 255, 255, 0.88);
  border: 1px solid rgba(255, 255, 255, 0.92);
  border-radius: 16px;
  padding: 24px 20px 20px;
  text-align: left;
  cursor: pointer;
  box-shadow: 0 22px 44px rgba(22, 40, 79, 0.10);
  backdrop-filter: blur(8px);
  transition: transform .12s ease, box-shadow .12s ease, border-color .12s ease;
  font-family: inherit;
  color: inherit;
}
.tool-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 28px 52px rgba(22, 40, 79, 0.14);
  border-color: rgba(43, 166, 222, 0.38);
}
.tool-icon {
  width: 46px;
  height: 46px;
  margin-bottom: 18px;
  padding: 7px;
  border-radius: 12px;
  background: #E7F8FF;
  color: #2BA6DE !important;
  box-shadow: inset 0 0 0 1px rgba(43, 166, 222, 0.14), 0 8px 18px rgba(43, 166, 222, 0.14);
}
.tool-icon.organize { color: var(--organize); }
.tool-icon.edit { color: var(--edit); }
.tool-icon.convert { color: var(--convert); }
.tool-icon svg { width: 100%; height: 100%; }

/* Buttons don't automatically inherit text color from the page in every browser —
   only font-family was being inherited here, so .tool-name was falling back to the
   browser's default button-text color (dark) instead of the app's light theme color,
   which is exactly why the headings were unreadable against the dark card background. */
.tool-name { font-weight: 800; font-size: 15px; margin-bottom: 9px; color: var(--ink); }
.tool-desc { color: #667892; font-size: 12.5px; line-height: 1.45; }

/* ---- tool view ---- */
.tool-view {
  max-width: 760px;
  margin: 40px auto 80px;
  padding: 0 24px;
}
.back-btn {
  background: none; border: none;
  color: var(--primary);
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  padding: 0 0 18px;
}
.tool-view h2 { margin: 0 0 4px; font-size: 26px; }
.tool-subtitle { color: var(--muted); margin: 0 0 24px; font-size: 14px; }

.dropzone {
  border: 2px dashed var(--border);
  border-radius: 14px;
  background: var(--card-bg);
  padding: 46px 20px;
  text-align: center;
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.dropzone.drag-over {
  border-color: var(--primary);
  background: rgba(43, 166, 222, 0.1);
}
.dropzone-icon { color: var(--primary); width: 40px; height: 40px; margin: 0 auto 14px; }
.dropzone-text { color: var(--muted); font-size: 14.5px; }
.dropzone .link { color: var(--primary-bright); font-weight: 600; text-decoration: underline; }

.file-list { margin-top: 18px; display: flex; flex-direction: column; gap: 8px; }
.file-row {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--card-bg); border: 1px solid var(--border); border-radius: 8px;
  padding: 10px 14px; font-size: 13.5px;
}
.file-row .name { font-weight: 600; }
.file-row .meta { color: var(--muted); font-size: 12.5px; margin-left: 8px; }
.file-row .remove { color: var(--muted); cursor: pointer; background:none; border:none; font-size: 16px; }
.file-row .remove:hover { color: var(--primary); }
.file-row .drag-handle { cursor: grab; color: var(--muted); margin-right: 8px; }

.options-panel {
  margin-top: 20px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.opt-row { display: flex; flex-direction: column; gap: 6px; }
.opt-row label { font-size: 13.5px; font-weight: 600; }
.opt-row input[type=text], .opt-row input[type=number], .opt-row select {
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 8px 10px;
  font-size: 14px;
  font-family: inherit;
  background: var(--card-bg-alt);
  color: var(--ink);
}
.opt-inline { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.radio-group { display: flex; gap: 16px; }
.radio-group label { font-weight: 500; display: flex; gap: 6px; align-items: center; }

.preview-wrap { margin-top: 4px; }
.preview-label { font-size: 12px; color: var(--muted); margin-bottom: 6px; }
#numPreviewCanvas, #wmPreviewCanvas {
  border: 1px solid var(--border);
  border-radius: 8px;
  max-width: 100%;
  display: block;
}

.thumb-grid {
  margin-top: 20px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 14px;
}
.thumb-card {
  background: var(--card-bg-alt); border: 1px solid var(--border); border-radius: 10px;
  padding: 8px; text-align: center; cursor: pointer; position: relative;
}
.thumb-card[draggable="true"] { cursor: grab; }
.thumb-card.dragging { opacity: 0.4; }
.thumb-card img { width: 100%; border-radius: 6px; border: 1px solid var(--border); display: block; }
.thumb-card .page-idx { font-size: 11.5px; color: var(--muted); margin-top: 6px; }
.thumb-card .thumb-actions {
  position: absolute; top: 4px; right: 4px; display: flex; gap: 4px;
}
.thumb-card .thumb-actions button {
  background: rgba(19,27,44,0.85); border: 1px solid rgba(255,255,255,0.15);
  border-radius: 5px; width: 22px; height: 22px; cursor: pointer; font-size: 12px;
  display: flex; align-items: center; justify-content: center;
  color: #fff;
}
.thumb-card .thumb-actions button:hover { color: #6FC3F0; }
.thumb-card.deleted { opacity: 0.3; }
.remove-badge {
  position: absolute; top: 4px; left: 4px;
  background: var(--primary); color: #fff; font-size: 10.5px; font-weight: 700;
  padding: 2px 6px; border-radius: 5px; z-index: 2;
}

.process-btn {
  margin-top: 26px;
  background: var(--primary);
  color: #fff;
  border: none;
  font-weight: 700;
  font-size: 15px;
  padding: 13px 28px;
  border-radius: 8px;
  cursor: pointer;
  transition: background .15s;
}
.process-btn:hover { background: var(--primary-dark); }
.process-btn:disabled { background: var(--border); color: var(--muted); cursor: not-allowed; }

.progress-area { margin-top: 22px; }
.progress-bar { background: var(--card-bg-alt); border-radius: 6px; height: 8px; overflow: hidden; }
.progress-fill { background: var(--primary); height: 100%; width: 0%; transition: width .2s; }
.progress-label { margin-top: 8px; font-size: 13px; color: var(--muted); }

.result-area {
  margin-top: 26px;
  background: rgba(46, 178, 108, 0.1);
  border: 1px solid rgba(46, 178, 108, 0.35);
  border-radius: 10px;
  padding: 20px;
  text-align: center;
}
.result-area h3 { margin: 0 0 6px; color: #15803D; }
.result-area p { margin: 0 0 14px; color: var(--muted); font-size: 13.5px; }
.download-btn {
  display: inline-block;
  background: var(--primary);
  color: #fff;
  text-decoration: none;
  font-weight: 700;
  padding: 11px 22px;
  border-radius: 8px;
  border: none;
  font-size: 14px;
  cursor: pointer;
  font-family: inherit;
}
.download-btn-list { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.download-all-btn {
  background: #2EB26C;
  margin-bottom: 14px;
}
.download-all-btn:hover { background: #279960; }
.download-all-btn:disabled { opacity: 0.6; cursor: default; }
.download-btn:hover { background: var(--primary-dark); }

.warn-note {
  background: rgba(245, 166, 35, 0.12); border: 1px solid rgba(245, 166, 35, 0.4); color: #92600A;
  border-radius: 8px; padding: 10px 14px; font-size: 13px; margin-bottom: 14px;
}
.warn-note.error { background: rgba(240, 102, 77, 0.12); border-color: rgba(240, 102, 77, 0.4); color: #C0392B; }

.print-actions { margin-bottom: 20px; }

.docx-preview-box, #docxPreviewWrap {
  background: var(--card-bg-alt);
  border-radius: 10px;
  padding: 24px;
  max-height: 560px;
  overflow: auto;
}
/* docx-preview renders each page as .docx-wrapper > section.docx at its true, original
   page size. Never shrink or reflow that — doing so changes line wrapping and breaks
   the very fidelity this tool exists for. If a page is wider than the box, let it
   scroll horizontally instead of squishing. */
.docx-preview-box .docx-wrapper, #docxPreviewWrap .docx-wrapper { background: transparent; }

@media print {
  @page { size: A4; margin: 0; }
  body * { visibility: hidden; }
  .print-target, .print-target * { visibility: visible; }
  .print-target {
    position: absolute; left: 0; top: 0; width: 100%;
    background: none; padding: 0; max-height: none; overflow: visible;
  }
  #xlsPrintWrap { display: block !important; }
  .docx-wrapper { transform: none !important; margin-bottom: 0 !important; }
  .html2pdf-preview-box { overflow: visible !important; max-height: none !important; border: none !important; }
  .docx-wrapper > section.docx { page-break-after: always; }
  .docx-wrapper > section.docx:last-child { page-break-after: auto; }
  .xls-sheet-block { page-break-after: always; }
  .xls-sheet-block:last-child { page-break-after: auto; }
}

/* Interactive page-break editor (Excel to PDF, PDF to Excel preview) */
.break-editor { overflow: auto; max-width: 100%; margin-top: 10px; }
.break-editor-table {
  border-collapse: collapse;
  font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 12px;
}
.break-editor-table th, .break-editor-table td {
  border: 1px solid var(--border);
  padding: 3px 9px;
  white-space: nowrap;
  color: var(--ink);
}
.break-editor-table th.gutter-col, .break-editor-table th.gutter-row {
  background: var(--card-bg-alt);
  color: var(--muted);
  cursor: pointer;
  user-select: none;
  font-weight: 600;
  text-align: center;
}
.break-editor-table th.gutter-col:hover, .break-editor-table th.gutter-row:hover { background: rgba(43,166,222,0.18); color: var(--primary-bright); }
.break-editor-table th.gutter-col.break-after,
.break-editor-table td.break-after-col { border-right: 3px solid var(--convert) !important; }
.break-editor-table th.gutter-row.break-after { border-bottom: 3px solid var(--convert) !important; }
.break-editor-table tr.break-after-row > td { border-bottom: 3px solid var(--convert) !important; }

#xlsPreviewWrap {
  background: var(--card-bg-alt);
  border-radius: 10px;
  padding: 24px;
  max-height: 520px;
  overflow: auto;
}
.xls-sheet-block {
  background: #fff;
  margin: 0 auto 24px;
  padding: 24px 28px;
  box-shadow: 0 4px 18px rgba(0,0,0,0.12);
  max-width: 100%;
  box-sizing: border-box;
  overflow-x: auto;
}
.xls-sheet-block:last-child { margin-bottom: 0; }
.xls-sheet-title { font-size: 14px; color: var(--muted); margin: 0 0 10px; font-weight: 700; }
.xls-sheet-block table {
  border-collapse: collapse;
  font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 12.5px;
  max-width: 100%;
}
.xls-sheet-block table td, .xls-sheet-block table th {
  border: 1px solid #d8d8d8;
  padding: 4px 8px;
  white-space: nowrap;
}
.xls-sheet-block table td.hdr { font-weight: 700; background: #f3f3f4; }

/* Preview for extracted PDF→Word / PDF→Excel content, shown before download */
#extractPreviewWrap {
  background: var(--card-bg-alt);
  border-radius: 10px;
  padding: 24px;
  max-height: 480px;
  overflow: auto;
  margin-top: 18px;
}
.extract-page-block {
  background: #fff;
  margin: 0 auto 20px;
  padding: 20px 24px;
  box-shadow: 0 4px 14px rgba(0,0,0,0.10);
  max-width: 100%;
  box-sizing: border-box;
  overflow-x: auto;
}
.extract-page-block:last-child { margin-bottom: 0; }
.extract-page-title { font-size: 12.5px; color: var(--muted); margin: 0 0 8px; font-weight: 700; }
.extract-page-block table {
  border-collapse: collapse;
  font-size: 12.5px;
  max-width: 100%;
  table-layout: fixed;
  word-wrap: break-word;
}
.extract-page-block table td { border: 1px solid #d8d8d8; padding: 4px 8px; }
.extract-page-block p { margin: 0 0 8px; font-size: 13px; line-height: 1.5; word-wrap: break-word; }

.footer {
  text-align: center;
  color: rgba(255, 255, 255, 0.34);
  font-size: 12.5px;
  padding: 32px 20px;
  background: #203E70;
}

@media (max-width: 1180px) {
  .hero {
    margin-left: 24px;
    margin-right: 24px;
  }
  .tool-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

@media (max-width: 920px) {
  .header-wrapper {
    position: relative;
    min-height: 76px;
  }
  .menu-area {
    width: 100%;
    order: 3;
  }
  .menu {
    display: none;
    width: 100%;
    flex-direction: column;
    align-items: flex-start;
    gap: 0;
    padding: 10px 0 16px;
  }
  .menu.active { display: flex; }
  .menu--style1 li { width: 100%; }
  .menu--style1 li a {
    display: block;
    width: 100%;
    padding: 11px 0;
    font-size: 15px;
  }
  .header-bar {
    display: block;
    margin-left: auto;
  }
  .header-bar span {
    transition: transform .2s ease, opacity .2s ease;
  }
  .header-bar.active span:first-child {
    transform: translateY(8px) rotate(45deg);
  }
  .header-bar.active span:nth-child(2) {
    opacity: 0;
  }
  .header-bar.active span:last-child {
    transform: translateY(-8px) rotate(-45deg);
  }
  .tool-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .hero h1 { font-size: 42px; }
}

@media (max-width: 560px) {
  .container-fluid { padding: 0 18px; }
  .header-wrapper {
    align-items: center;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 12px;
    min-height: auto;
    padding: 12px 0;
  }
  .header-wrapper .logo a img { height: 48px; }
  .menu {
    align-items: flex-start;
    flex-direction: column;
    flex-wrap: nowrap;
    gap: 0;
  }
  .menu--style1 li a { font-size: 14px; }
  .home { padding-top: 22px; }
  .hero {
    min-height: 238px;
    margin-left: 16px;
    margin-right: 16px;
    padding: 52px 22px 74px;
    border-radius: 18px;
  }
  .hero h1 { font-size: 30px; }
  .hero p { font-size: 14px; }
  .tool-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
    margin-top: -34px;
    padding: 0 18px;
  }
  .tool-card {
    min-height: 145px;
    padding: 20px 16px 18px;
  }
}

@media (max-width: 380px) {
  .tool-grid { grid-template-columns: 1fr; }
}

.docx-page-badge {
  position: absolute;
  top: 8px;
  left: 8px;
  background: var(--primary);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 6px;
  z-index: 5;
  pointer-events: none;
}
@media print {
  .docx-page-badge { display: none; }
}

.compress-estimate {
  margin-top: 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--primary-bright);
  line-height: 1.5;
}
.compress-estimate.warn {
  color: #92600A;
  background: rgba(245, 166, 35, 0.12);
  border: 1px solid rgba(245, 166, 35, 0.4);
  border-radius: 8px;
  padding: 8px 12px;
}


/* Password prompt modal */
.password-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  animation: fadeIn 0.15s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.password-modal {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 28px 32px;
  max-width: 400px;
  width: 90%;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}
.password-modal h3 {
  margin: 0 0 10px;
  font-size: 18px;
  color: var(--ink);
}
.password-modal p {
  margin: 0 0 16px;
  font-size: 13.5px;
  color: var(--muted);
  line-height: 1.5;
  word-break: break-word;
}
.password-error {
  color: #C0392B !important;
  font-weight: 600;
}
.password-input-row {
  margin-bottom: 18px;
}
.password-input-row input {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: 15px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s;
  background: var(--card-bg-alt);
  color: var(--ink);
}
.password-input-row input:focus {
  border-color: var(--primary);
}
.password-buttons {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}
.password-btn {
  padding: 9px 20px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  font-family: inherit;
  transition: background 0.12s;
}
.password-btn.cancel {
  background: var(--card-bg-alt);
  color: var(--muted);
}
.password-btn.cancel:hover {
  background: var(--border);
}
.password-btn.submit {
  background: var(--primary);
  color: #fff;
}
.password-btn.submit:hover {
  background: var(--primary-dark);
}


/* Redact tool */
.redact-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
}
.redact-pages-container {
  max-height: 600px;
  overflow-y: auto;
  background: var(--card-bg-alt);
  border-radius: 10px;
  padding: 20px;
}
.redact-page-wrap {
  margin-bottom: 24px;
}
.redact-page-wrap:last-child {
  margin-bottom: 0;
}
.redact-page-label {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--muted);
  margin-bottom: 8px;
}
.redact-canvas-wrap {
  background: #fff;
  box-shadow: 0 4px 18px rgba(0,0,0,0.12);
  border-radius: 4px;
  overflow: hidden;
  max-width: 100%;
  display: inline-block;
}
.redact-draw-canvas {
  display: block;
}

/* Compare PDF */
.compare-page-block {
  background: #fff;
  margin: 0 0 20px;
  padding: 18px 22px;
  border-radius: 10px;
  box-shadow: 0 4px 14px rgba(0,0,0,0.10);
  max-width: 100%;
  box-sizing: border-box;
}
.compare-page-block:last-child { margin-bottom: 0; }
.compare-page-title {
  font-size: 13px;
  color: var(--ink);
  font-weight: 700;
  margin: 0 0 10px;
}
.compare-diff-list {
  font-family: ui-monospace, "SF Mono", Consolas, monospace;
  font-size: 12.5px;
  line-height: 1.6;
  background: var(--card-bg-alt);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 14px;
  max-height: 220px;
  overflow-y: auto;
  color: var(--ink);
}
.compare-line { white-space: pre-wrap; word-break: break-word; }
.compare-line-removed { color: #C0392B; background: rgba(240,102,77,0.12); }
.compare-line-added { color: #15803D; background: rgba(46,178,108,0.12); }

/* Compare PDF: side-by-side */
.compare-side-by-side {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
}
.compare-side { flex: 1 1 260px; min-width: 200px; }
.compare-side-label {
  font-size: 11.5px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin-bottom: 6px;
}

/* PDF Editor */
.editor-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 16px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.editor-tool-group { display: flex; gap: 6px; flex-wrap: wrap; }
.editor-tool-btn {
  padding: 7px 14px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--card-bg-alt);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  color: var(--ink);
  transition: background 0.12s, color 0.12s, border-color 0.12s;
}
.editor-tool-btn:hover { border-color: var(--primary); }
/* This was the actual bug behind "the selected option vanishes" — the active state
   referenced a CSS variable (--brand) that was never defined anywhere, so clicking a
   tool never visibly changed anything even though the selection itself was working
   correctly underneath. */
.editor-tool-btn.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.editor-shapes-dropdown { position: relative; }
.editor-shapes-trigger {
  padding: 7px 14px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--card-bg-alt);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  color: var(--ink);
  transition: background 0.12s, color 0.12s, border-color 0.12s;
}
.editor-shapes-trigger:hover { border-color: var(--primary); }
.editor-shapes-trigger.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.editor-shapes-menu {
  position: absolute;
  top: 100%;
  left: 0;
  margin-top: 4px;
  background: var(--card-bg-alt);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 140px;
  z-index: 20;
  box-shadow: 0 6px 18px rgba(0,0,0,0.35);
}
.editor-shapes-menu[hidden] { display: none; }
.editor-shapes-option { text-align: left; width: 100%; }
.editor-color-group { display: flex; gap: 6px; align-items: center; }
.editor-color-swatch {
  width: 24px; height: 24px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  padding: 0;
  box-shadow: 0 0 0 1px rgba(0,0,0,0.15);
}
.editor-color-swatch.active { border-color: var(--ink); box-shadow: 0 0 0 1px var(--ink); }
.editor-size-group { display: flex; align-items: center; gap: 8px; }
.editor-font-group { display: flex; align-items: center; gap: 10px; }
.editor-font-group select {
  padding: 5px 8px;
  border-radius: 6px;
  border: 1px solid var(--border);
  font-size: 13px;
  background: var(--card-bg-alt);
  color: var(--ink);
}
.editor-bold-toggle { font-size: 13px; color: var(--ink); display: flex; align-items: center; gap: 5px; cursor: pointer; }
.editor-hint {
  font-size: 12.5px;
  color: var(--muted);
  margin-bottom: 12px;
  min-height: 16px;
}
.editor-page-nav {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 14px;
}
.editor-canvas-wrap {
  max-width: 100%;
  overflow-x: auto;
  display: flex;
  justify-content: center;
  background: var(--card-bg-alt);
  padding: 16px;
  border-radius: 8px;
}
.editor-canvas-stack { position: relative; }
.editor-canvas-stack img { position: absolute; top: 0; left: 0; user-select: none; }
.editor-overlay-canvas { position: relative; top: 0; left: 0; cursor: crosshair; }
.editor-inline-text-input {
  position: absolute;
  z-index: 5;
  border: 2px solid #2EB26C;
  box-shadow: 0 0 0 3px rgba(46,178,108,0.25);
  background: rgba(255,255,255,0.95);
  padding: 2px 4px;
  min-height: 28px;
  resize: both;
  overflow: auto;
  outline: none;
  line-height: 1.25;
}
/* This is driven by the browser's own actual focus state, not by any of my JS —
   if this amber glow never appears after clicking, the textarea genuinely never
   received keyboard focus, which is the single most useful fact for diagnosing
   "can't type" reports. */
.editor-inline-text-input:focus {
  border: 3px solid #F5B800;
  box-shadow: 0 0 0 5px rgba(245,184,0,0.4);
}

/* Create Invoice */
.invoice-layout {
  display: grid;
  grid-template-columns: 1.1fr 1fr;
  gap: 28px;
  align-items: start;
}
@media (max-width: 900px) {
  .invoice-layout { grid-template-columns: 1fr; }
}
.invoice-form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px 16px;
}
.invoice-form-grid .opt-row input { width: 100%; }
.invoice-divider { border: none; border-top: 1px solid var(--border); margin: 16px 0; }
.invoice-item-row {
  display: grid;
  grid-template-columns: 2.2fr 0.7fr 0.9fr 0.9fr auto;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
}
.invoice-item-row input {
  padding: 7px 9px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
}
.inv-item-amount { font-size: 13px; color: var(--muted); text-align: right; padding-right: 4px; }
.inv-item-remove {
  background: none; border: none; color: var(--muted); font-size: 18px;
  cursor: pointer; line-height: 1; padding: 4px;
}
.inv-item-remove:hover { color: var(--primary); }
.invoice-preview-col { position: sticky; top: 20px; }
.invoice-preview-label { font-size: 12.5px; color: var(--muted); margin-bottom: 8px; font-weight: 600; }
.invoice-preview {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 28px;
  font-size: 13px;
  color: var(--ink);
  min-height: 400px;
}
.invoice-preview-header { display: flex; justify-content: space-between; margin-bottom: 20px; }
.invoice-preview-title { font-size: 22px; font-weight: 800; letter-spacing: 0.5px; }
.invoice-preview-parties { display: flex; justify-content: space-between; gap: 20px; margin-bottom: 20px; line-height: 1.5; }
.invoice-preview-parties > div { flex: 1; }
.invoice-preview-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.invoice-preview-table th {
  text-align: left; background: #F0F0F2; padding: 7px 8px; font-weight: 600;
}
.invoice-preview-table th:not(:first-child), .invoice-preview-table td:not(:first-child) { text-align: right; }
.invoice-preview-table td { padding: 6px 8px; border-bottom: 1px solid #F0F0F1; }
.invoice-preview-totals { margin-top: 16px; margin-left: auto; width: 220px; font-size: 13px; }
.invoice-preview-totals > div { display: flex; justify-content: space-between; padding: 3px 0; }
.invoice-preview-total-final { font-weight: 800; font-size: 15px; border-top: 1px solid var(--border); margin-top: 4px; padding-top: 8px !important; }
.invoice-preview-notes { margin-top: 20px; font-size: 12px; color: var(--muted); }

/* Bulk Create Invoices */
.bulk-invoice-summary-table { width: 100%; border-collapse: collapse; font-size: 13px; margin-top: 12px; }
.bulk-invoice-summary-table th, .bulk-invoice-summary-table td { padding: 7px 10px; border-bottom: 1px solid var(--border); text-align: left; }
.bulk-invoice-summary-table th { background: var(--card-bg-alt); font-weight: 600; }

/* Invoice logo upload */
.invoice-logo-row { margin-bottom: 4px; }
.invoice-logo-upload { display: flex; align-items: center; gap: 12px; }
.invoice-logo-preview-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 10px;
  background: var(--card-bg-alt);
}
.invoice-logo-preview-img { max-height: 40px; max-width: 140px; object-fit: contain; }
.invoice-logo-preview-wrap .inv-item-remove { margin-left: 8px; }
.invoice-preview-logo { max-height: 44px; max-width: 130px; object-fit: contain; }

.html2pdf-preview-box {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  overflow: auto;
  max-height: 75vh;
}
