/* FAB Button in bottom right OF THE OVERLAY CONTENT */
#fab-estimates {
  position: absolute;
  bottom: 24px;
  right: 24px;
  width: 56px;
  height: 56px;
  background: linear-gradient(135deg, #ff7a9a, #d21c43);
  border: 1px solid rgba(255, 120, 150, 0.35);
  border-radius: 16px; 
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 100;
  color: #0f0b11;
  font-size: 32px;
  font-weight: 400;
  transition: transform 0.1s, opacity 0.2s;
  display: flex; 
}

#fab-estimates:active {
  transform: scale(0.92);
}

/* Modal Overlay (Upload Equipment) */
.est-modal-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  -webkit-backdrop-filter: blur(5px); backdrop-filter: blur(5px);
  z-index: 3000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  visibility: hidden;
  transition: opacity 0.25s ease, visibility 0.25s ease;
}

.est-modal-overlay.show {
  opacity: 1;
  pointer-events: auto;
  visibility: visible;
}

/* Modal for Upload (Small) — legacy fallback */
.est-modal-window-small {
  width: 90%; max-width: 340px;
  background: #1f1016; border: 1px solid rgba(255, 90, 130, 0.35);
  border-radius: 20px; box-shadow: 0 24px 60px rgba(0, 0, 0, 0.7);
  display: flex; flex-direction: column; overflow: hidden;
  pointer-events: none;
  transform: translateY(15px) scale(0.98);
  transition: transform 0.25s cubic-bezier(0.18, 0.89, 0.32, 1.28);
}
.est-modal-overlay.show .est-modal-window-small {
  transform: translateY(0) scale(1); pointer-events: auto;
}

