:root {
    color-scheme: light;
    --bg: #ffffff;
    --line: #edf1f7;
    --line-dark: #e4e9f2;
    --text: #516079;
    --heading: #445169;
    --muted: #8c97aa;
    --blue: #2f64d9;
    --blue-dark: #2c5ed2;
    --header: #fdfdff;
    --soft: #f7f9fd;
    --danger: #ff6363;
    --green: #21c789;
    --card: #ffffff;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
    font-size: 15px;
    letter-spacing: .01em;
}

a {
    color: var(--blue);
}

.app-shell {
    width: 100%;
    min-height: 100vh;
    overflow: hidden;
    border-top: 2px solid #3c4660;
}

.topbar {
    min-height: 75px;
    border-bottom: 1px solid var(--line);
    display: flex;
    align-items: center;
    padding: 0 28px;
    gap: 28px;
    background: #fff;
}

.brand {
    display: flex;
    align-items: center;
    min-width: 120px;
    gap: 12px;
}

.brand-link {
    display: inline-flex;
    align-items: center;
    text-decoration: none;
}

.brand-logo {
    display: block;
    height: 75px;
    width: auto;
    max-width: 120px;
}

.topnav {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
    height: 100%;
}

.topnav-link,
.nav-dropdown summary,
.button,
button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 40px;
    padding: 0 16px;
    border: 1px solid transparent;
    border-radius: 10px;
    background: transparent;
    color: #4e596f;
    text-decoration: none;
    font-weight: 600;
    cursor: pointer;
}

.topnav-link:hover,
.nav-dropdown summary:hover,
.topnav-link.is-active,
.nav-dropdown summary.is-active {
    background: #f2f5fb;
    color: var(--blue);
}

.nav-dropdown {
    position: relative;
}

.nav-dropdown summary {
    list-style: none;
}

.nav-dropdown summary::-webkit-details-marker {
    display: none;
}

.nav-dropdown-menu {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    min-width: 180px;
    background: var(--card);
    border: 1px solid var(--line-dark);
    border-radius: 14px;
    box-shadow: 0 12px 30px rgba(18, 32, 51, 0.12);
    padding: 8px;
    display: grid;
    gap: 8px;
    z-index: 20;
}

.nav-dropdown-menu a {
    display: block;
    padding: 10px 12px;
    border-radius: 10px;
    text-decoration: none;
    color: var(--text);
    background: #fff;
}

.nav-dropdown-menu a:hover {
    background: #f7f9fd;
}

.top-actions {
    display: flex;
    align-items: center;
    gap: 14px;
}

.icon-button {
    width: 40px;
    min-height: 40px;
    border-radius: 10px;
    background: #f2f5fb;
    color: #7f8aa0;
    border: 1px solid var(--line-dark);
}

.profile-pill {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    border: 1px solid var(--line-dark);
    border-radius: 999px;
    background: #fff;
}

.profile-pill.is-active,
.profile-pill:hover {
    background: #f7f9fd;
}

.profile-dropdown {
    position: relative;
}

.profile-dropdown summary {
    list-style: none;
    cursor: pointer;
}

.profile-dropdown summary::-webkit-details-marker {
    display: none;
}

.profile-dropdown-menu {
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    min-width: 220px;
    background: var(--card);
    border: 1px solid var(--line-dark);
    border-radius: 16px;
    box-shadow: 0 12px 30px rgba(18, 32, 51, 0.12);
    padding: 10px;
    display: grid;
    gap: 6px;
    z-index: 30;
}

.profile-dropdown-menu a,
.profile-dropdown-label {
    display: block;
    padding: 10px 12px;
    border-radius: 10px;
}

.profile-dropdown-menu a {
    text-decoration: none;
    color: var(--text);
    background: #fff;
    font-weight: 600;
}

.profile-dropdown-menu a:hover,
.profile-dropdown-menu a.is-active {
    background: #f7f9fd;
    color: var(--blue);
}

.profile-dropdown-label {
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .08em;
}

.profile-dropdown-divider {
    height: 1px;
    background: var(--line-dark);
    margin: 4px 2px;
}

.profile-dropdown-logout {
    color: #b42318 !important;
}

.profile-dropdown-logout:hover {
    background: #fff3f2 !important;
    color: #b42318 !important;
}

.avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: radial-gradient(circle at 55% 34%, #ffd2c7 0 22%, transparent 23%), linear-gradient(135deg, #6ca9ef, #e8668a);
    box-shadow: inset 0 -4px 0 rgba(36, 59, 107, .16);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-weight: 800;
    font-size: 14px;
}

.profile-name {
    color: var(--heading);
    font-weight: 600;
    font-size: 14px;
}

.profile-meta {
    color: var(--muted);
    font-size: 12px;
}

.page-body {
    width: 100%;
}

