:root {
  --bg: #f4f5f7;
  --card: #ffffff;
  --text: #1a1d23;
  --muted: #6b7280;
  --accent: #2456e6;
  --accent-dark: #1c45ba;
  --border: #e2e4e9;
  --warn-bg: #fff7e0;
  --warn-border: #f0c64a;
  --error-bg: #fdecec;
  --error-border: #e57373;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.topbar { background: #14181f; color: #fff; }
.topbar-inner {
  max-width: 960px; margin: 0 auto; padding: 12px 20px;
  display: flex; align-items: center; justify-content: space-between;
}
.brand { font-weight: 600; letter-spacing: 0.2px; }
.nav-link { color: #aeb6c2; text-decoration: none; margin-left: 16px; font-size: 14px; }
.nav-link:hover { color: #fff; }

.container { max-width: 960px; margin: 0 auto; padding: 24px 20px; width: 100%; flex: 1; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 22px 24px;
  margin-bottom: 20px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}
.login-card { max-width: 380px; margin: 10vh auto 0; }

h1 { font-size: 20px; margin: 0 0 6px; }
h2 { font-size: 16px; margin: 0 0 8px; }
.muted { color: var(--muted); font-size: 13.5px; margin: 0 0 14px; }

input[type="text"], input[type="password"] {
  width: 100%; padding: 10px 12px; margin-bottom: 10px;
  border: 1px solid var(--border); border-radius: 8px; font-size: 15px;
}
input:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }

.search-row { display: flex; gap: 10px; }
.search-row input { flex: 1; margin-bottom: 0; }

.btn {
  display: inline-block; padding: 9px 16px; border-radius: 8px;
  border: 1px solid var(--border); background: #fff; color: var(--text);
  font-size: 14px; cursor: pointer; text-decoration: none; white-space: nowrap;
}
.btn:hover { background: #f0f1f4; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-dark); }
.btn.subtle { border-style: dashed; color: var(--muted); }
.btn.small { padding: 4px 10px; font-size: 13px; }
.btn.wide { width: 100%; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.alert { padding: 10px 14px; border-radius: 8px; margin-bottom: 14px; font-size: 14px; }
.alert.error { background: var(--error-bg); border: 1px solid var(--error-border); }
.alert.warn  { background: var(--warn-bg);  border: 1px solid var(--warn-border);
               display: flex; align-items: center; gap: 12px; }

.status { margin: 0 0 20px; padding: 12px 16px; background: var(--card);
          border: 1px solid var(--border); border-radius: 10px; font-size: 14px; }
.spinner {
  display: inline-block; width: 14px; height: 14px; margin-right: 10px;
  border: 2px solid var(--border); border-top-color: var(--accent);
  border-radius: 50%; animation: spin 0.8s linear infinite; vertical-align: -2px;
}
@keyframes spin { to { transform: rotate(360deg); } }

.search-results { margin-top: 14px; display: flex; flex-direction: column; gap: 8px; }
.search-hit {
  text-align: left; padding: 10px 14px; background: #fafbfc;
  border: 1px solid var(--border); border-radius: 8px; cursor: pointer; font: inherit;
}
.search-hit:hover { border-color: var(--accent); background: #f5f8ff; }
.hit-title { font-weight: 600; margin-right: 8px; }
.hit-desc { display: block; color: var(--muted); font-size: 13px; margin-top: 2px; }

.badge {
  display: inline-block; padding: 1px 8px; border-radius: 10px;
  background: #e8edfb; color: var(--accent-dark); font-size: 12px; font-weight: 500;
}
.badge.stale { background: var(--warn-bg); color: #8a6d1a; }

.result-head { display: flex; justify-content: space-between; align-items: flex-start;
               gap: 16px; flex-wrap: wrap; margin-bottom: 12px; }
.result-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

#r-text, .input-area, .joblog {
  width: 100%; border: 1px solid var(--border); border-radius: 8px;
  font: 12.5px/1.45 ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  padding: 12px; background: #fafbfc; resize: vertical;
}
#r-text { height: 420px; }
.input-area { background: #fff; }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 20px; margin: 14px 0; }
.form-grid label { font-size: 13.5px; color: var(--muted); }
.form-grid label.check { display: flex; align-items: center; gap: 8px; color: var(--text); }
.form-grid input[type="text"] { margin-top: 4px; }

.progress { height: 8px; background: var(--border); border-radius: 4px; overflow: hidden; margin: 10px 0; }
.progress-fill { height: 100%; width: 0; background: var(--accent); transition: width 0.4s; }
.joblog { height: 220px; overflow-y: auto; white-space: pre-wrap; margin: 10px 0 14px; }

.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th, .table td { text-align: left; padding: 7px 10px; border-bottom: 1px solid var(--border); }
.table th { color: var(--muted); font-weight: 500; font-size: 13px; }
.table a { color: var(--accent-dark); text-decoration: none; }

.footer { text-align: center; color: var(--muted); font-size: 12.5px; padding: 18px; }
.hidden { display: none !important; }
