:root {
    --green-dark: #1c4d1c;
    --green: #2e5d2e;
    --green-light: #eef5ee;
    --border: #d5d5d5;
    --text: #222;
}

* { box-sizing: border-box; }

html, body {
    max-width: 100%;
    overflow-x: hidden;
}

body {
    font-family: 'Segoe UI', Arial, sans-serif;
    margin: 0;
    background: #f6f7f6;
    color: var(--text);
    -webkit-text-size-adjust: 100%;
}

img { max-width: 100%; height: auto; display: block; }

.container {
    max-width: 900px;
    margin: 0 auto;
    padding: 0 16px;
}

.topbar {
    background: var(--green-dark);
    color: #fff;
    padding: 14px 0;
}

.topbar-inner {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
}

.brand {
    font-size: 1.2rem;
    font-weight: 600;
    line-height: 1.3;
    word-break: break-word;
}

.logout-link {
    color: #fff;
    text-decoration: none;
    border: 1px solid rgba(255,255,255,0.6);
    padding: 8px 14px;
    border-radius: 4px;
    font-size: 0.9rem;
    min-height: 40px;
    display: inline-flex;
    align-items: center;
    white-space: nowrap;
}

.logout-link:hover { background: rgba(255,255,255,0.15); }

.page { padding: 24px 16px 40px; }

.card {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 24px;
    margin-bottom: 20px;
    overflow-wrap: break-word;
}

h1, h2, h3 {
    line-height: 1.3;
    overflow-wrap: break-word;
}

h2 { font-size: 1.4rem; margin-top: 0; }

.section-header {
    background: var(--green);
    color: #fff;
    padding: 10px 14px;
    border-radius: 4px;
    font-weight: 600;
    letter-spacing: 0.5px;
    margin: 24px 0 16px;
    text-transform: uppercase;
    font-size: 0.9rem;
}

.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.form-group { display: flex; flex-direction: column; }
.form-group.full { grid-column: 1 / -1; }

label {
    font-weight: 600;
    font-size: 0.9rem;
    margin-bottom: 6px;
}

input[type=text], input[type=email], input[type=password], input[type=date],
input[type=number], select, textarea, input[type=file] {
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 0.95rem;
    width: 100%;
    background: #fff;
    min-height: 44px;
}

input[type=file] { padding: 8px 10px; }

textarea { resize: vertical; min-height: 90px; }

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--green);
    color: #fff;
    border: none;
    padding: 12px 20px;
    border-radius: 4px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    text-align: center;
    min-height: 44px;
}

.btn:hover { background: var(--green-dark); }

.btn-secondary {
    background: #fff;
    color: var(--green);
    border: 1px solid var(--green);
}

.btn-small { padding: 8px 14px; font-size: 0.85rem; min-height: 38px; }

.alert {
    padding: 12px 16px;
    border-radius: 4px;
    margin-bottom: 16px;
    font-size: 0.95rem;
    overflow-wrap: break-word;
}

.alert-success { background: #e6f4ea; color: #1c4d1c; border: 1px solid #a9d6b5; }
.alert-error { background: #fdecea; color: #a53125; border: 1px solid #f3b3ac; }
.alert-info { background: #eaf2fb; color: #1a4d80; border: 1px solid #b6d4ee; }

.footer {
    background: #222;
    color: #ccc;
    text-align: center;
    padding: 16px 0;
    font-size: 0.85rem;
}

.login-box {
    max-width: 420px;
    margin: 40px auto;
    width: 100%;
}

.role-toggle {
    display: flex;
    gap: 20px;
    margin-bottom: 16px;
}

.role-toggle label {
    font-weight: 400;
    display: flex;
    align-items: center;
    gap: 6px;
}

.center-link {
    text-align: center;
    margin-top: 16px;
    font-size: 0.95rem;
}

.table-responsive {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: 6px;
}

table.data-table {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
}

table.data-table th, table.data-table td {
    border: 1px solid var(--border);
    padding: 10px 12px;
    text-align: left;
    font-size: 0.9rem;
}

table.data-table th {
    background: var(--green-light);
}

.filters {
    display: flex;
    gap: 12px;
    margin-bottom: 20px;
    flex-wrap: wrap;
    align-items: flex-end;
}

.filters .form-group { min-width: 200px; flex: 1 1 200px; }

.profile-grid {
    display: grid;
    grid-template-columns: 140px 1fr;
    gap: 24px;
    align-items: start;
}

.profile-photo img {
    width: 130px;
    height: 150px;
    object-fit: cover;
    border: 1px solid var(--border);
    border-radius: 4px;
}

.detail-table { width: 100%; }
.detail-table td { padding: 6px 10px; font-size: 0.95rem; overflow-wrap: break-word; }
.detail-table td.label { font-weight: 600; width: 220px; color: var(--green-dark); }

/* ---------------------------------------------------- */
/* Tablet and mobile breakpoint                          */
/* ---------------------------------------------------- */
@media (max-width: 640px) {
    .container { padding: 0 12px; }

    .topbar { padding: 12px 0; }
    .brand { font-size: 1.05rem; }

    .page { padding: 16px 10px 28px; }

    .card { padding: 16px; border-radius: 6px; margin-bottom: 16px; }

    h2 { font-size: 1.2rem; }

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

    .section-header { font-size: 0.85rem; padding: 9px 12px; margin: 18px 0 12px; }

    .login-box { margin: 20px auto; }

    .filters { flex-direction: column; align-items: stretch; gap: 10px; }
    .filters .form-group { min-width: 0; width: 100%; }
    .filters .btn { width: 100%; }

    /* Stack profile photo above details instead of side-by-side */
    .profile-grid {
        grid-template-columns: 1fr;
        gap: 16px;
        justify-items: center;
        text-align: center;
    }
    .profile-photo img { width: 120px; height: 140px; }
    .profile-grid .detail-table { text-align: left; }

    /* Turn fixed-width label/value table rows into stacked rows
       so long content never overflows the viewport */
    .detail-table, .detail-table tbody, .detail-table tr, .detail-table td {
        display: block;
        width: 100%;
    }
    .detail-table tr {
        padding: 8px 0;
        border-bottom: 1px solid var(--border);
    }
    .detail-table tr:last-child { border-bottom: none; }
    .detail-table td.label {
        width: auto;
        padding: 0 0 2px;
    }
    .detail-table td:not(.label) { padding: 0; }

    /* Data tables scroll horizontally instead of squeezing columns
       or forcing the page itself to scroll sideways */
    table.data-table { min-width: 560px; }

    .btn { width: 100%; }
    .btn.btn-small { width: auto; }
}

@media (max-width: 400px) {
    .brand { font-size: 0.95rem; }
    .logout-link { padding: 7px 10px; font-size: 0.85rem; }
}