/* ---- Upload Estimate Card (redesign) ---- */
.est-upload-card {
  position: relative;
  width: 90%; max-width: 320px;
  background: linear-gradient(170deg, #1e1222 0%, #160d18 100%);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 22px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.6), 0 0 0 1px rgba(255,120,150,0.12);
  padding: 28px 24px 22px;
  display: flex; flex-direction: column; align-items: center; gap: 14px;
  pointer-events: none;
  transform: translateY(14px) scale(0.97);
  transition: transform 0.3s cubic-bezier(0.18, 0.89, 0.32, 1.28), opacity 0.25s;
  opacity: 0;
}
.est-modal-overlay.show .est-upload-card {
  transform: translateY(0) scale(1);
  pointer-events: auto; opacity: 1;
}

.est-upload-close {
  position: absolute; top: 12px; right: 12px;
  width: 30px; height: 30px; border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.1);
  background: rgba(255,255,255,0.05); color: rgba(255,255,255,0.5);
  font-size: 16px; display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: all 0.2s;
}
.est-upload-close:hover { background: rgba(255,107,107,0.15); color: #FF6B6B; border-color: rgba(255,107,107,0.3); }

.est-upload-icon-area { display: flex; justify-content: center; }
.est-upload-circle {
  width: 64px; height: 64px; border-radius: 50%;
  background: linear-gradient(135deg, rgba(78,205,196,0.15), rgba(69,183,209,0.1));
  border: 1.5px solid rgba(78,205,196,0.25);
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 0 24px rgba(78,205,196,0.1);
}
.est-upload-circle-icon { font-size: 28px; line-height: 1; }

.est-upload-title {
  font-size: 17px; font-weight: 700; color: #fff;
  text-align: center; letter-spacing: 0.2px;
}
.est-upload-hint {
  font-size: 12px; color: rgba(255,255,255,0.4);
  text-align: center; margin-top: -6px;
}

.est-upload-form { display: flex; flex-direction: column; gap: 12px; width: 100%; }

.est-upload-dropzone {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  width: 100%; padding: 22px 16px; box-sizing: border-box;
  border: 2px dashed rgba(167,119,227,0.3);
  border-radius: 14px;
  background: rgba(167,119,227,0.06);
  cursor: pointer; transition: all 0.25s;
}
.est-upload-dropzone:hover {
  border-color: rgba(167,119,227,0.55);
  background: rgba(167,119,227,0.12);
}
.est-upload-dropzone:active { transform: scale(0.98); }
.est-upload-dropzone input { display: none; }
.est-upload-dropzone-icon {
  font-size: 26px; color: #C9A0FF; line-height: 1; font-weight: 300;
}
.est-upload-dropzone-text {
  font-size: 13px; color: #C9A0FF; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%;
}
/* When file selected */
.est-upload-dropzone.has-file {
  border-color: rgba(78,205,196,0.4);
  background: rgba(78,205,196,0.08);
}
.est-upload-dropzone.has-file .est-upload-dropzone-icon { color: #4ECDC4; }
.est-upload-dropzone.has-file .est-upload-dropzone-text { color: #4ECDC4; }

.est-upload-submit {
  width: 100%; padding: 13px; border: none; border-radius: 14px;
  background: linear-gradient(135deg, #FF6B6B 0%, #FF8E53 50%, #FEB47B 100%);
  color: #1a0a0a; font-size: 14px; font-weight: 700; cursor: pointer;
  box-shadow: 0 6px 18px rgba(255,107,107,0.25);
  transition: transform 0.15s, box-shadow 0.15s, filter 0.15s;
}
.est-upload-submit:hover { filter: brightness(1.06); box-shadow: 0 8px 24px rgba(255,107,107,0.35); }
.est-upload-submit:active { transform: translateY(1px); }
.est-upload-submit:disabled { opacity: 0.6; cursor: wait; }
.est-upload-submit.btn-processing { background: linear-gradient(135deg, #f1c40f, #f39c12) !important; }
.est-upload-submit.btn-success { background: linear-gradient(135deg, #2ecc71, #27ae60) !important; }
.est-upload-submit.btn-error { background: linear-gradient(135deg, #e74c3c, #c0392b) !important; color: #fff; }

/* Modal for Edit (Large - fills parent overlay-card) */
.est-modal-window-large {
  position: absolute;
  inset: 0;
  background: #181014; 
  border: 1px solid rgba(255, 120, 150, 0.35);
  border-radius: 18px; 
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
  display: flex; 
  flex-direction: column; 
  overflow: hidden; 
  pointer-events: none;
  transition: transform 0.25s ease, opacity 0.25s ease;
  opacity: 0;
  transform: translateY(20px);
}

.est-modal-overlay.show .est-modal-window-large {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

/* Common Header Styles for both */
.est-modal-header {
  height: 52px; 
  flex-shrink: 0; 
  display: flex; 
  align-items: center; 
  justify-content: center;
  position: relative;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.08) 0%, rgba(255, 255, 255, 0.02) 100%);
  border-bottom: 1px solid rgba(255, 120, 150, 0.2); 
  /* Rounded top corners if needed, but window has radius */
  padding: 0 48px; /* Added padding to prevent title overlap with close button */
}

.est-modal-title {
  font-weight: 700; 
  font-size: 16px; 
  color: #fff; 
  letter-spacing: normal;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.est-modal-close {
  position: absolute; 
  right: 12px; 
  top: 50%; 
  transform: translateY(-50%);
  width: 32px; 
  height: 32px; 
  border-radius: 8px; 
  border: 1px solid rgba(255, 120, 150, 0.25);
  background: rgba(255, 255, 255, 0.08); 
  color: #ffa5c0; 
  font-size: 18px;
  display: flex; 
  align-items: center; 
  justify-content: center; 
  cursor: pointer; 
  z-index: 10;
  opacity: 1;
}

.est-modal-close:hover {
  background: rgba(255, 255, 255, 0.15);
}

/* Content Styles */
.est-modal-content {
  padding: 24px;
  color: #eee;
  text-align: center;
  font-size: 14px;
  flex: 1; /* Takes remaining space */
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start; /* Start from top */
  overflow-y: auto; /* Scrollable content */
}

/* --- EDIT MODAL LAYOUT --- */
.est-edit-layout {
  display: flex;
  width: 100%;
  height: 100%;
  gap: 16px;
  overflow: hidden;
}

/* Ensure hidden doesn't break layout completely, but hides content */
.est-section-content.hidden,
.est-category-content.hidden {
  display: none;
}

/* Ensure transitions don't mess up width calculations too much */
.est-category-content, .est-section-content {
  display: block;
}

.est-edit-left {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: rgba(255, 255, 255, 0.03);
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  overflow: hidden;
}

/* Preview Column */
.est-edit-right {
    flex: 1;
    background: rgba(255, 255, 255, 0.03); /* Same as left */
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    flex-direction: column;
    overflow: hidden; 
    position: relative;
    padding: 0;
}

.est-preview-container {
    flex: 1;
    width: 100%;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    box-sizing: border-box; 
    background: rgba(0, 0, 0, 0.3); /* Dark background for slides */
}

/* Slide Wrapper handles the responsive space */
.est-slide-wrapper {
    width: 100%;
    max-width: 800px;
    aspect-ratio: 16 / 9;
    position: relative;
    background: transparent;
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
    flex-shrink: 0;
    cursor: zoom-in; /* Indicate clickable */
    transition: transform 0.2s;
}

.est-slide-wrapper:hover {
    transform: scale(1.02);
    z-index: 10;
}

/* Fullscreen Overlay for Slide Zoom */
.est-slide-zoom-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.9);
    z-index: 50; /* Higher than header and content */
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    border-radius: 18px; /* Match modal border radius */
}

.est-slide-zoom-overlay.show {
    opacity: 1;
    pointer-events: auto;
    visibility: visible;
}

.est-slide-zoom-wrapper {
    width: 100%;
    height: auto;
    max-width: 95%;
    max-height: 95%;
    aspect-ratio: 16 / 9;
    position: relative;
    box-shadow: 0 0 50px rgba(0,0,0,1);
    cursor: zoom-out;
}

/* Re-use content class but ensure it scales correctly inside zoom wrapper */
.est-slide-zoom-wrapper .est-slide-content {
    /* Scale will be handled by JS similar to preview list */
    transform-origin: center center;
    position: absolute; /* Re-added for single mode */
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%); /* Initial center */
}

/* Multi-View Zoom Styles override the absolute positioning */
.est-slide-zoom-wrapper.est-zoom-multi .est-zoom-slide-frame .est-slide-content {
    position: absolute;
    top: 0;
    left: 0;
    transform: none; /* Let JS handle scale */
    transform-origin: 0 0;
}

/* Multi-View Zoom Styles */
.est-slide-zoom-wrapper.est-zoom-multi {
    display: block; /* Let scroll container handle layout */
    padding: 0;
    overflow: hidden; /* Prevent wrapper from scrolling, use inner container */
    height: 100%;
    width: 100%;
    max-width: none;
    max-height: none;
    aspect-ratio: auto;
    cursor: default;
    position: relative; 
}

.est-zoom-scroll-container {
    width: 100%;
    height: 100%;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 60px 40px 100px 40px; /* Equal side padding */
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 40px;
    box-sizing: border-box;
}

.est-zoom-close-btn {
    display: none; /* Hide global close btn */
}

.est-zoom-item-block {
    width: 100%;
    max-width: 1100px;
    display: flex;
    flex-direction: column;
      gap: 12px;
    align-items: center;
    padding: 14px;
    background: #181014;
    border: 1px solid rgba(255, 120, 150, 0.35);
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.45);
    border-radius: 12px;
    box-sizing: border-box;
}

.est-zoom-slide-frame {
    width: 100%;
    position: relative;
    /* Aspect ratio will be maintained by JS height calculation or CSS */
    background: transparent;
    transition: height 0.2s;
}

.est-zoom-slide-frame .est-slide-content {
    position: absolute;
    top: 0;
    left: 0;
    transform-origin: 0 0; /* Scale from top-left for list view */
}

.est-zoom-controls {
    display: flex;
    gap: 10px;
    justify-content: center;
    width: 100%;
    padding: 8px 10px;
    background: #1f1016;
    border: 1px solid rgba(255, 120, 150, 0.25);
    box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.35);
    border-radius: 10px;
    box-sizing: border-box;
}

.est-zoom-controls-top {
    margin-bottom: 4px;
}

.est-zoom-controls-bottom {
    margin-top: 4px;
}

.est-zoom-controls-top .est-btn-action {
    flex: 0 0 auto;
    padding: 0 14px;
    font-size: 14px;
    white-space: nowrap;
}

.est-zoom-controls-bottom .est-btn-action {
    flex: 1 1 0;
    min-width: 0;
    padding: 0 10px;
    font-size: 12px;
    white-space: normal;
    text-align: center;
    line-height: 1.1;
    height: 44px;
}

.est-btn-action {
    height: 40px; /* Explicit height to match other controls */
    padding: 0 16px; /* Adjust padding for flex alignment */
    display: flex;
    align-items: center;
    justify-content: center; /* Center text */
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.25);
    color: #fff;
    border-radius: 8px;
    font-size: 14px;
    cursor: pointer;
    gap: 8px;
    transition: all 0.2s;
    white-space: nowrap;
    flex-shrink: 0;
    box-sizing: border-box; /* Ensure border is included in height */
}

.est-btn-action:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: translateY(-2px);
}

.est-btn-action .icon {
    font-size: 16px;
}

.btn-add-photo {
    border-color: rgba(46, 204, 113, 0.9);
    color: #eafff2;
    background: linear-gradient(180deg, rgba(46, 204, 113, 0.65), rgba(46, 204, 113, 0.35));
}
.btn-add-photo:hover {
    background: linear-gradient(180deg, rgba(46, 204, 113, 0.85), rgba(46, 204, 113, 0.45));
}

.btn-del-photo {
    border-color: rgba(231, 76, 60, 0.9);
    color: #fff0ee;
    background: linear-gradient(180deg, rgba(231, 76, 60, 0.65), rgba(231, 76, 60, 0.35));
}
.btn-del-photo:hover {
    background: linear-gradient(180deg, rgba(231, 76, 60, 0.85), rgba(231, 76, 60, 0.45));
}

.btn-dup-slide {
    border-color: rgba(88, 161, 255, 0.9);
    color: #eef6ff;
    background: linear-gradient(180deg, rgba(88, 161, 255, 0.65), rgba(88, 161, 255, 0.35));
}
.btn-dup-slide:hover {
    background: linear-gradient(180deg, rgba(88, 161, 255, 0.85), rgba(88, 161, 255, 0.45));
}

.btn-del-slide {
    border-color: rgba(231, 76, 60, 0.95);
    color: #fff0ee;
    background: linear-gradient(180deg, rgba(231, 76, 60, 0.7), rgba(231, 76, 60, 0.4));
}
.btn-del-slide:hover {
    background: linear-gradient(180deg, rgba(231, 76, 60, 0.9), rgba(231, 76, 60, 0.5));
}

.btn-close-zoom {
    border-color: rgba(180, 180, 180, 0.7);
    color: #e6e6e6;
    background: linear-gradient(180deg, rgba(140, 140, 140, 0.45), rgba(80, 80, 80, 0.35));
}
.btn-close-zoom:hover {
    background: linear-gradient(180deg, rgba(180, 180, 180, 0.55), rgba(90, 90, 90, 0.45));
}

.est-num-input {
    min-width: 50px;
    width: auto;
    flex-grow: 1;
    height: 40px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    color: #fff;
    text-align: center;
    font-size: 16px;
    font-weight: bold;
    outline: none;
    margin: 0 10px !important; /* Force margin overrides */
    padding: 0 10px;
    box-sizing: border-box; /* Ensure border is included in height */
    appearance: none;
    -webkit-appearance: none;
}

.est-zone-indicator {
    position: absolute;
    border: 2px dashed rgba(255, 255, 255, 0.2);
    box-sizing: border-box;
    display: flex;
    align-items: center;
    justify-content: center;
    color: rgba(255, 255, 255, 0.3);
    font-size: 14px;
    pointer-events: none;
}

.est-placed-photo {
    position: absolute;
    object-fit: contain;
    background: black; /* To hide background if transparent */
    width: 100%;
    height: 100%;
    left: 0;
    top: 0;
}


.est-num-input:focus {
    border-color: #ffd700;
    background: rgba(255, 255, 255, 0.15);
}

/* Photo Upload Modal specific styles */
.est-photo-overlay {
    z-index: 3100; /* Higher than everything else (Edit modal is 3000) */
}

.est-photo-window {
    background: #181014;
    border: 1px solid rgba(255, 120, 150, 0.35);
    max-width: 600px;
    width: 95%;
}

.est-photo-content {
    display: flex;
    flex-direction: column;
    gap: 20px;
    padding: 20px;
    height: auto;
}

.est-photo-preview-area {
    width: 100%;
    aspect-ratio: 16 / 9;
    background: rgba(0, 0, 0, 0.3);
    border: 2px dashed rgba(255, 255, 255, 0.15);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: grab;
    touch-action: none; /* prevent iOS Safari gestures interfering with pointer events */
    -webkit-user-select: none; user-select: none;
    overflow: hidden;
    position: relative;
    transition: border-color 0.2s;
    touch-action: none;
    user-select: none;
    z-index: 1; /* Establish stacking context */
}

.est-nav-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 1000;
    transition: all 0.2s;
    font-size: 20px;
    user-select: none;
    box-shadow: 0 4px 10px rgba(0,0,0,0.3);
}

.est-nav-btn:hover {
    background: rgba(255, 77, 121, 0.8);
    border-color: rgba(255, 255, 255, 0.4);
    transform: translateY(-50%) scale(1.1);
}

.est-nav-btn:active {
    transform: translateY(-50%) scale(0.95);
}

.est-nav-btn.prev { left: 16px; }
.est-nav-btn.next { right: 16px; }

.est-photo-badge {
    position: absolute;
    top: 15px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(20, 10, 15, 0.8);
    color: #ffd700;
    padding: 6px 16px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 600;
    border: 1px solid rgba(255, 215, 0, 0.3);
    z-index: 15;
    pointer-events: none;
    box-shadow: 0 4px 12px rgba(0,0,0,0.4);
    letter-spacing: 0.5px;
}

.est-photo-preview-area:focus {
    outline: none;
    border-color: rgba(255, 120, 150, 0.5);
}

.est-transform-wrapper {
    width: 100%;
    height: 100%;
    position: relative;
    transform-origin: 0 0;
    display: flex;
    align-items: center;
    justify-content: center;
    will-change: transform;
    z-index: 2; /* Lower than nav buttons but managed properly */
}

#estPreviewImg {
    width: 100%;
    height: 100%;
    object-fit: contain;
    pointer-events: none;
}

#estDrawingLayer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow: visible;
    pointer-events: auto; /* Catch all events to manage them reliably */
    z-index: 50; /* Ensure on top */
}

