/* ResumeSync: one handwritten stylesheet. No build step. */

:root {
    --bg: #f4f6f8;
    --surface: #ffffff;
    --ink: #1b2430;
    --muted: #556070;
    --line: #d9dee5;
    --line-strong: #b8c0cb;
    --primary: #1d4ed8;
    --primary-ink: #ffffff;
    --primary-soft: #e8eefc;
    --success-bg: #e3f4e8;
    --success-ink: #14532d;
    --warning-bg: #fdf0d2;
    --warning-ink: #7a4a00;
    --danger-bg: #fde6e4;
    --danger-ink: #8f1d14;
    --info-bg: #e2eefb;
    --info-ink: #0f3d75;
    --neutral-bg: #e9edf2;
    --neutral-ink: #33404f;
    --mark: #fff0a8;
    --radius: 8px;
    --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
    --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font: 15px/1.5 var(--font);
}

h1, h2, h3 { line-height: 1.25; margin: 0 0 .5rem; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }
p { margin: 0 0 .75rem; }
a { color: var(--primary); }
a:hover { text-decoration-thickness: 2px; }
img, iframe { max-width: 100%; }
ul { margin: 0; padding: 0; }
dl { margin: 0; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }

:focus-visible {
    outline: 3px solid #f59e0b;
    outline-offset: 2px;
    border-radius: 3px;
}

