:root {
    --bg: #f4f6f9;
    --card-bg: #ffffff;
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --text: #1f2937;
    --muted: #6b7280;
    --border: #e5e7eb;
    --success-bg: #ecfdf5;
    --success-text: #047857;
    --error-bg: #fef2f2;
    --error-text: #b91c1c;
    --radius: 10px;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: 'Segoe UI', Roboto, system-ui, -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

.container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 24px 16px 60px;
}

/* Top navigation */
.topbar {
    background: var(--card-bg);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 10;
}
.topbar-inner {
    max-width: 1100px;
    margin: 0 auto;
    padding: 14px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px;
}
.brand { font-weight: 700; font-size: 1.1rem; color: var(--text); }
.brand:hover { text-decoration: none; }
.topbar nav { display: flex; align-items: center; gap: 18px; }
.user-chip { color: var(--muted); font-size: 0.9rem; }
.logout-link { color: var(--error-text); }

/* Cards */
.card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    margin-bottom: 20px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.03);
}

/* Login page */
.login-wrap {
    min-height: 90vh;
    display: flex;
    align-items: center;
    justify-content: center;
}
.login-card {
    width: 100%;
    max-width: 380px;
    text-align: center;
}
.login-card h1 { font-size: 1.4rem; margin-bottom: 6px; }
.login-card p.subtitle { color: var(--muted); margin-top: 0; margin-bottom: 24px; }

/* Forms */
label { display: block; font-weight: 600; margin-bottom: 6px; font-size: 0.9rem; }
input[type=text], input[type=password], input[type=file], input[type=search], textarea, select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 1rem;
    margin-bottom: 16px;
    background: #fff;
    color: var(--text);
}
input:focus, textarea:focus, select:focus { outline: 2px solid var(--primary); outline-offset: 1px; }

.btn {
    display: inline-block;
    background: var(--primary);
    color: #fff;
    border: none;
    padding: 10px 18px;
    border-radius: 8px;
    font-size: 1rem;
    cursor: pointer;
    font-weight: 600;
}
.btn:hover { background: var(--primary-dark); text-decoration: none; }
.btn-danger { background: var(--error-text); }
.btn-secondary { background: #6b7280; }
.btn-block { width: 100%; }

.alert { padding: 12px 14px; border-radius: 8px; margin-bottom: 18px; font-size: 0.95rem; }
.alert-success { background: var(--success-bg); color: var(--success-text); }
.alert-error { background: var(--error-bg); color: var(--error-text); }

/* Dashboard table */
.page-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 18px;
}
.page-head h1 { margin: 0; font-size: 1.4rem; }

table.records {
    width: 100%;
    border-collapse: collapse;
    background: var(--card-bg);
    border-radius: var(--radius);
    overflow: hidden;
}
table.records th, table.records td {
    padding: 12px 14px;
    text-align: left;
    border-bottom: 1px solid var(--border);
    font-size: 0.92rem;
}
table.records th { background: #f9fafb; color: var(--muted); font-weight: 600; }
table.records tr:hover td { background: #f9fafb; }
.thumb { width: 40px; height: 50px; object-fit: cover; border-radius: 4px; border: 1px solid var(--border); }
.no-photo { width: 40px; height: 50px; border-radius: 4px; border: 1px dashed var(--border); display: flex; align-items: center; justify-content: center; font-size: 0.7rem; color: var(--muted); }

.search-box { display: flex; gap: 8px; margin-bottom: 4px; }
.search-box input { margin-bottom: 0; }

/* Record view / edit */
.record-grid {
    display: grid;
    grid-template-columns: 200px 1fr;
    gap: 24px;
}
.record-photo { width: 100%; border-radius: var(--radius); border: 1px solid var(--border); }
.field-row { display: flex; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid var(--border); gap: 12px; }
.field-row .field-label { color: var(--muted); font-size: 0.88rem; }
.field-row .field-value { font-weight: 600; text-align: right; }

@media (max-width: 640px) {
    .record-grid { grid-template-columns: 1fr; }
    .field-row .field-value { text-align: left; }
    .field-row { flex-direction: column; gap: 2px; }
    table.records { display: block; overflow-x: auto; white-space: nowrap; }
}

.badge { display: inline-block; padding: 2px 10px; border-radius: 999px; background: #eef2ff; color: var(--primary); font-size: 0.78rem; font-weight: 600; }
.actions a { margin-right: 10px; font-size: 0.88rem; }
.helper-text { color: var(--muted); font-size: 0.85rem; margin-top: -8px; margin-bottom: 16px; }
