/* ===== Modern mobile app design system (thai_web) ===== */

:root {
    --neu-bg: #F5F8FA;
    --neu-bg-deep: #E8F0F3;
    --neu-surface: #FFFFFF;
    --neu-surface-raised: #FBFEFF;
    --neu-line: #E1E8EC;
    --neu-line-strong: #D0DCE2;
    --neu-text: #10212A;
    --neu-text-muted: #61737E;
    --neu-text-disabled: #9AABB4;

    --neu-accent: #0E9F8D;
    --neu-accent-hover: #087D72;
    --neu-accent-soft: rgba(14, 159, 141, 0.12);
    --neu-accent-softer: rgba(14, 159, 141, 0.07);
    --neu-accent-shadow: rgba(14, 159, 141, 0.26);
    --neu-accent-shadow-strong: rgba(14, 159, 141, 0.34);
    --neu-accent-border: rgba(14, 159, 141, 0.24);
    --neu-gold: #C8912D;
    --neu-success: #159947;
    --neu-error: #D9474D;
    --neu-warning-soft: rgba(200, 145, 45, 0.13);
    --neu-error-soft: rgba(217, 71, 77, 0.12);
    --neu-success-soft: rgba(21, 153, 71, 0.12);

    --neu-shadow-light: rgba(255, 255, 255, 0.85);
    --neu-shadow-dark: rgba(31, 46, 53, 0.09);
    --neu-shadow-light-strong: rgba(255, 255, 255, 0.95);
    --neu-shadow-dark-strong: rgba(31, 46, 53, 0.15);

    --shadow-card: 0 14px 34px rgba(31, 46, 53, 0.08);
    --shadow-card-sm: 0 8px 22px rgba(31, 46, 53, 0.07);
    --shadow-floating: 0 18px 42px rgba(20, 33, 40, 0.18);

    --r-sm: 12px;
    --r-md: 16px;
    --r-lg: 24px;
    --r-xl: 30px;
    --r-pill: 999px;

    --topbar-h: 62px;
    --bottom-nav-h: 76px;
    --bottom-action-h: 82px;
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    padding: 0;
    min-height: 100%;
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
    background:
        linear-gradient(180deg, #EEF7F6 0%, var(--neu-bg) 36%, #F9FBFC 100%);
    color: var(--neu-text);
    font-family: 'Noto Sans Thai', 'Inter', sans-serif;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

body {
    min-height: 100vh;
    padding-top: var(--topbar-h);
}

body.has-bottom-nav {
    padding-bottom: calc(var(--bottom-nav-h) + env(safe-area-inset-bottom));
}

a {
    color: inherit;
    text-decoration: none;
}

button,
input,
textarea,
select {
    font-family: inherit;
}

button,
a {
    -webkit-tap-highlight-color: transparent;
}

img {
    max-width: 100%;
}

/* ----- App shell ----- */
.neu-container {
    width: 100%;
    max-width: 520px;
    min-height: 100vh;
    margin: 0 auto;
    position: relative;
    overflow-x: clip;
}

.neu-page {
    padding: 18px 16px calc(104px + env(safe-area-inset-bottom));
}

body.has-bottom-nav .neu-page {
    padding-bottom: calc(132px + env(safe-area-inset-bottom));
}

.neu-stack > * + * {
    margin-top: 16px;
}

.app-section-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin: 4px 2px 12px;
}

.app-section-title h2,
.app-section-title h3 {
    margin: 0;
    color: var(--neu-text);
    font-size: 16px;
    line-height: 1.25;
    font-weight: 800;
}

.app-eyebrow {
    margin: 0;
    color: var(--neu-text-muted);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0;
}

/* ----- Surface utilities ----- */
.neu-card,
.neu-card-lg,
.neu-card-sm,
.neu-pressed,
.neu-pressed-deep {
    background: var(--neu-surface);
    border: 1px solid var(--neu-line);
    color: var(--neu-text);
}

.neu-card {
    border-radius: var(--r-lg);
    box-shadow: var(--shadow-card-sm);
}

.neu-card-lg {
    border-radius: var(--r-xl);
    box-shadow: var(--shadow-card);
}

.neu-card-sm {
    border-radius: var(--r-md);
    box-shadow: var(--shadow-card-sm);
}

.neu-pressed,
.neu-pressed-deep {
    border-radius: var(--r-md);
    background: #F7FAFB;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.72);
}

.app-hero-card {
    position: relative;
    overflow: hidden;
    padding: 22px;
    border-radius: var(--r-xl);
    color: #fff;
    background:
        linear-gradient(135deg, #0E9F8D 0%, #087D72 54%, #14536A 100%);
    box-shadow: 0 18px 44px rgba(8, 125, 114, 0.26);
}

.app-hero-card::after {
    content: "";
    position: absolute;
    inset: auto -42px -72px auto;
    width: 180px;
    height: 180px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.13);
}

.app-hero-card > * {
    position: relative;
    z-index: 1;
}

.app-glass-card {
    background: rgba(255, 255, 255, 0.78);
    border: 1px solid rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(16px);
    box-shadow: var(--shadow-card-sm);
}

.app-chip {
    min-height: 30px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 6px 11px;
    border-radius: var(--r-pill);
    background: var(--neu-accent-soft);
    color: var(--neu-accent);
    border: 1px solid var(--neu-accent-border);
    font-size: 12px;
    font-weight: 800;
    white-space: nowrap;
}

.app-muted-panel {
    padding: 14px;
    border-radius: var(--r-lg);
    background: #F7FAFB;
    border: 1px solid var(--neu-line);
}

/* ----- Buttons ----- */
.neu-btn,
.neu-btn-primary,
.neu-btn-icon {
    min-height: 44px;
    border: 0;
    cursor: pointer;
    transition:
        transform 0.18s ease,
        box-shadow 0.18s ease,
        background 0.18s ease,
        border-color 0.18s ease;
}

.neu-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 18px;
    border-radius: var(--r-md);
    background: var(--neu-surface);
    border: 1px solid var(--neu-line);
    color: var(--neu-text);
    font-weight: 800;
    box-shadow: var(--shadow-card-sm);
}

