:root {
    --bg: #f5f7fa;
    --panel: #ffffff;
    --panel-subtle: #f8fafc;
    --ink: #172033;
    --muted: #647084;
    --line: #dbe2ea;
    --line-strong: #c8d3df;
    --accent: #0f8f9f;
    --accent-strong: #0a6675;
    --accent-soft: #e4f4f6;
    --danger: #b42318;
    --danger-soft: #fff0ed;
    --success: #16734a;
    --success-soft: #e8f6ee;
    --warning: #956000;
    --warning-soft: #fff7df;
    --shadow: 0 10px 24px rgba(17, 24, 39, 0.07);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    background: var(--bg);
    color: var(--ink);
    font-family:
        Inter,
        ui-sans-serif,
        system-ui,
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        sans-serif;
}

button,
input,
select,
textarea {
    font: inherit;
}

button {
    cursor: pointer;
}

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

.app-header {
    position: sticky;
    top: 0;
    z-index: 10;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: 24px;
    min-height: 72px;
    padding: 12px 24px;
    background: rgba(255, 255, 255, 0.96);
    border-bottom: 1px solid var(--line);
    backdrop-filter: blur(14px);
}

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

.brand-mark {
    display: grid;
    place-items: center;
    width: 36px;
    height: 36px;
    color: #ffffff;
    background: var(--ink);
    border-radius: 8px;
    font-weight: 800;
}

.brand h1,
.panel h2,
.workspace-header h2,
.cv-card h3 {
    margin: 0;
}

.brand h1 {
    font-size: 18px;
    line-height: 1.1;
}

.header-context {
    min-width: 0;
    padding-left: 12px;
    border-left: 1px solid var(--line);
}

.header-context strong {
    display: block;
    overflow: hidden;
    font-size: 15px;
    line-height: 1.2;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.header-context span {
    display: block;
    overflow: hidden;
    margin-top: 3px;
    color: var(--muted);
    font-size: 13px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.header-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
}

.brand p,
.workspace-header p,
.panel-heading p {
    margin: 3px 0 0;
    color: var(--muted);
    font-size: 13px;
}

.top-nav,
.filter-tabs,
.detail-meta,
.link-row,
.split-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}

.nav-button,
.filter-button {
    min-height: 34px;
    padding: 0 12px;
    color: var(--muted);
    background: transparent;
    border: 1px solid transparent;
    border-radius: 7px;
    font-weight: 750;
}

.nav-button.active,
.filter-button.active {
    color: var(--accent-strong);
    background: var(--accent-soft);
    border-color: #cce9ed;
}

main {
    padding: 18px;
}

main:has(#view-cv.active) {
    padding: 12px 18px;
}

.view {
    display: none;
}

.view.active {
    display: grid;
}

#view-jobs {
    grid-template-columns: minmax(0, 1fr);
    gap: 16px;
}

.detail-layout {
    grid-template-columns: minmax(0, 1fr) minmax(300px, 380px);
    gap: 18px;
}

.cv-layout {
    grid-template-rows: auto minmax(0, 1fr);
    gap: 10px;
    height: calc(100vh - 96px);
    min-height: 620px;
}

.panel {
    min-width: 0;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.search-panel {
    overflow: visible;
}

.panel-heading,
.workspace-header,
.cv-card-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 14px;
    padding: 18px;
    border-bottom: 1px solid var(--line);
}

.workspace-header.panel {
    align-items: center;
    border-bottom: 1px solid var(--line);
}

.panel h2,
.workspace-header h2,
.cv-card h3 {
    font-size: 16px;
    line-height: 1.2;
}

.count-label,
.badge {
    display: inline-flex;
    align-items: center;
    min-height: 24px;
    max-width: 160px;
    padding: 3px 8px;
    overflow: hidden;
    color: var(--muted);
    background: var(--panel-subtle);
    border: 1px solid var(--line);
    border-radius: 999px;
    font-size: 12px;
    font-weight: 750;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.count-label,
.badge.accent {
    color: var(--accent-strong);
    background: var(--accent-soft);
    border-color: #cce9ed;
}

.badge.success {
    color: var(--success);
    background: var(--success-soft);
    border-color: #c8ebd6;
}

.badge.warning {
    color: var(--warning);
    background: var(--warning-soft);
    border-color: #f1dfa6;
}

.badge.danger {
    color: var(--danger);
    background: var(--danger-soft);
    border-color: #f3c6bd;
}

.form-stack,
.action-content {
    display: grid;
    gap: 14px;
    padding: 18px;
}

.search-bar-form {
    grid-template-columns: minmax(190px, 1.2fr) minmax(180px, 1fr) minmax(170px, 0.75fr) minmax(150px, 0.7fr) 112px 112px auto;
    align-items: end;
}

.search-bar-form select[multiple] {
    min-height: 40px;
    max-height: 40px;
    overflow: auto;
}

.search-field-main {
    min-width: 0;
}

.search-field-small {
    min-width: 96px;
}

.search-submit {
    min-width: 136px;
}

label {
    display: grid;
    gap: 7px;
    color: var(--ink);
    font-size: 13px;
    font-weight: 750;
}

input,
select,
textarea {
    width: 100%;
    color: var(--ink);
    background: #ffffff;
    border: 1px solid var(--line-strong);
    border-radius: 7px;
    outline: none;
}

input {
    height: 40px;
    padding: 0 11px;
}

select {
    min-height: 40px;
    padding: 9px 10px;
}

textarea {
    min-height: 110px;
    padding: 10px 11px;
    line-height: 1.45;
    resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(15, 143, 159, 0.16);
}

.field-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.primary-button,
.secondary-button,
.icon-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 38px;
    padding: 0 12px;
    border-radius: 7px;
    border: 1px solid transparent;
    font-weight: 800;
}

