* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
    margin: 0;
    font-family: -apple-system, Segoe UI, Roboto, Arial, sans-serif;
    background: #f2f4f7;
    color: #1f2937;
}

.topbar {
    background: #0f4c81;
    color: #fff;
    padding: 14px 16px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px 16px;
    justify-content: space-between;
    align-items: center;
}
.topbar a { color: #fff; text-decoration: none; }
.topbar .brand { font-weight: 600; font-size: 17px; }
.topbar .nav { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 14px; }
.topbar .nav a, .topbar .nav span { opacity: .9; font-size: 14px; }
.topbar .nav a:hover { opacity: 1; text-decoration: underline; }

.wrap { max-width: 960px; margin: 24px auto; padding: 0 16px; }
.center-wrap { max-width: 400px; margin: 8vh auto; padding: 0 16px; }

.card {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 20px;
    margin-bottom: 18px;
}
.card h2 { margin-top: 0; font-size: 18px; }

label { display: block; margin: 12px 0 4px; font-size: 14px; font-weight: 600; }
input[type=text], input[type=password], input[type=file], select {
    width: 100%;
    padding: 12px 10px;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    font-size: 16px; /* 16px prevents iOS auto-zoom on focus */
}
button, .btn {
    display: inline-block;
    margin-top: 18px;
    background: #0f4c81;
    color: #fff;
    border: none;
    padding: 12px 18px;
    border-radius: 6px;
    font-size: 15px;
    cursor: pointer;
    text-decoration: none;
    text-align: center;
}
button:hover, .btn:hover { background: #0c3c66; }
.btn-secondary { background: #64748b; }
.btn-secondary:hover { background: #475569; }

.msg { padding: 10px 14px; border-radius: 6px; margin-bottom: 16px; font-size: 14px; }
.msg.ok { background: #dcfce7; color: #166534; border: 1px solid #86efac; }
.msg.err { background: #fee2e2; color: #991b1b; border: 1px solid #fca5a5; }

.table-wrap { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; margin-top: 10px; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid #e2e8f0; font-size: 14px; white-space: nowrap; }
th { color: #475569; font-weight: 600; }

.grid-links { display: flex; gap: 16px; flex-wrap: wrap; }
.grid-links .card { flex: 1; min-width: 220px; text-align: center; }
.grid-links a.btn { width: 100%; margin-top: 10px; }

.badge { background: #e2e8f0; padding: 2px 8px; border-radius: 12px; font-size: 12px; white-space: nowrap; }

/* ---- Responsive breakpoints ---- */
@media (max-width: 640px) {
    .topbar { padding: 12px; }
    .topbar .brand { font-size: 15px; width: 100%; }
    .topbar .nav { width: 100%; justify-content: flex-start; }

    .wrap, .center-wrap { margin: 14px auto; padding: 0 10px; }
    .card { padding: 16px; border-radius: 8px; }

    button, .btn { width: 100%; }
    form[method="get"] { flex-direction: column; align-items: stretch !important; }
    form[method="get"] button, form[method="get"] .btn { width: 100%; }

    th, td { font-size: 13px; padding: 8px 6px; }
}

@media (max-width: 400px) {
    .topbar .brand { font-size: 14px; }
}
