:root {
  --navy: #172642;
  --navy-2: #24385b;
  --blue: #2f6feb;
  --blue-soft: #edf4ff;
  --yellow: #f5cb3d;
  --ink: #1d2738;
  --muted: #687386;
  --line: #dfe5ee;
  --surface: #ffffff;
  --canvas: #f4f6f9;
  --danger: #b42318;
  --success: #087a55;
  --radius: 16px;
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--canvas); color: var(--ink); line-height: 1.45; }
button, input, textarea { font: inherit; }
button, summary, input[type="checkbox"] { cursor: pointer; }
a { color: inherit; }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: clamp(1.65rem, 3vw, 2.25rem); line-height: 1.15; }
h2 { margin-bottom: 0; font-size: clamp(1.25rem, 2vw, 1.55rem); line-height: 1.2; }

.page-width { width: min(1180px, calc(100% - 40px)); margin-inline: auto; }
.topbar { background: var(--navy); color: #fff; padding: 28px 0; }
.topbar-inner { display: flex; align-items: center; justify-content: space-between; gap: 24px; }
.topbar-actions { display: flex; align-items: center; gap: 12px; }
.schedule-badge { border-radius: 999px; padding: 7px 10px; background: rgba(255,255,255,.09); color: #c7cfdd; font-size: .75rem; font-weight: 750; }
.schedule-badge.is-on { background: rgba(245,203,61,.14); color: var(--yellow); }
.eyebrow, .step { margin-bottom: 6px; color: var(--yellow); font-size: .72rem; font-weight: 800; letter-spacing: .09em; text-transform: uppercase; }
.layout { display: grid; gap: 24px; padding-block: 28px 56px; }
.tabs { display: inline-flex; width: max-content; gap: 5px; padding: 5px; border: 1px solid var(--line); border-radius: 13px; background: #e9edf3; }
.tab-button { min-width: 130px; border: 0; border-radius: 9px; background: transparent; color: var(--muted); padding: 10px 18px; font-weight: 800; }
.tab-button.is-active { background: #fff; color: var(--navy); box-shadow: 0 2px 8px rgba(23,38,66,.09); }
.tab-panel-stack { display: grid; gap: 24px; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 28px; box-shadow: 0 8px 28px rgba(23, 38, 66, .05); }
.section-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin-bottom: 24px; }
.section-note { max-width: 430px; margin-bottom: 0; color: var(--muted); font-size: .9rem; text-align: right; }
.step { color: var(--blue); }
.muted, small, .field-help { color: var(--muted); }
.field-help { margin: -4px 0 16px; font-size: .9rem; }

label > span:first-child, legend { display: block; margin-bottom: 7px; color: var(--navy); font-weight: 700; font-size: .9rem; }
input:not([type="checkbox"]), textarea, select { width: 100%; border: 1px solid #cbd4e1; border-radius: 10px; background: #fff; color: var(--ink); padding: 11px 12px; outline: none; transition: border .15s, box-shadow .15s; }
input:not([type="checkbox"]):focus, textarea:focus, select:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(47, 111, 235, .13); }
textarea { resize: vertical; }
label small { display: block; margin-top: 6px; font-size: .78rem; }
.form-row { display: flex; margin-bottom: 24px; }
.date-field { width: min(360px, 100%); }
fieldset { min-width: 0; margin: 0; padding: 0; border: 0; }
legend { font-size: 1rem; }

.project-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.project-card { min-width: 0; border: 1px solid var(--line); border-radius: 13px; overflow: hidden; transition: border .15s, opacity .15s; }
.project-card:has([data-project-toggle]:checked) { border-color: #a9bce0; }
.project-card.is-disabled { opacity: .55; }
.project-select { display: flex; align-items: center; gap: 12px; min-height: 76px; padding: 15px 16px; background: #fbfcfe; cursor: pointer; }
.project-select input { position: absolute; opacity: 0; pointer-events: none; }
.project-select strong, .project-select small { display: block; }
.project-select small { margin-top: 2px; font-weight: 400; }
.checkmark { flex: 0 0 22px; width: 22px; height: 22px; border: 2px solid #aab4c4; border-radius: 6px; position: relative; }
.project-select input:checked + .checkmark { background: var(--blue); border-color: var(--blue); }
.project-select input:checked + .checkmark::after { content: ""; position: absolute; left: 6px; top: 2px; width: 5px; height: 10px; border: solid #fff; border-width: 0 2px 2px 0; transform: rotate(45deg); }
details { border-top: 1px solid var(--line); }
summary { padding: 11px 16px; color: var(--blue); font-size: .86rem; font-weight: 700; list-style-position: inside; }
.crm-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; padding: 8px 16px 18px; }
.field-span { grid-column: 1 / -1; }

.options-card { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-top: 22px; padding: 15px; border-radius: 13px; background: #f7f9fc; }
.switch-row { display: flex; align-items: flex-start; gap: 10px; padding: 8px; cursor: pointer; }
.switch-row input { flex: 0 0 auto; width: 18px; height: 18px; margin: 2px 0 0; accent-color: var(--blue); }
.switch-row span { margin: 0; font-size: .88rem; }
.switch-row strong, .switch-row small { display: block; }
.switch-row small { margin-top: 3px; font-weight: 400; }
.form-actions { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-top: 22px; }
.form-actions p { margin-bottom: 0; font-size: .85rem; }
.settings-form { display: grid; grid-template-columns: minmax(260px, .8fr) minmax(340px, 1.2fr); gap: 22px; }
.schedule-fields { display: grid; grid-template-columns: minmax(160px, 1fr) minmax(140px, .7fr); align-content: start; gap: 14px; }
.schedule-toggle { grid-column: 1 / -1; margin-top: 2px; padding: 10px 0; }
.auto-projects { grid-column: 1 / -1; padding-top: 18px; border-top: 1px solid var(--line); }
.auto-project-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.auto-project-option { display: flex; align-items: center; gap: 10px; min-height: 48px; border: 1px solid var(--line); border-radius: 10px; background: #fbfcfe; padding: 10px 12px; cursor: pointer; }
.auto-project-option input { width: 18px; height: 18px; margin: 0; accent-color: var(--blue); }
.auto-project-option span { margin: 0; font-size: .88rem; font-weight: 700; }
.settings-actions { grid-column: 1 / -1; margin-top: 0; padding-top: 18px; border-top: 1px solid var(--line); }

.button { border: 0; border-radius: 10px; padding: 10px 16px; font-weight: 750; transition: transform .1s, opacity .15s, background .15s; }
.button:hover:not(:disabled) { transform: translateY(-1px); }
.button:disabled { cursor: not-allowed; opacity: .5; }
.button-primary { background: var(--blue); color: #fff; padding: 12px 22px; box-shadow: 0 5px 14px rgba(47, 111, 235, .2); }
.button-quiet { background: rgba(255,255,255,.1); color: #fff; }
.button-wide { width: 100%; }
.button-small { padding: 8px 11px; font-size: .8rem; }
.button-danger { border: 1px solid #efc1bc; background: #fff5f3; color: var(--danger); }
.heading-actions { display: flex; align-items: center; gap: 10px; }
.icon-button { display: grid; place-items: center; width: 30px; height: 30px; border: 1px solid #e2b9b5; border-radius: 8px; background: #fff; color: var(--danger); font-size: 1.1rem; line-height: 1; }
.icon-button:hover { background: #fff0ee; }

.notice { border-radius: 11px; padding: 12px 15px; font-size: .9rem; }
.notice-error { background: #fff0ee; border: 1px solid #f4c7c2; color: var(--danger); }
.notice-success { background: #eaf8f2; border: 1px solid #b8e3d2; color: var(--success); }
.running-banner { display: flex; align-items: center; gap: 14px; border-radius: 13px; padding: 15px 18px; background: var(--blue-soft); border: 1px solid #c8dafb; color: var(--navy); }
.running-banner span:not(.spinner) { color: var(--muted); font-size: .87rem; }
.spinner { width: 23px; height: 23px; border: 3px solid #bed0ef; border-top-color: var(--blue); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.history-list, .file-list { display: grid; }
.history-item { display: grid; grid-template-columns: minmax(230px, .8fr) minmax(0, 1.2fr); gap: 20px; padding: 17px 0; border-top: 1px solid var(--line); }
.history-item:first-child, .file-row:first-child { border-top: 0; padding-top: 0; }
.history-main strong, .history-main small { display: block; }
.history-main strong { margin-top: 8px; }
.history-main small { margin-top: 3px; }
.history-result { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 8px; min-width: 0; }
.status { display: inline-flex; border-radius: 999px; padding: 4px 8px; background: #edf0f4; color: #566172; font-size: .72rem; font-weight: 800; text-transform: uppercase; letter-spacing: .03em; }
.status-completed { background: #e7f7f0; color: var(--success); }
.status-completed_with_errors, .status-failed, .status-interrupted { background: #fff0ee; color: var(--danger); }
.status-running, .status-queued { background: var(--blue-soft); color: var(--blue); }
.file-link { border-radius: 8px; background: var(--blue-soft); color: #2459b9; padding: 7px 10px; font-size: .82rem; font-weight: 700; text-decoration: none; }
.error-text { width: 100%; color: var(--danger); font-size: .8rem; text-align: right; overflow-wrap: anywhere; }
.count-badge { min-width: 32px; border-radius: 999px; padding: 5px 9px; background: #edf0f4; color: var(--muted); font-size: .8rem; font-weight: 800; text-align: center; }
.file-row { display: grid; grid-template-columns: auto minmax(0, 1fr) auto auto auto; align-items: center; gap: 13px; padding: 12px 0; border-top: 1px solid var(--line); }
.doc-icon { display: grid; place-items: center; width: 32px; height: 36px; border-radius: 6px; background: #1f5fae; color: #fff; font-weight: 900; }
.file-name { min-width: 0; overflow: hidden; color: var(--ink); text-overflow: ellipsis; white-space: nowrap; font-size: .9rem; font-weight: 650; text-decoration: none; }
.file-size { color: var(--muted); font-size: .8rem; }
.download-label { color: var(--blue); font-size: .82rem; font-weight: 750; }
.empty-state { padding: 26px; border: 1px dashed #cbd4e1; border-radius: 12px; color: var(--muted); text-align: center; }

.login-shell { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: radial-gradient(circle at 20% 10%, #2a426c 0, var(--navy) 44%, #111c31 100%); }
.login-card { width: min(420px, 100%); border-radius: 18px; background: #fff; padding: 34px; box-shadow: 0 28px 80px rgba(0,0,0,.28); }
.brand-mark { display: grid; place-items: center; width: 42px; height: 42px; margin-bottom: 22px; border-radius: 11px; background: var(--navy); color: var(--yellow); font-size: 1.2rem; font-weight: 900; }
.login-card .eyebrow { color: var(--blue); }
.login-card h1 { margin-bottom: 8px; }
.stack { display: grid; gap: 16px; margin-top: 22px; }
.stack .notice { margin-bottom: 0; }

@media (max-width: 760px) {
  .page-width { width: min(100% - 24px, 1180px); }
  .topbar { padding: 20px 0; }
  .topbar-actions { align-items: flex-end; flex-direction: column-reverse; gap: 6px; }
  .schedule-badge { max-width: 150px; padding: 0; background: transparent !important; text-align: right; }
  .topbar .eyebrow { font-size: .64rem; }
  .layout { gap: 14px; padding-block: 14px 36px; }
  .tabs { display: grid; width: 100%; grid-template-columns: 1fr 1fr; }
  .tab-button { min-width: 0; padding-inline: 10px; }
  .tab-panel-stack { gap: 14px; }
  .panel { padding: 18px 15px; border-radius: 13px; }
  .section-heading { display: block; margin-bottom: 18px; }
  .section-note { margin-top: 8px; text-align: left; }
  .project-grid, .options-card { grid-template-columns: 1fr; }
  .settings-form, .schedule-fields { grid-template-columns: 1fr; }
  .auto-project-grid { grid-template-columns: 1fr; }
  .schedule-toggle, .settings-actions { grid-column: auto; }
  .crm-fields { grid-template-columns: 1fr; }
  .field-span { grid-column: auto; }
  .form-actions { align-items: stretch; flex-direction: column; }
  .form-actions .button { width: 100%; }
  .history-item { grid-template-columns: 1fr; gap: 12px; }
  .history-result { justify-content: flex-start; }
  .error-text { text-align: left; }
  .file-row { grid-template-columns: auto minmax(0, 1fr) auto auto; }
  .file-size { display: none; }
  .download-label { font-size: 0; }
  .download-label::after { content: "↓"; font-size: 1.25rem; }
  .login-card { padding: 26px 22px; }
}
