/* Olie Job Tracker — light, modern, clean. No framework, no dark theme. */
:root {
    --bg:          #FAFAF8;
    --card:        #FFFFFF;
    --ink:         #1A1A1A;
    --muted:       #6B7280;
    --line:        #E5E7EB;
    --line-soft:   #F0F0EE;
    --accent:      #0F766E;
    --accent-hover:#0E6B63;
    --accent-soft: #E6F1F0;
    --accent-ink:  #FFFFFF;
    --danger:      #B91C1C;
    --danger-soft: #FEECEC;
    --radius:      8px;
    --radius-lg:   12px;
    --shadow:      0 1px 2px rgba(16,24,40,.04), 0 1px 3px rgba(16,24,40,.06);
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    font-family: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    font-size: 15px;
    line-height: 1.55;
    font-weight: 400;
    color: var(--ink);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

h1 { font-size: 26px; font-weight: 700; margin: 0 0 18px; letter-spacing: -0.01em; }
h2 { font-size: 18px; font-weight: 600; margin: 26px 0 12px; }
h3 { font-size: 15px; font-weight: 600; margin: 0 0 8px; }

.wrap { max-width: 1120px; margin: 0 auto; padding: 28px 22px 72px; }

/* ---- Top navigation ---------------------------------------------------- */
.topbar {
    position: sticky; top: 0; z-index: 20;
    background: var(--card);
    border-bottom: 1px solid var(--line);
}
.topbar-inner {
    max-width: 1120px; margin: 0 auto;
    display: flex; align-items: center; gap: 10px;
    padding: 10px 22px;
}
.brand {
    font-weight: 700; color: var(--ink); font-size: 15px;
    display: inline-flex; align-items: center; gap: 8px; margin-right: 6px;
}
.brand:hover { text-decoration: none; }
.brand .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--accent); display: inline-block; }

.mainnav { display: flex; align-items: center; gap: 4px; flex: 1; }
.mainnav a.navlink {
    color: var(--ink); font-weight: 500; font-size: 14px;
    padding: 7px 12px; border-radius: var(--radius); line-height: 1;
    transition: background .12s ease, color .12s ease;
}
.mainnav a.navlink:hover { background: var(--line-soft); text-decoration: none; }
.mainnav a.navlink.is-active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }

.navright { display: flex; align-items: center; gap: 14px; margin-left: auto; }
.navright .who { color: var(--muted); font-size: 13px; }
.navright .who strong { color: var(--ink); font-weight: 600; }
.navright a.signout { color: var(--muted); font-size: 13px; font-weight: 500; }
.navright a.signout:hover { color: var(--ink); }

.nav-toggle {
    display: none; background: none; border: 1px solid var(--line);
    border-radius: var(--radius); padding: 6px 10px; cursor: pointer; color: var(--ink);
}

/* ---- Buttons ----------------------------------------------------------- */
button, .btn {
    font: inherit; font-weight: 600; font-size: 14px; cursor: pointer;
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    background: var(--accent); color: var(--accent-ink);
    border: 1px solid var(--accent); border-radius: var(--radius);
    padding: 9px 15px; line-height: 1.2; transition: background .12s ease, border-color .12s ease;
}
button:hover, .btn:hover { background: var(--accent-hover); border-color: var(--accent-hover); text-decoration: none; }

.btn-sm { padding: 6px 11px; font-size: 13px; }
.btn-secondary {
    background: var(--card); color: var(--ink); border: 1px solid var(--line);
}
.btn-secondary:hover { background: var(--line-soft); border-color: var(--line); color: var(--ink); }
.btn-danger { background: var(--card); color: var(--danger); border-color: var(--line); }
.btn-danger:hover { background: var(--danger-soft); border-color: var(--danger-soft); }

button.link {
    background: none; border: 0; padding: 0; color: var(--accent);
    font: inherit; font-weight: 500; cursor: pointer; width: auto;
}
button.link:hover { text-decoration: underline; background: none; }
button.link.danger { color: var(--danger); }

