@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Noto+Sans+Thai:wght@300;400;500;600;700&display=swap');

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

:root {
    --page-bg: #f8fafc; /* Tailwind slate-50 */
    --surface: #ffffff;
    --surface-soft: #f1f5f9; /* Tailwind slate-100 */
    --text: #0f172a; /* Tailwind slate-900 */
    --text-muted: #64748b; /* Tailwind slate-500 */
    --border: #e2e8f0; /* Tailwind slate-200 */
    --border-hover: #cbd5e1; /* Tailwind slate-300 */
    --primary: #e11d48; /* Tailwind rose-600 (Pink/Rose) */
    --primary-hover: #be123c; /* Tailwind rose-700 */
    --primary-soft: #fff1f2; /* Tailwind rose-50 */
    --primary-dark: #881337; /* Tailwind rose-950 */
    --success: #10b981; /* Tailwind emerald-500 */
    --success-bg: #ecfdf5;
    --success-border: #a7f3d0;
    --success-text: #065f46;
    --error: #ef4444; /* Tailwind red-500 */
    --error-bg: #fef2f2;
    --error-border: #fecaca;
    --error-text: #991b1b;
}

body {
    min-height: 100vh;
    background: radial-gradient(circle at 100% 0%, #ffe4e6 0%, var(--page-bg) 50%); /* Rose-100 to Slate-50 */
    color: var(--text);
    font-family: 'Inter', 'Noto Sans Thai', sans-serif;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid rgba(226, 232, 240, 0.8);
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.03);
}

.header-inner {
    width: min(1040px, calc(100% - 40px));
    margin: 0 auto;
    padding: 20px 0 0;
}

h1 {
    color: var(--primary-dark);
    font-size: 26px;
    font-weight: 700;
    letter-spacing: -0.5px;
    position: relative;
    display: inline-block;
}

h1::after {
    content: '';
    position: absolute;
    bottom: -6px;
    left: 0;
    width: 40px;
    height: 4px;
    background: var(--primary);
    border-radius: 2px;
}

.nav {
    display: flex;
    gap: 12px;
    margin-top: 24px;
    padding-bottom: 12px;
}

.nav a {
    display: inline-flex;
    align-items: center;
    padding: 8px 18px;
    border-radius: 30px;
    color: var(--text-muted);
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    background: transparent;
    border: 1px solid transparent;
}

.nav a:hover {
    color: var(--primary);
    background: rgba(225, 29, 72, 0.05);
}

.nav a.active {
    color: #ffffff;
    background: var(--primary);
    box-shadow: 0 4px 12px rgba(225, 29, 72, 0.25);
    border-color: var(--primary);
}

main {
    width: min(1040px, calc(100% - 40px));
    margin: 0 auto;
    padding: 36px 0 64px;
}

form {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    box-shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.04), 
                0 1px 3px rgba(0, 0, 0, 0.02),
                0 30px 60px -15px rgba(225, 29, 72, 0.03);
    overflow: hidden;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

fieldset {
    margin: 0;
    padding: 30px 32px 32px;
    border: 0;
    border-bottom: 1px solid var(--surface-soft);
}

fieldset:last-of-type {
    border-bottom: none;
}

legend {
    width: 100%;
    margin-bottom: 22px;
    padding: 0 0 14px;
    border-bottom: 1px solid var(--border);
    color: var(--primary-dark);
    font-size: 18px;
    font-weight: 700;
    letter-spacing: 0;
    display: flex;
    align-items: center;
    gap: 8px;
    line-height: 1.35;
}

legend::before {
    content: '';
    display: inline-block;
    width: 6px;
    height: 18px;
    background: var(--primary);
    border-radius: 3px;
}

.grid {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    gap: 20px;
    align-items: start;
}

.col-2 { grid-column: span 2; }
.col-3 { grid-column: span 3; }
.col-4 { grid-column: span 4; }
.col-5 { grid-column: span 5; }
.col-6 { grid-column: span 6; }
.col-12 { grid-column: span 12; }

.person-grid {
    grid-template-columns: minmax(150px, 0.7fr) repeat(2, minmax(0, 1fr));
}

.person-grid > [class*="col-"] {
    grid-column: auto;
}

label {
    display: block;
    min-height: 22px;
    margin-bottom: 7px;
    color: #475569; /* slate-600 */
    font-size: 14px;
    font-weight: 600;
    line-height: 1.45;
}