body.auth-page {
    background: linear-gradient(180deg, #f7f9fd 0%, #eef3fb 100%);
}

.auth-page .topbar {
    justify-content: center;
}

.auth-page .brand {
    min-width: 0;
}

.auth-page .topnav,
.auth-page .top-actions {
    display: none;
}

.auth-layout {
    min-height: calc(100vh - 77px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 32px 16px 48px;
}

.auth-card {
    width: min(100%, 420px);
    background: #fff;
    border: 1px solid var(--line-dark);
    border-radius: 22px;
    box-shadow: 0 24px 50px rgba(40, 57, 88, 0.08);
    padding: 28px;
}

.auth-card h1 {
    margin: 0 0 8px;
    color: var(--heading);
}

.auth-card p {
    margin: 0 0 22px;
    color: var(--muted);
}

.auth-card .actions {
    margin-top: 20px;
    justify-content: stretch;
}

.auth-card .actions .button,
.auth-card .actions button {
    width: 100%;
}

.page-title-row {
    min-height: 78px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    padding: 20px 28px 10px;
}

.page-title-row-tools-only {
    min-height: auto;
    padding-top: 16px;
    padding-bottom: 0;
}

.page-content {
    padding: 0 28px 28px;
}

body.dashboard-page,
body.dashboard-page .app-shell {
    height: 100vh;
}

body.dashboard-page .page-body {
    height: calc(100vh - 77px);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

body.dashboard-page .page-content {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

h1,
h2,
h3 {
    margin: 0;
    color: var(--heading);
}

h1 {
    font-size: 28px;
    font-weight: 500;
}

h2 {
    font-size: 21px;
    font-weight: 600;
    margin-bottom: 8px;
}

.eyebrow {
    text-transform: uppercase;
    letter-spacing: .08em;
    font-size: 12px;
    color: var(--blue);
    font-weight: 700;
    margin: 0 0 6px;
}

.page-tools {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.view-toggle {
    display: inline-flex;
    min-height: 46px;
    border: 1px solid var(--line-dark);
    border-radius: 14px;
    overflow: hidden;
    background: #fafbfe;
}

.view-toggle a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 130px;
    padding: 0 18px;
    text-decoration: none;
    color: #92a0b6;
    font-weight: 600;
}

.view-toggle a.is-active {
    color: var(--blue);
    background: #f2f5fb;
}

.button,
button {
    background: var(--blue);
    color: #fff;
}

.button:hover,
button:hover {
    background: var(--blue-dark);
}

.button-secondary {
    background: #fff;
    color: var(--text);
    border: 1px solid var(--line-dark);
}

.button-secondary:hover {
    background: #f7f9fd;
}

.button-disabled {
    background: #f2f5fc;
    color: #97a5bd;
    border: 1px solid var(--line-dark);
    cursor: not-allowed;
}

.card {
    background: var(--card);
    border: 1px solid var(--line-dark);
    border-radius: 18px;
    padding: 20px;
    margin-bottom: 20px;
}

.dashboard-filter-bar {
    display: grid;
    grid-template-columns: 2.4fr repeat(4, minmax(140px, 1fr));
    gap: 16px;
    align-items: end;
}

.field-wide {
    grid-column: span 1;
}

.field {
    grid-column: span 1;
}

.field-actions {
    grid-column: 1 / -1;
}

label {
    display: block;
    font-weight: 600;
    margin-bottom: 8px;
    color: #66738a;
}

input,
select,
textarea {
    width: 100%;
    min-height: 42px;
    padding: 10px 12px;
    border-radius: 10px;
    border: 1px solid var(--line-dark);
    background: #fff;
    color: var(--text);
    font: inherit;
}

.dashboard-meta,
.search-meta,
.pagination,
.actions {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: center;
    flex-wrap: wrap;
}

.filter-actions {
    justify-content: flex-end;
    align-items: flex-end;
}

.inline-toggle {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    min-height: 42px;
    padding: 0 14px;
    border: 1px solid var(--line-dark);
    border-radius: 999px;
    background: #fff8d9;
    color: #8a6500;
    font-weight: 700;
    margin-bottom: 0;
}

.inline-toggle input {
    width: 16px;
    min-height: auto;
    margin: 0;
}

.inline-toggle span {
    display: inline-block;
}

.dashboard-summary {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
}

.summary-pill {
    padding: 10px 14px;
    border-radius: 999px;
    background: var(--soft);
    color: var(--heading);
    border: 1px solid var(--line-dark);
}

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

table {
    width: 100%;
    border-collapse: collapse;
    table-layout: auto;
    border-top: 1px solid var(--line-dark);
}

th,
td {
    padding: 16px 12px;
    border-bottom: 1px solid var(--line);
    text-align: left;
    vertical-align: top;
    white-space: nowrap;
}

th {
    color: #7e8ba3;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .05em;
    background: #fbfcff;
    font-weight: 600;
}

#dashboard-results {
    margin-top: 20px;
}

body.dashboard-page .dashboard-results-card {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

body.dashboard-page #dashboard-results {
    flex: 1;
    min-height: 0;
    overflow: auto;
}

body.dashboard-page #dashboard-results .table-wrap {
    max-height: 100%;
    overflow: auto;
}

body.dashboard-page #dashboard-results thead th {
    position: sticky;
    top: 0;
    z-index: 5;
}

td {
    color: #52617b;
}

tbody tr:hover {
    background: #f8fbff;
}

.badge {
    display: inline-block;
    padding: 6px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
    background: #eef4ff;
    color: var(--blue);
}

.project-type-clamp {
    display: -webkit-box;
    max-width: 58ch;
    overflow: hidden;
    white-space: normal;
    line-clamp: 3;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    line-height: 1.35;
}

.flash {
    margin: 0 28px 18px;
    padding: 12px 14px;
    border-radius: 12px;
}

.flash-success {
    background: #e8f7ef;
    color: #087443;
}

.flash-error {
    background: #fdecec;
    color: #b42318;
}

.muted {
    color: var(--muted);
}

.inline-form {
    display: inline;
}

.pagination-links {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.table-action {
    white-space: nowrap;
}

.action-buttons {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.icon-button {
    width: 38px;
    min-width: 38px;
    height: 38px;
    min-height: 38px;
    padding: 0;
    border: 0;
    border-radius: 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    font-weight: 700;
    box-shadow: inset 0 0 0 1px rgba(15, 23, 42, 0.06);
}

.icon-button-reanalyze {
    background: #e8f1ff;
    color: #1d4ed8;
}

.icon-button-reanalyze:hover {
    background: #d8e7ff;
}

.icon-button-hide {
    background: #ffe8e8;
    color: #c62828;
}

.icon-button-hide:hover {
    background: #ffd7d7;
}

.icon-button-star {
    background: #fff4bf;
    color: #c68a00;
}

.icon-button-star:hover,
.icon-button-star.is-active {
    background: #ffd95c;
    color: #8a6500;
}

.sort-button {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 0;
    min-height: 0;
    border: 0;
    background: transparent;
    color: inherit;
    text-transform: inherit;
    letter-spacing: inherit;
    font: inherit;
}

.sort-button:hover {
    background: transparent;
    color: var(--blue);
}

.sort-button.is-active {
    color: #5b6982;
}

.sort-indicator {
    position: relative;
    width: 10px;
    height: 16px;
    display: inline-block;
}

.sort-indicator::before,
.sort-indicator::after {
    content: "";
    position: absolute;
    left: 1px;
    border-left: 4px solid transparent;
    border-right: 4px solid transparent;
}

.sort-indicator::before {
    top: 0;
    border-bottom: 6px solid #d3dae7;
}

.sort-indicator::after {
    bottom: 0;
    border-top: 6px solid #d3dae7;
}

.sort-indicator.is-asc::before {
    border-bottom-color: var(--blue);
}

.sort-indicator.is-desc::after {
    border-top-color: var(--blue);
}

.dashboard-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 16px;
}

.result-card {
    border: 1px solid var(--line-dark);
    border-radius: 18px;
    padding: 18px;
    background: #fff;
    display: grid;
    gap: 14px;
}

.result-card-header,
.result-card-actions,
.result-grid {
    display: grid;
    gap: 12px;
}

.result-card-header {
    grid-template-columns: 1fr auto;
    align-items: start;
}

.result-company {
    color: var(--blue);
    font-size: 18px;
    font-weight: 600;
}

.result-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.result-item {
    display: grid;
    gap: 4px;
}

.result-item strong {
    color: var(--heading);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .05em;
}

.stack {
    display: grid;
    gap: 16px;
}

.checkbox-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 10px;
}

.checkbox-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    border: 1px solid var(--line-dark);
    border-radius: 10px;
    background: #fff;
}

