/* ── Variables ── */
:root {
  --blue: #1677ff; --green: #52c41a; --red: #ff4d4f; --orange: #fa8c16;
  --bg: #f5f7fa; --card: #fff; --border: #e8ecf0;
  --text: #1f2937; --text2: #6b7280; --text3: #9ca3af;
  --radius: 10px; --shadow: 0 1px 3px rgba(0,0,0,.04);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", sans-serif; background: var(--bg); color: var(--text); line-height: 1.5; -webkit-font-smoothing: antialiased; }
.app { max-width: 1200px; margin: 0 auto; padding: 20px 16px; }

/* ── Admin login ── */
.login-screen { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; background: radial-gradient(circle at top, #e8f2ff, var(--bg) 52%); }
.login-card { width: 360px; max-width: 100%; padding: 30px; border: 1px solid var(--border); border-radius: 16px; background: #fff; box-shadow: 0 18px 50px rgba(31, 41, 55, .1); }
.login-mark { width: 44px; height: 44px; display: grid; place-items: center; margin-bottom: 18px; border-radius: 12px; background: var(--blue); color: #fff; font-size: 22px; font-weight: 800; }
.login-card h1 { margin-bottom: 6px; font-size: 21px; }
.login-card > p { margin-bottom: 22px; color: var(--text2); font-size: 12px; }
.login-card label { display: block; margin-bottom: 14px; color: var(--text2); font-size: 12px; font-weight: 600; }
.login-card input { width: 100%; margin-top: 6px; padding: 10px 12px; border: 1.5px solid var(--border); border-radius: 8px; font-size: 14px; }
.login-card input:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px rgba(22, 119, 255, .1); }
.login-message { margin: -2px 0 12px; padding: 8px 10px; border-radius: 7px; background: #fff1f0; color: #cf1322; font-size: 12px; }

/* ── Header ── */
.header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.header h1 { font-size: 18px; font-weight: 700; letter-spacing: -.3px; }
.header-right { display: flex; align-items: center; gap: 8px; }
.mode { font-size: 11px; background: #f0f5ff; color: var(--blue); padding: 2px 10px; border-radius: 10px; font-weight: 500; }

/* ── Database Status Section ── */
.db-status-section { margin-bottom: 16px; }
.db-status-bar { display: flex; justify-content: space-between; align-items: center; background: var(--card); border: 1.5px solid var(--blue); border-radius: var(--radius); padding: 10px 16px; box-shadow: var(--shadow); }
.db-status-left { display: flex; align-items: center; gap: 10px; }
.db-hint { font-size: 11px; color: var(--text2); }
.db-version { font-size: 11px; color: var(--text3); text-align: right; }
.db-local-panel { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 16px; margin-top: 8px; box-shadow: var(--shadow); }
.db-local-header { display: flex; justify-content: space-between; align-items: center; }

/* ── Tabs ── */
.tabs { display: flex; gap: 0; border-bottom: 2px solid var(--border); margin-bottom: 16px; }
.tab-btn { padding: 10px 24px; border: none; background: none; font-size: 13px; font-weight: 600; color: var(--text3); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -2px; transition: all .2s; }
.tab-btn:hover { color: var(--text); }
.tab-btn.active { color: var(--blue); border-bottom-color: var(--blue); }
.tab-content { display: none; }
.tab-content.active { display: block; }

/* ── Simplified update workflows ── */
.update-intro { padding: 12px 16px; margin-bottom: 12px; border-radius: var(--radius); background: #eef6ff; color: #315b86; font-size: 13px; border: 1px solid #d6e9ff; }
.update-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.update-card { position: relative; padding: 22px; border-top: 3px solid var(--blue); }
.update-card-full { border-top-color: var(--orange); }
.update-card h2 { margin: 8px 0; font-size: 20px; }
.update-card p { min-height: 64px; color: var(--text2); font-size: 13px; }
.update-card-tag { display: inline-block; padding: 2px 9px; border-radius: 12px; color: var(--blue); background: #eaf3ff; font-size: 10px; font-weight: 700; }
.update-card-tag.orange { color: #c66a00; background: #fff3e5; }
.update-steps { margin: 14px 0 14px 20px; color: var(--text2); font-size: 12px; line-height: 1.9; }
.update-stats { padding: 10px 12px; margin-bottom: 12px; border-radius: 7px; background: #f8fafc; color: var(--text2); font-size: 12px; }
.update-options { display: flex; min-height: 36px; margin-bottom: 12px; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.workflow-verify-note { color: var(--green); font-size: 11px; font-weight: 600; }
.update-primary { padding: 11px 16px; font-size: 14px; }

/* ── Real software acceptance ── */
.acceptance-hero { display: flex; align-items: center; justify-content: space-between; gap: 24px; padding: 26px; margin-bottom: 12px; overflow: hidden; border-radius: 14px; background: linear-gradient(135deg, #0f2f55, #165a83); color: #fff; box-shadow: 0 12px 30px rgba(15, 47, 85, .16); }
.acceptance-hero h2 { margin: 3px 0 7px; font-size: 23px; }
.acceptance-hero p { max-width: 760px; color: rgba(255,255,255,.78); font-size: 12px; line-height: 1.7; }
.acceptance-kicker { color: #79d6ff; font-size: 9px; font-weight: 800; letter-spacing: 1.6px; }
.acceptance-run { flex-shrink: 0; min-width: 180px; padding: 12px 18px; background: #fff; color: #124e78; }
.acceptance-run:hover:not(:disabled) { background: #eaf8ff; }
.acceptance-scope { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; margin-bottom: 12px; }
.acceptance-scope > div { min-height: 58px; padding: 9px; border: 1px solid #d9e7f2; border-radius: 8px; background: #f8fbfd; color: #4d6577; font-size: 10px; }
.acceptance-scope span { display: grid; width: 19px; height: 19px; margin-bottom: 5px; place-items: center; border-radius: 50%; background: #dceef9; color: #155f8d; font-weight: 800; }
.acceptance-status { border-color: #d6e4ff; }
.acceptance-empty { padding: 8px; color: var(--text3); text-align: center; font-size: 12px; }
.acceptance-status-head { display: flex; justify-content: space-between; align-items: center; font-size: 12px; }
.acceptance-status-head > div { display: flex; align-items: center; gap: 9px; }
.acceptance-state { padding: 2px 8px; border-radius: 10px; font-size: 10px; font-weight: 700; }
.acceptance-state.running { background: #fff7e6; color: #d46b08; }
.acceptance-state.passed { background: #f6ffed; color: #389e0d; }
.acceptance-state.failed { background: #fff1f0; color: #cf1322; }
.acceptance-progress { height: 7px; margin: 11px 0 7px; overflow: hidden; border-radius: 5px; background: #edf0f3; }
.acceptance-progress i { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, #1677ff, #39b4e6); transition: width .35s; }
.acceptance-time { color: var(--text3); font-size: 10px; }
.acceptance-summary { display: flex; align-items: center; justify-content: space-between; padding: 18px 20px; margin-bottom: 12px; border: 1px solid; border-radius: 10px; }
.acceptance-summary > div { display: flex; align-items: center; gap: 12px; }
.acceptance-summary > div > span { display: grid; width: 34px; height: 34px; place-items: center; border-radius: 50%; color: #fff; font-size: 20px; font-weight: 800; }
.acceptance-summary h3 { font-size: 15px; }
.acceptance-summary p { margin-top: 2px; color: var(--text2); font-size: 10px; }
.acceptance-summary > strong { font-size: 23px; }
.acceptance-summary.passed { border-color: #b7eb8f; background: #f6ffed; }
.acceptance-summary.passed > div > span { background: var(--green); }
.acceptance-summary.passed > strong { color: #389e0d; }
.acceptance-summary.failed { border-color: #ffccc7; background: #fff1f0; }
.acceptance-summary.failed > div > span { background: var(--red); }
.acceptance-summary.failed > strong { color: #cf1322; }
.acceptance-db-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.acceptance-db-card > strong { display: block; margin-bottom: 4px; color: #155f8d; font-size: 22px; }
.acceptance-db-card > div { color: var(--text2); font-size: 12px; }
.acceptance-db-card > small { color: var(--text3); font-size: 10px; }
.acceptance-sample-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.acceptance-sample-grid > div { padding: 9px 11px; border-radius: 7px; background: #f8fafc; }
.acceptance-sample-grid small { display: block; margin-bottom: 2px; color: var(--text3); font-size: 9px; text-transform: uppercase; }
.acceptance-sample-grid strong { font-family: "SF Mono", Menlo, monospace; font-size: 11px; }
.acceptance-sample > p { margin-top: 8px; color: var(--text3); font-size: 10px; }
.acceptance-scenario-list { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.acceptance-scenario { display: flex; gap: 9px; padding: 11px; border: 1px solid var(--border); border-left-width: 3px; border-radius: 7px; background: #fff; }
.acceptance-scenario.passed { border-left-color: var(--green); }
.acceptance-scenario.failed { border-left-color: var(--red); }
.acceptance-check { display: grid; width: 21px; height: 21px; flex-shrink: 0; place-items: center; border-radius: 50%; color: #fff; font-size: 12px; font-weight: 800; }
.acceptance-scenario.passed .acceptance-check { background: var(--green); }
.acceptance-scenario.failed .acceptance-check { background: var(--red); }
.acceptance-scenario strong { font-size: 12px; }
.acceptance-scenario p { margin-top: 2px; color: var(--text2); font-size: 10px; }
.acceptance-error { margin-top: 10px; padding: 9px 11px; border-radius: 7px; background: #fff1f0; color: #cf1322; font-size: 11px; }

/* ── Cards ── */
.card { background: var(--card); border-radius: var(--radius); padding: 16px; margin-bottom: 12px; border: 1px solid var(--border); box-shadow: var(--shadow); }
.card-title { font-size: 12px; font-weight: 700; color: var(--text2); text-transform: uppercase; letter-spacing: .5px; margin-bottom: 12px; }
.card-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }

/* ── Grid ── */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.grid-5 { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }

/* ── Stats ── */
.stat-box { text-align: center; padding: 8px; background: #f8fafc; border-radius: 8px; }
.stat-num { font-size: 18px; font-weight: 700; }
.stat-num.green { color: var(--green); } .stat-num.red { color: var(--red); }
.stat-num.blue { color: var(--blue); } .stat-num.orange { color: var(--orange); }
.stat-label { font-size: 10px; color: var(--text3); margin-top: 2px; }
.stats-inline { font-size: 12px; color: var(--text2); }

/* ── Badges ── */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 3px 10px; border-radius: 20px; font-size: 11px; font-weight: 600; }
.badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; }
.badge.running { background: #fff7e6; color: #d46b08; } .badge.running::before { background: var(--orange); animation: pulse 1.5s infinite; }
.badge.completed { background: #f6ffed; color: #389e0d; } .badge.completed::before { background: var(--green); }
.badge.failed { background: #fff1f0; color: #cf1322; } .badge.failed::before { background: var(--red); }
.badge.paused, .badge.idle { background: #f0f5ff; color: #2f54eb; } .badge.paused::before, .badge.idle::before { background: #2f54eb; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .3; } }

/* ── Buttons ── */
.btn { padding: 7px 16px; border: none; border-radius: 7px; font-size: 12px; font-weight: 600; cursor: pointer; transition: all .15s; white-space: nowrap; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-blue { background: var(--blue); color: #fff; } .btn-blue:hover:not(:disabled) { background: #0958d9; }
.btn-orange { background: var(--orange); color: #fff; } .btn-orange:hover:not(:disabled) { background: #d46b08; }
.btn-red { background: var(--red); color: #fff; } .btn-red:hover:not(:disabled) { background: #cf1322; }
.btn-outline { background: #fff; color: var(--text2); border: 1.5px solid var(--border); } .btn-outline:hover:not(:disabled) { border-color: var(--blue); color: var(--blue); }
.btn-warn { color: var(--orange) !important; border-color: var(--orange) !important; }
.btn-sm { padding: 4px 10px; font-size: 11px; }
.btn-full { width: 100%; }

/* ── Form Controls ── */
.control-label { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; color: var(--text2); white-space: nowrap; }
.input-sm { width: 60px; padding: 4px 6px; border: 1px solid var(--border); border-radius: 5px; font-size: 12px; text-align: center; }
.input-sm:focus { outline: none; border-color: var(--blue); }
.select-sm { padding: 4px 6px; border: 1px solid var(--border); border-radius: 5px; font-size: 12px; }
.input-num { width: 100px; padding: 6px 10px; border: 1.5px solid var(--border); border-radius: 7px; font-size: 13px; text-align: center; }
.input-num:focus { outline: none; border-color: var(--blue); }
.input-search { width: 100%; padding: 8px 14px; border: 1.5px solid var(--border); border-radius: 7px; font-size: 13px; }
.input-search:focus { outline: none; border-color: var(--blue); }
.file-input { font-size: 11px; max-width: 160px; }
.preset-btns { display: flex; gap: 3px; }
.preset-btn { padding: 3px 8px; border: 1px solid var(--border); border-radius: 5px; font-size: 10px; cursor: pointer; background: #fff; color: var(--text2); font-weight: 500; }
.preset-btn:hover { border-color: var(--blue); color: var(--blue); }
label.cb { font-size: 12px; display: flex; align-items: center; gap: 4px; cursor: pointer; }

/* ── Toolbar ── */
.toolbar { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 6px; padding: 8px 0; }
.toolbar + .toolbar { border-top: 1px solid var(--border); }
.toolbar-group { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.crawl-toolbar { padding-bottom: 12px; margin-bottom: 12px; border-bottom: 1px solid var(--border); }

/* ── Action Messages ── */
.action-msg { font-size: 12px; padding: 4px 10px; border-radius: 6px; display: inline-block; margin-bottom: 8px; }
.action-msg.ok { background: #f6ffed; color: #389e0d; }
.action-msg.err { background: #fff1f0; color: #cf1322; }

/* ── Progress Panel ── */
.progress-panel { background: linear-gradient(135deg, #f0f5ff 0%, #f5f0ff 100%); border: 1.5px solid #d6e4ff; margin-bottom: 16px; }
.pg-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.pg-header h3 { font-size: 14px; font-weight: 700; }
.pg-actions { display: flex; gap: 8px; align-items: center; }
.pg-meta { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-bottom: 10px; font-size: 12px; }
.pg-meta > div { background: rgba(255,255,255,.7); padding: 6px 8px; border-radius: 6px; }
.pg-meta .lbl { color: var(--text3); font-size: 9px; text-transform: uppercase; font-weight: 600; letter-spacing: .3px; display: block; margin-bottom: 1px; }
.step-box { background: #fff; border-radius: 8px; padding: 10px 14px; margin-bottom: 10px; display: flex; align-items: center; gap: 10px; }
.step-icon { width: 28px; height: 28px; background: var(--blue); border-radius: 50%; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.step-icon svg { width: 14px; height: 14px; fill: #fff; animation: spin 1.5s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.step-text strong { font-size: 13px; display: block; }
.step-text span { font-size: 11px; color: var(--text2); }
.pg-bar { height: 6px; background: #e8ecf0; border-radius: 3px; overflow: hidden; margin-bottom: 10px; display: flex; }
.pg-bar .found { background: var(--green); transition: width .5s; }
.pg-bar .notfound { background: var(--orange); transition: width .5s; }
.pg-nums { display: flex; gap: 16px; margin-bottom: 10px; font-size: 12px; }

/* ── Log ── */
.log-box { background: #111827; border-radius: 8px; padding: 10px; max-height: 240px; overflow-y: auto; font-family: "SF Mono", Menlo, Consolas, monospace; font-size: 10.5px; line-height: 1.7; }
.log-box div { white-space: nowrap; color: #9ca3af; }
.log-box .ts { color: #4b5563; } .log-box .msg { color: #d1d5db; }

/* ── Tables ── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 12px; }
th { text-align: left; padding: 6px 8px; background: #f8fafc; font-weight: 700; color: var(--text2); border-bottom: 1.5px solid var(--border); font-size: 10px; text-transform: uppercase; letter-spacing: .3px; }
td { padding: 6px 8px; border-bottom: 1px solid #f3f4f6; }
.mono { font-family: "SF Mono", Menlo, monospace; font-size: 11px; }
.err-text { color: var(--red); font-size: 11px; max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cat-tag { padding: 1px 8px; border-radius: 10px; font-size: 10px; font-weight: 500; }

/* ── Preview ── */
.preview-wrap { overflow-x: auto; max-height: 500px; overflow-y: auto; }
.preview-wrap th, .preview-wrap td { white-space: nowrap; padding: 3px 6px; font-size: 11px; max-width: 120px; overflow: hidden; text-overflow: ellipsis; }

/* ── Pagination ── */
.pagination { display: flex; align-items: center; gap: 8px; margin-top: 10px; font-size: 12px; }

/* ── Full Update Controls ── */
.fu-controls { display: flex; flex-direction: column; gap: 8px; }
.fu-control-row { display: flex; gap: 12px; align-items: center; }
.fu-import { margin-top: 6px; padding-top: 8px; border-top: 1px solid var(--border); }
.fu-import-title { font-size: 11px; color: var(--text2); margin-bottom: 6px; }
.fu-import-row { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }

/* ── Query ── */
.query-bar { display: flex; gap: 8px; margin-bottom: 16px; }
.query-bar .input-search { max-width: 400px; }

@media (max-width: 850px) {
  .acceptance-hero { align-items: stretch; flex-direction: column; }
  .acceptance-run { width: 100%; }
  .acceptance-scope { grid-template-columns: repeat(2, 1fr); }
  .acceptance-db-grid, .acceptance-scenario-list { grid-template-columns: 1fr; }
  .acceptance-sample-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ── Sessions ── */
.session-card { background: #f8fafc; border-radius: 8px; padding: 10px 12px; margin-bottom: 6px; display: flex; justify-content: space-between; align-items: center; border: 1px solid var(--border); }
.session-info { font-size: 11px; color: var(--text2); line-height: 1.4; }
.session-info strong { color: var(--text); font-size: 12px; }

/* ── Responsive ── */
@media (max-width: 768px) {
  .update-grid { grid-template-columns: 1fr; }
  .grid-3 { grid-template-columns: 1fr; }
  .grid-4, .grid-5, .pg-meta { grid-template-columns: 1fr 1fr; }
  .toolbar { flex-direction: column; align-items: flex-start; }
  .db-status-bar { flex-direction: column; gap: 8px; align-items: flex-start; }
}