input,
select {
    width: 100%;
    height: 46px;
    padding: 10px 16px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    color: var(--text);
    font-family: inherit;
    font-size: 15px;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

input:hover,
select:hover {
    border-color: var(--border-hover);
}

input:focus,
select:focus {
    border-color: var(--primary);
    outline: none;
    box-shadow: 0 0 0 4px rgba(225, 29, 72, 0.12);
    background: #ffffff;
}

select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%23475569' stroke-width='2'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' d='M19 9l-7 7-7-7'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    background-size: 16px;
    padding-right: 40px;
}

.actions {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 14px;
    margin: 0;
    padding: 24px 32px;
    background: var(--surface-soft);
    border-top: 1px solid var(--border);
}

button,
.button-link {
    min-width: 130px;
    height: 46px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 24px;
    border-radius: 8px;
    border: 1px solid transparent;
    font-family: inherit;
    font-size: 15px;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

button {
    background: var(--primary);
    color: #ffffff;
    box-shadow: 0 4px 12px rgba(225, 29, 72, 0.15);
}

button:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(225, 29, 72, 0.2);
}

button:active {
    transform: translateY(1px);
}

.button-download {
    background: #1e293b; /* slate-800 */
    border-color: #1e293b;
    color: #ffffff;
    box-shadow: 0 4px 12px rgba(30, 41, 59, 0.15);
}

.button-download:hover {
    background: #0f172a; /* slate-900 */
    border-color: #0f172a;
    box-shadow: 0 6px 16px rgba(30, 41, 59, 0.2);
}

.button-link {
    background: #ffffff;
    border-color: var(--border);
    color: #475569;
}

.button-link:hover {
    background: var(--page-bg);
    border-color: var(--border-hover);
    color: var(--text);
    transform: translateY(-1px);
}

.button-link:active {
    transform: translateY(1px);
}

.alert {
    margin-bottom: 24px;
    padding: 16px 20px;
    border-radius: 12px;
    font-size: 15px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    animation: fadeIn 0.3s ease;
}

.alert-success {
    background: var(--success-bg);
    border: 1px solid var(--success-border);
    color: var(--success-text);
}

.alert-error {
    background: var(--error-bg);
    border: 1px solid var(--error-border);
    color: var(--error-text);
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-4px); }
    to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 760px) {
    header {
        background: #ffffff;
    }

    .header-inner {
        width: 100%;
        padding: 20px 16px 16px;
    }

    h1 {
        font-size: 20px;
        display: block;
        text-align: center;
        width: 100%;
    }

    h1::after {
        left: 50%;
        transform: translateX(-50%);
    }

    .nav {
        display: grid;
        grid-template-columns: repeat(3, 1fr);
        gap: 4px;
        background: #f1f5f9; /* Slate-100 */
        padding: 4px;
        border-radius: 12px;
        margin-top: 24px;
        border-bottom: none;
    }

    .nav a {
        display: flex;
        justify-content: center;
        align-items: center;
        text-align: center;
        padding: 8px 4px;
        font-size: 12px;
        font-weight: 600;
        line-height: 1.3;
        border-radius: 8px;
        min-height: 42px; /* Large touch target */
        color: var(--text-muted);
        background: transparent;
        box-shadow: none;
        border: none;
        flex-shrink: 0;
    }

    .nav a.active {
        color: var(--primary);
        background: #ffffff;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    }

    .nav a:hover {
        background: transparent;
        color: var(--primary);
    }

    main {
        width: calc(100% - 24px);
        padding: 20px 0 48px;
    }

    fieldset {
        padding: 24px 16px 26px;
    }

    legend {
        margin-bottom: 18px;
        padding-bottom: 12px;
        font-size: 17px;
    }

    .grid {
        gap: 16px;
    }

    .person-grid {
        grid-template-columns: 1fr;
    }

    .col-2, .col-3, .col-4, .col-5, .col-6 {
        grid-column: span 12;
    }

    label {
        min-height: 0;
    }

    input,
    select {
        height: 48px;
        font-size: 16px;
    }

    .actions {
        flex-direction: column-reverse;
        padding: 20px 16px;
        gap: 12px;
    }

    button,
    .button-link {
        width: 100%;
        height: 48px;
        min-height: 48px;
    }
}
