:root {
    color-scheme: light;
    --bg: #f4f7fb;
    --surface: #ffffff;
    --surface-soft: #f8fafc;
    --text: #142033;
    --muted: #68758a;
    --line: #dfe6ef;
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --success: #11845b;
    --success-soft: #eaf8f2;
    --warning: #a55b00;
    --warning-soft: #fff4dd;
    --danger: #c03636;
    --danger-soft: #fff0f0;
    --shadow: 0 18px 45px rgba(27, 45, 78, .09);
    --radius: 20px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
    margin: 0;
    min-height: 100vh;
    background: var(--bg);
    color: var(--text);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    line-height: 1.55;
}
button, input { font: inherit; }
a { color: inherit; }
code {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    overflow-wrap: anywhere;
}
.shell { width: min(1180px, calc(100% - 32px)); margin-inline: auto; }
.shell.narrow { width: min(780px, calc(100% - 32px)); }
.install-page {
    background:
        radial-gradient(circle at 10% 0%, rgba(37, 99, 235, .16), transparent 36%),
        radial-gradient(circle at 100% 30%, rgba(17, 132, 91, .10), transparent 34%),
        var(--bg);
}
.install-page .shell { padding-block: 54px; }
.login-shell { width: min(500px, calc(100% - 32px)); min-height: 100vh; display: grid; align-items: center; }
.hero-card { padding: 28px 8px 38px; text-align: center; }
.hero-card h1, .dashboard-hero h1, .login-card h1 { margin: 6px 0 12px; line-height: 1.1; letter-spacing: -.035em; }
.hero-card h1 { font-size: clamp(2.2rem, 6vw, 4.2rem); }
.dashboard-hero h1 { font-size: clamp(2rem, 4vw, 3.25rem); }
.lead { max-width: 680px; margin: 0 auto; color: var(--muted); font-size: 1.12rem; }
.eyebrow { margin: 0; color: var(--primary); font-size: .75rem; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; }
.app-mark {
    display: inline-grid;
    place-items: center;
    width: 68px;
    height: 68px;
    border-radius: 20px;
    color: #fff;
    background: linear-gradient(135deg, var(--primary), #5a8cff);
    box-shadow: 0 12px 25px rgba(37, 99, 235, .28);
    font-weight: 900;
    letter-spacing: -.05em;
}
.app-mark.small { width: 42px; height: 42px; border-radius: 13px; font-size: .85rem; box-shadow: none; }
.card {
    position: relative;
    padding: 26px;
    border: 1px solid rgba(223, 230, 239, .9);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow);
}
.card + .card { margin-top: 20px; }
.card h2 { margin: 2px 0 0; line-height: 1.2; }
.card-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; margin-bottom: 20px; }
.check-grid { display: grid; gap: 10px; margin: 22px 0; }
.check-row { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 14px; background: var(--surface-soft); }
.check-row small, .brand small, .info-list small, .account-card small, .selected-folder small, .folder-result small { display: block; color: var(--muted); }
.check-icon { display: grid; place-items: center; flex: 0 0 28px; width: 28px; height: 28px; border-radius: 50%; font-weight: 900; }
.check-icon.ok { color: var(--success); background: var(--success-soft); }
.check-icon.bad { color: var(--danger); background: var(--danger-soft); }
.status-pill { display: inline-flex; align-items: center; min-height: 29px; padding: 4px 10px; border-radius: 999px; color: var(--muted); background: #edf1f6; font-size: .75rem; font-weight: 800; white-space: nowrap; }
.status-pill.ok, .status-pill.phase-done { color: var(--success); background: var(--success-soft); }
.status-pill.bad, .status-pill.phase-error { color: var(--danger); background: var(--danger-soft); }
.status-pill.pending, .status-pill.warning, .status-pill.phase-scanning, .status-pill.phase-rendering, .status-pill.phase-uploading, .status-pill.phase-pausing, .status-pill.phase-paused { color: var(--warning); background: var(--warning-soft); }
.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    padding: 10px 17px;
    border: 1px solid transparent;
    border-radius: 12px;
    text-decoration: none;
    font-weight: 760;
    cursor: pointer;
    transition: transform .15s ease, background .15s ease, border-color .15s ease;
}
.button:hover:not(:disabled) { transform: translateY(-1px); }
.button:disabled { opacity: .45; cursor: not-allowed; }
.button.primary { color: #fff; background: var(--primary); }
.button.primary:hover:not(:disabled) { background: var(--primary-dark); }
.button.secondary { color: var(--primary); border-color: #cbd9f7; background: #f5f8ff; }
.button.ghost { color: var(--text); border-color: var(--line); background: transparent; }
.button.danger { color: var(--danger); }
.button.pause-button { color: #fff; border-color: #bd6b00; background: #bd6b00; }
.button.pause-button:hover:not(:disabled) { background: #9f5900; }
.button.jumbo { width: 100%; min-height: 56px; font-size: 1.04rem; }
.small-button { min-height: 36px; padding: 7px 12px; }
.button-row { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; margin-top: 18px; }
.external-links { margin-bottom: 18px; }
.fine-print, .muted { color: var(--muted); }
.fine-print { margin: 14px 0 0; font-size: .86rem; }
.alert { margin: 0 0 18px; padding: 13px 16px; border-radius: 13px; border: 1px solid transparent; }
.alert.success { color: var(--success); background: var(--success-soft); border-color: #ccecdf; }
.alert.warning { color: var(--warning); background: var(--warning-soft); border-color: #f2d9a9; }
.alert.error { color: var(--danger); background: var(--danger-soft); border-color: #f0caca; }
.stack-form { display: grid; gap: 14px; margin-top: 18px; }
.stack-form.compact { margin-top: 14px; }
label { display: grid; gap: 7px; color: #334158; font-size: .9rem; font-weight: 700; }
input[type="text"], input[type="password"], input[type="email"], input[type="number"], input[type="search"], input[type="date"], input[type="file"], select {
    width: 100%;
    min-height: 46px;
    padding: 10px 12px;
    border: 1px solid #cfd8e5;
    border-radius: 11px;
    color: var(--text);
    background: #fff;
    outline: none;
}
input:focus, select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37, 99, 235, .12); }
details { margin-top: 18px; border-top: 1px solid var(--line); padding-top: 14px; }
summary { color: var(--primary); cursor: pointer; font-weight: 750; }
.login-card { text-align: center; }
.login-card .stack-form, .login-card details { text-align: left; }
.login-card .app-mark { margin-bottom: 15px; }
.recovery-panel { margin-top: 20px; padding-top: 17px; border-top: 1px solid var(--line); text-align: left; }
.recovery-panel > p { margin: 0; }
.recovery-panel .fine-print { margin-top: 5px; }
.topbar { position: sticky; top: 0; z-index: 20; border-bottom: 1px solid rgba(223, 230, 239, .9); background: rgba(255,255,255,.88); backdrop-filter: blur(14px); }
.topbar-inner { min-height: 70px; display: flex; align-items: center; justify-content: space-between; gap: 18px; }
.brand { display: flex; align-items: center; gap: 11px; }
.brand strong { display: block; line-height: 1.1; }
.app-version { margin-left: auto; padding: 5px 9px; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); background: #fff; font-size: .78rem; font-weight: 800; }
.app-version-inline { display: inline-block; margin: 0 0 12px; padding: 4px 8px; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); background: rgba(255,255,255,.75); font-size: .78rem; font-weight: 800; }
.global-version-badge {
    position: fixed;
    right: 12px;
    bottom: 12px;
    z-index: 1000;
    padding: 6px 10px;
    border: 1px solid var(--line);
    border-radius: 999px;
    color: var(--muted);
    background: rgba(255,255,255,.94);
    box-shadow: 0 5px 18px rgba(27,45,78,.12);
    font-size: .76rem;
    font-weight: 850;
    pointer-events: none;
}
.dashboard { padding-block: 38px 70px; }
.dashboard-hero { display: flex; align-items: flex-end; justify-content: space-between; gap: 28px; padding: 18px 4px 34px; }
.dashboard-hero p:last-child { margin-bottom: 0; color: var(--muted); }
.overall-status { display: flex; align-items: center; gap: 11px; min-width: 215px; padding: 14px 16px; border: 1px solid var(--line); border-radius: 15px; background: rgba(255,255,255,.7); }
.overall-status small, .overall-status strong { display: block; }
.overall-status small { color: var(--muted); }
.status-dot { width: 12px; height: 12px; border-radius: 50%; background: #d69a3d; box-shadow: 0 0 0 5px rgba(214,154,61,.13); }
.status-dot.ok { background: var(--success); box-shadow: 0 0 0 5px rgba(17,132,91,.13); }
.steps-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 24px 18px; align-items: stretch; }
.step-card { min-height: 100%; padding-top: 32px; }
.step-card.complete { border-top: 4px solid var(--success); }
.step-number { position: absolute; top: -14px; left: 22px; display: grid; place-items: center; width: 34px; height: 34px; border-radius: 11px; color: #fff; background: var(--primary); font-weight: 900; box-shadow: 0 7px 14px rgba(37,99,235,.24); }
.info-list { display: grid; gap: 10px; margin: 0; }
.info-list > div { display: grid; gap: 2px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.info-list dt { color: var(--muted); font-size: .8rem; }
.info-list dd { margin: 0; font-weight: 650; overflow-wrap: anywhere; }
.secret-card { border: 1px solid #f0d393; background: linear-gradient(135deg, #fffaf0, #fff); }
.secret-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.secret-grid > div { position: relative; padding: 14px; border: 1px solid #eddbb5; border-radius: 14px; background: rgba(255,255,255,.7); }
.secret-grid small, .secret-grid code { display: block; }
.secret-grid code { margin: 5px 0 10px; font-size: 1.04rem; font-weight: 800; word-break: break-all; }
.copy-button { padding: 5px 9px; border: 1px solid var(--line); border-radius: 8px; color: var(--primary); background: #fff; font-size: .78rem; font-weight: 800; cursor: pointer; }
.copy-field { display: flex; align-items: center; gap: 10px; padding: 11px 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-soft); }
.copy-field code { flex: 1; font-size: .8rem; }
.mini-steps { padding-left: 20px; }
.mini-steps li { margin-bottom: 8px; }
.account-card, .selected-folder { display: flex; align-items: center; gap: 12px; padding: 13px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface-soft); }
.account-card img { width: 46px; height: 46px; border-radius: 50%; }
.account-card strong, .account-card small, .selected-folder strong, .selected-folder small { display: block; }
.selected-folder > div { min-width: 0; }
.selected-folder-list { display: grid; gap: 8px; }
.selected-folder strong { margin: 3px 0 6px; overflow-wrap: anywhere; }
.selected-folder code { overflow-wrap: anywhere; word-break: break-word; }
.folder-icon { display: inline-grid; place-items: center; flex: 0 0 40px; width: 40px; height: 34px; border-radius: 9px; color: #a65e00; background: #fff1c8; }
.folder-picker-trigger { margin-top: 16px; }
.inline-settings { display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: end; margin-top: 18px; }
.upload-test { display: grid; gap: 10px; margin-top: 18px; padding: 14px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface-soft); }
.upload-test p { margin: 4px 0 0; }
.upload-test-result { margin: 0; overflow-wrap: anywhere; }
.upload-test-result a { font-weight: 800; }
.inventory-card { margin-top: 24px; }
.automation-card { margin-top: 24px; }
.field-label { display: block; margin-top: 18px; }
.cron-instruction { display: grid; gap: 5px; margin: 18px 0; padding: 15px 17px; border: 1px solid #cbd9f7; border-radius: 14px; color: #25406f; background: #f5f8ff; }
.cron-instruction span { color: var(--muted); font-size: .9rem; }
.cron-copy-field code { overflow-wrap: anywhere; word-break: break-all; }
.cron-settings-form { display: grid; grid-template-columns: minmax(250px, 1.2fr) minmax(220px, .8fr) auto; gap: 14px; align-items: end; margin-top: 20px; }
.cron-toggle { min-height: 48px; display: flex; grid-template-columns: none; align-items: center; gap: 12px; padding: 10px 13px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-soft); }
.cron-toggle input { flex: 0 0 auto; width: 20px; height: 20px; accent-color: var(--primary); }
.cron-toggle span, .cron-toggle strong, .cron-toggle small { display: block; }
.cron-toggle small { margin-top: 2px; color: var(--muted); font-weight: 500; }
.cron-stats { grid-template-columns: repeat(3, 1fr); }
.cron-stats strong { font-size: 1rem; overflow-wrap: anywhere; }
.progress-track { width: 100%; height: 14px; border: 0; border-radius: 999px; overflow: hidden; background: #e6ebf2; }
.progress-track::-webkit-progress-bar { background: #e6ebf2; border-radius: 999px; }
.progress-track::-webkit-progress-value { background: linear-gradient(90deg, var(--primary), #65a0ff); border-radius: 999px; transition: width .25s ease; }
.progress-track::-moz-progress-bar { background: linear-gradient(90deg, var(--primary), #65a0ff); border-radius: 999px; }
.progress-message { min-height: 1.5em; color: var(--muted); }
.workflow-status { display: grid; gap: 10px; margin: 16px 0; padding: 15px 17px; border: 1px solid #cbd9f7; border-radius: 14px; background: #f5f8ff; }
.workflow-details { display: flex; flex-wrap: wrap; gap: 8px 20px; color: var(--muted); font-size: .9rem; }
.workflow-status p { margin: 0; color: var(--success); overflow-wrap: anywhere; }
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin: 18px 0; }
.stats-grid > div { padding: 13px; border: 1px solid var(--line); border-radius: 13px; background: var(--surface-soft); }
.stats-grid small, .stats-grid strong { display: block; }
.stats-grid small { color: var(--muted); }
.stats-grid strong { margin-top: 3px; font-size: 1.3rem; }
.counter-explanation { display: grid; gap: 6px; margin: -4px 0 18px; padding: 13px 15px; border-left: 4px solid #7ca2ef; border-radius: 0 10px 10px 0; background: #f7f9fe; color: var(--muted); font-size: .88rem; line-height: 1.45; }
.counter-explanation strong, .counter-explanation b { color: var(--text); }
.counter-explanation span { display: block; }
.search-card { margin-top: 24px; }
.navigation-guarantee {
    display: grid;
    gap: 5px;
    margin: 18px 0;
    padding: 14px 16px;
    border: 1px solid #cbd9f7;
    border-radius: 14px;
    background: #f5f8ff;
}
.navigation-guarantee span { color: var(--muted); font-size: .9rem; }
.navigation-actions { align-items: center; margin-bottom: 20px; }
.navigation-actions .fine-print { margin: 0; }
.search-index-error { color: var(--danger); }
.search-filter-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
    padding: 18px;
    border: 1px solid var(--line);
    border-radius: 16px;
    background: var(--surface-soft);
}
.search-filter-actions {
    display: flex;
    align-items: end;
    gap: 10px;
}
.search-filter-actions .button { flex: 1; }
.search-results-summary {
    min-height: 1.5em;
    margin: 20px 0 10px;
    color: var(--muted);
    font-weight: 700;
}
.search-table-wrap {
    overflow-x: auto;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: #fff;
}
.search-results-table {
    width: 100%;
    min-width: 840px;
    border-collapse: collapse;
    text-align: left;
}
.search-results-table th,
.search-results-table td {
    padding: 13px 14px;
    border-bottom: 1px solid var(--line);
    vertical-align: top;
}
.search-results-table th {
    color: var(--muted);
    background: var(--surface-soft);
    font-size: .8rem;
}
.search-results-table tbody tr:last-child td { border-bottom: 0; }
.search-result-name { max-width: 260px; font-weight: 800; overflow-wrap: anywhere; }
.search-result-type { white-space: nowrap; }
.search-result-paths { min-width: 310px; }
.search-result-paths span {
    display: block;
    max-width: 520px;
    overflow-wrap: anywhere;
}
.search-result-paths span + span { margin-top: 5px; }
.search-result-date { white-space: nowrap; }
.search-pagination {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 14px;
}
.search-pagination span { color: var(--muted); font-size: .9rem; font-weight: 800; }
.working-indicator { display: inline-flex; align-items: center; gap: 9px; color: var(--muted); font-weight: 700; }
.working-indicator span { width: 12px; height: 12px; border: 2px solid #b8c8e9; border-top-color: var(--primary); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.folder-dialog { width: min(720px, calc(100% - 24px)); max-height: 82vh; padding: 24px; border: 1px solid var(--line); border-radius: 20px; color: var(--text); background: var(--surface); box-shadow: 0 30px 90px rgba(22,34,56,.28); }
.folder-dialog::backdrop { background: rgba(14,25,43,.55); backdrop-filter: blur(3px); }
.dialog-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; }
.dialog-top h2 { margin: 2px 0 0; }
.icon-button { width: 38px; height: 38px; border: 1px solid var(--line); border-radius: 10px; background: #fff; font-size: 1.5rem; cursor: pointer; }
.folder-search { display: grid; grid-template-columns: 1fr auto; gap: 10px; margin: 20px 0 14px; }
.folder-dialog-help { margin: -8px 0 0; }
.folder-browser-toolbar { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.folder-current { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 14px; padding: 13px; border: 1px solid #cbd9f7; border-radius: 14px; background: #f5f8ff; }
.folder-current small, .folder-current strong { display: block; }
.folder-current small { color: var(--muted); }
.folder-current strong { margin-top: 2px; overflow-wrap: anywhere; }
.folder-results { display: grid; gap: 8px; max-height: 48vh; overflow: auto; padding-right: 4px; }
.folder-result { display: flex; align-items: center; gap: 12px; width: 100%; padding: 11px; border: 1px solid var(--line); border-radius: 12px; text-align: left; color: var(--text); background: #fff; cursor: pointer; }
.folder-result:hover:not(:disabled) { border-color: #a9bfe9; background: #f7f9ff; }
.selectable-folder-result { cursor: default; }
.selectable-folder-result input[type="checkbox"] { flex: 0 0 auto; width: 21px; height: 21px; accent-color: var(--primary); }
.scan-selection-footer { position: sticky; bottom: -24px; display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 16px -24px -24px; padding: 14px 24px; border-top: 1px solid var(--line); background: var(--surface); box-shadow: 0 -8px 20px rgba(22,34,56,.08); }
.scan-selection-footer span { font-weight: 800; }
.folder-result:disabled { opacity: .55; cursor: not-allowed; }
.folder-result strong, .folder-result small { display: block; }
.folder-result-text { min-width: 0; flex: 1; }
.folder-result strong, .folder-result small { overflow-wrap: anywhere; }
.folder-chevron { margin-left: auto; color: var(--primary); font-size: 1.8rem; line-height: 1; }
.hidden { display: none !important; }

@media (max-width: 920px) {
    .steps-grid { grid-template-columns: 1fr; gap: 24px; }
    .dashboard-hero { align-items: flex-start; flex-direction: column; }
    .overall-status { width: 100%; }
    .cron-settings-form { grid-template-columns: 1fr; align-items: stretch; }
    .search-filter-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 640px) {
    .shell { width: min(100% - 20px, 1180px); }
    .card { padding: 20px; border-radius: 16px; }
    .hero-card h1 { font-size: 2.25rem; }
    .secret-grid, .stats-grid, .cron-stats { grid-template-columns: 1fr 1fr; }
    .copy-field, .button-row { align-items: stretch; flex-direction: column; }
    .button-row .button, .button-row form, .button-row form .button { width: 100%; }
    .inline-settings, .folder-search { grid-template-columns: 1fr; }
    .folder-current { align-items: stretch; flex-direction: column; }
    .search-filter-grid { grid-template-columns: 1fr; padding: 14px; }
    .search-filter-actions { align-items: stretch; flex-direction: column; }
    .search-filter-actions .button { width: 100%; }
    .search-pagination { justify-content: space-between; }
}
