
/* Dark theme (default) */
:root { --bg:#0b0b0b; --fg:#ddd; --muted:#aaa; --panel:#141414; --accent:#3b82f6; --green:#22c55e; --border:#2a2a2a; --drag:#2563eb; }

/* Light theme */
[data-theme="light"] {
  --bg: #ffffff;
  --fg: #1f2937;
  --muted: #6b7280;
  --panel: #f9fafb;
  --accent: #3b82f6;
  --green: #059669;
  --border: #09090a;
  --drag: #2563eb;
}

/* Ocean Blue theme */
[data-theme="blue"] {
  --bg: #0c1826;
  --fg: #e0f2fe;
  --muted: #90caf9;
  --panel: #1e3a52;
  --accent: #03a9f4;
  --green: #4caf50;
  --border: #37474f;
  --drag: #0288d1;
}

/* Forest Green theme */
[data-theme="green"] {
  --bg: #0d1b0d;
  --fg: #e8f5e8;
  --muted: #a5d6a7;
  --panel: #1b2f1b;
  --accent: #4caf50;
  --green: #66bb6a;
  --border: #2e7d2e;
  --drag: #388e3c;
}

/* Deep Purple theme */
[data-theme="purple"] {
  --bg: #1a0d1a;
  --fg: #f3e5f5;
  --muted: #ce93d8;
  --panel: #2d1b2d;
  --accent: #9c27b0;
  --green: #ab47bc;
  --border: #4a148c;
  --drag: #7b1fa2;
}

/* Sunset Orange theme */
[data-theme="sunset"] {
  --bg: #2d1810;
  --fg: #fff3cd;
  --muted: #ffb347;
  --panel: #4a2c17;
  --accent: #ff6b35;
  --green: #ff8c42;
  --border: #d2691e;
  --drag: #ff4500;
}

/* Light theme overrides - backgrounds and dark button fixes */
[data-theme="light"] .app-header {
  background: #f8fafc;
  border-bottom-color: var(--border);
}

[data-theme="light"] .overlay {
  background: rgba(0, 0, 0, 0.85);
}

[data-theme="light"] .sheet,
[data-theme="light"] .card {
  background: #ffffff;
  border-color: var(--border);
}


[data-theme="light"] .input {
  background: #ffffff;
  border-color: var(--border);
}

/* Fix dark buttons in light theme - make them lighter and readable */
[data-theme="light"] .btn:not(.btn-blue):not(.btn-red):not(.btn-green):not(#btn-notes) {
  background: #f3f4f6;
  color: #374151;
  border-color: #d1d5db;
}

[data-theme="light"] .btn:not(.btn-blue):not(.btn-red):not(.btn-green):not(#btn-notes):hover {
  background: #e5e7eb;
  border-color: #9ca3af;
}

/* Fix unselected report IDs background and text for light theme */
[data-theme="light"] .child-report-btn {
  background: #ffffff;
  color: #1f2937;
  border-color: #d1d5db;
}


/* Notes button blue styling in light theme */
[data-theme="light"] #btn-notes {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

[data-theme="light"] #btn-notes:hover {
  background: #2563eb;
  border-color: #2563eb;
}

/* Fix notes textarea in light theme */
[data-theme="light"] .notes textarea {
  background: #f9fafb;
  color: #1f2937;
  border-color: var(--border);
}

/* Compact button style for emoji-only buttons */
.btn-compact {
  min-width: 48px !important;
  padding: 12px !important;
  width: auto !important;
}

[data-theme="light"] .bar {
  border-color: var(--border);
}

[data-theme="light"] .storage-bar {
  background: #f3f4f6;
  border: 1px solid #000;
}

/* Fix report name input visibility in light theme */
[data-theme="light"] .report-name-input {
  background: #ffffff;
  color: #1f2937;
  border-color: var(--accent);
}

/* Fix dashed toggle visibility in light theme */
[data-theme="light"] #dashed-toggle.active {
  background: #3b82f6 !important;
  color: white !important;
  border-color: #3b82f6 !important;
}

/* Forest Green theme - Brown header like tree trunk */
[data-theme="green"] .app-header {
  background: #4a3728;
  border-bottom-color: #5d4037;
}

[data-theme="green"] .btn:not(.btn-blue):not(.btn-red):not(.btn-green):not(#btn-notes):not(#btn-locate) {
  background: #2d4a2d;
  color: #e8f5e8;
  border-color: #4caf50;
}

[data-theme="green"] .btn:not(.btn-blue):not(.btn-red):not(.btn-green):not(#btn-notes):not(#btn-locate):hover {
  background: #388e3c;
  border-color: #66bb6a;
}

[data-theme="green"] #btn-close,
[data-theme="green"] #btn-clear,
[data-theme="green"] #btn-undo,
[data-theme="green"] #btn-redo,
[data-theme="green"] #btn-note-close,
[data-theme="green"] #settings-close,
[data-theme="green"] #floorplans-close {
  background: #2d4a2d;
  color: #e8f5e8;
  border-color: #4caf50;
}

[data-theme="green"] #btn-close:hover,
[data-theme="green"] #btn-clear:hover,
[data-theme="green"] #btn-undo:hover,
[data-theme="green"] #btn-redo:hover,
[data-theme="green"] #btn-note-close:hover,
[data-theme="green"] #settings-close:hover,
[data-theme="green"] #floorplans-close:hover {
  background: #388e3c;
  border-color: #66bb6a;
}


[data-theme="green"] .overlay {
  background: rgba(0, 0, 0, 0.8);
}

[data-theme="green"] .sheet,
[data-theme="green"] .card {
  background: #1a2e1a;
  border-color: #5d4037;
}

[data-theme="green"] #dashed-toggle.active {
  background: #4caf50 !important;
  color: white !important;
  border-color: #4caf50 !important;
}

/* Deep Purple theme - Enhanced purple elements */
[data-theme="purple"] .app-header {
  background: #2d0a4e;
  border-bottom-color: #4a148c;
}

[data-theme="purple"] #btn-notes {
  background: #8e24aa;
  color: white;
  border-color: #8e24aa;
}

[data-theme="purple"] #btn-notes:hover {
  background: #7b1fa2;
  border-color: #7b1fa2;
}

[data-theme="purple"] #btn-locate {
  background: #8e24aa;
  color: white;
  border-color: #8e24aa;
}

[data-theme="purple"] #btn-locate:hover {
  background: #7b1fa2;
  border-color: #7b1fa2;
}

[data-theme="purple"] .floorplans-archivum-sheet,
[data-theme="purple"] .floorplans-archivum-content {
  background: #2d1b2d;
  border-color: #4a148c;
}

[data-theme="purple"] .storage-bar {
  background: #1a0d1a;
}

/* Sunset Orange theme - Enhanced sunset elements */
[data-theme="sunset"] .app-header {
  background: #cc5500;
  border-bottom-color: #ff6b35;
}

[data-theme="sunset"] #btn-notes {
  background: #ff6b35;
  color: white;
  border-color: #ff6b35;
}

