:root {
  --bg: #ffffff;
  --bg-soft: #f6f7f9;
  --bg-hover: #f2f5fb;
  --ink: #16181d;          /* near-black primary text */
  --ink-soft: #5b6370;     /* secondary text */
  --ink-faint: #8a919e;    /* tertiary / captions */
  --border: #e6e8ec;
  --border-strong: #d3d7de;
  --accent: #1a56db;       /* professional blue, used sparingly */
  --accent-hover: #1442b0;
  --ok: #067a4e;
  --danger: #c0392b;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.04), 0 1px 3px rgba(16, 24, 40, 0.06);
  --shadow-lg: 0 10px 30px rgba(16, 24, 40, 0.10);
  --radius: 12px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- Top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--border);
}
.topbar-inner {
  max-width: 1200px; margin: 0 auto; padding: 14px 24px;
  display: flex; justify-content: space-between; align-items: center; gap: 16px;
}
.brand { display: flex; align-items: center; gap: 12px; color: var(--ink); }
.brand:hover { text-decoration: none; }
.brand-mark {
  display: inline-flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; border-radius: 10px;
  background: var(--ink); color: #fff;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.1; }
.brand-name { font-weight: 700; font-size: 16px; letter-spacing: -0.01em; }
.brand-sub { font-size: 12px; color: var(--ink-soft); font-weight: 500; }
.meta { color: var(--ink-soft); font-size: 12.5px; text-align: right; }
.meta strong { color: var(--ink); font-weight: 600; }

/* ---------- Hero ---------- */
.hero { border-bottom: 1px solid var(--border); background: var(--bg-soft); }
.hero-inner { max-width: 1200px; margin: 0 auto; padding: 44px 24px 40px; }
.hero h1 {
  margin: 0 0 10px; font-size: 32px; line-height: 1.15; letter-spacing: -0.02em; font-weight: 700;
  max-width: 720px;
}
.hero p { margin: 0; color: var(--ink-soft); font-size: 16px; max-width: 640px; }

/* ---------- Layout ---------- */
main { max-width: 1200px; margin: 0 auto; padding: 24px 24px 96px; }
.panel {
  background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 16px; margin-bottom: 16px;
}

/* ---------- Fields ---------- */
.field {
  background: var(--bg); border: 1px solid var(--border-strong); color: var(--ink);
  padding: 9px 12px; border-radius: 8px; font-size: 14px; font-family: inherit;
  transition: border-color .15s, box-shadow .15s;
}
.field::placeholder { color: var(--ink-faint); }
.field:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(26, 86, 219, 0.12);
}
.field-grow { flex: 1 1 260px; min-width: 200px; }
.field-label {
  display: inline-flex; align-items: center; gap: 8px;
  color: var(--ink-soft); font-size: 12.5px; font-weight: 500;
}
select.field { cursor: pointer; }

.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

