:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --ink: #1b2233;
  --ink-2: #4b5468;
  --muted: #7a8296;
  --line: #e3e6ec;
  --brand: #14213d;
  --accent: #0f8b6e;
  --accent-soft: #e3f5ef;
  --warn: #b26a00;
  --warn-soft: #fff4e0;
  --low: #8a93a6;
  --low-soft: #eef0f4;
  --danger: #b42318;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06);
  font-family: "Segoe UI", system-ui, -apple-system, "Noto Sans Arabic", Arial, sans-serif;
  font-size: 14px;
  color: var(--ink);
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); }
a { color: var(--brand); }
h1 { font-size: 22px; margin: 6px 0 14px; }
h2 { font-size: 15px; margin: 0 0 10px; }
h3 { font-size: 13px; margin: 14px 0 6px; color: var(--ink-2); text-transform: uppercase; letter-spacing: .04em; }
code { background: var(--low-soft); padding: 1px 5px; border-radius: 4px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.nowrap { white-space: nowrap; }

/* top bar */
.topbar { display: flex; align-items: center; gap: 24px; padding: 10px 24px; background: var(--brand); color: #fff; position: sticky; top: 0; z-index: 10; }
.topbar a { color: #cfd6e6; text-decoration: none; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 16px; color: #fff !important; }
.brand.big { font-size: 22px; color: var(--brand) !important; }
.logo { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 7px; background: var(--accent); color: #fff; font-weight: 800; }
.topbar nav { display: flex; gap: 4px; }
.topbar nav a { padding: 6px 10px; border-radius: 6px; }
.topbar nav a.active, .topbar nav a:hover { background: rgba(255, 255, 255, .12); color: #fff; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 16px; }
.topbar-right form { margin: 0; }
.role { font-size: 11px; background: rgba(255, 255, 255, .15); padding: 1px 6px; border-radius: 4px; margin-left: 4px; }

.container { max-width: 1320px; margin: 0 auto; padding: 20px 24px 60px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; margin-bottom: 16px; }
.card-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.card-head h2 { margin: 0; }
.card-head form { margin: 0; }
.narrow { max-width: 560px; }

/* buttons & inputs */
.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid transparent; border-radius: 7px; padding: 7px 14px; font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn-sm { padding: 5px 10px; font-size: 13px; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { filter: brightness(.95); }
.btn-ghost { background: var(--surface); border-color: var(--line); color: var(--ink); }
.btn-ghost:hover { background: var(--low-soft); }
.btn[disabled] { opacity: .6; cursor: default; }
.btn-block { width: 100%; justify-content: center; }
input, select, textarea { font: inherit; padding: 7px 9px; border: 1px solid var(--line); border-radius: 7px; background: #fff; color: var(--ink); min-width: 0; }
textarea { width: 100%; resize: vertical; }
label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--ink-2); }
label.check { flex-direction: row; align-items: center; gap: 6px; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.row { display: flex; gap: 12px; flex-wrap: wrap; }
.row > label { flex: 1; min-width: 180px; }
.inline { display: flex; gap: 6px; margin: 0; }
.alert { padding: 10px 14px; border-radius: 8px; margin-bottom: 14px; }
.alert-error { background: #fdecea; color: var(--danger); }
.alert-info { background: var(--accent-soft); color: #0b5e4a; }

/* KPIs */
.kpis { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; margin-bottom: 16px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.kpis-filtered .kpi { border-color: var(--accent); background: linear-gradient(var(--accent-soft), var(--surface) 60%); }
.kpi-num { font-size: 26px; font-weight: 700; }
.kpi-num.accent { color: var(--accent); }
.kpi-num.warn { color: var(--warn); }
.kpi-label { color: var(--muted); font-size: 12px; }

/* filters */
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.filters .grow { flex: 1 1 240px; }
.table-meta { margin: 0 2px 8px; font-size: 12px; }

/* table */
.table-wrap { padding: 0; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 600; padding: 10px 12px; border-bottom: 1px solid var(--line); background: #fafbfc; }
td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fafbfd; }
.title-cell { max-width: 620px; }
.tender-title { font-weight: 600; text-decoration: none; color: var(--ink); }
.tender-title:hover { color: var(--accent); }
.sub { color: var(--muted); font-size: 12px; margin-top: 2px; }
.summary { font-size: 12.5px; color: var(--ink-2); margin-top: 4px; }
.fit { font-size: 13px; }
.empty { text-align: center; padding: 40px; color: var(--muted); }

.score { display: inline-grid; place-items: center; min-width: 34px; height: 26px; padding: 0 6px; border-radius: 6px; font-weight: 700; font-size: 13px; }
.score.big { min-width: 56px; height: 44px; font-size: 20px; border-radius: 10px; }
.score-high { background: var(--accent); color: #fff; }
.score-medium { background: var(--warn-soft); color: var(--warn); }
.score-low { background: var(--low-soft); color: var(--ink-2); }
.score-irrelevant { background: #f6f6f6; color: #aaa; }
.badge { font-size: 10px; font-weight: 700; padding: 1px 5px; border-radius: 4px; margin-left: 4px; vertical-align: middle; }
.badge-ai { background: #ede9fe; color: #5b21b6; }
.badge-mail { display: inline-block; margin: 4px 0 0; background: #e0ecff; color: #1d4ed8; }
.pill { display: inline-block; font-size: 12px; font-weight: 600; padding: 2px 9px; border-radius: 999px; background: var(--low-soft); color: var(--ink-2); }
.pill-reviewing { background: #e0ecff; color: #1d4ed8; }
.pill-go, .pill-preparing { background: var(--accent-soft); color: #0b5e4a; }
.pill-submitted { background: #ede9fe; color: #5b21b6; }
.pill-won { background: #dcfce7; color: #166534; }
.pill-lost, .pill-no-go { background: #fdecea; color: var(--danger); }

/* detail */
.back { display: inline-block; margin-bottom: 10px; text-decoration: none; }
.detail-head { display: flex; gap: 14px; align-items: flex-start; margin-bottom: 16px; }
.detail-head h1 { margin: 0 0 4px; line-height: 1.35; }
.detail-grid { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 16px; align-items: start; }
.lead { font-size: 15px; line-height: 1.5; }
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px; margin: 12px 0; }
.facts > div { background: #fafbfc; border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; }
.facts span { display: block; font-size: 11px; color: var(--muted); }
.facts b { font-size: 13px; }
.memo h2, .memo h3 { font-size: 14px; text-transform: none; letter-spacing: 0; color: var(--brand); margin: 14px 0 4px; }
.memo p, .memo li { line-height: 1.5; }
.original { white-space: pre-wrap; background: #fafbfc; border: 1px solid var(--line); border-radius: 8px; padding: 10px; margin-top: 8px; max-height: 420px; overflow: auto; line-height: 1.6; }
.kv { display: grid; grid-template-columns: 90px 1fr; gap: 6px 10px; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
.breakdown { white-space: pre-wrap; font-size: 12px; background: #fafbfc; border-radius: 8px; padding: 10px; margin: 8px 0 0; font-family: inherit; }
.comments { list-style: none; padding: 0; margin: 12px 0 0; }
.comments li { border-top: 1px solid var(--line); padding: 8px 0; }
.comments li.event { color: var(--muted); font-size: 12px; }
.comments .who { font-size: 11px; color: var(--muted); margin-bottom: 2px; }

/* pipeline */
.board { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(230px, 1fr); gap: 12px; overflow-x: auto; padding-bottom: 8px; }
.column { background: #eceef2; border-radius: var(--radius); padding: 10px; min-height: 200px; }
.column-head { display: flex; justify-content: space-between; margin-bottom: 10px; }
.card.mini { display: block; padding: 10px; margin-bottom: 8px; text-decoration: none; color: var(--ink); }
.card.mini:hover { border-color: var(--accent); }
.mini-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.mini-title { font-weight: 600; font-size: 13px; margin-bottom: 4px; }
.empty-col { text-align: center; padding: 20px 0; }

/* notifications */
.bell { position: relative; font-size: 16px; text-decoration: none; }
.bell-count { position: absolute; top: -6px; right: -10px; background: #e5484d; color: #fff; font-size: 10px; font-weight: 700; border-radius: 999px; padding: 1px 5px; }
.notes { list-style: none; margin: 0; padding: 0; }
.notes li { border-bottom: 1px solid var(--line); }
.notes li:last-child { border-bottom: 0; }
.notes li a { display: block; padding: 12px 16px; color: var(--ink); text-decoration: none; }
.notes li a:hover { background: #fafbfd; }
.notes li.unread a { background: var(--accent-soft); }
.note-type { font-weight: 600; font-size: 13px; margin-bottom: 2px; }
.email-status p { margin: 6px 0; }

/* runs & settings */
.run summary { cursor: pointer; display: flex; gap: 10px; align-items: center; }
.log { white-space: pre-wrap; font-size: 12px; background: #0f172a; color: #d6deeb; padding: 12px; border-radius: 8px; max-height: 480px; overflow: auto; }
.checks { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 6px; margin-bottom: 12px; }
.settings label:not(.check) { margin-top: 8px; }
.actions { margin-top: 14px; }

/* login */
.login-body { min-height: 100vh; display: grid; place-items: center; }
.login-card { width: 340px; display: flex; flex-direction: column; gap: 12px; padding: 28px; }
.login-card p { margin: -6px 0 6px; }

@media (max-width: 900px) {
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .detail-grid { grid-template-columns: 1fr; }
  .topbar { flex-wrap: wrap; gap: 10px; padding: 10px 16px; }
  .topbar-right { margin-left: 0; }
  .container { padding: 16px; }
}

/* hosted edition */
.pc-status { display: flex; align-items: center; gap: 8px; }
.pc-status .muted { color: #cfd6e6; }
.topbar .pill-won { background: rgba(220, 252, 231, .95); }
.topbar .pill-lost { background: rgba(253, 236, 234, .95); }
@media (max-width: 900px) { .pc-status .muted { display: none; } }