* {
    box-sizing: border-box;
}
body {
    font-family: 'Sarabun', -apple-system, BlinkMacSystemFont, sans-serif;
    margin: 0;
    background: #f0f2f5;
    color: #1a1a1a;
    line-height: 1.5;
}
a {
    color: #2563eb;
    text-decoration: none;
}
a:hover {
    text-decoration: underline;
}

/* Login */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #1e3a5f 0%, #0f172a 100%);
}
.login-box {
    background: #fff;
    padding: 2rem 2.5rem;
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.2);
    width: 100%;
    max-width: 360px;
}
.login-box h1 {
    margin: 0 0 1.5rem;
    font-size: 1.5rem;
    color: #1e3a5f;
}
.login-box label {
    display: block;
    margin-bottom: 0.35rem;
    font-weight: 600;
    color: #374151;
}
.login-box input {
    width: 100%;
    padding: 0.6rem 0.75rem;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    margin-bottom: 1rem;
    font-size: 1rem;
}
.login-box input:focus {
    outline: none;
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37,99,235,0.15);
}
.login-box button {
    width: 100%;
    padding: 0.75rem;
    background: #2563eb;
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    margin-top: 0.5rem;
}
.login-box button:hover {
    background: #1d4ed8;
}
.login-box .error {
    background: #fef2f2;
    color: #b91c1c;
    padding: 0.6rem;
    border-radius: 8px;
    margin-bottom: 1rem;
    font-size: 0.9rem;
}

/* Header */
.header {
    background: #1e3a5f;
    color: #fff;
    padding: 1rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 1rem;
}
.header h1 {
    margin: 0;
    font-size: 1.25rem;
}
.header h1 a {
    color: #fff;
    text-decoration: none;
}
.header h1 a:hover {
    text-decoration: underline;
}
.user-menu {
    display: flex;
    align-items: center;
    gap: 1rem;
}
.user-menu a {
    color: #fff;
}
.user-menu a:hover {
    text-decoration: underline;
}

/* Buttons */
.btn {
    display: inline-block;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    border: none;
    text-decoration: none;
    transition: background 0.2s;
}
.btn-primary {
    background: #2563eb;
    color: #fff;
}
.btn-primary:hover {
    background: #1d4ed8;
}
.btn-outline {
    background: transparent;
    color: #fff;
    border: 1px solid rgba(255,255,255,0.6);
}
.btn-outline:hover {
    background: rgba(255,255,255,0.1);
    text-decoration: none;
}
.btn-sm {
    padding: 0.35rem 0.65rem;
    font-size: 0.85rem;
    margin-right: 0.35rem;
}
.btn-danger {
    background: #dc2626;
    color: #fff;
}
.btn-danger:hover {
    background: #b91c1c;
    text-decoration: none;
}
.btn-outline-dark {
    background: #fff;
    color: #374151;
    border: 1px solid #d1d5db;
}
.btn-outline-dark:hover {
    background: #f3f4f6;
    text-decoration: none;
}

/* Container */
.container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 1.5rem;
}
.toolbar {
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}
.search-bar {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
    padding: 0.75rem 1rem;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}
.search-label {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 500;
    color: #374151;
}
.search-label span {
    min-width: 2.5em;
}
.search-input,
.search-select {
    padding: 0.5rem 0.75rem;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 0.95rem;
}
.search-input {
    min-width: 180px;
}
.search-select {
    min-width: 140px;
}
.toolbar.topup-bar {
    background: #f8fafc;
    padding: 0.75rem 1rem;
    border-radius: 8px;
    margin-bottom: 0.5rem;
}
.topup-label {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 500;
    color: #374151;
}
.topup-input {
    width: 80px;
    padding: 0.4rem 0.5rem;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 1rem;
}
.col-check {
    width: 2.5rem;
    text-align: center;
}
.message {
    padding: 0.75rem 1rem;
    border-radius: 8px;
    margin-bottom: 1rem;
}
.message.success {
    background: #d1fae5;
    color: #065f46;
}
.message.error {
    background: #fee2e2;
    color: #b91c1c;
}
.message.warning {
    background: #fee2e2;
    color: #b91c1c;
}
.inline-list {
    list-style: none;
    padding-left: 0;
    margin: 0.25rem 0 0;
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem 0.75rem;
    font-size: 0.9rem;
}
.inline-list li::before {
    content: "• ";
}

