:root {
    --bg-main: #f4f8f5;
    --bg-secondary: #e8f2eb;
    --card-bg: #ffffff;
    --text-main: #123524;
    --text-muted: #4f6f5f;
    --primary: #1f6b45;
    --primary-hover: #185537;
    --danger: #dc2626;
    --success: #1f6b45;
    --line: #cfe0d6;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: "Sarabun", "Segoe UI", Arial, sans-serif;
    color: var(--text-main);
}

.auth-page {
    background: radial-gradient(circle at top, #ffffff 0%, var(--bg-secondary) 45%, var(--bg-main) 100%);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    position: relative;
    overflow: hidden;
}

.card {
    width: 100%;
    max-width: 420px;
    background: var(--card-bg);
    border-radius: 18px;
    padding: 28px 24px;
    box-shadow: 0 16px 36px rgba(31, 107, 69, 0.16);
    border: 1px solid #dce9e1;
}

.brand {
    text-align: center;
    color: var(--text-muted);
    font-size: 13px;
    letter-spacing: 1px;
    text-transform: uppercase;
    margin-bottom: 8px;
}

h1 {
    margin: 0 0 6px;
    font-size: 24px;
    text-align: center;
}

.subtitle {
    margin: 0 0 20px;
    font-size: 14px;
    color: var(--text-muted);
    text-align: center;
}

label {
    display: block;
    margin: 10px 0 8px;
    font-size: 14px;
    font-weight: 600;
}

input {
    width: 100%;
    padding: 12px 12px;
    border: 1px solid var(--line);
    border-radius: 10px;
    font-size: 16px;
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(31, 107, 69, 0.14);
}

button {
    width: 100%;
    margin-top: 16px;
    border: 0;
    border-radius: 10px;
    background: var(--primary);
    color: #ffffff;
    font-size: 16px;
    font-weight: 600;
    padding: 13px;
    min-height: 46px;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

button:hover {
    background: var(--primary-hover);
}

.message {
    margin-top: 12px;
    font-size: 14px;
    text-align: center;
    font-weight: 600;
}

.message.error {
    color: var(--danger);
}

.message.success {
    color: var(--success);
}

.hint {
    margin-top: 10px;
    font-size: 12px;
    color: var(--text-muted);
    text-align: center;
}

.page-link {
    margin-top: 14px;
    text-align: center;
    font-size: 14px;
}

.page-link a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 600;
}

.pin-input {
    text-align: center;
    letter-spacing: 8px;
    font-size: 26px;
    font-weight: 700;
}

/* PIN Login (numpad style) */
.login-page {
    overflow: hidden;
}

.bg-orb {
    position: fixed;
    border-radius: 50%;
    filter: blur(60px);
    opacity: 0.55;
    pointer-events: none;
    z-index: 0;
}

.bg-orb-1 {
    width: 320px;
    height: 320px;
    background: radial-gradient(circle, rgba(31, 107, 69, 0.35) 0%, transparent 70%);
    top: -80px;
    right: -60px;
    animation: orbFloat1 12s ease-in-out infinite;
}

.bg-orb-2 {
    width: 280px;
    height: 280px;
    background: radial-gradient(circle, rgba(24, 85, 55, 0.25) 0%, transparent 70%);
    bottom: -60px;
    left: -40px;
    animation: orbFloat2 14s ease-in-out infinite;
}

.bg-orb-3 {
    width: 200px;
    height: 200px;
    background: radial-gradient(circle, rgba(207, 224, 214, 0.8) 0%, transparent 70%);
    top: 40%;
    left: 50%;
    transform: translate(-50%, -50%);
    animation: orbFloat3 10s ease-in-out infinite;
}

@keyframes orbFloat1 {
    0%, 100% { transform: translate(0, 0) scale(1); }
    50% { transform: translate(-30px, 40px) scale(1.1); }
}

@keyframes orbFloat2 {
    0%, 100% { transform: translate(0, 0) scale(1); }
    50% { transform: translate(40px, -30px) scale(1.08); }
}

@keyframes orbFloat3 {
    0%, 100% { transform: translate(-50%, -50%) scale(1); opacity: 0.4; }
    50% { transform: translate(-50%, -55%) scale(1.15); opacity: 0.65; }
}

.login-card {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 420px;
    background: linear-gradient(160deg, #ffffff 0%, #f7fcf8 100%);
    border: 1px solid rgba(220, 233, 225, 0.9);
    border-radius: 24px;
    padding: 40px 30px;
    box-shadow:
        0 2px 4px rgba(31, 107, 69, 0.04),
        0 12px 28px rgba(31, 107, 69, 0.1),
        0 28px 56px rgba(18, 53, 36, 0.08),
        inset 0 1px 0 rgba(255, 255, 255, 0.95);
    text-align: center;
    backdrop-filter: blur(8px);
}

.card-enter {
    animation: cardEnter 0.75s cubic-bezier(0.34, 1.3, 0.64, 1) forwards;
    opacity: 0;
    transform: translateY(36px) scale(0.92) perspective(800px) rotateX(4deg);
}

@keyframes cardEnter {
    to {
        opacity: 1;
        transform: translateY(0) scale(1) perspective(800px) rotateX(0deg);
    }
}

.app-logo {
    margin-bottom: 15px;
    animation: float 3s ease-in-out infinite;
}

.logo-mark {
    width: 64px;
    height: 64px;
    object-fit: contain;
    display: inline-block;
    border-radius: 14px;
    background: #ffffff;
    padding: 6px;
    box-shadow: 0 6px 16px rgba(31, 107, 69, 0.18);
    animation: logoGlow 4s ease-in-out infinite;
}

.logo-inline {
    width: 16px;
    height: 16px;
    object-fit: contain;
    vertical-align: -2px;
    margin-right: 6px;
}


@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-8px); }
}

@keyframes logoGlow {
    0%, 100% { filter: drop-shadow(0 4px 12px rgba(31, 107, 69, 0.25)); }
    50% { filter: drop-shadow(0 6px 20px rgba(31, 107, 69, 0.45)); }
}

.app-title {
    margin: 0 0 5px;
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--text-main);
}

.app-subtitle {
    margin: 0 0 30px;
    font-size: 0.9rem;
    color: var(--text-muted);
}

.pin-dots {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-bottom: 30px;
}