.neu-btn:hover,
.neu-btn-primary:hover,
.neu-btn-icon:hover {
    transform: translateY(-1px);
}

.neu-btn:active,
.neu-btn.is-active,
.neu-btn-primary:active,
.neu-btn-icon:active {
    transform: translateY(0);
}

.neu-btn-primary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 9px;
    width: 100%;
    min-height: 48px;
    padding: 14px 22px;
    border-radius: var(--r-md);
    background: linear-gradient(135deg, var(--neu-accent) 0%, var(--neu-accent-hover) 100%);
    color: #fff;
    font-weight: 900;
    box-shadow: 0 14px 24px var(--neu-accent-shadow);
}

.neu-btn-primary:disabled {
    opacity: 0.55;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.neu-btn-icon {
    width: 44px;
    height: 44px;
    flex: none;
    border-radius: 15px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--neu-surface);
    border: 1px solid var(--neu-line);
    color: var(--neu-text-muted);
    box-shadow: var(--shadow-card-sm);
}

/* ----- Pills ----- */
.neu-pill {
    min-height: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding: 7px 12px;
    border-radius: var(--r-pill);
    background: var(--neu-surface);
    border: 1px solid var(--neu-line);
    color: var(--neu-text);
    font-weight: 800;
    font-size: 12px;
    box-shadow: none;
}

.neu-pill-accent {
    background: var(--neu-accent);
    border-color: var(--neu-accent);
    color: #fff;
}

/* ----- Inputs ----- */
.neu-input {
    width: 100%;
    min-height: 48px;
    padding: 13px 16px;
    border: 1px solid var(--neu-line);
    outline: none;
    background: var(--neu-surface);
    border-radius: var(--r-md);
    color: var(--neu-text);
    font-size: 16px;
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.72);
}

.neu-input::placeholder {
    color: var(--neu-text-disabled);
}

.neu-input:focus {
    border-color: var(--neu-accent-border);
    box-shadow: 0 0 0 4px var(--neu-accent-soft);
}

/* ----- Lists and grids ----- */
.neu-list-item {
    min-height: 58px;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    border-radius: var(--r-lg);
    background: var(--neu-surface);
    border: 1px solid var(--neu-line);
    box-shadow: var(--shadow-card-sm);
    transition: transform 0.18s ease, border-color 0.18s ease;
}

.neu-list-item:hover {
    transform: translateY(-1px);
    border-color: var(--neu-accent-border);
}

.neu-list-item .ico,
.app-icon-tile {
    width: 42px;
    height: 42px;
    flex: none;
    border-radius: 15px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--neu-accent-soft);
    color: var(--neu-accent);
    border: 1px solid var(--neu-accent-border);
    box-shadow: none;
}

.neu-list-item .label {
    flex: 1;
    min-width: 0;
    color: var(--neu-text);
    font-size: 14px;
    font-weight: 800;
}

.neu-list-item .chev {
    color: var(--neu-text-disabled);
    font-size: 12px;
}

.app-stat-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}

.app-stat-card {
    padding: 13px;
    border-radius: var(--r-lg);
    background: var(--neu-surface);
    border: 1px solid var(--neu-line);
    box-shadow: var(--shadow-card-sm);
}

.app-stat-card p {
    margin: 0;
}

.app-action-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}

.app-action-card {
    min-height: 76px;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 13px;
    border-radius: var(--r-lg);
    background: var(--neu-surface);
    border: 1px solid var(--neu-line);
    box-shadow: var(--shadow-card-sm);
}

/* ----- Topbar ----- */
.neu-topbar {
    position: fixed;
    top: 0;
    left: 50%;
    width: 100%;
    max-width: 520px;
    height: var(--topbar-h);
    padding: 10px 16px 8px;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    background: rgba(245, 248, 250, 0.82);
    border-bottom: 1px solid rgba(225, 232, 236, 0.76);
    backdrop-filter: blur(18px);
    z-index: 50;
}

