/* Reset & base */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    line-height: 1.6;
    color: #333;
    background: #f8f9fa;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
header {
    background: #2c3e50;
    color: #fff;
    padding: 0 1rem;
}
nav {
    max-width: 960px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 56px;
}
.brand {
    color: #fff;
    text-decoration: none;
    font-size: 1.1rem;
    font-weight: 600;
}
.nav-links { display: flex; align-items: center; gap: 1rem; }
.nav-links a { color: #ccc; text-decoration: none; font-size: 0.9rem; }
.nav-links a:hover { color: #fff; }
.nav-user { color: #aaa; font-size: 0.85rem; }

/* Main */
main { flex: 1; padding: 1.5rem 1rem; max-width: 960px; margin: 0 auto; width: 100%; }
footer { text-align: center; padding: 1rem; color: #999; font-size: 0.85rem; }

/* Container */
.container { width: 100%; }

/* Flash messages */
.flash {
    padding: 0.75rem 1rem;
    border-radius: 6px;
    margin-bottom: 1rem;
    font-size: 0.9rem;
}
.flash-success { background: #d4edda; color: #155724; border: 1px solid #c3e6cb; }
.flash-error { background: #f8d7da; color: #721c24; border: 1px solid #f5c6cb; }
.flash-info { background: #d1ecf1; color: #0c5460; border: 1px solid #bee5eb; }

/* Auth card */
.auth-card {
    max-width: 400px;
    margin: 2rem auto;
    background: #fff;
    padding: 2rem;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}
.auth-card h1 { margin-bottom: 1.5rem; font-size: 1.5rem; }
.auth-link { text-align: center; margin-top: 1rem; font-size: 0.9rem; }

/* Forms */
label { display: block; margin-bottom: 0.25rem; font-weight: 500; font-size: 0.9rem; }
input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="date"],
textarea,
select {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1px solid #ccc;
    border-radius: 6px;
    font-size: 0.95rem;
    margin-bottom: 1rem;
    font-family: inherit;
}
input:focus, textarea:focus, select:focus {
    outline: none;
    border-color: #2c3e50;
    box-shadow: 0 0 0 2px rgba(44,62,80,0.15);
}
textarea { resize: vertical; }

/* Checkboxes & radios */
.checkbox-label, .radio-label {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    font-weight: 400;
    padding: 0.35rem 0;
    cursor: pointer;
}
.checkbox-label input, .radio-label input {
    margin-top: 0.25rem;
    flex-shrink: 0;
}

/* Conditional fields */
.conditional-field {
    margin-left: 1.5rem;
    padding-left: 0.75rem;
    border-left: 2px solid #ddd;
    margin-bottom: 0.5rem;
}
.conditional-field.hidden { display: none; }

/* Fieldset */
fieldset {
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 1.25rem;
    margin-bottom: 1.25rem;
    background: #fff;
}
legend {
    font-weight: 600;
    font-size: 1rem;
    padding: 0 0.5rem;
}
fieldset p { margin-bottom: 0.75rem; font-size: 0.9rem; color: #555; }

.required { color: #c0392b; }
.form-intro { margin-bottom: 1.5rem; color: #555; }

/* Buttons */
.btn {
    display: inline-block;
    padding: 0.5rem 1.25rem;
    border: 1px solid #ccc;
    border-radius: 6px;
    background: #fff;
    color: #333;
    font-size: 0.9rem;
    cursor: pointer;
    text-decoration: none;
    font-family: inherit;
    line-height: 1.5;
}
.btn:hover { background: #f0f0f0; }
.btn-primary { background: #2c3e50; color: #fff; border-color: #2c3e50; }
.btn-primary:hover { background: #34495e; }
.btn-danger { background: #c0392b; color: #fff; border-color: #c0392b; }
.btn-danger:hover { background: #e74c3c; }
.btn-sm { padding: 0.25rem 0.75rem; font-size: 0.85rem; }
.form-actions { display: flex; gap: 0.75rem; margin-top: 0.5rem; }

/* Page header */
.page-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1.5rem; flex-wrap: wrap; gap: 0.5rem; }
.page-header h1 { font-size: 1.5rem; }

/* Tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; background: #fff; border-radius: 8px; overflow: hidden; box-shadow: 0 1px 4px rgba(0,0,0,0.06); }
th, td { padding: 0.6rem 0.75rem; text-align: left; font-size: 0.9rem; border-bottom: 1px solid #eee; }
th { background: #f5f6f7; font-weight: 600; white-space: nowrap; }
tbody tr:hover { background: #fafbfc; }

/* Badges */
.badge { display: inline-block; padding: 0.15rem 0.6rem; border-radius: 12px; font-size: 0.8rem; font-weight: 500; }
.badge-draft { background: #ffeaa7; color: #856404; }
.badge-submitted { background: #81ecec; color: #0c5460; }
.badge-locked { background: #dfe6e9; color: #636e72; }
.badge-unlock { background: #fab1a0; color: #6c3a2a; }

/* Filters */
.filters-form { background: #fff; padding: 1rem; border-radius: 8px; margin-bottom: 1.5rem; box-shadow: 0 1px 4px rgba(0,0,0,0.06); }
.filters-row { display: flex; flex-wrap: wrap; gap: 0.75rem; }
.filter-group { flex: 1; min-width: 140px; }
.filter-group label { font-size: 0.8rem; color: #666; margin-bottom: 0.15rem; }
.filter-group input, .filter-group select { margin-bottom: 0.5rem; }
.filters-actions { display: flex; gap: 0.5rem; margin-top: 0.5rem; flex-wrap: wrap; }
.result-count { font-size: 0.9rem; color: #666; margin-bottom: 0.75rem; }

/* Detail page */
.back-link { display: inline-block; margin-bottom: 1rem; color: #2c3e50; text-decoration: none; font-size: 0.9rem; }
.back-link:hover { text-decoration: underline; }
.detail-meta { background: #fff; padding: 1rem; border-radius: 8px; margin-bottom: 1.5rem; box-shadow: 0 1px 4px rgba(0,0,0,0.06); }
.detail-meta p { margin-bottom: 0.35rem; font-size: 0.9rem; }
.detail-answers { margin-bottom: 1.5rem; }
.answer-section { background: #fff; padding: 1rem; border-radius: 8px; margin-bottom: 0.75rem; box-shadow: 0 1px 4px rgba(0,0,0,0.06); }
.answer-section h3 { font-size: 0.95rem; margin-bottom: 0.5rem; color: #2c3e50; }
.answer-section ul { list-style: disc; margin-left: 1.5rem; }
.answer-section li { font-size: 0.9rem; margin-bottom: 0.2rem; }
.lock-form { margin-top: 1rem; }
.empty-state { text-align: center; color: #999; padding: 2rem; }

/* Pagination */
.pagination { display: flex; align-items: center; justify-content: center; gap: 1rem; margin-top: 1.25rem; }
.page-info { font-size: 0.9rem; color: #666; }

/* Email log */
.badge-failed { background: #f8d7da; color: #721c24; }
.badge-type-welcome { background: #d4edda; color: #155724; }
.badge-type-confirmation { background: #d1ecf1; color: #0c5460; }
.badge-type-reminder { background: #ffeaa7; color: #856404; }
.badge-type-reset { background: #e2d6f3; color: #4a235a; }
.badge-type-test { background: #dfe6e9; color: #636e72; }
.badge-type-other { background: #dfe6e9; color: #636e72; }
.error-cell { font-size: 0.8rem; color: #c0392b; max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Notifications */
.notifications-list { display: flex; flex-direction: column; gap: 0.75rem; }
.notification-card { background: #fff; padding: 1rem; border-radius: 8px; box-shadow: 0 1px 4px rgba(0,0,0,0.06); }
.notification-failed { border-left: 3px solid #c0392b; }
.notification-header { display: flex; align-items: center; gap: 0.5rem; margin-bottom: 0.5rem; flex-wrap: wrap; }
.notification-time { font-size: 0.8rem; color: #999; }
.notification-subject { font-weight: 600; font-size: 0.95rem; margin-bottom: 0.25rem; }
.notification-card { cursor: pointer; }
.notification-preview { font-size: 0.85rem; color: #666; }
.notification-body { display: none; font-size: 0.9rem; color: #333; white-space: pre-line; margin-top: 0.75rem; padding-top: 0.75rem; border-top: 1px solid #eee; overflow: visible; max-height: none; }
.notification-card.expanded .notification-preview { display: none; }
.notification-card.expanded .notification-body { display: block; }
.expand-icon { margin-left: auto; font-size: 0.75rem; color: #999; transition: transform 0.2s; }
.notification-card.expanded .expand-icon { transform: rotate(180deg); }
.notification-error { font-size: 0.8rem; color: #c0392b; margin-top: 0.5rem; }

/* Mobile */
@media (max-width: 600px) {
    main { padding: 1rem 0.75rem; }
    .auth-card { padding: 1.25rem; margin: 1rem auto; }
    .filters-row { flex-direction: column; }
    .filter-group { min-width: 100%; }
    th, td { padding: 0.4rem 0.5rem; font-size: 0.8rem; }
}
