/* ================================================================
   MJM NURSERY — SEEDLING HEIGHT SYSTEM
   height_styles.css
================================================================ */
@import url('https://fonts.googleapis.com/css2?family=DM+Sans:opsz,wght@9..40,400;9..40,500;9..40,600;9..40,700&display=swap');

*,*::before,*::after{box-sizing:border-box;margin:0;padding:0}
img{display:block;max-width:100%}
button{cursor:pointer;font-family:inherit}

:root{
  --g900:#0d2b0d;--g800:#1a4d1a;--g700:#236023;--g600:#2d7a2d;--g500:#3d9c3d;
  --g400:#5aab5a;--g300:#81c784;--g200:#b5dfb5;--g100:#e0f2e0;--g50:#f2faf2;
  --a800:#0f4c52;--a600:#177a83;--a400:#26b5c2;--a100:#d0f4f7;--a50:#edfbfc;
  --white:#fff;--surface:#f4f6f4;--card:#fff;--border:#dde8dd;--border2:#c4d8c4;
  --text1:#182018;--text2:#3d5c3d;--text3:#6b8a6b;--text4:#9db09d;
  --danger-bg:#fff1f1;--danger-text:#b91c1c;--danger-border:#fca5a5;
  --r-sm:6px;--r-md:10px;--r-lg:16px;--r-xl:24px;--r-full:999px;
  --shadow-xs:0 1px 2px rgba(0,0,0,.06);
  --shadow-sm:0 1px 4px rgba(0,0,0,.08),0 1px 2px rgba(0,0,0,.04);
  --shadow-fab:0 4px 16px rgba(27,77,27,.45),0 1px 4px rgba(0,0,0,.12);
  --nav-h:56px;--tab-h:62px;
}

html,body{height:100%;font-family:'DM Sans',sans-serif;font-size:16px;background:var(--surface);color:var(--text1);-webkit-font-smoothing:antialiased}
#app{max-width:480px;margin:0 auto;min-height:100vh;background:var(--surface);position:relative}

