        :root {
            /* Google Material 3 Token-like variables */
            --md-sys-color-primary: #2e7d32;
            --md-sys-color-on-primary: #ffffff;
            --md-sys-color-primary-container: #b8f2c8;
            --md-sys-color-secondary: #e65100;
            /* Adjusted Orange */
            --md-sys-color-background: #fdfcff;
            --md-sys-color-surface: #f0f2f5;
            --md-sys-color-surface-container: #ffffff;
            --md-sys-color-outline: #79747e;
            --md-sys-color-error: #ba1a1a;

            --border-radius-xl: 28px;
            --border-radius-lg: 16px;
            --border-radius-md: 12px;

            --animation-timing: cubic-bezier(0.2, 0.0, 0, 1.0);
        }

        body {
            font-family: 'Sarabun', sans-serif;
            background: var(--md-sys-color-surface);
            margin: 0;
            padding: 0;
            color: #1c1b1f;
            -webkit-tap-highlight-color: transparent;
        }

        /* --- Loader Animation --- */
        #loader {
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background: rgba(255, 255, 255, 0.9);
            z-index: 9999;
            display: flex;
            justify-content: center;
            align-items: center;
            flex-direction: column;
            backdrop-filter: blur(5px);
        }

        .spinner {
            width: 48px;
            height: 48px;
            border: 5px solid #e0e0e0;
            border-bottom-color: var(--md-sys-color-primary);
            border-radius: 50%;
            animation: rotation 1s linear infinite;
        }

        @keyframes rotation {
            0% {
                transform: rotate(0deg);
            }

            100% {
                transform: rotate(360deg);
            }
        }

        /* --- Pull to Refresh Styles --- */
        #ptr-indicator {
            width: 100%;
            height: 0;
            overflow: hidden;
            display: flex;
            align-items: center;
            justify-content: center;
            background: #f0f2f5;
            transition: height 0.2s ease;
            position: relative;
            z-index: 5;
        }

        .ptr-content {
            display: flex;
            flex-direction: column;
            align-items: center;
            color: var(--md-sys-color-primary);
            font-size: 0.85rem;
            font-weight: 500;
        }

        .ptr-icon {
            font-size: 24px;
            margin-bottom: 4px;
            transition: transform 0.2s ease;
        }

        .ptr-loading .ptr-icon {
            animation: rotation 1s linear infinite;
        }

        /* --- Animations & Keyframes --- */
        @keyframes float {
            0%   { transform: translateY(0px);  box-shadow: 0 4px 12px rgba(0,0,0,0.15); }
            50%  { transform: translateY(-8px); box-shadow: 0 12px 24px rgba(0,0,0,0.12); }
            100% { transform: translateY(0px);  box-shadow: 0 4px 12px rgba(0,0,0,0.15); }
        }
        @keyframes slideUpFadeIn {
            from { opacity: 0; transform: translateY(18px); }
            to   { opacity: 1; transform: translateY(0);   }
        }
        @keyframes popIn {
            0%   { opacity: 0; transform: scale(0.85); }
            70%  { transform: scale(1.03); }
            100% { opacity: 1; transform: scale(1); }
        }
        @keyframes shimmer {
            0%   { background-position: -200% center; }
            100% { background-position: 200% center; }
        }
        @keyframes ripple {
            to { transform: scale(4); opacity: 0; }
        }

        /* --- Header --- */
        header {
            background:
                radial-gradient(120% 80% at 0% 0%, rgba(255, 255, 255, 0.18) 0%, transparent 50%),
                radial-gradient(100% 100% at 100% 100%, rgba(0, 0, 0, 0.28) 0%, transparent 55%),
                linear-gradient(135deg, #064E3B 0%, #0f766e 55%, #059669 100%);
            color: #ffffff;
            padding: 22px 20px 56px;
            text-align: center;
            border-bottom-left-radius: 40px;
            border-bottom-right-radius: 40px;
            box-shadow:
                0 1px 1px rgba(255, 255, 255, 0.08) inset,
                0 -1px 0 rgba(0, 0, 0, 0.2) inset,
                0 18px 36px -12px rgba(5, 150, 105, 0.45);
            position: relative;
            z-index: 10;
            overflow: hidden;
        }
        header::before {
            content: "";
            position: absolute;
            top: -40%;
            right: -20%;
            width: 360px;
            height: 360px;
            border-radius: 50%;
            background: radial-gradient(circle, rgba(167, 243, 208, 0.25) 0%, transparent 65%);
            filter: blur(8px);
            pointer-events: none;
        }
        header::after {
            content: "";
            position: absolute;
            bottom: -60%;
            left: -10%;
            width: 280px;
            height: 280px;
            border-radius: 50%;
            background: radial-gradient(circle, rgba(110, 231, 183, 0.18) 0%, transparent 70%);
            filter: blur(10px);
            pointer-events: none;
        }
        header > * { position: relative; z-index: 1; }

        h1 {
            margin: 0;
            font-size: 1.55rem;
            font-weight: 700;
            letter-spacing: 0.3px;
            text-shadow: 0 2px 8px rgba(0,0,0,0.22);
        }

        p {
            margin: 4px 0 0;
            font-size: 0.92rem;
            opacity: 0.82;
            font-weight: 400;
            letter-spacing: 0.2px;
        }

        /* --- Admin Toggle Button (Icon Only) --- */
        .admin-toggle {
            position: absolute;
            top: 12px;
            right: 12px;
            background: rgba(255, 255, 255, 0.15);
            color: white;
            border: 1px solid rgba(255, 255, 255, 0.25);
            width: 38px;
            height: 38px;
            border-radius: 50%;
            font-size: 1.2rem;
            cursor: pointer;
            backdrop-filter: blur(10px);
            -webkit-backdrop-filter: blur(10px);
            transition: all 0.3s ease;
            box-shadow: 0 4px 6px rgba(0,0,0,0.1);
            display: flex;
            align-items: center;
            justify-content: center;
            font-family: 'Material Symbols Rounded';
        }

        .admin-toggle:hover {
            background: rgba(255, 255, 255, 0.25);
            transform: translateY(-2px);
            box-shadow: 0 6px 12px rgba(0,0,0,0.15);
        }

        /* --- Admin Mode Unlocked Animation --- */
        .admin-mode .admin-toggle {
            /* สีตอนจบแอนิเมชันให้กลับไปเป็นสีขาวปกติ แต่ไอคอนเป็นสีแดง */
            background: rgba(255, 255, 255, 0.15);
            color: #ff5252; /* สีแดงให้รู้ว่ายังปลดล็อกอยู่ */
            border-color: rgba(255, 255, 255, 0.25);
            animation: unlock-sequence 6s forwards;
        }

        @keyframes unlock-sequence {
            /* สเตป 1: กระพริบ 2 รอบ (0s - 3s) */
            0%   { background: #ffeb3b; color: #d84315; border-color: #fff176; transform: scale(1); box-shadow: 0 0 10px rgba(255, 235, 59, 0.6); }
            12.5%{ background: #ffeb3b; color: #d84315; border-color: #fff176; transform: scale(1.15) rotate(5deg); box-shadow: 0 0 25px rgba(255, 235, 59, 1); }
            25%  { background: #ffeb3b; color: #d84315; border-color: #fff176; transform: scale(1); box-shadow: 0 0 10px rgba(255, 235, 59, 0.6); }
            37.5%{ background: #ffeb3b; color: #d84315; border-color: #fff176; transform: scale(1.15) rotate(-5deg); box-shadow: 0 0 25px rgba(255, 235, 59, 1); }
            50%  { background: #ffeb3b; color: #d84315; border-color: #fff176; transform: scale(1); box-shadow: 0 0 10px rgba(255, 235, 59, 0.6); }
            
            /* สเตป 2: นิ่งสีเหลือง (3s - 5s) */
            80%  { background: #ffeb3b; color: #d84315; border-color: #fff176; transform: scale(1); box-shadow: 0 0 10px rgba(255, 235, 59, 0.6); }

            /* สเตป 3: เฟดกลับเป็นสีขาว แต่ไอคอนกุญแจเป็นสีแดง (5s - 6s) */
            100% { background: rgba(255, 255, 255, 0.15); color: #ff5252; border-color: rgba(255, 255, 255, 0.25); transform: scale(1); box-shadow: 0 4px 6px rgba(0,0,0,0.1); }
        }

        /* --- Tabs (Segmented Button Style) --- */
        .tabs {
            display: flex;
            justify-content: center;
            margin-top: -30px;
            padding: 0 15px;
            position: relative;
            z-index: 20;
        }

        .tab-btn {
            flex: 1;
            max-width: 160px;
            padding: 14px 18px;
            border: 1px solid rgba(16, 24, 40, 0.06);
            background: rgba(255, 255, 255, 0.95);
            backdrop-filter: blur(10px);
            -webkit-backdrop-filter: blur(10px);
            color: #49454f;
            font-weight: 600;
            font-size: 0.95rem;
            cursor: pointer;
            border-radius: 50px;
            margin: 0 6px;
            box-shadow:
                0 1px 2px rgba(16, 24, 40, 0.04),
                0 8px 20px -8px rgba(16, 24, 40, 0.12);
            transition: all 0.3s var(--animation-timing);
            font-family: 'Sarabun', sans-serif;
        }

        .tab-btn.active {
            background: linear-gradient(135deg, #f97316 0%, #e65100 100%);
            color: white;
            border-color: transparent;
            box-shadow:
                0 4px 10px rgba(230, 81, 0, 0.35),
                0 10px 24px -8px rgba(230, 81, 0, 0.5);
            transform: translateY(-2px);
        }

        .tab-btn:active {
            transform: scale(0.95) translateY(0);
        }

        /* --- Stats Cards --- */
        .stats-container {
            display: flex;
            gap: 12px;
            padding: 28px 20px 18px;
            overflow-x: auto;
            scroll-behavior: smooth;
        }

        .stats-container::-webkit-scrollbar {
            display: none;
        }

        .stat-card {
            --stat-tint-1: #ffffff;
            --stat-tint-2: #f5f7fb;
            --stat-accent: #2e7d32;
            --stat-soft: rgba(46, 125, 50, 0.12);
            min-width: 0;
            background:
                radial-gradient(120% 80% at 0% 0%, var(--stat-tint-1) 0%, transparent 55%),
                radial-gradient(120% 80% at 100% 100%, var(--stat-tint-2) 0%, transparent 60%),
                #ffffff;
            padding: 16px 12px 18px;
            border-radius: 22px;
            box-shadow:
                0 1px 1px rgba(16, 24, 40, 0.03),
                0 10px 24px -12px rgba(16, 24, 40, 0.12),
                inset 0 1px 0 rgba(255, 255, 255, 0.7);
            flex: 1;
            text-align: center;
            transition: transform 0.25s var(--animation-timing), box-shadow 0.25s;
            border: 1px solid rgba(16, 24, 40, 0.05);
            position: relative;
            overflow: hidden;
        }
        .stat-card::before {
            content: "";
            position: absolute;
            top: -40px;
            right: -40px;
            width: 120px;
            height: 120px;
            border-radius: 50%;
            background: var(--stat-soft);
            filter: blur(28px);
            pointer-events: none;
        }
        .stat-card > * { position: relative; z-index: 1; }
        .stat-card:nth-child(1) { --stat-tint-2: #e9f7ee; --stat-accent: #2e7d32; --stat-soft: rgba(46, 125, 50, 0.14); }
        .stat-card:nth-child(2) { --stat-tint-2: #fff1e6; --stat-accent: #e65100; --stat-soft: rgba(230, 81, 0, 0.14); }
        .stat-card:nth-child(3) { --stat-tint-2: #e7f0ff; --stat-accent: #1d4ed8; --stat-soft: rgba(29, 78, 216, 0.14); }
        .stat-card:hover {
            transform: translateY(-2px);
            box-shadow:
                0 1px 1px rgba(16, 24, 40, 0.03),
                0 16px 30px -12px rgba(16, 24, 40, 0.18),
                inset 0 1px 0 rgba(255, 255, 255, 0.8);
        }

        .stat-val {
            font-size: clamp(1.35rem, 5.5vw, 1.7rem);
            font-weight: 700;
            color: var(--stat-accent);
            display: block;
            line-height: 1.2;
            word-break: break-word;
            letter-spacing: -0.01em;
        }

        .stat-label {
            font-size: clamp(0.72rem, 3vw, 0.8rem);
            color: #6b7280;
            font-weight: 500;
            margin-top: 6px;
            display: block;
        }

        /* --- Sticky Search Bar --- */
        .search-wrapper {
            position: sticky;
            top: 10px;
            z-index: 100;
            padding: 0 20px;
            margin-bottom: 20px;
            pointer-events: none;
        }

        .search-box {
            position: relative;
            max-width: 800px;
            margin: 0 auto;
            pointer-events: auto;
            background: rgba(255, 255, 255, 0.92);
            backdrop-filter: blur(14px);
            -webkit-backdrop-filter: blur(14px);
            border: 1px solid rgba(16, 24, 40, 0.06);
            border-radius: 50px;
            box-shadow:
                0 1px 2px rgba(16, 24, 40, 0.04),
                0 10px 30px -12px rgba(16, 24, 40, 0.15);
            transition: box-shadow 0.3s, border-color 0.3s;
            display: flex;
            align-items: center;
        }
        .search-box:focus-within {
            border-color: rgba(46, 125, 50, 0.4);
            box-shadow:
                0 1px 2px rgba(16, 24, 40, 0.04),
                0 14px 36px -12px rgba(46, 125, 50, 0.25);
        }

        /* Hide native datalist dropdown arrow (keep functionality on focus/typing) */
        .search-input::-webkit-calendar-picker-indicator {
            display: none !important;
            -webkit-appearance: none;
            opacity: 0;
        }
        .search-input::-webkit-list-button {
            display: none !important;
            -webkit-appearance: none;
        }
        .search-input {
            -webkit-appearance: none;
            appearance: none;
        }

        .search-input {
            width: 100%;
            padding: 16px 48px 16px 50px;
            border: none;
            border-radius: 50px;
            background: transparent;
            font-family: 'Sarabun', sans-serif;
            font-size: 1rem;
            outline: none;
            color: #1c1b1f;
        }

        .search-icon {
            position: absolute;
            left: 20px;
            color: #5f6368;
            font-size: 1.2rem;
        }

        .search-clear {
            position: absolute;
            right: 16px;
            /* Shifted left from 15px to 45px to avoid datalist arrow */
            color: #5f6368;
            font-size: 1.2rem;
            cursor: pointer;
            padding: 5px;
            border-radius: 50%;
            display: none;
            /* Hidden by default */
            transition: background 0.2s;
        }

        .search-clear:hover {
            background: rgba(0, 0, 0, 0.05);
            color: #000;
        }

        /* --- Filter Chips --- */
        .filter-chips-container {
            display: flex;
            gap: 8px;
            padding: 0 20px 15px;
            overflow-x: auto;
            justify-content: center;
            flex-wrap: wrap;
        }


        /* Custom concrete icon — 4 concrete slabs in a 2x2 grid (top-down view) */
        .icon-concrete-dashes {
            display: inline-block;
            width: 1em;
            height: 1em;
            background-color: currentColor;
            -webkit-mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'><rect x='2' y='2.5' width='5.5' height='5' rx='0.8'/><rect x='8.5' y='2.5' width='5.5' height='5' rx='0.8'/><rect x='2' y='8.5' width='5.5' height='5' rx='0.8'/><rect x='8.5' y='8.5' width='5.5' height='5' rx='0.8'/></svg>") no-repeat center / contain;
                    mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'><rect x='2' y='2.5' width='5.5' height='5' rx='0.8'/><rect x='8.5' y='2.5' width='5.5' height='5' rx='0.8'/><rect x='2' y='8.5' width='5.5' height='5' rx='0.8'/><rect x='8.5' y='8.5' width='5.5' height='5' rx='0.8'/></svg>") no-repeat center / contain;
            vertical-align: -0.125em;
        }
        .filter-chip {
            --chip-accent: #6b7280;
            --chip-bg: #ffffff;
            display: inline-flex;
            align-items: center;
            gap: 7px;
            padding: 8px 16px 8px 13px;
            border-radius: 50px;
            border: 1px solid rgba(16, 24, 40, 0.08);
            font-size: 0.85rem;
            font-weight: 600;
            color: #374151;
            background: rgba(255, 255, 255, 0.92);
            backdrop-filter: blur(8px);
            -webkit-backdrop-filter: blur(8px);
            box-shadow: 0 1px 2px rgba(16, 24, 40, 0.04);
            cursor: pointer;
            white-space: nowrap;
            transition: transform 0.15s ease, box-shadow 0.2s ease, background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
            font-family: 'Sarabun', sans-serif;
        }
        .filter-chip > i {
            font-size: 0.82rem;
            color: var(--chip-accent);
            width: 22px;
            height: 22px;
            display: inline-flex;
            align-items: center;
            justify-content: center;
            border-radius: 7px;
            background: color-mix(in srgb, var(--chip-accent) 14%, transparent);
            transition: background 0.2s, color 0.2s, transform 0.2s;
        }
        .filter-chip:hover { border-color: rgba(16, 24, 40, 0.16); transform: translateY(-1px); box-shadow: 0 4px 12px -4px rgba(16, 24, 40, 0.1); }

        .filter-chip:active {
            transform: scale(0.93);
        }

        /* type-specific accent colors */
        .filter-chip.chip-all       { --chip-accent: #e65100; }
        .filter-chip.chip-asphalt   { --chip-accent: #334155; }
        .filter-chip.chip-concrete  { --chip-accent: #1d4ed8; }
        .filter-chip.chip-gravel    { --chip-accent: #b45309; }
        .filter-chip.chip-soil      { --chip-accent: #92400e; }
        .filter-chip.chip-building  { --chip-accent: #0f766e; }
        .filter-chip.chip-delivered { --chip-accent: #1a73e8; }

        .filter-chip.active {
            background: var(--chip-accent);
            color: white;
            border-color: transparent;
            box-shadow:
                0 4px 10px -2px color-mix(in srgb, var(--chip-accent) 50%, transparent),
                0 12px 24px -10px color-mix(in srgb, var(--chip-accent) 60%, transparent);
        }
        .filter-chip.active > i {
            background: rgba(255, 255, 255, 0.22);
            color: #ffffff;
        }

        /* --- List & Cards --- */
        .container {
            padding: 5px 20px 100px;
            max-width: 800px;
            margin: 0 auto;
        }

        /* ===== REDESIGNED CARD (soft pastel / glassy) ===== */
        .project-card {
            --tint-1: #ffffff;
            --tint-2: #f5f7fb;
            --accent: #475569;
            --accent-soft: rgba(71, 85, 105, 0.10);
            background:
                radial-gradient(120% 80% at 0% 0%, var(--tint-1) 0%, transparent 55%),
                radial-gradient(120% 80% at 100% 100%, var(--tint-2) 0%, transparent 60%),
                #ffffff;
            padding: 20px 20px 0;
            margin-bottom: 20px;
            border-radius: 26px;
            box-shadow:
                0 1px 1px rgba(16, 24, 40, 0.03),
                0 10px 24px -12px rgba(16, 24, 40, 0.10),
                inset 0 1px 0 rgba(255, 255, 255, 0.6);
            cursor: pointer;
            position: relative;
            transition: transform 0.28s cubic-bezier(0.2, 0, 0, 1), box-shadow 0.28s cubic-bezier(0.2, 0, 0, 1);
            border: 1px solid rgba(16, 24, 40, 0.05);
            overflow: hidden;
            opacity: 0;
            animation: slideUpFadeIn 0.45s forwards cubic-bezier(0.2, 0, 0, 1);
            display: flex;
            flex-direction: column;
        }

        /* Decorative blob/glow per type */
        .project-card::before {
            content: "";
            position: absolute;
            top: -70px;
            right: -70px;
            width: 220px;
            height: 220px;
            border-radius: 50%;
            background: var(--accent-soft);
            filter: blur(40px);
            pointer-events: none;
            z-index: 0;
        }
        .project-card > * { position: relative; z-index: 1; }

        /* type-based pastel tints */
        .project-card.type-asphalt  { --tint-1: #f8fafc; --tint-2: #eef2f6; --accent: #334155; --accent-soft: rgba(51, 65, 85, 0.14); }
        .project-card.type-concrete { --tint-1: #f5f9ff; --tint-2: #e6efff; --accent: #1d4ed8; --accent-soft: rgba(29, 78, 216, 0.14); }
        .project-card.type-gravel   { --tint-1: #fffaf2; --tint-2: #fdecd2; --accent: #b45309; --accent-soft: rgba(180, 83, 9, 0.16); }
        .project-card.type-soil     { --tint-1: #fff7ee; --tint-2: #fde6cf; --accent: #92400e; --accent-soft: rgba(146, 64, 14, 0.16); }
        .project-card.type-building { --tint-1: #f1fbf6; --tint-2: #d6f3e1; --accent: #0f766e; --accent-soft: rgba(15, 118, 110, 0.16); }

        .project-card:hover {
            transform: translateY(-4px);
            box-shadow:
                0 1px 1px rgba(16, 24, 40, 0.03),
                0 22px 40px -18px rgba(16, 24, 40, 0.18),
                inset 0 1px 0 rgba(255, 255, 255, 0.7);
        }

        .project-card:active {
            transform: scale(0.99) translateY(0);
        }

        .project-card .ripple {
            position: absolute;
            border-radius: 50%;
            width: 60px;
            height: 60px;
            background: rgba(0,0,0,0.06);
            transform: scale(0);
            animation: ripple 0.55s linear;
            pointer-events: none;
            margin-top: -30px;
            margin-left: -30px;
        }

        @keyframes slideUpFade {
            to { opacity: 1; transform: translateY(0); }
        }

        /* Top row: logo + status pill */
        .card-top {
            display: flex;
            align-items: center;
            justify-content: space-between;
            gap: 12px;
            margin-bottom: 16px;
        }
        .card-logo {
            width: 48px;
            height: 48px;
            border-radius: 14px;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 20px;
            color: var(--accent);
            background: rgba(255, 255, 255, 0.92);
            flex-shrink: 0;
            box-shadow:
                0 1px 2px rgba(16, 24, 40, 0.06),
                0 8px 18px -10px var(--accent-soft),
                inset 0 0 0 1px rgba(255, 255, 255, 0.7);
            backdrop-filter: blur(6px);
            -webkit-backdrop-filter: blur(6px);
        }
        /* coloring now via card variable */
        .card-logo.type-asphalt,
        .card-logo.type-concrete,
        .card-logo.type-gravel,
        .card-logo.type-soil,
        .card-logo.type-building { background: rgba(255, 255, 255, 0.92); color: var(--accent); }

        /* Right pill (Save / Saved analog) */
        .status-pill {
            display: inline-flex;
            align-items: center;
            gap: 6px;
            padding: 8px 13px;
            border-radius: 999px;
            font-size: 0.78rem;
            font-weight: 600;
            white-space: nowrap;
            line-height: 1;
            border: 1px solid rgba(16, 24, 40, 0.08);
            background: rgba(255, 255, 255, 0.85);
            color: #374151;
            backdrop-filter: blur(8px);
            -webkit-backdrop-filter: blur(8px);
            box-shadow: 0 1px 2px rgba(16, 24, 40, 0.04);
        }
        .status-pill i { font-size: 0.78rem; }
        .status-pill.pill-pending  { background: rgba(254, 243, 199, 0.9); color: #92400e; border-color: rgba(253, 230, 138, 0.9); }
        .status-pill.pill-active   { background: rgba(255, 237, 213, 0.9); color: #9a3412; border-color: rgba(254, 215, 170, 0.9); }
        .status-pill.pill-delivered{ background: rgba(219, 234, 254, 0.9); color: #1e40af; border-color: rgba(191, 219, 254, 0.9); }
        .status-pill.pill-done     { background: rgba(209, 250, 229, 0.9); color: #065f46; border-color: rgba(167, 243, 208, 0.9); }

        /* keep legacy class names available */
        .status-badge {
            display: inline-flex;
            align-items: center;
            padding: 6px 12px;
            border-radius: 999px;
            font-size: 0.75rem;
            font-weight: 600;
            white-space: nowrap;
            color: white;
        }
        .badge-active    { background: var(--md-sys-color-secondary); }
        .badge-pending   { background: #FFCA28; color: #000; }
        .badge-done      { background: #1a73e8; }
        .badge-completed { background: #1e8e3e; }

        /* Title block */
        .card-meta-top {
            font-size: 0.78rem;
            color: #6b7280;
            margin-bottom: 6px;
            display: flex;
            align-items: center;
            gap: 8px;
            flex-wrap: wrap;
            font-weight: 500;
        }
        .card-meta-top .dot { width: 3px; height: 3px; border-radius: 50%; background: #9ca3af; }
        .card-meta-top strong { font-weight: 600; color: var(--accent); }

        .card-title {
            font-weight: 700;
            font-size: 1.18rem;
            line-height: 1.4;
            color: #111827;
            width: 100%;
            word-break: break-word;
            margin-bottom: 14px;
            letter-spacing: -0.005em;
        }

        /* Tag chips inside the card */
        .card-chips {
            display: flex;
            flex-wrap: wrap;
            gap: 8px;
            margin-bottom: 16px;
        }
        .card-chip {
            display: inline-flex;
            align-items: center;
            gap: 6px;
            padding: 7px 13px;
            background: rgba(255, 255, 255, 0.7);
            color: #374151;
            border: 1px solid rgba(16, 24, 40, 0.06);
            border-radius: 999px;
            font-size: 0.78rem;
            font-weight: 500;
            white-space: nowrap;
            backdrop-filter: blur(6px);
            -webkit-backdrop-filter: blur(6px);
        }
        .card-chip i { font-size: 0.72rem; color: var(--accent); opacity: 0.85; }

        /* Description */
        .card-desc {
            font-size: 0.85rem;
            color: #4b5563;
            line-height: 1.55;
            margin-bottom: 12px;
            display: -webkit-box;
            -webkit-line-clamp: 2;
            -webkit-box-orient: vertical;
            overflow: hidden;
        }

        /* Progress (inline within card) */
        .card-progress-row {
            display: flex;
            align-items: center;
            justify-content: space-between;
            font-size: 0.78rem;
            color: #6b7280;
            margin-bottom: 6px;
            margin-top: 2px;
        }
        .card-progress-row .progress-pct { font-weight: 700; }

        .progress-bar-bg {
            background: rgba(16, 24, 40, 0.06);
            height: 6px;
            border-radius: 999px;
            overflow: hidden;
            margin: 0 0 16px;
        }

        /* Footer: budget + Apply-now style button */
        .card-footer {
            margin: 6px -20px 0;
            padding: 16px 20px 18px;
            border-top: 1px solid rgba(16, 24, 40, 0.06);
            background: rgba(255, 255, 255, 0.35);
            backdrop-filter: blur(8px);
            -webkit-backdrop-filter: blur(8px);
            display: flex;
            align-items: center;
            justify-content: space-between;
            gap: 12px;
        }
        .card-budget {
            display: flex;
            flex-direction: column;
            line-height: 1.2;
            min-width: 0;
        }
        .card-budget .budget-amt {
            font-size: 1.1rem;
            font-weight: 700;
            color: #111827;
            letter-spacing: -0.01em;
            display: inline-flex;
            align-items: baseline;
            gap: 4px;
        }
        /* Baht symbol — distinct font/weight so it doesn't look like an 8 */
        .baht-sym {
            font-family: 'Noto Sans Thai', 'Segoe UI', Tahoma, sans-serif;
            font-weight: 500;
            color: var(--accent, #2e7d32);
            font-size: 0.85em;
            padding: 1px 5px;
            border-radius: 6px;
            background: color-mix(in srgb, var(--accent, #2e7d32) 10%, transparent);
            line-height: 1;
            display: inline-block;
            margin-right: 2px;
            transform: translateY(-1px);
        }
        /* In modal (no --accent in scope), use a neutral green */
        #m-budget .baht-sym {
            color: #0f766e;
            background: rgba(15, 118, 110, 0.1);
        }
        .card-budget .budget-sub {
            font-size: 0.74rem;
            color: #6b7280;
            margin-top: 4px;
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
            max-width: 200px;
        }
        .card-cta {
            background: #111827;
            color: #fff;
            border: none;
            padding: 12px 22px;
            border-radius: 999px;
            font-family: 'Sarabun', sans-serif;
            font-size: 0.88rem;
            font-weight: 600;
            cursor: pointer;
            white-space: nowrap;
            flex-shrink: 0;
            transition: background 0.2s ease, transform 0.15s ease, box-shadow 0.2s ease;
            display: inline-flex;
            align-items: center;
            gap: 8px;
            box-shadow: 0 4px 12px -4px rgba(17, 24, 39, 0.4);
        }
        .card-cta:hover { background: #000; box-shadow: 0 8px 18px -4px rgba(17, 24, 39, 0.5); }
        .card-cta:active { transform: scale(0.96); }

        /* Overdue inline alert (restyled) */
        .card-overdue {
            background: #fef2f2;
            color: #b91c1c;
            border: 1px solid #fecaca;
            padding: 6px 10px;
            border-radius: 10px;
            font-size: 0.78rem;
            font-weight: 600;
            display: inline-flex;
            align-items: center;
            gap: 6px;
            margin-bottom: 10px;
        }

        /* Extended-time progress */
        .card-ext-row {
            display: flex;
            align-items: center;
            justify-content: space-between;
            font-size: 0.74rem;
            color: #c2410c;
            margin-bottom: 6px;
            font-weight: 600;
        }
        .progress-bar-bg.ext { background: #fff7ed; border: 1px solid #fed7aa; height: 5px; margin-bottom: 14px; }

        .card-meta {
            font-size: 0.85rem;
            color: #5f6368;
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-top: 5px;
        }

        .progress-bar-fill {
            height: 100%;
            width: 0%;
            transition: width 1s ease-in-out;
            border-radius: 4px;
        }

        /* --- Edit Button (Admin Only) --- */
        .header-actions {
            display: flex;
            align-items: center;
            gap: 22px; /* เพิ่มระยะห่างให้กว้างขึ้นตามคำขอ */
            flex-shrink: 0;
            width: 100%;
            justify-content: flex-end;
        }

        .admin-icon-btn {
            display: none;
            /* Hidden by default */
            width: 28px;
            height: 28px;
            border-radius: 50%;
            border: none;
            background: #fff;
            box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
            align-items: center;
            justify-content: center;
            cursor: pointer;
            font-family: 'Material Symbols Rounded';
            font-size: 16px;
            color: #555;
            transition: transform 0.2s, background 0.2s;
            pointer-events: auto;
            position: relative;
            z-index: 10;
        }

        .admin-icon-btn span, .admin-icon-btn i {
            pointer-events: none; /* ป้องกันไอคอนขวางการคลิกที่ตัวปุ่ม */
        }

        .admin-icon-btn:hover {
            transform: scale(1.1);
        }

        .admin-icon-btn.edit-action {
            color: #f9a825; /* Golden Yellow for Edit */
        }

        .admin-icon-btn.delete-action {
            color: var(--md-sys-color-error);
        }

        body.admin-mode .admin-icon-btn {
            display: flex;
        }

        /* --- Floating Action Button (Add) --- */
        .fab {
            display: none;
            position: fixed;
            bottom: 30px;
            right: 30px;
            width: 56px;
            height: 56px;
            background: var(--md-sys-color-secondary);
            color: white;
            border-radius: 16px;
            border: none;
            box-shadow: 0 4px 12px rgba(230, 81, 0, 0.4);
            align-items: center;
            justify-content: center;
            font-size: 24px;
            cursor: pointer;
            z-index: 90;
            transition: transform 0.2s cubic-bezier(0.2, 0, 0, 1), box-shadow 0.2s ease;
            animation: popIn 0.4s cubic-bezier(0.2, 0, 0, 1);
        }

        .fab:hover {
            transform: scale(1.1) rotate(45deg);
            box-shadow: 0 8px 20px rgba(230, 81, 0, 0.5);
        }

        .fab:active {
            transform: scale(0.94) rotate(45deg);
        }

        body.admin-mode .fab {
            display: flex;
        }

        /* --- Modal --- */
        #modal,
        #auth-modal,
        #form-modal {
            display: none;
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background: rgba(15, 23, 42, 0.45);
            z-index: 2000;
            align-items: flex-end;
            justify-content: center;
            opacity: 0;
            transition: opacity 0.22s ease;
        }
        @media (min-width: 700px) and (hover: hover) {
            #modal, #auth-modal, #form-modal { backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); }
        }

        #modal.show,
        #auth-modal.show,
        #form-modal.show {
            opacity: 1;
        }

        .modal-content {
            background:
                radial-gradient(120% 60% at 50% 0%, #ffffff 0%, transparent 60%),
                linear-gradient(180deg, #fafbfd 0%, #ffffff 100%);
            width: 100%;
            max-width: 720px;
            border-radius: 32px 32px 0 0;
            padding: 22px 22px 40px;
            max-height: 88vh;
            overflow-y: auto;
            transform: translate3d(0, 100%, 0);
            transition: transform 0.32s cubic-bezier(0.22, 1, 0.36, 1);
            will-change: transform;
            box-shadow:
                0 -1px 0 rgba(255, 255, 255, 0.9) inset,
                0 -8px 30px rgba(16, 24, 40, 0.18);
            position: relative;
            -webkit-overflow-scrolling: touch;
        }
        /* Drag handle on top of bottom sheet */
        .modal-content::before {
            content: "";
            display: block;
            width: 40px;
            height: 4px;
            border-radius: 999px;
            background: rgba(16, 24, 40, 0.18);
            margin: 0 auto 18px;
        }

        /* --- Floating Close Button (Sticky) --- */
        .modal-close-btn {
            position: sticky;
            top: 10px;
            float: right;
            margin-right: -4px;
            margin-bottom: -42px;
            width: 38px;
            height: 38px;
            border-radius: 50%;
            background: rgba(255, 255, 255, 0.95);
            backdrop-filter: blur(10px);
            -webkit-backdrop-filter: blur(10px);
            border: 1px solid rgba(16, 24, 40, 0.08);
            cursor: pointer;
            display: flex;
            align-items: center;
            justify-content: center;
            transition: all 0.25s;
            color: #374151;
            z-index: 100;
            box-shadow:
                0 1px 2px rgba(16, 24, 40, 0.06),
                0 8px 18px -8px rgba(16, 24, 40, 0.18);
        }

        /* Clear float issues */
        .modal-content::after {
            content: "";
            display: table;
            clear: both;
        }

        .modal-close-btn:hover {
            background: #e0e0e0;
            transform: rotate(90deg);
            color: #000;
        }

        .modal-close-btn span {
            font-size: 20px;
            font-weight: bold;
        }


        #modal.show .modal-content,
        #auth-modal.show .modal-content,
        #form-modal.show .modal-content {
            transform: translate3d(0, 0, 0);
        }

        @media (min-width: 700px) {

            #modal,
            #auth-modal,
            #form-modal {
                align-items: center;
            }

            .modal-content {
                border-radius: 28px;
                max-height: 90vh;
                transform: translate3d(0, 20px, 0) scale(0.98);
                opacity: 0;
                transition: transform 0.28s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.22s;
            }

            #modal.show .modal-content,
            #auth-modal.show .modal-content,
            #form-modal.show .modal-content {
                transform: translate3d(0, 0, 0) scale(1);
                opacity: 1;
            }
        }

        .section-header {
            font-size: 0.92rem;
            font-weight: 700;
            color: #065f46;
            background: linear-gradient(135deg, rgba(209, 250, 229, 0.7) 0%, rgba(167, 243, 208, 0.5) 100%);
            border: 1px solid rgba(46, 125, 50, 0.15);
            padding: 10px 16px 10px 14px;
            border-radius: 14px;
            margin: 26px 0 14px;
            display: flex;
            align-items: center;
            gap: 10px;
            letter-spacing: 0.01em;
        }
        .section-header::before {
            content: "";
            width: 4px;
            height: 16px;
            border-radius: 999px;
            background: linear-gradient(180deg, #2e7d32 0%, #0f766e 100%);
            flex-shrink: 0;
        }

        /* ===== Modal Status Card (redesigned) ===== */
        .modal-status-card {
            position: relative;
            margin: 4px 4px 22px;
            padding: 20px 20px 22px;
            border-radius: 22px;
            background:
                radial-gradient(120% 80% at 0% 0%, #ffffff 0%, transparent 55%),
                radial-gradient(120% 80% at 100% 100%, #ecfdf5 0%, transparent 60%),
                #ffffff;
            border: 1px solid rgba(46, 125, 50, 0.18);
            box-shadow:
                0 1px 1px rgba(16, 24, 40, 0.03),
                0 16px 36px -16px rgba(46, 125, 50, 0.25),
                inset 0 1px 0 rgba(255, 255, 255, 0.8);
            overflow: hidden;
        }
        .modal-status-card .modal-status-glow {
            position: absolute !important;
            top: -80px;
            right: -60px;
            width: 220px;
            height: 220px;
            border-radius: 50%;
            background: radial-gradient(circle, rgba(46, 125, 50, 0.18) 0%, transparent 70%);
            filter: blur(20px);
            pointer-events: none;
            z-index: 0;
        }
        .modal-status-card > * { position: relative; z-index: 1; }
        .modal-status-row {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 14px;
            padding-bottom: 12px;
            border-bottom: 1px dashed rgba(46, 125, 50, 0.22);
        }
        .modal-status-label {
            font-size: 0.82rem;
            color: #6b7280;
            font-weight: 500;
        }
        .modal-status-value {
            font-weight: 700;
            font-size: 1.05rem;
            color: #065f46;
            letter-spacing: -0.005em;
        }
        .modal-progress-row {
            display: flex;
            justify-content: space-between;
            align-items: center;
            font-size: 0.83rem;
            color: #6b7280;
            margin-bottom: 8px;
            font-weight: 500;
        }
        .modal-progress-row-ext { color: #c2410c; font-weight: 600; }
        .modal-progress-pct { font-weight: 700; color: #065f46; }
        .modal-progress-bar {
            height: 10px !important;
            background: rgba(16, 24, 40, 0.05) !important;
            border: none !important;
            margin: 0 !important;
            border-radius: 999px !important;
        }
        .modal-progress-bar-ext {
            background: rgba(251, 146, 60, 0.15) !important;
        }
        .modal-progress-bar .progress-bar-fill {
            background: linear-gradient(90deg, #22c55e, #16a34a) !important;
            border-radius: 999px !important;
        }
        .modal-ext-block {
            margin-top: 16px;
            padding-top: 16px;
            border-top: 1px dashed rgba(251, 146, 60, 0.35);
        }

        /* Hide rows with empty values (e.g., no contract no., no delivery date) */
        .detail-group:has(> .detail-value:empty) { display: none; }
        /* Hide empty BOQ button wrapper when button is hidden */
        #modal .modal-content > div:has(> #m-boq-btn[style*="display:none"]),
        #modal .modal-content > div:has(> #m-boq-btn[style*="display: none"]) { display: none; }

        .detail-group {
            margin-bottom: 6px;
            padding: 12px 4px;
            border-bottom: 1px solid rgba(16, 24, 40, 0.06);
            display: flex;
            justify-content: space-between;
            align-items: baseline;
            flex-wrap: wrap;
            gap: 10px;
            transition: background 0.2s;
            border-radius: 8px;
        }
        .detail-group:hover { background: rgba(46, 125, 50, 0.03); }
        .detail-group:last-child { border-bottom: 0; }

        .detail-label {
            font-size: 0.84rem;
            color: #6b7280;
            font-weight: 500;
            flex: 1;
            min-width: 110px;
        }

        .detail-value {
            font-size: 0.98rem;
            font-weight: 600;
            color: #111827;
            text-align: right;
            flex: 1.6;
            word-break: break-word;
            line-height: 1.5;
        }

        .value-block {
            display: block;
            width: 100%;
            text-align: left;
            margin-top: 4px;
            line-height: 1.6;
        }

        .close-btn {
            width: 100%;
            padding: 16px;
            background: #f5f5f5;
            color: #444;
            border: none;
            border-radius: 50px;
            font-size: 1rem;
            font-weight: 600;
            margin-top: 30px;
            cursor: pointer;
            font-family: 'Sarabun', sans-serif;
        }

        /* --- Form Styles --- */
        .form-group {
            margin-bottom: 15px;
        }

        .form-label {
            display: block;
            margin-bottom: 5px;
            font-size: 0.9rem;
            color: #444;
        }

        .form-input,
        .form-textarea,
        .form-select {
            width: 100%;
            padding: 12px 15px;
            border: 1px solid #ccc;
            border-radius: 8px;
            font-family: 'Sarabun', sans-serif;
            font-size: 1rem;
            box-sizing: border-box;
            background-color: white;
        }

        .form-input:focus,
        .form-textarea:focus {
            border-color: var(--md-sys-color-primary);
            outline: none;
        }

        .primary-btn {
            width: 100%;
            padding: 16px;
            background: var(--md-sys-color-primary);
            color: white;
            border: none;
            border-radius: 50px;
            font-size: 1rem;
            font-weight: 600;
            margin-top: 20px;
            cursor: pointer;
            box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
            font-family: 'Sarabun', sans-serif;
        }

        .primary-btn:disabled {
            background: #ccc;
            box-shadow: none;
        }

        /* ===== Date Prompt Modal (deliver/inspect) ===== */
        .date-prompt-overlay {
            display: none;
            position: fixed;
            inset: 0;
            background: rgba(15, 23, 42, 0.5);
            z-index: 2200;
            align-items: center;
            justify-content: center;
            padding: 20px;
            opacity: 0;
            transition: opacity 0.22s ease;
        }
        .date-prompt-overlay.show { opacity: 1; }
        .date-prompt-content {
            background:
                radial-gradient(120% 80% at 0% 0%, #f0fdf4 0%, transparent 60%),
                radial-gradient(120% 80% at 100% 100%, #eff6ff 0%, transparent 60%),
                #ffffff;
            width: 100%;
            max-width: 400px;
            border-radius: 26px;
            padding: 28px 24px 22px;
            box-shadow:
                0 1px 1px rgba(255, 255, 255, 0.9) inset,
                0 30px 60px -20px rgba(15, 23, 42, 0.4),
                0 0 0 1px rgba(16, 24, 40, 0.05);
            transform: translate3d(0, 30px, 0) scale(0.96);
            transition: transform 0.28s cubic-bezier(0.22, 1, 0.36, 1);
            position: relative;
            text-align: center;
        }
        .date-prompt-overlay.show .date-prompt-content {
            transform: translate3d(0, 0, 0) scale(1);
        }
        .date-prompt-icon {
            width: 56px;
            height: 56px;
            border-radius: 18px;
            background: linear-gradient(135deg, #d1fae5 0%, #a7f3d0 100%);
            color: #047857;
            display: inline-flex;
            align-items: center;
            justify-content: center;
            margin: 0 auto 14px;
            box-shadow: 0 8px 18px -8px rgba(4, 120, 87, 0.4);
        }
        .date-prompt-icon .material-symbols-rounded { font-size: 28px; }
        .date-prompt-icon.icon-inspect {
            background: linear-gradient(135deg, #dbeafe 0%, #bfdbfe 100%);
            color: #1d4ed8;
            box-shadow: 0 8px 18px -8px rgba(29, 78, 216, 0.4);
        }
        #date-prompt-title {
            margin: 0 0 6px;
            font-size: 1.2rem;
            font-weight: 700;
            color: #0f172a;
            letter-spacing: -0.005em;
        }
        #date-prompt-subtitle {
            margin: 0 0 22px;
            font-size: 0.88rem;
            color: #6b7280;
            line-height: 1.5;
            word-break: break-word;
        }
        .date-prompt-label {
            display: block;
            text-align: left;
            font-size: 0.82rem;
            color: #6b7280;
            font-weight: 600;
            margin: 0 4px 8px;
        }
        .date-prompt-content #date-prompt-input {
            width: 100%;
            padding: 14px 16px;
            font-size: 1rem;
            font-family: 'Sarabun', sans-serif;
            border: 1.5px solid rgba(16, 24, 40, 0.12);
            border-radius: 14px;
            background: rgba(255, 255, 255, 0.7);
            color: #111827;
            margin-bottom: 22px;
            transition: border-color 0.2s, box-shadow 0.2s;
            box-sizing: border-box;
        }
        .date-prompt-content #date-prompt-input:focus {
            outline: none;
            border-color: #2e7d32;
            box-shadow: 0 0 0 4px rgba(46, 125, 50, 0.12);
        }
        .date-prompt-actions {
            display: grid;
            grid-template-columns: 1fr 1.4fr;
            gap: 10px;
        }
        .date-prompt-btn-cancel,
        .date-prompt-btn-confirm {
            padding: 13px 16px;
            border-radius: 999px;
            font-family: 'Sarabun', sans-serif;
            font-size: 0.95rem;
            font-weight: 600;
            cursor: pointer;
            transition: transform 0.15s ease, background 0.2s ease, box-shadow 0.2s ease;
            border: none;
        }
        .date-prompt-btn-cancel {
            background: rgba(16, 24, 40, 0.05);
            color: #374151;
        }
        .date-prompt-btn-cancel:hover { background: rgba(16, 24, 40, 0.08); }
        .date-prompt-btn-confirm {
            background: linear-gradient(135deg, #16a34a 0%, #15803d 100%);
            color: #ffffff;
            box-shadow: 0 4px 12px -4px rgba(22, 163, 74, 0.5);
        }
        .date-prompt-btn-confirm:hover {
            box-shadow: 0 8px 18px -4px rgba(22, 163, 74, 0.6);
            transform: translateY(-1px);
        }
        .date-prompt-btn-confirm.btn-inspect {
            background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
            box-shadow: 0 4px 12px -4px rgba(29, 78, 216, 0.5);
        }
        .date-prompt-btn-confirm.btn-inspect:hover {
            box-shadow: 0 8px 18px -4px rgba(29, 78, 216, 0.6);
        }
        .date-prompt-btn-cancel:active,
        .date-prompt-btn-confirm:active { transform: scale(0.97); }

        /* --- PDF Modal --- */
        .pdf-modal-content {
            background: white;
            width: 95%;
            height: 90vh;
            /* Full height */
            border-radius: 12px;
            position: relative;
            display: flex;
            flex-direction: column;
            overflow: hidden;
            box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
        }

        .pdf-frame {
            border: none;
            width: 100%;
            flex: 1;
            background: #eee;
        }

        .pdf-header {
            padding: 15px 20px;
            background: #f8f9fa;
            border-bottom: 1px solid #ddd;
            display: flex;
            justify-content: space-between;
            align-items: center;
            font-weight: bold;
            color: #444;
        }

        /* ─── Mobile Performance Optimization ─── */
        @media (max-width: 768px) {
            /* Kill expensive backdrop-filter on mobile — saves GPU */
            .tab-btn,
            .search-box,
            .filter-chip,
            .card-chip,
            .card-footer,
            .card-logo,
            .status-pill,
            .admin-toggle {
                backdrop-filter: none !important;
                -webkit-backdrop-filter: none !important;
            }

            /* Remove decorative blurred pseudo-elements */
            .project-card::before,
            .stat-card::before,
            header::before,
            header::after {
                display: none !important;
            }

            /* Promote scrolling layers to GPU */
            .project-card {
                will-change: transform;
                transform: translateZ(0);
            }

            /* Reduce animation complexity */
            .project-card {
                animation-duration: 0.2s !important;
            }
            .project-card:hover {
                transform: none;
                box-shadow: 0 1px 1px rgba(16, 24, 40, 0.03), 0 10px 24px -12px rgba(16, 24, 40, 0.10), inset 0 1px 0 rgba(255, 255, 255, 0.6);
            }
        }