:root {
    --primary: #0040D0;
    --primary-dark: #011081;
    --primary-soft: #E0E8FB;
    --teal: #00C0F0;
    --bg: #F4F7FF;
    --card: #FFFFFF;
    --text: #0E1F2C;
    --text-secondary: #5E6E7C;
    --text-tertiary: #9DAAB5;
    --border: #DDE3F0;
    --destructive: #FF3B30;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }
.muted { color: var(--text-secondary); }
.small { font-size: 13px; }
.error {
    background: rgba(255,59,48,0.1);
    border: 1px solid rgba(255,59,48,0.3);
    color: var(--destructive);
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 14px;
    margin: 12px 0;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 24px;
    background: linear-gradient(135deg, #011081 0%, #0040D0 100%);
    color: white;
    box-shadow: 0 2px 12px rgba(14,31,44,0.08);
}
.topbar .brand {
    display: flex;
    align-items: center;
    gap: 12px;
}
.topbar .brand img {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    object-fit: cover;
}
.topbar .brand strong { display: block; font-size: 16px; }
.topbar .brand span { display: block; font-size: 12px; opacity: 0.8; letter-spacing: 1px; text-transform: uppercase; }

.user-strip {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 13px;
}

button {
    font-family: inherit;
    font-size: 15px;
    border: none;
    cursor: pointer;
    border-radius: 10px;
    padding: 10px 18px;
    font-weight: 600;
    transition: opacity 0.15s, transform 0.05s;
}
button:active { transform: scale(0.98); }
button:disabled { opacity: 0.4; cursor: not-allowed; }
button.primary {
    background: var(--primary);
    color: white;
}
button.primary:hover:not(:disabled) { opacity: 0.9; }
button.ghost {
    background: rgba(255,255,255,0.15);
    color: white;
}

.auth-view {
    min-height: calc(100vh - 64px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.card {
    background: var(--card);
    border-radius: 16px;
    padding: 32px;
    box-shadow: 0 4px 24px rgba(14,31,44,0.06);
    width: 100%;
    max-width: 420px;
}
.card h1 {
    font-size: 24px;
    margin-bottom: 6px;
}
.card p.muted {
    margin-bottom: 24px;
    font-size: 14px;
}

label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 16px;
}
label.row {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 8px;
    font-weight: 500;
    color: var(--text);
}
label.row input {
    width: auto;
    margin: 0;
}

input[type=text],
input[type=email],
input[type=password],
input[type=number],
input[type=datetime-local],
input[type=date],
textarea,
select {
    width: 100%;
    margin-top: 6px;
    padding: 10px 12px;
    font-size: 15px;
    color: var(--text);
    background: white;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-family: inherit;
}
input:focus, textarea:focus, select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(0,64,208,0.1);
}
textarea { resize: vertical; min-height: 88px; }

.form-view {
    max-width: 720px;
    margin: 32px auto;
    padding: 0 24px 80px;
}
.form-view h1 {
    font-size: 28px;
    margin-bottom: 4px;
}
.form-view > p.muted {
    margin-bottom: 24px;
    font-size: 14px;
}
.form-view section {
    background: var(--card);
    border-radius: 14px;
    padding: 22px;
    margin-bottom: 16px;
    box-shadow: 0 2px 10px rgba(14,31,44,0.04);
}
.form-view section h2 {
    font-size: 16px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.6px;
    margin-bottom: 14px;
}

.actions {
    display: flex;
    justify-content: flex-end;
    margin-top: 8px;
}

.map {
    width: 100%;
    height: 320px;
    border-radius: 10px;
    margin-top: 6px;
    border: 1px solid var(--border);
    overflow: hidden;
}

.suggestions {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    padding: 8px 0;
    scrollbar-width: thin;
}
.suggestions .suggestion {
    flex: 0 0 auto;
    width: 130px;
    height: 90px;
    border-radius: 10px;
    overflow: hidden;
    cursor: pointer;
    border: 3px solid transparent;
    position: relative;
    transition: transform 0.1s;
}
.suggestions .suggestion:hover { transform: translateY(-2px); }
.suggestions .suggestion img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.suggestions .suggestion.selected {
    border-color: var(--primary);
    box-shadow: 0 4px 14px rgba(0,64,208,0.25);
}
.suggestions .suggestion .check {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: white;
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 700;
    opacity: 0;
}
.suggestions .suggestion.selected .check { opacity: 1; }
.suggestions .placeholder {
    width: 130px;
    height: 90px;
    background: linear-gradient(135deg, var(--primary-soft), white);
    border-radius: 10px;
    flex: 0 0 auto;
    animation: pulse 1.5s ease-in-out infinite;
}
@keyframes pulse {
    0%, 100% { opacity: 0.6; }
    50% { opacity: 1; }
}

.attribution {
    margin-top: 8px;
    font-size: 12px;
}
.attribution a {
    color: var(--primary);
    text-decoration: none;
}
.attribution a:hover { text-decoration: underline; }

/* ----- AI suggestions panel ----- */
.ai-section {
    background: linear-gradient(135deg, var(--primary-soft), white);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 22px;
    margin-bottom: 16px;
    box-shadow: 0 2px 10px rgba(14,31,44,0.04);
}
.ai-section h2 {
    font-size: 16px;
    color: var(--primary-dark);
    text-transform: uppercase;
    letter-spacing: 0.6px;
    margin-bottom: 14px;
}
.ai-controls {
    display: flex;
    gap: 10px;
    margin-bottom: 14px;
}
.ai-controls input {
    flex: 1;
    margin: 0;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: white;
    font-size: 14px;
}
.ai-controls input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(0,64,208,0.1);
}
.ai-controls button { flex-shrink: 0; }

.ai-results {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 10px;
}
.ai-card {
    background: white;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 14px;
    cursor: pointer;
    transition: border-color 0.15s, transform 0.05s, box-shadow 0.15s;
    text-align: left;
    font-family: inherit;
    color: inherit;
}
.ai-card:hover {
    border-color: var(--primary);
    box-shadow: 0 4px 14px rgba(0,64,208,0.12);
    transform: translateY(-1px);
}
.ai-card .name {
    font-size: 15px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 2px;
}
.ai-card .country {
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 8px;
}
.ai-card .meta {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 8px;
}
.ai-card .meta-pill {
    font-size: 11px;
    font-weight: 600;
    padding: 3px 8px;
    border-radius: 999px;
    background: var(--primary-soft);
    color: var(--primary-dark);
}
.ai-card .meta-pill.level { background: rgba(0,192,240,0.15); color: #006a85; }
.ai-card .description {
    font-size: 13px;
    color: var(--text);
    line-height: 1.45;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.ai-loading {
    grid-column: 1 / -1;
    text-align: center;
    padding: 20px;
    font-size: 14px;
    color: var(--text-secondary);
}