/* Modal (popup) */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.45);
    align-items: center;
    justify-content: center;
    z-index: 1000;
}
.modal-box {
    background: #fff;
    padding: 1.75rem 2rem;
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
    min-width: 320px;
    max-width: 90vw;
}
.modal-box h2 {
    margin: 0 0 0.5rem;
    font-size: 1.25rem;
    color: #1e3a5f;
}
.modal-desc {
    margin: 0 0 1.25rem;
    color: #6b7280;
    font-size: 0.9rem;
}
.modal-box .form-group {
    margin-bottom: 1.25rem;
}
.modal-box .topup-input {
    width: 100%;
    max-width: 120px;
}
.input-suffix {
    margin-left: 0.35rem;
    color: #6b7280;
}
.modal-actions {
    display: flex;
    gap: 0.75rem;
    margin-top: 1.25rem;
}

/* Table */
.table-wrap {
    overflow-x: auto;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}
.data-table {
    width: 100%;
    border-collapse: collapse;
}
.data-table th,
.data-table td {
    padding: 0.85rem 1rem;
    text-align: left;
    border-bottom: 1px solid #e5e7eb;
}
.data-table th {
    background: #f8fafc;
    font-weight: 600;
    color: #374151;
    font-size: 0.9rem;
}
.data-table tbody tr:hover {
    background: #f8fafc;
}
.data-table .empty {
    text-align: center;
    color: #6b7280;
    padding: 2rem;
}
.data-table .expired {
    color: #dc2626;
    font-weight: 500;
}

@media (max-width: 640px) {
    .container {
        padding: 1rem;
    }
    .toolbar,
    .search-bar {
        flex-direction: column;
        align-items: stretch;
    }
    .search-input,
    .search-select {
        width: 100%;
        min-width: 0;
    }
    .table-wrap {
        border-radius: 8px;
        box-shadow: none;
    }
    .data-table th,
    .data-table td {
        padding: 0.6rem 0.5rem;
        font-size: 0.85rem;
    }
    .data-table th {
        font-size: 0.8rem;
        white-space: nowrap;
    }
    .pagination {
        justify-content: center;
    }
}

.pagination {
    margin-top: 0.75rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}
.page-link {
    padding: 0.3rem 0.6rem;
    border-radius: 999px;
    border: 1px solid #d1d5db;
    background: #fff;
    font-size: 0.85rem;
    color: #374151;
    text-decoration: none;
}
.page-link:hover {
    background: #f3f4f6;
}
.page-link.active {
    background: #2563eb;
    color: #fff;
    border-color: #2563eb;
    cursor: default;
}

/* Form card */
.form-card {
    background: #fff;
    padding: 2rem;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    max-width: 520px;
}
.form-card h2 {
    margin: 0 0 1.5rem;
    font-size: 1.25rem;
    color: #1e3a5f;
}
.form-group {
    margin-bottom: 1.25rem;
}
.form-group label {
    display: block;
    margin-bottom: 0.4rem;
    font-weight: 600;
    color: #374151;
}
.form-group input,
.form-group select {
    width: 100%;
    padding: 0.6rem 0.75rem;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 1rem;
}
.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: #2563eb;
}
.form-group.readonly input {
    background: #f3f4f6;
    color: #4b5563;
}
.days-left-hint {
    display: block;
    margin-top: 0.25rem;
    font-size: 0.875rem;
    color: #6b7280;
}
.form-group input[type="date"] {
    max-width: 12rem;
}
.form-group .number-select {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    max-width: 140px;
}
.form-group .number-select input {
    text-align: center;
    margin: 0;
}
.num-btn {
    width: 36px;
    height: 36px;
    border: 1px solid #d1d5db;
    background: #f9fafb;
    border-radius: 8px;
    font-size: 1.2rem;
    cursor: pointer;
    line-height: 1;
    color: #374151;
}
.num-btn:hover {
    background: #e5e7eb;
}
.form-actions {
    margin-top: 1.5rem;
    display: flex;
    gap: 0.75rem;
}
.form-card .error {
    background: #fef2f2;
    color: #b91c1c;
    padding: 0.6rem;
    border-radius: 8px;
    margin-bottom: 1rem;
    font-size: 0.9rem;
}
