:root {
  --primary: #0f5c4d;
  --primary-dark: #0a4238;
  --bg: #f4f6f5;
  --card: #ffffff;
  --text: #1f2a28;
  --muted: #5d6b68;
  --danger: #b3261e;
  --radius: 10px;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "Segoe UI", Tahoma, "Noto Kufi Arabic", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.7;
}
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 20px; background: var(--primary); color: #fff;
}
.brand { color: #fff; text-decoration: none; font-weight: 700; }
.logout { display: flex; align-items: center; gap: 10px; margin: 0; }
.container { max-width: 960px; margin: 24px auto; padding: 0 16px; }
.card { background: var(--card); border-radius: var(--radius); padding: 24px; box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.card.narrow { max-width: 420px; margin: 40px auto; }
h1 { margin-top: 0; font-size: 1.4rem; }
label { display: block; margin-bottom: 14px; color: var(--muted); }
input { display: block; width: 100%; margin-top: 4px; padding: 10px; border: 1px solid #cfd8d6; border-radius: 8px; font: inherit; }
button { padding: 9px 18px; border: 0; border-radius: 8px; background: var(--primary); color: #fff; font: inherit; cursor: pointer; }
button:hover { background: var(--primary-dark); }
.topbar button { background: rgba(255,255,255,.15); }
.error { color: var(--danger); }

/* Navigation */
.nav { display: flex; gap: 16px; }
.nav a { color: #fff; text-decoration: none; opacity: .85; }
.nav a:hover, .nav a.active { opacity: 1; text-decoration: underline; }

/* Library */
.card + .card { margin-top: 16px; }
.muted { color: var(--muted); }
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 8px; }
.filters input { flex: 1 1 220px; margin: 0; width: auto; }
.filters select { padding: 9px; border: 1px solid #cfd8d6; border-radius: 8px; font: inherit; background: #fff; }
.filters .reset { color: var(--muted); }
.table-wrap { overflow-x: auto; }
table.docs { width: 100%; border-collapse: collapse; font-size: .95rem; }
table.docs th, table.docs td { padding: 8px 10px; border-bottom: 1px solid #e6ecea; text-align: right; vertical-align: top; }
table.docs th { color: var(--muted); font-weight: 600; white-space: nowrap; }
table.docs a { color: var(--primary); text-decoration: none; }
table.docs a:hover { text-decoration: underline; }
.code { font-family: Consolas, monospace; font-size: .85rem; white-space: nowrap; }
.tag { display: inline-block; padding: 1px 6px; border-radius: 6px; background: #eef2f1; font-size: .8rem; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: .8rem; white-space: nowrap; }
.src-ministry { background: #dff1ea; color: #0a4238; }
.src-expro { background: #e6ecf8; color: #23407a; }
.src-unknown { background: #f3eee2; color: #6b5420; }
.gate { display: inline-block; min-width: 22px; margin-left: 4px; padding: 0 5px; border-radius: 6px; background: var(--primary); color: #fff; text-align: center; font-size: .8rem; }
.pager { display: flex; gap: 16px; justify-content: center; margin-top: 16px; }
.pager a { color: var(--primary); }
.meta { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; }
.meta dt { color: var(--muted); }
.meta dd { margin: 0; }
a.button { display: inline-block; padding: 9px 18px; border-radius: 8px; background: var(--primary); color: #fff; text-decoration: none; }
a.button:hover { background: var(--primary-dark); }
.chunk { border-top: 1px solid #e6ecea; padding: 10px 0; }
.chunk header { font-size: .85rem; margin-bottom: 4px; }
.chunk-text { white-space: normal; font-size: .95rem; }
.table-chunk .chunk-text { font-family: inherit; background: #f8faf9; padding: 8px; border-radius: 6px; }
h2 { font-size: 1.15rem; margin-top: 0; }

.notice { background: #fff6e0; border: 1px solid #f0d68a; color: #6b5420; padding: 8px 12px; border-radius: 8px; }
.related { margin: 0; padding-right: 18px; }
.related li { margin-bottom: 6px; }
.related a { color: var(--primary); }

/* Search */
.chip { display: inline-block; background: #eef6f3; border: 1px solid #cfe5dd; padding: 4px 10px; border-radius: 999px; }
.chip a { color: var(--danger); margin-right: 8px; text-decoration: none; }
.hit { border-top: 1px solid #e6ecea; padding: 12px 0; }
.hit h2 { font-size: 1.05rem; margin: 0 0 4px; }
.hit h2 a { color: var(--primary); text-decoration: none; }
.hit h2 a:hover { text-decoration: underline; }
.hit-meta { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 0 0 6px; font-size: .85rem; }
.snippet { margin: 0; color: #2c3a37; }
.snippet mark { background: #fff1a8; padding: 0 2px; border-radius: 3px; }
.hit-links { margin: 4px 0 0; font-size: .85rem; }
.hit-links a { color: var(--primary); }
.nav-search { display: flex; gap: 6px; }
.nav-search input { margin: 0; padding: 6px 10px; width: 220px; border: 0; border-radius: 6px; }

/* Ask */
.ask-form textarea { width: 100%; padding: 10px; border: 1px solid #cfd8d6; border-radius: 8px; font: inherit; resize: vertical; }
.ask-options { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-top: 10px; }
.ask-options select { padding: 9px; border: 1px solid #cfd8d6; border-radius: 8px; font: inherit; background: #fff; }
.modes { display: flex; gap: 6px; border: 0; margin: 0; padding: 0; }
.mode { display: inline-flex; align-items: center; gap: 4px; margin: 0; padding: 6px 12px; border: 1px solid #cfd8d6; border-radius: 999px; cursor: pointer; color: var(--text); }
.mode input { width: auto; margin: 0; display: inline; }
.opinion-mode { border-color: #e2b45c; }
.answer-text { font-size: 1.02rem; line-height: 1.9; }
.answer-text.not-found { color: var(--muted); }
.ref { display: inline-block; min-width: 18px; margin: 0 2px; padding: 0 4px; border-radius: 6px; background: #e3efe9; color: var(--primary); font-size: .75rem; text-align: center; text-decoration: none; vertical-align: super; }
.sources li { margin-bottom: 10px; }
.sources a { color: var(--primary); }
.sources .open-file { font-size: .85rem; margin-right: 8px; }
.sources blockquote { margin: 4px 0 0; padding: 6px 10px; border-right: 3px solid #cfe5dd; background: #f8faf9; color: #33433f; font-size: .9rem; }
.answer.opinion { border: 2px solid #e2b45c; background: #fffaf0; }
.opinion-label { display: inline-block; margin: 0 0 10px; padding: 3px 10px; border-radius: 999px; background: #f6e2b5; color: #6b4b10; font-weight: 600; }
.meta-line { font-size: .8rem; margin-top: 14px; }
.recent { margin: 0; padding-right: 18px; }
.recent li { margin-bottom: 6px; }
.recent a { color: var(--primary); }