/* ---------- Buttons ---------- */
.btn {
  border: 1px solid transparent; padding: 9px 18px; border-radius: 8px;
  font-weight: 600; font-size: 14px; cursor: pointer; font-family: inherit;
  transition: background .15s, border-color .15s, color .15s;
}
.btn-primary { background: var(--ink); color: #fff; }
.btn-primary:hover { background: #000; }
.btn-ghost { background: var(--bg); color: var(--ink); border-color: var(--border-strong); }
.btn-ghost:hover { background: var(--bg-soft); }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

/* ---------- Alerts subscription ---------- */
.alerts { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.alerts-text { display: flex; flex-direction: column; gap: 2px; }
.alerts-text strong { font-size: 14.5px; }
.alerts-text span { color: var(--ink-soft); font-size: 12.5px; }
.alerts-form { display: flex; gap: 8px; flex: 1 1 420px; flex-wrap: wrap; }
.alerts-form .field { flex: 1 1 160px; }
.sub-msg { flex-basis: 100%; font-size: 13px; margin-top: 2px; }
.sub-msg.ok { color: var(--ok); }
.sub-msg.err { color: var(--danger); }

/* ---------- Results ---------- */
.results-head { display: flex; justify-content: space-between; align-items: center; margin: 4px 2px 12px; }
.result-count { color: var(--ink-soft); font-size: 13px; }
.pager { display: flex; align-items: center; gap: 10px; }
.page-info { color: var(--ink-soft); font-size: 12.5px; }

.table-wrap {
  overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--bg); box-shadow: var(--shadow);
}
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 14px 16px; border-bottom: 1px solid var(--border); vertical-align: top; }
thead th {
  background: var(--bg-soft); color: var(--ink-soft); font-weight: 600; font-size: 11.5px;
  text-transform: uppercase; letter-spacing: 0.04em; position: sticky; top: 0; white-space: nowrap;
}
th.num, td.value { text-align: right; }
tbody tr:last-child td { border-bottom: none; }
tbody tr { transition: background .12s; }
tbody tr:hover td { background: var(--bg-hover); }
td.title { min-width: 340px; max-width: 480px; }
td.title a { color: var(--ink); font-weight: 600; }
td.title a:hover { color: var(--accent); text-decoration: none; }
td.org { max-width: 220px; color: var(--ink-soft); font-size: 12.5px; }
td.value { white-space: nowrap; font-variant-numeric: tabular-nums; font-weight: 600; }
td.date { white-space: nowrap; color: var(--ink-soft); font-size: 12.5px; }
td.tid { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 11.5px; color: var(--ink-faint); }
.view-link a { color: var(--accent); font-weight: 600; white-space: nowrap; }
.empty { text-align: center; color: var(--ink-soft); padding: 40px; }

/* ---------- Footer ---------- */
.footer { border-top: 1px solid var(--border); background: var(--bg-soft); }
.footer-inner {
  max-width: 1200px; margin: 0 auto; padding: 22px 24px;
  display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  color: var(--ink-soft); font-size: 12.5px;
}
.footer-inner strong { color: var(--ink); }

/* ---------- Chat widget ---------- */
.chat-toggle {
  position: fixed; bottom: 24px; right: 24px; width: 56px; height: 56px; border-radius: 50%;
  background: var(--ink); color: #fff; border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  box-shadow: var(--shadow-lg); z-index: 50; transition: transform .15s, background .15s;
}
.chat-toggle:hover { background: #000; transform: translateY(-1px); }
.chat-panel {
  position: fixed; bottom: 92px; right: 24px; width: 370px; max-width: calc(100vw - 48px);
  height: 500px; max-height: calc(100vh - 140px); background: var(--bg);
  border: 1px solid var(--border); border-radius: 16px; display: flex; flex-direction: column;
  overflow: hidden; z-index: 50; box-shadow: var(--shadow-lg);
}
.chat-panel.hidden, .chat-toggle.hidden { display: none; }
.chat-header {
  display: flex; justify-content: space-between; align-items: center; padding: 14px 16px;
  background: var(--ink); color: #fff; font-weight: 600;
}
.chat-close { background: none; border: none; color: rgba(255,255,255,0.7); cursor: pointer; font-size: 15px; padding: 2px 6px; }
.chat-close:hover { color: #fff; }
.chat-log { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 10px; background: var(--bg-soft); }
.msg { padding: 10px 13px; border-radius: 12px; max-width: 85%; line-height: 1.45; white-space: pre-wrap; font-size: 13.5px; }
.msg.bot { background: var(--bg); border: 1px solid var(--border); align-self: flex-start; border-bottom-left-radius: 3px; }
.msg.user { background: var(--ink); color: #fff; align-self: flex-end; border-bottom-right-radius: 3px; }
.msg.bot a { color: var(--accent); }
.chat-input { display: flex; gap: 8px; padding: 12px; border-top: 1px solid var(--border); background: var(--bg); }
.chat-input input { flex: 1; background: var(--bg); border: 1px solid var(--border-strong); color: var(--ink); padding: 9px 12px; border-radius: 8px; font-family: inherit; }
.chat-input input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(26,86,219,0.12); }
.typing { color: var(--ink-faint); font-style: italic; }

/* ---------- Responsive ---------- */
@media (max-width: 640px) {
  .hero h1 { font-size: 25px; }
  .hero p { font-size: 14.5px; }
  .topbar-inner, .hero-inner, main, .footer-inner { padding-left: 16px; padding-right: 16px; }
  .meta { display: none; }
}