[data-theme="sunset"] #btn-notes:hover {
  background: #ff4500;
  border-color: #ff4500;
}

[data-theme="sunset"] #btn-locate {
  background: #ff6b35;
  color: white;
  border-color: #ff6b35;
}

[data-theme="sunset"] #btn-locate:hover {
  background: #ff4500;
  border-color: #ff4500;
}

[data-theme="sunset"] .btn:not(.btn-blue):not(.btn-red):not(.btn-green):not(#btn-notes):not(#btn-locate) {
  background: #b8860b;
  color: #2d1810;
  border-color: #daa520;
}

[data-theme="sunset"] .btn:not(.btn-blue):not(.btn-red):not(.btn-green):not(#btn-notes):not(#btn-locate):hover {
  background: #daa520;
  border-color: #ffd700;
}

[data-theme="sunset"] #sig-save {
  background: #ffd700;
  color: #2d1810;
  border-color: #ffd700;
}

[data-theme="sunset"] #sig-save:hover {
  background: #ffed4e;
  border-color: #ffed4e;
}

[data-theme="sunset"] .storage-bar {
  background: #2d1810;
}

[data-theme="sunset"] #btn-sign.btn-green {
  background: #dc2626;
  color: white;
  border-color: #dc2626;
}

[data-theme="sunset"] #btn-sign.btn-green:hover {
  background: #b91c1c;
  border-color: #b91c1c;
}

[data-theme="sunset"] #dashed-toggle.active {
  background: #ff6b35 !important;
  color: white !important;
  border-color: #ff6b35 !important;
}
* { box-sizing:border-box; }
html,body { 
  margin:0; height:100%; background:var(--bg); color:var(--fg); 
  font-family:system-ui,Segoe UI,Roboto,Arial; 
  -webkit-tap-highlight-color: transparent;
  /* Disable iOS text selection and callouts on non-input elements */
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  /* Allow pan but prevent zoom */
  touch-action: pan-x pan-y;
  /* Disable overscroll bounce */
  overscroll-behavior: none;
}

/* PWA enhancements for full-screen launch */
.pwa-mode {
  /* Use dynamic viewport height to handle iOS safe areas */
  min-height: 100vh;
  min-height: calc(var(--vh, 1vh) * 100);
}

.pwa-mode html,
.pwa-mode body {
  /* Enhanced PWA experience with proper viewport handling */
  height: 100vh;
  height: calc(var(--vh, 1vh) * 100);
  overflow-x: hidden;
}

/* === annotation editor modal lock: prevent background scrolling === */
.annotation-editor-open {
  overflow: hidden !important;
  position: fixed !important;
  width: 100% !important;
  height: 100% !important;
}
.annotation-editor-open .wrap,
.annotation-editor-open #board,
.annotation-editor-open .tile.card {
  touch-action: none !important;
  pointer-events: none !important;
  user-select: none !important;
  -webkit-user-select: none !important;
}

