:root {
  color-scheme: light;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  color: #0f172a;
  background: #f7f9fc;
  --bg: #f7f9fc;
  --panel: #ffffff;
  --ink: #0f172a;
  --muted: #64748b;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --primary-soft: #eef2ff;
  --accent: #0f766e;
  --accent-soft: #ecfdf5;
  --danger: #b42318;
  --danger-soft: #fff1f2;
  --warning: #a16207;
  --warning-soft: #fffbeb;
  --focus: rgb(79 70 229 / .18);
  --shadow-sm: 0 1px 2px rgb(15 23 42 / .05);
  --shadow-frozen: 9px 0 12px -12px rgb(15 23 42 / .55);
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; background: var(--bg); color: var(--ink); font-size: 14px; line-height: 1.5; }
[hidden] { display: none !important; }
button, input { font: inherit; letter-spacing: 0; }
button {
  min-height: 34px;
  padding: 0 13px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
  box-shadow: var(--shadow-sm);
  color: #273247;
  cursor: pointer;
  white-space: nowrap;
  transition: background .16s ease, border-color .16s ease, box-shadow .16s ease;
}
button:hover:not(:disabled) { border-color: var(--border-strong); background: #f8fafc; }
button:focus-visible, input:focus-visible { outline: 0; border-color: var(--primary); box-shadow: 0 0 0 3px var(--focus); }
button:disabled { cursor: not-allowed; opacity: .46; }
button.primary { border-color: var(--primary); background: var(--primary); color: #fff; box-shadow: 0 5px 12px -8px rgb(79 70 229 / .85); }
button.primary:hover:not(:disabled) { border-color: var(--primary-hover); background: var(--primary-hover); }
button.danger { border-color: #fecaca; background: #fff; color: var(--danger); }
button.danger:hover:not(:disabled) { border-color: #fda4af; background: var(--danger-soft); }

.app-header {
  display: flex;
  height: 72px;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 0 24px;
  border-bottom: 1px solid var(--border);
  background: rgb(255 255 255 / .96);
  box-shadow: 0 1px 0 rgb(15 23 42 / .02);
}
.brand { display: flex; min-width: 0; align-items: center; gap: 11px; }
.brand-mark { display: grid; width: 34px; height: 34px; place-items: center; border-radius: 6px; background: var(--primary); color: #fff; font-weight: 800; }
.brand h1 { margin: 0; font-size: 18px; line-height: 1.25; letter-spacing: 0; }
.brand p { margin: 3px 0 0; color: var(--muted); font-size: 12px; }
.header-status { display: flex; align-items: center; gap: 8px; }
.status-pill {
  display: inline-flex;
  min-height: 28px;
  align-items: center;
  padding: 0 9px;
  border: 1px solid #a7f3d0;
  border-radius: 5px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 12px;
  font-weight: 650;
}
.status-pill::before { width: 6px; height: 6px; margin-right: 6px; border-radius: 50%; background: #10b981; content: ""; }
.status-pill.pending { border-color: var(--border); background: #f8fafc; color: var(--muted); }
.status-pill.pending::before { background: #94a3b8; }
.status-pill.error { border-color: #fecdd3; background: var(--danger-soft); color: var(--danger); }
.status-pill.error::before { background: #f43f5e; }

main { width: min(1680px, 100%); margin: 0 auto; padding: 0 24px 28px; }
.tabs { display: flex; height: 58px; align-items: end; gap: 2px; border-bottom: 1px solid var(--border); }
.tabs button { height: 41px; padding: 0 15px; border: 0; border-bottom: 2px solid transparent; border-radius: 0; background: transparent; box-shadow: none; color: #64748b; font-weight: 680; }
.tabs button:hover:not(:disabled) { background: #f1f5f9; color: #334155; }
.tabs button.active { border-bottom-color: var(--primary); background: transparent; color: var(--primary); }
.tabs button span { margin-left: 5px; color: #94a3b8; font-size: 12px; font-variant-numeric: tabular-nums; }
.tabs button.active span { color: #6366f1; }
.view { padding-top: 16px; }
.view[hidden] { display: none !important; }
.ranking-controls { display: flex; flex-wrap: wrap; gap: 24px; align-items: end; margin-bottom: 12px; padding: 14px; border: 1px solid var(--border); border-radius: 6px; background: var(--panel); box-shadow: var(--shadow-sm); }
.ranking-controls > div, .ranking-controls > label { display: grid; gap: 7px; }
.control-label { color: var(--muted); font-size: 12px; font-weight: 700; }
.segmented { display: inline-flex; overflow: hidden; border: 1px solid var(--border); border-radius: 5px; background: #f8fafc; }
.segment { min-height: 32px; padding: 0 14px; border: 0; border-right: 1px solid var(--border); border-radius: 0; background: transparent; color: #475569; font-size: 12px; }
.segment:last-child { border-right: 0; }
.segment.is-active { background: var(--primary-soft); color: var(--primary); font-weight: 750; }
.ranking-controls input { height: 32px; padding: 0 8px; border: 1px solid var(--border); border-radius: 5px; color: #334155; }
.ranking-date-control { padding: 3px 5px 5px; border-radius: 6px; cursor: pointer; }
.ranking-date-control:hover { background: #f8fafc; }
.ranking-date-control input { width: 100%; cursor: pointer; }
.ranking-meta { display: flex; align-items: center; justify-content: space-between; width: 100%; margin-bottom: 9px; color: var(--muted); font-size: 12px; }
.ranking-times { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 8px 18px; }
.ranking-times span { white-space: nowrap; }
.ranking-automation-panel { grid-area: ranking; min-width: 0; padding: 16px; border: 1px solid var(--border); border-radius: 6px; background: var(--panel); box-shadow: var(--shadow-sm); }
.ranking-auto-note { color: var(--muted); font-size: 12px; line-height: 1.7; margin: 8px 0; }
.ranking-cookie-form { padding: 12px 0; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.ranking-cookie-form label, .ranking-auto-form label { font-size: 12px; font-weight: 600; }
#ranking-cookie-status { margin-left: 8px; color: var(--muted); font-weight: 400; }
#ranking-cookie { display: block; width: 100%; margin-top: 8px; padding: 9px 10px; border: 1px solid var(--border); border-radius: 5px; }
.ranking-auto-form { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px; margin: 16px 0; }
.ranking-auto-form .number-input { margin-top: 6px; }
.ranking-auto-form input { width: 100px; height: 34px; padding: 7px 9px; border: 0; background: transparent; outline-offset: -2px; }
.ranking-auto-overview { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.ranking-auto-overview strong { font-size: 12px; overflow-wrap: anywhere; }
.ranking-auto-message { margin: 12px 0; font-size: 12px; line-height: 1.7; }
.ranking-auto-message.error { color: var(--danger); }
.ranking-log-dialog { width: min(1100px, 94vw); max-height: 85vh; padding: 20px; border: 1px solid var(--border); border-radius: 8px; }
.ranking-log-dialog::backdrop { background: rgba(15, 23, 42, .35); }
.ranking-log-dialog td:last-child { min-width: 150px; white-space: normal; overflow-wrap: anywhere; }
@media (max-width: 700px) { .ranking-meta { align-items: flex-start; gap: 12px; } .ranking-times { flex-direction: column; gap: 5px; } }

/* Filter structure is intentionally unchanged; these rules only align its visual language. */
.source-bar { display: flex; gap: 12px; align-items: end; padding: 14px; border: 1px solid var(--border); border-radius: 6px; background: var(--panel); box-shadow: var(--shadow-sm); }
.source-main { flex: 1; min-width: 0; }
.section-label { display: block; margin-bottom: 7px; color: #475569; font-size: 12px; font-weight: 700; }
.source-main input { width: 100%; height: 36px; padding: 0 11px; border: 1px solid var(--border); border-radius: 5px; background: #f8fafc; color: #475569; }
.metrics { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 10px; margin: 12px 0; }
.metrics > div { min-height: 78px; padding: 13px 14px; border: 1px solid var(--border); border-radius: 6px; background: var(--panel); box-shadow: var(--shadow-sm); }
.metrics span { display: block; color: var(--muted); font-size: 12px; }
.metrics strong { display: block; margin-top: 9px; overflow-wrap: anywhere; font-size: 20px; font-variant-numeric: tabular-nums; letter-spacing: 0; }
.metrics strong.accent { color: var(--primary); }
.workspace-grid { display: grid; grid-template-areas: "settings progress" "automation ranking"; grid-template-columns: minmax(420px, .9fr) minmax(460px, 1.1fr); gap: 12px; align-items: start; }
.settings-panel { grid-area: settings; }
.progress-panel { grid-area: progress; }
.automation-panel { grid-area: automation; }
.settings-panel, .progress-panel, .automation-panel { padding: 16px; border: 1px solid var(--border); border-radius: 6px; background: var(--panel); box-shadow: var(--shadow-sm); }
.panel-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 15px; }
.panel-heading h2, .table-toolbar h2 { margin: 0; font-size: 15px; letter-spacing: 0; }
.panel-heading span, .table-toolbar span { color: var(--muted); font-size: 12px; }
.count-badge { padding: 4px 7px; border-radius: 4px; background: var(--primary-soft); color: var(--primary) !important; font-weight: 700; }
fieldset { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 16px; padding: 0; border: 0; }
legend { width: 100%; margin-bottom: 8px; color: #334155; font-size: 12px; font-weight: 750; }
fieldset label { position: relative; cursor: pointer; }
fieldset input { position: absolute; opacity: 0; pointer-events: none; }
fieldset label span { display: grid; min-width: 70px; height: 34px; place-items: center; padding: 0 12px; border: 1px solid var(--border); border-radius: 5px; background: #fff; font-size: 13px; }
fieldset label:hover span { border-color: var(--border-strong); background: #f8fafc; }
fieldset input:focus-visible + span { border-color: var(--primary); box-shadow: 0 0 0 3px var(--focus); }
fieldset input:checked + span { border-color: #a5b4fc; background: var(--primary-soft); color: var(--primary); font-weight: 750; }
.bands label span { min-width: 96px; }
.locked-rules { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; padding: 12px; border: 1px solid #c7d2fe; border-radius: 5px; background: #f8faff; }
.locked-rules span { padding: 4px 7px; border-radius: 4px; background: #e0e7ff; color: #4338ca; font-size: 12px; }
.locked-rules .rule-label { padding-left: 0; background: transparent; color: #475569; font-weight: 750; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.task-id { max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.progress-track { height: 8px; overflow: hidden; border-radius: 4px; background: #e8edf4; }
#progress-bar { width: 0; height: 100%; background: var(--primary); transition: width .25s ease; }
.progress-detail { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-top: 15px; }
.progress-detail > div { min-height: 70px; padding: 12px; border: 1px solid var(--border); border-radius: 5px; background: #fff; }
.progress-detail span { display: block; color: var(--muted); font-size: 12px; }
.progress-detail strong { display: block; margin-top: 8px; overflow-wrap: anywhere; font-size: 16px; font-variant-numeric: tabular-nums; }
.message { margin-top: 12px; padding: 11px 12px; border-left: 3px solid #94a3b8; background: #f8fafc; color: #475569; font-size: 12px; }
.message.error { border-color: var(--danger); background: var(--danger-soft); color: var(--danger); }
.automation-status { display: inline-flex; min-height: 26px; align-items: center; padding: 0 8px; border: 1px solid var(--border); border-radius: 5px; background: #f8fafc; color: #64748b !important; font-size: 11px !important; font-weight: 750; white-space: nowrap; }
.automation-status.is-running { border-color: #c7d2fe; background: var(--primary-soft); color: var(--primary) !important; }
.automation-status.is-waiting { border-color: #a7f3d0; background: var(--accent-soft); color: #047857 !important; }
.automation-status.is-error { border-color: #fecdd3; background: var(--danger-soft); color: var(--danger) !important; }
.automation-overview { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.automation-overview > div { min-height: 66px; padding: 10px 11px; border: 1px solid var(--border); border-radius: 5px; background: #f8fafc; }
.automation-overview span { display: block; color: var(--muted); font-size: 11px; }
.automation-overview strong { display: block; margin-top: 6px; overflow: hidden; color: #172033; font-size: 14px; text-overflow: ellipsis; white-space: nowrap; }
.automation-plan-picker { display: grid; grid-template-columns: minmax(0, 1fr) minmax(180px, .8fr); align-items: end; gap: 10px; margin-top: 12px; padding: 10px 11px; border: 1px solid #c7d2fe; border-radius: 6px; background: #f5f7ff; }
.automation-plan-picker label { display: grid; gap: 5px; color: #4338ca; font-size: 11px; font-weight: 750; }
.automation-plan-picker select { width: 100%; height: 36px; padding: 0 9px; border: 1px solid #a5b4fc; border-radius: 5px; outline: 0; background: #fff; color: #172033; font: inherit; }
.automation-plan-picker select:focus { border-color: #6366f1; box-shadow: 0 0 0 3px var(--focus); }
.automation-plan-picker p { margin: 0; color: #64748b; font-size: 11px; line-height: 1.55; }
.automation-builder { margin-top: 12px; padding: 11px; border: 1px solid var(--border); border-radius: 6px; background: #fcfdff; }
.automation-add-row { display: grid; grid-template-columns: .7fr 1fr auto; align-items: end; gap: 8px; }
.automation-add-row label, .automation-intervals label { display: grid; gap: 5px; color: #475569; font-size: 11px; font-weight: 700; }
.automation-add-row select, .automation-intervals input { width: 100%; height: 34px; padding: 0 9px; border: 1px solid var(--border); border-radius: 5px; outline: 0; background: #fff; color: #172033; font: inherit; }
.automation-add-row select:focus, .automation-intervals input:focus { border-color: #818cf8; box-shadow: 0 0 0 3px var(--focus); }
.automation-queue { display: grid; gap: 6px; max-height: 244px; margin-top: 10px; overflow: auto; }
.automation-queue-row { display: grid; grid-template-columns: 28px minmax(0, 1fr) 88px; min-height: 40px; align-items: center; gap: 8px; padding: 5px 6px; border: 1px solid #dbe3ee; border-radius: 5px; background: #fff; }
.automation-queue-row.is-current { border-color: #a5b4fc; background: #f5f7ff; }
.automation-queue-row.is-cycle-start { border-left: 3px solid #0f766e; }
.automation-start-note { margin: 9px 0 0; color: #64748b; font-size: 11px; }
.automation-start-picker { display: inline-flex; align-items: center; gap: 3px; color: #0f766e; font-size: 11px; font-weight: 700; }
.automation-start-picker input { margin: 0; }
.automation-queue-index { display: grid; width: 24px; height: 24px; place-items: center; border-radius: 4px; background: #eef2ff; color: #4338ca; font-size: 11px; font-weight: 800; }
.automation-queue-label { overflow: hidden; color: #273247; font-size: 12px; font-weight: 680; text-overflow: ellipsis; white-space: nowrap; }
.automation-queue-actions { display: flex; gap: 4px; justify-content: flex-end; }
.automation-queue-actions button { width: 26px; min-height: 26px; padding: 0; color: #64748b; font-size: 12px; }
.automation-empty { padding: 18px 8px; color: var(--muted); font-size: 12px; text-align: center; }
.automation-intervals { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin-top: 12px; }
.number-input { display: grid; grid-template-columns: minmax(0, 1fr) 48px; align-items: center; overflow: hidden; border: 1px solid var(--border); border-radius: 5px; background: #fff; }
.number-input input { border: 0; border-radius: 0; box-shadow: none !important; }
.number-input em { color: #64748b; font-size: 11px; font-style: normal; text-align: center; }
.automation-cycle-hint { margin: 7px 0 0; color: #64748b; font-size: 11px; }
.automation-message { min-height: 37px; margin: 12px 0 0; padding: 9px 10px; border-left: 3px solid #94a3b8; background: #f8fafc; color: #475569; font-size: 11px; }
.automation-message.is-error { border-color: var(--danger); background: var(--danger-soft); color: var(--danger); }
.automation-actions { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 12px; }
.automation-actions button { min-height: 32px; padding: 0 11px; font-size: 12px; }

.table-view { min-height: calc(100vh - 126px); padding-bottom: 0; display: grid; grid-template-rows: auto auto minmax(0, 1fr); }
#view-rankings { display: block; }
#view-rankings .table-wrap { margin-top: 0; }
.table-toolbar { display: flex; min-height: 64px; align-items: center; justify-content: space-between; gap: 18px; padding: 10px 0; border: 0; border-radius: 0; background: transparent; box-shadow: none; }
.table-title { display: grid; min-width: 0; gap: 3px; }
.table-title h2 { color: #0f172a; font-size: 16px; }
.table-title span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.table-actions, .pager { display: flex; align-items: center; gap: 7px; }
.page-size-select { display: flex; align-items: center; gap: 5px; color: var(--muted); font-size: 11px; font-weight: 700; }
.page-size-select select { height: 30px; padding: 0 7px; border: 1px solid var(--border); border-radius: 5px; background: #fff; color: #334155; font: inherit; }
.pager { padding: 3px; border: 1px solid var(--border); border-radius: 6px; background: #f8fafc; }
.page-numbers { display: flex; align-items: center; gap: 2px; }
.page-numbers button, .page-ellipsis { display: grid; width: 26px; min-height: 28px; place-items: center; padding: 0; border: 0; border-radius: 4px; background: transparent; color: #475569; font-size: 12px; font-variant-numeric: tabular-nums; }
.page-numbers button:hover { background: #fff; color: var(--primary); }
.page-numbers button[aria-current="page"] { background: var(--primary); color: #fff; font-weight: 750; }
.page-ellipsis { color: #94a3b8; }
.icon-button { display: grid; width: 30px; min-height: 28px; place-items: center; padding: 0; border: 0; background: transparent; box-shadow: none; color: #475569; }
.icon-button span { color: inherit; font-size: 21px; line-height: 1; }
.icon-button:hover:not(:disabled) { border-color: transparent; background: #fff; color: var(--primary); }
.page-indicator { min-width: 54px; color: #475569 !important; text-align: center; font-variant-numeric: tabular-nums; font-weight: 650; }
.export-button { min-width: 116px; }
.table-filter-bar { display: grid; grid-template-columns: minmax(220px, 1.4fr) repeat(4, minmax(135px, .75fr)) auto; align-items: end; gap: 12px; padding: 12px 0; border: 0; background: transparent; box-shadow: none; }
.table-filter-field { display: grid; min-width: 0; gap: 6px; }
.table-filter-field > span { color: #475569; font-size: 11px; font-weight: 700; }
.table-filter-field input, .table-filter-field select { width: 100%; height: 34px; min-width: 0; padding: 0 10px; border: 1px solid var(--border); border-radius: 5px; outline: 0; background: #fff; color: #172033; font: inherit; }
.table-filter-field input:focus, .table-filter-field select:focus { border-color: #818cf8; box-shadow: 0 0 0 3px var(--focus); }
.table-filter-actions { display: flex; gap: 7px; }
.table-filter-actions button { min-height: 34px; white-space: nowrap; }
.api-settings-grid { display: grid; grid-template-columns: minmax(360px, .8fr) minmax(520px, 1.2fr); gap: 12px; align-items: start; }
.api-panel { padding: 16px; border: 1px solid var(--border); border-radius: 6px; background: var(--panel); box-shadow: var(--shadow-sm); }
.openapi-view { display: grid; gap: 12px; }
.openapi-view > .api-panel { min-width: 0; }
.openapi-create-form { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px; }
.openapi-create-form label { display: grid; gap: 6px; flex: 1 1 220px; max-width: 380px; color: #475569; font-size: 12px; }
.openapi-create-form input, .openapi-key-content input { width: 100%; min-width: 0; height: 36px; padding: 0 10px; border: 1px solid var(--border); border-radius: 5px; color: var(--ink); background: #fff; }
.openapi-key-table td:first-child { max-width: 280px; overflow-wrap: anywhere; white-space: normal; }
.openapi-key-actions button + button { margin-left: 8px; }
.openapi-doc-actions { display: flex; align-items: center; justify-content: flex-end; gap: 8px; }
.openapi-doc-actions .button-like { min-height: 34px; color: #273247; text-decoration: none; }
.openapi-doc-actions .button-like:hover { border-color: var(--border-strong); background: #f8fafc; }
.openapi-docs h3 { margin: 22px 0 10px; font-size: 14px; }
.openapi-docs p { margin: 10px 0; color: #475569; line-height: 1.8; overflow-wrap: anywhere; }
.openapi-docs pre { margin: 12px 0; padding: 14px; overflow-x: auto; border: 1px solid var(--border); border-radius: 5px; background: #f8fafc; font-size: 12px; line-height: 1.7; }
.openapi-docs code { font-size: 12px; }
.openapi-docs table { min-width: 500px; }
.openapi-copy-row { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; color: var(--muted); font-size: 12px; }
.openapi-key-content { padding: 20px 22px; }
.openapi-key-content label { display: block; margin-bottom: 8px; font-weight: 600; }
.openapi-key-content input { font-family: monospace; }
.openapi-key-content p { color: var(--muted); min-height: 20px; }
.api-credential-status { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin: 0 0 16px; }
.api-credential-status > div { padding: 10px 11px; border: 1px solid var(--border); border-radius: 5px; background: #f8fafc; }
.api-credential-status dt { color: var(--muted); font-size: 11px; }
.api-credential-status dd { margin: 5px 0 0; overflow: hidden; color: #273247; font-weight: 700; text-overflow: ellipsis; white-space: nowrap; }
.api-credentials-form { display: grid; gap: 10px; margin-bottom: 16px; padding-bottom: 16px; border-bottom: 1px solid var(--border); }
.api-credentials-form > label { display: grid; gap: 6px; color: #475569; font-size: 11px; font-weight: 700; }
.api-credentials-form input { width: 100%; height: 34px; min-width: 0; padding: 0 10px; border: 1px solid var(--border); border-radius: 5px; outline: 0; background: #fff; color: var(--ink); font: inherit; }
.api-credentials-form input:focus { border-color: #818cf8; box-shadow: 0 0 0 3px var(--focus); }
.api-config-form { display: grid; gap: 12px; }
.api-config-form > label:not(.binary-setting) { display: grid; gap: 6px; color: #475569; font-size: 11px; font-weight: 700; }
.api-next-scheduled-at { margin: -2px 0 0; color: var(--primary); font-size: 12px; font-weight: 700; font-variant-numeric: tabular-nums; }
.binary-setting { display: flex; align-items: center; gap: 8px; color: #334155; font-size: 12px; font-weight: 700; }
.binary-setting input { width: 16px; height: 16px; accent-color: var(--primary); }
.api-actions { display: flex; flex-wrap: wrap; gap: 7px; }
.api-metrics { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-top: 14px; }
.api-metrics > div { min-height: 68px; padding: 10px 11px; border: 1px solid var(--border); border-radius: 5px; background: #f8fafc; }
.api-metrics span { display: block; color: var(--muted); font-size: 11px; }
.api-metrics strong { display: block; margin-top: 6px; font-size: 17px; font-variant-numeric: tabular-nums; }
#api-sync-progress { width: 0; height: 100%; background: var(--accent); transition: width .25s ease; }
.api-progress-detail strong { overflow-wrap: anywhere; }
.table-wrap { min-height: 0; max-height: none; overflow: auto; border: 1px solid var(--border); border-radius: 0; background: var(--panel); box-shadow: none; scrollbar-color: #cbd5e1 transparent; scrollbar-width: thin; }
table { width: max-content; min-width: 100%; border-collapse: separate; border-spacing: 0; font-size: 12px; }
th, td { height: 46px; max-width: 240px; padding: 0 12px; overflow: hidden; border-right: 1px solid #edf1f5; border-bottom: 1px solid #e8edf3; background: #fff; text-align: left; text-overflow: ellipsis; white-space: nowrap; }
th { position: sticky; top: 0; z-index: 3; height: 42px; background: #f1f5f9; color: #334155; font-size: 12px; font-weight: 700; }
th:last-child, td:last-child { border-right: 0; }
tbody tr:nth-child(even) td { background: #fcfdff; }
tbody tr:hover td { background: #f8faff; }
.numeric-cell { text-align: right; font-variant-numeric: tabular-nums; }
.book-id-cell code { color: #64748b; font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace; font-size: 11px; }
.book-name-cell strong, .author-name-cell strong { color: #172033; font-weight: 680; }
.book-name-cell strong { display: block; overflow: hidden; text-overflow: ellipsis; }
.cell-muted, .is-zero { color: #94a3b8; }
.data-badge, .count-value { display: inline-flex; min-height: 22px; align-items: center; justify-content: center; padding: 1px 7px; border: 1px solid transparent; border-radius: 4px; font-size: 11px; font-weight: 700; line-height: 18px; }
.level-s-plus { border-color: #fecdd3; background: #fff1f2; color: #be123c; }
.level-s { border-color: #fde68a; background: var(--warning-soft); color: var(--warning); }
.level-a { border-color: #cbd5e1; background: #f1f5f9; color: #475569; }
.level-other { border-color: var(--border); background: #f8fafc; color: var(--muted); }
.reading-value { color: var(--accent); font-weight: 700; font-variant-numeric: tabular-nums; }
.copy-cell { max-width: 260px; }
.copy-tags { display: flex; gap: 4px; overflow: hidden; }
.copy-tags .data-badge { flex: 0 0 auto; max-width: 180px; overflow: hidden; text-overflow: ellipsis; }
.copy-direct { border-color: #fecdd3; background: var(--danger-soft); color: #be123c; }
.copy-split { border-color: #c7d2fe; background: var(--primary-soft); color: #4338ca; }
.copy-other { border-color: #bae6fd; background: #f0f9ff; color: #0369a1; }
.status-text { display: inline-flex; align-items: center; gap: 6px; }
.status-text::before { width: 6px; height: 6px; border-radius: 50%; background: #94a3b8; content: ""; }
.status-text.is-success { color: #047857; }
.status-text.is-success::before { background: #10b981; }

#novel-table th[data-column-key="bookId"], #novel-table td[data-column-key="bookId"] { width: 168px; min-width: 168px; }
#novel-table th[data-column-key="bookName"], #novel-table td[data-column-key="bookName"] { width: 260px; min-width: 260px; max-width: 260px; }
#novel-table th[data-column-key="totalChapters"], #novel-table td[data-column-key="totalChapters"] { width: 96px; min-width: 96px; }
#novel-table th.column-recommendationLevel { background: #fff5f6; color: #9f1239; }
#novel-table th.column-tomatoReading { background: #ecfdf5; color: #0f766e; }
#novel-table th.column-copyProcessing { background: #eef2ff; color: #4338ca; }

#author-table th[data-column-key="author"], #author-table td[data-column-key="author"] { width: 160px; min-width: 160px; }
#author-table th[data-column-key="total"], #author-table td[data-column-key="total"] { width: 104px; min-width: 104px; }
#author-table th[data-column-key="under1k"], #author-table th[data-column-key="oneTo10k"],
#author-table th[data-column-key="tenTo100k"], #author-table th[data-column-key="oneHundredTo500k"],
#author-table th[data-column-key="over500k"] { background: #eefbf7; color: #0f766e; }
#novel-table .is-frozen, #author-table .is-frozen { position: sticky; left: var(--sticky-left); z-index: 4; }
#novel-table th.is-frozen, #author-table th.is-frozen { z-index: 7; background: #e9eef5; }
#novel-table td.is-frozen, #author-table td.is-frozen { background: #fff; }
#novel-table tbody tr:nth-child(even) td.is-frozen, #author-table tbody tr:nth-child(even) td.is-frozen { background: #fcfdff; }
#novel-table tbody tr:hover td.is-frozen, #author-table tbody tr:hover td.is-frozen { background: #f8faff; }
#novel-table .frozen-boundary, #author-table .frozen-boundary { box-shadow: var(--shadow-frozen); }
.novel-column-header, .author-column-header { padding: 0; cursor: grab; user-select: none; }
.novel-column-header:active, .author-column-header:active { cursor: grabbing; }
.novel-sort-button, .author-sort-button { display: flex; width: 100%; min-width: 84px; min-height: 42px; align-items: center; justify-content: space-between; gap: 8px; padding: 0 12px; border: 0; border-radius: 0; background: transparent; box-shadow: none; color: inherit; font: inherit; }
.novel-sort-button:hover, .author-sort-button:hover { border: 0; background: rgb(255 255 255 / .45); color: var(--primary); }
.novel-sort-button i, .author-sort-button i { color: #94a3b8; font-size: 12px; font-style: normal; }
.novel-column-header[aria-sort="ascending"] .novel-sort-button i,
.novel-column-header[aria-sort="descending"] .novel-sort-button i,
.author-column-header[aria-sort="ascending"] .author-sort-button i,
.author-column-header[aria-sort="descending"] .author-sort-button i { color: var(--primary); }
.novel-column-header.is-dragging, .author-column-header.is-dragging { opacity: .45; }
.novel-column-header.drag-before, .author-column-header.drag-before { box-shadow: inset 3px 0 var(--primary); }
.novel-column-header.drag-after, .author-column-header.drag-after { box-shadow: inset -3px 0 var(--primary); }
.author-metric-cell { min-width: 86px; }
.author-total-cell { color: var(--primary); font-size: 13px; font-weight: 750; }
.count-total { min-width: 32px; border-color: #c7d2fe; background: var(--primary-soft); color: #4338ca; }
.author-metric-cell.has-value { color: #0f766e; font-weight: 700; }
.reading-summary-cell { min-width: 104px; }
.coverage-cell { min-width: 132px; text-align: left; }
.coverage-value { display: grid; grid-template-columns: 38px 68px; align-items: center; gap: 7px; color: #4338ca; font-weight: 700; font-variant-numeric: tabular-nums; }
.coverage-track { display: block; height: 5px; overflow: hidden; border-radius: 3px; background: #e2e8f0; }
.coverage-track i { display: block; height: 100%; border-radius: inherit; background: var(--primary); }
.logs-table-wrap { max-height: calc(100vh - 196px); }
#logs-table { min-width: 1290px; }
#logs-table th:nth-child(1), #logs-table td:nth-child(1) { width: 300px; min-width: 300px; }
#logs-table th:nth-child(2), #logs-table td:nth-child(2) { width: 120px; min-width: 120px; }
#logs-table th:nth-child(3), #logs-table td:nth-child(3),
#logs-table th:nth-child(9), #logs-table td:nth-child(9) { width: 170px; min-width: 170px; }
#logs-table th:nth-child(n+4):nth-child(-n+7), #logs-table td:nth-child(n+4):nth-child(-n+7) { width: 92px; min-width: 92px; text-align: right; }
#logs-table th:nth-child(8), #logs-table td:nth-child(8) { width: 132px; min-width: 132px; }
#logs-table th:nth-child(10), #logs-table td:nth-child(10) { width: 82px; min-width: 82px; }
.log-filter-cell strong { display: block; overflow: hidden; color: #172033; text-overflow: ellipsis; }
.log-time-cell { color: #475569; font-variant-numeric: tabular-nums; }
.log-success-cell { color: #047857; font-weight: 750; }
.log-failure-cell { color: var(--danger); font-weight: 750; }
.log-complete { border-color: #a7f3d0; background: var(--accent-soft); color: #047857; }
.log-warning { border-color: #fde68a; background: var(--warning-soft); color: var(--warning); }
.message.warning { color: var(--warning); }
.log-failed { border-color: #fecaca; background: var(--danger-soft); color: #b91c1c; }
.log-running { border-color: #c7d2fe; background: var(--primary-soft); color: #4338ca; }
.log-cancelled { border-color: var(--border); background: #f1f5f9; color: #64748b; }
.segmented-control { display: inline-flex; align-items: center; padding: 3px; border: 1px solid var(--border); border-radius: 7px; background: #f8fafc; }
.segmented-control button { min-height: 30px; padding: 0 11px; border: 0; border-radius: 5px; background: transparent; color: var(--muted); font-size: 12px; font-weight: 700; }
.segmented-control button[aria-selected="true"] { background: #fff; color: var(--primary); box-shadow: 0 1px 3px rgb(15 23 42 / .12); }
.log-error-cell { position: relative; width: 320px; min-width: 320px; max-width: 320px; overflow: visible; color: var(--danger); white-space: nowrap; }
#logs-table tbody tr { height: 46px; }
.log-diagnostic-summary { display: block; max-width: 296px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.log-warning-indicator { position: relative; display: inline-grid; width: 24px; height: 24px; place-items: center; border: 1px solid #f59e0b; border-radius: 50%; outline: 0; background: #fffbeb; color: #b45309; cursor: help; font-size: 14px; font-weight: 800; line-height: 1; }
.log-warning-tooltip { position: absolute; right: 0; top: calc(100% - 4px); z-index: 12; width: min(560px, calc(100vw - 48px)); max-height: 220px; padding: 10px 12px; overflow: auto; border: 1px solid #fcd34d; border-radius: 5px; background: #fffdf5; box-shadow: 0 8px 20px rgb(15 23 42 / .16); color: #78350f; font-size: 11px; font-weight: 500; line-height: 1.55; opacity: 0; pointer-events: none; transform: translateY(-3px); transition: opacity .12s ease, transform .12s ease; visibility: hidden; white-space: pre-wrap; overflow-wrap: anywhere; }
.log-warning-indicator:is(:hover, :focus, :focus-visible) .log-warning-tooltip { opacity: 1; pointer-events: auto; transform: translateY(0); visibility: visible; }
.current-log td { background: #f5f7ff !important; }
.current-log td:first-child { box-shadow: inset 3px 0 var(--primary); }
.log-open-button { min-height: 28px; padding: 0 10px; color: var(--primary); font-size: 12px; }
.aggregate-editor { position: relative; }
.aggregate-editor summary { list-style: none; cursor: pointer; }
.aggregate-editor summary::-webkit-details-marker { display: none; }
.button-like { min-height: 32px; display: inline-flex; align-items: center; padding: 0 12px; border: 1px solid var(--border); border-radius: 5px; background: #fff; color: var(--primary); font-size: 12px; font-weight: 700; }
.aggregate-popover { position: absolute; right: 0; top: calc(100% + 6px); z-index: 20; width: 260px; padding: 12px; border: 1px solid var(--border); border-radius: 6px; background: #fff; box-shadow: 0 12px 28px rgb(15 23 42 / .16); }
.aggregate-popover fieldset { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px; margin: 0 0 10px; padding: 8px; border: 1px solid var(--border); }
.aggregate-popover legend { padding: 0 4px; color: var(--muted); font-size: 11px; }
.aggregate-popover label { display: flex; align-items: center; gap: 5px; font-size: 12px; }
.aggregate-popover button { width: 100%; }
.aggregate-columns-list { display: grid; gap: 5px; margin-top: 10px; }
.aggregate-columns-list > span { display: grid; grid-template-columns: minmax(0, 1fr) 24px; align-items: center; gap: 5px; padding: 5px 6px 5px 8px; border: 1px solid #dbe3ee; border-radius: 4px; background: #f8fafc; color: #334155; font-size: 11px; }
.aggregate-columns-list > span > button { width: 24px; min-height: 24px; padding: 0; color: #64748b; font-size: 16px; }
.aggregate-columns-list small { color: var(--muted); font-size: 11px; }
.field-dialog { width: min(720px, calc(100vw - 32px)); max-height: min(760px, calc(100vh - 32px)); padding: 0; overflow: hidden; border: 1px solid var(--border); border-radius: 7px; background: #fff; box-shadow: 0 24px 70px rgb(15 23 42 / .26); color: #172033; }
.field-dialog::backdrop { background: rgb(15 23 42 / .48); backdrop-filter: blur(2px); }
.field-dialog-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; padding: 20px 22px 16px; border-bottom: 1px solid var(--border); }
.field-dialog-header h2 { font-size: 18px; }
.field-dialog-header p { margin-top: 4px; color: var(--muted); font-size: 12px; }
.field-freeze-summary { display: flex; align-items: center; justify-content: space-between; margin: 14px 22px 8px; padding: 10px 12px; border-bottom: 2px solid #a5b4fc; color: #4338ca; font-size: 12px; }
.field-freeze-summary span { color: var(--muted); }
.field-list { display: grid; gap: 8px; max-height: min(520px, calc(100vh - 260px)); padding: 0 22px 16px; overflow: auto; }
.field-setting-row { display: grid; grid-template-columns: 24px minmax(140px, 1fr) 92px 74px; min-height: 54px; align-items: center; gap: 10px; padding: 8px 10px; border: 1px solid var(--border); border-radius: 5px; background: #fff; }
.field-setting-row.is-frozen { border-color: #c7d2fe; background: #f5f7ff; }
.field-drag-handle { color: #94a3b8; font-size: 15px; letter-spacing: -4px; }
.field-visible-toggle, .field-freeze-toggle { display: flex; min-width: 0; align-items: center; gap: 8px; cursor: pointer; }
.field-visible-toggle span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; font-weight: 650; }
.field-freeze-toggle span { color: #475569; font-size: 12px; }
.field-visible-toggle input, .field-freeze-toggle input { width: 16px; height: 16px; accent-color: var(--primary); }
.field-order-actions { display: flex; gap: 5px; }
.field-order-actions button { width: 32px; min-height: 30px; padding: 0; color: #475569; }
.field-dialog-footer { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 22px; border-top: 1px solid var(--border); background: #f8fafc; }
.empty-row td { position: static !important; height: 190px; background: #fff !important; box-shadow: none !important; color: var(--muted); text-align: center !important; }

#toast { position: fixed; right: 20px; bottom: 20px; z-index: 100; max-width: min(380px, calc(100vw - 40px)); padding: 11px 14px; border-radius: 6px; background: #0f172a; box-shadow: 0 12px 30px rgb(15 23 42 / .2); color: #fff; font-size: 13px; opacity: 0; pointer-events: none; transform: translateY(8px); transition: opacity .18s ease, transform .18s ease; }
#toast.show { opacity: 1; transform: translateY(0); }
#toast.error { background: #9f1239; }

.access-screen { display: grid; min-height: 100vh; place-items: center; padding: 24px; }
.access-panel { display: grid; width: min(360px, 100%); gap: 12px; padding: 28px; border: 1px solid var(--border); border-radius: 7px; background: #fff; box-shadow: 0 16px 44px rgb(15 23 42 / .12); }
.access-panel .brand-mark { width: 36px; height: 36px; }
.access-panel h1 { margin: 4px 0 0; font-size: 20px; }
.access-panel > p { margin: 0; color: var(--muted); }
.access-panel label { display: grid; gap: 6px; margin-top: 8px; color: #475569; font-size: 12px; font-weight: 700; }
.access-panel input { height: 38px; padding: 0 10px; border: 1px solid var(--border); border-radius: 5px; background: #fff; color: var(--ink); }
.access-panel .access-message { min-height: 19px; color: var(--danger); font-size: 12px; }
.access-panel button { width: 100%; }

@media (max-width: 900px) {
  .app-header { height: auto; min-height: 86px; align-items: flex-start; padding: 13px 14px; }
  .header-status { flex-wrap: wrap; justify-content: flex-end; }
  main { padding: 0 14px 20px; }
  .metrics { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .workspace-grid { grid-template-areas: "settings" "progress" "automation" "ranking"; grid-template-columns: 1fr; }
  .api-settings-grid { grid-template-columns: 1fr; }
  .table-filter-bar { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .table-filter-actions { align-self: end; }
  .table-wrap { max-height: calc(100vh - 350px); }
}

@media (max-width: 600px) {
  .app-header { display: block; }
  .header-status { justify-content: flex-start; margin-top: 12px; }
  .header-status .status-pill { flex: 1 1 auto; justify-content: center; }
  #header-export { width: 100%; }
  .tabs { height: auto; align-items: stretch; flex-wrap: wrap; padding-top: 10px; }
  .tabs button { flex: 1 1 96px; padding: 0 8px; }
  .source-bar, .table-toolbar { align-items: stretch; flex-direction: column; }
  .source-bar button { width: 100%; }
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .workspace-grid { display: block; }
  .progress-panel { margin-top: 12px; }
  .progress-detail { grid-template-columns: 1fr 1fr; }
  .automation-add-row { grid-template-columns: 1fr; }
  .automation-plan-picker { grid-template-columns: 1fr; }
  .automation-intervals { grid-template-columns: 1fr; }
  .api-credential-status, .api-metrics { grid-template-columns: 1fr 1fr; }
  .table-toolbar { gap: 10px; padding: 12px; }
  .table-title span { white-space: normal; }
  .table-actions { flex-wrap: wrap; justify-content: space-between; }
  .export-button { flex: 1 1 auto; }
  .table-filter-bar { grid-template-columns: 1fr; padding: 12px; }
  .table-filter-actions button { flex: 1 1 0; }
  .openapi-docs .panel-heading { align-items: flex-start; }
  .openapi-doc-actions { flex: 0 0 auto; }
  .table-wrap { max-height: calc(100vh - 480px); }
  .field-setting-row { grid-template-columns: 20px minmax(100px, 1fr) 76px 70px; gap: 6px; }
}