.primary-button {
    color: #ffffff;
    background: var(--accent);
}

.primary-button:hover {
    background: var(--accent-strong);
}

.secondary-button {
    color: var(--ink);
    background: #ffffff;
    border-color: var(--line-strong);
}

.secondary-button:hover,
.icon-button:hover {
    background: var(--panel-subtle);
}

.danger-button {
    color: var(--danger);
    border-color: #f3c6bd;
}

.icon-button {
    width: 36px;
    padding: 0;
    color: var(--muted);
    background: #ffffff;
    border-color: var(--line);
}

button:disabled {
    cursor: not-allowed;
    opacity: 0.55;
}

svg {
    width: 17px;
    height: 17px;
    fill: none;
    stroke: currentColor;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-width: 2;
}

.status-text {
    min-height: 22px;
    margin: 0;
    padding: 0 18px 18px;
    color: var(--muted);
    font-size: 13px;
}

.status-text.error {
    color: var(--danger);
}

.status-text.success {
    color: var(--success);
}

.filter-tabs {
    padding: 16px 0 0;
}

.filter-button {
    min-height: 40px;
    padding: 0 16px;
    font-size: 15px;
}

.job-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    align-items: stretch;
    gap: 14px;
    padding: 14px 0 0;
}

.jobs-workspace {
    min-width: 0;
    padding: 18px;
}

.jobs-workspace .workspace-header {
    align-items: center;
    padding: 0;
    border-bottom: 0;
}

.title-with-count {
    display: flex;
    align-items: center;
    gap: 12px;
}

.jobs-workspace #jobs-title {
    font-size: 24px;
    line-height: 1.15;
}

.jobs-workspace #jobs-subtitle {
    margin-top: 6px;
    font-size: 15px;
}

.job-row {
    display: grid;
    grid-template-rows: minmax(0, 1fr) auto;
    gap: 16px;
    width: 100%;
    min-height: 172px;
    padding: 16px;
    color: var(--ink);
    text-align: left;
    background: #ffffff;
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: 0 6px 16px rgba(17, 24, 39, 0.04);
}

.job-row:hover,
.job-row.active {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(15, 143, 159, 0.12);
}

.job-row-main {
    display: grid;
    align-content: start;
    gap: 8px;
    min-width: 0;
}

.job-row strong {
    font-size: 15px;
    line-height: 1.32;
}

.job-company {
    color: var(--muted);
    font-size: 13px;
}

.job-description {
    display: -webkit-box;
    overflow: hidden;
    color: #3d495b;
    font-size: 13px;
    line-height: 1.35;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
}

.job-meta {
    display: flex;
    flex-direction: row;
    align-items: flex-end;
    align-self: end;
    flex-wrap: wrap;
    justify-content: flex-start;
    gap: 6px;
}

.detail-content {
    display: grid;
    gap: 16px;
    padding: 18px;
}

.detail-title-row {
    display: flex;
    justify-content: space-between;
    gap: 18px;
}

.detail-title-row h3 {
    margin: 0;
    font-size: 24px;
    line-height: 1.2;
}

.detail-title-row p {
    margin: 5px 0 0;
    color: var(--muted);
}

.link-row a {
    color: var(--accent-strong);
    font-size: 13px;
    font-weight: 800;
}

.markdown-body {
    max-width: 980px;
    color: #344155;
    font-size: 15px;
    line-height: 1.65;
}

.markdown-body h3,
.markdown-body h4,
.markdown-body h5 {
    margin: 20px 0 8px;
    color: var(--ink);
}

.markdown-body p {
    margin: 0 0 12px;
}

.markdown-body ul {
    margin: 0 0 12px 20px;
    padding: 0;
}

.markdown-body li {
    margin: 4px 0;
}

.action-panel {
    align-self: start;
    position: sticky;
    top: 90px;
}