.pin-dot {
    width: 18px;
    height: 18px;
    border: 2px solid #cfe0d6;
    border-radius: 50%;
    background: #f7fcf8;
    box-shadow:
        inset 0 2px 4px rgba(18, 53, 36, 0.06),
        0 2px 6px rgba(31, 107, 69, 0.08);
    transition: all 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.pin-dot.active {
    background: linear-gradient(145deg, #2a8f5c, #1f6b45);
    border-color: #1f6b45;
    box-shadow:
        0 0 14px rgba(31, 107, 69, 0.5),
        0 4px 8px rgba(31, 107, 69, 0.25),
        inset 0 1px 2px rgba(255, 255, 255, 0.35);
    transform: scale(1.2);
}

.pin-dot.pop {
    animation: dotPop 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes dotPop {
    0% { transform: scale(0.8); }
    50% { transform: scale(1.45); }
    100% { transform: scale(1.2); }
}

.numpad {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 15px;
    max-width: 300px;
    margin: 0 auto;
}

.num-btn {
    position: relative;
    overflow: hidden;
    background: linear-gradient(160deg, #ffffff 0%, #edf5f0 100%);
    border: 1px solid #d4e5db;
    color: var(--text-main);
    border-radius: 16px;
    height: 65px;
    font-size: 1.6rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    box-shadow:
        0 5px 0 #b8d4c4,
        0 8px 16px rgba(31, 107, 69, 0.12),
        inset 0 1px 0 rgba(255, 255, 255, 0.95),
        inset 0 -2px 4px rgba(31, 107, 69, 0.04);
    transform: translateY(0) scale(1);
    transition:
        transform 0.28s cubic-bezier(0.34, 1.56, 0.64, 1),
        box-shadow 0.28s cubic-bezier(0.34, 1.56, 0.64, 1),
        background 0.2s ease;
    animation: btnFadeIn 0.5s cubic-bezier(0.34, 1.2, 0.64, 1) backwards;
}

@keyframes btnFadeIn {
    from {
        opacity: 0;
        transform: translateY(16px) scale(0.85);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.num-btn:hover {
    transform: translateY(-3px) scale(1.02);
    box-shadow:
        0 7px 0 #b8d4c4,
        0 14px 28px rgba(31, 107, 69, 0.18),
        inset 0 1px 0 rgba(255, 255, 255, 0.95);
}

.num-btn.pressed,
.num-btn:active {
    transform: translateY(5px) scale(0.97);
    box-shadow:
        0 1px 0 #b8d4c4,
        0 3px 8px rgba(31, 107, 69, 0.1),
        inset 0 3px 6px rgba(18, 53, 36, 0.1);
    background: linear-gradient(160deg, #e8f2eb 0%, #dce9e1 100%);
    transition-duration: 0.1s;
}

.num-btn .ripple {
    position: absolute;
    border-radius: 50%;
    background: rgba(31, 107, 69, 0.25);
    transform: scale(0);
    animation: rippleExpand 0.6s ease-out forwards;
    pointer-events: none;
}

@keyframes rippleExpand {
    to {
        transform: scale(2.5);
        opacity: 0;
    }
}

.num-btn.control-btn {
    font-size: 1.1rem;
    background: linear-gradient(160deg, #f9fcfa 0%, #eef5f1 100%);
    color: var(--text-muted);
    box-shadow:
        0 4px 0 #c5d9ce,
        0 6px 14px rgba(31, 107, 69, 0.08),
        inset 0 1px 0 rgba(255, 255, 255, 0.9);
}

.num-btn.control-btn:hover {
    box-shadow:
        0 6px 0 #c5d9ce,
        0 12px 22px rgba(31, 107, 69, 0.12),
        inset 0 1px 0 rgba(255, 255, 255, 0.9);
}

.num-btn.control-btn.pressed,
.num-btn.control-btn:active {
    background: linear-gradient(160deg, #fde8e8 0%, #f5d0d0 100%);
    color: var(--danger);
    box-shadow:
        0 1px 0 #e8b4b4,
        0 3px 8px rgba(220, 38, 38, 0.1),
        inset 0 3px 6px rgba(220, 38, 38, 0.08);
}

.num-btn .delete-icon {
    width: 26px;
    height: 26px;
    flex-shrink: 0;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
    pointer-events: none;
}

.error-alert {
    font-size: 0.85rem;
    padding: 10px 15px;
    border-radius: 12px;
    margin-bottom: 20px;
    background-color: #fef2f2;
    border: 1px solid #fca5a5;
    color: var(--danger);
    animation: shake 0.4s ease-in-out;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-6px); }
    75% { transform: translateX(6px); }
}

.loading-overlay {
    position: absolute;
    inset: 0;
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(6px);
    border-radius: 24px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 10;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
}

.loading-overlay.active {
    opacity: 1;
    pointer-events: all;
}

.spinner {
    width: 3rem;
    height: 3rem;
    border: 4px solid #e8f2eb;
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-bottom: 12px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading-text {
    color: var(--primary);
    font-weight: 700;
}

.login-card .page-link {
    margin-top: 24px;
}

.login-card .page-link a {
    transition: color 0.2s ease, transform 0.2s ease;
    display: inline-block;
}

.login-card .page-link a:hover {
    transform: translateY(-1px);
}

.pwa-install {
    margin-top: 20px;
    padding-top: 18px;
    border-top: 1px dashed #d4e5db;
}

.pwa-install__btn {
    width: 100%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 16px;
    border-radius: 14px;
    border: 1.5px solid #b8d8c5;
    background: linear-gradient(160deg, #f0fdf4 0%, #ffffff 100%);
    color: var(--primary);
    font-family: inherit;
    font-size: 0.95rem;
    font-weight: 700;
    cursor: pointer;
    transition:
        transform 0.2s ease,
        box-shadow 0.2s ease,
        border-color 0.2s ease,
        background 0.2s ease;
    box-shadow: 0 4px 14px rgba(31, 107, 69, 0.1);
}

.pwa-install__btn:hover {
    transform: translateY(-1px);
    border-color: #86efac;
    box-shadow: 0 8px 20px rgba(31, 107, 69, 0.16);
}

.pwa-install__btn:active {
    transform: translateY(0);
}

.pwa-install__btn i {
    font-size: 1.15rem;
}

.pwa-install__hint {
    margin: 8px 0 0;
    font-size: 0.78rem;
    color: var(--text-muted);
}

.pwa-install-modal {
    position: fixed;
    inset: 0;
    z-index: 1200;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: max(16px, env(safe-area-inset-top)) 16px max(16px, env(safe-area-inset-bottom));
}

.pwa-install-modal[hidden] {
    display: none !important;
}

.pwa-install-modal__backdrop {
    position: fixed;
    inset: 0;
    background: rgba(18, 53, 36, 0.45);
    backdrop-filter: blur(4px);
}

.pwa-install-modal__panel {
    position: relative;
    width: min(100%, 380px);
    max-height: calc(100dvh - 32px);
    margin: auto;
    flex-shrink: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    background: linear-gradient(160deg, #ffffff 0%, #f7fcf8 100%);
    border: 1px solid #dce9e1;
    border-radius: 20px;
    padding: 24px 22px 20px;
    box-shadow: 0 24px 48px rgba(18, 53, 36, 0.18);
    text-align: center;
}

.pwa-install-modal__close {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 34px;
    height: 34px;
    border: none;
    border-radius: 10px;
    background: #f0fdf4;
    color: var(--text-muted);
    display: grid;
    place-items: center;
    cursor: pointer;
}

.pwa-install-modal__close:hover {
    background: #dcfce7;
    color: var(--primary);
}

.pwa-install-modal__brand .logo-mark {
    width: 56px;
    height: 56px;
    padding: 5px;
    animation: none;
}

.pwa-install-modal__title {
    margin: 12px 0 8px;
    font-size: 1.25rem;
}

.pwa-install-modal__lead {
    margin: 0 0 14px;
    font-size: 0.9rem;
    color: var(--text-muted);
    line-height: 1.5;
}

.pwa-install-modal__steps {
    margin: 0 0 18px;
    padding-left: 20px;
    text-align: left;
    font-size: 0.88rem;
    color: var(--text-main);
    line-height: 1.55;
}

.pwa-install-modal__steps li + li {
    margin-top: 10px;
}

.pwa-install-modal__steps i {
    vertical-align: -2px;
    color: var(--primary);
}

.pwa-install-modal__done {
    width: 100%;
    border: none;
    border-radius: 12px;
    padding: 12px 16px;
    background: linear-gradient(135deg, #34d399 0%, #10b981 60%, #047857 100%);
    color: #ffffff;
    font-family: inherit;
    font-size: 0.95rem;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 8px 18px rgba(16, 185, 129, 0.25);
}

.pwa-install-modal__done:hover {
    filter: brightness(1.03);
}

body.pwa-install-modal-open {
    overflow: hidden;
}

@media (prefers-reduced-motion: reduce) {
    .card-enter,
    .app-logo,
    .logo-mark,
    .bg-orb,
    .num-btn,
    .pin-dot.pop {
        animation: none !important;
    }

    .card-enter {
        opacity: 1;
        transform: none;
    }

    .num-btn {
        transition: none;
    }
}

/* Register page */
.register-card {
    max-width: 460px;
}

.register-card .app-subtitle {
    margin-bottom: 20px;
}

.success-alert {
    font-size: 0.85rem;
    padding: 10px 15px;
    border-radius: 12px;
    margin-bottom: 20px;
    background-color: #f0fdf4;
    border: 1px solid #86efac;
    color: var(--success);
    animation: fadeInUp 0.5s cubic-bezier(0.34, 1.2, 0.64, 1);
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.register-form {
    text-align: left;
    margin-bottom: 16px;
}

.register-form .form-group {
    margin-bottom: 12px;
}

.register-form label {
    display: flex;
    align-items: center;
    gap: 6px;
    margin: 0 0 6px;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.register-form label i {
    color: var(--primary);
    font-size: 1rem;
}

.form-input {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid #d4e5db;
    border-radius: 12px;
    font-size: 16px;
    font-family: inherit;
    color: var(--text-main);
    background: linear-gradient(160deg, #ffffff 0%, #f7fcf8 100%);
    box-shadow:
        0 3px 0 #cfe0d6,
        0 4px 10px rgba(31, 107, 69, 0.06),
        inset 0 1px 0 rgba(255, 255, 255, 0.95);
    outline: none;
    transition:
        border-color 0.25s ease,
        box-shadow 0.28s cubic-bezier(0.34, 1.56, 0.64, 1),
        transform 0.28s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.form-input:focus {
    border-color: var(--primary);
    transform: translateY(-1px);
    box-shadow:
        0 4px 0 #b8d4c4,
        0 8px 18px rgba(31, 107, 69, 0.14),
        0 0 0 3px rgba(31, 107, 69, 0.1),
        inset 0 1px 0 rgba(255, 255, 255, 0.95);
}

.pin-section {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin: 6px 0 18px;
}

.pin-step {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}

.pin-step-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
    transition: color 0.3s ease;
}

.pin-step-label.active {
    color: var(--primary);
}

.pin-step-label.done {
    color: var(--success);
}

.pin-dots-sm {
    gap: 10px;
    margin-bottom: 0;
}

.pin-dots-sm .pin-dot {
    width: 14px;
    height: 14px;
}

.numpad-sm {
    gap: 12px;
    max-width: 280px;
}

.numpad-sm .num-btn {
    height: 56px;
    font-size: 1.4rem;
    border-radius: 14px;
}

.numpad-sm .delete-icon {
    width: 22px;
    height: 22px;
}

.submit-btn {
    position: relative;
    overflow: hidden;
    width: 100%;
    margin-top: 18px;
    border: 0;
    border-radius: 14px;
    padding: 14px;
    min-height: 50px;
    font-size: 1rem;
    font-weight: 700;
    font-family: inherit;
    color: #ffffff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: linear-gradient(160deg, #2a8f5c 0%, #1f6b45 100%);
    box-shadow:
        0 5px 0 #14532d,
        0 10px 24px rgba(31, 107, 69, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.2);
    transform: translateY(0);
    transition:
        transform 0.28s cubic-bezier(0.34, 1.56, 0.64, 1),
        box-shadow 0.28s cubic-bezier(0.34, 1.56, 0.64, 1),
        opacity 0.2s ease;
    animation: btnFadeIn 0.5s cubic-bezier(0.34, 1.2, 0.64, 1) 0.5s backwards;
}

.submit-btn:hover:not(:disabled) {
    transform: translateY(-3px);
    box-shadow:
        0 7px 0 #14532d,
        0 14px 30px rgba(31, 107, 69, 0.35),
        inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.submit-btn.pressed:not(:disabled),
.submit-btn:active:not(:disabled) {
    transform: translateY(4px);
    box-shadow:
        0 1px 0 #14532d,
        0 4px 12px rgba(31, 107, 69, 0.2),
        inset 0 3px 6px rgba(0, 0, 0, 0.15);
}

.submit-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    box-shadow:
        0 3px 0 #a8c4b4,
        0 4px 10px rgba(31, 107, 69, 0.1);
}

.register-card .page-link {
    margin-top: 18px;
}

.register-pin-info {
    display: none;
    margin: 10px 0 14px;
    padding: 12px 14px;
    border-radius: 12px;
    border: 1px solid #bae6fd;
    background: linear-gradient(160deg, #f0f9ff 0%, #e0f2fe 100%);
    text-align: center;
}

.register-pin-info.show {
    display: block;
}

.register-pin-info__label {
    font-size: 0.82rem;
    font-weight: 700;
    color: #0369a1;
    margin-bottom: 6px;
}

.register-pin-info__label i {
    vertical-align: -2px;
    margin-right: 4px;
}

.register-pin-info__value {
    font-size: 1.75rem;
    font-weight: 800;
    letter-spacing: 0.35em;
    color: #0c4a6e;
    font-variant-numeric: tabular-nums;
}

.register-pin-info__hint {
    margin-top: 6px;
    font-size: 0.72rem;
    color: #64748b;
    line-height: 1.4;
}

.register-signature-section {
    display: none;
    margin-bottom: 12px;
    text-align: left;
}

.register-signature-section.show {
    display: block;
}

.register-signature-label {
    display: flex;
    align-items: center;
    gap: 6px;
    margin: 0 0 8px;
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-muted);
}

.register-signature-label i {
    color: var(--primary);
}

.register-signature-box {
    min-height: 88px;
}

.register-role-section {
    display: none;
    margin: 8px 0 12px;
    text-align: left;
}

.register-role-section.show {
    display: block;
}

.register-role-label {
    display: flex;
    align-items: center;
    gap: 6px;
    margin: 0 0 8px;
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-muted);
}

.register-role-label i {
    color: var(--primary);
}

.register-role-selector {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    background: #f1f5f3;
    padding: 4px;
    border-radius: 12px;
}

.register-role-option {
    position: relative;
    cursor: pointer;
}

.register-role-option input[type="radio"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.register-role-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    min-height: 64px;
    padding: 10px 8px;
    border-radius: 10px;
    background: transparent;
    color: #5b6f64;
    font-size: 0.82rem;
    font-weight: 700;
    transition: all 0.2s ease;
}

.register-role-card i {
    font-size: 1.25rem;
    line-height: 1;
}

.register-role-option input[value="store"]:checked + .register-role-card--store {
    background: linear-gradient(135deg, #2a8a5a 0%, #1f6b45 100%);
    color: #fff;
    box-shadow: 0 4px 14px rgba(31, 107, 69, 0.28);
}

.register-role-option input[value="bfg"]:checked + .register-role-card--bfg {
    background: linear-gradient(135deg, #38bdf8 0%, #0284c7 100%);
    color: #fff;
    box-shadow: 0 4px 14px rgba(2, 132, 199, 0.28);
}

.register-role-option input[value="miniadmin"]:checked + .register-role-card--miniadmin {
    background: linear-gradient(135deg, #f59e0b 0%, #b45309 100%);
    color: #fff;
    box-shadow: 0 4px 14px rgba(180, 83, 9, 0.32);
}

.register-lookup {
    text-align: left;
    margin-bottom: 14px;
}

.register-lookup label {
    display: flex;
    align-items: center;
    gap: 6px;
    margin: 0 0 8px;
    font-size: 0.85rem;
    color: var(--text-muted);
    font-weight: 600;
}

.register-lookup label i {
    color: var(--primary);
}

.lookup-row {
    display: flex;
    align-items: stretch;
    gap: 10px;
}

.lookup-row .form-input {
    flex: 1;
    min-width: 0;
}

.lookup-btn {
    flex-shrink: 0;
    width: auto;
    min-width: 120px;
    margin-top: 0;
    border: 0;
    border-radius: 12px;
    padding: 0 16px;
    min-height: 48px;
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 700;
    color: #ffffff;
    cursor: pointer;
    background: linear-gradient(160deg, #2a8f5c 0%, #1f6b45 100%);
    box-shadow:
        0 4px 0 #14532d,
        0 8px 18px rgba(31, 107, 69, 0.25),
        inset 0 1px 0 rgba(255, 255, 255, 0.2);
    transition:
        transform 0.28s cubic-bezier(0.34, 1.56, 0.64, 1),
        box-shadow 0.28s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.lookup-btn:hover {
    transform: translateY(-2px);
}

.lookup-btn:active {
    transform: translateY(3px);
    box-shadow:
        0 1px 0 #14532d,
        0 4px 10px rgba(31, 107, 69, 0.2),
        inset 0 2px 4px rgba(0, 0, 0, 0.12);
}

.lookup-hint {
    margin-top: 8px;
    font-size: 0.8rem;
    color: var(--text-muted);
    text-align: left;
}

.lookup-hint.success {
    color: var(--success);
    font-weight: 600;
}

.lookup-hint.error {
    color: var(--danger);
    font-weight: 600;
}

.lookup-hint.loading {
    color: var(--primary);
}

.employee-preview {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
    margin: 10px 0 16px;
    text-align: left;
}

.preview-item {
    background: linear-gradient(160deg, #f7fcf8 0%, #edf5f0 100%);
    border: 1px solid #dbe9df;
    border-radius: 12px;
    padding: 10px 12px;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.9);
}

.preview-item span {
    display: block;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.preview-item strong {
    font-size: 0.9rem;
    color: var(--text-main);
    word-break: break-word;
}

.preview-input {
    width: 100%;
    border: 1px solid #dbe9df;
    border-radius: 10px;
    background: #ffffff;
    padding: 8px 10px;
    font-size: 0.9rem;
    color: var(--text-main);
}

.pin-section-disabled {
    opacity: 0.45;
    pointer-events: none;
    filter: grayscale(0.2);
}

/* Register mobile — เลื่อนได้ + ย่อส่วน PIN ให้เห็นปุ่มลงทะเบียน */
.register-page.auth-page {
    align-items: flex-start;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    padding: 12px 12px max(16px, env(safe-area-inset-bottom));
}

.register-page.login-page {
    overflow-y: auto;
    overflow-x: hidden;
    min-height: 100dvh;
    min-height: 100svh;
}

@media (max-width: 768px) {
    .register-card {
        padding: 18px 14px 20px;
        margin: 0 auto 12px;
    }

    .register-card .app-logo {
        margin-bottom: 6px;
        animation: none;
    }

    .register-card .app-logo i {
        font-size: 2rem;
        line-height: 1;
    }

    .register-card .app-title {
        font-size: 1.25rem;
        margin-bottom: 2px;
    }

    .register-card .app-subtitle {
        margin-bottom: 12px;
        font-size: 0.82rem;
        line-height: 1.4;
    }

    .register-lookup {
        margin-bottom: 8px;
    }

    .register-lookup label {
        margin-bottom: 6px;
        font-size: 0.8rem;
    }

    .lookup-hint {
        margin-top: 6px;
        font-size: 0.75rem;
    }

    .employee-preview {
        grid-template-columns: 1fr 1fr;
        gap: 8px;
        margin: 8px 0 10px;
    }

    .preview-item {
        padding: 8px 10px;
        border-radius: 10px;
    }

    .preview-item span {
        font-size: 0.68rem;
        margin-bottom: 2px;
    }

    .preview-item strong {
        font-size: 0.82rem;
    }

    .register-page .register-pin-info__value {
        font-size: 1.45rem;
        letter-spacing: 0.28em;
    }

    .register-page .register-signature-box {
        min-height: 72px;
    }

    .register-page .register-role-card {
        min-height: 56px;
        font-size: 0.78rem;
        padding: 8px 6px;
    }

    .register-page .register-role-card i {
        font-size: 1.1rem;
    }

    .register-page .submit-btn {
        margin-top: 10px;
        min-height: 46px;
        padding: 11px;
        font-size: 0.95rem;
    }

    .register-card .page-link {
        margin-top: 10px;
        font-size: 0.85rem;
    }
}

@media (max-width: 768px) and (max-height: 740px) {
    .register-card .app-subtitle {
        margin-bottom: 8px;
    }
}

/* ===== Dashboard (premium) ===== */
.dash {
    --dash-green: #1f6b45;
    --dash-green-dark: #123524;
    --dash-hero-shadow: rgba(18, 53, 36, 0.28);
    min-height: 100vh;
    margin: 0;
    background:
        radial-gradient(1200px 600px at 100% -10%, rgba(31, 107, 69, 0.10), transparent 60%),
        radial-gradient(900px 500px at -10% 110%, rgba(31, 107, 69, 0.08), transparent 55%),
        #f1f6f2;
    color: var(--text-main);
}

/* --- Theme 0: เบิกตะกร้าออกจากคลังหลัก (Forest Green Theme) --- */
.dash.theme-withdraw {
    --dash-green: #1f6b45; /* Forest Green */
    --dash-green-dark: #123524; /* Dark Forest Green */
    --dash-hero-shadow: rgba(18, 53, 36, 0.28);
    --bg-main: #f1f6f2;
    --bg-secondary: #e2ece6;
    --text-main: #123524;
    --text-muted: #5b6f64;
    background:
        radial-gradient(1200px 600px at 100% -10%, rgba(31, 107, 69, 0.10), transparent 60%),
        radial-gradient(900px 500px at -10% 110%, rgba(31, 107, 69, 0.08), transparent 55%),
        #f1f6f2;
}
.dash.theme-withdraw .dash-nav {
    border-bottom: 1px solid #bcd9c7;
}
.dash.theme-withdraw .dash-user {
    border-color: #bcd9c7;
    background: #f1f6f2;
}
.dash.theme-withdraw .dash-user__avatar {
    background: linear-gradient(135deg, #2a8a5a 0%, #1f6b45 55%, #123524 100%);
}
.dash.theme-withdraw .dash-back {
    color: #1f6b45;
    border-color: #bcd9c7;
}
.dash.theme-withdraw .dash-back:hover {
    background: #f1f6f2;
    border-color: #2a8a5a;
}

/* --- Theme 1: จ่ายตะกร้าส่ง CP (Orange/Amber Theme) --- */
.dash.theme-to-cp {
    --dash-green: #ea580c; /* Orange */
    --dash-green-dark: #7c2d12; /* Dark Brown-Orange */
    --dash-hero-shadow: rgba(124, 45, 18, 0.28);
    --bg-main: #fff7ed;
    --bg-secondary: #ffedd5;
    --text-main: #431407;
    --text-muted: #7c2d12;
    background:
        radial-gradient(1200px 600px at 100% -10%, rgba(234, 88, 12, 0.08), transparent 60%),
        radial-gradient(900px 500px at -10% 110%, rgba(234, 88, 12, 0.06), transparent 55%),
        #fefaf6;
}
.dash.theme-to-cp .dash-nav {
    border-bottom: 1px solid #fed7aa;
}
.dash.theme-to-cp .dash-user {
    border-color: #fbd38d;
    background: #fffaf0;
}
.dash.theme-to-cp .dash-user__avatar {
    background: linear-gradient(135deg, #f97316 0%, #ea580c 55%, #7c2d12 100%);
}
.dash.theme-to-cp .withdraw-card {
    border-color: #fbd38d;
    box-shadow: 0 10px 30px rgba(234, 88, 12, 0.02);
}
.dash.theme-to-cp .withdraw-card:hover {
    box-shadow: 0 15px 35px rgba(234, 88, 12, 0.05);
}
.dash.theme-to-cp .withdraw-card__header {
    border-bottom-color: #fff7ed;
}
.dash.theme-to-cp .input-wrapper input:focus,
.dash.theme-to-cp .input-wrapper select:focus {
    border-color: #ea580c;
    box-shadow: 0 0 0 4px rgba(234, 88, 12, 0.12);
}
.dash.theme-to-cp .dash-back {
    color: #ea580c;
    border-color: #fbd38d;
}
.dash.theme-to-cp .dash-back:hover {
    background: #fff7ed;
    border-color: #f7a072;
}

/* --- Theme 2: รับเข้าคืนตะกร้า (Blue/Teal Theme) --- */
.dash.theme-receive {
    --dash-green: #0284c7; /* Ocean Blue */
    --dash-green-dark: #0f172a; /* Slate Blue */
    --dash-hero-shadow: rgba(15, 23, 42, 0.28);
    --bg-main: #f0f9ff;
    --bg-secondary: #e0f2fe;
    --text-main: #032b45;
    --text-muted: #1e3a8a;
    background:
        radial-gradient(1200px 600px at 100% -10%, rgba(2, 132, 199, 0.08), transparent 60%),
        radial-gradient(900px 500px at -10% 110%, rgba(2, 132, 199, 0.06), transparent 55%),
        #f4faff;
}
.dash.theme-receive .dash-nav {
    border-bottom: 1px solid #bae6fd;
}
.dash.theme-receive .dash-user {
    border-color: #93c5fd;
    background: #f0f7ff;
}
.dash.theme-receive .dash-user__avatar {
    background: linear-gradient(135deg, #38bdf8 0%, #0284c7 55%, #1e3a8a 100%);
}
.dash.theme-receive .withdraw-card {
    border-color: #bae6fd;
    box-shadow: 0 10px 30px rgba(2, 132, 199, 0.02);
}
.dash.theme-receive .withdraw-card:hover {
    box-shadow: 0 15px 35px rgba(2, 132, 199, 0.05);
}
.dash.theme-receive .withdraw-card__header {
    border-bottom-color: #f0f9ff;
}
.dash.theme-receive .input-wrapper input:focus,
.dash.theme-receive .input-wrapper select:focus {
    border-color: #0284c7;
    box-shadow: 0 0 0 4px rgba(2, 132, 199, 0.12);
}
.dash.theme-receive .dash-back {
    color: #0284c7;
    border-color: #bae6fd;
}
.dash.theme-receive .dash-back:hover {
    background: #f0f9ff;
    border-color: #38bdf8;
}

/* --- Theme 3: จัดการคลังตะกร้าทั้งหมดสำหรับ Admin (Deep Teal Theme) --- */
.dash.theme-stock {
    --dash-green: #0d9488; /* Deep Teal */
    --dash-green-dark: #115e59; /* Dark Teal */
    --dash-hero-shadow: rgba(17, 94, 89, 0.28);
    --bg-main: #f0fdfa;
    --bg-secondary: #ccfbf1;
    --text-main: #042f2e;
    --text-muted: #115e59;
    background:
        radial-gradient(1200px 600px at 100% -10%, rgba(13, 148, 136, 0.08), transparent 60%),
        radial-gradient(900px 500px at -10% 110%, rgba(13, 148, 136, 0.06), transparent 55%),
        #f5fdfb;
}
.dash.theme-stock .dash-nav {
    border-bottom: 1px solid #99f6e4;
}
.dash.theme-stock .dash-user {
    border-color: #5eead4;
    background: #f0fdfa;
}
.dash.theme-stock .dash-user__avatar {
    background: linear-gradient(135deg, #14b8a6 0%, #0d9488 55%, #115e59 100%);
}
.dash.theme-stock .withdraw-card {
    border-color: #99f6e4;
    box-shadow: 0 10px 30px rgba(13, 148, 136, 0.02);
}
.dash.theme-stock .withdraw-card:hover {
    box-shadow: 0 15px 35px rgba(13, 148, 136, 0.05);
}
.dash.theme-stock .withdraw-card__header {
    border-bottom-color: #f0fdfa;
}
.dash.theme-stock .input-wrapper input:focus,
.dash.theme-stock .input-wrapper select:focus {
    border-color: #0d9488;
    box-shadow: 0 0 0 4px rgba(13, 148, 136, 0.12);
}
.dash.theme-stock .dash-back {
    color: #0d9488;
    border-color: #99f6e4;
}
.dash.theme-stock .dash-back:hover {
    background: #f0fdfa;
    border-color: #14b8a6;
}

/* --- Theme 4: รายงานและประวัติย้อนหลัง (Indigo Theme) --- */
.dash.theme-reports {
    --dash-green: #6366f1; /* Indigo */
    --dash-green-dark: #312e81; /* Dark Indigo */
    --dash-hero-shadow: rgba(49, 46, 129, 0.28);
    --bg-main: #eef2ff;
    --bg-secondary: #e0e7ff;
    --text-main: #1e1b4b;
    --text-muted: #312e81;
    background:
        radial-gradient(1200px 600px at 100% -10%, rgba(99, 102, 241, 0.08), transparent 60%),
        radial-gradient(900px 500px at -10% 110%, rgba(99, 102, 241, 0.06), transparent 55%),
        #fafaff;
}

/* --- Theme 5: แผงสรุปยอดผู้บริหาร (Premium Purple/Violet Theme) --- */
.dash.theme-dashboard {
    --dash-green: #8b5cf6; /* Violet */
    --dash-green-dark: #4c1d95; /* Dark Purple */
    --dash-hero-shadow: rgba(76, 29, 149, 0.28);
    --bg-main: #f5f3ff;
    --bg-secondary: #ede9fe;
    --text-main: #2e1065;
    --text-muted: #4c1d95;
    background:
        radial-gradient(1200px 600px at 100% -10%, rgba(139, 92, 246, 0.08), transparent 60%),
        radial-gradient(900px 500px at -10% 110%, rgba(139, 92, 246, 0.06), transparent 55%),
        #faf5ff;
}
.dash.theme-dashboard .dash-nav {
    border-bottom: 1px solid #ddd6fe;
}
.dash.theme-dashboard .dash-user {
    border-color: #c084fc;
    background: #faf5ff;
}
.dash.theme-dashboard .dash-user__avatar {
    background: linear-gradient(135deg, #a78bfa 0%, #8b5cf6 55%, #4c1d95 100%);
}
.dash.theme-dashboard .dash-back {
    color: #8b5cf6;
    border-color: #ddd6fe;
}
.dash.theme-dashboard .dash-back:hover {
    background: #f5f3ff;
    border-color: #a78bfa;
}
.dash.theme-reports .dash-nav {
    border-bottom: 1px solid #c7d2fe;
}
.dash.theme-reports .dash-user {
    border-color: #a5b4fc;
    background: #f5f7ff;
}
.dash.theme-reports .dash-user__avatar {
    background: linear-gradient(135deg, #818cf8 0%, #6366f1 55%, #312e81 100%);
}
.dash.theme-reports .filter-section {
    border-color: #c7d2fe;
    box-shadow: 0 10px 30px rgba(99, 102, 241, 0.02);
}
.dash.theme-reports .history-table-container {
    border-color: #c7d2fe;
}
.dash.theme-reports .history-table th {
    background: #f5f7ff;
    border-bottom-color: #a5b4fc;
    color: #312e81;
}
.dash.theme-reports .input-wrapper input:focus,
.dash.theme-reports .input-wrapper select:focus {
    border-color: #6366f1;
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.12);
}
.dash.theme-reports .dash-back {
    color: #6366f1;
    border-color: #c7d2fe;
}
.dash.theme-reports .dash-back:hover {
    background: #f5f7ff;
    border-color: #818cf8;
}
.dash.theme-reports .pagination-btn.active {
    background: #6366f1;
    border-color: #6366f1;
}
.dash.theme-reports .btn-filter-submit {
    background: linear-gradient(135deg, #818cf8 0%, #6366f1 60%, #312e81 100%);
    box-shadow: 0 4px 10px rgba(99, 102, 241, 0.25);
}
.dash.theme-reports .btn-filter-submit:hover {
    box-shadow: 0 6px 15px rgba(99, 102, 241, 0.35);
}
.dash.theme-reports .btn-print-action {
    color: #6366f1;
    border-color: #c7d2fe;
}
.dash.theme-reports .btn-print-action:hover {
    background: #f5f7ff;
    border-color: #818cf8;
}

/* --- Theme 6: รายงานสรุปยอดประจำวัน (Emerald/Mint Theme) --- */
.dash.theme-summary {
    --dash-green: #10b981; /* Emerald */
    --dash-green-dark: #064e3b; /* Dark Emerald */
    --dash-hero-shadow: rgba(6, 78, 59, 0.28);
    --bg-main: #ecfdf5;
    --bg-secondary: #d1fae5;
    --text-main: #064e3b;
    --text-muted: #047857;
    background:
        radial-gradient(1200px 600px at 100% -10%, rgba(16, 185, 129, 0.08), transparent 60%),
        radial-gradient(900px 500px at -10% 110%, rgba(16, 185, 129, 0.06), transparent 55%),
        #f9fbfb;
}
.dash.theme-summary .dash-nav {
    border-bottom: 1px solid #a7f3d0;
}
.dash.theme-summary .dash-user {
    border-color: #6ee7b7;
    background: #f0fdf4;
}
.dash.theme-summary .dash-user__avatar {
    background: linear-gradient(135deg, #34d399 0%, #10b981 55%, #064e3b 100%);
}
.dash.theme-summary .dash-back {
    color: #10b981;
    border-color: #a7f3d0;
}
.dash.theme-summary .dash-back:hover {
    background: #f0fdf4;
    border-color: #34d399;
}
.dash.theme-summary .filter-section {
    border-color: #a7f3d0;
    box-shadow: 0 10px 30px rgba(16, 185, 129, 0.02);
}
.dash.theme-summary .history-table-container {
    border: none;
}
.dash.theme-summary .history-table {
    border-collapse: collapse;
    width: 100%;
}
.dash.theme-summary .history-table th {
    background: #f0fdf4;
    color: #064e3b;
}
.dash.theme-summary .history-table th,
.dash.theme-summary .history-table td {
    border: 1px solid #000000;
}
.dash.theme-summary .input-wrapper input:focus,
.dash.theme-summary .input-wrapper select:focus {
    border-color: #10b981;
    box-shadow: 0 0 0 4px rgba(16, 185, 129, 0.12);
}
.dash.theme-summary .btn-filter-submit {
    background: linear-gradient(135deg, #34d399 0%, #10b981 60%, #064e3b 100%);
    box-shadow: 0 4px 10px rgba(16, 185, 129, 0.25);
}
.dash.theme-summary .btn-filter-submit:hover {
    box-shadow: 0 6px 15px rgba(16, 185, 129, 0.35);
}
.dash.theme-summary .btn-print-action {
    color: #10b981;
    border-color: #a7f3d0;
}
.dash.theme-summary .btn-print-action:hover {
    background: #f0fdf4;
    border-color: #34d399;
}

.dash-nav {
    position: sticky;
    top: 0;
    z-index: 20;
    background: rgba(255, 255, 255, 0.82);
    backdrop-filter: saturate(150%) blur(12px);
    -webkit-backdrop-filter: saturate(150%) blur(12px);
    border-bottom: 1px solid #e2ece6;
}

.dash-nav__inner {
    max-width: 1080px;
    margin: 0 auto;
    padding: 12px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.dash-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.dash-brand__logo {
    width: 44px;
    height: 44px;
    object-fit: contain;
    border-radius: 12px;
    background: #fff;
    padding: 4px;
    box-shadow: 0 6px 16px rgba(31, 107, 69, 0.18);
}

.dash-brand__text {
    display: flex;
    flex-direction: column;
    line-height: 1.2;
    min-width: 0;
}

.dash-brand__name {
    font-weight: 700;
    font-size: 17px;
    color: var(--dash-green-dark);
}

.dash-brand__sub {
    font-size: 12px;
    color: var(--text-muted);
}

.dash-nav__right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.dash-user {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 10px 6px 6px;
    background: #ffffff;
    border: 1px solid #e2ece6;
    border-radius: 999px;
    box-shadow: 0 2px 8px rgba(18, 53, 36, 0.05);
}

.dash-user__avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    color: #fff;
    font-weight: 700;
    font-size: 14px;
    background: linear-gradient(135deg, #2a8a5a 0%, #1f6b45 55%, #123524 100%);
    box-shadow: inset 0 1px 1px rgba(255, 255, 255, 0.3);
}

.dash-user__meta {
    display: flex;
    flex-direction: column;
    line-height: 1.2;
}

.dash-user__name {
    font-weight: 600;
    font-size: 14px;
    color: var(--text-main);
}

.dash-user__role {
    font-size: 12px;
    color: var(--text-muted);
}

.dash-logout {
    width: 42px;
    height: 42px;
    flex: none;
    display: grid;
    place-items: center;
    border-radius: 12px;
    color: var(--text-muted);
    background: #ffffff;
    border: 1px solid #e2ece6;
    transition: color 0.2s ease, background 0.2s ease, border-color 0.2s ease, transform 0.15s ease;
}

.dash-logout svg {
    width: 20px;
    height: 20px;
}

.dash-logout:hover {
    color: var(--danger);
    border-color: #f3c6c6;
    background: #fff5f5;
}

.dash-logout:active {
    transform: scale(0.94);
}

.dash-main {
    max-width: 1080px;
    margin: 0 auto;
    padding: 28px 24px 56px;
}

.dash-hero {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    padding: 26px 28px;
    border-radius: 22px;
    color: #ffffff;
    background:
        radial-gradient(600px 240px at 90% -40%, rgba(255, 255, 255, 0.18), transparent 60%),
        linear-gradient(135deg, var(--dash-green, #1f6b45) 0%, var(--dash-green-dark, #123524) 100%);
    box-shadow: 0 18px 40px var(--dash-hero-shadow, rgba(18, 53, 36, 0.28));
    position: relative;
    overflow: hidden;
}

.dash-hero::after {
    content: "";
    position: absolute;
    right: -40px;
    bottom: -60px;
    width: 200px;
    height: 200px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.06);
}

.dash-hero__greet {
    margin: 0 0 4px;
    font-size: 14px;
    color: rgba(234, 255, 243, 0.8);
}

.dash-hero__name {
    margin: 0 0 8px;
    font-size: 26px;
    font-weight: 700;
    text-align: left;
    color: #ffffff;
}

.dash-hero__meta {
    margin: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.dash-hero__meta span {
    font-size: 12.5px;
    padding: 4px 12px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.14);
    border: 1px solid rgba(255, 255, 255, 0.18);
}

.dash-hero__date {
    flex: none;
    font-size: 13px;
    color: rgba(234, 255, 243, 0.92);
    padding: 8px 14px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.18);
    position: relative;
    z-index: 1;
}

.dash-section-title {
    margin: 30px 2px 14px;
    font-size: 16px;
    font-weight: 700;
    color: var(--dash-green-dark);
    text-align: left;
}

.dash-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 18px;
}

.dash-card {
    --accent: #1f6b45;
    --accent-soft: rgba(31, 107, 69, 0.12);
    --card-glow: rgba(18, 53, 36, 0.12);
    display: flex;
    flex-direction: column;
    text-decoration: none;
    color: inherit;
    background: #ffffff;
    border: 1px solid #e6efe9;
    border-radius: 20px;
    padding: 22px;
    box-shadow: 0 10px 26px rgba(18, 53, 36, 0.06);
    position: relative;
    overflow: hidden;
    isolation: isolate;
    transition: transform 0.25s cubic-bezier(.2,.8,.25,1), box-shadow 0.25s ease, border-color 0.25s ease;
    will-change: transform;
}

.dash-card::before {
    content: "";
    position: absolute;
    inset: 0 0 auto 0;
    height: 5px;
    background: var(--accent);
    transform: scaleX(0);
    transform-origin: left;
    transition: transform 0.4s cubic-bezier(.25,.8,.25,1);
}

.dash-card::after {
    content: "";
    position: absolute;
    right: -30px;
    bottom: -30px;
    width: 120px;
    height: 120px;
    border-radius: 50%;
    background: var(--accent);
    opacity: 0.015;
    transition: all 0.4s ease;
    z-index: -1;
}

.dash-card:hover {
    transform: translateY(-8px);
    border-color: var(--accent);
    box-shadow: 0 20px 38px var(--card-glow);
}

.dash-card:hover::after {
    transform: scale(1.6);
    opacity: 0.045;
}

.dash-card:hover::before {
    transform: scaleX(1);
}

.dash-card:active {
    transform: translateY(-2px);
}

.dash-card--green { 
    --accent: #1f6b45; 
    --accent-soft: rgba(31, 107, 69, 0.08); 
    --card-glow: rgba(31, 107, 69, 0.15);
    background: linear-gradient(135deg, #f4faf6 0%, #ffffff 100%);
    border-left: 5px solid #1f6b45;
}
.dash-card--teal { 
    --accent: #0284c7; 
    --accent-soft: rgba(2, 132, 199, 0.08); 
    --card-glow: rgba(2, 132, 199, 0.15);
    background: linear-gradient(135deg, #f0f9ff 0%, #ffffff 100%);
    border-left: 5px solid #0284c7;
}
.dash-card--orange { 
    --accent: #ea580c; 
    --accent-soft: rgba(234, 88, 12, 0.08); 
    --card-glow: rgba(234, 88, 12, 0.15);
    background: linear-gradient(135deg, #fff7ed 0%, #ffffff 100%);
    border-left: 5px solid #ea580c;
}
.dash-card--stock { 
    --accent: #0d9488; 
    --accent-soft: rgba(13, 148, 136, 0.08); 
    --card-glow: rgba(13, 148, 136, 0.15);
    background: linear-gradient(135deg, #f0fdfa 0%, #ffffff 100%);
    border-left: 5px solid #0d9488;
}
.dash-card--executive { 
    --accent: #8b5cf6; 
    --accent-soft: rgba(139, 92, 246, 0.08); 
    --card-glow: rgba(139, 92, 246, 0.15);
    background: linear-gradient(135deg, #f5f3ff 0%, #ffffff 100%);
    border-left: 5px solid #8b5cf6;
}
.dash-card--reports { 
    --accent: #6366f1; 
    --accent-soft: rgba(99, 102, 241, 0.08); 
    --card-glow: rgba(99, 102, 241, 0.15);
    background: linear-gradient(135deg, #eef2ff 0%, #ffffff 100%);
    border-left: 5px solid #6366f1;
}
.dash-card--summary { 
    --accent: #10b981; 
    --accent-soft: rgba(16, 185, 129, 0.08); 
    --card-glow: rgba(16, 185, 129, 0.15);
    background: linear-gradient(135deg, #ecfdf5 0%, #ffffff 100%);
    border-left: 5px solid #10b981;
}

.dash-card__icon {
    width: 58px;
    height: 58px;
    border-radius: 16px;
    display: grid;
    place-items: center;
    color: var(--accent);
    background: var(--accent-soft);
    margin-bottom: 18px;
    transition: transform 0.25s ease, background 0.25s ease, color 0.25s ease;
}

.dash-card__icon svg {
    width: 30px;
    height: 30px;
}

.dash-card:hover .dash-card__icon {
    transform: scale(1.12) rotate(6deg);
    color: #fff;
    background: linear-gradient(135deg, var(--accent) 0%, var(--dash-green-dark, #123524) 100%);
    box-shadow: 0 8px 20px var(--card-glow);
}

.dash-card__body {
    flex: 1;
}

.dash-card__body h3 {
    margin: 0 0 8px;
    font-size: 18px;
    font-weight: 700;
    color: var(--dash-green-dark);
    line-height: 1.3;
}

.dash-card__body p {
    margin: 0;
    font-size: 13.5px;
    line-height: 1.55;
    color: var(--text-muted);
}

.dash-card__cta {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-top: 18px;
    font-size: 13.5px;
    font-weight: 600;
    color: var(--accent);
}

.dash-card__cta svg {
    width: 16px;
    height: 16px;
    transition: transform 0.25s ease;
}

.dash-card:hover .dash-card__cta svg {
    transform: translateX(4px);
}

@media (max-width: 1024px) {
    .card {
        max-width: 520px;
    }

    .dash-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 768px) {
    .auth-page,
    .dashboard-page {
        padding: 14px;
    }

    .dash-nav__inner {
        padding: 10px 16px;
    }

    .dash-brand__sub {
        display: none;
    }

    .dash-user__meta {
        display: none;
    }

    .dash-main {
        padding: 20px 16px 44px;
    }

    .dash-hero {
        flex-direction: column;
        align-items: flex-start;
        gap: 14px;
        padding: 22px;
    }

    .dash-hero__name {
        font-size: 22px;
    }

    .dash-grid {
        grid-template-columns: 1fr;
        gap: 14px;
    }

    .dash-card {
        padding: 18px;
    }

    .card,
    .dashboard-card,
    .login-card {
        border-radius: 14px;
        padding: 18px 16px;
    }

    .login-card {
        padding: 28px 20px;
    }

    .num-btn {
        height: 58px;
        font-size: 1.4rem;
    }

    .pin-dots {
        gap: 12px;
        margin-bottom: 24px;
    }

    h1 {
        font-size: 22px;
    }

    input,
    button {
        min-height: 44px;
    }

    .pin-input {
        font-size: 22px;
        letter-spacing: 6px;
    }

}

@media (max-width: 480px) {
    .card,
    .login-card {
        padding: 16px 14px;
    }

    .pin-input {
        letter-spacing: 4px;
        font-size: 20px;
    }

    .app-logo .logo-mark {
        width: 56px;
        height: 56px;
        padding: 5px;
    }

    .app-title {
        font-size: 1.4rem;
    }

    .num-btn {
        height: 54px;
        border-radius: 14px;
    }

    .numpad {
        gap: 10px;
    }

    .numpad-sm {
        max-width: 100%;
    }

    .numpad-sm .num-btn {
        height: 50px;
        font-size: 1.25rem;
    }

    .register-card {
        max-width: 100%;
    }

    .lookup-row {
        flex-direction: column;
    }

    .lookup-btn {
        width: 100%;
        min-width: 0;
    }

    .employee-preview {
        grid-template-columns: 1fr;
    }
}

/* ===================================================================
   Basket Withdraw Form (Premium Redesign)
   =================================================================== */
.withdraw-grid {
    display: grid;
    grid-template-columns: 2.2fr 1fr;
    gap: 24px;
    align-items: start;
    transition: all 0.3s ease;
}

.withdraw-col-main, .withdraw-col-side {
    display: flex;
    flex-direction: column;
    gap: 24px;
    transition: all 0.3s ease;
}

.dash-back {
    width: 42px;
    height: 42px;
    flex: none;
    display: grid;
    place-items: center;
    border-radius: 12px;
    color: var(--dash-green, #1f6b45);
    background: #ffffff;
    border: 1px solid #e2ece6;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.dash-back svg { width: 22px; height: 22px; }
.dash-back:hover { background: #eef6f0; border-color: #b8d8c5; transform: translateX(-2px); }
.dash-back:active { transform: scale(0.94); }

.form-billno-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-weight: 700;
    font-size: 13.5px;
    letter-spacing: 0.5px;
    color: #1f6b45;
    background: rgba(31, 107, 69, 0.08);
    border: 1px solid rgba(31, 107, 69, 0.16);
    padding: 8px 16px;
    border-radius: 999px;
}

.form-billno-badge svg { width: 16px; height: 16px; }

.withdraw-alert {
    display: flex;
    gap: 14px;
    background: #fff5f5;
    border: 1px solid #f3c6c6;
    border-radius: 16px;
    padding: 16px 20px;
    margin-bottom: 24px;
    align-items: flex-start;
}

.withdraw-alert__icon {
    width: 24px;
    height: 24px;
    color: #cb3a31;
    flex: none;
}

.withdraw-alert__icon svg { width: 24px; height: 24px; }

.withdraw-alert__content {
    font-size: 14px;
    color: #912018;
}

.withdraw-alert__content strong { display: block; font-size: 15px; margin-bottom: 4px; }
.withdraw-alert__content ul { margin: 4px 0 0; padding-left: 20px; }
.withdraw-alert__content li { margin-top: 2px; }

/* Premium Card */
.withdraw-card {
    background: #ffffff;
    border: 1px solid #e2ece6;
    border-radius: 20px;
    padding: 24px;
    box-shadow: 0 10px 30px rgba(18, 53, 36, 0.03);
    transition: box-shadow 0.3s ease;
}

.withdraw-card:hover {
    box-shadow: 0 15px 35px rgba(18, 53, 36, 0.06);
}

.withdraw-card__header {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid #f1f6f3;
}

.withdraw-card__icon {
    width: 42px;
    height: 42px;
    border-radius: 10px;
    background: rgba(31, 107, 69, 0.08);
    color: #1f6b45;
    display: grid;
    place-items: center;
    flex: none;
}

.withdraw-card__icon svg { width: 22px; height: 22px; }

.withdraw-card__title {
    margin: 0;
    font-size: 16px;
    font-weight: 700;
    color: #123524;
    text-align: left;
}

.withdraw-card__subtitle {
    margin: 2px 0 0;
    font-size: 12px;
    color: var(--text-muted);
    text-align: left;
}

/* Form Fields */
.form-grid-3 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
}

.form-grid-2 {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
    margin-top: 16px;
}

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

.form-group label {
    font-size: 13px;
    font-weight: 600;
    color: #123524;
    text-align: left;
}

.input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.input-wrapper input {
    width: 100%;
    height: 48px;
    padding: 0 16px 0 44px;
    border: 1.5px solid #cfe0d6;
    border-radius: 12px;
    font-family: inherit;
    font-size: 14.5px;
    color: #123524;
    background: #fafdfb;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.input-wrapper select {
    width: 100%;
    height: 48px;
    padding: 0 36px 0 16px;
    border: 1.5px solid #cfe0d6;
    border-radius: 12px;
    font-family: inherit;
    font-size: 14.5px;
    color: #123524;
    background: #fafdfb;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='none' stroke='%235f7e70' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m2 4 4 4 4-4'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 16px center;
    background-size: 12px;
}

.input-wrapper input:focus,
.input-wrapper select:focus {
    outline: none;
    border-color: #1f6b45;
    box-shadow: 0 0 0 4px rgba(31, 107, 69, 0.12);
    background: #ffffff;
}

.input-wrapper.disabled input {
    background: #f3f7f4;
    color: #5f7e70;
    border-color: #e2ece6;
    cursor: not-allowed;
}

.field-icon {
    position: absolute;
    left: 14px;
    width: 18px;
    height: 18px;
    color: #8ba897;
    pointer-events: none;
}

/* Items List Table */
.items-list-container {
    border: 1px solid #e2ece6;
    border-radius: 14px;
    overflow: hidden;
    background: #ffffff;
    margin-bottom: 16px;
}

.items-list-header {
    display: grid;
    grid-template-columns: 2.8fr 1fr 48px;
    gap: 12px;
    padding: 12px 16px;
    background: #f4f8f5;
    border-bottom: 1px solid #e2ece6;
    font-size: 13px;
    font-weight: 700;
    color: #5f7e70;
    text-align: left;
}

.items-list-body {
    padding: 8px;
}

.items-list-row {
    display: grid;
    grid-template-columns: 2.8fr 1fr 48px;
    gap: 12px;
    align-items: center;
    padding: 6px 8px;
}

.items-list-row input,
.items-list-row select {
    width: 100%;
    height: 44px;
    padding: 0 14px;
    border: 1.5px solid #cfe0d6;
    border-radius: 10px;
    font-family: inherit;
    font-size: 14px;
    color: #123524;
    background: #fafdfb;
    transition: all 0.2s ease;
    cursor: pointer;
}

.items-list-row select {
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='none' stroke='%235f7e70' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m2 4 4 4 4-4'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    background-size: 12px;
    padding-right: 36px;
}

.items-list-row input[type="number"] {
    cursor: text;
}

.items-list-row input:focus,
.items-list-row select:focus {
    outline: none;
    border-color: #1f6b45;
    box-shadow: 0 0 0 3px rgba(31, 107, 69, 0.1);
    background: #ffffff;
}

.btn-row-delete {
    width: 44px;
    height: 44px;
    min-height: auto;
    margin-top: 0;
    display: grid;
    place-items: center;
    border: 1px solid #f9d5d5;
    background: #fff5f5;
    color: #cb3a31;
    border-radius: 10px;
    cursor: pointer;
    padding: 0;
    transition: all 0.2s ease;
}

.btn-row-delete svg { width: 18px; height: 18px; }
.btn-row-delete:hover { background: #ffebeb; border-color: #cb3a31; transform: scale(1.02); }
.btn-row-delete:active { transform: scale(0.95); }

.btn-add-item {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    height: 48px;
    border: 1.5px dashed #a3cbb6;
    background: #f4faf6;
    color: #1f6b45;
    font-weight: 600;
    font-size: 14px;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-add-item svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

.btn-add-item:hover { background: #e9f5f0; border-color: #1f6b45; color: #185537; }

/* Photo Upload */
.photo-upload-zone {
    position: relative;
    border: 2px dashed #bcd9c7;
    border-radius: 14px;
    background: #fafdfb;
    padding: 10px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s ease;
    aspect-ratio: 16 / 9;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    max-width: 320px;
    margin: 0 auto;
}

.photo-upload-zone:hover { border-color: #1f6b45; background: #f2f9f5; }

.photo-upload-zone input[type=file] {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
    z-index: 3;
}

.upload-zone-preview {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    border-radius: 14px;
    overflow: hidden;
    z-index: 2;
    background: #000;
}

.upload-zone-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.upload-zone-delete {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.9);
    border: none;
    color: #ef4444;
    font-size: 20px;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 4;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    transition: all 0.2s ease;
}

.upload-zone-delete:hover {
    background: #ef4444;
    color: #fff;
    transform: scale(1.1);
}

.upload-zone-badge {
    position: absolute;
    bottom: 10px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(18, 53, 36, 0.85);
    color: #fff;
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 11.5px;
    font-weight: 500;
    pointer-events: none;
    backdrop-filter: blur(4px);
    box-shadow: 0 2px 6px rgba(0,0,0,0.1);
}

.upload-zone-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}

.upload-zone-icon {
    width: 40px;
    height: 40px;
    display: grid;
    place-items: center;
    color: #8ba897;
}

.upload-zone-icon svg { width: 32px; height: 32px; }
.upload-zone-text { font-size: 14px; font-weight: 600; color: #123524; }
.upload-zone-hint { font-size: 11.5px; color: var(--text-muted); }

.photo-preview-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
    gap: 10px;
    margin-top: 16px;
}

.photo-thumb {
    position: relative;
    aspect-ratio: 1;
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid #e2ece6;
    background: #f4f8f5;
    box-shadow: 0 4px 12px rgba(0,0,0,0.03);
}

.photo-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    cursor: zoom-in;
}

.photo-thumb .thumb-del {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: none;
    background: rgba(18, 53, 36, 0.8);
    color: #fff;
    font-size: 16px;
    display: grid;
    place-items: center;
    cursor: pointer;
    padding: 0;
    transition: all 0.2s ease;
}

.photo-thumb .thumb-del:hover { background: #cb3a31; }

/* Signature Trigger Box */
.signature-trigger-box {
    width: 100%;
    min-height: 140px;
    border: 2px dashed #bcd9c7;
    border-radius: 16px;
    background: #fafdfb;
    cursor: pointer;
    display: grid;
    place-items: center;
    padding: 12px;
    transition: all 0.2s ease;
}

.signature-trigger-box:hover { border-color: #1f6b45; background: #f2f9f5; }

.sig-placeholder-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    color: #5f7e70;
    font-size: 13.5px;
    font-weight: 600;
}

.sig-placeholder-content svg { width: 36px; height: 36px; color: #8ba897; }

.sig-preview-wrapper {
    position: relative;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.sig-preview-img {
    max-height: 140px;
    max-width: 100%;
    object-fit: contain;
}

.sig-edit-badge {
    position: absolute;
    bottom: -4px;
    right: 0;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    background: rgba(31, 107, 69, 0.08);
    border: 1px solid rgba(31, 107, 69, 0.15);
    color: #1f6b45;
    font-size: 11.5px;
    font-weight: 600;
    border-radius: 999px;
}

.sig-edit-badge svg { width: 12px; height: 12px; }

/* Actions */
.withdraw-actions {
    display: flex;
    gap: 12px;
    margin-top: 12px;
}

.btn-withdraw-cancel {
    flex: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 48px;
    border-radius: 12px;
    border: 1.5px solid #cfe0d6;
    background: #ffffff;
    color: #5f7e70;
    font-weight: 600;
    font-size: 14.5px;
    text-decoration: none;
    transition: all 0.2s ease;
}

.btn-withdraw-cancel:hover { background: #f4f8f5; color: #123524; }

.btn-withdraw-submit {
    flex: 2;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: 48px;
    min-height: auto;
    margin-top: 0;
    border: none;
    border-radius: 12px;
    background: linear-gradient(135deg, #2a8a5a 0%, #1f6b45 60%, #15543a 100%);
    color: #ffffff;
    font-weight: 700;
    font-size: 14.5px;
    cursor: pointer;
    box-shadow: 0 8px 20px rgba(31, 107, 69, 0.25);
    transition: all 0.2s ease;
}

.btn-withdraw-submit svg { width: 18px; height: 18px; }
.btn-withdraw-submit:hover { transform: translateY(-2px); box-shadow: 0 12px 26px rgba(31, 107, 69, 0.32); }
.btn-withdraw-submit:active { transform: translateY(0); }

/* Signature modal */
.sig-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(10, 30, 20, 0.55);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    display: none;
    align-items: flex-start;
    justify-content: center;
    padding: max(16px, env(safe-area-inset-top)) 16px max(16px, env(safe-area-inset-bottom));
    z-index: 100;
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.sig-modal-overlay.show { display: flex; }

.sig-modal-card {
    width: min(760px, 100%);
    max-height: calc(100dvh - 32px);
    max-height: calc(100svh - 32px);
    margin: auto;
    flex-shrink: 0;
    background: #fff;
    border-radius: 18px;
    overflow: hidden;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.3);
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.sig-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid #eef2f0;
    flex-shrink: 0;
}

.sig-modal-header h3 { margin: 0; font-size: 16px; color: #123524; }

.sig-modal-close {
    border: none;
    background: transparent;
    font-size: 26px;
    line-height: 1;
    color: var(--text-muted);
    cursor: pointer;
    width: auto;
    padding: 0 4px;
}

.sig-modal-body {
    padding: 18px 20px;
    overflow-y: auto;
    flex: 1 1 auto;
    min-height: 0;
    -webkit-overflow-scrolling: touch;
}

.sig-canvas-wrap {
    border: 1.5px solid var(--line);
    border-radius: 12px;
    overflow: hidden;
    background: #fff;
    background-image: linear-gradient(#eef5f0 1px, transparent 1px);
    background-size: 100% 34px;
    background-position: 0 100%;
}

.sig-canvas {
    display: block;
    width: 100%;
    height: 240px;
    cursor: crosshair;
    touch-action: none;
}

@media (min-width: 600px) {
    .sig-canvas {
        height: 360px;
    }
}

.sig-hint { text-align: center; font-size: 12px; color: var(--text-muted); margin-top: 10px; }

.sig-modal-footer {
    display: flex;
    gap: 10px;
    padding: 14px 20px max(18px, env(safe-area-inset-bottom));
    flex-shrink: 0;
}

.sig-btn {
    flex: 1;
    height: 48px;
    border-radius: 12px;
    font-weight: 700;
    font-size: 15px;
    cursor: pointer;
    border: none;
}

.sig-btn--clear { background: #f1f5f3; color: var(--text-muted); border: 1.5px solid var(--line); }
.sig-btn--clear:hover { background: #e8efea; }
.sig-btn--save { background: linear-gradient(135deg, #2a8a5a, #1f6b45); color: #fff; }

/* Photo viewer */
.photo-viewer {
    position: fixed;
    inset: 0;
    background: rgba(8, 20, 14, 0.88);
    display: none;
    align-items: center;
    justify-content: center;
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 60px 24px 24px;
    z-index: 110;
}

.photo-viewer.show { display: flex; }
.photo-viewer img { max-width: 100%; max-height: 86vh; object-fit: contain; border-radius: 10px; }

.photo-viewer__close {
    position: absolute;
    top: 18px;
    right: 20px;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    border: none;
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
    font-size: 24px;
    cursor: pointer;
}

/* Responsive */
@media (max-width: 900px) {
    .withdraw-grid { grid-template-columns: 1fr; }
    .withdraw-col-main, .withdraw-col-side { gap: 18px; }
    .form-grid-3 { grid-template-columns: 1fr; }
    .form-grid-2 { grid-template-columns: 1fr; margin-top: 0; }
    .form-group { margin-bottom: 12px; }
}

@media (max-width: 600px) {
    .items-list-header { display: none; }
    .items-list-row {
        grid-template-columns: 1fr;
        grid-template-areas: "name" "qty" "del";
        gap: 8px;
        border: 1px solid #e2ece6;
        border-radius: 12px;
        padding: 12px;
        margin-bottom: 8px;
        background: #fafdfb;
    }
    .items-list-row select:nth-child(1) { grid-area: name; }
    .items-list-row input:nth-child(2) { grid-area: qty; }
    .btn-row-delete { grid-area: del; width: 100%; }
    .withdraw-actions { flex-direction: column-reverse; }
    .btn-withdraw-cancel, .btn-withdraw-submit { width: 100%; }
}

/* ===================================================================
   Print Layout (A4)
   =================================================================== */
.print-body {
    margin: 0;
    background: #54665c;
    font-family: "Sarabun", "Segoe UI", Arial, sans-serif;
    padding: 24px 16px 60px;
}

.print-toolbar {
    max-width: 794px;
    margin: 0 auto 18px;
    display: flex;
    justify-content: flex-end;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}

.pt-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 44px;
    padding: 0 20px;
    border-radius: 11px;
    font-weight: 700;
    font-size: 14px;
    text-decoration: none;
    cursor: pointer;
    border: none;
    white-space: nowrap;
    flex-shrink: 0;
}

.pt-btn--ghost { background: rgba(255, 255, 255, 0.92); color: #1f6b45; }
.pt-btn--ghost:hover { background: #fff; }
.pt-btn--primary { background: linear-gradient(135deg, #2a8a5a, #1f6b45); color: #fff; box-shadow: 0 8px 20px rgba(0,0,0,0.25); }

.paper {
    width: 794px;
    max-width: 100%;
    min-height: 1123px;
    margin: 0 auto;
    background: #fff;
    color: #15241c;
    padding: 40px 44px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.3);
    box-sizing: border-box;
    position: relative;
}

.paper + .paper {
    margin-top: 40px;
}

@media screen {
    .print-body .paper {
        min-height: auto;
    }
}

.paper-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 20px;
    padding-bottom: 18px;
    border-bottom: 2.5px solid #1f6b45;
}

.paper-head__brand { display: flex; align-items: center; gap: 14px; }
.paper-logo { width: 64px; height: 64px; object-fit: contain; }
.paper-company { font-size: 15px; font-weight: 700; letter-spacing: 1px; color: #1f6b45; }
.paper-doctitle { font-size: 22px; font-weight: 700; color: #123524; margin-top: 2px; }

.paper-head__meta { text-align: right; }
.paper-billno {
    display: inline-block;
    font-size: 16px;
    font-weight: 700;
    color: #b42318;
    border: 1.5px solid #b42318;
    border-radius: 8px;
    padding: 4px 12px;
    margin-bottom: 8px;
}

.paper-meta-table { font-size: 13.5px; margin-left: auto; border-collapse: collapse; }
.paper-meta-table th { text-align: right; color: #5b6f64; font-weight: 600; padding: 1px 8px 1px 0; }
.paper-meta-table td { text-align: left; font-weight: 700; }

.paper-info {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0;
    margin: 18px 0;
    border: 1px solid #d3e2d9;
    border-radius: 10px;
    overflow: hidden;
}

.info-cell { padding: 10px 14px; border-right: 1px solid #d3e2d9; }
.info-cell:last-child { border-right: none; }
.info-label { display: block; font-size: 12px; color: #5b6f64; margin-bottom: 3px; }
.info-value { display: block; font-size: 15px; font-weight: 700; }

.paper-items {
    width: 100%;
    border-collapse: collapse;
    margin-top: 6px;
    font-size: 14px;
}

.paper-items th, .paper-items td {
    border: 1px solid #cdddd3;
    padding: 9px 12px;
}

.paper-items thead th {
    background: #1f6b45;
    color: #fff;
    font-weight: 600;
    font-size: 13.5px;
}

.paper-items .col-no { width: 56px; text-align: center; }
.paper-items .col-color { width: 130px; text-align: center; }
.paper-items .col-qty { width: 90px; text-align: center; }
.paper-items tbody td { height: 22px; }
.paper-items tbody .col-name { font-weight: 600; }
.empty-row td { color: transparent; }

.paper-items tfoot td {
    background: #f3f8f4;
    font-weight: 700;
    font-size: 14.5px;
}
.total-label { text-align: right; }
.total-value { text-align: center; color: #1f6b45; }

.paper-subtitle {
    font-size: 14px;
    font-weight: 700;
    color: #123524;
    margin: 22px 0 10px;
    padding-left: 10px;
    border-left: 4px solid #1f6b45;
}

.paper-photos__grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
}

.paper-photos__split {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
}

.paper-photos__group {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.paper-photos__group-title {
    font-size: 13px;
    font-weight: 700;
    color: #1f6b45;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 4px;
    text-align: center;
}

.paper-photos__group .paper-photos__grid {
    grid-template-columns: 1fr;
    width: 100%;
    max-width: 260px;
}

.paper-photo {
    aspect-ratio: 16 / 9;
    border: 1.5px solid #bcd9c7;
    border-radius: 10px;
    overflow: hidden;
    background: #f3f8f4;
    box-shadow: 0 2px 6px rgba(0,0,0,0.04);
}

.paper-photo img { width: 100%; height: 100%; object-fit: cover; display: block; }

.paper-signs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 50px;
    margin-top: 30px;
}

.sign-box { text-align: center; }
.sign-area { height: 80px; display: flex; align-items: flex-end; justify-content: center; }
.sign-img { max-height: 78px; max-width: 80%; object-fit: contain; }
.sign-line { border-bottom: 1.5px dotted #8a9b91; margin: 4px 20px 0; }
.sign-label { font-size: 13.5px; font-weight: 700; margin-top: 8px; color: #123524; }
.sign-name { font-size: 13px; color: #5b6f64; margin-top: 3px; }

.paper-foot {
    margin-top: 40px;
    padding-top: 12px;
    border-top: 1px dashed #cdddd3;
    font-size: 11.5px;
    color: #8a9b91;
    text-align: center;
}

/* Paper Tag (Original / Copy) */
.paper-tag {
    display: inline-block;
    font-size: 11px;
    font-weight: 700;
    padding: 2px 10px;
    border-radius: 4px;
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
}
.paper-tag--original {
    background: #eaf5f0;
    color: #1f6b45;
    border: 1px solid #bcd9c7;
}
.paper-tag--copy {
    background: #f1f5f3;
    color: #5b6f64;
    border: 1px solid #cfe0d6;
}

/* Watermark for Copy Page */
.paper--copy::before {
    content: "( สำเนา )";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) rotate(-30deg);
    font-size: 130px;
    font-weight: 700;
    color: rgba(31, 107, 69, 0.05); /* Very faint green */
    pointer-events: none;
    z-index: 0;
    white-space: nowrap;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
}

/* Ensure all content sections sit above the watermark */
.paper-head, .paper-info, .paper-items, .paper-spacer, .paper-signs, .paper-foot {
    position: relative;
    z-index: 1;
}

/* Segmented Control for Payout Type */
.payout-type-container {
    margin-bottom: 24px;
    padding-bottom: 20px;
    border-bottom: 1px dashed #e2ece6;
}
.payout-label {
    display: block;
    margin-bottom: 8px;
    font-weight: 700;
    color: #123524;
    font-size: 14px;
}
.payout-selector {
    display: grid;
    grid-template-columns: 1fr 1fr;
    background: #f1f5f3;
    padding: 4px;
    border-radius: 12px;
    gap: 4px;
}
.payout-selector.three-cols {
    grid-template-columns: repeat(3, 1fr);
}
@media (max-width: 600px) {
    .payout-selector.three-cols {
        grid-template-columns: 1fr;
    }
}
.payout-option {
    position: relative;
    cursor: pointer;
}
.payout-option input[type="radio"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}
.payout-option-card {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 16px;
    border-radius: 10px;
    background: #ffffff;
    border: 1px solid #dcdfdc;
    color: #5b6f64;
    font-size: 14px;
    font-weight: 700;
    transition: all 0.2s ease;
}
.payout-option-card:hover {
    background: #fafdfc;
    border-color: #bcd9c7;
}
.payout-option input:checked + .payout-option-card {
    border-color: transparent;
}
.payout-option input[value="vehicle"]:checked + .payout-option-card,
.payout-option input[value="cp"]:checked + .payout-option-card {
    background: linear-gradient(135deg, #facc15 0%, #eab308 100%);
    color: #451a03;
    box-shadow: 0 4px 14px rgba(234, 179, 8, 0.35);
}
.payout-option input[value="bfg"]:checked + .payout-option-card,
.payout-option input[value="store"]:checked + .payout-option-card {
    background: linear-gradient(135deg, #2a8a5a 0%, #1f6b45 100%);
    color: #ffffff;
    box-shadow: 0 4px 14px rgba(31, 107, 69, 0.35);
}
.theme-damaged .payout-option input[value="store"]:checked + .payout-option-card,
.theme-damaged .payout-option input[value="bfg"]:checked + .payout-option-card,
.theme-damaged .payout-option input[value="cp"]:checked + .payout-option-card {
    background: linear-gradient(135deg, #fca5a5 0%, #dc2626 100%);
    color: #ffffff;
    box-shadow: 0 4px 14px rgba(220, 38, 38, 0.35);
}
.payout-option-card svg {
    width: 18px;
    height: 18px;
    color: currentColor;
    flex-shrink: 0;
}

/* Stamp look for BFG payout signature */
.bfg-stamp-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border: 3px double #1f6b45;
    border-radius: 50%;
    width: 90px;
    height: 90px;
    margin: 0 auto;
    padding: 4px;
    background: #fff;
    color: #1f6b45;
    transform: rotate(-8deg);
    box-shadow: 0 0 0 3px rgba(31,107,69,0.05);
    opacity: 0.85;
}
.bfg-stamp-img {
    width: 32px !important;
    height: 32px !important;
    object-fit: contain;
    margin-bottom: 2px;
}
.bfg-stamp-text {
    font-size: 8.5px;
    font-weight: 700;
    text-align: center;
    line-height: 1.1;
    text-transform: uppercase;
}

@media print {
    @page { size: A4; margin: 8mm; }
    .print-body { background: #fff; padding: 0; }
    .no-print { display: none !important; }
    .paper {
        width: 100%;
        min-height: auto;
        margin: 0;
        padding: 0;
        box-shadow: none;
        page-break-after: always;
        break-after: page;
    }
    .paper:last-child {
        page-break-after: avoid;
        break-after: avoid;
    }
    .paper-photo, .paper-items th, .paper-items thead th, .paper-items tfoot td, .paper-tag {
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
    .paper-foot {
        margin-top: 20px;
    }
}

/* Stock Modal Styles */
.stock-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(10, 30, 20, 0.6);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    display: none;
    align-items: flex-start;
    justify-content: center;
    padding: max(16px, env(safe-area-inset-top)) 16px max(16px, env(safe-area-inset-bottom));
    z-index: 1000;
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-y;
}

.stock-modal-overlay.show {
    display: flex;
    align-items: flex-start;
    justify-content: center;
}

.stock-modal-overlay.show > .stock-modal-card {
    margin-left: auto;
    margin-right: auto;
    flex-shrink: 0;
}

.stock-modal-card {
    width: min(500px, calc(100vw - 32px));
    max-width: calc(100vw - 32px);
    max-height: calc(100dvh - 32px);
    max-height: calc(100svh - 32px);
    margin: 16px auto;
    flex-shrink: 0;
    background: #fff;
    border-radius: 20px;
    overflow: hidden;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.25);
    animation: modalEnter 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    display: flex;
    flex-direction: column;
    min-height: 0;
    box-sizing: border-box;
}

@keyframes modalEnter {
    from { transform: scale(0.9) translateY(20px); opacity: 0; }
    to { transform: scale(1) translateY(0); opacity: 1; }
}

.stock-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 24px;
    border-bottom: 1px solid #eef2f0;
    background: #fafdfb;
    flex-shrink: 0;
}

.stock-modal-header h3 {
    margin: 0;
    font-size: 17px;
    color: #123524;
    font-weight: 700;
}

.stock-modal-close {
    border: none;
    background: transparent;
    font-size: 28px;
    line-height: 1;
    color: #8ba897;
    cursor: pointer;
    padding: 0;
    transition: color 0.2s ease;
}
.stock-modal-close:hover {
    color: #ef4444;
}

.stock-modal-body {
    padding: 24px;
    overflow-y: auto;
    overflow-x: hidden;
    flex: 1 1 auto;
    -webkit-overflow-scrolling: touch;
}

.stock-modal-body .confirm-media-frame {
    position: relative;
    width: 100%;
    height: 200px;
    max-height: 200px;
    min-height: 160px;
    flex-shrink: 0;
    border-radius: 10px;
    overflow: hidden;
    border: 1px solid #ddd;
    background: #f3f6f4;
}

.stock-modal-body .confirm-media-frame img {
    position: absolute;
    inset: 0;
    width: 100% !important;
    height: 100% !important;
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    display: block;
}

.stock-modal-body .confirm-sig-frame {
    position: relative;
    height: 72px;
    max-height: 72px;
    flex: 1;
    min-width: 0;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #fff;
    border: 1px solid #eef2f0;
    border-radius: 6px;
}

.stock-modal-body .confirm-sig-frame img {
    max-height: 68px;
    max-width: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
    display: block;
    background: #fff;
}

.confirm-modal-body {
    padding: 20px;
}

.stock-modal-card--confirm {
    width: min(580px, calc(100vw - 32px));
    max-width: calc(100vw - 32px);
    max-height: calc(100svh - 32px);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.stock-modal-card--confirm .stock-modal-header {
    flex-shrink: 0;
}

.stock-modal-card--confirm .stock-modal-body,
.stock-modal-card--confirm .confirm-modal-body {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    padding: 20px;
    max-height: none;
    height: auto;
}

.stock-modal-card--confirm .stock-modal-footer {
    flex-shrink: 0;
    flex-direction: row;
    gap: 10px;
    padding: 16px 20px 20px;
}

.stock-modal-card--confirm .stock-modal-footer .stock-btn-secondary,
.stock-modal-card--confirm .stock-modal-footer .stock-btn-primary {
    flex: 1 1 0;
    min-width: 0;
    width: auto;
    min-height: 46px;
}

.stock-modal-card--detail {
    width: min(640px, 100%);
}

.stock-modal-body .confirm-items-scroll {
    max-height: 200px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.stock-modal-body .confirm-details-scroll {
    max-height: 168px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.success-modal-card {
    width: min(420px, 100%);
    text-align: center;
}

.stock-modal-card.success-modal-card .stock-modal-body,
.success-modal-body {
    display: block;
    padding: 32px 24px 28px;
    overflow-y: auto;
    flex: none;
    min-height: auto;
    height: auto;
    max-height: none;
}

.success-modal-icon {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    margin: 0 auto 18px;
    flex-shrink: 0;
}

.success-modal-icon svg {
    width: 40px;
    height: 40px;
    display: block;
}

.success-modal-icon--receive {
    background: linear-gradient(135deg, #e0f2fe, #bae6fd);
    color: #0369a1;
}

.success-modal-icon--cp {
    background: linear-gradient(135deg, #ffedd5, #fed7aa);
    color: #c2410c;
}

.success-modal-title {
    margin: 0 0 8px;
    font-size: 18px;
    font-weight: 700;
}

.success-modal-title--receive {
    color: #075985;
}

.success-modal-title--cp {
    color: #9a3412;
}

.success-modal-desc {
    color: #5b6f64;
    font-size: 14px;
    line-height: 1.6;
    margin: 0 0 20px;
}

.stock-modal-body.text-center {
    text-align: center;
}

.confirm-intro {
    font-size: 14px;
    color: #5b6f64;
    margin-bottom: 16px;
}

.confirm-details-box {
    background: #f4f8f5;
    border: 1.5px solid #e2ece6;
    border-radius: 14px;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 20px;
}

.confirm-detail-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 14px;
    border-bottom: 1px dashed #e2ece6;
    padding-bottom: 8px;
}
.confirm-detail-row:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.detail-label {
    font-weight: 600;
    color: #5b6f64;
}

.detail-value {
    font-weight: 700;
    color: #123524;
    text-align: right;
}

.detail-value.highlight {
    color: #1f6b45;
    font-size: 16px;
}

.confirm-question {
    font-size: 14.5px;
    font-weight: 700;
    color: #123524;
    text-align: center;
    margin-top: 10px;
}

.stock-modal-footer {
    display: flex;
    gap: 12px;
    padding: 16px 20px 20px;
    padding-bottom: max(20px, env(safe-area-inset-bottom));
    padding-left: max(20px, env(safe-area-inset-left));
    padding-right: max(20px, env(safe-area-inset-right));
    border-top: 1px solid #eef2f0;
    background: #fafdfb;
    flex-shrink: 0;
    position: relative;
    z-index: 2;
    box-shadow: 0 -6px 16px rgba(18, 53, 36, 0.06);
    box-sizing: border-box;
    width: 100%;
    min-width: 0;
}

.stock-modal-footer .stock-btn-primary {
    box-shadow: none;
}

.stock-modal-footer .stock-btn-primary:hover {
    box-shadow: none;
    transform: none;
    filter: brightness(0.96);
}

@media (max-width: 768px) {
    html {
        touch-action: manipulation;
        -webkit-text-size-adjust: 100%;
    }

    html.modal-open,
    html.modal-open body {
        touch-action: manipulation;
    }

    .input-wrapper input,
    .input-wrapper select,
    .items-list-row input,
    .items-list-row select,
    textarea {
        font-size: 16px !important;
    }

    .stock-modal-card {
        animation: modalEnterMobile 0.22s ease-out;
    }

    @keyframes modalEnterMobile {
        from {
            opacity: 0;
            transform: translateY(10px);
        }
        to {
            opacity: 1;
            transform: none;
        }
    }

    .stock-modal-overlay {
        padding: 0;
    }

    .stock-modal-overlay.show {
        display: flex;
        flex-direction: column;
        overflow: hidden;
        height: 100dvh;
        height: 100svh;
    }

    .stock-modal-overlay.show > .stock-modal-card {
        width: 100%;
        max-width: 100vw;
        height: 100%;
        max-height: 100%;
        min-height: 0;
        margin: 0;
        border-radius: 0;
        flex: 1;
        display: flex;
        flex-direction: column;
        box-sizing: border-box;
    }

    .stock-modal-card--confirm .stock-modal-body,
    .stock-modal-card--confirm .confirm-modal-body {
        flex: 1 1 0;
        min-height: 0;
        max-height: none;
        height: auto;
        padding: 16px 16px 8px;
    }

    .stock-modal-header {
        padding: 16px 18px;
        flex-shrink: 0;
    }

    .stock-modal-header h3 {
        font-size: 17px;
    }

    .stock-modal-body .confirm-media-frame {
        height: min(240px, 40vh);
        max-height: min(240px, 40vh);
        min-height: 180px;
    }

    .stock-modal-body .confirm-sig-frame {
        height: 80px;
        max-height: 80px;
    }

    .stock-modal-body .confirm-sig-frame img {
        max-height: 76px;
    }

    .stock-modal-body .confirm-items-scroll {
        max-height: min(320px, 40vh);
    }

    .stock-modal-body .confirm-details-scroll {
        max-height: min(220px, 30vh);
    }

    .stock-modal-card--confirm .stock-modal-footer {
        flex-direction: column;
        gap: 10px;
        padding: 12px 16px max(16px, env(safe-area-inset-bottom));
        padding-left: max(16px, env(safe-area-inset-left));
        padding-right: max(16px, env(safe-area-inset-right));
        box-shadow: 0 -8px 20px rgba(18, 53, 36, 0.08);
    }

    .stock-modal-card--confirm .stock-modal-footer .stock-btn-secondary,
    .stock-modal-card--confirm .stock-modal-footer .stock-btn-primary {
        width: 100%;
        flex: none;
        min-height: 52px;
        font-size: 16px;
    }

    .stock-modal-footer {
        flex-shrink: 0;
        flex-direction: column;
        gap: 10px;
        padding: 12px 16px max(16px, env(safe-area-inset-bottom));
        padding-left: max(16px, env(safe-area-inset-left));
        padding-right: max(16px, env(safe-area-inset-right));
        box-shadow: 0 -8px 20px rgba(18, 53, 36, 0.08);
    }

    .stock-btn-secondary,
    .stock-btn-primary,
    .success-modal-actions .stock-modal-btn {
        width: 100%;
        flex: none;
        min-width: 0;
        min-height: 52px;
        font-size: 16px;
        box-sizing: border-box;
    }

    .stock-modal-card.success-modal-card .stock-modal-body,
    .stock-modal-card.success-modal-card .success-modal-body {
        flex: 1;
        display: flex;
        flex-direction: column;
        justify-content: center;
        padding: 28px 20px max(24px, env(safe-area-inset-bottom));
    }

    .success-modal-icon {
        width: 84px;
        height: 84px;
        margin-bottom: 20px;
    }

    .success-modal-icon svg {
        width: 46px;
        height: 46px;
    }

    .success-modal-title {
        font-size: 22px;
        margin-bottom: 12px;
    }

    .success-modal-desc {
        font-size: 15px;
        line-height: 1.7;
        margin-bottom: 28px;
    }

    .alert-modal-card {
        width: 100%;
        max-width: 100%;
        height: 100%;
        max-height: 100%;
        margin: 0;
        border-radius: 0;
        display: flex;
        flex-direction: column;
    }

    .alert-modal-body {
        flex: 1;
        overflow-y: auto;
    }
}

@media (max-width: 480px) {
    .stock-modal-header {
        padding: 14px 16px;
    }

    .stock-modal-header h3 {
        font-size: 15px;
        padding-right: 8px;
    }

    .stock-modal-body {
        padding: 16px;
    }

    .alert-modal-body {
        padding: 24px 16px 20px !important;
    }

    .stock-modal-footer {
        flex-direction: column;
        padding: 12px 16px max(16px, env(safe-area-inset-bottom));
    }

    .stock-btn-secondary,
    .stock-btn-primary {
        width: 100%;
        min-height: 48px;
    }

    #cwPhotosSection,
    .confirm-photos-grid {
        grid-template-columns: 1fr !important;
    }
}

/* Alert modal (validation errors) */
.alert-modal-card {
    width: min(420px, 100%);
    text-align: center;
    max-height: calc(100dvh - 32px);
    max-height: calc(100svh - 32px);
    overflow: hidden;
}

.alert-modal-body {
    padding: 30px 24px 24px !important;
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.alert-modal-icon {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: #fef2f2;
    color: #ef4444;
    display: grid;
    place-items: center;
    margin: 0 auto 16px;
    flex-shrink: 0;
}

.alert-modal-icon svg {
    width: 28px;
    height: 28px;
}

.alert-modal-title {
    margin: 0 0 8px;
    font-size: 18px;
    font-weight: 700;
    color: var(--dash-green-dark, #123524);
    flex-shrink: 0;
}

.alert-modal-desc {
    color: #5b6f64;
    font-size: 14px;
    text-align: left;
    line-height: 1.5;
    background: #fafafa;
    padding: 12px;
    border-radius: 8px;
    border: 1px solid #eee;
    max-height: min(240px, 42vh);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    flex: 1 1 auto;
    min-height: 0;
}

.stock-modal-btn--danger {
    background: #ef4444;
    color: #fff;
    margin-top: 16px;
    flex-shrink: 0;
}

.stock-modal-btn--danger:hover {
    background: #dc2626;
}

.detail-modal-body {
    padding: 24px;
}

.confirm-photos-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 16px;
}

.success-modal-icon--stock {
    background: linear-gradient(135deg, #d1fae5, #a7f3d0);
    color: #047857;
}

.success-modal-title--stock {
    color: #064e3b;
}

.stock-modal-btn--outline-withdraw {
    color: #14532d;
    border-color: #86efac;
    background: linear-gradient(180deg, #f0fdf4 0%, #ffffff 100%);
    box-shadow: 0 2px 8px rgba(31, 107, 69, 0.1);
}

.stock-modal-btn--outline-withdraw:hover {
    color: #123524;
    border-color: #4ade80;
    background: #dcfce7;
    transform: translateY(-1px);
    box-shadow: 0 4px 14px rgba(31, 107, 69, 0.18);
}

.stock-modal-btn--primary-withdraw {
    background: linear-gradient(135deg, #2a8a5a 0%, #1f6b45 60%, #15543a 100%);
    color: #fff;
    box-shadow: 0 4px 14px rgba(31, 107, 69, 0.28);
}

.stock-modal-btn--primary-withdraw:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 18px rgba(31, 107, 69, 0.34);
}

.stock-btn-secondary {
    flex: 1 1 0;
    min-width: 0;
    height: 46px;
    border: 1.5px solid #cfe0d6;
    background: #fff;
    color: #5b6f64;
    font-family: inherit;
    font-size: 14.5px;
    font-weight: 600;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    box-sizing: border-box;
    padding: 0 12px;
}
.stock-btn-secondary:hover {
    background: #f4f8f5;
    color: #123524;
    border-color: #bcd9c7;
}

.stock-btn-primary {
    flex: 1 1 0;
    min-width: 0;
    height: 46px;
    border: none;
    background: #1f6b45;
    color: #fff;
    font-family: inherit;
    font-size: 14.5px;
    font-weight: 600;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 4px 12px rgba(31, 107, 69, 0.15);
    box-sizing: border-box;
    padding: 0 12px;
}
.stock-btn-primary:hover {
    background: #185537;
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(31, 107, 69, 0.25);
}

/* Success Card Specific */
.success-card {
    width: min(420px, 100%);
    border-top: 5px solid #1f6b45;
}

.success-checkmark-icon {
    width: 64px;
    height: 64px;
    background: #eaf5f0;
    color: #1f6b45;
    border-radius: 50%;
    display: grid;
    place-items: center;
    margin: 0 auto 16px;
}
.success-checkmark-icon svg {
    width: 36px;
    height: 36px;
}

.stock-modal-title {
    font-size: 20px;
    font-weight: 700;
    color: #123524;
    margin: 0 0 8px;
}

.stock-modal-desc {
    font-size: 14.5px;
    color: #5b6f64;
    margin: 0 0 24px;
    line-height: 1.5;
}

.stock-modal-btn {
    width: 100%;
    height: 46px;
    border: none;
    border-radius: 12px;
    font-family: inherit;
    font-size: 14.5px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    box-sizing: border-box;
}

.stock-modal-btn svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

.success-modal-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 100%;
}

.success-modal-actions .stock-modal-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.success-modal-actions .stock-modal-btn svg {
    width: 20px;
    height: 20px;
    max-width: 20px;
    max-height: 20px;
    flex: 0 0 20px;
    display: block;
}

.stock-modal-btn--outline {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    text-decoration: none;
    border: 1.5px solid;
    background: #fff;
}

.stock-modal-btn--outline-cp {
    color: #9a3412;
    border-color: #fdba74;
    background: linear-gradient(180deg, #fff7ed 0%, #ffffff 100%);
    box-shadow: 0 2px 8px rgba(234, 88, 12, 0.1);
}

.stock-modal-btn--outline-cp:hover {
    color: #7c2d12;
    border-color: #fb923c;
    background: #ffedd5;
    transform: translateY(-1px);
    box-shadow: 0 4px 14px rgba(234, 88, 12, 0.18);
}

.stock-modal-btn--outline-receive {
    color: #0369a1;
    border-color: #7dd3fc;
    background: linear-gradient(180deg, #f0f9ff 0%, #ffffff 100%);
    box-shadow: 0 2px 8px rgba(2, 132, 199, 0.1);
}

.stock-modal-btn--outline-receive:hover {
    color: #075985;
    border-color: #38bdf8;
    background: #e0f2fe;
    transform: translateY(-1px);
    box-shadow: 0 4px 14px rgba(2, 132, 199, 0.18);
}

.stock-modal-btn--primary-cp {
    background: linear-gradient(135deg, #ea580c 0%, #b45309 60%, #9a3412 100%);
    color: #fff;
    box-shadow: 0 4px 14px rgba(234, 88, 12, 0.28);
}

.stock-modal-btn--primary-cp:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 18px rgba(234, 88, 12, 0.34);
}

.stock-modal-btn--primary-receive {
    background: linear-gradient(135deg, #0284c7 0%, #0369a1 60%, #075985 100%);
    color: #fff;
    box-shadow: 0 4px 14px rgba(2, 132, 199, 0.28);
}

.stock-modal-btn--primary-receive:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 18px rgba(2, 132, 199, 0.34);
}

.stock-modal-btn--primary {
    background: #1f6b45;
    color: #fff;
    box-shadow: 0 4px 12px rgba(31, 107, 69, 0.15);
}
.stock-modal-btn--primary:hover {
    background: #185537;
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(31, 107, 69, 0.25);
}

@media screen and (max-width: 840px) {
    .print-body {
        padding: 12px 12px 48px;
        overflow-y: auto;
        min-height: 100vh;
        min-height: 100dvh;
        -webkit-overflow-scrolling: touch;
    }

    .print-toolbar {
        position: sticky;
        top: 0;
        z-index: 20;
        margin: -12px -12px 14px;
        padding: 12px;
        background: rgba(84, 102, 92, 0.96);
        backdrop-filter: blur(8px);
        -webkit-backdrop-filter: blur(8px);
        justify-content: flex-start;
    }

    .paper {
        min-height: auto;
        padding: 20px 16px;
    }

    .paper + .paper {
        margin-top: 24px;
    }

    .paper-doctitle {
        font-size: 18px;
    }

    .paper-info {
        grid-template-columns: 1fr;
    }

    .paper-photos__split {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    .paper-photos__group .paper-photos__grid {
        grid-template-columns: 1fr !important;
        max-width: min(240px, 100%);
    }

    .paper-photo {
        aspect-ratio: 4 / 3;
        max-height: 180px;
    }

    .paper-photo img {
        width: 100%;
        height: 100%;
        max-height: 180px;
        object-fit: contain;
        background: #eef5f0;
    }

    .paper-signs {
        grid-template-columns: 1fr;
        gap: 24px;
    }
}
