 :root {
     --bg: #f0f2f5;
     --white: #fff;
     --surface: #f7f8fa;
     --border: #e3e7ef;
     --border2: #cdd3e0;
     --text: #1a1d2e;
     --dim: #5a6070;
     --muted: #9aa0b0;
     --blue: #1a6ef5;
     --blue-bg: #eef4ff;
     --blue-bd: #b8d4fd;
     --green: #0f9e5a;
     --green-bg: #edfaf3;
     --green-bd: #b3e8cf;
     --orange: #d06010;
     --orange-bg: #fff4e6;
     --orange-bd: #f5c880;
     --red: #c0304a;
     --red-bg: #fff0f3;
     --red-bd: #f5b8c4;
     --purple: #6030c0;
     --purple-bg: #f4effe;
     --purple-bd: #c8b0f0;
     --teal: #0080a0;
     --teal-bg: #e8f8ff;
     --teal-bd: #90d8f0;
     --brown: #806020;
     --brown-bg: #fdf6e8;
     --brown-bd: #e8d090;
     --photo: #2563eb;
     --photo-bg: #eff6ff;
     --photo-bd: #bfdbfe;
     --r: 10px;
     --sh: 0 2px 10px rgba(0, 0, 0, .06);
 }

 * {
     box-sizing: border-box;
     margin: 0;
     padding: 0;
 }

 body {
     font-family: 'Sarabun', sans-serif;
     background: var(--bg);
     color: var(--text);
     min-height: 100vh;
 }

 /* TANK GROUPS & PREMIUM NESTED UI */
 .tgroup {
     margin-bottom: 24px;
 }

 .tg-hd {
     padding: 12px 16px;
     display: flex;
     align-items: center;
     gap: 12px;
     cursor: pointer;
     margin-bottom: 12px;
 }

 .tg-hd.cen {
     border-left: 5px solid var(--purple);
 }

 .tg-hd.sep {
     border-left: 5px solid var(--blue);
 }

 .tg-hd.smp {
     border-left: 5px solid var(--orange);
 }

 .tg-hd.dec {
     border-left: 5px solid var(--green);
 }

 .tg-icon {
     font-size: 18px;
 }

 .tg-title {
     font-size: 15px;
     font-weight: 700;
     flex: 1;
     color: var(--text);
 }

 .tg-cnt {
     font-size: 11px;
     color: var(--muted);
     background: var(--white);
     padding: 2px 10px;
     border-radius: 99px;
     border: 1px solid var(--border);
 }

 .tg-arr {
     font-size: 10px;
     color: var(--muted);
     transition: transform 0.2s;
 }

 .tg-arr.open {
     transform: rotate(0deg);
 }

 .tg-body {
     display: flex;
     flex-direction: column;
     gap: 16px;
 }

 /* TANK UNIT (THE OUTER FRAME) */
 .tank-unit {
     background: var(--white);
     border-radius: 24px;
     border: 1px solid var(--border);
     padding: 20px;
     box-shadow: 0 10px 25px rgba(0, 0, 0, 0.05);
     margin-bottom: 20px;
 }

 .tank-main-info {
     margin-bottom: 16px;
 }

 .tm-title-row {
     display: flex;
     justify-content: space-between;
     align-items: center;
     margin-bottom: 4px;
 }

 .tm-tank-id {
     font-family: 'JetBrains Mono';
     font-size: 12px;
     font-weight: 700;
     color: var(--blue);
     text-transform: uppercase;
 }

 .tm-tank-name {
     font-size: 18px;
     font-weight: 800;
     color: var(--text);
     margin: 0;
 }

 .btn-icon-xs {
     background: var(--surface);
     color: var(--dim);
     border: 1px solid var(--border);
     width: 34px;
     height: 34px;
     border-radius: 12px;
     display: flex;
     align-items: center;
     justify-content: center;
     font-size: 16px;
     cursor: pointer;
     transition: all 0.2s;
 }

 .btn-icon-xs:hover {
     background: #e2e8f0;
     transform: scale(1.1);
 }

 .add-zone-btn {
     width: 100%;
     padding: 10px;
     background: #f8fafc;
     border: 1px dashed #cbd5e1;
     border-radius: 10px;
     color: var(--blue);
     font-size: 13px;
     font-weight: 600;
     cursor: pointer;
     display: flex;
     align-items: center;
     justify-content: center;
     gap: 8px;
     transition: all 0.2s;
     margin-top: 5px;
 }

 .add-zone-btn:hover {
     background: #f1f5f9;
     border-color: var(--blue);
     transform: translateY(-1px);
 }

 .tm-subtitle {
     font-size: 13px;
     color: var(--dim);
     margin: 4px 0 12px;
     display: flex;
     align-items: center;
     gap: 6px;
 }

 .tm-photos {
     display: grid;
     grid-template-columns: 1fr 1fr;
     gap: 10px;
     margin: 12px 0;
 }

 .tm-photos img {
     width: 100%;
     aspect-ratio: 4/3;
     object-fit: cover;
     border-radius: 16px;
     border: 1px solid var(--border);
     cursor: zoom-in;
     transition: transform 0.2s;
 }

 .tm-photos img:only-child {
     grid-column: span 2;
     aspect-ratio: 16/9;
 }

 /* ZONE ROW (THE INNER DATA - NESTED STYLE) */
 .tank-zones-list {
     background: var(--surface);
     border-radius: 18px;
     padding: 8px;
     border: 1px solid var(--border);
 }

 .zi-row {
     background: var(--white);
     border-radius: 12px;
     padding: 12px;
     display: flex;
     align-items: center;
     gap: 12px;
     margin-bottom: 6px;
     cursor: pointer;
     transition: all 0.2s;
     border: 1px solid transparent;
 }

 .zi-row:last-child {
     margin-bottom: 0;
 }

 .zi-row:hover {
     border-color: var(--blue-bd);
     transform: translateX(4px);
     box-shadow: 0 4px 12px rgba(0, 0, 0, 0.03);
 }

 .zi-icon-box {
     width: 40px;
     height: 40px;
     background: var(--surface);
     border: 1px solid var(--border);
     border-radius: 10px;
     display: flex;
     align-items: center;
     justify-content: center;
     font-size: 12px;
     font-weight: 800;
     color: var(--blue);
     font-family: 'JetBrains Mono';
     flex-shrink: 0;
 }

 .nav {
     background: var(--white);
     border-bottom: 1px solid var(--border);
     padding: 0 16px;
     display: flex;
     align-items: center;
     gap: 10px;
     height: 50px;
     position: sticky;
     top: 0;
     z-index: 300;
     box-shadow: 0 1px 4px rgba(0, 0, 0, .05);
 }

 .nav-logo {
     width: 28px;
     height: 28px;
     background: linear-gradient(135deg, #1a6ef5, #6030c0);
     border-radius: 7px;
     display: flex;
     align-items: center;
     justify-content: center;
     font-size: 14px;
 }

 .nav-title {
     font-size: 14px;
     font-weight: 700;
     flex: 1;
 }

 .nav-right {
     display: flex;
     gap: 6px;
     align-items: center;
 }

 .nav-badge {
     font-size: 10px;
     font-weight: 700;
     background: var(--blue-bg);
     color: var(--blue);
     padding: 3px 8px;
     border-radius: 5px;
     cursor: pointer;
 }

 .nav-badge:hover {
     background: var(--blue);
     color: #fff;
 }

 .bc {
     padding: 8px 16px;
     font-size: 11px;
     color: var(--muted);
     display: flex;
     align-items: center;
     gap: 5px;
     flex-wrap: wrap;
 }

 .bc span {
     cursor: pointer;
     transition: color .1s;
 }

 .bc span:hover {
     color: var(--blue);
 }

 .bc span.cur {
     color: var(--text);
     font-weight: 600;
     cursor: default;
 }

 .bc-sep {
     color: var(--border2);
 }

 /* FAB & MODAL STYLES */
 .fab {
     position: fixed;
     right: 20px;
     bottom: 30px;
     width: 56px;
     height: 56px;
     background: linear-gradient(135deg, var(--blue), #124bab);
     color: white;
     border-radius: 50%;
     display: flex;
     align-items: center;
     justify-content: center;
     font-size: 28px;
     box-shadow: 0 4px 15px rgba(26, 110, 245, 0.4);
     cursor: pointer;
     z-index: 999;
     transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
     border: none;
     outline: none;
 }

 .fab:hover {
     transform: scale(1.1);
     box-shadow: 0 6px 20px rgba(26, 110, 245, 0.5);
 }

 .fab:active {
     transform: scale(0.95);
 }

 .modal-overlay {
     position: fixed;
     top: 0;
     left: 0;
     width: 100%;
     height: 100%;
     background: rgba(0, 0, 0, 0.6);
     backdrop-filter: blur(4px);
     z-index: 2000;
     display: none;
     align-items: center;
     justify-content: center;
 }

 .modal-overlay.on {
     display: flex;
 }

 .modal-content {
     background: var(--white);
     width: 90%;
     max-width: 500px;
     border-radius: 24px;
     padding: 24px;
     animation: zoomIn 0.3s ease-out;
     max-height: 90vh;
     overflow-y: auto;
 }

 @keyframes slideUp {
     from {
         transform: translateY(100%);
     }

     to {
         transform: translateY(0);
     }
 }

 .form-group {
     margin-bottom: 16px;
 }

 .form-label {
     font-size: 13px;
     font-weight: 700;
     color: var(--text);
     margin-bottom: 6px;
     display: block;
 }

 .form-input,
 .form-select {
     width: 100%;
     padding: 12px;
     border-radius: 12px;
     border: 1.5px solid var(--border);
     font-family: inherit;
     font-size: 14px;
     outline: none;
     transition: border-color 0.2s;
 }

 .form-input:focus,
 .form-select:focus {
     border-color: var(--blue);
 }

 .form-input[readonly] {
     background: var(--surface);
     color: var(--muted);
     cursor: not-allowed;
 }

 .photo-slots {
     display: grid;
     grid-template-columns: 1fr 1fr;
     gap: 12px;
     margin-top: 10px;
 }

 .photo-box {
     background: var(--surface);
     border: 2px dashed var(--border);
     border-radius: 12px;
     aspect-ratio: 1;
     display: flex;
     flex-direction: column;
     align-items: center;
     justify-content: center;
     cursor: pointer;
     position: relative;
     overflow: hidden;
 }

 .photo-box img {
     width: 100%;
     height: 100%;
     object-fit: cover;
 }

 .photo-box .btn-del {
     position: absolute;
     top: 4px;
     right: 4px;
     background: rgba(0, 0, 0, 0.5);
     color: white;
     border: none;
     width: 24px;
     height: 24px;
     border-radius: 50%;
     display: flex;
     align-items: center;
     justify-content: center;
     font-size: 12px;
 }

 .btn-confirm {
     width: 100%;
     background: var(--blue);
     color: white;
     border: none;
     padding: 14px;
     border-radius: 14px;
     font-family: inherit;
     font-weight: 700;
     font-size: 15px;
     margin-top: 20px;
     cursor: pointer;
     box-shadow: 0 4px 12px rgba(26, 110, 245, 0.2);
 }

 .btn-confirm:disabled {
     opacity: 0.6;
     cursor: not-allowed;
 }

 .btn-cancel {
     width: 100%;
     background: #fff;
     color: var(--muted);
     border: 1.5px solid var(--border);
     padding: 12px;
     border-radius: 14px;
     font-family: inherit;
     font-weight: 700;
     font-size: 14px;
     margin-top: 10px;
     cursor: pointer;
     transition: all 0.2s;
 }

 .btn-cancel:hover {
     background: var(--bg);
     color: var(--text);
 }

 .btn-delete {
     width: auto;
     background: #fff;
     color: var(--red);
     border: 1px solid var(--red-bd);
     padding: 6px 12px;
     border-radius: 10px;
     font-family: inherit;
     font-weight: 700;
     font-size: 12px;
     cursor: pointer;
     transition: all 0.2s;
     display: none;
     /* ซ่อนไว้ก่อน จะโชว์เฉพาะตอน Edit */
 }

 .btn-delete:hover {
     background: var(--red-bg);
     border-color: var(--red);
 }

 /* PHOTO LIGHTBOX */
 .photo-lightbox {
     position: fixed;
     top: 0;
     left: 0;
     width: 100%;
     height: 100%;
     background: rgba(0, 0, 0, 0.9);
     backdrop-filter: blur(8px);
     z-index: 3000;
     display: none;
     align-items: center;
     justify-content: center;
     cursor: zoom-out;
     animation: fadeIn 0.3s ease;
 }

 .photo-lightbox.on {
     display: flex;
 }

 .photo-lightbox img {
     max-width: 95%;
     max-height: 95%;
     border-radius: 12px;
     box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
     object-fit: contain;
     animation: zoomIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
 }

 @keyframes fadeIn {
     from {
         opacity: 0;
     }

     to {
         opacity: 1;
     }
 }

 @keyframes zoomIn {
     from {
         transform: scale(0.8);
         opacity: 0;
     }

     to {
         transform: scale(1);
         opacity: 1;
     }
 }

 .close-lightbox {
     position: absolute;
     top: 20px;
     right: 20px;
     width: 40px;
     height: 40px;
     background: rgba(255, 255, 255, 0.2);
     color: white;
     border: none;
     border-radius: 50%;
     display: flex;
     align-items: center;
     justify-content: center;
     font-size: 20px;
     cursor: pointer;
     transition: background 0.2s;
 }

 .close-lightbox:hover {
     background: rgba(255, 255, 255, 0.4);
 }

 .search-box {
     margin-top: 8px;
     cursor: pointer;
 }

 .page {
     display: none;
     padding: 0 14px 90px;
     max-width: 620px;
     margin: 0 auto;
 }

 .page.on {
     display: block;
 }

 /* SEARCH */
 .hero {
     background: linear-gradient(135deg, #12306a, #1a6ef5);
     border-radius: var(--r);
     padding: 20px 16px;
     margin: 12px 0 14px;
     color: #fff;
     position: relative;
     /* 🚀 เพื่อให้โลโก้วางตำแหน่ง absolute ได้ */
     overflow: hidden;
     /* 🚀 กันโลโก้หลุดขอบ */
 }

 .hero h2 {
     font-size: 17px;
     font-weight: 700;
     margin-bottom: 3px;
 }

 .hero p {
     font-size: 12px;
     opacity: .7;
     margin-bottom: 14px;
 }

 .sbox {
     display: flex;
     gap: 8px;
 }

 .sinput {
     flex: 1;
     background: rgba(255, 255, 255, .15);
     border: 1.5px solid rgba(255, 255, 255, .3);
     border-radius: 8px;
     color: #fff;
     font-family: inherit;
     font-size: 13px;
     padding: 9px 12px;
     outline: none;
 }

 .sinput::placeholder {
     color: rgba(255, 255, 255, .55);
 }

 .sbtn {
     background: #fff;
     color: var(--blue);
     border: none;
     border-radius: 8px;
     padding: 9px 16px;
     font-family: inherit;
     font-size: 12px;
     font-weight: 700;
     cursor: pointer;
 }

 .stitle {
     font-size: 10px;
     font-weight: 700;
     text-transform: uppercase;
     letter-spacing: .07em;
     color: var(--muted);
     margin: 16px 0 8px;
     display: flex;
     align-items: center;
     gap: 6px;
 }

 .stitle::after {
     content: '';
     flex: 1;
     height: 1px;
     background: var(--border);
 }

 .rcard {
     background: var(--white);
     border: 1.5px solid var(--border);
     border-radius: var(--r);
     padding: 12px 14px;
     margin-bottom: 9px;
     cursor: pointer;
     transition: all .15s;
     box-shadow: var(--sh);
 }

 .rcard:hover {
     border-color: var(--blue);
     transform: translateY(-1px);
 }

 .rcard-top {
     display: flex;
     align-items: center;
     justify-content: space-between;
     margin-bottom: 7px;
 }

 .rcard-name {
     font-size: 13px;
     font-weight: 700;
 }

 .pbl {
     font-family: 'JetBrains Mono';
     font-size: 10px;
     color: var(--blue);
     background: var(--blue-bg);
     padding: 2px 7px;
     border-radius: 4px;
     border: 1px solid var(--blue-bd);
 }

 .rtags {
     display: flex;
     gap: 5px;
     flex-wrap: wrap;
 }

 .tag {
     display: inline-flex;
     align-items: center;
     gap: 3px;
     padding: 2px 8px;
     border-radius: 5px;
     font-size: 10px;
     font-weight: 700;
 }

 .tag.cen {
     background: var(--purple-bg);
     color: var(--purple);
 }

 .tag.dec {
     background: var(--green-bg);
     color: var(--green);
 }

 .tag.brand {
     background: var(--brown-bg);
     color: var(--brown);
 }

 .tag.cnt {
     background: var(--surface);
     color: var(--dim);
     border: 1px solid var(--border);
 }

 .rmeta {
     font-size: 10px;
     color: var(--muted);
     margin-top: 5px;
 }

 /* STATION */
 .stn-card {
     background: var(--white);
     border-radius: var(--r);
     border: 1px solid var(--border);
     padding: 14px;
     margin: 10px 0;
     box-shadow: var(--sh);
 }

 .stn-top {
     display: flex;
     align-items: flex-start;
     justify-content: space-between;
     gap: 10px;
     margin-bottom: 10px;
 }

 .stn-name {
     font-size: 15px;
     font-weight: 700;
 }

 .stn-grid {
     display: grid;
     grid-template-columns: 1fr 1fr;
     gap: 8px;
 }

 .stn-kv {
     display: flex;
     flex-direction: column;
     gap: 2px;
 }

 .stn-k {
     font-size: 9px;
     font-weight: 700;
     text-transform: uppercase;
     letter-spacing: .05em;
     color: var(--muted);
 }

 .stn-v {
     font-size: 12px;
     font-weight: 600;
 }

 /* 🚀 PTT THEME FOR STATION CARD */
 .stn-card.ptt-theme {
     border: 1px solid #cce1f1;
     padding: 0;
     box-shadow: 0 4px 16px rgba(0, 94, 184, 0.15);
     border-radius: 12px;
     overflow: hidden;
     background: var(--white);
     margin-bottom: 20px;
 }

 .stn-card.ptt-theme .stn-top {
     background: linear-gradient(135deg, #005eb8 0%, #004b93 100%);
     border-bottom: 4px solid #d31145;
     padding: 16px;
     margin-bottom: 0;
 }

 .stn-card.ptt-theme .stn-name {
     color: #ffffff;
     font-size: 15px;
 }

 .stn-card.ptt-theme .pbl {
     background: rgba(255, 255, 255, 0.2);
     color: #ffffff;
     border: 1px solid rgba(255, 255, 255, 0.5);
 }

 .stn-card.ptt-theme .stn-grid {
     padding: 16px 16px 4px 16px;
     background: #ffffff;
 }

 .stn-card.ptt-theme .stn-v {
     color: #005eb8;
     font-size: 14px;
     font-weight: 800;
 }

 .two-opt {
     display: grid;
     grid-template-columns: 1fr 1fr;
     gap: 10px;
     margin: 0 0 14px;
 }

 .opt-card {
     background: var(--white);
     border: 1.5px solid var(--border);
     border-radius: var(--r);
     padding: 14px;
     text-align: center;
     cursor: pointer;
     transition: all .15s;
     box-shadow: var(--sh);
 }

 .opt-card:hover {
     border-color: var(--blue);
     background: var(--blue-bg);
 }

 .opt-icon {
     font-size: 24px;
     margin-bottom: 5px;
 }

 .opt-label {
     font-size: 12px;
     font-weight: 700;
 }

 .opt-sub {
     font-size: 10px;
     color: var(--dim);
     margin-top: 2px;
 }

 .pm-row {
     background: var(--white);
     border: 1px solid var(--border);
     border-radius: 8px;
     padding: 9px 12px;
     display: flex;
     align-items: center;
     justify-content: space-between;
     margin-bottom: 6px;
 }

 .pm-left {
     display: flex;
     align-items: center;
     gap: 7px;
 }

 .pm-round {
     font-family: 'JetBrains Mono';
     font-size: 10px;
     font-weight: 700;
     background: var(--blue-bg);
     color: var(--blue);
     padding: 2px 7px;
     border-radius: 4px;
 }

 .pm-date {
     font-size: 11px;
     color: var(--dim);
 }

 .pm-right {
     display: flex;
     gap: 10px;
 }

 .pm-stat {
     display: flex;
     flex-direction: column;
     align-items: center;
     font-size: 9px;
     color: var(--muted);
 }

 .pm-val {
     font-size: 13px;
     font-weight: 700;
 }

 .ok {
     color: var(--green);
 }

 .warn {
     color: var(--orange);
 }

 .fail {
     color: var(--red);
 }

 /* TANK GROUPS */
 .tgroup {
     background: var(--white);
     border-radius: var(--r);
     border: 1.5px solid var(--border);
     margin-bottom: 10px;
     overflow: hidden;
     box-shadow: var(--sh);
 }

 .tg-hd {
     padding: 11px 14px;
     display: flex;
     align-items: center;
     gap: 9px;
     cursor: pointer;
     transition: background .12s;
 }

 .tg-hd:hover {
     background: var(--surface);
 }

 .tg-hd.cen {
     border-left: 4px solid var(--purple);
 }

 .tg-hd.dec {
     border-left: 4px solid var(--green);
 }

 .tg-hd.sep {
     border-left: 4px solid var(--brown);
 }

 .tg-hd.smp {
     border-left: 4px solid var(--orange);
 }

 .tg-icon {
     font-size: 16px;
 }

 .tg-title {
     font-size: 12px;
     font-weight: 700;
     flex: 1;
 }

 .tg-cnt {
     font-size: 10px;
     color: var(--muted);
     background: var(--bg);
     padding: 2px 7px;
     border-radius: 99px;
     border: 1px solid var(--border);
 }

 .tg-arr {
     font-size: 11px;
     color: var(--muted);
     transition: transform .2s;
 }

 .tg-arr.open {
     transform: rotate(90deg);
 }

 .tg-body {
     padding: 8px 12px;
     display: flex;
     flex-direction: column;
     gap: 7px;
 }

 .zitem {
     background: var(--surface);
     border: 1px solid var(--border);
     border-radius: 8px;
     padding: 9px 11px;
     display: flex;
     align-items: center;
     gap: 9px;
     cursor: pointer;
     transition: all .15s;
 }

 .zitem:hover {
     border-color: var(--blue);
     background: var(--blue-bg);
 }

 .zi-num {
     width: 26px;
     height: 26px;
     border-radius: 6px;
     background: var(--white);
     border: 1.5px solid var(--border);
     display: flex;
     align-items: center;
     justify-content: center;
     font-size: 10px;
     font-weight: 700;
     font-family: 'JetBrains Mono';
     color: var(--dim);
     flex-shrink: 0;
 }

 .zi-info {
     flex: 1;
 }

 .zi-name {
     font-size: 12px;
     font-weight: 700;
 }

 .zi-sub {
     font-size: 10px;
     color: var(--dim);
 }

 .zi-st {
     font-size: 10px;
     padding: 2px 7px;
     border-radius: 99px;
     font-weight: 700;
 }

 .zi-st.ok {
     background: var(--green-bg);
     color: var(--green);
 }

 .zi-st.warn {
     background: var(--orange-bg);
     color: var(--orange);
 }

 .zi-arr {
     color: var(--muted);
     font-size: 12px;
 }

 /* ZONE DETAIL */
 .zone-hd {
     background: var(--white);
     border-radius: var(--r);
     border: 1px solid var(--border);
     padding: 12px 14px;
     margin: 10px 0;
     box-shadow: var(--sh);
 }

 .zh-top {
     display: flex;
     align-items: center;
     gap: 8px;
     margin-bottom: 8px;
 }

 /* 🚀 PTT THEME FOR ZONE HD */
 .zone-hd.ptt-theme {
     border: 1px solid #cce1f1;
     padding: 0;
     box-shadow: 0 4px 16px rgba(0, 94, 184, 0.15);
     border-radius: 12px;
     background: var(--white);
     overflow: hidden;
 }

 .zone-hd.ptt-theme .zh-top {
     background: linear-gradient(135deg, #0d47a1 0%, #002171 100%);
     border-bottom: 4px solid #d31145;
     padding: 16px;
     margin-bottom: 0;
 }

 .zone-hd.ptt-theme .zh-name,
 .zone-hd.ptt-theme .zh-icon {
     color: #ffffff;
 }

 .zone-hd.ptt-theme .pills {
     padding: 16px;
     margin: 0;
     background: #ffffff;
 }

 .zone-hd.ptt-theme .zh-size {
     background: rgba(255, 255, 255, 0.2);
     color: #ffffff;
     border: 1px solid rgba(255, 255, 255, 0.5);
     font-size: 13px;
     padding: 4px 10px;
     border-radius: 8px;
 }

 .zh-icon {
     font-size: 20px;
 }

 .zh-name {
     font-size: 14px;
     font-weight: 700;
     flex: 1;
 }

 .zh-size {
     font-family: 'JetBrains Mono';
     font-size: 11px;
     color: var(--dim);
     background: var(--surface);
     padding: 3px 8px;
     border-radius: 5px;
     border: 1px solid var(--border);
 }

 .pills {
     display: flex;
     gap: 6px;
     flex-wrap: wrap;
     margin: 8px 0;
 }

 .ipill {
     display: inline-flex;
     align-items: center;
     gap: 5px;
     font-size: 11px;
     color: var(--dim);
     background: var(--surface);
     border: 1px solid var(--border);
     border-radius: 6px;
     padding: 3px 9px;
 }

 .ipill strong {
     color: var(--text);
 }

 .prev-box {
     background: var(--surface);
     border: 1px solid var(--border);
     border-radius: 8px;
     padding: 9px 12px;
     margin-bottom: 10px;
 }

 .prev-label {
     font-size: 9px;
     font-weight: 700;
     text-transform: uppercase;
     letter-spacing: .05em;
     color: var(--muted);
     margin-bottom: 6px;
 }

 .prev-row {
     display: flex;
     align-items: center;
     justify-content: space-between;
     font-size: 11px;
     padding: 3px 0;
     border-bottom: 1px solid var(--border);
 }

 .prev-row:last-child {
     border-bottom: none;
 }

 .prev-name {
     color: var(--dim);
 }

 .prev-st {
     font-size: 10px;
     font-weight: 700;
 }

 .prev-st.ok {
     color: var(--green);
 }

 .prev-st.warn {
     color: var(--orange);
 }

 .prev-st.fail {
     color: var(--red);
 }

 /* EQUIP CARD */
 .ecard {
     background: var(--white);
     border-radius: var(--r);
     border: 1.5px solid var(--border);
     margin-bottom: 10px;
     overflow: hidden;
     box-shadow: var(--sh);
 }

 .ec-hd {
     padding: 10px 13px;
     border-bottom: 1px solid var(--border);
     display: flex;
     align-items: center;
     gap: 8px;
 }

 .ec-hd.eq {
     border-left: 4px solid var(--blue);
     background: var(--blue-bg);
 }

 .ec-hd.aer {
     border-left: 4px solid var(--green);
     background: var(--green-bg);
 }

 .ec-hd.sed {
     border-left: 4px solid var(--orange);
     background: var(--orange-bg);
 }

 .ec-hd.sep {
     border-left: 4px solid var(--brown);
     background: var(--brown-bg);
 }

 .ec-hd.smp {
     border-left: 4px solid var(--teal);
     background: var(--teal-bg);
 }

 .ec-icon {
     font-size: 16px;
 }

 .ec-title {
     font-size: 12px;
     font-weight: 700;
     flex: 1;
 }

 .ec-body {
     padding: 10px 12px;
     display: flex;
     flex-direction: column;
     gap: 8px;
 }

 .col-hdr {
     display: grid;
     grid-template-columns: 1fr 90px 90px 24px;
     gap: 7px;
     padding: 0 9px 4px;
     font-size: 9px;
     font-weight: 700;
     text-transform: uppercase;
     letter-spacing: .05em;
     color: var(--muted);
 }

 .erow {
     display: grid;
     grid-template-columns: 1fr 90px 90px 24px;
     gap: 7px;
     align-items: center;
     padding: 7px 9px;
     background: var(--surface);
     border: 1px solid var(--border);
     border-radius: 7px;
 }

 .er-name {
     font-size: 11px;
     font-weight: 700;
 }

 .er-code {
     font-family: 'JetBrains Mono';
     font-size: 9px;
     color: var(--muted);
 }

 .einput {
     background: var(--white);
     border: 1px solid var(--border);
     border-radius: 5px;
     padding: 5px 6px;
     font-family: 'JetBrains Mono';
     font-size: 11px;
     color: var(--text);
     outline: none;
     text-align: center;
     width: 100%;
 }

 .einput:focus {
     border-color: var(--blue);
 }

 .esel {
     background: var(--white);
     border: 1px solid var(--border);
     border-radius: 5px;
     padding: 5px 4px;
     font-family: inherit;
     font-size: 10px;
     font-weight: 600;
     outline: none;
     color: var(--text);
     width: 100%;
 }

 .esel:focus {
     border-color: var(--blue);
 }

 .edel {
     background: none;
     border: none;
     color: var(--muted);
     cursor: pointer;
     font-size: 13px;
     padding: 0;
 }

 .edel:hover {
     color: var(--red);
 }

 .add-btn {
     display: flex;
     align-items: center;
     gap: 5px;
     background: none;
     border: 1.5px dashed var(--border2);
     border-radius: 7px;
     padding: 7px 10px;
     font-family: inherit;
     font-size: 11px;
     font-weight: 600;
     color: var(--muted);
     cursor: pointer;
     width: 100%;
     transition: all .15s;
 }

 .add-btn:hover {
     border-color: var(--blue);
     color: var(--blue);
     background: var(--blue-bg);
 }

 /* ══ PHOTO SECTION ══ */
 .photo-section {
     background: var(--white);
     border-radius: var(--r);
     border: 1.5px solid var(--photo-bd);
     margin-bottom: 10px;
     overflow: hidden;
     box-shadow: var(--sh);
 }

 .ph-hd {
     padding: 9px 13px;
     border-bottom: 1px solid var(--photo-bd);
     display: flex;
     align-items: center;
     gap: 8px;
     background: var(--photo-bg);
 }

 .ph-hd-title {
     font-size: 12px;
     font-weight: 700;
     color: var(--photo);
     flex: 1;
 }

 /* 🚀 PTT THEME FOR PHOTO SECTION */
 .photo-section.ptt-theme {
     border: 1px solid #cce1f1;
     border-radius: 12px;
     box-shadow: 0 4px 16px rgba(0, 94, 184, 0.15);
     overflow: hidden;
 }

 .photo-section.ptt-theme .ph-hd {
     background: linear-gradient(135deg, #0d47a1 0%, #002171 100%);
     border-bottom: 4px solid #d31145;
 }

 .photo-section.ptt-theme .ph-hd-title {
     color: #ffffff;
     font-size: 14px;
 }

 .ph-body {
     padding: 12px;
 }

 .ph-grid {
     display: grid;
     grid-template-columns: 1fr 1fr;
     gap: 8px;
     margin-bottom: 10px;
 }

 .ph-thumb {
     aspect-ratio: 4/3;
     border-radius: 8px;
     background: var(--surface);
     border: 1.5px solid var(--border);
     display: flex;
     flex-direction: column;
     align-items: center;
     justify-content: center;
     gap: 4px;
     position: relative;
     overflow: hidden;
     cursor: pointer;
     transition: border-color .15s;
 }

 .ph-thumb:hover {
     border-color: var(--photo);
 }

 .ph-thumb.filled {
     border-color: var(--photo-bd);
     background: var(--photo-bg);
 }

 .ph-thumb-icon {
     font-size: 22px;
 }

 .ph-thumb-label {
     font-size: 10px;
     color: var(--muted);
 }

 .ph-thumb.filled .ph-thumb-label {
     color: var(--photo);
     font-weight: 600;
 }

 .ph-delete {
     position: absolute;
     top: 5px;
     right: 5px;
     background: rgba(192, 48, 74, .85);
     color: #fff;
     border: none;
     border-radius: 4px;
     width: 20px;
     height: 20px;
     font-size: 11px;
     cursor: pointer;
     display: flex;
     align-items: center;
     justify-content: center;
 }

 /* upload zone */
 .ph-upload {
     border: 2px dashed var(--photo-bd);
     border-radius: 8px;
     padding: 14px;
     text-align: center;
     cursor: pointer;
     transition: all .15s;
     background: var(--photo-bg);
 }

 .ph-upload:hover {
     border-color: var(--photo);
     background: var(--photo-bg);
 }

 .ph-upload-icon {
     font-size: 24px;
     margin-bottom: 4px;
 }

 .ph-upload-label {
     font-size: 11px;
     color: var(--photo);
     font-weight: 600;
 }

 .ph-upload-sub {
     font-size: 10px;
     color: var(--muted);
     margin-top: 2px;
 }

 /* inline photo in equip row */
 .equip-photo-row {
     display: flex;
     align-items: center;
     gap: 8px;
     padding: 6px 9px;
     background: var(--photo-bg);
     border: 1px solid var(--photo-bd);
     border-radius: 7px;
 }

 .ep-label {
     font-size: 10px;
     color: var(--photo);
     font-weight: 600;
     flex: 1;
 }

 .ep-thumb {
     width: 40px;
     height: 40px;
     border-radius: 6px;
     background: var(--surface);
     border: 1px solid var(--border);
     display: flex;
     align-items: center;
     justify-content: center;
     font-size: 18px;
     cursor: pointer;
     overflow: hidden;
     flex-shrink: 0;
 }

 .ep-thumb.filled {
     background: var(--photo-bg);
     border-color: var(--photo-bd);
 }

 .ep-add {
     font-size: 10px;
     color: var(--muted);
     cursor: pointer;
     background: var(--white);
     border: 1px dashed var(--border2);
     border-radius: 5px;
     padding: 5px 8px;
     font-family: inherit;
     font-weight: 600;
     transition: all .15s;
 }

 .ep-add:hover {
     color: var(--photo);
     border-color: var(--photo);
 }

 /* WQ */
 .wq-meta {
     background: var(--white);
     border-radius: var(--r);
     border: 1px solid var(--border);
     padding: 12px 14px;
     margin: 10px 0;
     box-shadow: var(--sh);
 }

 .wq-meta-top {
     display: flex;
     align-items: center;
     justify-content: space-between;
     margin-bottom: 10px;
 }

 .wq-title {
     font-size: 14px;
     font-weight: 700;
 }

 .wq-round {
     font-family: 'JetBrains Mono';
     font-size: 11px;
     font-weight: 700;
     color: var(--blue);
     background: var(--blue-bg);
     padding: 3px 9px;
     border-radius: 5px;
 }

 .wq-row {
     display: flex;
     align-items: center;
     gap: 8px;
     flex-wrap: wrap;
 }

 .date-box {
     background: var(--white);
     padding: 8px 12px;
     border-radius: 10px;
     border: 1px solid var(--border);
     box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05);
     display: flex;
     align-items: center;
     gap: 10px;
     position: relative;
     cursor: pointer;
 }

 .date-box:active {
     transform: scale(0.98);
 }

 .dinput-overlay {
     position: absolute;
     top: 0;
     left: 0;
     width: 100%;
     height: 100%;
     opacity: 0;
     cursor: pointer;
     z-index: 10;
 }

 .dinput:focus {
     border-color: var(--blue);
 }

 /* 🚀 ขยายจุดรับการจิ้มล่องหนให้เต็มพื้นที่ 100% */
 #wq-inspect-date {
     appearance: none !important;
     -webkit-appearance: none !important;
 }

 #wq-inspect-date::-webkit-calendar-picker-indicator {
     position: absolute !important;
     top: 0 !important;
     left: 0 !important;
     width: 100% !important;
     height: 100% !important;
     margin: 0 !important;
     padding: 0 !important;
     cursor: pointer !important;
     opacity: 0 !important;
     /* ล่องหนแต่จิ้มติดทั้งกล่อง */
 }

 .global-notice {
     background: var(--blue-bg);
     border: 1px solid var(--blue-bd);
     border-radius: 8px;
     padding: 9px 12px;
     display: flex;
     align-items: center;
     gap: 8px;
     font-size: 11px;
     color: var(--blue);
     margin-bottom: 12px;
 }

 .gn-edit {
     margin-left: auto;
     font-weight: 700;
     cursor: pointer;
     text-decoration: underline;
     white-space: nowrap;
 }

 .pgrid {
     display: flex;
     flex-direction: column;
     gap: 7px;
 }

 .pcard {
     background: var(--white);
     border: 1.5px solid var(--border);
     border-radius: 12px;
     padding: 12px 14px;
     display: grid;
     grid-template-columns: 1.2fr 90px 90px 32px;
     gap: 10px;
     align-items: center;
     box-shadow: 0 2px 4px rgba(0, 0, 0, 0.02);
 }

 .pcard.pass {
     border-color: var(--green-bd);
     background: var(--green-bg);
 }

 .pcard.fail {
     border-color: var(--red-bd);
     background: var(--red-bg);
 }

 .pc-name {
     font-size: 16px;
     font-weight: 800;
     color: var(--text);
 }

 .pc-unit {
     font-size: 11px;
     color: var(--muted);
     font-family: 'JetBrains Mono';
     font-weight: 600;
 }

 .pc-val {
     background: var(--white);
     border: 1.5px solid var(--border);
     border-radius: 8px;
     padding: 6px 7px;
     font-family: 'JetBrains Mono';
     font-size: 14px;
     font-weight: 700;
     text-align: center;
     outline: none;
     color: var(--text);
     width: 100%;
     height: 34px;
 }

 .pc-val:focus {
     border-color: var(--blue);
 }

 .pc-input-group,
 .pc-thr-group {
     display: flex;
     flex-direction: column;
     align-items: center;
     gap: 3px;
 }

 .pc-label {
     font-size: 10px;
     font-weight: 800;
     color: var(--muted);
     text-transform: uppercase;
     letter-spacing: 0.5px;
 }

 .pc-thr-label {
     font-size: 10px;
     font-weight: 800;
     color: var(--muted);
     text-transform: uppercase;
     letter-spacing: 0.5px;
 }

 .pc-thr-val {
     font-family: 'JetBrains Mono';
     font-size: 13px;
     font-weight: 700;
     color: var(--dim);
     background: var(--surface);
     border: 1.5px solid var(--border);
     border-radius: 8px;
     padding: 6px 4px;
     text-align: center;
     width: 100%;
     min-height: 34px;
     display: flex;
     align-items: center;
     justify-content: center;
 }

 .pc-badge {
     width: 28px;
     height: 28px;
     border-radius: 50%;
     display: flex;
     align-items: center;
     justify-content: center;
     font-size: 13px;
     font-weight: 700;
 }

 .pc-badge.pass {
     background: var(--green);
     color: #fff;
 }

 .pc-badge.fail {
     background: var(--red);
     color: #fff;
 }

 .result-summary {
     border-radius: 9px;
     padding: 11px 13px;
     display: flex;
     align-items: center;
     gap: 10px;
     margin-top: 10px;
 }

 .result-summary.fail {
     background: var(--red-bg);
     border: 1px solid var(--red-bd);
 }

 .result-summary.pass {
     background: var(--green-bg);
     border: 1px solid var(--green-bd);
 }

 /* SETTINGS */
 .settings-notice {
     background: var(--orange-bg);
     border: 1px solid var(--orange-bd);
     border-radius: 8px;
     padding: 9px 12px;
     font-size: 11px;
     color: var(--orange);
     display: flex;
     align-items: center;
     gap: 8px;
     margin-bottom: 12px;
 }

 .thr-card {
     background: var(--white);
     border-radius: var(--r);
     border: 1px solid var(--border);
     padding: 14px;
     box-shadow: var(--sh);
 }

 .thr-row {
     display: grid;
     grid-template-columns: 1fr auto auto;
     gap: 10px;
     align-items: center;
     padding: 8px 0;
     border-bottom: 1px solid var(--border);
 }

 .thr-row:last-child {
     border-bottom: none;
 }

 .thr-name {
     font-size: 13px;
     font-weight: 700;
 }

 .thr-unit {
     font-size: 10px;
     color: var(--muted);
     font-family: 'JetBrains Mono';
 }

 .thr-type {
     font-size: 10px;
     color: var(--dim);
 }

 .thr-input {
     background: var(--surface);
     border: 1.5px solid var(--border);
     border-radius: 6px;
     padding: 6px 9px;
     font-family: 'JetBrains Mono';
     font-size: 13px;
     font-weight: 700;
     text-align: center;
     outline: none;
     color: var(--text);
     width: 75px;
 }

 .thr-input:focus {
     border-color: var(--orange);
 }

 /* BTNS */
 .btn {
     display: inline-flex;
     align-items: center;
     gap: 5px;
     padding: 9px 18px;
     border-radius: 7px;
     font-family: inherit;
     font-size: 12px;
     font-weight: 700;
     cursor: pointer;
     border: none;
     transition: all .15s;
 }

 .btn-blue {
     background: var(--blue);
     color: #fff;
 }

 .btn-blue:hover {
     opacity: .88;
 }

 .btn-green {
     background: var(--green);
     color: #fff;
 }

 .btn-green:hover {
     opacity: .88;
 }

 .btn-out {
     background: var(--white);
     color: var(--dim);
     border: 1.5px solid var(--border);
 }

 .btn-out:hover {
     border-color: var(--blue);
     color: var(--blue);
 }

 .btn-orange {
     background: var(--orange);
     color: #fff;
 }

 .brow {
     display: flex;
     gap: 8px;
     margin-top: 14px;
 }

 /* 🃏 Search Cards (Minimalist) */
 .rcard {
     background: var(--white);
     border-radius: 14px;
     padding: 16px;
     margin-bottom: 12px;
     border: 1px solid var(--border);
     transition: all 0.2s ease;
     cursor: pointer;
     position: relative;
     box-shadow: var(--sh);
 }

 .rcard:active {
     transform: scale(0.98);
 }

 .rcard-top {
     display: flex;
     justify-content: space-between;
     align-items: flex-start;
     margin-bottom: 10px;
 }

 .rcard-name {
     font-size: 16px;
     font-weight: 800;
     color: var(--text);
     flex: 1;
     margin-right: 10px;
     line-height: 1.4;
 }

 .rcard-pbl {
     background: #EEF2FF;
     color: #4F46E5;
     border: 1px solid #C7D2FE;
     padding: 2px 10px;
     border-radius: 6px;
     font-size: 11px;
     font-weight: 800;
 }

 .rcard-badges {
     display: flex;
     flex-wrap: wrap;
     gap: 6px;
     margin-bottom: 12px;
 }

 .badge-pill {
     display: inline-flex;
     align-items: center;
     gap: 4px;
     padding: 4px 12px;
     border-radius: 20px;
     font-size: 11px;
     font-weight: 800;
 }

 .b-sys {
     background: #F5F3FF;
     color: #7C3AED;
     border: 1px solid #DDD6FE;
 }

 .b-brand {
     background: #FFF7ED;
     color: #9A3412;
     border: 1px solid #FFEDD5;
 }

 .rcard-loc {
     font-size: 13px;
     font-weight: 700;
     color: var(--muted);
     display: flex;
     align-items: center;
     gap: 4px;
 }

 /* ⏳ Loading States */
 .loading-overlay {
     position: fixed;
     top: 0;
     left: 0;
     right: 0;
     bottom: 0;
     background: rgba(255, 255, 255, 0.7);
     backdrop-filter: blur(5px);
     z-index: 1000;
     display: none;
     flex-direction: column;
     align-items: center;
     justify-content: center;
     gap: 15px;
 }

 .loading-overlay.on {
     display: flex;
 }

 .spinner {
     width: 44px;
     height: 44px;
     border: 4px solid var(--blue-bg);
     border-top: 4px solid var(--blue);
     border-radius: 50%;
     animation: spin 0.8s linear infinite;
 }

 @keyframes spin {
     0% {
         transform: rotate(0deg);
     }

     100% {
         transform: rotate(360deg);
     }
 }

 .loading-text {
     font-size: 15px;
     font-weight: 700;
     color: var(--text);
     padding: 0 30px;
     text-align: center;
     line-height: 1.5;
 }

 /* 🖼️ Photo Lightbox (Premium) */
 .photo-lightbox {
     position: fixed;
     top: 0;
     left: 0;
     width: 100%;
     height: 100%;
     background: rgba(0, 0, 0, 0.9);
     backdrop-filter: blur(8px);
     z-index: 2000;
     display: none;
     align-items: center;
     justify-content: center;
     padding: 20px;
     transition: all 0.3s ease;
 }

 .photo-lightbox.on {
     display: flex;
     animation: fadeIn 0.3s ease;
 }

 #lightbox-img {
     max-width: 95%;
     max-height: 90%;
     border-radius: 12px;
     box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
     transition: opacity 0.3s ease-in-out;
     opacity: 0;
     /* JS will set to 1 after load */
 }

 .close-lightbox {
     position: absolute;
     top: 20px;
     right: 20px;
     background: rgba(255, 255, 255, 0.1);
     color: white;
     border: none;
     width: 44px;
     height: 44px;
     border-radius: 50%;
     font-size: 28px;
     cursor: pointer;
     display: flex;
     align-items: center;
     justify-content: center;
     transition: all 0.2s;
     z-index: 2001;
 }

 .close-lightbox:hover {
     background: rgba(255, 255, 255, 0.3);
     transform: rotate(90deg);
 }

 @keyframes fadeIn {
     from {
         opacity: 0;
     }

     to {
         opacity: 1;
     }
 }

 /* ════ PTT THEME & HISTORY STYLES ════ */
 .ptt-theme {
     background: linear-gradient(135deg, #005596 0%, #003a6b 100%);
     color: white;
     border: none;
     box-shadow: 0 4px 15px rgba(0, 85, 150, 0.2);
 }

 .stn-card {
     background: var(--white);
     border-radius: 20px;
     overflow: hidden;
     border: 1px solid var(--border);
     box-shadow: var(--sh);
 }

 .stn-top {
     padding: 16px 20px;
     border-bottom: 1px solid rgba(255, 255, 255, 0.1);
 }

 /* History Row Animation */
 #water-history-list>div {
     animation: slideUp 0.4s ease forwards;
 }

 @keyframes slideUp {
     from {
         opacity: 0;
         transform: translateY(20px);
     }

     to {
         opacity: 1;
         transform: translateY(0);
     }
 }

 /* Ensure button sizing consistency */
 #page-water .brow .btn {
     padding: 12px 5px;
     font-size: 13px;
     height: 48px;
     display: flex;
     align-items: center;
     justify-content: center;
 }

 /* Page transitions */
 .page {
     display: none;
 }

 .page.on {
     display: block;
 }