#estDrawingLayer line {
    pointer-events: auto; /* Ensure lines are clickable */
    stroke-linecap: round;
    cursor: pointer;
    transition: stroke-width 0.1s;
}

#estDrawingLayer line:hover {
    stroke-width: 3; /* Hover effect */
}

#estDrawingLayer line.selected {
    filter: drop-shadow(0 0 2px rgba(255,255,255,0.8));
}

.est-arrow-handle {
    pointer-events: auto !important;
    cursor: grab;
    fill: white;
    stroke: #ff0000;
    stroke-width: 1;
    transition: r 0.1s;
}
.est-arrow-handle:hover {
    r: 6;
}
.est-arrow-handle:active {
    cursor: grabbing;
}

.est-upload-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    color: #888;
    font-size: 14px;
    position: absolute;
    z-index: 10;
    pointer-events: auto; /* Enable clicks */
    cursor: pointer;
}

.est-photo-preview-area:hover {
    border-color: rgba(255, 120, 150, 0.5);
    background: rgba(255, 255, 255, 0.02);
}

.est-photo-controls {
    display: flex;
    gap: 10px;
    width: 100%;
    align-items: center;
    flex-wrap: nowrap; /* Prevent wrapping to keep one line */
}

.est-control-separator {
    width: 1px;
    height: 24px;
    background: rgba(255, 255, 255, 0.2);
    margin: 0 5px;
    flex-shrink: 0;
}

