:root {
    --layout-max-width: 1380px;
    --layout-padding: 1.35rem;
    --brand-primary: #0f3d6d;
    --brand-accent: #2563eb;
    --brand-accent-2: #7c3aed;
    --surface: #ffffff;
    --surface-muted: #eef2f7;
    --text: #0f172a;
    --muted: #475569;
    --border: #d7deea;
    --success: #15803d;
    --error: #b91c1c;
    --warning: #c2410c;
    --shadow: 0 16px 50px rgba(15, 23, 42, 0.12);
    color-scheme: light;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
    background: radial-gradient(circle at 20% 20%, rgba(124, 58, 237, 0.12), transparent 25%),
        radial-gradient(circle at 80% 10%, rgba(37, 99, 235, 0.12), transparent 30%),
        linear-gradient(180deg, #f8fafc 0%, #eef2f7 100%);
    color: var(--text);
    line-height: 1.6;
}

a { color: inherit; text-decoration: none; }

a.link { color: var(--brand-accent); font-weight: 600; }

.layout-container {
    max-width: var(--layout-max-width);
    width: 100%;
    margin: 0 auto;
    padding: 0 var(--layout-padding);
}

.app-header,
.app-footer {
    background: rgba(255, 255, 255, 0.9);
    color: var(--text);
    padding: 1rem 0;
    z-index: 1200;
    backdrop-filter: blur(10px);
}

.app-header {
    position: sticky;
    top: 0;
    border-bottom: 1px solid var(--border);
}

.app-footer {
    border-top: 1px solid var(--border);
}

.app-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
}

.footer-powered {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem;
    align-items: center;
    padding: 0 0 1rem;
}

.powered-by-text {
    display: grid;
    gap: 0.25rem;
    align-items: start;
}

.footer-heading {
    margin: 0;
    font-weight: 800;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    font-size: 0.9rem;
}

.footer-subtitle {
    margin: 0;
    color: var(--muted);
    font-weight: 600;
}

.footer-logo-strip {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 0.75rem;
    align-items: center;
    padding: 0 0 1rem;
}

.logo-tile {
    background: #ffffff;
    border: 1px solid var(--border);
    border-radius: 0.85rem;
    padding: 0.8rem 1rem;
    min-height: 72px;
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.06);
    display: grid;
    place-items: center;
}

.logo-tile img {
    max-width: 100%;
    max-height: 48px;
    width: auto;
    height: auto;
    display: block;
    object-fit: contain;
}

.footer-links {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-weight: 600;
}

.brand {
    display: flex;
    gap: 0.85rem;
    align-items: center;
}

.logo-mark {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    background: linear-gradient(135deg, var(--brand-accent), var(--brand-accent-2));
    display: grid;
    place-items: center;
    color: white;
    font-weight: 800;
    box-shadow: 0 10px 30px rgba(37, 99, 235, 0.25);
}

.brand-copy { display: flex; flex-direction: column; gap: 0.15rem; }

.eyebrow {
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin: 0;
    color: var(--muted);
    font-size: 0.75rem;
}

.headline {
    margin: 0;
    font-size: 1.2rem;
    font-weight: 700;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

a.ghost {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.65rem 1.1rem;
    border-radius: 0.85rem;
    border: 1px solid var(--border);
    font-weight: 700;
}

.user-menu {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.logout-form {
    margin: 0;
}

.user-badge {
    background: var(--surface-muted);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 0.5rem 0.75rem;
    border-radius: 0.75rem;
    font-weight: 700;
}

.page-shell {
    padding: 2rem 0 3rem;
    display: grid;
    gap: 1.5rem;
}

.hero {
    color: var(--text);
    padding: 1.75rem;
    border-radius: 1.25rem;
    box-shadow: var(--shadow);
    display: grid;
    gap: 1rem;
    position: relative;
}

.hero-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.hero-actions a {
    text-decoration: none;
}

.hero.gradient {
    background: linear-gradient(135deg, rgba(37, 99, 235, 0.08), rgba(124, 58, 237, 0.08)),
        linear-gradient(120deg, #e0f2fe 0%, #eef2ff 100%);
    border: 1px solid rgba(124, 58, 237, 0.1);
}

.hero h1 { margin: 0; font-size: 2.1rem; }
.hero p { margin: 0; color: var(--muted); }

.hero-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 0.75rem;
}

.surface {
    background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
    border-radius: 1.05rem;
    padding: 1.35rem;
    box-shadow: var(--shadow);
    border: 1px solid rgba(15, 61, 109, 0.08);
}

.section-header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
}

.section-title {
    margin: 0 0 0.75rem;
    font-size: 1.25rem;
    font-weight: 700;
}

.search-grid {
    display: grid;
    gap: 1rem;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 0.9rem;
}

.form-stack {
    display: grid;
    gap: 1rem;
}

label { display: block; font-weight: 700; margin-bottom: 0.35rem; }

input[type="text"],
input[type="email"],
input[type="password"],
input[type="url"],
select {
    width: 100%;
    padding: 0.75rem 0.85rem;
    border: 1px solid var(--border);
    border-radius: 0.85rem;
    font-size: 1rem;
    background: #f8fafc;
}

.actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
    align-items: center;
}