.split-actions {
    align-items: stretch;
}

.split-actions > * {
    flex: 1;
}

.progress-panel {
    display: grid;
    gap: 8px;
    padding: 12px;
    background: var(--panel-subtle);
    border: 1px solid var(--line);
    border-radius: 8px;
}

.progress-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    font-size: 13px;
}

.progress-header strong {
    color: var(--ink);
}

.progress-header span {
    color: var(--accent-strong);
    font-weight: 800;
}

.progress-track {
    height: 10px;
    overflow: hidden;
    background: #dbe7ea;
    border-radius: 999px;
}

.progress-track span {
    display: block;
    width: 0;
    height: 100%;
    background: var(--accent);
    border-radius: inherit;
    transition: width 220ms ease;
}

.progress-panel p {
    margin: 0;
    color: var(--muted);
    font-size: 13px;
    line-height: 1.35;
}

.cv-history {
    min-height: 34px;
}

.history-list {
    display: flex;
    gap: 8px;
    overflow-x: auto;
}

.history-item {
    min-height: 32px;
    padding: 0 12px;
    color: var(--muted);
    background: #ffffff;
    border: 1px solid var(--line);
    border-radius: 7px;
    font-weight: 750;
    white-space: nowrap;
}

.history-item.active {
    color: var(--accent-strong);
    border-color: var(--accent);
}

.cv-grid,
.cv-editor-layout {
    display: grid;
    gap: 14px;
}

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

.cv-editor-layout {
    grid-template-columns: minmax(500px, 560px) minmax(0, 1fr);
    align-items: stretch;
    min-height: 0;
}

.cv-card {
    min-width: 0;
    overflow: hidden;
}

.cv-editor-panel,
.cv-preview-panel {
    min-width: 0;
    overflow: hidden;
}

.cv-editor-panel {
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    min-height: 0;
}

.cv-card-header {
    align-items: center;
}

.cv-editor-panel > .cv-card-header {
    padding: 10px 14px;
}

.cv-editor-panel > .cv-card-header h3 {
    margin: 0;
    font-size: 15px;
    line-height: 1.15;
}

.cv-editor-panel > .cv-card-header .secondary-button {
    min-height: 32px;
    padding: 0 10px;
    font-size: 12px;
}

.cv-preview-panel {
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
}

.cv-preview-panel .cv-card-header {
    display: grid;
    grid-template-columns: minmax(160px, 1fr) auto;
    align-items: center;
    padding: 12px 16px;
}

.cv-preview-panel .cv-card-header > div:last-child {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
}

.cv-preview-panel .cv-card-header h2 {
    margin: 0;
    font-size: 18px;
    line-height: 1.15;
}

.cv-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 6px;
}

.segmented-control {
    display: inline-flex;
    gap: 4px;
    padding: 4px;
    margin-top: 0;
    background: var(--panel-subtle);
    border: 1px solid var(--line);
    border-radius: 8px;
}

.segment-button {
    min-height: 30px;
    padding: 0 10px;
    color: var(--muted);
    background: transparent;
    border: 1px solid transparent;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 800;
}

.segment-button.active {
    color: var(--accent-strong);
    background: #ffffff;
    border-color: var(--line);
}

.cv-editor {
    display: grid;
    align-content: start;
    gap: 10px;
    min-height: 0;
    padding: 14px;
}

.editor-section {
    display: grid;
    gap: 10px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--line);
}

.editor-section-compact {
    gap: 8px;
}

.editor-section:last-child {
    padding-bottom: 0;
    border-bottom: 0;
}

.editor-section-heading {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 10px;
}

.editor-section-heading h4 {
    margin: 0;
    font-size: 14px;
    line-height: 1.2;
}

.editor-section-heading span,
.editor-muted {
    margin: 0;
    color: var(--muted);
    font-size: 12px;
    font-weight: 650;
}

.description-options {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.description-option {
    display: grid;
    grid-template-columns: 48px minmax(0, 1fr);
    gap: 8px;
    width: 100%;
    min-height: 48px;
    padding: 8px;
    color: var(--ink);
    text-align: left;
    background: #ffffff;
    border: 1px solid var(--line);
    border-radius: 8px;
}

.description-option.active,
.color-field.active {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(15, 143, 159, 0.12);
}

.description-option strong {
    color: var(--accent-strong);
    font-size: 12px;
}

.description-option span {
    min-width: 0;
    color: var(--muted);
    font-size: 11px;
    line-height: 1.3;
}

.description-editor-label textarea {
    min-height: 78px;
    max-height: 96px;
}

.color-fields {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px;
}

.color-field {
    padding: 8px;
    background: var(--panel-subtle);
    border: 1px solid var(--line);
    border-radius: 8px;
}

.color-field input[type="color"] {
    height: 30px;
    padding: 3px;
}

.color-field input[type="text"] {
    height: 32px;
    padding: 0 8px;
    font-size: 12px;
}

.palette-group {
    display: grid;
    gap: 6px;
}

.palette-group-title {
    color: var(--muted);
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
}

.palette-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(76px, 1fr));
    gap: 6px;
}