.est-btn-icon {
    width: 44px;
    height: 40px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 20px; /* Slightly larger for emoji */
    line-height: 1; /* Fix vertical alignment */
    flex-shrink: 0;
    box-sizing: border-box; 
    padding: 0 0 2px 0; /* Visual tweak to lift emoji slightly */
}

.est-btn-icon:hover {
    background: rgba(255, 255, 255, 0.2);
}

.est-btn-icon.active {
    background: rgba(255, 77, 121, 0.3);
    border-color: #ff4d79;
    box-shadow: 0 0 10px rgba(255, 77, 121, 0.3);
}

.btn-arrow-num {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 2px;
}

.btn-success {
    background: rgba(46, 204, 113, 0.2);
    color: #2ecc71;
    border: 1px solid rgba(46, 204, 113, 0.4);
}
.btn-success:hover {
    background: rgba(46, 204, 113, 0.3);
}
.est-slide-content {
    width: 1280px;
    height: 720px;
    background: white;
    position: absolute;
    top: 0;
    left: 0;
    transform-origin: 0 0;
    /* Transformation will be set via JS */
    overflow: hidden;
    font-family: "Times New Roman", Times, serif;
    color: black;
}

.est-soprovod-slide-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    appearance: none;
    display: block;
}

.est-role-group {
    padding: 8px 10px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.03);
    margin-bottom: 10px;
}