.neu-topbar .title {
    flex: 1;
    min-width: 0;
    text-align: left;
    font-size: 17px;
    font-weight: 900;
    color: var(--neu-text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ----- Drawer ----- */
.neu-drawer-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(16, 33, 42, 0.36);
    backdrop-filter: blur(5px);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.22s ease, visibility 0.22s ease;
    z-index: 80;
}

.neu-drawer-backdrop.is-open {
    opacity: 1;
    visibility: visible;
}

.neu-drawer {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 50%;
    width: min(88vw, 360px);
    max-width: 360px;
    background: var(--neu-bg);
    transform: translateX(calc(-50% - 520px));
    transition: transform 0.28s ease;
    z-index: 81;
    box-shadow: var(--shadow-floating);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.neu-drawer.is-open {
    transform: translateX(calc(-50% - 80px));
}

@media (max-width: 520px) {
    .neu-drawer {
        left: 0;
        transform: translateX(-100%);
    }

    .neu-drawer.is-open {
        transform: translateX(0);
    }
}

/* ----- Segmented control ----- */
.neu-segmented {
    display: flex;
    gap: 6px;
    padding: 5px;
    border-radius: var(--r-pill);
    background: #EAF1F4;
    border: 1px solid var(--neu-line);
    overflow-x: auto;
}

.neu-segmented::-webkit-scrollbar {
    display: none;
}

.neu-segmented a {
    flex: 1 0 auto;
    min-height: 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px 13px;
    border-radius: var(--r-pill);
    color: var(--neu-text-muted);
    font-size: 13px;
    font-weight: 900;
    white-space: nowrap;
    transition: background 0.18s ease, color 0.18s ease, box-shadow 0.18s ease;
}

.neu-segmented a.is-active {
    background: var(--neu-surface);
    color: var(--neu-accent);
    box-shadow: 0 6px 14px rgba(31, 46, 53, 0.08);
}

/* ----- FAB and bottom bars ----- */
.neu-fab {
    position: fixed;
    right: max(18px, calc((100vw - 520px) / 2 + 18px));
    bottom: calc(var(--bottom-nav-h) + 18px + env(safe-area-inset-bottom));
    width: 54px;
    height: 54px;
    border-radius: 18px;
    background: #10212A;
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.1);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 21px;
    z-index: 45;
    box-shadow: var(--shadow-floating);
    transition: transform 0.18s ease;
}

.neu-fab:hover {
    transform: translateY(-2px);
}

.neu-fab .badge {
    position: absolute;
    top: -5px;
    right: -5px;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    border-radius: var(--r-pill);
    background: var(--neu-error);
    color: #fff;
    font-size: 11px;
    font-weight: 900;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.neu-bottom-action {
    position: fixed;
    left: 50%;
    bottom: 0;
    width: 100%;
    max-width: 520px;
    padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
    transform: translateX(-50%);
    background: linear-gradient(to top, rgba(245, 248, 250, 0.98) 72%, rgba(245, 248, 250, 0));
    z-index: 46;
}

body.has-bottom-nav .neu-bottom-action {
    bottom: calc(var(--bottom-nav-h) + env(safe-area-inset-bottom));
}

.app-bottom-nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    padding: 8px max(10px, env(safe-area-inset-left)) calc(8px + env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-right));
    display: grid;
    grid-template-columns: repeat(var(--bottom-nav-count, 4), minmax(0, 1fr));
    gap: 4px;
    background: rgba(255, 255, 255, 0.92);
    border-top: 1px solid var(--neu-line);
    backdrop-filter: blur(18px);
    z-index: 44;
    box-shadow: 0 -14px 30px rgba(31, 46, 53, 0.08);
}

.app-bottom-nav a {
    min-height: 56px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    border-radius: 18px;
    color: var(--neu-text-muted);
    font-size: 10px;
    font-weight: 900;
    position: relative;
}

.app-bottom-nav a i {
    font-size: 17px;
}

.app-bottom-nav a.is-active {
    background: var(--neu-accent-soft);
    color: var(--neu-accent);
}

.app-bottom-nav .badge {
    position: absolute;
    top: 4px;
    right: 18%;
    min-width: 17px;
    height: 17px;
    border-radius: var(--r-pill);
    padding: 0 5px;
    background: var(--neu-error);
    color: #fff;
    font-size: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* ----- Modal helpers ----- */
.neu-modal-backdrop,
.app-modal-backdrop {
    background: rgba(16, 33, 42, 0.42) !important;
    backdrop-filter: blur(6px);
}

.neu-divider {
    height: 1px;
    margin: 16px 0;
    background: var(--neu-line);
}

.text-muted { color: var(--neu-text-muted); }
.text-accent { color: var(--neu-accent); }
.text-success { color: var(--neu-success); }
.text-error { color: var(--neu-error); }
.text-gold { color: var(--neu-gold); }

@media (min-width: 768px) {
    .neu-container,
    .neu-topbar,
    .app-bottom-nav,
    .neu-bottom-action {
        max-width: 560px;
    }

    .neu-fab {
        right: max(22px, calc((100vw - 560px) / 2 + 22px));
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        scroll-behavior: auto !important;
        transition-duration: 0.01ms !important;
    }
}