.swatch-button {
    display: grid;
    grid-template-columns: 18px minmax(0, 1fr);
    align-items: center;
    gap: 7px;
    min-height: 30px;
    padding: 4px 6px;
    color: var(--ink);
    background: #ffffff;
    border: 1px solid var(--line);
    border-radius: 7px;
}

.swatch-button span {
    width: 18px;
    height: 18px;
    border: 1px solid rgba(0, 0, 0, 0.14);
    border-radius: 5px;
}

.swatch-button strong {
    overflow: hidden;
    font-size: 10px;
    text-overflow: ellipsis;
}

.font-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
}

.font-grid select {
    min-height: 36px;
    padding: 7px 9px;
}

.site-image-strip {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(88px, 1fr));
    gap: 8px;
}

.site-image-thumb {
    display: grid;
    gap: 5px;
    padding: 6px;
    color: var(--ink);
    text-align: left;
    background: #ffffff;
    border: 1px solid var(--line);
    border-radius: 8px;
}

.site-image-thumb img {
    width: 100%;
    aspect-ratio: 16 / 9;
    object-fit: cover;
    background: var(--panel-subtle);
    border-radius: 6px;
}

.site-image-thumb span {
    overflow: hidden;
    color: var(--muted);
    font-size: 10px;
    font-weight: 750;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.editor-action-row {
    display: grid;
    grid-template-columns: 1fr 1fr 1.2fr;
    gap: 8px;
}

.editor-actions .status-text {
    padding: 0;
}

.cv-preview {
    min-height: 0;
    height: 100%;
    overflow: hidden;
    background: #e8edf2;
}

.cv-preview iframe {
    display: block;
    width: 100%;
    height: 100%;
    min-height: 0;
    background: transparent;
    border: 0;
}

.empty-state {
    display: grid;
    place-items: center;
    min-height: 180px;
    color: var(--muted);
    text-align: center;
}

.empty-state.compact {
    min-height: 44px;
    background: #ffffff;
    border: 1px solid var(--line);
    border-radius: 8px;
}

.image-modal {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: grid;
    place-items: center;
    padding: 32px;
    background: rgba(15, 23, 42, 0.76);
}

.image-modal[hidden] {
    display: none;
}

.image-modal img {
    max-width: min(1180px, 94vw);
    max-height: 88vh;
    object-fit: contain;
    background: #ffffff;
    border-radius: 8px;
    box-shadow: 0 24px 70px rgba(0, 0, 0, 0.35);
}

.image-modal-close {
    position: absolute;
    top: 18px;
    right: 18px;
}

body.modal-open {
    overflow: hidden;
}

@media (max-width: 1120px) {
    #view-jobs,
    .detail-layout,
    .cv-grid,
    .cv-editor-layout {
        grid-template-columns: 1fr;
    }

    .action-panel,
    .cv-editor-panel {
        position: static;
        max-height: none;
    }

    .cv-layout {
        height: auto;
        min-height: 0;
    }

    .cv-editor-layout {
        grid-template-columns: 1fr;
    }

    .cv-preview {
        height: 78vh;
        min-height: 560px;
    }

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

    .search-submit {
        min-width: 0;
    }
}

@media (max-width: 720px) {
    .app-header {
        grid-template-columns: 1fr;
        align-items: flex-start;
    }

    .header-context {
        width: 100%;
        padding-left: 0;
        border-left: 0;
    }

    .header-actions {
        justify-content: flex-start;
        width: 100%;
        flex-wrap: wrap;
    }

    main {
        padding: 12px;
    }

    .search-bar-form {
        grid-template-columns: 1fr;
    }

    .job-row {
        grid-template-columns: 1fr;
    }

    .job-meta {
        align-items: flex-start;
        flex-direction: row;
        flex-wrap: wrap;
    }

    .detail-title-row,
    .workspace-header,
    .cv-card-header {
        flex-direction: column;
    }

    .cv-preview-panel .cv-card-header {
        grid-template-columns: 1fr;
    }

    .cv-preview-panel .cv-card-header > div:last-child,
    .color-fields,
    .font-grid,
    .description-options,
    .editor-action-row {
        grid-template-columns: 1fr;
    }

    .cv-preview-panel .cv-card-header > div:last-child {
        align-items: flex-start;
        flex-direction: column;
    }

    .cv-preview {
        height: 68vh;
        min-height: 440px;
    }

    .cv-actions {
        justify-content: flex-start;
    }
}