button {
    border: none;
    border-radius: 0.85rem;
    padding: 0.75rem 1.15rem;
    font-weight: 800;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    transition: transform 0.1s ease, box-shadow 0.1s ease;
}

button.primary {
    background: linear-gradient(120deg, var(--brand-accent), var(--brand-accent-2));
    color: white;
    box-shadow: 0 12px 30px rgba(37, 99, 235, 0.25);
}

button.ghost {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text);
}

button.secondary {
    background: rgba(37, 99, 235, 0.08);
    color: var(--brand-primary);
    border: 1px solid rgba(37, 99, 235, 0.16);
}

button:disabled { opacity: 0.6; cursor: not-allowed; box-shadow: none; }

button:not(:disabled):hover { transform: translateY(-1px); box-shadow: 0 12px 40px rgba(15, 23, 42, 0.12); }

.status-row { display: flex; gap: 0.75rem; align-items: center; flex-wrap: wrap; }
.table-actions { display: flex; gap: 0.75rem; align-items: center; flex-wrap: wrap; justify-content: flex-end; }

.pill {
    padding: 0.4rem 0.85rem;
    border-radius: 999px;
    font-weight: 700;
    border: 1px solid var(--border);
    background: #f8fafc;
    color: var(--muted);
}

.pill.success { border-color: rgba(22, 163, 74, 0.4); color: var(--success); }
.pill.error { border-color: rgba(220, 38, 38, 0.3); color: var(--error); }
.pill.warning { border-color: rgba(234, 88, 12, 0.4); color: var(--warning); }

.badge-row { display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: center; }

.ai-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.05rem 0.45rem;
    border-radius: 999px;
    border: 1px solid rgba(124, 58, 237, 0.25);
    background: rgba(124, 58, 237, 0.06);
    color: var(--brand-accent-2);
    font-size: 0.72rem;
    font-weight: 700;
    line-height: 1.2;
}

.ai-badge::before {
    content: "•";
    color: var(--brand-accent);
}


.map-card { position: relative; overflow: hidden; }
.map-header { align-items: flex-start; }
.map-actions { display: flex; gap: 0.5rem; align-items: center; }
.map-shell {
    transition: max-height 0.32s ease, opacity 0.32s ease, transform 0.32s ease;
    transform-origin: top right;
    max-height: 640px;
    overflow: hidden;
}
.map-card[data-collapsed="true"] .map-shell {
    max-height: 0;
    opacity: 0;
    transform: scale(0.96) translate(12px, -14px);
    pointer-events: none;
}

.map {
    border-radius: 1rem;
    border: 1px solid var(--border);
    min-height: 480px;
    width: 100%;
    height: 520px;
}

#map-canvas {
    min-height: 520px;
    height: 520px;
    width: 100%;
}

.map-fallback {
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
    color: var(--muted);
    text-align: center;
}

.map-legend {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.75rem;
}

.map-card[data-collapsed="true"] .map-legend {
    opacity: 0;
}

.table-card { overflow: hidden; }

.table-wrapper { overflow-x: auto; }

@media (min-width: 1100px) {
    .table-wrapper {
        overflow: visible;
    }
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.95rem;
}