/* iOS PWA status bar spacing */
.pwa-mode .app-header {
  padding-top: calc(10px + var(--status-bar-height, 0px));
}
.app-header { display:flex; align-items:center; justify-content:space-between; padding:10px 14px; border-bottom:1px solid var(--border); background:#0e0e0e; position:sticky; top:0; z-index:10; }
.app-header .title { font-weight:700; }
.app-header .meta { opacity:.7; font-size:12px; }
.actions { display:flex; gap:8px; }
.btn { background:#1a1a1a; color:var(--fg); border:1px solid var(--border); border-radius:8px; padding:12px 16px; cursor:pointer; min-width:48px; min-height:48px; font-size:16px; }
.btn:hover { border-color:#3a3a3a; }
.btn-blue { background:var(--accent); color:white; border-color:transparent; }
.btn-green { background:var(--green); color:black; border-color:transparent; }
.btn-red { background:#dc2626; color:white; border-color:transparent; font-size:16px; padding:12px 16px; }
.wrap { padding:16px; }
.board-wrap { border:1px solid var(--border); border-radius:12px; padding:10px; min-height:260px; }

.add-tile { display:grid; align-content:center; justify-items:center; gap:6px; border:2px dashed var(--border); border-radius:12px; padding:24px; color:var(--muted); cursor:pointer; margin-bottom:12px;}
.add-tile .plus { font-size:32px; }
.hint { opacity:.7; font-size:12px; }
.small { font-size:12px; opacity:.75; }

.board { display:grid; grid-template-columns:repeat(auto-fill, minmax(180px,1fr)); gap:8px; }
.tile.card { background:var(--panel); border:1px solid var(--border); border-radius:10px; overflow:hidden; position:relative; touch-action:auto; height:200px; -webkit-touch-callout:none; -webkit-user-select:none; }

/* iOS drag prevention for all draggable elements - but allow full touch interaction */
[draggable="true"], .draggable {
  -webkit-touch-callout: none !important;
  -webkit-user-select: none !important;
  -webkit-user-drag: element !important;
  touch-action: auto !important; /* Allow all touch interactions for drag */
  user-select: none !important;
}

/* Allow text selection only in input fields and textareas */
input, textarea, [contenteditable="true"] {
  -webkit-user-select: text !important;
  -webkit-touch-callout: default !important;
  user-select: text !important;
  touch-action: manipulation !important;
}

/* Disable image drag and selection effects */
img {
  -webkit-user-drag: none;
  -webkit-touch-callout: none;
  user-select: none;
  pointer-events: none;
}

/* Disable text selection on buttons and UI elements */
.btn, .tile, .card, .tool, .modal {
  -webkit-user-select: none !important;
  -webkit-touch-callout: none !important;
  user-select: none !important;
}

/* Prevent long-press context menus on interactive elements */
.btn, .tile.card, [data-tool], canvas {
  -webkit-touch-callout: none !important;
  -webkit-user-select: none !important;
}
.tile.card img { width:100%; height:200px; object-fit:contain; display:block; user-select:none; -webkit-user-drag:none; background:#000; -webkit-touch-callout:none; pointer-events:none; }
.tile.card.note-tile { display:flex; flex-direction:column; }
.tile.card.note-tile .note-icon { height:140px; flex-shrink:0; }
.tile.card.note-tile .note-label { height:60px; max-height:60px; overflow:hidden; line-height:1.2; flex-shrink:0; }
.tile.card .del { position:absolute; top:6px; right:6px; width:26px; height:26px; border-radius:50%; background:#7f1d1d; color:#fff; border:none; cursor:pointer; font-weight:700; line-height:26px; text-align:center; }
/* Legacy del class - replaced by card-delete in new layout */
.tile.placeholder { border:2px dashed var(--drag); border-radius:10px; min-height:100px; background:transparent; }
.board.dragging { outline:none; }
.tile.card.dragging { opacity:.4; }
.tile.card.drop-before { border-left:4px solid var(--accent); background:rgba(59, 130, 246, 0.1); }
.tile.card.drop-after { border-right:4px solid var(--accent); background:rgba(59, 130, 246, 0.1); }
.tile.card.swap-target { border:2px dashed var(--accent); background:rgba(59, 130, 246, 0.1); }
.tile.card.swap-target::before {
  content: '⟷ ⟷ ⟷';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 60px;
  color: #dc2626;
  font-weight: bold;
  text-shadow: 2px 2px 4px rgba(0,0,0,0.8);
  pointer-events: none;
  z-index: 6;
  line-height: 0.7;
  white-space: pre-line;
  text-align: center;
}
.tile.card.swap-target::after {
  content: '';
  pointer-events: none;
}

.modal { position:fixed; inset:0; display:grid; place-items:center; background:rgba(0,0,0,.6); z-index:10000; }
.modal[hidden] { display:none; }
.card { background:#121212; border:1px solid var(--border); border-radius:12px; box-shadow:0 10px 30px rgba(0,0,0,.4); }
.editor-grid { width:min(1325px,98vw); display:grid; grid-template-rows:auto 1fr; }
.toolbar { display:flex; justify-content:space-between; align-items:center; gap:10px; padding:8px; border-bottom:1px solid var(--border); flex-wrap:wrap; }
.toolbar.thin .left, .toolbar.thin .right { display:flex; align-items:center; gap:10px; flex-wrap:wrap; }
.tools .tool.active { outline:2px solid var(--accent); background:rgba(59, 130, 246, 0.2); }
/* Floor plan tool active styling - universal across all themes */
button[data-floor-tool].active,
.btn[data-floor-tool].active,
.tool[data-floor-tool].active { 
  outline: 3px solid #dc2626 !important; 
  background: rgba(220, 38, 38, 0.4) !important; 
  box-shadow: 0 0 12px rgba(220, 38, 38, 0.6) !important;
  border: 2px solid #dc2626 !important;
}
.size { display:flex; align-items:center; gap:8px; }
.size input { accent-color: var(--accent); }
.swatches { display:flex; gap:8px; }
.swatch { width:28px; height:28px; border-radius:6px; border:2px solid #0007; cursor:pointer; }
.swatch[data-color="#FF3B30"] { background:#FF3B30; }
.swatch[data-color="#FFF200"] { background:#FFF200; }
.swatch[data-color="#3FB7FF"] { background:#3FB7FF; }

.shape-controls { display:flex; align-items:center; gap:12px; }
.shape-types { display:flex; gap:6px; }
.shape-btn { width:36px; height:36px; padding:0; font-size:18px; display:flex; align-items:center; justify-content:center; }
.shape-btn.active { outline:2px solid var(--accent); background:rgba(59, 130, 246, 0.2); }
#dashed-toggle { font-size:12px; padding:8px 12px; min-width:auto; min-height:auto; }
#dashed-toggle.active { background:var(--accent); color:white; }

.stage-wrap { display:grid; grid-template-columns:1fr 340px; gap:10px; padding:10px; }
.stage { position:relative; background:#000; border:1px solid var(--border); border-radius:8px; overflow:hidden; height:650px; width:calc(100% - 20px); }
.stage canvas { position:absolute; left:0; top:0; width:100%; height:100%; touch-action:none; }
#base-canvas { z-index:1; }
#hi-canvas { z-index:2; }
#ink-canvas { z-index:3; }
#overlay-canvas { z-index:4; pointer-events:none; }
.txt-layer { position:absolute; inset:0; z-index:5; pointer-events:none; }
.textbox { position:absolute; min-width:160px; max-width:90%; min-height:40px; height:auto; color:#000; background:rgba(229,57,53,.85); border-radius:6px; padding:10px 12px; pointer-events:auto; font-size:24px; line-height:1.35; white-space:pre-wrap; word-wrap:break-word; }
.textbox[contenteditable="true"] { outline:none; }
.textbox::selection { background:#222; color:#fff; }

.notes textarea { width:100%; height:100%; min-height:650px; background:#0c0c0c; color:var(--fg); border:1px solid var(--border); border-radius:8px; padding:8px; }

.overlay { position:fixed; inset:0; display:grid; place-items:center; background:rgba(0,0,0,.8); z-index:9999; }
.overlay[hidden] { display:none; }
.sheet { width:min(980px,95vw); background:#121212; border:1px solid var(--border); border-radius:12px; padding:8px; }
.sheet.small { width:min(640px,95vw); }
.bar { display:flex; align-items:center; justify-content:space-between; padding:8px; border-bottom:1px solid var(--border); }
.footer-actions { border-top:1px solid var(--border); border-bottom:none; }
.grid2 { display:grid; grid-template-columns:1fr 1fr; gap:10px; padding:8px; }
.input { width:100%; background:#0c0c0c; color:var(--fg); border:1px solid var(--border); border-radius:8px; padding:8px; }

.libgrid { display:grid; grid-template-columns:300px 1fr; gap:12px; min-height:360px; padding:10px; }
.jobs-pane { border-right:1px solid var(--border); padding-right:10px; display:grid; gap:10px; align-content:start; }
.report-name-item { margin-bottom:8px; }
.report-name-btn { background:#dc2626; color:white; border:2px solid #dc2626; border-radius:6px; padding:6px 10px; cursor:pointer; font-size:12px; width:80%; max-width:80%; text-align:center; margin:0 auto; margin-top:-8px; font-weight:600; min-height:32px; display:-webkit-box; -webkit-box-orient:vertical; -webkit-line-clamp:3; overflow:hidden; word-break:break-word; hyphens:auto; -webkit-hyphens:auto; -ms-hyphens:auto; overflow-wrap:break-word; position:relative; z-index:2; border-top-left-radius:0px; border-top-right-radius:0px; }
.report-name-btn:hover { background:#b91c1c; border-color:#b91c1c; }
.report-name-btn.editing { background:#1a1a1a; color:var(--fg); border:2px solid var(--accent); }
.report-name-input { background:#1a1a1a; color:var(--fg); border:2px solid var(--accent); border-radius:8px; padding:12px 16px; font-size:16px; width:100%; font-weight:600; }
.report-name-item { display: flex; flex-direction: column-reverse; }
.child-reports { margin-left:0px; margin-top:0px; margin-bottom:8px; }
.child-reports .child-report-btn { margin-left:0px; }
.report-name-item > div:first-child { margin-left:20px; margin-top:0px; }
.child-report-btn { background:#1a1a1a; color:var(--fg); border:2px solid var(--border); border-radius:8px; padding:12px 16px; cursor:pointer; font-size:17px; width:100%; text-align:left; margin-bottom:4px; font-weight:600; min-height:50px; }
.child-report-btn.current { background:var(--accent); color:white; border-color:transparent; }
.child-report-btn.drop-target { border:2px dashed var(--accent); background:rgba(59, 130, 246, 0.1); }
.action-buttons { display:flex; flex-direction:column; gap:8px; }
.pane-title { font-weight:700; }
.jobs-list { display:grid; gap:6px; }
.cards-pane { display:grid; gap:10px; align-content:start; }
.cards-header { display:flex; align-items:center; justify-content:space-between; }
.storage-indicator { display:flex; flex-direction:column; gap:4px; font-size:12px; min-width: 100px; }
.storage-bar { width:120px; height:4px; background:var(--border); border-radius:2px; overflow:hidden; }
.storage-fill { height:100%; background:var(--green); transition:width 0.3s ease; }
.storage-fill.warning { background:#f59e0b; }
.storage-fill.critical { background:#dc2626; }
.cards-bucket { display:flex; flex-wrap:wrap; gap:8px; min-height:120px; border:1px dashed var(--border); border-radius:12px; padding:8px; }
.cards-bucket.dragging { outline:none; }
.thumb { width:140px; height:140px; max-height:140px; border:1px solid var(--border); border-radius:8px; overflow:hidden; display:flex; flex-direction:column; padding:4px; background:#111; color:#ddd; position:relative; }
.thumb img { flex:1; object-fit:contain; background:#000; }
.thumb .note-thumb-content { flex:1; display:flex; flex-direction:column; }
.thumb .note-thumb-icon { flex:1; }
.thumb .note-thumb-label { height:20px; max-height:20px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }

/* Delete button styling for thumb cards (favicon red X design) */
.thumb .card-delete {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 24px;
  height: 24px;
  background: #dc2626;
  color: white;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.9;
  transition: all 0.2s ease;
  z-index: 10;
}

.thumb .card-delete:hover {
  opacity: 1;
  background: #b91c1c;
  transform: scale(1.1);
}

.thumb.dragging { opacity:.4; }
.thumb.drop-target { border:2px dashed var(--accent); background:rgba(59, 130, 246, 0.1); }
.thumb.swap-target { border:2px dashed var(--accent); background:rgba(59, 130, 246, 0.1); }
.thumb.swap-target::before {
  content: '⟷ ⟷ ⟷';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 45px;
  color: #dc2626;
  font-weight: bold;
  text-shadow: 2px 2px 4px rgba(0,0,0,0.8);
  pointer-events: none;
  z-index: 6;
  line-height: 0.7;
  white-space: pre-line;
  text-align: center;
}
.thumb.swap-target::after {
  content: '';
  pointer-events: none;
}
.thumb.placeholder { border:2px dashed var(--drag); min-height:80px; }

/* Red arrows overlay for reports library buttons */
.child-report-btn.swap-target::after {
  content: '⟷ ⟷ ⟷';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 45px;
  color: #dc2626;
  font-weight: bold;
  text-shadow: 2px 2px 4px rgba(0,0,0,0.8);
  pointer-events: none;
  z-index: 6;
  line-height: 0.7;
  white-space: pre-line;
  text-align: center;
}

/* PDF Cards */
.pdf-section { margin-top:24px; border-top:1px solid var(--border); padding-top:16px; }
.pdf-bucket { display:flex; flex-direction:column; gap:8px; min-height:60px; }
.pdf-empty { color:var(--muted); font-size:14px; text-align:center; padding:20px; }
.pdf-card { display:flex; align-items:center; gap:12px; background:#0f1419; border:2px solid #e74c3c; border-radius:12px; padding:12px; cursor:pointer; transition:all 0.2s; position:relative; }
.pdf-card:hover { background:#141a20; border-color:#c0392b; transform:translateY(-1px); }
.pdf-card, .pdf-card * { opacity: 1 !important; }
.pdf-icon { font-size:24px; flex-shrink:0; background:linear-gradient(135deg, #e74c3c, #c0392b); -webkit-background-clip:text; -webkit-text-fill-color:transparent; background-clip:text; }
.pdf-info { flex:1; min-width:0; }
.pdf-name { font-weight:600; color:#e74c3c; margin-bottom:4px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; max-width:calc(100% - 70px); }
.pdf-meta { font-size:12px; color:var(--muted); }
.pdf-delete { position:absolute; top:8px; right:8px; width:24px; height:24px; border-radius:50%; background:#7f1d1d; color:#fff; border:none; cursor:pointer; font-weight:700; line-height:24px; text-align:center; font-size:14px; }
.pdf-delete:hover { background:#991b1b; }

/* Floor Plan Viewer */
.floorplan-upload-area { margin-bottom:16px; }
.floorplan-upload-cta { display:grid; align-content:center; justify-items:center; gap:4px; border:2px dashed var(--border); border-radius:8px; padding:12px; color:var(--muted); cursor:pointer; transition:all 0.2s; text-align:center; }
.floorplan-upload-cta:hover { border-color:var(--accent); color:var(--accent); }
.upload-icon { font-size:24px; }
.upload-text { font-weight:600; font-size:14px; }
.upload-hint { font-size:11px; opacity:0.7; }
.floorplan-cards-bucket { display:flex; flex-wrap:wrap; gap:8px; min-height:120px; margin-bottom:16px; }
.floorplan-card { width:140px; height:160px; max-height:160px; border:1px solid var(--border); border-radius:8px; overflow:hidden; display:flex; flex-direction:column; padding:4px; background:#111; color:#ddd; position:relative; cursor:pointer; transition:all 0.2s; }
.floorplan-card:hover { border-color:var(--accent); }
.floorplan-card-preview { flex:1; overflow:hidden; display:flex; align-items:center; justify-content:center; color:var(--muted); background:#000; border-radius:4px; margin-bottom:4px; }
.floorplan-card-preview img { width:100%; height:100%; object-fit:cover; }
.floorplan-card-title { height:16px; max-height:16px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; font-size:11px; font-weight:600; color:var(--fg); }
.floorplan-card-meta { height:14px; max-height:14px; overflow:hidden; font-size:10px; color:var(--muted); }
.floorplan-card-badge { position:absolute; top:6px; left:6px; background:var(--accent); color:white; font-size:9px; padding:1px 4px; border-radius:3px; font-weight:600; }
.floorplan-card-delete { position:absolute; top:4px; right:4px; width:20px; height:20px; border-radius:50%; background:#7f1d1d; color:#fff; border:none; cursor:pointer; font-weight:700; line-height:20px; text-align:center; font-size:12px; }
.floorplan-card-delete:hover { background:#991b1b; }

/* Floor Plan Viewer Modal */
.floorplan-viewer-grid { width:min(1056px,95vw); display:grid; grid-template-rows:auto 1fr; max-height:90vh; }
.floor-viewer-content { display:grid; grid-template-columns:1fr 240px; gap:8px; padding:8px; min-height:600px; }
.floor-viewer-main { display:flex; flex-direction:column; }
.floor-canvas-container { position:relative; flex:1; background:#000; border:1px solid var(--border); border-radius:8px; overflow:hidden; min-height:200px; }
.floor-canvas-container canvas { position:absolute; top:0; left:0; width:100%; height:100%; cursor:grab; }
.floor-canvas-container canvas:active { cursor:grabbing; }
.floor-pins-layer { position:absolute; top:0; left:0; width:100%; height:100%; pointer-events:none; overflow:visible; }
.floor-pins-layer .pin { pointer-events:auto; cursor:pointer; }
.floor-pins-layer .pin:hover { filter:brightness(1.2); }

/* Plan Navigation */
.plan-navigation { display:flex; align-items:center; gap:8px; }
.plan-counter { padding:8px 12px; background:var(--panel); border:1px solid var(--border); border-radius:6px; font-size:14px; font-weight:600; min-width:80px; text-align:center; }
.plan-tools { display:flex; align-items:center; gap:8px; margin-left:16px; }
.plan-badge { padding:4px 8px; background:var(--accent); color:white; border-radius:4px; font-size:12px; font-weight:600; margin-left:16px; }

/* Card Tray */
.floor-card-tray { display:flex; flex-direction:column; border-left:1px solid var(--border); padding-left:10px; }
.card-tray-header { margin-bottom:12px; }
.tray-hint { font-size:12px; color:var(--muted); margin-top:4px; }
.floor-card-tray-content { display:grid; grid-template-columns:1fr 1fr; gap:8px; max-height:500px; overflow-y:auto; overflow-x:visible; padding:4px; align-content:start; }
.floor-card-tray-content.compact-3,
.floor-card-tray-content.compact-4 { 
  align-content: start; /* Collapse cards toward top instead of stretching */
  gap:4px; /* Smaller gap for both rows and columns */
}
/* Size reduction only for 9+ cards */
.floor-card-tray-content.compact-9 .tray-card { 
  height:100px; /* Reduced from 140px but maintains proportions */
  padding:6px; /* Reduced from 10px */
}
.floor-card-tray-content.compact-9 .tray-card-image { 
  height:70px; /* Reduced from 100px but maintains proportions */
  margin-bottom:4px; /* Reduced from 6px */
}

/* Hide scrollbars for floor plan card tray */
.floor-card-tray-content::-webkit-scrollbar {
  width: 0px;
  background: transparent;
}
.floor-card-tray-content::-webkit-scrollbar-thumb {
  background: transparent;
}
.tray-card { display:flex; flex-direction:column; height:140px; width:100%; padding:10px; background:var(--panel); border:1px solid var(--border); border-radius:8px; cursor:pointer; transition:all 0.2s; }
.tray-card:hover { border-color:var(--accent); transform:translateY(-1px); }
.tray-card.danger-highlight { border-color:#dc2626 !important; background:rgba(220, 38, 38, 0.15) !important; animation:pulse-border 2s infinite !important; }
.tray-card-image { width:100%; height:100px; background:#000; border-radius:8px; overflow:hidden; position:relative; margin-bottom:6px; }
.tray-card-image.has-pin { overflow:visible; /* Allow pin icons to extend above card */ }
.tray-card.has-pin-card { overflow:visible; /* Allow pin icons to extend beyond card boundaries */ }
.tray-card-image img { width:100%; height:100%; object-fit:cover; border-radius:8px; }
.tray-card-info { display:flex; flex-direction:column; align-items:center; text-align:center; }
.tray-card-title { display:none; }
.tray-card-meta { font-size:11px; font-weight:600; color:var(--muted); text-transform:uppercase; letter-spacing:0.5px; }
.tray-card-linked { opacity:1; cursor:pointer; }
.tray-card-linked:hover { border-color:var(--accent); }
.pin-indicator { position: absolute; top: 55%; left: 50%; transform: translate(-50%, -55%); z-index: 10; pointer-events: none; 
  /* Ensure pin is properly sized - updated for 1.2x scale */
  width: 35px; height: 46px;
}

@keyframes pulse-border {
  0%, 100% { border-color:#dc2626 !important; }
  50% { border-color:#f87171 !important; }
}

/* Pin Popover */
.pin-popover { position:absolute; z-index:20000; background:var(--panel); border:1px solid var(--border); border-radius:8px; box-shadow:0 4px 12px rgba(0,0,0,0.4); min-width:300px; max-width:400px; }
.pin-popover-content { padding:12px; }
.pin-popover-header { display:flex; align-items:center; justify-content:space-between; margin-bottom:8px; }
.pin-popover-close { width:20px; height:20px; background:#dc2626; color:white; border:none; border-radius:50%; cursor:pointer; font-size:12px; line-height:1; display:flex; align-items:center; justify-content:center; opacity:0.9; transition:all 0.2s ease; flex-shrink:0; }
.pin-popover-close:hover { opacity:1; background:#b91c1c; transform:scale(1.1); }
.pin-color-chip { width:16px; height:16px; border-radius:50%; border:2px solid #000; flex-shrink:0; }
.pin-popover-title { font-weight:600; font-size:14px; }
.pin-popover-main { margin-bottom:8px; }
.pin-popover-card-preview { display:flex; gap:8px; margin-bottom:8px; padding:8px; background:var(--bg); border:1px solid var(--border); border-radius:6px; }
.pin-popover-card-image { width:50px; height:50px; background:#000; border-radius:4px; overflow:hidden; flex-shrink:0; }
.pin-popover-card-image img { width:100%; height:100%; object-fit:cover; }
.pin-popover-card-info { flex:1; min-width:0; }
.pin-popover-card-name { font-weight:600; font-size:12px; margin-bottom:2px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.pin-popover-card-type { font-size:10px; color:var(--muted); }
.pin-popover-body { font-size:12px; }
.pin-popover-actions { display:flex; gap:6px; }
.pin-popover-actions .btn { padding:6px 10px; font-size:12px; min-height:auto; min-width:auto; }

/* PDF Viewer Modal */
.pdf-viewer-container { width:90vw; height:85vh; max-width:1000px; max-height:700px; background:var(--card); border:1px solid var(--border); border-radius:12px; display:flex; flex-direction:column; overflow:hidden; margin:auto; }
.pdf-viewer-header { display:flex; justify-content:space-between; align-items:center; padding:16px; border-bottom:1px solid var(--border); background:#0a0f1a; }
.pdf-viewer-title { font-weight:600; color:#e74c3c; flex:1; min-width:0; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.pdf-viewer-controls { display:flex; gap:8px; flex-shrink:0; }
.pdf-viewer-content { 
  flex:1; 
  padding:4px; 
  overflow:auto; 
  -webkit-overflow-scrolling:touch;
  /* Enhanced iOS scrolling support */
  position:relative;
  height:100%;
  -webkit-transform:translateZ(0);
  transform:translateZ(0);
}
.pdf-viewer-content iframe { 
  width:100%; 
  height:100%; 
  border-radius:8px; 
  /* Enhanced touch support for iOS */
  touch-action:pan-y pinch-zoom;
  -webkit-overflow-scrolling:touch;
  overflow:auto;
  /* Force hardware acceleration */
  -webkit-transform:translateZ(0);
  transform:translateZ(0);
  /* Ensure proper scrolling on iOS */
  -webkit-scroll-behavior:smooth;
  scroll-behavior:smooth;
}

/* Floor Plans/Archivum Modal */
.floorplans-archivum-sheet { width:min(780px,95vw); max-height:99vh; }
.floorplans-archivum-content { 
  display:grid; 
  grid-template-columns:300px 1fr; 
  gap:20px; 
  padding:16px; 
  max-height:calc(99vh - 120px); 
  overflow-y:auto; 
}
.floorplans-section { display:flex; flex-direction:column; }
.archivum-section { display:flex; flex-direction:column; border-left:1px solid var(--border); padding-left:20px; }

.err { position:fixed; right:10px; bottom:10px; background:#b91c1c; color:white; padding:8px 10px; border-radius:8px; }

.signpad { background:#000; border:1px solid var(--border); border-radius:8px; width:min(1060px,95vw); padding:0; }
.signpad canvas { display:block; width:100%; height:420px; touch-action:none; }


/* === iPad-first responsive design === */
.modal .editor-grid .stage-wrap{ max-height: calc(100vh - 220px); overflow-x:auto; overflow-y:hidden; }
.modal .editor-grid .stage{ max-width: 100%; max-height: calc(100vh - 260px); }
.modal .editor-grid canvas{ max-width: 100%; height: auto; }
.modal .editor-grid img{ max-width: 100%; max-height: 100%; object-fit: contain; }

/* iPad-first touch targets (keep button improvements, revert large sizes) */
@media (min-width: 768px) {
  .btn { min-width: 52px; min-height: 52px; padding: 14px 18px; font-size: 17px; }
  .swatch { width: 32px; height: 32px; }
  .tool { min-width: 48px; min-height: 48px; }
  /* Reverted: textbox, editor-grid, stage, notes sizes back to original */
  /* Reverted: signpad sizes back to original */
}

/* Large tablet landscape (keep only button improvements) */
@media (min-width: 1024px) {
  /* Reverted: All large size changes removed to prevent scrollbars */
}

/* ===== NEW WORKSPACE LAYOUT ===== */
.workspace-grid {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 16px;
  height: calc(100vh - 120px); /* Account for header and some padding */
  max-height: 600px; /* iPad optimization */
}

.reports-sidebar {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.sidebar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

.sidebar-title {
  margin: 0;
  font-size: 14px;
  font-weight: 700;
  color: var(--fg);
}

.btn-small {
  padding: 6px 12px;
  font-size: 12px;
  min-height: auto;
  min-width: auto;
}

.workspace-main {
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow: hidden;
}

.workspace-controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px;
  flex-shrink: 0;
}

.controls-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

/* Reference layout styling - horizontal arrangement for non-iPhone devices */
.original-controls {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.control-group {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--muted);
}

.input-small {
  width: 140px;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--bg);
  color: var(--fg);
  font-size: 12px;
}

.add-tile-compact {
  height: 80px;
  flex-shrink: 0;
  margin-bottom: 0;
}

.add-tile-compact .plus {
  font-size: 24px;
}

.add-tile-compact .add-text {
  font-size: 12px;
}

.board-compact {
  flex: 1;
  overflow-y: auto;
  min-height: 200px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px;
  background: var(--panel);
}

.location-row {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px;
  flex-shrink: 0;
}

.location-control {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  font-size: 12px;
  color: var(--muted);
}

.location-input {
  flex: 1;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--bg);
  color: var(--fg);
  font-size: 12px;
}

/* Clear All Data Button - Bottom Right */
.clear-all-btn {
  position: fixed;
  bottom: 16px;
  right: 16px;
  z-index: 1000;
  padding: 8px 12px;
  font-size: 12px;
  min-height: auto;
  min-width: auto;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

/* Add red X to workspace cards */
.tile.card {
  position: relative;
}

.tile.card .card-delete {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 24px;
  height: 24px;
  background: #dc2626;
  color: white;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.8;
  transition: opacity 0.2s;
  z-index: 10;
}

.tile.card .card-delete:hover {
  opacity: 1;
  background: #b91c1c;
}

.tile.card {
  cursor: pointer;
  transition: transform 0.2s, border-color 0.2s;
}

.tile.card:hover {
  transform: translateY(-2px);
  border-color: var(--accent);
}

/* Responsive adjustments for tablets (between iPhone and desktop) */
@media (min-width: 431px) and (max-width: 768px) {
  .workspace-grid {
    grid-template-columns: 1fr;
    grid-template-rows: 200px 1fr;
    height: calc(100vh - 100px);
  }
  
  .reports-sidebar {
    max-height: 200px;
  }
  
  .sidebar-header {
    flex-direction: column;
    gap: 8px;
    align-items: stretch;
  }
}

/* ===== IPHONE PORTRAIT MODE OPTIMIZATION ===== */

/* CSS-based orientation lock for iPhone only (not iPad) */
@supports (-webkit-touch-callout: none) {
  @media screen and (orientation: landscape) and (max-width: 430px) and (max-height: 932px) {
    body::before {
      content: "Please rotate your iPhone to portrait mode";
      position: fixed;
      top: 0;
      left: 0;
      width: 100%;
      height: 100%;
      background: rgba(0, 0, 0, 0.9);
      color: white;
      display: flex;
      align-items: center;
      justify-content: center;
      font-size: 18px;
      text-align: center;
      z-index: 99999;
      padding: 20px;
    }
    
    body > *:not(::before) {
      display: none !important;
    }
  }
}

/* iPhone-specific viewport optimization (max iPhone Pro Max width) */
@media (max-width: 430px) and (max-height: 932px) {
  /* Force iPhone to use full viewport */
  html, body {
    width: 100%;
    overflow-x: hidden;
    position: relative;
  }
  
  /* Adjust app header for iPhone */
  .app-header {
    padding: 8px 12px;
    flex-wrap: nowrap;
  }
  
  .app-header .title {
    font-size: 16px;
    flex-shrink: 0;
  }
  
  .app-header .meta {
    display: none; /* Hide version on iPhone to save space */
  }
  
  .actions {
    gap: 4px;
    flex-shrink: 0;
  }
  
  /* Restructure workspace for iPhone portrait */
  .workspace-grid {
    grid-template-columns: 1fr;
    grid-template-rows: 180px 1fr;
    gap: 8px;
    height: calc(100vh - 80px);
  }
  
  .reports-sidebar {
    max-height: 180px;
    padding: 8px;
  }
  
  .sidebar-header {
    flex-direction: row;
    justify-content: space-between;
    margin-bottom: 8px;
  }
  
  .sidebar-title {
    font-size: 12px;
  }
  
  /* Enable vertical scrolling in main workspace only */
  .workspace-main {
    overflow-y: auto !important;
    overflow-x: hidden !important;
    max-height: calc(100vh - 140px) !important;
    min-height: calc(100vh - 160px) !important;
  }
  
  /* Prevent scrolling in other UI elements */
  .modal, .sheet, .overlay {
    overflow: hidden !important;
  }
  
  .modal .card {
    overflow: hidden !important;
  }
  
  /* Stack workspace controls vertically on iPhone */
  .workspace-controls {
    flex-direction: column;
    gap: 4px;
    padding: 4px;
    flex-shrink: 0; /* Don't shrink controls */
  }
  
  .controls-left {
    width: 100%;
  }
  
  /* Hide original controls and show iPhone reorganized controls */
  .original-controls {
    display: none !important;
  }
  
  .iphone-controls-reorganized {
    display: block !important;
  }
  
  /* Job inputs side-by-side row */
  .job-inputs-row {
    display: flex;
    gap: 4px;
    margin-bottom: 4px;
  }
  
  .job-control-compact {
    flex: 1;
    display: flex;
    flex-direction: column;
    font-size: 10px;
    color: var(--muted);
  }
  
  .job-input-compact {
    width: 100%;
    padding: 2px 4px;
    border: 1px solid var(--border);
    border-radius: 3px;
    background: var(--bg);
    color: var(--fg);
    font-size: 12px;
    height: 28px;
  }
  
  /* Location row full-width */
  .location-row-iphone {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-bottom: 4px;
  }
  
  .location-control-iphone {
    flex: 1;
    display: flex;
    flex-direction: column;
    font-size: 10px;
    color: var(--muted);
  }
  
  .location-input-iphone {
    width: 100%;
    padding: 2px 4px;
    border: 1px solid var(--border);
    border-radius: 3px;
    background: var(--bg);
    color: var(--fg);
    font-size: 12px;
    height: 28px;
  }
  
  .btn-location-iphone {
    min-width: 28px !important;
    width: 28px;
    height: 28px;
    padding: 2px !important;
    font-size: 12px;
    flex-shrink: 0;
    align-self: flex-end; /* Align with input */
  }
  
  /* Storage row compact */
  .storage-row-iphone {
    margin-bottom: 4px;
  }
  
  .storage-indicator-iphone {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 9px;
  }
  
  #storage-text-iphone {
    font-size: 8px;
    color: var(--muted);
  }
  
  .storage-bar-iphone {
    width: 50px;
    height: 3px;
    background: var(--border);
    border-radius: 2px;
    overflow: hidden;
  }
  
  .storage-fill-iphone {
    height: 100%;
    background: var(--green);
    transition: width 0.3s ease;
  }
  
  /* Hide original location row on iPhone */
  .location-row {
    display: none !important;
  }
  
  .controls-right {
    display: flex;
    gap: 3px;
    justify-content: space-between;
    width: 100%;
  }
  
  /* Optimize buttons for iPhone */
  .btn {
    min-width: auto;
    min-height: 36px; /* Reduced for more space */
    padding: 4px 6px;
    font-size: 12px;
  }
  
  .btn-small {
    padding: 2px 4px;
    font-size: 10px;
    min-height: 28px;
  }
  
  /* iPhone-specific button sizing - much smaller */
  #btn-floorplans {
    flex: 1;
    max-width: 70px;
    font-size: 11px;
    padding: 4px;
  }
  
  #lib-export {
    flex: 1;
    max-width: 40px;
    font-size: 11px;
    padding: 4px;
  }
  
  #btn-notes {
    width: 36px;
    height: 36px;
    padding: 4px;
    font-size: 16px;
    flex-shrink: 0;
  }
  
  /* Make storage indicator more compact on iPhone */
  .storage-indicator {
    display: flex !important; /* Override the hide rule from before */
    flex-direction: row;
    gap: 4px;
    font-size: 10px;
    align-items: center;
  }
  
  #storage-text {
    font-size: 9px;
  }
  
  .storage-bar {
    width: 60px;
    height: 3px;
  }
  
  /* Image cards optimization for iPhone */
  .board-compact {
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 6px;
    padding: 6px;
  }
  
  .tile.card {
    height: 160px;
  }
  
  .tile.card img {
    height: 160px;
  }
  
  /* Hide original location row on iPhone since we moved it to controls */
  .location-row {
    display: none !important;
  }
  
  /* Modal optimizations for iPhone */
  .modal .card {
    margin: 10px;
    max-width: calc(100vw - 20px);
    max-height: calc(100vh - 20px);
  }
  
  .sheet.small {
    width: calc(100vw - 20px);
  }
  
  /* Location-related modal optimizations */
  .location-modal, .geolocation-modal {
    max-width: calc(100vw - 30px) !important;
    padding: 8px !important;
  }
  
  .location-modal .input, .geolocation-modal .input {
    font-size: 16px !important;
    padding: 8px !important;
  }
  
  /* Annotation editor iPhone layout */
  .editor-grid {
    width: calc(100vw - 20px);
    max-height: calc(100vh - 40px);
  }
  
  /* Stack annotation image and notes vertically on iPhone */
  .stage-wrap {
    display: flex;
    flex-direction: column;
    gap: 8px;
  }
  
  .stage {
    width: 100%;
    height: 300px;
  }
  
  .notes {
    width: 100%;
    height: 200px;
  }
  
  .notes textarea {
    min-height: 180px;
  }
  
  /* Toolbar optimization for iPhone */
  .toolbar.thin {
    flex-wrap: wrap;
    gap: 6px;
    padding: 6px;
  }
  
  /* Keep floor plan toolbar inline on iPhone */
  .floorplan-viewer-grid .toolbar.thin .left {
    width: auto;
    flex: 1;
    justify-content: flex-start;
  }
  
  .floorplan-viewer-grid .toolbar.thin .right {
    width: auto;
    justify-content: flex-end;
    border-top: none;
    padding-top: 0;
  }
  
  /* Other modals can still use collapsing toolbar */
  .modal:not(#floorplan-viewer) .toolbar.thin .left {
    width: 100%;
    justify-content: center;
  }
  
  .modal:not(#floorplan-viewer) .toolbar.thin .right {
    width: 100%;
    justify-content: center;
    border-top: 1px solid var(--border);
    padding-top: 6px;
  }
  
  /* Tool buttons for iPhone touch */
  .tool {
    min-width: 40px;
    min-height: 40px;
    padding: 8px;
  }
  
  .shape-btn {
    width: 32px;
    height: 32px;
  }
  
  /* Storage indicator hide on iPhone to save space */
  .storage-indicator {
    display: none;
  }
  
  /* Floor plans modal optimization */
  .floorplans-archivum-sheet {
    width: calc(100vw - 10px);
  }
  
  .floorplans-archivum-content {
    grid-template-columns: 1fr;
    gap: 12px;
    padding: 8px;
  }
  
  .archivum-section {
    border-left: none;
    border-top: 1px solid var(--border);
    padding-left: 0;
    padding-top: 12px;
  }
  
  /* Floor plan viewer optimization */
  .floorplan-viewer-grid {
    width: calc(100vw - 60px);
    max-width: calc(100vw - 60px);
    height: calc(100vh - 305px);
    max-height: calc(100vh - 305px);
    margin: 0;
    left: 50%;
    transform: translateX(-50%);
    position: fixed;
    top: 80px;
  }
  
  /* NUCLEAR iOS zoom fix - remove ALL touch restrictions */
  #floorplan-viewer,
  #floorplan-viewer *,
  #floorplan-viewer canvas,
  #floorplan-viewer .floor-canvas-container,
  #floorplan-viewer .floor-canvas-container canvas {
    touch-action: manipulation !important;
    -webkit-touch-callout: default !important;
    -webkit-user-select: none !important;
    user-select: none !important;
  }
  
  .floor-viewer-content {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
    height: calc(100vh - 260px);
    max-height: calc(100vh - 260px);
    min-height: 200px;
    overflow: visible;
    padding: 4px;
  }
  
  .floor-canvas-container {
    min-height: 150px !important;
    max-height: calc(100vh - 565px) !important;
    margin: 0;
    width: 100%;
  }
  
  .floor-card-tray {
    border-left: none;
    border-top: 1px solid var(--border);
    overflow-y: auto;
    max-height: 300px;
    padding-left: 0;
    padding-top: 8px;
  }
  
  .floor-card-tray-content {
    grid-template-columns: repeat(auto-fit, minmax(70px, 70px));
    gap: 6px;
    max-height: 160px;
    justify-content: start;
  }
  
  .tray-card {
    height: 70px;
    width: 70px;
    padding: 3px;
    min-width: 70px;
    max-width: 70px;
    flex-shrink: 0;
  }
  
  .tray-card-image {
    height: 45px;
    margin-bottom: 2px;
  }
  
  /* Sign modal optimization */
  .signpad {
    width: calc(100vw - 20px);
  }
  
  .signpad canvas {
    height: 300px;
  }
  
  /* Clear all data button positioning for iPhone */
  .clear-all-btn {
    bottom: 10px;
    right: 10px;
    font-size: 10px;
    padding: 6px 8px;
  }
}

/* iPhone-specific styles using JavaScript-added class */
.iphone-optimized .app-header {
  -webkit-user-select: none;
  user-select: none;
}

.iphone-optimized .btn {
  -webkit-tap-highlight-color: rgba(0, 0, 0, 0.1);
  tap-highlight-color: rgba(0, 0, 0, 0.1);
}

/* Additional iPhone-specific overrides with high specificity */
@media (max-width: 430px) and (max-height: 932px) {
  /* Ensure modal inputs are properly sized */
  .input {
    max-width: 100% !important;
    font-size: 16px !important; /* Prevent zoom on focus in iOS */
  }
  
  /* Fix job details modal inputs */
  #job-name-input, #job-code-input {
    width: 100% !important;
    max-width: 100% !important;
    font-size: 16px !important;
  }
  
  /* Optimize settings inputs for iPhone */
  #set-occupation, #set-phone {
    font-size: 16px !important;
    width: 100% !important;
  }
  
  /* Location input optimization */
  .location-input {
    font-size: 16px !important;
  }
  
  /* Note editor optimization */
  #note-name, #note-content {
    font-size: 16px !important;
  }
  
  /* Prevent horizontal scroll on iPhone */
  * {
    max-width: 100vw !important;
  }
  
  .modal {
    padding: 5px !important;
  }
  
  /* Ensure buttons don't overflow */
  .controls-right {
    flex-wrap: wrap !important;
  }
  
  /* Grid adjustments for iPhone */
  .grid2 {
    grid-template-columns: 1fr !important;
    gap: 8px !important;
  }
  
  /* Override min-width constraints for iPhone */
  .btn {
    min-width: auto !important;
  }
  
  .pin-popover {
    min-width: 250px !important;
    max-width: calc(100vw - 20px) !important;
  }
  
  .textbox {
    min-width: 120px !important;
    max-width: calc(100vw - 40px) !important;
  }
  
  .plan-counter {
    min-width: 60px !important;
  }
  
  /* ===== COMPLETE IPHONE PORTRAIT FIXES ===== */
  
  /* Remove ALL dividing bars on iPhone */
  .app-header,
  .toolbar,
  .bar,
  .sidebar-header,
  .pdf-viewer-header {
    border-bottom: none !important;
  }
  
  /* Floor plan canvas height increase for iPhone */
  .floor-canvas-container {
    min-height: 250px !important;
  }
  
  /* iPhone PDF viewer - prevent right-side cutoff */
  .pdf-viewer-container {
    width: 95vw !important;
    height: 80vh !important;
  }
  
  .pdf-viewer-content iframe {
    width: 100% !important;
    height: 100% !important;
    transform: scale(0.7) !important;
    transform-origin: top left !important;
  }
  
  /* SIMPLE 2-COLUMN LAYOUT: Report names side-by-side, Report IDs side-by-side */
  
  /* Remove container constraints - let everything flow naturally */
  .jobs-list {
    display: block !important;
    width: 100% !important;
  }
  
  .report-name-item {
    display: contents !important;
  }
  
  .child-reports {
    display: contents !important;
  }
  
  /* Report name buttons - 50% width each, side-by-side, SMALL */
  .report-name-btn {
    width: calc(50% - 4px) !important;
    display: inline-block !important;
    vertical-align: top !important;
    font-size: 8px !important;
    padding: 3px !important;
    min-height: 24px !important;
    margin: 2px !important;
    text-overflow: ellipsis !important;
    overflow: hidden !important;
    white-space: nowrap !important;
    box-sizing: border-box !important;
  }
  
  /* Report ID buttons - 50% width each, side-by-side, MICROSCOPIC for tiny iPhone */
  .child-report-btn {
    width: calc(50% - 4px) !important;
    display: inline-block !important;
    vertical-align: top !important;
    font-size: 7px !important;
    padding: 2px !important;
    min-height: 20px !important;
    margin: 2px !important;
    text-overflow: ellipsis !important;
    overflow: hidden !important;
    white-space: nowrap !important;
    box-sizing: border-box !important;
  }
  
  /* CRITICAL: Fix GIANT report name modal textbox on iPhone - Override ALL themes */
  .report-name-input,
  [data-theme="light"] .report-name-input,
  [data-theme="dark"] .report-name-input,
  [data-theme="green"] .report-name-input,
  [data-theme="purple"] .report-name-input,
  [data-theme="sunset"] .report-name-input {
    font-size: 16px !important; /* MUST be 16px to prevent iPhone zoom */
    padding: 6px 8px !important;
    max-height: 44px !important;
    width: 90% !important;
    min-width: 90% !important;
    max-width: 90% !important;
    line-height: 1.2 !important; /* Reduced to keep compact with 16px font */
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    display: -webkit-box !important;
    -webkit-line-clamp: 2 !important;
    -webkit-box-orient: vertical !important;
    box-sizing: border-box !important;
  }
  
  /* Fix iPhone input zoom bugs */
  #notes,
  #job-name-iphone,
  #job-code-iphone, 
  #location-field-iphone,
  .job-input-compact,
  .location-input-iphone,
  .report-name-input {
    font-size: 16px !important;
  }
  
  /* Center and fix notes button emoji on iPhone - prevent squishing */
  #btn-notes {
    width: 40px !important;
    height: 40px !important;
    min-width: 40px !important;
    flex-shrink: 0 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    font-size: 16px !important;
    padding: 0 !important;
    text-align: center !important;
  }
  
}
"/* force deployment $(date) */" 