/* ---- Forms ------------------------------------------------------------- */
label { display: grid; gap: 6px; font-size: 13px; font-weight: 500; color: var(--ink); }
.hint { font-weight: 400; color: var(--muted); font-size: 12.5px; }
input, select, textarea {
    font: inherit; color: var(--ink); padding: 9px 11px; width: 100%;
    border: 1px solid var(--line); border-radius: var(--radius); background: #fff;
    transition: border-color .12s ease, box-shadow .12s ease;
}
input:focus, select:focus, textarea:focus {
    outline: none; border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}
textarea { resize: vertical; min-height: 90px; line-height: 1.5; }
label.checkbox, label.radio { flex-direction: row; align-items: center; gap: 8px; font-weight: 400; }
label.checkbox input, label.radio input { width: auto; }

.alert { padding: 11px 14px; border-radius: var(--radius); font-size: 14px; margin: 0 0 16px; }
.alert.error { background: var(--danger-soft); color: #991B1B; border: 1px solid #F6C9C9; }
.alert.ok { background: var(--accent-soft); color: #115E56; border: 1px solid #C7E4E1; }

/* ---- Page header ------------------------------------------------------- */
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.page-head h1 { margin-bottom: 6px; }
.page-head .lede { color: var(--muted); font-size: 14px; margin: 0 0 18px; }
.back { margin: 0 0 14px; font-size: 13px; }
.muted { color: var(--muted); font-size: 12.5px; }

/* ---- Cards ------------------------------------------------------------- */
.card {
    background: var(--card); border: 1px solid var(--line);
    border-radius: var(--radius-lg); padding: 22px; box-shadow: var(--shadow);
}
.card + .card { margin-top: 18px; }

/* ---- Dashboard status tiles ------------------------------------------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(112px, 1fr)); gap: 10px; margin-bottom: 22px; }
.stat {
    background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-lg);
    padding: 13px 14px; text-align: left; color: var(--ink); transition: border-color .12s ease;
}
.stat:hover { border-color: var(--accent); text-decoration: none; }
.stat.is-active { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }
.stat-n { display: block; font-size: 22px; font-weight: 700; color: var(--accent); line-height: 1.1; }
.stat-label { display: block; font-size: 12px; color: var(--muted); text-transform: capitalize; margin-top: 2px; }

/* ---- Needs attention --------------------------------------------------- */
.attention { border-left: 3px solid #D97706; }
.attention h2 { margin-top: 0; color: #92400E; }
.attention ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.attention li { display: flex; justify-content: space-between; gap: 12px; font-size: 14px; padding: 6px 0; border-bottom: 1px solid var(--line-soft); }
.attention li:last-child { border-bottom: 0; }
.attention .why { color: #B45309; font-size: 12.5px; white-space: nowrap; }

/* ---- Filter tabs ------------------------------------------------------- */
.tabs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.tabs a {
    font-size: 13px; font-weight: 500; color: var(--ink);
    padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--card);
}
.tabs a:hover { border-color: var(--accent); text-decoration: none; }
.tabs a.is-active { background: var(--accent); border-color: var(--accent); color: #fff; }
.tabs a .n { opacity: .7; margin-left: 4px; }

/* ---- Filters bar ------------------------------------------------------- */
.filters { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 16px; align-items: center; }
.filters input[type=search] { flex: 1 1 240px; }
.filters select { flex: 0 0 auto; width: auto; }
.filters .clear { color: var(--muted); font-size: 13px; }

/* ---- Tables ------------------------------------------------------------ */
.table-wrap { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-lg); overflow: hidden; box-shadow: var(--shadow); }
table.data { width: 100%; border-collapse: collapse; }
table.data th, table.data td { padding: 12px 14px; text-align: left; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
table.data th { font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; background: #FCFCFB; }
table.data tbody tr:last-child td { border-bottom: 0; }
table.data tbody tr:hover { background: #FCFCFB; }
table.data td.tight { width: 1%; white-space: nowrap; }
table.data a.title { font-weight: 600; color: var(--ink); }
table.data a.title:hover { color: var(--accent); }
td.msg { color: var(--muted); font-size: 13px; max-width: 280px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.row-actions { display: flex; gap: 12px; align-items: center; white-space: nowrap; }
.row-actions form { display: inline; margin: 0; }

/* ---- Badges ------------------------------------------------------------ */
.tag {
    display: inline-block; font-size: 11px; font-weight: 500; padding: 2px 8px; border-radius: 999px;
    background: var(--line-soft); color: var(--muted); text-transform: capitalize;
}
.status {
    display: inline-block; font-size: 12px; font-weight: 600; padding: 3px 9px; border-radius: 999px; text-transform: capitalize;
    border: 1px solid transparent;
}
.status-new       { background: var(--accent-soft); color: #115E56; }
.status-saved     { background: #E0EDFF; color: #1D4ED8; }
.status-applied   { background: #FEF3C7; color: #92400E; }
.status-interview { background: #EDE9FE; color: #6D28D9; }
.status-offer     { background: #DCFCE7; color: #166534; }
.status-rejected  { background: #F3F4F6; color: #6B7280; }
.status-dismissed { background: #F9FAFB; color: #9CA3AF; }

/* ---- Bulk action bar --------------------------------------------------- */
.bulkbar {
    position: sticky; bottom: 16px; z-index: 15;
    display: none; align-items: center; gap: 14px; flex-wrap: wrap;
    margin-top: 14px; padding: 12px 16px;
    background: var(--ink); color: #fff; border-radius: var(--radius-lg);
    box-shadow: 0 6px 20px rgba(16,24,40,.18);
}
.bulkbar.show { display: flex; }
.bulkbar .count { font-weight: 600; font-size: 14px; }
.bulkbar select { width: auto; background: #fff; color: var(--ink); }
.bulkbar .spacer { flex: 1; }
.bulkbar button { padding: 7px 12px; font-size: 13px; }
.bulkbar .btn-clear { background: transparent; border-color: rgba(255,255,255,.35); color: #fff; }
.bulkbar .btn-clear:hover { background: rgba(255,255,255,.12); }

/* ---- Empty state ------------------------------------------------------- */
.empty { background: var(--card); border: 1px dashed var(--line); border-radius: var(--radius-lg);
    padding: 36px; text-align: center; color: var(--muted); }
.empty h1 { color: var(--ink); }

/* ---- Login ------------------------------------------------------------- */
.login-card {
    max-width: 380px; margin: 10vh auto 0; background: var(--card);
    border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 32px; box-shadow: var(--shadow);
}
.login-card h1 { text-align: center; }
.login-card form { display: grid; gap: 16px; margin-top: 4px; }
.login-card button { width: 100%; padding: 11px; }

/* ---- Info tooltip ------------------------------------------------------ */
.info {
    display: inline-flex; align-items: center; justify-content: center;
    width: 16px; height: 16px; border-radius: 50%;
    background: var(--line-soft); color: var(--muted);
    font-size: 11px; font-weight: 700; font-style: normal; cursor: help;
    position: relative; margin-left: 5px; vertical-align: middle; user-select: none;
}
.info:hover { background: var(--accent-soft); color: var(--accent); }
.info .tip {
    visibility: hidden; opacity: 0; position: absolute; left: 50%; bottom: calc(100% + 8px);
    transform: translateX(-50%); width: 280px; max-width: 78vw; z-index: 30;
    background: var(--ink); color: #fff; font-size: 12.5px; font-weight: 400; line-height: 1.5;
    text-align: left; padding: 10px 12px; border-radius: var(--radius);
    box-shadow: 0 6px 20px rgba(16,24,40,.22); transition: opacity .12s ease, visibility .12s ease;
    pointer-events: none;
}
.info .tip::after {
    content: ""; position: absolute; top: 100%; left: 50%; transform: translateX(-50%);
    border: 6px solid transparent; border-top-color: var(--ink);
}
.info:hover .tip, .info:focus .tip { visibility: visible; opacity: 1; }

/* ---- Expandable "how it works" panel ---------------------------------- */
details.explain { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 4px 18px; margin-bottom: 20px; box-shadow: var(--shadow); }
details.explain summary { cursor: pointer; font-weight: 600; padding: 12px 0; list-style: none; display: flex; align-items: center; gap: 8px; }
details.explain summary::-webkit-details-marker { display: none; }
details.explain summary::before { content: "›"; display: inline-block; transition: transform .15s ease; font-size: 18px; color: var(--muted); }
details.explain[open] summary::before { transform: rotate(90deg); }
details.explain .body { padding: 0 0 16px; color: #374151; font-size: 14px; }
details.explain .body ul { margin: 8px 0; padding-left: 20px; }
details.explain .body li { margin: 4px 0; }

/* ---- Search form ------------------------------------------------------- */
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 18px; }
.form-grid .full { grid-column: 1 / -1; }
.field { display: grid; gap: 6px; }
.field > .label-row { display: flex; align-items: center; font-size: 13px; font-weight: 600; }
.field .sub { display: grid; gap: 6px; }

.county-select { min-height: 200px; }
.county-select:disabled, input:disabled, .is-disabled { background: #F3F4F6; color: #9CA3AF; cursor: not-allowed; }

.radios, .checks { display: flex; flex-wrap: wrap; gap: 8px 18px; }
.pill-check { display: inline-flex; align-items: center; gap: 7px; padding: 7px 12px; border: 1px solid var(--line); border-radius: 999px; font-size: 13px; font-weight: 500; cursor: pointer; }
.pill-check input { width: auto; }
.pill-check:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.pill-check.is-disabled { opacity: .5; cursor: not-allowed; }

.form-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 22px; align-items: center; }

/* Preview results */
.preview-box { margin-top: 16px; display: none; }
.preview-box.show { display: block; }
.preview-box .pv-list { display: grid; gap: 8px; margin-top: 8px; }
.preview-item { border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; background: #FCFCFB; }
.preview-item .pv-title { font-weight: 600; font-size: 14px; }
.preview-item .pv-meta { color: var(--muted); font-size: 12.5px; margin-top: 2px; }

/* ---- Job detail -------------------------------------------------------- */
.job-detail .sub { color: var(--muted); margin: 4px 0 0; }
dl.meta { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; margin: 18px 0; }
dl.meta dt { font-size: 12px; color: var(--muted); }
dl.meta dd { margin: 2px 0 0; font-weight: 600; }
.snippet p { color: #374151; }
.deadline-warn { display: inline-block; background: var(--danger-soft); color: #991B1B; font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 999px; }
.deadline-ok { color: var(--muted); font-size: 12px; }

.crm-form { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; margin-top: 8px; }
.crm-form .full { grid-column: 1 / -1; }
.crm-form .form-actions { grid-column: 1 / -1; }

/* Add-job form reuse */
.tracking form, form.stack { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
form.stack .full { grid-column: 1 / -1; }
form.stack .form-actions { grid-column: 1 / -1; }

/* ---- Toast ------------------------------------------------------------- */
.toast {
    position: fixed; right: 20px; bottom: 20px; z-index: 50;
    background: var(--ink); color: #fff; padding: 12px 16px; border-radius: var(--radius);
    box-shadow: 0 6px 20px rgba(16,24,40,.22); font-size: 14px; max-width: 360px;
    animation: toastin .2s ease;
}
@keyframes toastin { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

/* ---- Responsive -------------------------------------------------------- */
@media (max-width: 760px) {
    .nav-toggle { display: inline-block; }
    .mainnav, .navright {
        display: none; position: absolute; top: 100%; left: 0; right: 0;
        flex-direction: column; align-items: stretch; gap: 2px;
        background: var(--card); border-bottom: 1px solid var(--line); padding: 8px 14px;
    }
    .topbar.open .mainnav, .topbar.open .navright { display: flex; }
    .navright { border-top: 1px solid var(--line-soft); margin-left: 0; }
    .mainnav a.navlink { padding: 10px 12px; }
    .form-grid, .crm-form, .tracking form, form.stack { grid-template-columns: 1fr; }
    .topbar-inner { position: relative; }
}
@media (max-width: 520px) {
    table.data thead { display: none; }
    table.data, table.data tbody, table.data tr, table.data td { display: block; width: 100%; }
    table.data tr { border-bottom: 1px solid var(--line); padding: 6px 0; }
    table.data td { border: 0; padding: 4px 14px; }
    table.data td.tight { width: auto; }
}