/* TOP BAR */
.top-bar{position:sticky;top:0;z-index:200;height:var(--nav-h);background:var(--g800);display:flex;align-items:center;padding:0 14px;gap:10px;box-shadow:0 2px 10px rgba(0,0,0,.2)}
.top-bar-logo{display:flex;align-items:center;gap:9px;flex:1;min-width:0}
.top-bar-back{width:32px;height:32px;border-radius:8px;background:rgba(255,255,255,.12);border:1px solid rgba(255,255,255,.15);display:flex;align-items:center;justify-content:center;flex-shrink:0;text-decoration:none;transition:background .15s;margin-right:4px}
.top-bar-back:hover{background:rgba(255,255,255,.22)}
.top-bar-back svg{width:17px;height:17px;stroke:#fff;fill:none;stroke-width:2.2;stroke-linecap:round;stroke-linejoin:round}
.top-bar-icon{width:32px;height:32px;border-radius:8px;background:rgba(255,255,255,.13);display:flex;align-items:center;justify-content:center;flex-shrink:0}
.top-bar-icon svg{width:17px;height:17px;stroke:#fff;fill:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:round}
.top-bar-title{font-size:15px;font-weight:700;color:#fff;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.top-bar-sub{font-size:10px;color:rgba(255,255,255,.55);margin-top:1px}
.top-bar-actions{display:flex;align-items:center;gap:4px;flex-shrink:0}
.top-bar-btn{width:36px;height:36px;border-radius:8px;background:transparent;border:none;display:flex;align-items:center;justify-content:center;transition:background .15s}
.top-bar-btn:hover{background:rgba(255,255,255,.1)}
.top-bar-btn svg{width:18px;height:18px;stroke:rgba(255,255,255,.85);fill:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:round}

/* BOTTOM TABS */
.bottom-tabs{position:fixed;bottom:0;left:50%;transform:translateX(-50%);width:100%;max-width:480px;height:var(--tab-h);background:var(--white);border-top:1px solid var(--border);display:grid;grid-template-columns:repeat(4,1fr);z-index:200;box-shadow:0 -2px 10px rgba(0,0,0,.07)}
.tab-item{display:flex;flex-direction:column;align-items:center;justify-content:center;gap:4px;padding:8px 4px;cursor:pointer;border:none;background:transparent;transition:background .15s;-webkit-tap-highlight-color:transparent;position:relative}
.tab-item:hover{background:var(--g50)}
.tab-item.active{background:var(--g50)}
.tab-item.active::before{content:'';position:absolute;top:0;left:20%;right:20%;height:2.5px;background:var(--g800);border-radius:0 0 4px 4px}
.tab-icon{width:22px;height:22px;display:flex;align-items:center;justify-content:center}
.tab-icon svg{width:20px;height:20px;stroke:var(--text3);fill:none;stroke-width:1.8;stroke-linecap:round;stroke-linejoin:round;transition:stroke .15s}
.tab-item.active .tab-icon svg{stroke:var(--g800)}
.tab-label{font-size:11px;font-weight:500;color:var(--text3);transition:color .15s}
.tab-item.active .tab-label{color:var(--g800);font-weight:700}
.tab-badge{position:absolute;top:6px;right:calc(50% - 18px);min-width:16px;height:16px;background:var(--g600);color:#fff;font-size:9px;font-weight:700;border-radius:var(--r-full);display:flex;align-items:center;justify-content:center;padding:0 4px}

/* PAGE */
.page-scroll{padding-bottom:calc(var(--tab-h) + 1rem);min-height:calc(100vh - var(--nav-h))}
.view{display:none}
.view.active{display:block}

/* STATS */
.summary-strip{background:var(--g800);padding:14px 16px 20px;display:flex;gap:10px}
.stat-card{flex:1;background:rgba(255,255,255,.1);border-radius:var(--r-md);padding:10px 10px 8px;text-align:center}
.stat-value{font-size:22px;font-weight:700;color:#fff;line-height:1;margin-bottom:4px}
.stat-label{font-size:10px;font-weight:500;color:rgba(255,255,255,.6);text-transform:uppercase;letter-spacing:.4px}

/* LIST */
.list-header{padding:14px 16px 8px;display:flex;align-items:center;justify-content:space-between}
.list-heading{font-size:12px;font-weight:700;text-transform:uppercase;letter-spacing:.6px;color:var(--text3)}
.list-count{font-size:11px;font-weight:600;background:var(--g100);color:var(--g700);padding:3px 10px;border-radius:var(--r-full)}
.record-list{padding:0 12px}
.record-item{background:var(--card);border:1px solid var(--border);border-radius:var(--r-lg);margin-bottom:9px;display:flex;align-items:center;gap:12px;padding:11px 12px;cursor:pointer;transition:all .15s;box-shadow:var(--shadow-xs);-webkit-tap-highlight-color:transparent}
.record-item:hover{border-color:var(--g300);box-shadow:var(--shadow-sm);transform:translateX(2px)}
.record-item:active{transform:scale(.99)}

/* THUMB STACK */
.record-thumb-stack{width:52px;height:52px;position:relative;flex-shrink:0}
.record-thumb-stack img,.record-thumb-stack .thumb-ph{width:42px;height:42px;border-radius:var(--r-md);object-fit:cover;border:1.5px solid var(--white);position:absolute}
.record-thumb-stack img:nth-child(1),.record-thumb-stack .thumb-ph:nth-child(1){top:0;left:0;z-index:3}
.record-thumb-stack img:nth-child(2),.record-thumb-stack .thumb-ph:nth-child(2){top:4px;left:5px;z-index:2}
.record-thumb-stack img:nth-child(3),.record-thumb-stack .thumb-ph:nth-child(3){top:8px;left:10px;z-index:1}
.thumb-ph{background:var(--g50);display:flex;align-items:center;justify-content:center}
.thumb-ph svg{width:16px;height:16px;stroke:var(--g300);fill:none;stroke-width:1.5}

.record-info{flex:1;min-width:0}
.record-plot{font-size:15px;font-weight:600;color:var(--text1);margin-bottom:3px}
.record-meta{font-size:12px;color:var(--text3);margin-bottom:5px}
.record-heights{display:flex;gap:6px;flex-wrap:wrap}
.height-pill{font-size:11px;font-weight:600;padding:2px 9px;border-radius:var(--r-full);background:var(--a50);color:var(--a800);border:1px solid var(--a100)}
.height-pill.missing{background:var(--surface);color:var(--text4);border-color:var(--border);font-weight:400}
.avg-pill{font-size:11px;font-weight:700;padding:2px 9px;border-radius:var(--r-full);background:var(--g100);color:var(--g700);border:1px solid var(--g200)}

.record-actions{display:flex;flex-direction:column;gap:6px;flex-shrink:0}
.icon-btn{width:32px;height:32px;border-radius:8px;border:1px solid var(--border);background:var(--white);display:flex;align-items:center;justify-content:center;transition:all .15s}
.icon-btn svg{width:15px;height:15px;fill:none;stroke-width:1.8;stroke-linecap:round;stroke-linejoin:round}
.icon-btn.edit-btn svg{stroke:var(--g600)}
.icon-btn.del-btn svg{stroke:var(--danger-text)}
.icon-btn.edit-btn:hover{border-color:var(--g300);background:var(--g50)}
.icon-btn.del-btn:hover{border-color:var(--danger-border);background:var(--danger-bg)}

/* EMPTY */
.empty-state{text-align:center;padding:3rem 1.5rem 2rem}
.empty-state-icon{width:64px;height:64px;border-radius:50%;background:var(--g100);display:flex;align-items:center;justify-content:center;margin:0 auto 16px}
.empty-state-icon svg{width:30px;height:30px;stroke:var(--g400);fill:none;stroke-width:1.5}
.empty-state h3{font-size:15px;font-weight:600;color:var(--text2);margin-bottom:6px}
.empty-state p{font-size:13px;color:var(--text4);line-height:1.5}

/* FAB */
.fab{position:fixed;bottom:calc(var(--tab-h) + 16px);right:16px;width:52px;height:52px;border-radius:50%;background:var(--g600);border:none;display:flex;align-items:center;justify-content:center;box-shadow:var(--shadow-fab);z-index:150;transition:background .2s;-webkit-tap-highlight-color:transparent}
@media(min-width:480px){.fab{right:calc(50% - 224px)}}
.fab:hover{background:var(--g500)}
.fab:active{opacity:.85}
.fab svg{width:24px;height:24px;stroke:#fff;fill:none;stroke-width:2.5;stroke-linecap:round}

/* FORM */
.form-view-header{background:var(--g800);padding:14px 16px;display:flex;align-items:center;gap:12px}
.back-btn{width:36px;height:36px;border-radius:9px;background:rgba(255,255,255,.13);border:none;display:flex;align-items:center;justify-content:center;flex-shrink:0;transition:background .15s}
.back-btn:hover{background:rgba(255,255,255,.2)}
.back-btn svg{width:18px;height:18px;stroke:#fff;fill:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:round}
.form-view-title{font-size:16px;font-weight:700;color:#fff;flex:1}
.form-view-id{font-size:11px;font-weight:600;background:rgba(255,255,255,.15);color:rgba(255,255,255,.9);padding:4px 12px;border-radius:var(--r-full);flex-shrink:0}
.form-card{background:var(--card);border:1px solid var(--border);border-radius:var(--r-lg);margin:14px 12px;overflow:hidden;box-shadow:var(--shadow-sm)}
.form-section-head{padding:12px 16px;background:var(--g50);border-bottom:1px solid var(--border);font-size:11px;font-weight:700;text-transform:uppercase;letter-spacing:.6px;color:var(--g700);display:flex;align-items:center;gap:7px}
.form-section-head svg{width:14px;height:14px;stroke:var(--g600);fill:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:round}
.form-inner{padding:16px}
.form-row{display:grid;grid-template-columns:1fr 1fr;gap:12px}
.form-field{margin-bottom:16px}
.form-field:last-child{margin-bottom:0}
.field-label{font-size:12px;font-weight:600;color:var(--text2);margin-bottom:7px;display:flex;align-items:center;gap:5px}
.req{color:#e02020;font-size:11px}
.opt{font-size:10px;font-weight:500;color:var(--text4);margin-left:auto;background:var(--surface);padding:1px 7px;border-radius:4px}
.input,select.input{width:100%;height:40px;padding:0 12px;font-size:14px;font-family:'DM Sans',sans-serif;border:1px solid var(--border2);border-radius:var(--r-md);background:var(--surface);color:var(--text1);outline:none;transition:border-color .15s,box-shadow .15s,background .15s;-webkit-appearance:none;appearance:none}
.input:focus,select.input:focus{border-color:var(--g500);box-shadow:0 0 0 3px rgba(61,156,61,.14);background:var(--white)}
.input[readonly]{color:var(--text3);background:var(--surface);cursor:default}
.select-wrap{position:relative}
.select-wrap::after{content:'';position:absolute;right:12px;top:50%;transform:translateY(-50%);border-left:5px solid transparent;border-right:5px solid transparent;border-top:6px solid var(--text3);pointer-events:none}
.select-wrap select{padding-right:32px;cursor:pointer}

/* HEIGHT SAMPLES */
.samples-grid{display:grid;grid-template-columns:repeat(3,1fr);gap:10px}
.sample-col{background:var(--a50);border:1px solid var(--a100);border-radius:var(--r-md);padding:12px 10px;text-align:center}
.sample-num{width:28px;height:28px;border-radius:50%;background:var(--a800);color:#fff;font-size:13px;font-weight:700;display:flex;align-items:center;justify-content:center;margin:0 auto 6px}
.sample-col-label{font-size:11px;font-weight:700;color:var(--a800);text-transform:uppercase;letter-spacing:.5px;margin-bottom:8px}
.height-input-wrap{position:relative;display:flex;align-items:center}
.height-input{width:100%;height:44px;padding:0 28px 0 8px;font-size:18px;font-weight:700;font-family:'DM Sans',sans-serif;border:1.5px solid var(--a100);border-radius:var(--r-md);background:var(--white);color:var(--a800);outline:none;text-align:center;transition:border-color .15s,box-shadow .15s;-webkit-appearance:none;appearance:none}
.height-input:focus{border-color:var(--a400);box-shadow:0 0 0 3px rgba(38,181,194,.15)}
.height-input::placeholder{color:var(--text4);font-size:14px;font-weight:400}
.height-unit{position:absolute;right:6px;font-size:10px;font-weight:600;color:var(--text4);pointer-events:none}
.sample-filled{font-size:11px;color:var(--g600);font-weight:500;margin-top:6px;min-height:16px}
.avg-bar{margin-top:12px;background:var(--g50);border:1px solid var(--g200);border-radius:var(--r-md);padding:10px 14px;display:flex;align-items:center;justify-content:space-between}
.avg-bar-label{font-size:12px;font-weight:600;color:var(--text2)}
.avg-bar-value{font-size:18px;font-weight:700;color:var(--g700)}
.avg-bar-unit{font-size:12px;color:var(--text3);margin-left:3px}

/* PHOTO SLOTS */
.photo-slots{display:grid;grid-template-columns:repeat(3,1fr);gap:10px}
.photo-slot{position:relative;aspect-ratio:1/1;border-radius:var(--r-md);overflow:hidden;border:1.5px dashed var(--border2);background:var(--surface);cursor:pointer;transition:all .15s;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:5px;-webkit-tap-highlight-color:transparent}
.photo-slot:hover{border-color:var(--g400);background:var(--g50)}
.photo-slot.has-photo{border-style:solid;border-color:var(--border)}
.photo-slot svg{width:22px;height:22px;stroke:var(--text4);fill:none;stroke-width:1.5}
.photo-slot-label{font-size:10px;font-weight:600;color:var(--text4);text-transform:uppercase;letter-spacing:.4px}
.photo-slot-num{width:20px;height:20px;border-radius:50%;background:var(--border2);color:var(--text3);font-size:10px;font-weight:700;display:flex;align-items:center;justify-content:center}
.photo-slot img{position:absolute;inset:0;width:100%;height:100%;object-fit:cover}
.photo-slot-clear{position:absolute;top:4px;right:4px;width:22px;height:22px;border-radius:50%;background:rgba(0,0,0,.55);border:none;color:#fff;font-size:14px;display:flex;align-items:center;justify-content:center;z-index:2;line-height:1;transition:background .15s}
.photo-slot-clear:hover{background:rgba(185,28,28,.8)}
.photo-req-note{font-size:11px;color:var(--text4);text-align:center;margin-top:8px}
.photo-req-note.error{color:var(--danger-text);font-weight:500}

/* FORM ACTIONS */
.form-actions{display:grid;grid-template-columns:1fr 1fr;gap:10px;padding:14px 12px}
.btn{height:44px;border-radius:var(--r-md);font-size:14px;font-weight:600;font-family:'DM Sans',sans-serif;border:none;transition:all .15s}
.btn:active{transform:scale(.97)}
.btn-cancel{background:var(--white);border:1px solid var(--border2);color:var(--text2)}
.btn-cancel:hover{background:var(--surface)}
.btn-save{background:var(--g800);color:#fff;box-shadow:0 2px 8px rgba(26,77,26,.3)}
.btn-save:hover{background:var(--g600)}

/* DETAIL */
.detail-photos{display:grid;grid-template-columns:repeat(3,1fr);gap:6px;padding:14px 12px 0}
.detail-photo{aspect-ratio:1/1;border-radius:var(--r-md);overflow:hidden;border:1px solid var(--border);background:var(--g50);cursor:pointer;position:relative}
.detail-photo img{width:100%;height:100%;object-fit:cover}
.detail-photo-empty{width:100%;height:100%;display:flex;align-items:center;justify-content:center}
.detail-photo-empty svg{width:28px;height:28px;stroke:var(--g300);fill:none;stroke-width:1.5}
.detail-photo-num{position:absolute;bottom:5px;left:5px;background:rgba(0,0,0,.5);color:#fff;font-size:9px;font-weight:700;padding:1px 6px;border-radius:4px}
.detail-body{padding:14px 12px}
.detail-tag-row{display:flex;align-items:center;gap:8px;margin-bottom:10px;flex-wrap:wrap}
.detail-nursery-tag{font-size:11px;font-weight:700;background:var(--g800);color:#fff;padding:4px 12px;border-radius:var(--r-full)}
.detail-id{font-size:12px;color:var(--text3);font-weight:500}
.detail-date{margin-left:auto;font-size:11px;color:var(--text4)}
.detail-plot{font-size:20px;font-weight:700;color:var(--text1);margin-bottom:4px}
.detail-batch{font-size:12px;color:var(--text3);margin-bottom:16px}
.detail-height-grid{display:grid;grid-template-columns:repeat(3,1fr);gap:8px;margin-bottom:10px}
.detail-height-cell{background:var(--a50);border:1px solid var(--a100);border-radius:var(--r-md);padding:12px 8px;text-align:center}
.detail-height-cell-label{font-size:10px;font-weight:700;text-transform:uppercase;letter-spacing:.5px;color:var(--a600);margin-bottom:6px}
.detail-height-val{font-size:22px;font-weight:700;color:var(--a800);line-height:1}
.detail-height-unit{font-size:11px;color:var(--a600);font-weight:500;margin-top:2px}
.detail-avg-row{background:var(--g100);border:1px solid var(--g200);border-radius:var(--r-md);padding:12px 16px;display:flex;align-items:center;justify-content:space-between;margin-bottom:16px}
.detail-avg-label{font-size:13px;font-weight:600;color:var(--g700)}
.detail-avg-val{font-size:20px;font-weight:700;color:var(--g800)}
.detail-avg-unit{font-size:12px;color:var(--text3);margin-left:3px}

/* LIGHTBOX */
.lightbox{position:fixed;inset:0;background:rgba(0,0,0,.9);z-index:9000;display:none;align-items:center;justify-content:center}
.lightbox.open{display:flex}
.lightbox img{max-width:95vw;max-height:90vh;border-radius:var(--r-md);object-fit:contain}
.lightbox-close{position:absolute;top:16px;right:16px;width:36px;height:36px;border-radius:50%;background:rgba(255,255,255,.15);border:none;color:#fff;font-size:20px;display:flex;align-items:center;justify-content:center;cursor:pointer}

/* TOAST */
.toast{position:fixed;bottom:calc(var(--tab-h) + 16px);left:50%;transform:translateX(-50%) translateY(8px);background:var(--g900);color:#fff;padding:10px 20px;border-radius:var(--r-full);font-size:13px;font-weight:500;white-space:nowrap;opacity:0;pointer-events:none;z-index:9999;transition:all .28s ease;box-shadow:0 4px 16px rgba(0,0,0,.2)}
.toast.show{opacity:1;transform:translateX(-50%) translateY(0)}

/* MODAL */
.modal-overlay{position:fixed;inset:0;background:rgba(0,0,0,.45);z-index:300;display:flex;align-items:flex-end;justify-content:center;opacity:0;pointer-events:none;transition:opacity .25s}
.modal-overlay.show{opacity:1;pointer-events:all}
.modal-box{background:var(--white);border-radius:20px 20px 0 0;padding:20px 20px 32px;width:100%;max-width:480px;transform:translateY(20px);transition:transform .25s ease}
.modal-overlay.show .modal-box{transform:translateY(0)}
.modal-title{font-size:16px;font-weight:700;color:var(--text1);margin-bottom:8px}
.modal-msg{font-size:13px;color:var(--text3);margin-bottom:20px;line-height:1.5}
.modal-btns{display:grid;grid-template-columns:1fr 1fr;gap:10px}
.btn-modal-cancel{height:44px;border-radius:var(--r-md);background:var(--surface);border:1px solid var(--border2);color:var(--text2);font-size:14px;font-weight:600;font-family:'DM Sans',sans-serif;cursor:pointer}
.btn-modal-delete{height:44px;border-radius:var(--r-md);background:var(--danger-text);border:none;color:#fff;font-size:14px;font-weight:600;font-family:'DM Sans',sans-serif;cursor:pointer}

/* LOADING */
#loading-overlay{position:fixed;inset:0;background:rgba(0,0,0,.45);z-index:9998;display:flex;align-items:center;justify-content:center}
#loading-overlay.hidden{display:none !important}
.loading-box{background:#fff;border-radius:16px;padding:24px 32px;display:flex;flex-direction:column;align-items:center;gap:12px}
.loading-spinner{width:32px;height:32px;border:3px solid #e0f2e0;border-top-color:#1a4d1a;border-radius:50%;animation:lspin .7s linear infinite}
.loading-text{font-size:13px;font-weight:600;color:#3d5c3d;font-family:'DM Sans',sans-serif}
@keyframes lspin{to{transform:rotate(360deg)}}
.hidden{display:none !important}