/* ===== LOCAL FONTS (Sarabun) ===== */
@font-face { font-family:'Sarabun'; font-weight:300; font-style:normal; font-display:swap;
  src: url('fonts/sarabun-300-thai.woff2') format('woff2');
  unicode-range: U+02D7,U+0303,U+0331,U+0E01-0E5B,U+200C-200D,U+25CC; }
@font-face { font-family:'Sarabun'; font-weight:300; font-style:normal; font-display:swap;
  src: url('fonts/sarabun-300-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+2000-206F,U+20AC,U+2122,U+FEFF,U+FFFD; }

@font-face { font-family:'Sarabun'; font-weight:400; font-style:normal; font-display:swap;
  src: url('fonts/sarabun-400-thai.woff2') format('woff2');
  unicode-range: U+02D7,U+0303,U+0331,U+0E01-0E5B,U+200C-200D,U+25CC; }
@font-face { font-family:'Sarabun'; font-weight:400; font-style:normal; font-display:swap;
  src: url('fonts/sarabun-400-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+2000-206F,U+20AC,U+2122,U+FEFF,U+FFFD; }

@font-face { font-family:'Sarabun'; font-weight:500; font-style:normal; font-display:swap;
  src: url('fonts/sarabun-500-thai.woff2') format('woff2');
  unicode-range: U+02D7,U+0303,U+0331,U+0E01-0E5B,U+200C-200D,U+25CC; }
@font-face { font-family:'Sarabun'; font-weight:500; font-style:normal; font-display:swap;
  src: url('fonts/sarabun-500-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+2000-206F,U+20AC,U+2122,U+FEFF,U+FFFD; }

@font-face { font-family:'Sarabun'; font-weight:600; font-style:normal; font-display:swap;
  src: url('fonts/sarabun-600-thai.woff2') format('woff2');
  unicode-range: U+02D7,U+0303,U+0331,U+0E01-0E5B,U+200C-200D,U+25CC; }
@font-face { font-family:'Sarabun'; font-weight:600; font-style:normal; font-display:swap;
  src: url('fonts/sarabun-600-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+2000-206F,U+20AC,U+2122,U+FEFF,U+FFFD; }

@font-face { font-family:'Sarabun'; font-weight:700; font-style:normal; font-display:swap;
  src: url('fonts/sarabun-700-thai.woff2') format('woff2');
  unicode-range: U+02D7,U+0303,U+0331,U+0E01-0E5B,U+200C-200D,U+25CC; }
@font-face { font-family:'Sarabun'; font-weight:700; font-style:normal; font-display:swap;
  src: url('fonts/sarabun-700-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+2000-206F,U+20AC,U+2122,U+FEFF,U+FFFD; }

/* ===== THEME VARIABLES ===== */
:root {
    --body-bg: linear-gradient(135deg, #0a2e10 0%, #0d3818 50%, #0a4418 100%);
    --dot-color: rgba(79,173,38,0.25);
    --login-footer-color: rgba(255,255,255,0.7);
    --login-footer-shadow: 0 1px 4px rgba(0,0,0,0.5);
    --page-bg: #f8fafc;
    --card-bg: #ffffff;
    --card-border: #e2e8f0;
    --text-primary: #2d3748;
    --text-muted: #718096;
    --input-bg: #f8fafc;
    --input-border: #e2e8f0;
    --table-header-bg: #f8fafc;
    --table-row-hover: #f0f4f8;
    --stat-card-bg: #ffffff;
    --topbar-bg: rgba(10,46,16,0.97);

    /* ---- ชื่อตัวแปรที่ฝั่งงานสินเชื่อใช้ (ค่าตรงกับของข้างบน) ---- */
    --green:       #1d6b22;
    --green-dark:  #155119;
    --green-light: #e8f3e9;
    /* ปุ่มหลักของ refinance เป็นไล่เฉดไม่ใช่สีตัน — จุดที่ตาจับได้ทันทีว่าคนละแอป */
    --green-grad:  linear-gradient(135deg, #1d6b22, #145218);
    /* ชุดสีข้อความ/เส้น/พื้น ยกมาจาก refinance ตรงตัว (โทน slate ไม่ใช่โทนเขียวอมเทา) */
    --ink:      #2d3748;
    --ink-soft: #718096;
    --line:     #e2e8f0;
    --bg:       #f8fafc;
    --card:     #ffffff;
    --red:    #c62828;
    --orange: #e07a1f;
    --yellow: #b58900;
    --blue:   #1565c0;
    --purple: #6a3fb5;
    --gray:   #6b7280;
    /* การ์ดของ refinance มนกว่าและเงาฟุ้งกว่าของเดิมเรา */
    --radius: 16px;
    --shadow: 0 2px 16px rgba(0, 0, 0, .08);
    /* พื้นหลังไล่เฉดเขียว + ลายจุด — ใช้เฉพาะหน้าล็อกอิน เหมือนที่ refinance ทำ */
    --login-bg:  linear-gradient(135deg, #0a2e10 0%, #0d3818 50%, #0a4418 100%);
    /* แถบบนของ refinance โปร่งแสงแล้วเบลอสิ่งที่อยู่ใต้มัน ไม่ใช่สีเขียวทึบ */
}

@media (prefers-color-scheme: light) {
    :root {
        --body-bg: linear-gradient(135deg, #eef6ef 0%, #f0f7f1 50%, #f5faf5 100%);
        --dot-color: rgba(29,107,34,0.14);
        --login-footer-color: rgba(20,60,20,0.6);
        --login-footer-shadow: none;
        --login-card-bg: #ffffff;
        --login-card-shadow: 0 25px 60px rgba(0,0,0,0.12);
        --login-label-color: #2d3748;
        --login-input-bg: #f8fafc;
        --login-input-border: #e2e8f0;
        --login-input-color: #2d3748;
        --login-placeholder: #b0bec5;
        --login-input-focus-bg: #ffffff;
    }
}

@media (prefers-color-scheme: dark) {
    :root {
        --dot-color: rgba(255,255,255,0.12);
        --login-card-bg: #1b3f1f;
        --login-card-shadow: 0 0 20px rgba(255,255,255,0.35), 0 0 60px rgba(255,255,255,0.18), 0 0 120px rgba(255,255,255,0.08);
        --login-card-border: none;
        --login-label-color: #f0f0f0;
        --login-input-bg: #0a1f0c;
        --login-input-border: #1e4a22;
        --login-input-color: #e8f5e9;
        --login-placeholder: #4a7a4e;
        --login-input-focus-bg: #0a1f0c;
    }
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* ===== SELECTION PAGE ===== */
body.select-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 20px;
}

.select-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 32px;
    width: 100%;
    max-width: 560px;
}

.select-header {
    text-align: center;
    color: #fff;
}

.select-logo {
    font-size: 3.5rem;
    display: block;
    margin-bottom: 12px;
}

.select-header h1 {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 6px;
}

.select-header p {
    font-size: 0.95rem;
    opacity: 0.6;
    font-weight: 300;
}

.select-cards {
    display: flex;
    flex-direction: column;
    gap: 14px;
    width: 100%;
}

.user-card {
    display: flex;
    align-items: center;
    gap: 20px;
    padding: 22px 26px;
    border-radius: 16px;
    border: none;
    cursor: pointer;
    font-family: 'Sarabun', sans-serif;
    text-align: left;
    transition: all 0.2s ease;
    box-shadow: 0 6px 24px rgba(0,0,0,0.2);
}

.ae-card {
    background: linear-gradient(135deg, #ffffff, #f0f4ff);
    color: #1a1f36;
}

.ae-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 12px 32px rgba(29, 107, 34, 0.35);
}

.cro-card {
    background: linear-gradient(135deg, #0a2e10, #145218);
    color: #fff;
}

.cro-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 12px 32px rgba(0,0,0,0.4);
}

.card-icon {
    font-size: 2.2rem;
    width: 56px;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 14px;
    flex-shrink: 0;
}

.ae-card .card-icon {
    background: #e8f5e9;
}

.cro-card .card-icon {
    background: rgba(255,255,255,0.1);
}

.card-body {
    flex: 1;
}

.card-title {
    font-size: 1.4rem;
    font-weight: 700;
    letter-spacing: 1px;
    margin-bottom: 2px;
}

.card-desc {
    font-size: 0.88rem;
    line-height: 1.5;
}

.ae-card .card-desc {
    color: #718096;
}

.ae-card .card-desc span {
    color: #1d6b22;
    font-weight: 600;
}

.cro-card .card-desc {
    color: rgba(255,255,255,0.6);
}

.cro-card .card-desc span {
    color: #90cdf4;
    font-weight: 600;
}

.card-arrow {
    font-size: 1.3rem;
    opacity: 0.4;
    transition: all 0.2s;
}

.user-card:hover .card-arrow {
    opacity: 1;
    transform: translateX(4px);
}

.select-footer {
    color: rgba(255,255,255,0.35);
    font-size: 0.78rem;
}

/* ===== ROLE BADGE (login page) ===== */
.role-badge {
    display: inline-block;
    padding: 4px 14px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    margin-bottom: 14px;
}

.ae-badge {
    background: #e8f5e9;
    color: #1d6b22;
}

.cro-badge {
    background: #1a1f36;
    color: #90cdf4;
    border: 1px solid rgba(144,205,244,0.3);
}

/* ===== TOPBAR ROLE TAG ===== */
.topbar-role-tag {
    font-size: 0.72rem;
    font-weight: 700;
    padding: 3px 10px;
    border-radius: 10px;
    letter-spacing: 0.5px;
}

.ae-tag {
    background: rgba(29, 107, 34, 0.25);
    color: #a5d6a7;
}

.cro-tag {
    background: rgba(144, 205, 244, 0.2);
    color: #90cdf4;
}
/* เดิม admin_dashboard.php เขียน style สีนี้ไว้ inline ในแท็ก
 * ย้ายมาเป็นคลาสเพราะตอนนี้ topbar มีที่เดียว จะฝัง style ของ role เดียวไว้ในนั้นไม่ได้ */
.admin-tag {
    background: rgba(251, 191, 36, 0.25);
    color: #f59e0b;
}

/* ===== LOGIN BACK LINK ===== */
.login-back {
    color: rgba(255,255,255,0.5);
    font-size: 0.85rem;
    text-decoration: none;
    align-self: flex-start;
    transition: color 0.2s;
    margin-bottom: -10px;
}

.login-back:hover {
    color: rgba(255,255,255,0.85);
}

/* ===== LOGIN PAGE ===== */
body.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 20px;
    overflow: hidden;
    background:
        radial-gradient(circle, var(--dot-color) 1px, transparent 1px),
        var(--body-bg);
    background-size: 28px 28px, auto;
}


.login-bg-svg {
    position: fixed;
    inset: 0;
    z-index: 0;
    overflow: hidden;
    pointer-events: none;
}
.login-bg-svg svg {
    width: 100%;
    height: 100%;
}

.login-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 18px;
    width: 100%;
    position: relative;
    z-index: 1;
}

.login-card {
    background: var(--login-card-bg, #fff);
    box-shadow: var(--login-card-shadow, 0 25px 60px rgba(0,0,0,0.35));
    border: var(--login-card-border, none);
    border-radius: 20px;
    padding: 48px 44px;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 25px 60px rgba(0,0,0,0.35);
    text-align: center;
}

.login-logo {
    font-size: 3.2rem;
    margin-bottom: 14px;
    display: block;
}

.login-title {
    font-size: 1.7rem;
    font-weight: 700;
    color: #1a1f36;
    margin-bottom: 4px;
}

.login-subtitle {
    font-size: 0.88rem;
    color: #a0aec0;
    margin-bottom: 36px;
    letter-spacing: 0.8px;
    text-transform: uppercase;
    font-weight: 500;
}

.login-field {
    text-align: left;
    margin-bottom: 22px;
}

.login-field label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--login-label-color, #4a5568);
    margin-bottom: 8px;
}

.login-field input {
    width: 100%;
    padding: 13px 16px;
    border: 1.5px solid var(--login-input-border, #e2e8f0);
    background: var(--login-input-bg, #f8fafc);
    color: var(--login-input-color, #2d3748);
    border-radius: 10px;
    font-size: 1rem;
    font-family: 'Sarabun', sans-serif;
    color: #2d3748;
    background: #fafbfc;
    text-align: center;
    letter-spacing: 0.3px;
    transition: all 0.2s;
    outline: none;
}

.login-field input:focus {
    border-color: #1d6b22;
    background: var(--login-input-focus-bg, #fff);
    box-shadow: 0 0 0 3px rgba(29, 107, 34, 0.15);
}

.password-field-wrap { position: relative; }
.password-field-wrap input { padding-right: 44px; }
.password-toggle-btn {
    position: absolute;
    right: 6px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.1rem;
    padding: 6px 8px;
    line-height: 1;
    opacity: 0.55;
    transition: opacity 0.2s;
}
.password-toggle-btn:hover { opacity: 1; }

/* Export status filter dropdown */
.export-dropdown { position: relative; display: inline-flex; align-items: center; gap: 6px; }
.export-dropdown .btn-primary { height: 42px; box-sizing: border-box; }
.export-filter-btn {
    width: 42px;
    height: 42px;
    padding: 0;
    box-sizing: border-box;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    border: 1.5px solid #1d6b22;
    background: #fff;
    color: #1d6b22;
    font-size: 1.1rem;
    cursor: pointer;
    flex-shrink: 0;
    transition: background .15s, color .15s;
}
.export-filter-btn:hover { background: #1d6b22; color: #fff; }
.export-status-panel {
    position: absolute;
    right: 0;
    top: calc(100% + 8px);
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    box-shadow: 0 8px 24px rgba(0,0,0,.15);
    padding: 14px;
    width: 270px;
    z-index: 50;
    text-align: left;
}
.export-status-panel-header {
    border-bottom: 1px solid #e2e8f0;
    padding-bottom: 8px;
    margin-bottom: 8px;
    font-weight: 600;
    font-size: .85rem;
    color: #2d3748;
}
.export-status-list {
    max-height: 280px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 7px;
    font-size: .85rem;
    color: #4a5568;
}
.export-status-list label,
.export-status-panel-header label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}

.login-field input::placeholder {
    color: var(--login-placeholder, #b0bec5);
    font-weight: 300;
}

.btn-login {
    width: 100%;
    padding: 13px;
    background: linear-gradient(135deg, #1d7a24, #145218);
    color: #fff;
    border: none;
    border-radius: 10px;
    font-size: 1rem;
    font-weight: 600;
    font-family: 'Sarabun', sans-serif;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 4px 14px rgba(29, 107, 34, 0.4);
    margin-top: 4px;
}

.btn-login:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 18px rgba(29, 107, 34, 0.5);
}

.btn-login:disabled {
    opacity: 0.7;
    cursor: not-allowed;
    transform: none;
}

.login-footer {
    color: var(--login-footer-color);
    font-size: 0.78rem;
    text-shadow: var(--login-footer-shadow);
}

/* ===== TOP BAR (form page) ===== */
.topbar {
    position: sticky;
    top: 0;
    z-index: 100;
    background: rgba(10, 46, 16, 0.97);
    backdrop-filter: blur(10px);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 28px;
    height: 56px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.25);
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.topbar-logo {
    font-size: 1.3rem;
}

.topbar-logo-img {
    height: 34px;
    width: auto;
    display: block;
    object-fit: contain;
}

.topbar-title {
    font-size: 1rem;
    font-weight: 700;
    color: #fff;
    letter-spacing: 0.3px;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 14px;
}

.topbar-user {
    color: rgba(255,255,255,0.8);
    font-size: 0.9rem;
    font-weight: 500;
    background: rgba(255,255,255,0.1);
    padding: 5px 14px;
    border-radius: 20px;
}

.btn-logout {
    background: #b91c1c;
    color: #fff;
    border: 1px solid #991b1b;
    border-radius: 8px;
    padding: 6px 14px;
    font-size: 0.82rem;
    font-family: 'Sarabun', sans-serif;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
}

.btn-logout:hover {
    background: #7f1d1d;
    color: #fff;
    border-color: #7f1d1d;
}

body {
    font-family: 'Sarabun', sans-serif;
    background: var(--body-bg);
    min-height: 100vh;
    padding: 0;
    color: #2d3748;
}

.page-wrapper {
    max-width: 860px;
    margin: 0 auto;
    padding: 30px 20px;
}

/* Header */
.header {
    text-align: center;
    margin-bottom: 30px;
    color: #fff;
}

.header-icon {
    font-size: 3rem;
    margin-bottom: 10px;
    display: block;
}

.header h1 {
    font-size: 2rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    margin-bottom: 6px;
}

.header p {
    font-size: 1rem;
    opacity: 0.7;
    font-weight: 300;
}

/* Card Container */
.container {
    background: #fff;
    border-radius: 20px;
    overflow: hidden;
    box-shadow: 0 25px 60px rgba(0,0,0,0.35);
}

/* Alert */
.alert {
    margin: 20px 30px 0;
    padding: 14px 18px;
    border-radius: 10px;
    font-size: 0.95rem;
    font-weight: 500;
}

.alert.alert-error {
    background: #fff5f5;
    border: 1px solid #fed7d7;
    color: #c53030;
}

.alert.alert-success {
    background: #f0fff4;
    border: 1px solid #9ae6b4;
    color: #276749;
}

/* Section */
.section {
    padding: 28px 35px;
    border-bottom: 1px solid #f0f4f8;
}

.section:last-of-type {
    border-bottom: none;
}

.section-title {
    font-size: 1.05rem;
    font-weight: 700;
    color: #1a1f36;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
    padding-bottom: 12px;
    border-bottom: 2px solid #e8f5e9;
}

.section-icon {
    font-size: 1.2rem;
    background: #e8f5e9;
    width: 36px;
    height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
}

/* Form Grid */
.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 18px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-group.full-width {
    grid-column: 1 / -1;
}

label {
    font-size: 0.88rem;
    font-weight: 600;
    color: #4a5568;
    letter-spacing: 0.2px;
}

.required {
    color: #e53e3e;
    margin-left: 2px;
}

input[type="text"],
input[type="tel"],
input[type="number"],
select,
textarea {
    padding: 11px 14px;
    border: 1.5px solid #e2e8f0;
    border-radius: 10px;
    font-size: 0.95rem;
    font-family: 'Sarabun', sans-serif;
    color: #2d3748;
    background: #fafbfc;
    transition: all 0.2s ease;
    outline: none;
}

input[readonly] {
    background: #eef1f5;
    color: #718096;
    cursor: not-allowed;
}

input[type="text"]:focus,
input[type="tel"]:focus,
input[type="number"]:focus,
select:focus,
textarea:focus {
    border-color: #1d6b22;
    background: #fff;
    box-shadow: 0 0 0 3px rgba(29, 107, 34, 0.1);
}

input[type="text"]::placeholder,
input[type="tel"]::placeholder,
input[type="number"]::placeholder,
textarea::placeholder {
    color: #b0bec5;
    font-weight: 300;
}

input.input-error,
select.input-error {
    border-color: #e53e3e;
    background: #fff5f5;
}

textarea {
    resize: vertical;
    min-height: 90px;
}

select {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%23718096' d='M1 1l5 5 5-5'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    padding-right: 36px;
}

.error-msg {
    font-size: 0.78rem;
    color: #e53e3e;
    font-weight: 500;
    min-height: 16px;
}

/* Form Actions */
.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 14px;
    padding: 24px 35px;
    background: #f8fafc;
    border-top: 1px solid #f0f4f8;
}

.btn-primary,
.btn-secondary {
    padding: 12px 30px;
    border-radius: 10px;
    font-size: 0.95rem;
    font-weight: 600;
    font-family: 'Sarabun', sans-serif;
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-primary {
    background: linear-gradient(135deg, #1d6b22, #145218);
    color: #fff;
    box-shadow: 0 4px 14px rgba(29, 107, 34, 0.4);
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 18px rgba(29, 107, 34, 0.5);
}

.btn-stats {
    background: linear-gradient(135deg, #2a78d6, #1c5cab);
    box-shadow: 0 4px 14px rgba(42, 120, 214, 0.4);
}
.btn-stats:hover {
    box-shadow: 0 6px 18px rgba(42, 120, 214, 0.5);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-primary:disabled {
    opacity: 0.7;
    cursor: not-allowed;
    transform: none;
}

.btn-secondary {
    background: #fff;
    color: #718096;
    border: 1.5px solid #e2e8f0;
}

.btn-secondary:hover {
    background: #f7fafc;
    border-color: #cbd5e0;
    color: #4a5568;
}

/* Modal */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.55);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
    backdrop-filter: blur(4px);
}

.modal-box {
    background: #fff;
    border-radius: 20px;
    padding: 45px 40px;
    text-align: center;
    max-width: 400px;
    width: 100%;
    box-shadow: 0 20px 60px rgba(0,0,0,0.25);
    animation: popIn 0.3s ease;
}

@keyframes popIn {
    from { transform: scale(0.85); opacity: 0; }
    to   { transform: scale(1); opacity: 1; }
}

.modal-icon {
    width: 72px;
    height: 72px;
    background: linear-gradient(135deg, #48bb78, #38a169);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    color: #fff;
    margin: 0 auto 20px;
    box-shadow: 0 8px 20px rgba(72, 187, 120, 0.4);
}

.modal-box h2 {
    font-size: 1.4rem;
    font-weight: 700;
    color: #1a1f36;
    margin-bottom: 10px;
}

.modal-box p {
    color: #718096;
    font-size: 0.95rem;
    margin-bottom: 28px;
    line-height: 1.6;
}

.modal-box .btn-primary {
    width: 100%;
    justify-content: center;
    font-size: 1rem;
}

/* ===== CONTENT AREA (light bg for dashboard/detail pages) ===== */
.content-area {
    background: #f0f4f8;
    min-height: calc(100vh - 56px);
}

/* ===== STATUS BADGES ===== */
.badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
    white-space: nowrap;
}
.status-blue   { background: #ebf8ff; color: #2b6cb0; }
.status-orange { background: #fff7ed; color: #c05621; }
.status-red    { background: #fff5f5; color: #c53030; }
.status-green  { background: #f0fff4; color: #276749; }
.status-yellow { background: #fffff0; color: #975a16; }
.status-gray   { background: #f7fafc; color: #718096; }
.status-pink   { background: #fdf2f8; color: #be185d; }

/* ===== DASHBOARD ===== */
.dash-wrapper {
    max-width: 1200px;
    margin: 0 auto;
    padding: 28px 24px 48px;
}
.dash-header {
    margin-bottom: 24px;
}
.dash-header h2 {
    font-size: 1.4rem;
    font-weight: 700;
    color: #1a202c;
    margin-bottom: 16px;
}
.dash-stats {
    display: grid;
    grid-template-columns: repeat(9, 1fr);
    gap: 8px;
}
.stat-card {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 10px 6px;
    text-align: center;
    min-width: 0;
    color: #1a202c;
    text-decoration: none;
    transition: all 0.2s;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}
.stat-card:hover, .stat-card.active {
    transform: translateY(-3px);
    box-shadow: 0 8px 24px rgba(0,0,0,0.12);
    border-color: #cbd5e0;
}
.stat-num { font-size: 1.4rem; font-weight: 700; line-height: 1; margin-bottom: 3px; }
.stat-label { font-size: 0.62rem; color: #718096; letter-spacing: 0.2px; }
.stat-blue   { border-top: 3px solid #1d6b22; }
.stat-blue   .stat-num { color: #1d6b22; }
.stat-orange { border-top: 3px solid #f6993f; }
.stat-orange .stat-num { color: #d97706; }
.stat-red    { border-top: 3px solid #e53e3e; }
.stat-red    .stat-num { color: #e53e3e; }
.stat-green  { border-top: 3px solid #38a169; }
.stat-green  .stat-num { color: #38a169; }
.stat-purple { border-top: 3px solid #7c3aed; }
.stat-purple .stat-num { color: #7c3aed; }
.stat-teal   { border-top: 3px solid #0d9488; }
.stat-teal   .stat-num { color: #0d9488; }
.stat-gray   { border-top: 3px solid #718096; }
.stat-gray   .stat-num { color: #718096; }
.stat-indigo { border-top: 3px solid #4f46e5; }
.stat-indigo .stat-num { color: #4f46e5; }

/* Page header card */
.page-header-card {
    background: #fff;
    border-radius: 14px;
    padding: 20px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.07);
    border: 1px solid #e8edf2;
}
.page-header-left { display: flex; flex-direction: column; gap: 3px; }
.page-title { font-size: 1.25rem; font-weight: 700; color: #1a202c; }
.page-subtitle { font-size: 0.85rem; color: #718096; }

/* Dash card (white card wrapping table) */
.dash-card {
    background: #fff;
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 2px 16px rgba(0,0,0,0.08);
    border: 1px solid #e8edf2;
    margin-top: 16px;
}
.dash-card-header {
    padding: 14px 20px;
    background: #f8fafc;
    border-bottom: 1px solid #e8edf2;
    font-size: 0.85rem;
    font-weight: 600;
    color: #4a5568;
}

/* Table helpers */
.table-empty { text-align: center; padding: 48px 20px; color: #a0aec0; font-size: 0.95rem; }
.td-name { font-weight: 600; color: #1a202c; }
.td-car {
    color: #4a5568;
    max-width: 140px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    line-height: 1.7;
}
.td-id .case-id {
    display: inline-block;
    max-width: 160px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    vertical-align: bottom;
    line-height: 1.7;
}
.td-amount { font-weight: 600; color: #2d3748; white-space: nowrap; }
.td-actions { display: flex; flex-direction: column; gap: 6px; align-items: stretch; }
.td-actions > * { white-space: normal; overflow-wrap: break-word; flex-shrink: 0; width: 100%; text-align: center; line-height: 1.25; }
/* จอกว้าง: ช่องปุ่มต้องเป็น table-cell — ถ้าเป็น flex ช่องจะไม่ยืดตามความสูงแถว
   แถวที่สูง (เช่นแถวแดงที่มีคำเตือน) เลยเห็นพื้นขาวโผล่ใต้ปุ่ม
   (มือถือ ≤640px ยังเป็น flex ตามเดิม — การ์ดใช้แบบนั้น) */
@media (min-width: 641px) {
    .dash-table td.td-actions { display: table-cell; }
    .dash-table td.td-actions > * { display: block; }
    .dash-table td.td-actions > * + * { margin-top: 6px; }
}
/* ป้ายสถานะในตารางขึ้นบรรทัดใหม่ได้ — คอลัมน์กว้างคงที่ ป้ายยาวอย่าง
   "รอแจ้งผลลูกค้า (อนุมัติ)" ถูกตัดหายไปครึ่งคำ */
.dash-table td .badge { white-space: normal; line-height: 1.35; }
.dash-table .td-actions .btn-assign,
.dash-table .td-actions .btn-view,
.dash-table .td-actions .btn-reassign {
    padding: 5px 6px;
    font-size: 0.78rem;
    box-sizing: border-box;
}

/* ซ่อนคอลัมน์เบอร์โทรบนจอกว้าง โชว์เฉพาะบนมือถือ (การ์ดมีที่พอ) */
.col-phone-mobile { display: none; }

/* stat-active */
.stat-active { box-shadow: 0 0 0 2px #1d6b22; border-color: #1d6b22; }

/* Dashboard Table */
.dash-table-wrap {
    background: #fff;
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 10px 40px rgba(0,0,0,0.25);
}
.dash-table-scroll { overflow-x: auto; }
.dash-table {
    width: 100%;
    table-layout: fixed;
    border-collapse: collapse;
    font-size: 0.85rem;
}
.dash-table th {
    background: #f1f5f9;
    padding: 11px 14px;
    text-align: left;
    font-weight: 700;
    color: #4a5568;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    border-bottom: 2px solid #e2e8f0;
    white-space: nowrap;
}
.dash-table td {
    padding: 11px 14px;
    border-bottom: 1px solid #e2e8f0;
    color: #2d3748;
    vertical-align: middle;
    overflow-wrap: break-word;
    overflow: hidden;
}
.dash-table tbody tr:nth-child(even) td { background: #f8fafc; }
.dash-table tr:last-child td { border-bottom: none; }
.dash-table tr:hover td { background: #f8fafc; }

.case-id {
    font-weight: 700;
    color: #1d6b22;
    text-decoration: none;
}
.case-id:hover { text-decoration: underline; }

.btn-assign {
    background: linear-gradient(135deg, #1d6b22, #145218);
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 6px 14px;
    font-size: 0.82rem;
    font-family: 'Sarabun', sans-serif;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}
.btn-assign:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(74,108,247,0.4); }
.btn-reassign { background: linear-gradient(135deg, #f6993f, #dd6b20); }
.btn-reassign:hover { box-shadow: 0 4px 12px rgba(246,153,63,0.4); }

.btn-close-case { background: linear-gradient(135deg, #f472b6, #db2777); }
.btn-close-case:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(219,39,119,0.4); }

.btn-return-case {
    background: linear-gradient(135deg, #ef4444, #b91c1c);
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 10px 16px;
    font-size: 0.88rem;
    font-family: 'Sarabun', sans-serif;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
}
.btn-return-case:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(185,28,28,0.4); }

.btn-accept {
    background: linear-gradient(135deg, #48bb78, #38a169);
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 6px 14px;
    font-size: 0.82rem;
    font-family: 'Sarabun', sans-serif;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}
.btn-accept:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(72,187,120,0.4); }

.btn-view {
    background: rgba(74,108,247,0.1);
    color: #1d6b22;
    border: 1px solid rgba(74,108,247,0.2);
    border-radius: 8px;
    padding: 6px 12px;
    font-size: 0.82rem;
    font-family: 'Sarabun', sans-serif;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    display: inline-block;
    transition: all 0.2s;
}
.btn-view:hover { background: rgba(74,108,247,0.18); }

/* หน้าที่กำลังเปิดอยู่ — ใช้กับลิงก์เมนูบน topbar
 * ควบรวมแล้ว topbar มีลิงก์ข้ามฝั่งหลายอัน ถ้าไม่ทำตัวที่เปิดอยู่ให้เด่น
 * คนเปิดหลายแท็บพร้อมกัน (ซึ่งเป็นเรื่องปกติ) จะไม่รู้ว่าตัวเองอยู่หน้าไหน */
.btn-view-active,
.btn-view-active:hover {
    background: #fff;
    color: #0a2e10;
    border-color: #fff;
    font-weight: 700;
}

/* Countdown */
.countdown {
    font-size: 0.9rem;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    color: #d97706;
}

/* ===== TOPBAR BACK LINK ===== */
.topbar-back {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: rgba(255,255,255,0.9);
    font-size: 0.85rem;
    font-weight: 600;
    text-decoration: none;
    background: rgba(255,255,255,0.12);
    border: 1px solid rgba(255,255,255,0.18);
    padding: 6px 14px 6px 10px;
    border-radius: 20px;
    transition: all 0.2s;
}
.topbar-back:hover { background: rgba(255,255,255,0.22); color: #fff; }

/* ===== CASE DETAIL ===== */
.detail-wrapper {
    max-width: 900px;
    margin: 0 auto;
    padding: 28px 24px 48px;
}
.detail-header {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 18px;
    padding: 26px 32px;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 20px;
    color: #1a202c;
    box-shadow: 0 4px 16px rgba(0,0,0,0.08);
    border-left: 5px solid #1d6b22;
}
.detail-case-id {
    display: inline-block;
    background: #e8f5e9;
    color: #1d6b22;
    border-radius: 20px;
    padding: 3px 12px;
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}
.detail-customer { font-size: 1.7rem; font-weight: 700; color: #1a202c; margin-bottom: 4px; }
.detail-phone { font-size: 0.95rem; color: #718096; }
.detail-body { display: flex; flex-direction: column; gap: 16px; }

.detail-card {
    background: #fff;
    border-radius: 16px;
    padding: 24px 28px;
    box-shadow: 0 6px 24px rgba(0,0,0,0.15);
}
.detail-card-title {
    font-size: 0.95rem;
    font-weight: 700;
    color: #1a1f36;
    margin-bottom: 18px;
    padding-bottom: 12px;
    border-bottom: 2px solid #e8f5e9;
    display: flex;
    align-items: center;
    gap: 8px;
}
.detail-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 18px 32px;
}
.detail-grid > div {
    display: flex;
    flex-direction: column;
    gap: 3px;
}
.detail-label {
    display: block;
    font-size: 0.72rem;
    font-weight: 700;
    color: #a0aec0;
    text-transform: uppercase;
    letter-spacing: 0.6px;
}
.detail-grid > div > *:last-child:not(.detail-label) {
    font-size: 0.95rem;
    color: #1a202c;
    font-weight: 500;
}
.status-select-input {
    padding: 10px 14px;
    border: 1.5px solid #e2e8f0;
    border-radius: 10px;
    font-size: 0.95rem;
    font-family: 'Sarabun', sans-serif;
    color: #2d3748;
    background: #fafbfc;
    min-width: 240px;
    cursor: pointer;
    outline: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%23718096' d='M1 1l5 5 5-5'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    padding-right: 36px;
}
.status-select-input:focus { border-color: #1d6b22; box-shadow: 0 0 0 3px rgba(74,108,247,0.1); }

/* Notes */
.notes-log {
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-height: 360px;
    overflow-y: auto;
    padding-right: 4px;
    margin-bottom: 16px;
}
.note-empty { color: #a0aec0; font-size: 0.9rem; text-align: center; padding: 24px 0; }
.note-item {
    background: #f8fafc;
    border-radius: 10px;
    padding: 12px 16px;
    border-left: 3px solid #e2e8f0;
}
.note-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
    flex-wrap: wrap;
}
.note-author { font-weight: 600; color: #2d3748; font-size: 0.88rem; }
.note-role-tag {
    font-size: 0.7rem;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 8px;
    background: rgba(74,108,247,0.1);
    color: #1d6b22;
    letter-spacing: 0.3px;
}
.note-role-tag.cro-tag { background: rgba(144,205,244,0.2); color: #2b77a8; }
.note-date { color: #a0aec0; font-size: 0.78rem; margin-left: auto; }
.note-text { color: #4a5568; font-size: 0.9rem; line-height: 1.6; }
.note-form textarea {
    width: 100%;
    border: 1.5px solid #e2e8f0;
    border-radius: 10px;
    padding: 12px 14px;
    font-size: 0.9rem;
    font-family: 'Sarabun', sans-serif;
    color: #2d3748;
    background: #fafbfc;
    resize: vertical;
    outline: none;
    transition: border-color 0.2s;
}
.note-form textarea:focus { border-color: #1d6b22; box-shadow: 0 0 0 3px rgba(74,108,247,0.1); }

/* ===== MODAL select fix ===== */
.modal-box .login-field select {
    width: 100%;
    padding: 11px 14px;
    border: 1.5px solid #e2e8f0;
    border-radius: 10px;
    font-size: 0.95rem;
    font-family: 'Sarabun', sans-serif;
    color: #2d3748;
    background: #fafbfc;
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%23718096' d='M1 1l5 5 5-5'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    padding-right: 36px;
    outline: none;
}

/* ===== RESPONSIVE ===== */

/* Tablet */
@media (max-width: 900px) {
    .dash-wrapper { padding: 20px 16px 36px; }
    .dash-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
    .detail-grid { gap: 14px 20px; }
}

/* ===== HAMBURGER BUTTON ===== */
.topbar-hamburger {
    display: none;
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: 8px;
    color: #fff;
    width: 36px;
    height: 36px;
    font-size: 1.2rem;
    line-height: 1;
    cursor: pointer;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.2s;
}
.topbar-hamburger:hover { background: rgba(255,255,255,0.18); }

/* Mobile */
@media (max-width: 640px) {

    /* Topbar — hamburger layout */
    .topbar {
        height: auto;
        padding: 10px 14px;
        flex-wrap: wrap;
        gap: 0;
        align-items: center;
    }
    .topbar-left { flex: 1; gap: 8px; }
    .topbar-logo { font-size: 1.1rem; }
    .topbar-title { font-size: 0.9rem; }
    .topbar-role-tag { font-size: 0.68rem; padding: 2px 8px; }
    .topbar-hamburger { display: flex; }

    /* Menu drawer — hidden by default */
    .topbar-right {
        display: none;
        width: 100%;
        flex-direction: column;
        gap: 6px;
        padding: 10px 0 4px;
        border-top: 1px solid rgba(255,255,255,0.12);
        margin-top: 8px;
    }
    .topbar-right.open { display: flex; }

    /* Items inside drawer */
    .topbar-user {
        display: flex !important;
        background: rgba(255,255,255,0.07);
        border-radius: 8px;
        padding: 9px 14px;
        font-size: 0.9rem;
        justify-content: center;
        color: rgba(255,255,255,0.85);
    }
    .topbar-right a,
    .topbar-right .btn-logout,
    .topbar-right .btn-view {
        width: 100%;
        text-align: center;
        justify-content: center;
        padding: 10px 14px;
        font-size: 0.9rem;
        border-radius: 8px;
        display: block;
        box-sizing: border-box;
    }
    .topbar-back {
        font-size: 0.85rem;
        padding: 5px 12px 5px 8px;
    }

    /* Content area */
    .content-area { min-height: calc(100vh - 52px); }
    .dash-wrapper { padding: 14px 12px 32px; }

    /* กล่องผลการค้นหา: กลืนกับพื้นหลังหน้าจอมือถือ ไม่ต้องมีกรอบ/เงาซ้อนกับการ์ดรถแต่ละคัน */
    #cc-results-card {
        background: transparent;
        border: none;
        box-shadow: none;
        border-radius: 0;
    }
    #cc-results-card .dash-card-header {
        background: transparent;
        border-bottom: none;
        padding: 14px 4px 8px;
    }
    #cc-results-card .dash-table-scroll { padding: 0 4px; }

    /* Page header card */
    .page-header-card {
        padding: 14px 16px;
        flex-direction: column;
        gap: 12px;
        align-items: flex-start;
    }
    .page-title { font-size: 1.05rem; }
    .page-subtitle { font-size: 0.82rem; }
    .page-header-card .btn-primary { width: 100%; justify-content: center; }

    /* Stat cards: 2 per row */
    .dash-stats {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }
    .stat-card { padding: 14px 12px; border-radius: 12px; min-width: 0; }
    .stat-num { font-size: 1.8rem; }
    .stat-label { font-size: 0.72rem; }

    /* Dash card */
    .dash-card { border-radius: 12px; margin-top: 12px; }
    .dash-card-header { padding: 12px 14px; font-size: 0.82rem; }

    /* Card Table: แปลง table เป็น card บนมือถือ */
    .dash-table-scroll { overflow: visible; }
    .dash-table { min-width: 0 !important; width: 100%; }
    .dash-table thead { display: none; }
    .dash-table tbody tr {
        display: block;
        background: #fff;
        border: 2px solid #1d6b22;
        border-radius: 12px;
        margin: 0 0 16px 0;
        padding: 4px 0;
        box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    }
    .dash-table tbody tr:last-child { margin-bottom: 0; }
    .dash-table tbody tr:nth-child(even) td { background: transparent; }
    .dash-table tbody td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 9px 16px;
        font-size: 0.88rem;
        border-bottom: none;
        text-align: right;
        min-width: 0;
        gap: 10px;
    }
    .dash-table tbody td::before {
        content: attr(data-label);
        font-size: 0.72rem;
        font-weight: 700;
        color: #a0aec0;
        text-transform: uppercase;
        letter-spacing: 0.5px;
        flex-shrink: 0;
        text-align: left;
    }
    .dash-table tbody td.td-id {
        background: #f8fafc;
        padding: 10px 16px;
        font-size: 0.95rem;
    }
    .dash-table tbody td.td-id::before { display: none; }
    /* บนมือถือมีที่พอ ไม่ต้องตัดข้อความ */
    .td-id .case-id, .td-car {
        max-width: none;
        white-space: normal;
        overflow: visible;
        text-overflow: unset;
    }
    .dash-table tbody td.col-phone-mobile { display: flex !important; }
    .dash-table tbody td.td-actions {
        flex-direction: row;
        justify-content: flex-end;
        padding: 10px 16px 14px;
        gap: 8px;
        flex-wrap: wrap;
    }
    .dash-table tbody td.td-actions::before { display: none; }
    .dash-table tbody td.td-actions > * {
        flex: 1 1 0;
        text-align: center;
        min-width: 0;
    }
    .dash-table tbody td[data-label="hide"] { display: none; }
    .table-empty { padding: 32px 12px; font-size: 0.88rem; }

    /* Buttons */
    .btn-assign, .btn-reassign { padding: 7px 14px; font-size: 0.82rem; }
    .btn-accept { padding: 7px 14px; font-size: 0.82rem; }
    .btn-view { padding: 7px 14px; font-size: 0.82rem; }
    .td-actions { gap: 6px; flex-wrap: wrap; }

    /* Case detail */
    .detail-wrapper { padding: 14px 12px 32px; }
    .detail-header {
        flex-direction: column;
        gap: 14px;
        padding: 18px 18px;
        border-left-width: 4px;
    }
    .detail-customer { font-size: 1.3rem; }
    .detail-card { padding: 18px 16px; border-radius: 12px; }
    .detail-grid { grid-template-columns: 1fr; gap: 14px; }
    .status-select-input { min-width: 100%; width: 100%; }
    .note-form textarea { font-size: 0.88rem; }
    .detail-card-title { font-size: 0.9rem; }

    /* AE form page */
    .page-wrapper { padding: 16px 12px; }
    .header h1 { font-size: 1.5rem; }
    .section { padding: 18px 16px; }
    .form-grid { grid-template-columns: 1fr; }
    .form-group.full-width { grid-column: auto; }
    .form-actions { padding: 16px; flex-direction: column; }
    .btn-primary, .btn-secondary { width: 100%; justify-content: center; }

    /* Login / select pages */
    .login-card { padding: 32px 22px; }
    .login-title { font-size: 1.4rem; }
    .select-cards { gap: 12px; }
    .user-card { padding: 18px 18px; gap: 14px; }
    .card-title { font-size: 1.2rem; }

    /* Modal */
    .modal { padding: 12px; align-items: flex-end; }
    .modal-box { padding: 28px 20px; border-radius: 20px 20px 16px 16px; max-width: 100%; }
}

/* Very small screens */
@media (max-width: 380px) {
    .topbar-title { display: none; }
    .stat-num { font-size: 1.5rem; }
    .detail-customer { font-size: 1.15rem; }
}

/* ===== Review modal (AE ตรวจสอบข้อมูลก่อนบันทึก) ===== */
.review-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    padding: 8px 0;
    border-bottom: 1px solid #f0f4f8;
    font-size: 0.88rem;
}
.review-row:last-child { border-bottom: none; }
.review-label { color: #718096; flex-shrink: 0; }
.review-value { color: #1a202c; font-weight: 600; text-align: right; overflow-wrap: break-word; }

/* ===== TOAST (success banner after redirect) ===== */
.toast-success {
    position: fixed;
    top: 20px;
    right: 20px;
    background: #1d6b22;
    color: #fff;
    padding: 14px 20px;
    border-radius: 10px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.25);
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.92rem;
    font-weight: 600;
    font-family: 'Sarabun', sans-serif;
    z-index: 2000;
    animation: toast-slide-in 0.3s ease-out;
}
.toast-success .toast-icon {
    background: rgba(255,255,255,0.2);
    border-radius: 50%;
    width: 24px;
    height: 24px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
}
@keyframes toast-slide-in {
    from { transform: translateX(30px); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}
@media (max-width: 640px) {
    .toast-success { left: 12px; right: 12px; top: 12px; }
}

/* ============================================================
   ส่วนงานสินเชื่อ — ยกมาจาก credit/assets/style.css ตอนควบรวม

   ★ คลาสที่ชื่อชนกันถูกตัดของฝั่งสินเชื่อทิ้ง ★
   .alert .badge .btn-primary .detail-grid .section-title .section-icon
   ของสองฝั่งต่างกันแค่ขนาด/ความมน — ใช้ของ refinance ซึ่งเป็นหน้าตาที่คนใช้อยู่ทุกวัน
   นี่คือความหมายของ "ทำให้ของ marketing กลายเป็น refinance"

   ★ กฎของหน้าล็อกอินฝั่งสินเชื่อถูกตัดทิ้งทั้งหมด ★
   หน้านั้นถูกลบไปตอนรวมล็อกอิน เหลือไว้ก็เป็นโค้ดตายที่วันหนึ่งมีคนแก้แล้วงงว่าไม่มีผล

   ตัวแปรสีของฝั่งสินเชื่อยกค่ามาจาก refinance อยู่แล้ว ตัวที่ซ้ำจึงตัดทิ้ง
   เหลือเฉพาะตัวที่ refinance ยังไม่มีชื่อนั้น
   ============================================================ */

/* ===== ฟอนต์ Sarabun (ไฟล์เดียวกับ refinance) =====
   แยกไฟล์ไทย/ละตินด้วย unicode-range — เบราว์เซอร์โหลดเฉพาะชุดที่ใช้จริง
   ทั้งชุด 10 ไฟล์รวม 124 KB */
@font-face { font-family:'Sarabun'; font-weight:300; font-style:normal; font-display:swap;
  src: url('../fonts/sarabun-300-thai.woff2') format('woff2');
  unicode-range: U+02D7,U+0303,U+0331,U+0E01-0E5B,U+200C-200D,U+25CC; }
@font-face { font-family:'Sarabun'; font-weight:300; font-style:normal; font-display:swap;
  src: url('../fonts/sarabun-300-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+2000-206F,U+20AC,U+2122,U+FEFF,U+FFFD; }
@font-face { font-family:'Sarabun'; font-weight:400; font-style:normal; font-display:swap;
  src: url('../fonts/sarabun-400-thai.woff2') format('woff2');
  unicode-range: U+02D7,U+0303,U+0331,U+0E01-0E5B,U+200C-200D,U+25CC; }
@font-face { font-family:'Sarabun'; font-weight:400; font-style:normal; font-display:swap;
  src: url('../fonts/sarabun-400-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+2000-206F,U+20AC,U+2122,U+FEFF,U+FFFD; }
@font-face { font-family:'Sarabun'; font-weight:500; font-style:normal; font-display:swap;
  src: url('../fonts/sarabun-500-thai.woff2') format('woff2');
  unicode-range: U+02D7,U+0303,U+0331,U+0E01-0E5B,U+200C-200D,U+25CC; }
@font-face { font-family:'Sarabun'; font-weight:500; font-style:normal; font-display:swap;
  src: url('../fonts/sarabun-500-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+2000-206F,U+20AC,U+2122,U+FEFF,U+FFFD; }
@font-face { font-family:'Sarabun'; font-weight:600; font-style:normal; font-display:swap;
  src: url('../fonts/sarabun-600-thai.woff2') format('woff2');
  unicode-range: U+02D7,U+0303,U+0331,U+0E01-0E5B,U+200C-200D,U+25CC; }
@font-face { font-family:'Sarabun'; font-weight:600; font-style:normal; font-display:swap;
  src: url('../fonts/sarabun-600-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+2000-206F,U+20AC,U+2122,U+FEFF,U+FFFD; }
@font-face { font-family:'Sarabun'; font-weight:700; font-style:normal; font-display:swap;
  src: url('../fonts/sarabun-700-thai.woff2') format('woff2');
  unicode-range: U+02D7,U+0303,U+0331,U+0E01-0E5B,U+200C-200D,U+25CC; }
@font-face { font-family:'Sarabun'; font-weight:700; font-style:normal; font-display:swap;
  src: url('../fonts/sarabun-700-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+2000-206F,U+20AC,U+2122,U+FEFF,U+FFFD; }


/* Marketing App — mobile-first
   ธีมสีเดียวกับระบบพี่น้อง (refinance/intranet) เพื่อให้คนใช้รู้สึกว่าเป็นชุดเดียวกัน
   เขียนแบบ mobile ก่อนแล้วค่อยขยายที่ min-width เพราะ CRO/Maker ส่วนใหญ่ใช้มือถือ */

/* refinance รองรับโหมดมืด — ยกมาเฉพาะหน้าล็อกอินซึ่งเป็นหน้าที่เห็นผลชัดที่สุด
   ส่วนหน้าใช้งานจริงยังเป็นพื้นสว่างทั้งคู่ จึงไม่ต้องทำอะไรเพิ่ม */
@media (prefers-color-scheme: dark) {
    :root {
        --dot-color: rgba(255, 255, 255, .12);
    }
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: "Sarabun", "Segoe UI", "Noto Sans Thai", system-ui, -apple-system, sans-serif;
    font-size: 15px;
    line-height: 1.6;
    color: var(--ink);
    background: var(--bg);
    -webkit-text-size-adjust: 100%;
}

h1 { font-size: 1.4rem; margin: 0 0 4px; }
h2 { font-size: 1.1rem; margin: 0 0 12px; }
h3 { font-size: .95rem; margin: 0 0 8px; }

a { color: var(--green); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ★ ลิงก์ที่หน้าตาเป็นปุ่มหรือการ์ด ต้องไม่มีเส้นใต้ตอน hover ★
   a:hover ข้างบนมี specificity (0,1,1) สูงกว่า .btn-primary (0,1,0) ที่สั่ง
   text-decoration:none ไว้ กฎทั่วไปเลยชนะ แล้วเส้นใต้ไปโผล่กลางปุ่ม
   .btn กับ .tab มีกฎกันไว้อยู่แล้ว ที่เหลือตกหล่นมาตั้งแต่ต้น */
a.stat-card:hover,
a.btn-view:hover,
a.btn-primary:hover,
a.btn-secondary:hover,
a.topbar-back:hover,
a.btn-logout:hover { text-decoration: none; }

.muted    { color: var(--ink-soft); }
.d-block  { display: block; }
.nowrap   { white-space: nowrap; }
.num      { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- Topbar ---------- */
/* ★ แถบบนใช้ของ refinance (style.css ที่รากระบบ) ★
 * ควบรวมแล้วทั้งระบบต้องมีแถบบนอันเดียวกัน — กฎ .topbar* ชุดเดิมของฝั่งนี้
 * ถูกตัดออกทั้งหมด ไม่ใช่ย้ายไปที่อื่น · เหลือไว้จะทับของ refinance
 * เพราะไฟล์นี้โหลดทีหลังและใช้ชื่อคลาสเดียวกันเป๊ะ
 */

.nav-badge {
    display: inline-grid;
    place-items: center;
    min-width: 18px; height: 18px;
    padding: 0 5px;
    margin-left: 4px;
    border-radius: 999px;
    background: var(--red);
    color: #fff;
    font-size: .7rem;
    font-weight: 700;
}

/* ---------- Layout ---------- */
.page {
    max-width: 1100px;
    margin: 0 auto;
    padding: 20px 16px 60px;
}

.page-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 20px;
}

.page-footer {
    padding: 20px 16px calc(20px + env(safe-area-inset-bottom));
    text-align: center;
    font-size: .8rem;
    color: var(--ink-soft);
}

.card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 18px;
    margin-bottom: 16px;
}

/* ---------- Tabs ---------- */
.tabs {
    display: flex;
    gap: 4px;
    overflow-x: auto;
    margin-bottom: 14px;
    scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }

.tab {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border-radius: 999px;
    background: #fff;
    border: 1px solid var(--line);
    color: var(--ink-soft);
    white-space: nowrap;
    font-size: .9rem;
}
.tab:hover { text-decoration: none; }
.tab.is-active { background: var(--green); border-color: var(--green); color: #fff; }

/* ---------- Search ---------- */
.searchbar { display: flex; gap: 8px; margin-bottom: 16px; }
.searchbar input { flex: 1; min-width: 0; }

/* ---------- Table ---------- */
/* ตารางกว้างต้องเลื่อนในกล่องตัวเอง ห้ามให้ body เลื่อนแนวนอน */
.table-scroll {
    overflow-x: auto;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    -webkit-overflow-scrolling: touch;
}

.table { width: 100%; border-collapse: collapse; font-size: .9rem; }

.table th {
    padding: 10px 12px;
    text-align: left;
    font-size: .75rem;
    font-weight: 700;
    color: #4a5568;
    text-transform: uppercase;
    letter-spacing: .6px;
    background: #f1f5f9;
    border-bottom: 2px solid var(--line);
    white-space: nowrap;
}
.table th.num { text-align: right; }

.table td { padding: 10px 12px; border-bottom: 1px solid #f0f2f0; vertical-align: top; }
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr { cursor: pointer; }
.table tbody tr:nth-child(even) td { background: #f8fafc; }
.table tbody tr:hover td { background: #f0f4f8; }
.table small { font-size: .78rem; }

/* ---------- Badge ---------- */
.badge-green  { background: #e6f4ea; color: #1d6b22; }
.badge-blue   { background: #e3f0fb; color: var(--blue); }
.badge-orange { background: #fdf0e2; color: var(--orange); }
.badge-yellow { background: #fbf4dc; color: var(--yellow); }
.badge-red    { background: #fbe6e6; color: var(--red); }
.badge-purple { background: #eee8fa; color: var(--purple); }
.badge-gray   { background: #eef0ef; color: var(--gray); }

/* ---------- Form ---------- */
.field { margin-bottom: 14px; }

.field label {
    display: block;
    margin-bottom: 5px;
    font-size: .85rem;
    font-weight: 600;
    color: var(--ink-soft);
}
.field label .req { color: var(--red); }

input[type="text"], input[type="tel"], input[type="number"], input[type="search"],
input[type="password"], input[type="date"], select, textarea {
    width: 100%;
    padding: 10px 12px;
    /* 16px กัน iOS Safari ซูมเข้าเองตอนโฟกัสช่องกรอก */
    font-size: 16px;
    font-family: inherit;
    color: var(--ink);
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 9px;
    outline: none;
}
input:focus, select:focus, textarea:focus {
    border-color: var(--green);
    box-shadow: 0 0 0 3px rgba(29, 107, 34, .12);
}
textarea { min-height: 84px; resize: vertical; }

.field-row { display: grid; gap: 14px; }
@media (min-width: 640px) {
    .field-row-2 { grid-template-columns: 1fr 1fr; }
    .field-row-3 { grid-template-columns: repeat(3, 1fr); }
}

.password-wrap { position: relative; }
.password-wrap input { padding-right: 44px; }
.password-toggle {
    position: absolute;
    top: 50%; right: 6px;
    transform: translateY(-50%);
    width: 34px; height: 34px;
    border: none;
    background: none;
    cursor: pointer;
    font-size: 1rem;
    opacity: .6;
}
.password-toggle:hover { opacity: 1; }

/* ---------- Button ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    /* 44px = ขนาดเป้าแตะขั้นต่ำที่นิ้วกดไม่พลาดบนมือถือ */
    min-height: 44px;
    padding: 10px 18px;
    border: 1px solid transparent;
    border-radius: 10px;
    font: inherit;
    font-weight: 600;
    font-size: .92rem;
    cursor: pointer;
    white-space: nowrap;
}
.btn:hover { text-decoration: none; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.btn-primary:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 6px 18px rgba(29, 107, 34, .5);
}
.btn-primary:active { transform: translateY(0); }

.btn-danger  { background: var(--red); color: #fff; }
.btn-ghost   { background: #fff; border: 1.5px solid var(--line); color: var(--ink-soft); }
.btn-ghost:hover:not(:disabled) { background: #f7fafc; border-color: #cbd5e0; color: #4a5568; }

.btn-sm    { min-height: 34px; padding: 5px 12px; font-size: .85rem; }
.btn-block { width: 100%; }

/* ---------- Alert ---------- */
.alert-error   { background: #fbe9e9; border-color: #f2c4c4; color: #8e1f1f; }
.alert-success { background: #e6f4ea; border-color: #bfe0c8; color: #14571a; }
.alert-warn    { background: #fdf6e3; border-color: #ecd9a5; color: #7a5c00; }

/* ---------- Empty ---------- */
.empty {
    padding: 48px 20px;
    text-align: center;
    background: var(--card);
    border: 1px dashed var(--line);
    border-radius: var(--radius);
    color: var(--ink-soft);
}

/* ---------- Login ---------- */
.login-page {
    background:
        radial-gradient(circle, var(--dot-color) 1px, transparent 1px),
        var(--login-bg);
    background-size: 28px 28px, auto;
}

.login-brand { text-align: center; margin-bottom: 24px; }
.login-brand h1 { font-size: 1.25rem; margin: 0 0 2px; }
.login-brand p  { margin: 0; font-size: .85rem; color: var(--ink-soft); }

.login-hint {
    margin: 18px 0 0;
    font-size: .78rem;
    line-height: 1.7;
    color: var(--ink-soft);
    text-align: center;
}

/* ---------- Case detail ---------- */
.action-panel {
    /* แผงนี้คือสิ่งเดียวที่คนเปิดหน้ามาต้องทำ — ตีกรอบเขียวให้เห็นก่อนอย่างอื่น */
    border-left: 4px solid var(--green);
    background: linear-gradient(180deg, var(--green-light) 0%, #fff 90px);
}

@media (min-width: 640px) { .detail-grid { grid-template-columns: repeat(3, 1fr); } }

.detail-grid dt {
    font-size: .78rem;
    font-weight: 600;
    color: var(--ink-soft);
    margin-bottom: 2px;
}
.detail-grid dd { margin: 0; word-break: break-word; }
.detail-grid .span-all { grid-column: 1 / -1; }

.compare {
    display: grid;
    gap: 12px;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    padding: 14px;
    margin-bottom: 16px;
    background: #fafbfa;
    border: 1px solid var(--line);
    border-radius: 9px;
}
.compare small { display: block; font-size: .75rem; }
.compare strong { font-size: 1.05rem; }

/* ---------- Radio ---------- */
.radio-list { display: grid; gap: 8px; }

.radio-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px 14px;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 9px;
    cursor: pointer;
}
.radio-item:hover { border-color: var(--green); }
.radio-item input { margin-top: 3px; flex: none; width: 18px; height: 18px; accent-color: var(--green); }
/* :has() ให้ทั้งกล่องเปลี่ยนสีตามตัวที่เลือก — เบราว์เซอร์เก่าไม่รองรับก็แค่ไม่ไฮไลต์ ยังใช้ได้ปกติ */
.radio-item:has(input:checked) { border-color: var(--green); background: var(--green-light); }
.radio-item small { line-height: 1.5; }

/* ---------- Attachments ---------- */
.attach-group { padding-top: 14px; border-top: 1px solid #f0f2f0; margin-top: 14px; }
.attach-group:first-of-type { padding-top: 0; border-top: none; margin-top: 0; }

.attach-list { list-style: none; margin: 0 0 10px; padding: 0; }

.attach-list li {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    padding: 8px 0;
    border-bottom: 1px solid #f6f7f6;
}
.attach-list li:last-child { border-bottom: none; }
.attach-list small { font-size: .78rem; }

.upload-form { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.upload-form input[type="file"] { flex: 1; min-width: 200px; font-size: .85rem; }

.link-danger {
    padding: 0;
    border: none;
    background: none;
    color: var(--red);
    font: inherit;
    font-size: .8rem;
    text-decoration: underline;
    cursor: pointer;
}

.copyable {
    padding: 3px 8px;
    background: #f0f2f0;
    border-radius: 5px;
    font-size: .82rem;
    cursor: pointer;
    word-break: break-all;
}
.copyable:hover { background: var(--green-light); }

/* ---------- Timeline ---------- */
.timeline { list-style: none; margin: 0; padding: 0; }

.timeline li {
    position: relative;
    padding: 0 0 20px 24px;
    /* เส้นตั้งเชื่อมจุด — ใช้ border ของ li เอง จะได้ยาวตามเนื้อหาพอดี */
    border-left: 2px solid var(--line);
}
.timeline li:last-child { border-left-color: transparent; padding-bottom: 0; }

.timeline-dot {
    position: absolute;
    left: -7px; top: 4px;
    width: 12px; height: 12px;
    border: 2px solid #fff;
    border-radius: 50%;
    background: var(--green);
}

.timeline-body > div { margin: 4px 0; }
.timeline-note {
    margin: 6px 0;
    padding: 8px 12px;
    background: #fafbfa;
    border-radius: 7px;
    font-size: .88rem;
}

/* ---------- ตัวเลือกรุ่นรถ (amnbook) ---------- */
.car-picker {
    /* ตีกรอบให้เห็นว่าทั้งบล็อกนี้เป็นชุดเดียวกัน และค่ามาจากระบบอื่น ไม่ใช่ช่องพิมพ์อิสระ */
    margin: 0 0 14px;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 9px;
    background: #fafbfa;
}

.car-picker legend {
    padding: 0 6px;
    font-size: .85rem;
    font-weight: 600;
    color: var(--ink-soft);
}
.car-picker legend small { font-weight: 400; margin-left: 6px; }

.car-result { margin-top: 10px; }
.car-result p { margin: 0 0 8px; font-size: .88rem; }
.car-result .alert { margin-bottom: 0; }

.car-chosen {
    padding: 10px 12px;
    border-radius: 8px;
    background: var(--green-light);
    color: var(--green-dark);
    font-weight: 600;
}

/* ---------- วงเงินอ้างอิงจาก amnbook ---------- */
.car-price {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin-top: 8px;
    padding: 10px 12px;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 8px;
}

.car-price div { text-align: center; }

.car-price small {
    display: block;
    font-size: .72rem;
    color: var(--ink-soft);
    margin-bottom: 2px;
}

.car-price strong {
    /* tabular-nums ให้หลักตรงกันทุกแถว เวลาเทียบหลายรุ่นจะอ่านง่าย */
    font-size: .95rem;
    font-variant-numeric: tabular-nums;
    color: var(--green-dark);
}

.car-price-none {
    margin-top: 8px !important;
    font-size: .8rem;
    color: var(--yellow);
}

/* ในรายการตัวเลือกหลายรุ่น ตารางราคาต้องไม่ดันข้อความชื่อรุ่นจนล้น */
.radio-item .car-price { margin-top: 6px; }

/* คำนำหน้าแคบกว่าชื่อ/สกุล — ช่องกว้างเท่ากันหมดจะดูเสียสัดส่วนเพราะพิมพ์แค่ "นาย" */
@media (min-width: 640px) {
    .field-row-name { grid-template-columns: 0.5fr 1fr 1fr; }
}

/* ---------- บล็อกที่อยู่ (โครงเดียวกับ loanapp/AMPL01) ---------- */
/* class .la-* ต้องคงชื่อไว้ — assets/address.js ผูกกับชื่อพวกนี้ */
.la-row {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    gap: 12px 14px;
}

.la-f label {
    display: block;
    margin-bottom: 3px;
    font-size: .8rem;
    font-weight: 600;
    color: var(--ink-soft);
}

/* บนมือถือให้ทุกช่องเต็มความกว้าง 12 คอลัมน์อ่านไม่ออก */
.la-f { grid-column: span 12; }
@media (min-width: 640px) {
    .c2 { grid-column: span 3; }
    .c3 { grid-column: span 4; }
    .c4 { grid-column: span 6; }
}
@media (min-width: 900px) {
    .c2 { grid-column: span 2; }
    .c3 { grid-column: span 3; }
    .c4 { grid-column: span 4; }
}

.addr-line {
    margin: 0 0 14px;
    padding: 10px 12px;
    background: #fafbfa;
    border: 1px solid var(--line);
    border-radius: 8px;
    line-height: 1.7;
}

/* ---------- ประเภทรถ: สองตัวเลือกวางข้างกัน ---------- */

/* ---------- เช็คลิสต์รูปรถ ---------- */
/* 30 ช่องบนมือถือ = เลื่อนยาวมาก · ทำให้แต่ละช่องเตี้ยที่สุดเท่าที่ยังกดง่าย
   และไล่สายตาหาช่องที่ยังไม่ได้ถ่ายเจอโดยไม่ต้องอ่านทุกบรรทัด */


/* ถ่ายแล้ว = พื้นเขียวจางและขอบซ้ายทึบ — กวาดตาลงมาแล้วรู้ทันทีว่าเหลือช่องไหน
   ไม่พึ่งสีอย่างเดียว มีเครื่องหมาย ✓ กำกับด้วยสำหรับคนตาบอดสี */


.slot-upload { margin-top: 8px; }

/* กล่องเทาขอบประ + เครื่องหมายบวก — ทั้งกล่องคือปุ่ม แตะตรงไหนก็ขึ้นกล้อง
   ทำเป็นกล่องใหญ่เพราะคนถ่ายยืนอยู่ข้างรถ ถือมือถือมือเดียว บางทีใส่ถุงมือ
   เป้าหมายเล็กๆ แบบปุ่มธรรมดาจะกดพลาดตลอด */
.slot-add {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    min-height: 84px;
    padding: 12px;
    border: 2px dashed var(--line);
    border-radius: 10px;
    background: #fafbfa;
    color: var(--ink-soft);
    cursor: pointer;
    text-align: center;
    -webkit-tap-highlight-color: transparent;
    transition: border-color .15s ease, background .15s ease;
}
.slot-add:hover  { border-color: var(--green); background: var(--green-light); color: var(--green); }
.slot-add:active { transform: scale(.99); }

/* input ซ่อนแบบยังโฟกัสได้ — ใช้ display:none หรือ attribute hidden แล้วคนที่ใช้คีย์บอร์ด
   จะ tab ไปไม่ถึงเลย ทั้งที่กล่องนี้เป็นทางเดียวที่จะแนบรูปได้ */
.slot-add-input {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
    pointer-events: none;
}
.slot-add:focus-within {
    outline: 2px solid var(--green);
    outline-offset: 2px;
    border-color: var(--green);
}

.slot-add-icon { font-size: 1.6rem; line-height: 1; font-weight: 300; }
.slot-add-text { font-size: .8rem; }

/* ข้อความเต็มสำหรับ screen reader — "ถ่ายรูป" เฉยๆ ซ้ำกัน 30 ปุ่มบนหน้าเดียว
   ต้องบอกด้วยว่าเป็นช่องไหน */
.slot-add-sr {
    position: absolute;
    width: 1px; height: 1px;
    padding: 0; margin: -1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
}

/* ช่องที่มีรูปแล้ว — ย่อเป็นแถบเตี้ยๆ ไม่ต้องเด่นเท่าช่องที่ยังว่าง */
.slot-add-more {
    flex-direction: row;
    gap: 6px;
    min-height: 0;
    padding: 7px 10px;
    border-style: solid;
    background: transparent;
}
.slot-add-more .slot-add-icon { font-size: 1.05rem; }
.slot-add-more .slot-add-text { font-size: .76rem; }

/* ระหว่างอัปโหลด — กันกดซ้ำและบอกว่ากำลังทำงานอยู่ */
.slot-add.is-busy {
    pointer-events: none;
    opacity: .65;
    border-style: solid;
    border-color: var(--green);
}

/* ---------- รูปย่อในเช็คลิสต์ ---------- */
.slot-thumb {
    display: block;
    width: 100%;
    padding: 0;
    border: 1px solid var(--line);
    border-radius: 8px;
    overflow: hidden;
    background: #eef1ef;
    cursor: zoom-in;
    -webkit-tap-highlight-color: transparent;
}
.slot-thumb img {
    display: block;
    width: 100%;
    max-width: 100%;
    /* ความสูงคงที่ทุกใบ — เช็คลิสต์ 30 ช่องที่รูปสูงไม่เท่ากันจะกระโดดจนกวาดตาไม่ได้
       และรูปย่อมีไว้ให้ "รู้ว่าถ่ายอะไรไว้" เท่านั้น ดูรายละเอียดไปดูในตัวดูรูปเต็มจอ
       ตั้งสูงกว่านี้แล้วเลื่อนดู 30 ช่องจะยาวจนหาช่องที่ยังว่างไม่เจอ */
    height: 140px;
    object-fit: cover;
}
.slot-thumb:focus-visible { outline: 2px solid var(--green); outline-offset: 2px; }

/* ---------- ตัวดูรูปเต็มจอ ---------- */
/* ฝ่ายประเมินดูรูปบนแท็บเล็ตเป็นหลัก และเคยชินกับการเลื่อน/ซูมแบบแอปแชท
   จึงทำท่าเดียวกัน: ปัดซ้ายขวาเปลี่ยนรูป · หุบสองนิ้วซูม · แตะสองครั้งซูมเร็ว */
.pv {
    position: fixed;
    inset: 0;
    z-index: 1000;
    background: #000;
    display: flex;
    flex-direction: column;
    /* กันเบราว์เซอร์แย่งท่าทางไปทำ scroll/zoom ของหน้าเว็บ — เราจัดการเองทั้งหมด */
    touch-action: none;
    user-select: none;
}
.pv[hidden] { display: none; }

.pv-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    color: #fff;
    background: rgba(0, 0, 0, .55);
    font-size: .9rem;
}
.pv-count { opacity: .7; font-variant-numeric: tabular-nums; flex: none; }
.pv-label { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pv-close,
.pv-zoom {
    flex: none;
    width: 40px; height: 40px;
    border: 0; border-radius: 999px;
    background: rgba(255, 255, 255, .15);
    color: #fff;
    font-size: 1.3rem;
    line-height: 1;
    cursor: pointer;
}
/* ปุ่มซูมมีไว้เพื่อปากกา/สไตลัสเป็นหลัก — ตัวชี้ตัวเดียวหุบสองนิ้วไม่ได้
   คนใช้นิ้วยังหุบสองนิ้วหรือแตะสองครั้งได้ตามปกติ ปุ่มนี้เป็นทางเลือกเสริม */
.pv-zoom { font-weight: 600; }
.pv-zoom:disabled { opacity: .3; cursor: default; }

.pv-stage {
    flex: 1;
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}
.pv-img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    transform-origin: 0 0;
    will-change: transform;
    -webkit-user-drag: none;
}

/* ปุ่มลูกศร — แท็บเล็ตวางบนโต๊ะแล้วปัดไม่ถนัดเท่าถือมือถือ ต้องมีปุ่มให้กดด้วย
   จอเล็กซ่อนไว้ ปัดเอาสะดวกกว่าอยู่แล้วและปุ่มจะบังรูป */
.pv-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 48px; height: 48px;
    border: 0; border-radius: 999px;
    background: rgba(255, 255, 255, .18);
    color: #fff;
    font-size: 1.5rem;
    line-height: 1;
    cursor: pointer;
    display: none;
}
.pv-prev { left: 12px; }
.pv-next { right: 12px; }
@media (min-width: 700px) and (pointer: fine)  { .pv-nav { display: block; } }
@media (min-width: 700px) and (pointer: coarse) { .pv-nav { display: block; } }
.pv-nav:disabled { opacity: .25; cursor: default; }

.pv-hint {
    padding: 6px 14px 10px;
    color: rgba(255, 255, 255, .55);
    font-size: .74rem;
    text-align: center;
}
/* จอแคบ (มือถือแนวตั้ง) ซ่อนปุ่มซูม — นิ้วหุบเอาสะดวกกว่า และแถบบนจะแน่นเกินไป
   ปากกาใช้กับแท็บเล็ตซึ่งจอกว้างกว่านี้อยู่แล้ว */
@media (max-width: 420px) { .pv-zoom { display: none; } }

/* ช่อง "เพิ่มรูปนอกเช็คลิสต์" — ขอบประให้ต่างจากช่องบังคับที่ขอบทึบ
   สื่อว่าไม่ใช่ของที่ต้องมี แต่ยังอยู่ในกริดเดียวกันเพื่อให้กดถ่ายได้แบบเดียวกัน */

/* ---------- ช่องที่ถ่ายไม่ได้ ---------- */
/* สีเหลืองไม่ใช่เขียว — "จัดการแล้ว" ไม่เท่ากับ "มีรูป" คนตีราคาต้องแยกออกด้วยการกวาดตา
   และมี ⚠ กำกับด้วยไม่ได้พึ่งสีอย่างเดียว */

/* ทางเลือกสุดท้าย ไม่ใช่ทางลัด — พับเก็บไว้ให้กดยากกว่าการถ่ายรูปเล็กน้อยโดยตั้งใจ */

.sr-only {
    position: absolute; width: 1px; height: 1px;
    padding: 0; margin: -1px; overflow: hidden;
    clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---------- ถูกตีกลับมาให้แก้ ---------- */
/* แถบนี้ต้องแย่งสายตาให้ได้ — หน้าเคสยาว 30 ช่องรูป ถ้ากลมกลืนไปกับการ์ดอื่น
   CRO จะเลื่อนผ่านแล้วส่งกลับมาแบบเดิม ซึ่งคือปัญหาที่ฟีเจอร์นี้ตั้งใจแก้พอดี */
.returned-banner { border-left: 4px solid var(--orange); background: #fff8f0; }
.returned-banner h2 { color: var(--orange); }
.returned-note {
    font-size: 1rem;
    line-height: 1.6;
    margin: 0 0 8px;
    white-space: pre-wrap;
}

/* กล่องตีกลับฝั่งฝ่ายประเมิน — คั่นจากฟอร์มบันทึกผลให้ชัดว่าเป็นคนละการตัดสินใจ */
.return-box {
    margin-top: 18px;
    padding-top: 14px;
    border-top: 1px dashed var(--line);
}
.return-box h3 { margin: 0 0 4px; font-size: .95rem; }

/* ---------- กริดรูปย่อในการ์ดไฟล์แนบ ---------- */
.thumb-grid {
    list-style: none;
    margin: 0 0 10px;
    padding: 0;
    display: grid;
    gap: 10px;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
}
/* min-width:0 กัน grid item บวมตามขนาดจริงของรูป (ค่าเริ่มต้นคือ min-width:auto) */
.thumb-item { min-width: 0; font-size: .74rem; }
.thumb-item small { display: block; color: var(--ink-soft); margin-top: 2px; }
.thumb-item form { display: inline; }
.thumb-file {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 110px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #f4f6f4;
    text-align: center;
    font-size: .78rem;
    padding: 6px;
    word-break: break-word;
}
.slot-thumb {
    display: block; width: 100%; padding: 0;
    border: 1px solid var(--line); border-radius: 8px;
    overflow: hidden; background: #eef1ef; cursor: zoom-in;
    -webkit-tap-highlight-color: transparent;
}
.slot-thumb img { display: block; width: 100%; max-width: 100%; height: 110px; object-fit: cover; }
.slot-thumb:focus-visible { outline: 2px solid var(--green); outline-offset: 2px; }

/* ---------- ช่องกรอกทะเบียน ---------- */
/* สองช่องติดกันโดยมีขีดคั่น — หน้าตาเหมือนป้ายจริง คนกรอกจะรู้ทันทีว่าอะไรใส่ตรงไหน
   โดยไม่ต้องอ่าน label และพิมพ์เว้นวรรคมั่วไม่ได้เพราะเป็นคนละช่อง */
.plate-input { display: flex; align-items: center; gap: 8px; }
.plate-input input { min-width: 0; text-align: center; }
.plate-input input:first-child { flex: 1.2; }
.plate-input input:last-child  { flex: 1; letter-spacing: .08em; }
.plate-input span { color: var(--ink-soft); }

/* ---------- เตือนว่าทะเบียนนี้เพิ่งถูกประเมินไปแล้ว ---------- */
/* ฝ่ายประเมินต้องเห็นก่อนตีราคา ไม่งั้นจะตีราคารถคันเดิมซ้ำโดยไม่รู้ตัว
   ใช้สีน้ำเงินไม่ใช่ส้ม — นี่คือข้อมูลประกอบการตัดสินใจ ไม่ใช่ความผิดที่ต้องแก้ */
.dup-banner { border-left: 4px solid var(--blue); background: #f2f7fd; }
.dup-banner h2 { color: var(--blue); }
.dup-list { margin: 8px 0 0; padding-left: 18px; font-size: .85rem; line-height: 1.8; }

/* ---------- ทะเบียนถูกล็อก ---------- */
/* แดงเพราะเป็นข้อห้ามจริง ไม่ใช่คำเตือน — กดส่งไม่ผ่านแน่นอนจนกว่าจะครบเวลา
   ต่างจาก .dup-banner (น้ำเงิน = ข้อมูลประกอบ) และ .returned-banner (ส้ม = ต้องไปแก้) */
.lock-banner { border-left: 4px solid var(--red); background: #fdf4f4; }
.lock-banner h2 { color: var(--red); }
.lock-note { margin: 0; font-size: .92rem; line-height: 1.6; }

/* ---------- หัวข้อในฟอร์ม (ชุดเดียวกับ refinance) ----------
   refinance วางฟอร์มเป็นหัวข้อพร้อมไอคอนในกล่องสี่เหลี่ยมมน ไม่ใช่ <h2> เปล่าๆ
   ยกมาให้ตรงเพื่อให้ CRO ที่สลับไปมาระหว่างสองแอปไม่รู้สึกว่าเป็นคนละระบบ
   (ต้นฉบับ: refinance/style.css — .section-title / .section-icon) */
/* ============================================================
   กล่องงานใหม่รอกดรับ (dashboard ของ CRO)

   ★ ทำไมไม่ใส่รวมในตารางเคส ★
   เป็นงานเดียวในหน้านี้ที่มีเวลาจำกัด — ปนอยู่ในตารางรวมเมื่อไหร่จะถูกเลื่อนผ่าน
   จนหมดเวลา · ยกออกมาไว้บนสุด ใช้สีส้มของสถานะ "รอ CRO รับงาน" เป็นตัวนำสายตา
   ============================================================ */
.lead-inbox {
    border: 1px solid #f0d9bd;
    border-left: 4px solid var(--orange);
    background: #fffaf3;
    border-radius: 12px;
    padding: 18px 20px;
    margin-bottom: 22px;
}
.lead-inbox-head { margin-bottom: 14px; }
.lead-inbox-head h2 {
    margin: 0 0 4px;
    font-size: 1.05rem;
    color: #8a4b0a;
    display: flex; align-items: center; gap: 9px;
}
.lead-inbox-head p { margin: 0; font-size: .85rem; }
.lead-count {
    background: var(--orange); color: #fff;
    min-width: 24px; height: 24px; border-radius: 99px;
    display: inline-flex; align-items: center; justify-content: center;
    font-size: .8rem; font-weight: 700; padding: 0 7px;
}

.lead-card {
    background: var(--card);
    border: 1px solid #f0e2cf;
    border-radius: 10px;
    padding: 14px 16px;
    display: flex; flex-wrap: wrap; gap: 14px;
    align-items: center; justify-content: space-between;
}
.lead-card + .lead-card { margin-top: 10px; }
.lead-main { flex: 1 1 260px; min-width: 0; }
.lead-no {
    font-size: .78rem; color: var(--ink-soft);
    font-variant-numeric: tabular-nums; letter-spacing: .02em;
}
.lead-name { font-weight: 600; font-size: 1.02rem; margin: 2px 0 3px; }
.lead-meta { font-size: .85rem; }

.lead-side { display: flex; flex-direction: column; align-items: flex-end; gap: 8px; flex: none; }

/* ตัวนับถอยหลัง — เหลือน้อยกว่า 10 นาทีเปลี่ยนเป็นแดงเพื่อให้สะดุดตา */
.lead-timer {
    font-variant-numeric: tabular-nums;
    font-weight: 700; font-size: 1.15rem; color: var(--orange);
    line-height: 1.2;
}
.lead-timer.is-urgent { color: var(--red); }
.lead-timer.is-over   { color: var(--red); font-size: .9rem; font-weight: 600; }

.lead-actions { display: flex; gap: 8px; }
.lead-actions form { margin: 0; }
.lead-peek { font-size: .8rem; color: var(--ink-soft); text-decoration: underline; }
.lead-peek:hover { color: var(--green); }

@media (max-width: 560px) {
    .lead-side { align-items: stretch; width: 100%; }
    .lead-actions { width: 100%; }
    .lead-actions form, .lead-actions .btn { flex: 1; width: 100%; }
    .lead-timer { text-align: left; }
    .lead-peek  { text-align: left; }
}

/* ============================================================
   ธงเตือนของฝ่ายประเมินราคา

   ★ ทำไมต้องเด่นขนาดนี้ ★
   ข้อความพวกนี้แปลว่า "ห้ามเพิ่มวงเงิน" หรือ "รับจัดไม่ได้"
   คนขั้นถัดไปต้องเห็นก่อนตัดสินใจ — พลาดแล้วหมายถึงมีคนไปเพิ่มยอด
   ให้เคสที่ห้ามเพิ่ม ซึ่งเป็นความเสียหายที่ตามแก้ทีหลังไม่ได้
   ============================================================ */

/* แถบบนสุดของหน้าเคส */
.case-alert {
    background: #fdecea;
    border: 1px solid #f5c2c0;
    border-left: 5px solid #c62828;
    color: #8f1d1a;
    font-weight: 700;
    padding: 12px 16px;
    border-radius: 10px;
    margin-bottom: 16px;
    font-size: .95rem;
}

/* แถวในรายการเคส */
.row-alert > td { background: #fdecea; }
.row-alert:hover > td { background: #fbdedb; }
/* ตาราง dash-table มีสีสลับแถว (แถวคู่) กับสี hover ที่เจาะจงกว่า — ต้องชนะสองตัวนั้น
   ไม่งั้นเคสที่มีคำเตือนซึ่งตกแถวคู่จะไม่เป็นสีแดง */
.dash-table tbody tr.row-alert > td { background: #fdecea; }
.dash-table tbody tr.row-alert:hover > td { background: #fbdedb; }

.alert-tag {
    color: #c62828;
    font-weight: 700;
    margin-top: 2px;
    line-height: 1.35;
}

/* ตัวเลือกหมายเหตุมาตรฐาน — วางเหนือช่องพิมพ์ */
.note-picker {
    width: 100%;
    margin-bottom: 8px;
    padding: 9px 12px;
    border: 1px solid var(--line, #e2e8f0);
    border-radius: 8px;
    font-family: inherit;
    font-size: .9rem;
    background: #fff;
}

/* ค้นหารถจากทะเบียน (plate_search.php) */
.plate-search-form { display: flex; gap: 10px; padding: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.plate-search-form input { flex: 1 1 220px; padding: 10px 14px; font-size: 1rem; border: 1.5px solid #e2e8f0; border-radius: 10px; }
.plate-search-empty { padding: 20px; color: #718096; text-align: center; }
.page-header-actions { display: flex; gap: 8px; flex-wrap: wrap; }
@media (max-width: 768px) {
    .page-header-actions { width: 100%; }
    .page-header-actions > * { flex: 1; justify-content: center; }
}

/* ราคา ab. ในหน้าเคสสินเชื่อ — สามตัวเลขที่คนตีราคาใช้เทียบ ต้องอ่านได้ในแวบเดียว */
.ab-price { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin: 4px 0 6px; }
.ab-tile { background: #f7faf7; border: 1px solid #e2e8e2; border-radius: 10px; padding: 10px 14px; display: flex; flex-direction: column; }
.ab-tile span { font-size: .78rem; color: #718096; font-weight: 600; }
.ab-tile strong { font-size: 1.35rem; line-height: 1.3; color: #1f2d1f; font-variant-numeric: tabular-nums; }
.ab-tile small { font-size: .72rem; color: #a0aec0; }
.ab-tile.ab-main { background: #eaf5ea; border-color: #b7dbb9; }
.ab-tile.ab-main strong { color: #1d6b22; }
@media (max-width: 480px) {
    .ab-price { gap: 6px; }
    .ab-tile { padding: 8px 10px; }
    .ab-tile strong { font-size: 1.05rem; }
}

/* วันที่จดทะเบียนแบบ พ.ศ. — ช่องพิมพ์ + ปุ่มปฏิทิน (JS อยู่ที่ credit/assets/script.js) */
.date-be-pick { position: relative; display: flex; gap: 6px; }
.date-be-pick input[type=text] { flex: 1; min-width: 0; }
.date-be-btn {
    flex: none; width: 44px; display: grid; place-items: center;
    border: 1px solid var(--line); border-radius: 10px; background: var(--card); color: var(--green); cursor: pointer;
}
.date-be-btn svg { width: 20px; height: 20px; }
.date-be-cal {
    position: absolute; top: calc(100% + 6px); left: 0; z-index: 50;
    width: 300px; max-width: calc(100vw - 32px); padding: 10px;
    background: var(--card); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow);
}
.date-be-head { display: flex; gap: 6px; align-items: center; margin-bottom: 8px; }
.date-be-head select { flex: 1; min-width: 0; padding: 6px 8px; }
.date-be-head button {
    flex: none; width: 32px; height: 32px; border: 0; border-radius: 8px;
    background: var(--green-light); color: var(--green); font-size: 1.2rem; cursor: pointer;
}
.date-be-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; text-align: center; }
.date-be-grid .dow { font-size: .75rem; color: var(--ink-soft); padding: 4px 0; }
.date-be-grid button {
    border: 0; background: none; padding: 8px 0; border-radius: 8px; color: var(--ink); cursor: pointer; font: inherit;
}
.date-be-grid button:hover:not(:disabled) { background: var(--green-light); }
.date-be-grid button.is-today { font-weight: 700; color: var(--green); }
.date-be-grid button.is-sel { background: var(--green); color: #fff; }
.date-be-grid button:disabled { color: var(--line); cursor: default; }

/* popup ตรวจสอบข้อมูลก่อนส่ง (credit/assets/script.js · form[data-review]) */
.review-dlg {
    width: min(520px, calc(100vw - 32px));
    max-height: calc(100vh - 48px);
    overflow: auto;
    border: 0;
    border-radius: var(--radius);
    padding: 22px 22px 18px;
    background: var(--card-bg);
    color: var(--text-primary);
    box-shadow: 0 20px 60px rgba(0,0,0,.3);
}
.review-dlg::backdrop { background: rgba(0,0,0,.45); }
.review-dlg .review-title { margin: 0 0 14px; font-size: 1.15rem; }
.review-list { margin: 0 0 12px; }
.review-list > div {
    display: grid;
    grid-template-columns: 120px 1fr;
    gap: 10px;
    padding: 8px 0;
    border-bottom: 1px solid var(--card-border);
}
.review-list dt { color: var(--text-muted); }
.review-list dd { margin: 0; white-space: pre-line; overflow-wrap: anywhere; }
.review-actions { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; margin-top: 14px; }

/* กล่องเพิ่มหมายเหตุของ CRO เหนือ timeline (credit/case_detail.php) */
.note-add { margin: 0 0 18px; padding-bottom: 16px; border-bottom: 1px solid var(--card-border); }
.note-add .field { margin-bottom: 8px; }

.case-cro { margin: 2px 0 0; }
