:root {
    --gold: #c9a227;
    --gold-dark: #9a7b1a;
    --wood: #f5efe6;
    --wood-dark: #e8dcc8;
    --ink: #1a1a1a;
    --muted: #666;
    --border: #ddd;
    --success: #1f7a4c;
    --danger: #b42318;
    --warning: #b54708;
    --info: #175cd3;
    --radius: 8px;
    --shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
}

* { box-sizing: border-box; }

html {
    height: 100%;
}

body {
    margin: 0;
    min-height: 100%;
    display: flex;
    flex-direction: column;
    font-family: Georgia, "Times New Roman", serif;
    color: var(--ink);
    background: var(--wood);
    line-height: 1.5;
}

a { color: var(--gold-dark); text-decoration: none; }
a:hover { text-decoration: underline; }

.container {
    width: min(1100px, 92%);
    margin: 0 auto;
}

.site-header {
    background: #111;
    color: #fff;
    border-bottom: 4px solid var(--gold);
}

.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 1rem 0;
    flex-wrap: wrap;
}

.brand { display: flex; align-items: center; gap: .75rem; color: #fff; text-decoration: none; }
.brand-mark {
    background: var(--gold);
    color: #111;
    font-weight: 700;
    padding: .35rem .6rem;
    border-radius: 4px;
}
.brand-text { font-size: .9rem; max-width: 28rem; }

.nav { display: flex; gap: .75rem; align-items: center; flex-wrap: wrap; }
.nav a { color: #fff; text-decoration: none; font-family: Arial, sans-serif; font-size: .95rem; }

.main {
    flex: 1 0 auto;
    padding: 2rem 0 3rem;
    width: 100%;
}

.site-footer {
    flex-shrink: 0;
    margin-top: auto;
    background: #111;
    color: #ccc;
    padding: 1.25rem 0;
    text-align: center;
    font-family: Arial, sans-serif;
    font-size: .9rem;
}

.member-attachment-form {
    margin-bottom: 1.25rem;
    padding-bottom: 1.25rem;
    border-bottom: 1px solid var(--border);
}

.member-attachment-form:last-child {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}

.member-password-form {
    max-width: 480px;
}

.member-account-actions .btn {
    margin-top: .5rem;
}
.muted { color: #999; margin-top: .25rem; }

.card {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.hero {
    background: linear-gradient(135deg, #111, #333);
    color: #fff;
    padding: 2.5rem;
    border-radius: var(--radius);
    margin-bottom: 2rem;
}
.hero h1 { margin: 0 0 .5rem; color: var(--gold); }
.hero p { margin: 0; font-family: Arial, sans-serif; }

.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 1rem; }
.grid-3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 1rem; }

.btn {
    display: inline-block;
    padding: .55rem 1rem;
    border-radius: 6px;
    border: none;
    cursor: pointer;
    font-family: Arial, sans-serif;
    font-size: .95rem;
    text-decoration: none;
}
.btn-primary { background: var(--gold); color: #111; font-weight: 700; }
.btn-primary:hover { background: var(--gold-dark); color: #fff; text-decoration: none; }
.btn-outline { background: transparent; border: 1px solid #fff; color: #fff; }
.btn-outline:hover { background: #fff; color: #111; text-decoration: none; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-success { background: var(--success); color: #fff; }
.btn-sm { padding: .35rem .7rem; font-size: .85rem; }

.form-group { margin-bottom: 1rem; }
.form-group label {
    display: block;
    font-family: Arial, sans-serif;
    font-weight: 600;
    margin-bottom: .35rem;
    font-size: .92rem;
}
.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: .6rem .75rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-family: Arial, sans-serif;
    font-size: .95rem;
}
.form-group textarea { min-height: 90px; resize: vertical; }
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 1rem; }
.required::after { content: " *"; color: var(--danger); }

.section-title {
    margin: 1.5rem 0 1rem;
    padding-bottom: .35rem;
    border-bottom: 2px solid var(--gold);
    color: var(--gold-dark);
}

.alert {
    padding: .85rem 1rem;
    border-radius: 6px;
    margin: 1rem 0;
    font-family: Arial, sans-serif;
}
.alert-success { background: #e8f5ee; color: var(--success); border: 1px solid #b7e0c8; }
.alert-error { background: #fdecec; color: var(--danger); border: 1px solid #f5c2c0; }
.alert-warning { background: #fff4e5; color: var(--warning); border: 1px solid #ffd8a8; }
.alert-info { background: #eef4ff; color: var(--info); border: 1px solid #c7d7fe; }

.table-wrap { overflow-x: auto; }
table {
    width: 100%;
    border-collapse: collapse;
    font-family: Arial, sans-serif;
    font-size: .92rem;
}
th, td {
    padding: .65rem .75rem;
    border-bottom: 1px solid var(--border);
    text-align: left;
}
th { background: var(--wood-dark); }

.badge {
    display: inline-block;
    padding: .2rem .55rem;
    border-radius: 999px;
    font-size: .78rem;
    font-family: Arial, sans-serif;
    font-weight: 700;
    text-transform: uppercase;
}
.badge-pending { background: #fff4e5; color: var(--warning); }
.badge-approved { background: #e8f5ee; color: var(--success); }
.badge-rejected { background: #fdecec; color: var(--danger); }

.stat-card {
    background: #fff;
    border-radius: var(--radius);
    padding: 1rem 1.25rem;
    border-left: 4px solid var(--gold);
    box-shadow: var(--shadow);
}
.stat-card strong { display: block; font-size: 1.75rem; }
.stat-card span { font-family: Arial, sans-serif; color: var(--muted); font-size: .9rem; }

.admin-nav {
    display: flex;
    gap: .5rem;
    flex-wrap: wrap;
    margin-bottom: 1.5rem;
}
.admin-nav a {
    padding: .45rem .85rem;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-family: Arial, sans-serif;
    text-decoration: none;
}
.admin-nav a.active,
.admin-nav a:hover {
    background: var(--gold);
    color: #111;
    border-color: var(--gold);
    text-decoration: none;
}

/* Applications filters + DataTables */
.applications-filters {
    margin-bottom: 1rem;
    padding: 1rem 1.25rem;
}
.filter-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 1rem;
    align-items: end;
}
.filter-grid .form-group label {
    display: block;
    font-size: .85rem;
    margin-bottom: .35rem;
    font-weight: 600;
}
.filter-grid select,
.filter-grid .filter-date {
    width: 100%;
    padding: .55rem .65rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    font: inherit;
}
.filter-actions .btn {
    width: 100%;
}
.applications-table {
    width: 100% !important;
}
.dataTables_wrapper {
    font-family: Arial, sans-serif;
    font-size: .9rem;
}
.dataTables_wrapper .dataTables_filter input,
.dataTables_wrapper .dataTables_length select {
    padding: .45rem .6rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    font: inherit;
    margin-left: .35rem;
}
.dataTables_wrapper .dataTables_paginate .paginate_button {
    padding: .35rem .65rem !important;
    border: 1px solid var(--border) !important;
    border-radius: 6px !important;
    background: #fff !important;
    margin: 0 .15rem !important;
    cursor: pointer;
}
.dataTables_wrapper .dataTables_paginate .paginate_button.current,
.dataTables_wrapper .dataTables_paginate .paginate_button:hover:not(.disabled) {
    background: var(--gold) !important;
    border-color: var(--gold) !important;
    color: #111 !important;
}
.dataTables_wrapper .dataTables_paginate .paginate_button.disabled {
    opacity: .45;
    cursor: default;
}
.dataTables_wrapper .dataTables_length,
.dataTables_wrapper .dataTables_filter {
    margin-bottom: 1rem;
}
.dataTables_wrapper .dataTables_info {
    color: var(--muted);
    font-size: .85rem;
    margin-top: .75rem;
}

.login-box {
    max-width: 420px;
    margin: 2rem auto;
}

.text-center { text-align: center; }
.text-right { text-align: right; }
.mt-1 { margin-top: 1rem; }
.mb-0 { margin-bottom: 0; }

/* Photo crop */
.photo-crop-hint { font-size: .88rem; margin: 0 0 .75rem; }
.photo-preview-img {
    width: 150px;
    height: 200px;
    object-fit: cover;
    border: 2px solid var(--wood-dark);
    border-radius: 6px;
    display: block;
    background: #fff;
}
.member-photo-display { margin-bottom: 1rem; }
.file-input-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
}
.attachment-upload-actions {
    display: flex;
    gap: .5rem;
    flex-wrap: wrap;
    margin-top: .75rem;
}
.is-hidden {
    display: none !important;
}
.attachment-preview-slot {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 200px;
}
.attachment-preview-slot .photo-preview-img {
    margin: 0 auto;
}

.photo-crop-modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .65);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}
.photo-crop-modal[hidden] { display: none; }
.photo-crop-dialog {
    background: #fff;
    border-radius: var(--radius);
    padding: 1.25rem;
    width: min(720px, 96vw);
    max-height: 90vh;
    overflow: auto;
}
.photo-crop-dialog h3 { margin: 0 0 1rem; }
.photo-crop-area {
    max-height: 60vh;
    background: #111;
}
.photo-crop-area img { max-width: 100%; display: block; }
.photo-crop-actions {
    display: flex;
    gap: .5rem;
    margin-top: 1rem;
    flex-wrap: wrap;
}
body.photo-crop-open { overflow: hidden; }

/* Inline validation */
.field-error {
    color: #b42318;
    font-size: .85rem;
    margin-top: .35rem;
    display: block;
}
.form-group.is-invalid input,
.form-group.is-invalid select,
.form-group.is-invalid textarea {
    border-color: #b42318;
    box-shadow: 0 0 0 2px rgba(180, 35, 24, .12);
}
.alert-error { background: #fef3f2; border: 1px solid #fecdca; color: #912018; }

/* Attachment upload & display */
.attachment-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1.25rem;
    margin-top: .75rem;
}
.attachment-display-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1.25rem;
    margin-top: .75rem;
    max-width: 560px;
}
.attachment-box,
.attachment-display-box {
    border: 1px solid #ddd;
    border-radius: var(--radius);
    padding: 1rem;
    background: #fafafa;
}
.attachment-display-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}
.attachment-box h4,
.attachment-display-box h4 {
    margin: 0 0 .75rem;
    font-size: .95rem;
    width: 100%;
}
.attachment-preview-frame {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    background: #fff;
    border: 2px solid var(--wood-dark);
    border-radius: 6px;
    overflow: hidden;
}
.attachment-preview-frame--photo {
    aspect-ratio: 3 / 4;
    max-width: 180px;
}
.attachment-preview-frame--card {
    aspect-ratio: 16 / 10;
    max-width: 260px;
    min-height: 162px;
}
.attachment-preview-link {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    line-height: 0;
}
.attachment-photo-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.attachment-card-img {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
    display: block;
}
.attachment-placeholder {
    width: 100%;
    height: 100%;
    min-height: 200px;
    border: 2px dashed #ccc;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #888;
    font-size: .85rem;
    background: #fff;
}
.attachment-preview-frame--photo .attachment-placeholder {
    min-height: 0;
    aspect-ratio: 3 / 4;
    border: none;
}
.attachment-preview-frame--card .attachment-placeholder {
    min-height: 0;
    aspect-ratio: 16 / 10;
    border: none;
}
.attachment-placeholder-wide {
    width: 100%;
}
.visiting-card-preview {
    max-width: 100%;
    max-height: 180px;
    object-fit: contain;
    border: 1px solid #ddd;
    border-radius: 6px;
    background: #fff;
    display: block;
}
.section-title {
    margin: 1.25rem 0 .5rem;
    font-size: 1.05rem;
}

.signature-preview {
    margin-bottom: .75rem;
    padding: .75rem;
    background: #fafafa;
    border: 1px solid var(--border);
    border-radius: 6px;
    text-align: center;
}
.signature-preview img {
    max-width: 220px;
    max-height: 80px;
    object-fit: contain;
}

/* Flatpickr */
.flatpickr-date + .flatpickr-input {
    width: 100%;
    padding: .6rem .75rem;
    border: 1px solid #ccc;
    border-radius: var(--radius);
    font: inherit;
    background: #fff;
    cursor: pointer;
}
.flatpickr-date + .flatpickr-input:focus {
    outline: none;
    border-color: var(--wood-dark);
    box-shadow: 0 0 0 2px rgba(92, 64, 51, .15);
}
.form-group.is-invalid .flatpickr-date + .flatpickr-input {
    border-color: #b42318;
    box-shadow: 0 0 0 2px rgba(180, 35, 24, .12);
}
.flatpickr-calendar {
    border-radius: var(--radius);
    box-shadow: 0 8px 24px rgba(0, 0, 0, .15);
    font-family: inherit;
}
.flatpickr-day.selected,
.flatpickr-day.startRange,
.flatpickr-day.endRange {
    background: var(--wood-dark);
    border-color: var(--wood-dark);
}
.flatpickr-day.selected:hover,
.flatpickr-day.startRange:hover,
.flatpickr-day.endRange:hover {
    background: var(--gold);
    border-color: var(--gold);
}

@media (max-width: 640px) {
    .brand-text { display: none; }
    .attachment-display-grid {
        grid-template-columns: 1fr;
        max-width: none;
    }
    .attachment-preview-frame--photo,
    .attachment-preview-frame--card {
        max-width: 100%;
    }
}