.est-role-title {
    font-weight: 700;
    color: #ffd0dd;
    font-size: 13px;
    margin-bottom: 6px;
}

.est-role-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    justify-content: center;
}

.est-role-item {
    padding: 4px 8px;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.06);
    color: #ddd;
    font-size: 12px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    cursor: pointer;
    transition: background 0.2s;
}

.est-role-item:hover {
    background: rgba(255, 255, 255, 0.15);
}

.est-photo-layer {
    position: absolute;
    inset: 0;
    pointer-events: none;
}

.est-photo-layer img {
    position: absolute;
    object-fit: contain;
    background: transparent;
}

.est-photo-layer svg {
    position: absolute;
    inset: 0;
    overflow: visible;
}

/* Common Text Box Style */
.est-ppt-textbox {
    position: absolute;
    display: flex;
    flex-direction: column;
    justify-content: center;
    line-height: 1.2;
    white-space: pre-wrap;
}

/* Specific Styles matching Python logic */
.est-ppt-title-main {
    text-align: center;
    justify-content: center;
}

.est-ppt-title-footer {
    text-align: left;
    justify-content: flex-start;
}

.est-ppt-item-left {
    text-align: left;
    justify-content: flex-start;
}

.est-ppt-item-right {
    text-align: right;
    justify-content: flex-start;
}

.est-edit-header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(255, 255, 255, 0.05);
}

.est-section-title {
    font-weight: 600;
    color: #fff;
    font-size: 14px;
}

