:root {
  --bg: #f5f7fb;
  --panel: #ffffff;
  --text: #172033;
  --muted: #5d6a7e;
  --line: #d8e0ec;
  --accent: #0b5cab;
  --accent-dark: #084986;
  --soft: #eaf2fb;
  --warn: #fff7df;
  --shadow: 0 18px 45px rgba(22, 34, 51, 0.12);
}

* { box-sizing: border-box; }
html, body { width: 100%; min-height: 100%; margin: 0; }
body {
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background: var(--bg);
}
button, input, select { font: inherit; }
button {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  border-radius: 10px;
  padding: 0.72rem 0.95rem;
  cursor: pointer;
  transition: transform .12s ease, box-shadow .12s ease, background .12s ease;
}
button:hover { transform: translateY(-1px); box-shadow: 0 8px 18px rgba(22, 34, 51, 0.10); }
button:disabled { opacity: .45; cursor: not-allowed; transform: none; box-shadow: none; }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 700; }
button.primary:hover { background: var(--accent-dark); }
button.ghost { background: transparent; }

.app-shell { width: 100%; max-width: none; margin: 0; padding: 18px; }
.hero {
  width: 100%;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 18px;
  align-items: stretch;
  background: linear-gradient(135deg, #0b5cab, #14345f);
  color: #fff;
  border-radius: 18px;
  padding: 24px;
  box-shadow: var(--shadow);
}
.eyebrow { margin: 0 0 6px; color: rgba(255,255,255,.72); text-transform: uppercase; letter-spacing: .08em; font-size: .72rem; font-weight: 800; }
.drawer .eyebrow { color: var(--muted); }
h1 { margin: 0; font-size: clamp(1.7rem, 2.5vw, 3rem); line-height: 1.05; }
.subtitle { margin: 12px 0 0; max-width: 1100px; color: rgba(255,255,255,.86); font-size: 1.02rem; }
.stat-grid { display: grid; grid-template-columns: repeat(3, minmax(120px, 1fr)); gap: 12px; }
.stat-card { min-width: 130px; padding: 16px; border: 1px solid rgba(255,255,255,.22); border-radius: 14px; background: rgba(255,255,255,.10); backdrop-filter: blur(6px); }
.stat-card span { display: block; font-size: 1.45rem; font-weight: 900; }
.stat-card small { color: rgba(255,255,255,.76); }
.notice { margin: 16px 0; padding: 13px 16px; border: 1px solid #f0d889; background: var(--warn); border-radius: 14px; }
.workspace { display: grid; gap: 14px; width: 100%; }
.controls, .summary-panel, .results-panel {
  width: 100%;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 16px;
  box-shadow: 0 8px 22px rgba(22, 34, 51, 0.06);
}
.search-row { display: grid; grid-template-columns: minmax(280px, 1fr) auto auto; gap: 12px; align-items: end; }
.filter-row { display: grid; grid-template-columns: minmax(260px, 1fr) minmax(220px, 1fr) minmax(220px, 0.8fr) minmax(140px, 0.4fr); gap: 12px; margin-top: 12px; }
.action-row { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 12px; }
label span { display: block; margin-bottom: 6px; color: var(--muted); font-size: .82rem; font-weight: 800; }
input, select {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: .65rem .8rem;
  color: var(--text);
  background: #fff;
}
input:focus, select:focus { outline: 3px solid rgba(11,92,171,.14); border-color: var(--accent); }
.originals { margin-top: 12px; padding: 12px; border-radius: 12px; background: var(--soft); border: 1px solid #cddff2; }
.originals ul { margin: 8px 0 0; padding-left: 20px; }
.originals a { color: var(--accent-dark); font-weight: 700; }
.hidden { display: none !important; }
.file-summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 10px; }
.file-card { border: 1px solid var(--line); border-radius: 13px; padding: 12px; background: #fbfdff; }
.file-card strong { display: block; margin-bottom: 6px; }
.file-card small { color: var(--muted); }
.results-toolbar { display: flex; justify-content: space-between; gap: 12px; align-items: center; margin-bottom: 10px; }
.status { margin-left: 8px; color: var(--muted); font-size: .9rem; }
.pager { display: flex; align-items: center; gap: 8px; }
.table-wrap { width: 100%; overflow: auto; border: 1px solid var(--line); border-radius: 13px; max-height: calc(100vh - 360px); min-height: 330px; background: #fff; }
table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: .9rem; }
th, td { border-bottom: 1px solid var(--line); border-right: 1px solid #eef2f7; padding: 9px 10px; vertical-align: top; text-align: left; }
th { position: sticky; top: 0; z-index: 1; background: #eef5fd; color: #1b365d; font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; }
tr:hover td { background: #fbfdff; }
td.code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; white-space: nowrap; color: #19395f; font-weight: 700; }
td.desc { min-width: 420px; max-width: 780px; white-space: pre-wrap; line-height: 1.36; }
td.compact { white-space: nowrap; }
td.levels { min-width: 240px; max-width: 420px; color: var(--muted); }
.detail-btn { padding: .45rem .6rem; border-radius: 8px; white-space: nowrap; }
.drawer {
  position: fixed;
  top: 0;
  right: 0;
  width: min(760px, 52vw);
  height: 100vh;
  background: #fff;
  border-left: 1px solid var(--line);
  box-shadow: -18px 0 45px rgba(22, 34, 51, 0.22);
  transform: translateX(104%);
  transition: transform .18s ease;
  z-index: 20;
  display: flex;
  flex-direction: column;
}
.drawer.open { transform: translateX(0); }
.drawer-header { display: flex; justify-content: space-between; gap: 12px; align-items: start; padding: 18px; border-bottom: 1px solid var(--line); }
.drawer-header h2 { margin: 0; font-size: 1.25rem; line-height: 1.2; }
.icon-btn { width: 40px; height: 40px; padding: 0; font-size: 1.45rem; line-height: 1; }
.drawer-content { padding: 18px; overflow: auto; }
.backdrop { position: fixed; inset: 0; background: rgba(5, 12, 24, 0.35); z-index: 19; }
.kv-table { width: 100%; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.kv-table th { width: 220px; position: static; }
.kv-table td { white-space: pre-wrap; }
.block-title { margin: 22px 0 8px; font-size: 1.05rem; }
.badge { display: inline-flex; align-items: center; padding: .2rem .45rem; border-radius: 999px; background: var(--soft); color: var(--accent-dark); font-size: .78rem; font-weight: 800; }

@media (max-width: 1100px) {
  .hero { grid-template-columns: 1fr; }
  .stat-grid { grid-template-columns: repeat(3, 1fr); }
  .filter-row { grid-template-columns: 1fr 1fr; }
  .drawer { width: min(920px, 88vw); }
}
@media (max-width: 720px) {
  .app-shell { padding: 10px; }
  .hero { padding: 18px; }
  .stat-grid, .search-row, .filter-row { grid-template-columns: 1fr; }
  .results-toolbar { align-items: stretch; flex-direction: column; }
  .pager { justify-content: space-between; }
  .drawer { width: 100vw; }
  td.desc { min-width: 300px; }
}