.checkbox-item input {
    width: auto;
    margin: 0;
    min-height: auto;
}

.status-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
    margin-top: 16px;
}

.status-card {
    border: 1px solid var(--line-dark);
    border-radius: 14px;
    padding: 14px;
    background: #fff;
}

.progress-bar {
    width: 100%;
    height: 10px;
    background: #e9eef7;
    border-radius: 999px;
    overflow: hidden;
}

.progress-bar span {
    display: block;
    height: 100%;
    background: linear-gradient(90deg, var(--blue), #4f8cff);
}

.code-inline {
    display: inline-block;
    padding: 6px 10px;
    border-radius: 8px;
    background: #0f172a;
    color: #f8fafc;
    font-size: 13px;
    word-break: break-all;
}

@media (max-width: 1200px) {
    .dashboard-filter-bar {
        grid-template-columns: repeat(6, minmax(0, 1fr));
    }

    .field-wide,
    .field,
    .field-actions {
        grid-column: span 3;
    }
}

@media (max-width: 900px) {
    .topbar,
    .page-title-row,
    .page-content,
    .flash {
        padding-left: 18px;
        padding-right: 18px;
    }

    .topbar {
        flex-wrap: wrap;
        padding-top: 16px;
        padding-bottom: 16px;
    }

    .brand {
        min-width: auto;
        width: 100%;
    }

    .topnav {
        width: 100%;
        order: 3;
        flex-wrap: wrap;
    }

    .top-actions {
        margin-left: auto;
    }

    .page-title-row {
        flex-direction: column;
        align-items: flex-start;
    }

    .dashboard-filter-bar {
        grid-template-columns: 1fr;
    }

    .field-wide,
    .field,
    .field-actions {
        grid-column: auto;
    }

    .result-grid {
        grid-template-columns: 1fr;
    }
}