.est-add-btn {
    background: rgba(46, 204, 113, 0.2);
    color: #2ecc71;
    border: 1px solid rgba(46, 204, 113, 0.4);
    border-radius: 6px;
    padding: 4px 10px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
}
.est-add-btn:hover {
    background: rgba(46, 204, 113, 0.3);
}

.est-items-list {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
}

.est-category-group {
    margin-bottom: 20px;
}

.est-category-title {
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #ff7a9a; /* Bright pink */
    font-weight: 800;
    margin-bottom: 10px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    padding-bottom: 6px;
    text-shadow: 0 0 8px rgba(255, 122, 154, 0.3); /* Glow */
    cursor: pointer;
    display: flex;
    justify-content: center; /* Center text */
    align-items: center;
    position: relative; /* For absolute arrow */
}

.est-category-title:hover {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 4px;
}

.est-category-title::after {
    content: "▼";
    font-size: 10px;
    color: #fff;
    transition: transform 0.2s;
    position: absolute;
    right: 6px; /* Stick to right */
}

.est-category-title.collapsed::after {
    transform: rotate(-90deg);
}

.est-category-content.hidden {
    display: none;
}

.est-edit-section {
    margin-bottom: 16px;
}

.est-section-name {
    font-size: 13px;
    color: #aaa;
    text-transform: uppercase;
    font-weight: 700;
    margin-bottom: 6px;
    padding-left: 4px;
    border-left: 3px solid #ff7a9a;
    
    /* Collapsible styles */
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: background 0.2s;
    padding-right: 4px;
}

.est-section-name:hover {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 0 4px 4px 0;
}

.est-section-name::after {
    content: "▼";
    font-size: 9px;
    color: #777;
    transition: transform 0.2s;
}

.est-section-name.collapsed::after {
    transform: rotate(-90deg);
}

.est-section-content.hidden {
    display: none;
}

.est-edit-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.05);
    padding: 8px 10px;
    margin-bottom: 4px;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.2s;
    text-align: left; /* Align text left */
}

.est-edit-item:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 120, 150, 0.3);
}

.est-item-name {
    font-size: 13px;
    color: #fff;
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-right: 10px;
}

.est-item-values {
    display: flex;
    align-items: center;
    gap: 8px;
}

.est-item-coef {
    font-size: 12px;
    color: #aaa;
    font-weight: 600;
    background: rgba(255, 255, 255, 0.1);
    padding: 2px 5px;
    border-radius: 4px;
}

.est-item-count {
    font-size: 13px;
    font-weight: bold;
    color: #ffd700;
    background: rgba(0, 0, 0, 0.3);
    padding: 2px 6px;
    border-radius: 4px;
    min-width: 24px;
    text-align: center;
}

/* =========================================
   ESTIMATES LIST STYLES (Inside A1 Overlay)
   ========================================= */

.est-scroll-container {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    padding-bottom: 100px; /* Space for FAB */
}

.est-group {
    margin-bottom: 24px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
    overflow: hidden;
}

.est-header {
    padding: 12px 16px;
    font-size: 14px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #111; /* Dark text on colored bg */
}

/* Header Colors */
.header-yellow {
    background: rgba(255, 215, 0, 0.85); /* Yellow */
}

.header-orange {
    background: rgba(255, 140, 0, 0.85); /* Orange */
}

.header-green {
    background: rgba(50, 205, 50, 0.85); /* Green */
}

.est-list {
    min-height: 60px;
    padding: 10px;
}

/* --- ESTIMATE CARD (NEW) --- */
.est-card {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    margin-bottom: 10px;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    overflow: hidden;
    box-sizing: border-box;
    width: 100%;
}

/* Header: Date | Event Name */
.est-card-header {
    font-size: 14px;
    font-weight: 600;
    color: #fff;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    padding-bottom: 6px;
    margin-bottom: 2px;
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
    overflow: hidden;
}