.sr-only {
    position: absolute !important;
    width: 1px; height: 1px;
    margin: -1px; padding: 0;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.skip-link {
    position: absolute;
    left: .5rem; top: -4rem;
    background: var(--ink);
    color: #fff;
    padding: .6rem 1rem;
    border-radius: var(--radius);
    z-index: 100;
}
.skip-link:focus { top: .5rem; }

/* Top bar ------------------------------------------------------------- */

.topbar { background: var(--ink); color: #fff; }
.topbar__inner {
    max-width: 1280px;
    margin: 0 auto;
    padding: .5rem 1rem;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .5rem 1.5rem;
}
.brand { color: #fff; font-weight: 700; font-size: 1.1rem; text-decoration: none; letter-spacing: .01em; }
.brand--large { color: var(--ink); font-size: 1.5rem; text-align: center; display: block; margin-bottom: 1rem; }
.nav { display: flex; flex-wrap: wrap; gap: .25rem; flex: 1; }
.nav a {
    color: #dfe5ee;
    text-decoration: none;
    padding: .4rem .75rem;
    border-radius: 6px;
}
.nav a:hover { background: rgba(255, 255, 255, .12); color: #fff; }
.nav a.is-active { background: rgba(255, 255, 255, .18); color: #fff; }
.topbar__user { display: flex; align-items: center; gap: .75rem; }
.topbar__name { color: #dfe5ee; font-size: .9rem; }
.topbar .btn--ghost { color: #fff; border-color: rgba(255, 255, 255, .45); }
.topbar .btn--ghost:hover { background: rgba(255, 255, 255, .14); }

/* Page ---------------------------------------------------------------- */

.page { max-width: 1280px; margin: 0 auto; padding: 1.25rem 1rem 3rem; }
.page:focus { outline: none; }
.page-head {
    display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
    gap: .75rem; margin-bottom: 1rem;
}
.page-head h1 { margin: 0; }
.actions { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }

.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1rem 1.1rem;
    margin-bottom: 1rem;
}
.card__title { margin-bottom: .75rem; }
.grid-2 { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); align-items: start; }

.stats { display: grid; gap: .75rem; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); margin-bottom: 1rem; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: .9rem 1rem; box-shadow: var(--shadow); }
.stat__value { font-size: 1.75rem; font-weight: 700; margin: 0; line-height: 1.1; }
.stat__label { color: var(--muted); margin: .25rem 0 0; font-size: .875rem; }

.list { list-style: none; }
.list__row { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: .6rem 0; border-top: 1px solid var(--line); }
.list__row:first-child { border-top: 0; }

/* Buttons ------------------------------------------------------------- */

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
    font: inherit; font-weight: 600;
    padding: .5rem .95rem;
    border: 1px solid var(--line-strong);
    background: var(--surface);
    color: var(--ink);
    border-radius: 6px;
    cursor: pointer;
    text-decoration: none;
    line-height: 1.2;
}
.btn:hover { background: #eef1f5; }
.btn--primary { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.btn--primary:hover { background: #1a43b8; }
.btn--danger { background: #b42318; border-color: #b42318; color: #fff; }
.btn--danger:hover { background: #912018; }
.btn--ghost { background: transparent; }
.btn--sm { padding: .3rem .65rem; font-size: .875rem; }
.btn--block { width: 100%; }
.btn[disabled], .btn[aria-disabled="true"] { opacity: .55; cursor: not-allowed; }
.inline-form { display: inline; margin: 0; }

/* Forms --------------------------------------------------------------- */

.form { display: grid; gap: 1rem; }
.field { display: grid; gap: .3rem; }
.field label, .field .label { font-weight: 600; font-size: .9rem; }
.field--inline { display: flex; align-items: center; gap: .5rem; }
.field--inline label { font-weight: 400; }
.field__hint { color: var(--muted); font-size: .85rem; margin: 0; }
.field__error { color: var(--danger-ink); font-size: .875rem; margin: 0; font-weight: 600; }

input[type="text"], input[type="email"], input[type="password"], input[type="number"],
input[type="date"], input[type="search"], input[type="url"], select, textarea {
    width: 100%;
    font: inherit;
    padding: .5rem .65rem;
    border: 1px solid var(--line-strong);
    border-radius: 6px;
    background: #fff;
    color: var(--ink);
}
textarea { min-height: 6rem; resize: vertical; }
input[aria-invalid="true"] { border-color: #b42318; }
input[type="checkbox"], input[type="radio"] { width: 1.05rem; height: 1.05rem; accent-color: var(--primary); }
fieldset { border: 1px solid var(--line); border-radius: var(--radius); padding: .75rem 1rem 1rem; margin: 0; min-width: 0; }
legend { font-weight: 600; padding: 0 .35rem; }
.form-grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.form-actions { display: flex; gap: .5rem; flex-wrap: wrap; }

/* Login --------------------------------------------------------------- */

body.guest { display: grid; place-items: center; min-height: 100vh; padding: 1rem; }
.auth-card {
    width: 100%; max-width: 400px;
    background: var(--surface); border: 1px solid var(--line); border-radius: 12px;
    box-shadow: var(--shadow); padding: 1.75rem;
}
.auth-card:focus { outline: none; }
.auth-card__title { font-size: 1.2rem; text-align: center; margin-bottom: 1rem; }

/* Flash --------------------------------------------------------------- */

.flash { padding: .7rem 1rem; border-radius: var(--radius); margin-bottom: 1rem; border: 1px solid transparent; font-weight: 500; }
.flash--success { background: var(--success-bg); color: var(--success-ink); border-color: #b7dfc2; }
.flash--warning { background: var(--warning-bg); color: var(--warning-ink); border-color: #ecd49a; }
.flash--danger { background: var(--danger-bg); color: var(--danger-ink); border-color: #f1b8b3; }

/* Badges & chips ------------------------------------------------------ */

.badge {
    display: inline-block; padding: .1rem .55rem; border-radius: 999px;
    font-size: .78rem; font-weight: 600; line-height: 1.5; white-space: nowrap;
}
.badge--neutral { background: var(--neutral-bg); color: var(--neutral-ink); }
.badge--success { background: var(--success-bg); color: var(--success-ink); }
.badge--warning { background: var(--warning-bg); color: var(--warning-ink); }
.badge--danger { background: var(--danger-bg); color: var(--danger-ink); }
.badge--info { background: var(--info-bg); color: var(--info-ink); }

.chips { display: flex; flex-wrap: wrap; gap: .35rem; margin: 0; padding: 0; list-style: none; }
.chip {
    display: inline-flex; align-items: center; gap: .3rem;
    padding: .12rem .6rem; border-radius: 999px;
    background: var(--neutral-bg); color: var(--neutral-ink);
    font-size: .82rem; line-height: 1.5;
}
.chip__label { color: var(--muted); }
.chip--hl { background: var(--mark); color: #4a3b00; font-weight: 600; }
.chip__x {
    display: inline-grid; place-items: center;
    width: 1.25rem; height: 1.25rem; border-radius: 50%;
    color: var(--neutral-ink); text-decoration: none; font-size: 1rem; line-height: 1;
}
.chip__x:hover { background: rgba(0, 0, 0, .12); }
.chip-filter { background: var(--primary-soft); color: #14327f; }
.chip-filter .chip__label { color: #36508f; }

/* Tables -------------------------------------------------------------- */

.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: .55rem .6rem; text-align: left; vertical-align: top; border-top: 1px solid var(--line); }
.table thead th {
    border-top: 0; border-bottom: 2px solid var(--line-strong);
    font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted);
}
.table tbody th { font-weight: 600; }
.table tbody tr:hover { background: #f8fafc; }
.table .num { text-align: right; }
.cell-error { color: var(--danger-ink); max-width: 28ch; overflow-wrap: anywhere; }

details.runs summary { cursor: pointer; color: var(--primary); font-weight: 600; }
details.runs[open] summary { margin-bottom: .5rem; }
.table--nested { font-size: .85rem; margin-top: .5rem; }

/* Empty state --------------------------------------------------------- */

.empty { text-align: center; padding: 2rem 1rem; color: var(--muted); }
.empty__title { color: var(--ink); font-weight: 600; font-size: 1.05rem; margin-bottom: .25rem; }
.empty__action { margin-top: .75rem; }

/* Pagination ---------------------------------------------------------- */

.pagination { display: flex; flex-wrap: wrap; justify-content: center; gap: .25rem; margin-top: 1.25rem; }
.pagination__link {
    min-width: 2.25rem; text-align: center; padding: .4rem .7rem;
    border: 1px solid var(--line-strong); border-radius: 6px; background: var(--surface);
    text-decoration: none; color: var(--ink);
}
a.pagination__link:hover { background: #eef1f5; }
.pagination__link.is-current { background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 700; }
.pagination__link.is-disabled { color: var(--muted); background: transparent; }
.pagination__gap { padding: .4rem .3rem; color: var(--muted); }

/* Candidate search ---------------------------------------------------- */

.search-layout { display: grid; gap: 1.25rem; grid-template-columns: 280px minmax(0, 1fr); align-items: start; }
.searchbar { display: flex; gap: .5rem; flex-wrap: wrap; margin-bottom: .75rem; }
.searchbar input[type="search"], .searchbar input[type="text"] { flex: 1 1 260px; }
.searchbar--ai { margin-bottom: 1rem; }

.sidebar { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.sidebar__summary { display: none; }
.sidebar__body { padding: 1rem; display: grid; gap: 1.1rem; }
.facet { border: 0; padding: 0; }
.facet legend, .facet__title { padding: 0; font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 700; margin-bottom: .35rem; }
.facet__list { list-style: none; display: grid; gap: .15rem; max-height: 14rem; overflow-y: auto; }
.facet__item { display: flex; align-items: center; gap: .5rem; padding: .1rem 0; }
.facet__item label { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.facet__count { color: var(--muted); font-size: .8rem; }
.facet__row { display: flex; gap: .5rem; }
.toggle { display: inline-flex; gap: .75rem; font-size: .875rem; margin-bottom: .35rem; }
.toggle label { display: inline-flex; align-items: center; gap: .3rem; }
.typeahead { position: relative; }
.typeahead__list {
    position: absolute; z-index: 20; left: 0; right: 0; top: 100%;
    background: #fff; border: 1px solid var(--line-strong); border-radius: 6px;
    box-shadow: 0 6px 18px rgba(16, 24, 40, .14);
    list-style: none; max-height: 14rem; overflow-y: auto;
}
.typeahead__list[hidden] { display: none; }
.typeahead__option { padding: .4rem .65rem; cursor: pointer; display: flex; justify-content: space-between; gap: .5rem; }
.typeahead__option[aria-selected="true"], .typeahead__option:hover { background: var(--primary-soft); }

.results-bar { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: .5rem 1rem; margin-bottom: .75rem; }
.results-bar__count { font-weight: 600; }
.results-bar__hint { margin: .15rem 0 0; font-size: .875rem; color: var(--muted); }
#search-results { transition: opacity .15s ease-in; }
#search-results.is-loading { opacity: .55; }
#search-results:focus { outline: none; }
@media (prefers-reduced-motion: reduce) { #search-results { transition: none; } }
.results-bar form { display: flex; align-items: center; gap: .4rem; }
.results-bar select { width: auto; }
.active-filters { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem; margin-bottom: .75rem; }

.result {
    background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
    box-shadow: var(--shadow); padding: .9rem 1rem; margin-bottom: .75rem;
}
.result__head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: .35rem 1rem; align-items: baseline; }
.result__name { font-size: 1.1rem; margin: 0; }
.result__meta { color: var(--muted); font-size: .9rem; display: flex; flex-wrap: wrap; gap: .25rem .9rem; margin: .15rem 0 .5rem; }
.result__snippet { color: #3a4553; font-size: .9rem; margin: .5rem 0 0; overflow-wrap: anywhere; }
.result__foot { display: flex; flex-wrap: wrap; gap: .35rem .75rem; align-items: center; margin-top: .6rem; }
mark { background: var(--mark); color: inherit; padding: 0 .1em; border-radius: 2px; }

/* Candidate detail ---------------------------------------------------- */

.detail { display: grid; gap: 1rem; grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); align-items: start; }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: .35rem 1rem; }
.facts dt { color: var(--muted); font-weight: 600; }
.facts dd { margin: 0; overflow-wrap: anywhere; }
.timeline { list-style: none; display: grid; gap: .9rem; }
.timeline__title { font-weight: 600; margin: 0; }
.timeline__meta { color: var(--muted); font-size: .875rem; margin: 0; }
.preview { width: 100%; height: 640px; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; }
.resume-list { list-style: none; display: grid; gap: .6rem; }
.resume-list li { padding: .6rem 0; border-top: 1px solid var(--line); }
.resume-list li:first-child { border-top: 0; }
.section-gap { margin-top: 1rem; }

.tag-groups { display: grid; gap: .75rem; }
.tag-group__title { font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 700; margin-bottom: .3rem; }

/* Mailboxes ----------------------------------------------------------- */

.sync-state { font-size: .85rem; color: var(--muted); }

/* Responsive ---------------------------------------------------------- */

@media (max-width: 900px) {
    .search-layout { grid-template-columns: minmax(0, 1fr); }
    .sidebar__summary {
        display: block; cursor: pointer; padding: .8rem 1rem; font-weight: 700; list-style: none;
    }
    .sidebar__summary::-webkit-details-marker { display: none; }
    .sidebar__summary::after { content: "+"; float: right; font-weight: 400; }
    details[open] > .sidebar__summary::after { content: "\2212"; }
    .detail { grid-template-columns: minmax(0, 1fr); }
    .preview { height: 480px; }
}

@media (min-width: 901px) {
    /* The sidebar is a details element for mobile; it is always open on desktop. */
    .sidebar > .sidebar__body { display: grid !important; }
}

@media (max-width: 560px) {
    .topbar__user { width: 100%; justify-content: space-between; }
    .facts { grid-template-columns: minmax(0, 1fr); }
    .facts dt { margin-top: .5rem; }
}

@media (prefers-reduced-motion: reduce) {
    * { scroll-behavior: auto !important; transition: none !important; animation: none !important; }
}
