:root {
  --bg: #f4f6f9; --panel: #fff; --ink: #1d2733; --muted: #6b7785; --line: #dfe4ea;
  --brand: #1f5f99; --brand-d: #174a78; --danger: #b3261e; --ok: #1e7b45; --warn: #a76100;
  --font: "Segoe UI", system-ui, -apple-system, "Noto Sans", "Noto Sans Bengali", "Noto Sans Devanagari", sans-serif;
  --mono: Consolas, "SFMono-Regular", Menlo, monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font: 14px/1.45 var(--font); color: var(--ink); background: var(--bg); display: flex; flex-direction: column; }
a { color: var(--brand); }
.muted { color: var(--muted); }
code, pre { font-family: var(--mono); }

/* header */
.top { display: flex; align-items: center; gap: 18px; padding: 0 16px; background: #13314f; color: #fff; height: 50px; flex: none; }
.brand { font-weight: 600; white-space: nowrap; }
.brand small { opacity: .6; font-weight: 400; }
.logo { color: #7cc4ff; }
.tabs { display: flex; gap: 2px; flex: 1; }
.tabs button { background: none; border: 0; color: #c9d6e3; padding: 15px 12px; cursor: pointer; font: inherit; border-bottom: 3px solid transparent; }
.tabs button.active, .tabs button:hover { color: #fff; border-bottom-color: #7cc4ff; }
.top .right { display: flex; gap: 10px; align-items: center; }
.top .credit { color: #9fc6ea; font-size: 12px; font-style: italic; white-space: nowrap; }
.pill { background: #2a4d70; padding: 3px 10px; border-radius: 99px; font-size: 12px; }
.pill.busy { background: #e0a100; color: #222; animation: pulse 1.6s infinite; }
@keyframes pulse { 50% { opacity: .65; } }

main { flex: 1; overflow: hidden; display: flex; flex-direction: column; min-height: 0; }
.tab { display: none; flex: 1; flex-direction: column; min-height: 0; padding: 10px 14px; overflow: auto; }
.tab.active { display: flex; }

/* buttons */
.btn { font: inherit; padding: 6px 12px; border: 1px solid #c3cbd4; background: #fff; color: var(--ink); border-radius: 5px; cursor: pointer; text-decoration: none; display: inline-block; white-space: nowrap; }
.btn:hover:not(:disabled) { background: #eef3f8; }
.btn:disabled { opacity: .45; cursor: default; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover:not(:disabled) { background: var(--brand-d); }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.danger-outline { color: var(--danger); border-color: #e2b4b1; }
.btn.small { padding: 3px 8px; font-size: 12px; }
.toolbar { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.toolbar .group { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.chk { display: inline-flex; align-items: center; gap: 5px; cursor: pointer; }
.filters { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; flex-wrap: wrap; }
.filters input[type=search] { width: 360px; max-width: 100%; }
input, select, textarea { font: inherit; padding: 6px 8px; border: 1px solid #c3cbd4; border-radius: 5px; background: #fff; color: inherit; }
input:focus, select:focus, textarea:focus { outline: 2px solid #9cc7ee; border-color: var(--brand); }

.dropdown { position: relative; }
.menu { display: none; position: absolute; right: 0; top: 100%; z-index: 20; background: #fff; border: 1px solid var(--line); border-radius: 6px; box-shadow: 0 8px 24px rgba(0,0,0,.12); min-width: 330px; padding: 4px 0; }
.menu.open { display: block; }
.menu a { display: block; padding: 7px 14px; cursor: pointer; color: var(--ink); text-decoration: none; }
.menu a:hover { background: #eef3f8; }
.menu hr { border: 0; border-top: 1px solid var(--line); margin: 4px 0; }

/* grid + detail */
.split { display: flex; gap: 10px; flex: 1; min-height: 0; }
.tablewrap { flex: 1; overflow: auto; background: var(--panel); border: 1px solid var(--line); border-radius: 6px; min-height: 0; }
.grid { border-collapse: collapse; width: 100%; font-size: 13px; }
.grid th { position: sticky; top: 0; background: #eef2f6; text-align: left; padding: 7px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; z-index: 1; }
.grid th[data-sort] { cursor: pointer; }
.grid th.sorted[data-dir=asc]::after { content: " ▲"; font-size: 10px; }
.grid th.sorted[data-dir=desc]::after { content: " ▼"; font-size: 10px; }
.grid td { padding: 5px 8px; border-bottom: 1px solid #eef1f4; vertical-align: top; }
.grid tbody tr:hover { background: #f6f9fc; }
.grid tr.cur { background: #e3effa !important; }
.grid td.n { text-align: right; font-variant-numeric: tabular-nums; }
.grid .c { text-align: center; width: 28px; }
.grid td.name { min-width: 220px; font-weight: 500; }
.grid td.nowrap { white-space: nowrap; color: var(--muted); font-size: 12px; }
.grid td.url { max-width: 300px; word-break: break-all; font-size: 12px; }
.pager { display: flex; gap: 10px; align-items: center; justify-content: center; padding: 8px; }
.detail { width: 430px; flex: none; overflow: auto; background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 10px 12px; font-size: 13px; }
.detail h3 { margin: 0 0 8px; font-size: 15px; }
.detail h4 { margin: 14px 0 6px; font-size: 13px; }
.dactions { display: flex; gap: 6px; margin-bottom: 8px; }
.kv { border-collapse: collapse; width: 100%; }
.kv th { text-align: left; color: var(--muted); font-weight: 500; padding: 2px 8px 2px 0; vertical-align: top; white-space: nowrap; width: 110px; }
.kv td { padding: 2px 0; word-break: break-word; }
.mini { border-collapse: collapse; width: 100%; font-size: 12px; }
.mini th { text-align: left; background: #f1f4f7; padding: 3px 6px; }
.mini td { padding: 3px 6px; border-bottom: 1px solid #f0f2f5; }
.mini td.n { text-align: right; }
.mini tr.u td { color: var(--muted); font-family: var(--mono); font-size: 11px; word-break: break-all; padding-top: 0; }

.badge { display: inline-block; padding: 1px 8px; border-radius: 99px; font-size: 12px; background: #e9edf1; white-space: nowrap; }
.c-active { background: #cdebd7; color: #11552d; }
.c-empty { background: #e2f3e7; color: #2b6a40; }
.c-formats_only, .c-identify_only { background: #fff1c7; color: #7a5600; }
.c-oai_error { background: #ffdcb8; color: #8a4300; }
.c-not_oai, .c-unreachable { background: #f9d5d3; color: #8f1f19; }
.s-completed { background: #cdebd7; } .s-failed { background: #f9d5d3; } .s-cancelled { background: #ffe8c2; } .s-running, .s-stopping { background: #fff1c7; }
.tag { display: inline-block; font-size: 11px; padding: 0 6px; border-radius: 4px; background: #e8eef5; margin: 1px; }
.tag.warn { background: #ffe1b3; color: #7a4400; }

/* job panel */
.jobpanel { flex: none; background: #0f1b28; color: #d7e0ea; border-top: 3px solid #234; }
.jobhead { display: flex; align-items: center; gap: 12px; padding: 6px 14px; }
.jobhead .muted { color: #93a4b6; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; }
.bar { width: 220px; height: 8px; background: #26384c; border-radius: 4px; overflow: hidden; flex: none; }
.bar div { height: 100%; width: 0; background: #4fb3ff; transition: width .4s; }
.bar div.indet { animation: indet 1.4s infinite linear; }
@keyframes indet { 0% { margin-left: -30%; } 100% { margin-left: 100%; } }
.log { margin: 0; height: 190px; background: transparent; color: #d7e0ea; border-radius: 0; overflow: auto; padding: 6px 14px; font-size: 12px; line-height: 1.5; white-space: pre-wrap; word-break: break-all; border-top: 1px solid #22344a; }
.jobpanel.collapsed .log { display: none; }
.l-debug { color: #7f93a8; } .l-warn { color: #ffc766; } .l-error { color: #ff8a80; }

/* dashboard */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 10px; margin-bottom: 14px; }
.kpi { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; }
.kpi .v { font-size: 24px; font-weight: 600; color: var(--brand); }
.kpi .k { color: var(--muted); font-size: 12px; }
.sections { display: grid; grid-template-columns: repeat(auto-fill, minmax(380px, 1fr)); gap: 12px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; }
.card h3 { margin: 0 0 8px; font-size: 14px; }

/* settings + forms */
.settings { display: grid; grid-template-columns: repeat(auto-fill, minmax(360px, 1fr)); gap: 14px; }
.settings fieldset { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 10px 14px; margin: 0; }
.settings legend { font-weight: 600; padding: 0 6px; }
.settings label, .form label { display: flex; flex-direction: column; gap: 3px; margin: 8px 0; }
.settings label.chk { flex-direction: row; }
.settings .actions { grid-column: 1 / -1; }
.form textarea { resize: vertical; }
dialog { border: 0; border-radius: 10px; box-shadow: 0 20px 60px rgba(0,0,0,.3); width: min(620px, 94vw); padding: 18px 22px; }
dialog::backdrop { background: rgba(10, 20, 30, .45); }
dialog h2 { margin: 0 0 6px; font-size: 18px; }
dialog .actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 10px; }

.toast { position: fixed; right: 18px; top: 62px; z-index: 50; background: #24384d; color: #fff; padding: 10px 16px; border-radius: 6px; box-shadow: 0 6px 20px rgba(0,0,0,.25); max-width: 460px; white-space: pre-line; }
.toast.err { background: var(--danger); } .toast.ok { background: var(--ok); }

/* auth / install pages */
body.auth { align-items: center; justify-content: center; padding: 30px 12px; overflow: auto; display: block; }
.card.narrow { max-width: 520px; margin: 40px auto; }
.msg { padding: 8px 12px; border-radius: 6px; }
.msg.err { background: #fbe1df; color: #7d1a14; } .msg.ok { background: #d9f0e1; color: #11552d; } .msg.warn { background: #fff1c7; }
.req { list-style: none; padding: 0; } .req .ok { color: var(--ok); } .req .bad { color: var(--danger); }
pre { background: #f1f4f7; padding: 8px 10px; border-radius: 6px; overflow: auto; }

@media (max-width: 1100px) {
  .split { flex-direction: column; } .detail { width: auto; max-height: 45vh; }
  .tabs button { padding: 15px 7px; }
}