.est-date { color: #aaa; font-size: 13px; font-weight: normal; flex-shrink: 0; }
.est-divider { color: #555; flex-shrink: 0; }
.est-event { color: #ffd700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; flex: 1; }

/* Files Row: PPTX + XLSX + Actions */
.est-files-row {
    display: flex;
    gap: 8px;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
}

.est-files-left {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-shrink: 1;
    min-width: 0;
    flex-wrap: wrap;
}

.est-file-link {
    display: flex;
    align-items: center;
    gap: 6px;
    background: rgba(0, 0, 0, 0.3);
    padding: 6px 10px;
    border-radius: 6px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    text-decoration: none;
    color: #eee;
    font-size: 12px;
    transition: all 0.2s;
    white-space: nowrap;
    flex-shrink: 0;
}
.est-file-link:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 120, 150, 0.5);
}

.est-icon-pptx { color: #ff7a9a; font-weight: bold; font-size: 11px; }
.est-icon-xlsx { color: #2ecc71; font-weight: bold; font-size: 11px; }

/* Actions Row (Cross/Check) */
.est-actions {
    display: flex;
    justify-content: flex-end;
    gap: 6px;
    flex-shrink: 0;
    margin-left: auto;
}

.est-act-btn {
    width: 32px;
    height: 32px;
    min-width: 32px;
    min-height: 32px;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    transition: transform 0.1s;
    flex-shrink: 0;
    box-sizing: border-box;
}
.est-act-btn:active { transform: scale(0.9); }

.btn-hide { background: rgba(255, 77, 121, 0.15); color: #ff4d79; border: 1px solid rgba(255, 77, 121, 0.3); }
.btn-approve { background: rgba(46, 204, 113, 0.15); color: #2ecc71; border: 1px solid rgba(46, 204, 113, 0.3); }
.btn-edit { background: rgba(52, 152, 219, 0.15); color: #3498db; border: 1px solid rgba(52, 152, 219, 0.3); }

/* --- READY TREE VIEW --- */
.est-ready-group {
    margin-bottom: 16px;
    width: 100%;
}

.est-ready-title {
    font-size: 14px;
    font-weight: 700;
    color: #ffe3ea;
    padding: 10px 14px;
    border: 1px solid rgba(255, 120, 150, 0.45);
    border-radius: 10px;
    cursor: pointer;
    background: linear-gradient(180deg, rgba(255, 90, 130, 0.18), rgba(24, 16, 20, 0.95));
    box-shadow: 0 6px 14px rgba(0, 0, 0, 0.35);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.est-ready-title::after {
    content: "▾";
    font-size: 12px;
    transition: transform 0.2s;
}

.est-ready-title.collapsed::after {
    transform: rotate(-90deg);
}

.est-ready-content {
    display: block;
    padding: 10px 8px 0 10px;
}

.est-ready-content.hidden {
    display: none;
}

.est-tree-year {
    margin-bottom: 12px;
}
.est-year-title {
    font-size: 16px;
    font-weight: bold;
    color: #aaa;
    padding: 8px 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    margin-bottom: 4px;
    cursor: pointer;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 6px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.est-year-title:hover {
    background: rgba(255, 255, 255, 0.1);
}
.est-year-title::after {
    content: "▼";
    font-size: 10px;
    transition: transform 0.2s;
}
.est-year-title.collapsed::after {
    transform: rotate(-90deg);
}

.est-year-content {
    display: block;
    padding-left: 10px;
}
.est-year-content.hidden {
    display: none;
}

.est-tree-month {
    margin-top: 6px;
    margin-bottom: 6px;
    border-left: 2px solid rgba(255, 255, 255, 0.1);
    padding-left: 12px;
}

.est-month-title {
    font-size: 14px;
    color: #ccc;
    font-weight: 600;
    margin-bottom: 6px;
    text-transform: uppercase;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.est-month-title:hover {
    background: rgba(255, 255, 255, 0.05);
}
.est-month-title::after {
    content: "▼";
    font-size: 9px;
    transition: transform 0.2s;
}
.est-month-title.collapsed::after {
    transform: rotate(-90deg);
}

.est-month-content {
    display: block;
    margin-top: 6px;
}
.est-month-content.hidden {
    display: none;
}

.est-empty {
    text-align: center;
    color: #666;
    font-size: 13px;
    padding: 15px;
    font-style: italic;
}

/* Number Control in Photo Modal */
.est-num-wrapper {
    display: none; /* Hidden by default */
    align-items: center;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    height: 40px;
    margin-left: auto;
    margin-right: 10px;
    overflow: hidden;
    position: relative;
    flex: 1 1 80px;
    min-width: 80px;
}

.est-num-btn {
    width: 32px;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    color: #ffd700;
    font-size: 18px;
    cursor: pointer;
    transition: background 0.2s;
    position: absolute;
    top: 0;
    z-index: 2;
}

.est-num-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

#estNumDec {
    left: 0;
    border-right: 1px solid rgba(255, 255, 255, 0.15);
}

#estNumInc {
    right: 0;
    border-left: 1px solid rgba(255, 255, 255, 0.15);
}

.est-num-input-field {
    width: 100%;
    height: 100%;
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    border-radius: 0 !important;
    color: #fff;
    text-align: center;
    font-size: 16px;
    font-weight: bold;
    outline: none;
    padding: 0 36px;
    margin: 0;
    appearance: textfield;
    -moz-appearance: textfield;
    box-sizing: border-box;
    line-height: 40px;
    position: relative;
    z-index: 1;
    transform: translateY(4px);
}

/* Keep "Готово" pinned to right in photo controls */
.est-photo-controls .btn-success {
    margin-left: auto;
}
.est-num-input-field::-webkit-outer-spin-button,
.est-num-input-field::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

/* Name Input in Photo Modal */
.est-photo-name-panel {
    width: 100%;
    max-width: 400px;
    margin: 2px auto 0 auto;
    padding: 10px;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.14);
    background: rgba(255, 255, 255, 0.05);
    box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.18);
}

.est-photo-name-title {
    font-size: 12px;
    color: #c8c8c8;
    text-align: center;
    margin-bottom: 8px;
    letter-spacing: 0.2px;
}

.est-photo-name-row {
    margin-top: 0;
    width: 100%;
    max-width: 400px;
    margin-left: auto;
    margin-right: auto;
    position: relative;
}

.est-name-input {
    width: 100%;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    color: #fff;
    padding: 10px 14px;
    font-size: 14px;
    outline: none;
    text-align: center;
    transition: all 0.2s;
}

.est-name-input:focus {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 120, 150, 0.5);
    box-shadow: 0 0 10px rgba(255, 120, 150, 0.2);
}

.est-name-input::placeholder {
    color: #888;
}

.est-name-hints {
    position: absolute;
    left: 0;
    right: 0;
    top: calc(100% + 6px);
    max-height: 180px;
    overflow-y: auto;
    background: #22141b;
    border: 1px solid rgba(255, 120, 150, 0.35);
    border-radius: 8px;
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.45);
    z-index: 40;
    display: none;
}

.est-name-hints.up {
    top: auto;
    bottom: calc(100% + 6px);
}

.est-name-hints.show {
    display: block;
}

.est-name-hint-item {
    width: 100%;
    height: 34px;
    border: none;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    background: transparent;
    color: #eee;
    font-size: 13px;
    text-align: left;
    padding: 0 10px;
    cursor: pointer;
}

.est-name-hint-item:last-child {
    border-bottom: none;
}

.est-name-hint-item:hover {
    background: rgba(255, 120, 150, 0.12);
}


/* Filtered Slides Overlay (Soprovod) */
.est-role-filter-overlay {
    position: absolute;
    inset: 0;
    background: #181014;
    z-index: 100;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    pointer-events: none;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.est-role-filter-overlay.show {
    opacity: 1;
    pointer-events: auto;
    visibility: visible;
}

.est-fixed-header {
    height: 60px;
    background: rgba(30, 20, 25, 0.95);
    border-bottom: 1px solid rgba(255, 120, 150, 0.25);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 20px;
    flex-shrink: 0;
    z-index: 10;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

.est-close-all-btn {
    background: linear-gradient(180deg, rgba(231, 76, 60, 0.2), rgba(231, 76, 60, 0.1));
    border: 1px solid rgba(231, 76, 60, 0.4);
    color: #ffcccb;
    padding: 8px 24px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 8px;
}

.est-close-all-btn:hover {
    background: rgba(231, 76, 60, 0.3);
    transform: translateY(-1px);
}

.est-filtered-scroll-area {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 40px;
}

.est-filtered-slide-item {
    width: 100%;
    max-width: 900px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: rgba(255, 255, 255, 0.02);
    padding: 12px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.est-filtered-slide-view {
    width: 100%;
    aspect-ratio: 16 / 9;
    background: #000;
    border-radius: 8px;
    overflow: hidden;
    position: relative;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.est-slide-controls {
    display: flex;
    justify-content: center;
    gap: 12px;
    padding-top: 4px;
}

.est-slide-btn {
    height: 36px;
    padding: 0 16px;
    border-radius: 6px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    background: rgba(255, 255, 255, 0.05);
    color: #ddd;
    font-size: 13px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s;
}

.est-slide-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: translateY(-1px);
}

.est-slide-btn.btn-add {
    border-color: rgba(46, 204, 113, 0.4);
    color: #a8e6cf;
    background: rgba(46, 204, 113, 0.1);
}
.est-slide-btn.btn-add:hover {
    background: rgba(46, 204, 113, 0.2);
}

.est-slide-btn.btn-del {
    border-color: rgba(231, 76, 60, 0.4);
    color: #ffcccb;
    background: rgba(231, 76, 60, 0.1);
}
.est-slide-btn.btn-del:hover {
    background: rgba(231, 76, 60, 0.2);
}

.est-slide-btn.btn-close-slide {
    border-color: rgba(255, 255, 255, 0.15);
    color: #aaa;
}
.est-slide-btn.btn-close-slide:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
}

.est-slide-number {
    position: absolute;
    bottom: 10px;
    right: 10px;
    background: rgba(0, 0, 0, 0.6);
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    pointer-events: none;
    z-index: 20;
}
