/* Base */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: Georgia, serif;
    font-size: 16px;
    line-height: 1.6;
    color: #222;
    background-color: #fafafa;
}

a {
    color: #2a6496;
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

/* Layout */
.container {
    max-width: 860px;
    margin: 0 auto;
    padding: 2rem 1.5rem;
}

/* Navbar */
.navbar {
    background-color: #2a6496;
    padding: 0.9rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.nav-brand {
    color: #fff;
    font-size: 1.4rem;
    font-weight: bold;
    letter-spacing: 0.5px;
}

.nav-brand:hover {
    text-decoration: none;
    opacity: 0.85;
}

.nav-links a {
    color: #fff;
    margin-left: 1.5rem;
    font-size: 0.95rem;
}

.nav-links a:hover {
    text-decoration: underline;
}

/* Hero */
.hero {
    text-align: center;
    padding: 4rem 1rem;
}

.hero h1 {
    font-size: 3rem;
    color: #2a6496;
    margin-bottom: 0.5rem;
}

.tagline {
    font-size: 1.15rem;
    color: #666;
    margin-bottom: 2rem;
}

/* Search */
.search-form {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    margin-bottom: 2rem;
}

.search-input {
    width: 100%;
    max-width: 480px;
    padding: 0.6rem 1rem;
    font-size: 1rem;
    border: 1px solid #ccc;
    border-radius: 4px;
}

/* Buttons */
.btn {
    padding: 0.6rem 1.2rem;
    font-size: 1rem;
    border: none;
    border-radius: 4px;
    cursor: pointer;
}

.btn-primary {
    background-color: #2a6496;
    color: #fff;
}

.btn-primary:hover {
    background-color: #1e4d72;
}

/* Alerts */
.alert {
    padding: 0.75rem 1rem;
    border-radius: 4px;
    margin-bottom: 1rem;
}

.alert-success {
    background-color: #dff0d8;
    color: #3c763d;
    border: 1px solid #d6e9c6;
}

.alert-error {
    background-color: #f2dede;
    color: #a94442;
    border: 1px solid #ebccd1;
}

/* Auth forms */
.auth-form {
    max-width: 420px;
    margin: 3rem auto;
}

.auth-form h2 {
    margin-bottom: 1.5rem;
}

.form-group {
    margin-bottom: 1.2rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.3rem;
    font-weight: bold;
    font-size: 0.95rem;
}

.form-group input {
    width: 100%;
    padding: 0.6rem 0.8rem;
    font-size: 1rem;
    border: 1px solid #ccc;
    border-radius: 4px;
}

.auth-switch {
    margin-top: 1rem;
    font-size: 0.9rem;
    color: #666;
}

/* Search results */
.results-list {
    list-style: none;
    margin-top: 1rem;
}

.results-list li {
    padding: 0.75rem 0;
    border-bottom: 1px solid #eee;
}

.result-meta {
    display: block;
    font-size: 0.85rem;
    color: #888;
    margin-top: 0.2rem;
}

/* Person profile */
.person-header {
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid #eee;
}

.person-header h2 {
    font-size: 1.8rem;
    color: #2a6496;
}

.person-title {
    font-size: 1rem;
    color: #555;
    margin-top: 0.3rem;
}

.person-institution {
    font-size: 1rem;
    color: #555;
}

.person-details {
    margin-bottom: 2rem;
}

.person-details p {
    margin-bottom: 0.5rem;
}

h3 {
    margin: 1.5rem 0 0.75rem;
    font-size: 1.1rem;
    color: #333;
}

/* Wizard */
.wizard-steps {
    display: flex;
    gap: 1rem;
    margin-bottom: 2rem;
}

.wizard-step {
    padding: 0.4rem 1rem;
    border-radius: 4px;
    font-size: 0.9rem;
    background-color: #eee;
    color: #888;
}

.wizard-step.active {
    background-color: #2a6496;
    color: #fff;
}

.wizard-step.done {
    background-color: #dff0d8;
    color: #3c763d;
}

/* Form layout */
.form-intro {
    color: #666;
    margin-bottom: 1.5rem;
}

.form-hint {
    color: #888;
    font-style: italic;
}

fieldset {
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 1.2rem;
    margin-bottom: 1.5rem;
}

legend {
    font-weight: bold;
    font-size: 0.95rem;
    padding: 0 0.5rem;
    color: #444;
}

.form-row {
    display: flex;
    gap: 1rem;
}

.form-row .form-group {
    flex: 1;
}

.form-group select {
    width: 100%;
    padding: 0.6rem 0.8rem;
    font-size: 1rem;
    border: 1px solid #ccc;
    border-radius: 4px;
    background-color: #fff;
}

.form-group textarea {
    width: 100%;
    padding: 0.6rem 0.8rem;
    font-size: 1rem;
    border: 1px solid #ccc;
    border-radius: 4px;
    resize: vertical;
}

.field-hint {
    font-size: 0.85rem;
    color: #888;
    font-weight: normal;
}

.char-count {
    font-size: 0.8rem;
    color: #888;
    display: block;
    text-align: right;
}

.form-actions {
    display: flex;
    gap: 1rem;
    margin-top: 1.5rem;
}

.btn-secondary {
    background-color: #eee;
    color: #444;
}

.btn-secondary:hover {
    background-color: #ddd;
}

/* Advisor results */
.advisor-results li {
    padding: 0.75rem 0;
    border-bottom: 1px solid #eee;
}

.advisor-results label {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    cursor: pointer;
}

.advisor-results input[type="radio"] {
    margin-top: 0.2rem;
    flex-shrink: 0;
}

/* Unconfirmed badge */
.badge-unconfirmed {
    display: inline-block;
    font-size: 0.72rem;
    padding: 0.15rem 0.5rem;
    border-radius: 3px;
    background-color: #fcf8e3;
    color: #8a6d3b;
    border: 1px solid #faebcc;
    margin-left: 0.5rem;
    vertical-align: middle;
    font-style: normal;
}

/* Tree */
.tree-node {
    display: flex;
    align-items: center;
    margin-bottom: 6px;
    white-space: nowrap;
    position: relative;
}

.tree-indent {
    flex-shrink: 0;
    position: relative;
    align-self: stretch;
}

.tree-spine {
    position: absolute;
    top: 0;
    bottom: -6px;
    left: 12px;
    width: 2px;
}

.tree-spine.last {
    bottom: 50%;
}

.tree-branch {
    position: absolute;
    top: 50%;
    left: 12px;
    width: calc(100% - 12px);
    height: 2px;
    margin-top: -1px;
}

.tree-card {
    width: 220px;
    flex-shrink: 0;
    border-radius: 8px;
    padding: 7px 10px;
    overflow: hidden;
    margin-left: 0;
    cursor: pointer;
}

.line-confirmed {
    background: #185fa5;
}

.line-unconfirmed {
    background: #854f0b;
}

.tree-card.focal-verified {
    background: #185fa5;
    border: 1.5px solid #0c447c;
}

.tree-card.focal-unverified {
    background: #c87941;
    border: 1.5px solid #854f0b;
}

.tree-card.confirmed {
    background: #e6f1fb;
    border: 0.5px solid #185fa5;
}

.tree-card.unconfirmed {
    background: #e6f1fb;
    border: 0.5px solid #185fa5;
}

.tree-name {
    font-size: 13px;
    font-weight: bold;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tree-name.focal-verified { color: #fff; }
.tree-name.focal-unverified { color: #fff; }
.tree-name.confirmed { color: #0c447c; }
.tree-name.unconfirmed { color: #0c447c; }

.tree-sub {
    font-size: 11px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tree-sub.focal-verified { color: #b5d4f4; }
.tree-sub.focal-unverified { color: #faeeda; }
.tree-sub.confirmed { color: #185fa5; }
.tree-sub.unconfirmed { color: #185fa5; }

.tree-expander {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #185fa5;
    border: 0.5px solid #0c447c;
    color: #fff;
    font-size: 11px;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    margin-left: 8px;
    align-self: center;
    user-select: none;
}

.tree-expander.collapsed { background: #378add; }

/* Legend */
.tree-legend {
    display: flex;
    gap: 1.5rem;
    margin-top: 1.5rem;
    font-size: 0.85rem;
    color: #666;
    flex-wrap: wrap;
    align-items: center;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.legend-swatch {
    width: 14px;
    height: 14px;
    border-radius: 3px;
    flex-shrink: 0;
}

.legend-swatch.focal-verified { background: #185fa5; border: 1.5px solid #0c447c; }
.legend-swatch.focal-unverified { background: #c87941; border: 1.5px solid #854f0b; }

.legend-line {
    width: 28px;
    height: 3px;
    border-radius: 2px;
    flex-shrink: 0;
}

.legend-line.line-confirmed { background: #185fa5; }
.legend-line.line-unconfirmed { background: #854f0b; }

/* Admin */
.admin-stats {
    display: flex;
    gap: 1.5rem;
    flex-wrap: wrap;
    margin-bottom: 2rem;
}

.stat-card {
    background: #f0f6fd;
    border: 0.5px solid #b5d4f4;
    border-radius: 8px;
    padding: 1.2rem 1.5rem;
    min-width: 140px;
    text-align: center;
}

.stat-number {
    font-size: 2.2rem;
    font-weight: bold;
    color: #185fa5;
}

.stat-label {
    font-size: 0.85rem;
    color: #666;
    margin-bottom: 0.5rem;
}

.admin-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.admin-table th {
    text-align: left;
    padding: 0.6rem 0.8rem;
    background: #f0f6fd;
    border-bottom: 2px solid #b5d4f4;
    color: #185fa5;
    font-weight: bold;
}

.admin-table td {
    padding: 0.6rem 0.8rem;
    border-bottom: 1px solid #eee;
    vertical-align: middle;
}

.admin-table tr:hover td {
    background: #fafcff;
}

.btn-action {
    display: inline-block;
    padding: 0.25rem 0.6rem;
    border-radius: 4px;
    font-size: 0.8rem;
    border: none;
    cursor: pointer;
    text-decoration: none;
    margin-right: 0.3rem;
}

.btn-approve {
    background: #dff0d8;
    color: #3c763d;
    border: 1px solid #d6e9c6;
}

.btn-approve:hover { background: #c8e5b8; }

.btn-reject {
    background: #f2dede;
    color: #a94442;
    border: 1px solid #ebccd1;
}

.btn-reject:hover { background: #e8c8c8; }

.btn-edit {
    background: #f0f6fd;
    color: #185fa5;
    border: 1px solid #b5d4f4;
}

.btn-edit:hover { background: #dceefa; }

/* Connection badges */
.badge-confirmed {
    display: inline-block;
    font-size: 0.72rem;
    padding: 0.15rem 0.5rem;
    border-radius: 3px;
    background-color: #dff0d8;
    color: #3c763d;
    border: 1px solid #d6e9c6;
    margin-left: 0.5rem;
    vertical-align: middle;
}

.badge-flagged {
    display: inline-block;
    font-size: 0.72rem;
    padding: 0.15rem 0.5rem;
    border-radius: 3px;
    background-color: #f2dede;
    color: #a94442;
    border: 1px solid #ebccd1;
    margin-left: 0.5rem;
    vertical-align: middle;
}

.connection-list {
    list-style: none;
    margin-top: 0.5rem;
}

.connection-list li {
    padding: 0.5rem 0;
    border-bottom: 1px solid #eee;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Advisor search results box */
.results-box {
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 1.5rem;
    max-height: 300px;
    overflow-y: auto;
}

.add-new-section {
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 1rem;
}

.add-new-toggle {
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Co-advisor tree node */
.tree-card.co-advisor-group {
    width: 280px;
    background: #f0f0f0;
    border: 1.5px solid #888;
    cursor: default;
}

.co-advisor-header {
    font-size: 11px;
    font-weight: bold;
    color: #555;
    margin-bottom: 4px;
}

.co-advisor-tooltip-trigger {
    cursor: help;
    color: #555;
    font-weight: bold;
}

.co-advisor-name {
    display: inline;
    font-size: 12px;
    font-weight: bold;
    color: #333;
    text-decoration: none;
}

.co-advisor-name:hover {
    text-decoration: underline;
}

.co-advisor-sep {
    font-size: 12px;
    color: #666;
}

/* Co-advised note on profile pages */
.co-advised-note {
    font-size: 0.8rem;
    color: #888;
    margin-left: 0.5rem;
}

.co-advised-note a {
    color: #666;
}

/* You tag in tree */
.you-tag {
    font-size: 0.65rem;
    font-weight: normal;
    padding: 0.1rem 0.35rem;
    border-radius: 3px;
    background-color: rgba(255,255,255,0.25);
    color: inherit;
    opacity: 0.85;
    white-space: nowrap;
}

/* Verified checkmark badge */
.verified-checkmark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 15px;
    height: 15px;
    border-radius: 50%;
    background: #fff;
    flex-shrink: 0;
}

.verified-checkmark svg {
    width: 10px;
    height: 10px;
    display: block;
}

/* Larger checkmark for profile page h2 */
.person-header .verified-checkmark {
    width: 24px;
    height: 24px;
}

.person-header .verified-checkmark svg {
    width: 16px;
    height: 16px;
}

/* Invite landing page */
.invite-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin: 2rem 0;
}

.invite-or {
    color: var(--text-muted, #666);
    font-style: italic;
}

.invite-disclaimer {
    font-size: 0.875rem;
    color: var(--text-muted, #666);
    margin-top: 2rem;
    border-top: 1px solid #eee;
    padding-top: 1rem;
}

/* Footer */
.site-footer {
    text-align: center;
    padding: 1.5rem;
    margin-top: 3rem;
    border-top: 1px solid #eee;
    font-size: 0.875rem;
    color: #888;
    display: flex;
    justify-content: center;
    gap: 1.5rem;
    align-items: center;
}

.site-footer a {
    color: #888;
}

.site-footer a:hover {
    color: #2a6496;
}

/* Mobile nav */
.nav-mobile-right {
    display: none;
    align-items: center;
    gap: 1rem;
}

.nav-mobile-logout {
    color: #fff;
    font-size: 0.95rem;
}

.nav-mobile-logout:hover {
    text-decoration: underline;
}

.hamburger {
    background: none;
    border: none;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    gap: 5px;
    padding: 4px;
}

.hamburger span {
    display: block;
    width: 24px;
    height: 2px;
    background: #fff;
    border-radius: 2px;
}

.drawer-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 100;
}

.drawer-backdrop.open {
    display: block;
}

.drawer {
    position: fixed;
    top: 0;
    right: 0;
    width: 72%;
    max-width: 320px;
    height: 100%;
    background: #2a6496;
    z-index: 101;
    transform: translateX(100%);
    transition: transform 0.25s ease;
    padding: 1.5rem;
    box-shadow: -4px 0 16px rgba(0,0,0,0.3);
}

.drawer.open {
    transform: translateX(0);
}

.drawer-close {
    background: none;
    border: none;
    color: #fff;
    font-size: 1.4rem;
    cursor: pointer;
    display: block;
    margin-left: auto;
    margin-bottom: 1.5rem;
    padding: 0;
}

.drawer-nav {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.drawer-nav a {
    color: #fff;
    font-size: 1.1rem;
    padding: 0.85rem 0;
    border-bottom: 1px solid rgba(255,255,255,0.15);
    text-decoration: none;
}

.drawer-nav a:hover {
    text-decoration: underline;
}

@media (max-width: 600px) {
    #nav-links-desktop {
        display: none;
    }
    .nav-mobile-right {
        display: flex;
    }
}

/* Lineage tree card on profile page */
.tree-card-link {
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    flex-shrink: 0;
    width: 80px;
    padding: 0.5rem 0.4rem;
    background: #2a6496;
    color: #fff;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: bold;
    line-height: 1.3;
    text-decoration: none;
}

.tree-card-link:hover {
    background: #1e4d72;
    text-decoration: none;
    color: #fff;
}

/* Admin stats rows */
.admin-stats-rows {
    margin-bottom: 2rem;
    border: 1px solid #e0ecf8;
    border-radius: 8px;
    overflow: hidden;
}

.stat-row {
    display: flex;
    align-items: center;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid #e0ecf8;
    gap: 1rem;
}

.stat-row:last-child {
    border-bottom: none;
}

.stat-row:hover {
    background: #f5f9ff;
}

.stat-row-sub {
    padding-top: 0.4rem;
    padding-bottom: 0.4rem;
    background: #fafcff;
}

.stat-row-number {
    font-size: 1.4rem;
    font-weight: bold;
    color: #185fa5;
    width: 2.5rem;
    text-align: right;
    flex-shrink: 0;
}

.stat-row-label {
    flex: 1;
    color: #444;
    font-size: 0.95rem;
}

.stat-row-link {
    font-size: 0.85rem;
    color: #2a6496;
    flex-shrink: 0;
    min-width: 4rem;
    text-align: right;
}

.admin-lock-link {
    font-size: 0.85rem;
    color: #888;
}

.admin-lock-link:hover {
    color: #a94442;
}