@font-face { font-family: "Mark"; src: url("markpro-book.otf") format("opentype"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Mark"; src: url("markpro-medium.otf") format("opentype"); font-weight: 500; font-display: swap; }
@font-face { font-family: "Mark"; src: url("markpro-bold.otf") format("opentype"); font-weight: 700; font-display: swap; }
@font-face { font-family: "Mark"; src: url("markpro-heavy.otf") format("opentype"); font-weight: 800; font-display: swap; }

:root {
    --ink: #171710;
    --muted: #747268;
    --soft: #a19f95;
    --paper: #f3f2ed;
    --white: #fff;
    --line: #e5e3da;
    --line-dark: #d5d2c7;
    --blue: #4cb16e;
    --blue-dark: #2f7d4a;
    --blue-soft: #edf8f0;
    --green: #42a86d;
    --green-soft: #eaf7ef;
    --orange: #ee805b;
    --orange-soft: #fff0e9;
    --red: #cf4e3a;
    --red-soft: #fcecea;
    --shadow: 0 15px 45px rgba(23, 23, 16, .06);
    --font: "Mark", "Segoe UI", Arial, sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; background: var(--paper); color: var(--ink); font: 400 15px/1.45 var(--font); -webkit-font-smoothing: antialiased; }
button, input, textarea, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
[hidden] { display: none !important; }

.app-header {
    position: sticky; z-index: 50; top: 0; display: flex; align-items: center; gap: 28px; min-height: 68px;
    padding: 10px max(24px, calc((100vw - 1420px) / 2)); border-bottom: 1px solid rgba(229, 227, 218, .9);
    background: rgba(255, 255, 255, .93); backdrop-filter: blur(16px);
}
.brand { display: inline-flex; align-items: center; gap: 11px; color: inherit; text-decoration: none; }
.brand-mark { display: grid; width: 42px; height: 42px; flex: 0 0 auto; place-items: center; border-radius: 13px; background: var(--ink); box-shadow: 0 5px 15px rgba(23,23,16,.13); }
.brand-mark img { width: 42px; height: 42px; }
.brand strong, .brand small { display: block; }
.brand strong { font-size: 15px; font-weight: 800; letter-spacing: -.01em; }
.brand small { margin-top: 1px; color: var(--muted); font-size: 11px; }
.view-switcher { display: flex; align-items: center; gap: 3px; padding: 4px; border-radius: 11px; background: var(--paper); }
.view-button { padding: 7px 13px; border: 0; border-radius: 8px; background: transparent; color: var(--muted); font-size: 13px; font-weight: 700; }
.view-button:hover { color: var(--ink); }
.view-button.is-active { background: var(--white); color: var(--ink); box-shadow: 0 2px 8px rgba(23,23,16,.06); }
.header-user { display: flex; align-items: center; gap: 9px; margin-left: auto; }
.user-avatar { display: grid; width: 35px; height: 35px; place-items: center; border-radius: 50%; background: var(--blue-soft); color: var(--blue-dark); font-size: 11px; font-weight: 800; }
.user-copy strong, .user-copy small { display: block; }
.user-copy strong { max-width: 160px; overflow: hidden; font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.user-copy small { color: var(--muted); font-size: 10px; }
.icon-button { display: grid; width: 36px; height: 36px; place-items: center; border: 0; border-radius: 9px; background: transparent; color: var(--muted); }
.icon-button:hover { background: var(--paper); color: var(--ink); }
.icon-button svg { width: 19px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.app-shell { width: min(1420px, calc(100% - 48px)); margin: 0 auto; padding: 42px 0 72px; }
.hero-grid { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(430px, .8fr); align-items: center; gap: 60px; padding: 8px 4px 30px; }
.eyebrow, .panel-kicker { margin: 0; color: var(--blue-dark); font-size: 11px; font-weight: 800; letter-spacing: .105em; text-transform: uppercase; }
.hero-copy h1, .settings-intro h1 { margin: 8px 0 10px; font-size: 38px; font-weight: 800; letter-spacing: -.035em; line-height: 1.08; }
.hero-copy > p:last-child, .settings-intro > p:last-child { max-width: 650px; margin: 0; color: var(--muted); font-size: 14px; line-height: 1.55; }
.hero-stats { display: grid; grid-template-columns: repeat(3, 1fr); overflow: hidden; border: 1px solid var(--line); border-radius: 18px; background: rgba(255,255,255,.65); }
.hero-stats > div { position: relative; min-height: 100px; padding: 17px 18px; border-right: 1px solid var(--line); }
.hero-stats > div:last-child { border-right: 0; }
.hero-stats strong, .hero-stats span { display: block; }
.hero-stats strong { margin-bottom: 9px; font-size: 23px; font-weight: 800; letter-spacing: -.03em; }
.hero-stats span:last-child { color: var(--muted); font-size: 11px; line-height: 1.35; }
.connection-summary { display: grid; grid-template-columns: auto minmax(0, 1fr); align-content: center; column-gap: 9px; }
.connection-summary .status-dot { grid-column: 1; grid-row: 1; align-self: center; margin: 0; }
.connection-summary strong { grid-column: 2; grid-row: 1; align-self: center; margin: 0; font-size: 15px; }
.connection-summary > span:last-child { grid-column: 1 / -1; margin-top: 8px; }
.status-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: #c1bfb5; box-shadow: 0 0 0 4px rgba(193,191,181,.14); }
.status-dot.is-good { background: var(--green); box-shadow: 0 0 0 4px rgba(66,168,109,.13); }
.status-dot.is-bad { background: var(--red); box-shadow: 0 0 0 4px rgba(207,78,58,.12); }

.panel { position: relative; display: grid; grid-template-columns: 62px minmax(0, 1fr); margin-bottom: 22px; border: 1px solid var(--line); border-radius: 20px; background: var(--white); box-shadow: var(--shadow); }
.step-number { display: grid; align-content: start; justify-content: center; padding-top: 28px; border-right: 1px solid var(--line); color: var(--blue-dark); font-size: 12px; font-weight: 800; letter-spacing: .06em; }
.panel-main { min-width: 0; padding: 28px 31px 30px; }
.panel-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 22px; }
.panel-heading h2, .section-heading h2 { margin: 5px 0 0; font-size: 24px; font-weight: 800; letter-spacing: -.028em; line-height: 1.2; }
.subtle-badge, .connection-badge { display: inline-flex; align-items: center; min-height: 28px; padding: 5px 10px; border-radius: 999px; background: var(--paper); color: var(--muted); font-size: 11px; font-weight: 700; white-space: nowrap; }
.connection-badge.is-good { background: var(--green-soft); color: #277e4c; }
.connection-badge.is-bad { background: var(--red-soft); color: var(--red); }
.field-label { display: block; margin-bottom: 7px; color: var(--muted); font-size: 11px; font-weight: 700; }
textarea, input, select { color: var(--ink); outline: 0; }
textarea:focus, input:focus, select:focus { border-color: var(--blue) !important; box-shadow: 0 0 0 3px rgba(76,177,110,.12); }
#sourceUrls { width: 100%; min-height: 190px; resize: vertical; padding: 16px 17px; border: 1px solid var(--line-dark); border-radius: 13px; background: #fcfcfa; font-family: "SFMono-Regular", Consolas, monospace; font-size: 13px; line-height: 1.7; }
#sourceUrls::placeholder { color: #aaa89f; }
.form-footer { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-top: 13px; }
.form-footer p { margin: 0; color: var(--muted); font-size: 11px; }
.button { display: inline-flex; min-height: 41px; align-items: center; justify-content: center; gap: 8px; padding: 9px 15px; border: 1px solid transparent; border-radius: 10px; font-size: 12px; font-weight: 800; text-decoration: none; transition: transform .15s, border-color .15s, background .15s; }
.button:hover:not(:disabled) { transform: translateY(-1px); }
.button:disabled { cursor: not-allowed; opacity: .48; }
.button svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }
.button-primary { background: var(--ink); color: var(--white); box-shadow: 0 7px 18px rgba(23,23,16,.13); }
.button-primary:hover:not(:disabled) { background: #2b2b23; }
.button-secondary { border-color: var(--line-dark); background: var(--white); color: var(--ink); }
.button-secondary:hover:not(:disabled), .button-quiet:hover:not(:disabled) { border-color: #bdbab0; }
.button-quiet { border-color: var(--line); background: #fbfbf9; color: var(--muted); }
.button-small { min-height: 33px; padding: 6px 10px; border-radius: 8px; font-size: 11px; }
.button-wide { width: 100%; min-height: 47px; }

.progress-panel { display: block; padding: 25px 28px; }
.progress-head, .progress-head > div, .progress-meta { display: flex; align-items: center; }
.progress-head { justify-content: space-between; gap: 20px; }
.progress-head > div { flex-wrap: wrap; gap: 8px; }
.progress-head strong { font-size: 14px; }
.progress-head small { flex-basis: 100%; margin-left: 18px; color: var(--muted); font-size: 11px; }
.activity-pulse { width: 10px; height: 10px; border-radius: 50%; background: var(--blue); animation: pulse 1.5s infinite; }
@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(76,177,110,.35); } 50% { box-shadow: 0 0 0 7px rgba(76,177,110,0); } }
.progress-track { height: 7px; overflow: hidden; margin-top: 19px; border-radius: 99px; background: var(--paper); }
.progress-track span { display: block; width: 0; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--blue), #78c993); transition: width .25s ease; }
.progress-meta { justify-content: space-between; margin-top: 8px; color: var(--muted); font-size: 10px; }

.results-panel { grid-template-columns: 62px minmax(0, 1fr); }
.panel-main-wide { padding-right: 0; padding-left: 0; }
.results-heading { padding: 0 31px; }
.toolbar { display: flex; gap: 7px; }
.selection-summary { display: grid; grid-template-columns: repeat(3, minmax(125px, max-content)) minmax(290px, 1fr); align-items: center; gap: 8px; padding: 13px 31px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); background: #f8f8f5; }
.summary-stat { display: flex; min-height: 40px; align-items: center; gap: 8px; padding: 8px 11px; border: 1px solid var(--line); border-radius: 10px; background: var(--white); }
.summary-stat strong, .summary-stat span { display: block; }
.summary-stat strong { min-width: 18px; font-size: 18px; font-weight: 800; line-height: 1; text-align: center; }
.summary-stat span { color: var(--muted); font-size: 10px; font-weight: 700; white-space: nowrap; }
.summary-stat-ready { border-color: #d7eadc; background: #f3faf5; }
.summary-stat-ready strong { color: #328354; }
.summary-stat-duplicate { background: #fbfbf9; }
.summary-stat-problem { border-color: #f0dfc7; background: #fff9f0; }
.summary-stat-problem strong { color: #b66a31; }
.selection-action { display: flex; align-items: center; justify-content: flex-end; gap: 13px; }
.selection-action > span { color: var(--muted); font-size: 10px; }
.table-scroll { overflow-x: auto; }
.results-table { width: 100%; border-collapse: collapse; }
.results-table th { padding: 12px 12px; border-bottom: 1px solid var(--line); color: var(--muted); font-size: 10px; font-weight: 800; letter-spacing: .05em; text-align: left; text-transform: uppercase; }
.results-table td { padding: 15px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.results-table tbody tr:last-child td { border-bottom: 0; }
.results-table tbody tr:hover { background: #fcfcfa; }
.check-cell { width: 48px; padding-left: 30px !important; }
.check-cell input { width: 16px; height: 16px; accent-color: var(--ink); }
.action-cell { width: 100px; padding-right: 30px !important; text-align: right !important; }
.source-cell { min-width: 280px; max-width: 520px; }
.source-cell strong, .source-cell a { display: block; }
.source-cell strong { overflow: hidden; font-size: 13px; text-overflow: ellipsis; white-space: nowrap; }
.source-cell a { max-width: 460px; overflow: hidden; margin-top: 3px; color: var(--muted); font-size: 10px; text-decoration: none; text-overflow: ellipsis; white-space: nowrap; }
.source-cell a:hover { color: var(--blue-dark); }
.found-cell { min-width: 130px; }
.found-cell span { display: block; color: var(--muted); font-size: 10px; }
.found-cell span + span { margin-top: 4px; }
.status-cell { min-width: 150px; }
.status-pill { display: inline-flex; align-items: center; gap: 6px; min-height: 26px; padding: 4px 8px; border-radius: 999px; background: var(--paper); color: var(--muted); font-size: 10px; font-weight: 800; }
.status-pill::before { width: 6px; height: 6px; border-radius: 50%; background: currentColor; content: ""; }
.status-pill.ready, .status-pill.imported { background: var(--green-soft); color: #2d8853; }
.status-pill.duplicate { background: #f1f0ec; color: #77746b; }
.status-pill.error, .status-pill.import_error { background: var(--red-soft); color: var(--red); }
.status-pill.extracting, .status-pill.importing { background: var(--blue-soft); color: var(--blue-dark); }
.row-note { display: block; max-width: 270px; margin-top: 5px; color: var(--muted); font-size: 9px; line-height: 1.35; }
.row-note.error { color: var(--red); }
.row-actions { display: flex; justify-content: flex-end; gap: 4px; }
.row-action { padding: 5px 7px; border: 0; border-radius: 7px; background: transparent; color: var(--muted); font-size: 10px; font-weight: 700; }
.row-action:hover { background: var(--paper); color: var(--ink); }
.row-action.link { color: var(--blue-dark); text-decoration: none; }

.recent-section { padding: 35px 4px 0; }
.section-heading { margin-bottom: 15px; }
.recent-list { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.recent-item { min-width: 0; padding: 16px; border: 1px solid var(--line); border-radius: 13px; background: rgba(255,255,255,.62); }
.recent-item strong { display: block; overflow: hidden; font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.recent-item a { display: block; overflow: hidden; margin-top: 5px; color: var(--blue-dark); font-size: 10px; text-decoration: none; text-overflow: ellipsis; white-space: nowrap; }
.recent-item span { display: block; margin-top: 11px; color: var(--muted); font-size: 9px; }
.empty-state { grid-column: 1 / -1; margin: 0; padding: 22px; border: 1px dashed var(--line-dark); border-radius: 13px; color: var(--muted); font-size: 12px; text-align: center; }

.settings-intro { max-width: 870px; padding: 8px 4px 28px; }
.settings-form { padding-bottom: 70px; }
.settings-panel { margin-bottom: 18px; }
.field-grid { display: grid; gap: 17px 20px; }
.field-grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-field > span, .selector-copy strong { display: block; margin-bottom: 6px; font-size: 11px; font-weight: 800; }
.form-field em { color: var(--muted); font-size: 9px; font-style: normal; font-weight: 500; }
.form-field input, .form-field select { width: 100%; min-height: 42px; padding: 9px 11px; border: 1px solid var(--line-dark); border-radius: 9px; background: #fcfcfa; font-size: 12px; }
.form-field small { display: block; margin-top: 5px; color: var(--muted); font-size: 9px; }
.inline-actions { display: flex; align-items: center; gap: 12px; margin-top: 20px; }
.inline-result { color: var(--muted); font-size: 11px; }
.inline-result.is-good { color: var(--green); }
.inline-result.is-bad { color: var(--red); }
.selector-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
.selector-field { display: grid; grid-template-columns: 34px minmax(140px, .7fr) minmax(190px, 1fr); align-items: center; gap: 11px; padding: 12px; border: 1px solid var(--line); border-radius: 12px; background: #fdfdfb; }
.selector-icon { display: grid; width: 34px; height: 34px; place-items: center; border-radius: 9px; background: var(--blue-soft); color: var(--blue-dark); font-size: 14px; font-weight: 800; }
.selector-copy strong { margin: 0; }
.selector-copy small { display: block; margin-top: 2px; color: var(--muted); font-size: 9px; line-height: 1.3; }
.selector-field input { min-width: 0; width: 100%; padding: 9px 10px; border: 1px solid var(--line-dark); border-radius: 8px; background: var(--white); font: 11px/1.3 "SFMono-Regular", Consolas, monospace; }
.selector-help { margin-top: 16px; padding: 11px 13px; border-radius: 10px; background: var(--paper); color: var(--muted); font-size: 10px; }
code { padding: 2px 5px; border-radius: 5px; background: rgba(23,23,16,.065); color: var(--ink); font: 10px Consolas, monospace; }
.settings-savebar { position: sticky; z-index: 20; bottom: 16px; display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 12px 14px 12px 17px; border: 1px solid var(--line-dark); border-radius: 14px; background: rgba(255,255,255,.94); box-shadow: 0 14px 35px rgba(23,23,16,.12); backdrop-filter: blur(12px); }
.settings-savebar > div { display: flex; align-items: center; gap: 9px; color: var(--muted); font-size: 11px; }

.preview-dialog { width: min(900px, calc(100% - 32px)); max-height: calc(100vh - 40px); padding: 0; overflow: hidden; border: 1px solid var(--line); border-radius: 18px; background: var(--white); box-shadow: 0 30px 90px rgba(23,23,16,.22); }
.preview-dialog::backdrop { background: rgba(23,23,16,.42); backdrop-filter: blur(4px); }
.dialog-head { display: flex; align-items: center; justify-content: space-between; padding: 21px 23px 13px; }
.dialog-head h2 { margin: 4px 0 0; font-size: 24px; }
.preview-source { display: block; overflow: hidden; margin: 0 23px; color: var(--blue-dark); font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.preview-meta { display: flex; flex-wrap: wrap; gap: 7px; padding: 13px 23px; }
.preview-meta span { padding: 5px 8px; border-radius: 7px; background: var(--paper); color: var(--muted); font-size: 9px; }
.preview-warnings { margin: 0 23px 15px; padding: 12px 14px; border: 1px solid #efd7ab; border-radius: 10px; background: #fff8e9; color: #76591c; font-size: 11px; }
.preview-warnings strong { display: block; margin-bottom: 5px; color: #624810; font-size: 11px; }
.preview-warnings ul { display: grid; gap: 4px; margin: 0; padding-left: 18px; }
.preview-dialog iframe { display: block; width: 100%; height: min(540px, 60vh); border: 0; border-top: 1px solid var(--line); background: #fff; }
.toast-region { position: fixed; z-index: 100; right: 20px; bottom: 20px; display: grid; gap: 8px; width: min(360px, calc(100% - 40px)); }
.toast { padding: 13px 15px; border: 1px solid var(--line-dark); border-left: 4px solid var(--blue); border-radius: 10px; background: var(--white); box-shadow: 0 12px 35px rgba(23,23,16,.16); font-size: 11px; animation: toast-in .2s ease; }
.toast.is-error { border-left-color: var(--red); }
.toast.is-success { border-left-color: var(--green); }
@keyframes toast-in { from { transform: translateY(7px); opacity: 0; } }

.login-page { display: grid; min-height: 100vh; place-items: center; padding: 24px; background: radial-gradient(circle at 75% 15%, #e5f5ea 0, transparent 33%), var(--paper); }
.login-card { width: min(445px, 100%); padding: 34px; border: 1px solid var(--line); border-radius: 22px; background: rgba(255,255,255,.92); box-shadow: 0 25px 80px rgba(23,23,16,.1); }
.login-copy { padding: 42px 0 29px; }
.login-copy h1 { margin: 8px 0 10px; font-size: 43px; letter-spacing: -.045em; }
.login-copy > p:last-child { margin: 0; color: var(--muted); line-height: 1.6; }
.login-button svg, .button-wide svg { fill: currentColor; stroke: none; }
.login-hint { margin: 13px 0 0; color: var(--muted); font-size: 10px; text-align: center; }
.alert { margin-bottom: 14px; padding: 11px 12px; border-radius: 9px; font-size: 11px; }
.alert-error { background: var(--red-soft); color: var(--red); }
.setup-box { padding: 15px; border-radius: 11px; background: var(--orange-soft); color: #7b4a31; font-size: 11px; }
.setup-box p { margin: 6px 0 10px; }
.setup-box code { word-break: break-all; }

@media (max-width: 1100px) {
    .hero-grid { grid-template-columns: 1fr; gap: 30px; }
    .hero-stats { max-width: 700px; }
    .selector-grid { grid-template-columns: 1fr; }
    .recent-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 760px) {
    .app-header { gap: 12px; padding: 9px 14px; }
    .brand small, .user-copy { display: none; }
    .view-switcher { margin-left: auto; }
    .header-user { margin-left: 0; }
    .user-avatar { display: none; }
    .app-shell { width: min(100% - 24px, 1420px); padding-top: 25px; }
    .hero-grid { padding-top: 12px; }
    .hero-copy h1, .settings-intro h1 { font-size: 32px; }
    .hero-stats { grid-template-columns: 1fr; }
    .hero-stats > div { min-height: 90px; border-right: 0; border-bottom: 1px solid var(--line); }
    .hero-stats > div:last-child { border-bottom: 0; }
    .panel { grid-template-columns: 1fr; }
    .step-number { display: none; }
    .panel-main { padding: 22px 18px; }
    .results-heading { padding: 0 18px; }
    .selection-summary { grid-template-columns: repeat(3, 1fr); padding: 13px 18px; }
    .summary-stat { align-items: flex-start; flex-direction: column; gap: 3px; }
    .summary-stat strong { text-align: left; }
    .selection-action { grid-column: 1 / -1; margin-top: 14px; }
    .field-grid-2 { grid-template-columns: 1fr; }
    .selector-field { grid-template-columns: 34px minmax(0, 1fr); }
    .selector-field input { grid-column: 1 / -1; }
    .recent-list { grid-template-columns: 1fr; }
    .panel-heading { flex-direction: column; }
    .form-footer { align-items: stretch; flex-direction: column; }
    .form-footer .button { width: 100%; }
}