table tbody tr {
    cursor: pointer;
    transition: background-color 0.15s ease, box-shadow 0.15s ease;
}

table tbody tr:focus-visible,
table tbody tr:hover {
    background: #f8fafc;
    box-shadow: inset 0 0 0 1px #e2e8f0;
}

table thead { background: #f1f5f9; }

table th, table td {
    padding: 0.75rem 0.6rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.table-link {
    display: inline-block;
    line-height: 1.4;
}

.contact-stack {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.contact-line {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    flex-wrap: wrap;
}

.contact-value {
    font-weight: 600;
}

.contact-value a {
    color: inherit;
    text-decoration: underline;
    text-decoration-color: rgba(37, 99, 235, 0.4);
    text-decoration-thickness: 2px;
    text-underline-offset: 3px;
}

.contact-value a:hover {
    color: var(--brand-accent);
}

table th {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--muted);
}

.score-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 52px;
    padding: 0.35rem 0.6rem;
    border-radius: 0.75rem;
    color: #fff;
    font-weight: 800;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
}

.score-badge.muted {
    background: #cbd5e1;
    color: #0f172a;
}

.insights-list {
    margin: 0.2rem 0 0;
    padding-left: 1.1rem;
    color: var(--text);
}

.insights-list li {
    margin-bottom: 0.15rem;
    line-height: 1.4;
}

.insights-block {
    display: grid;
    gap: 0.35rem;
}

.insight-note {
    padding: 0.55rem 0.6rem;
    border: 1px solid var(--border);
    border-radius: 0.75rem;
    background: #f8fafc;
}

.note-label {
    margin: 0 0 0.1rem;
    font-size: 0.85rem;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.note-body {
    margin: 0;
    font-weight: 600;
    line-height: 1.5;
}

.skill-list {
    margin: 0;
    padding-left: 1.1rem;
    display: grid;
    gap: 0.25rem;
    list-style: disc;
}

.badge {
    display: inline-block;
    padding: 0.35rem 0.6rem;
    border-radius: 0.65rem;
    background: #eef2ff;
    color: #4338ca;
    font-weight: 700;
    margin-right: 0.35rem;
}

.detail-card {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.detail-layout {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.meta-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 0.85rem;
}

.score-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1rem;
    align-items: flex-start;
}

.score-tile {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.score-badge.large {
    min-width: 80px;
    font-size: 1.1rem;
}

.meta-block {
    background: #f8fafc;
    border: 1px solid var(--border);
    border-radius: 0.85rem;
    padding: 0.85rem 1rem;
}

.meta-label {
    margin: 0;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--muted);
    font-size: 0.8rem;
}

.meta-value {
    margin: 0.25rem 0 0;
    font-weight: 700;
}

.detail-grid {
    display: grid;
    gap: 1rem;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}

.detail-header {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.detail-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    align-items: flex-start;
}

.detail-meta {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.detail-block {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    padding: 1rem;
    border: 1px solid var(--border);
    border-radius: 0.85rem;
    background: #f8fafc;
}

.detail-block h3 {
    margin: 0;
    font-size: 1rem;
}

.detail-description {
    white-space: normal;
    line-height: 1.6;
    display: grid;
    gap: 0.6rem;
}

.detail-description p {
    margin: 0;
}

.detail-description .bullet-list {
    margin: 0;
    padding-left: 1.25rem;
    list-style: disc;
    display: grid;
    gap: 0.35rem;
}

.loader {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: 3px solid rgba(255, 255, 255, 0.5);
    border-top-color: #fff;
    animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.helper-text { color: var(--muted); margin: 0; font-size: 0.95rem; }

.empty-state {
    text-align: center;
    padding: 1.25rem;
    color: var(--muted);
}

.auth-card {
    width: 100%;
    max-width: 520px;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.95) 0%, #ffffff 100%);
    border-radius: 1.4rem;
    padding: 1.65rem;
    border: 1px solid rgba(124, 58, 237, 0.1);
    box-shadow: var(--shadow);
}

.auth-header h1 { margin: 0.25rem 0; }

.auth-form { display: grid; gap: 1rem; }

.form-control { display: grid; gap: 0.35rem; }

.checkbox-row { grid-template-columns: auto 1fr; align-items: center; }

.validation { color: var(--error); font-weight: 600; font-size: 0.9rem; }

.logout-form { margin: 0; }

.auth-shell {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 1rem;
    align-items: stretch;
}

.auth-panel {
    background: linear-gradient(135deg, rgba(37, 99, 235, 0.1), rgba(124, 58, 237, 0.12)),
        radial-gradient(circle at 80% 20%, rgba(37, 99, 235, 0.12), transparent 40%),
        #0f172a;
    color: #e2e8f0;
    border-radius: 1.4rem;
    padding: 1.5rem;
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: var(--shadow);
    position: relative;
    overflow: hidden;
}

.auth-panel::after {
    content: "";
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at 20% 20%, rgba(255, 255, 255, 0.08), transparent 35%);
    pointer-events: none;
}

.auth-panel h2 { margin: 0.25rem 0; color: #fff; }

.feature-list {
    margin: 0.75rem 0 0;
    padding-left: 1.1rem;
    display: grid;
    gap: 0.25rem;
    color: #cbd5e1;
}

.feature-list li::marker { color: #a855f7; }

.auth-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.35rem 0.65rem;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: #e2e8f0;
    font-weight: 700;
}

.muted-on-dark {
    color: #cbd5e1;
    max-width: 420px;
}

.settings-card { margin-top: 1rem; }

.settings-grid {
    display: grid;
    gap: 1rem;
    align-items: start;
}

.table-actions { display: flex; gap: 0.75rem; align-items: center; flex-wrap: wrap; justify-content: flex-end; }

.modal { position: fixed; inset: 0; display: grid; place-items: center; z-index: 2000; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(15, 23, 42, 0.35); backdrop-filter: blur(4px); }
.modal-dialog {
    position: relative;
    max-width: 820px;
    width: min(92vw, 820px);
    background: var(--surface);
    border-radius: 1rem;
    box-shadow: var(--shadow);
    overflow: hidden;
    z-index: 1;
}
.modal-header,
.modal-footer { padding: 1.25rem 1.5rem; display: flex; align-items: center; gap: 1rem; justify-content: space-between; }
.modal-body { padding: 0 1.5rem 1.5rem; display: flex; flex-direction: column; gap: 1rem; }
.modal-header { border-bottom: 1px solid var(--border); }
.modal-footer { border-top: 1px solid var(--border); }
.wizard-step { display: block; }
.wizard-nav { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.wizard-nav .spacer { flex: 1; }
.option-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 0.75rem; }
.card-option {
    border: 1px solid var(--border);
    border-radius: 0.75rem;
    padding: 0.85rem;
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 0.75rem;
    align-items: center;
    cursor: pointer;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.card-option:hover { border-color: var(--brand-accent); box-shadow: 0 10px 30px rgba(37, 99, 235, 0.08); }
.card-option input { margin: 0; }
.step-content { display: block; }
.alert { border-radius: 0.75rem; border: 1px solid var(--border); padding: 0.85rem 1rem; background: #f8fafc; }
.alert.error { border-color: rgba(220, 38, 38, 0.35); color: var(--error); background: #fef2f2; }
.ghost.icon { font-size: 1.2rem; width: 2.5rem; height: 2.5rem; padding: 0; }
.modal-open { overflow: hidden; }
.console-output {
    background: #0f172a;
    color: #e2e8f0;
    font-family: ui-monospace, "SFMono-Regular", Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
    border: 1px solid var(--border);
    border-radius: 0.75rem;
    padding: 1rem;
    max-height: 420px;
    overflow: auto;
    white-space: pre-wrap;
    word-break: break-word;
}
#admin-console-status[data-variant="error"] {
    color: var(--error);
}

/* Ensure elements respect the `hidden` attribute even when they define their own display values. */
.modal[hidden],
.wizard-step[hidden],
.step-content[hidden] {
    display: none !important;
}

@media (max-width: 980px) {
    .grid-layout { grid-template-columns: 1fr; }
    .app-header, .app-footer { padding: 1rem 1.25rem; position: static; }
    .page-shell { padding: 1.25rem 1rem 2rem; }
}
