:root {
  --bg: #fbfaf8;
  --panel: #ffffff;
  --panel-2: #f6f4f0;
  --line: #e6e2db;
  --line-2: #d5cfc5;
  --text: #1b1a18;
  --dim: #6f6a63;
  --dim-2: #928c83;
  --accent: #b4552d;
  --accent-soft: #f6ebe4;
  --ok: #2f7d4f;
  --ok-soft: #e8f3ec;
  --warn: #9a6a12;
  --warn-soft: #f8f0dd;
  --bad: #b03b2e;
  --bad-soft: #fbeae7;
  --info: #3a5f92;
  --radius: 9px;
  --shadow: 0 1px 2px rgba(24, 20, 14, 0.05), 0 8px 24px -12px rgba(24, 20, 14, 0.14);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #16151300;
    --bg: #161513;
    --panel: #1e1d1a;
    --panel-2: #252320;
    --line: #322f2b;
    --line-2: #423e38;
    --text: #ece8e1;
    --dim: #9a948b;
    --dim-2: #7d776f;
    --accent: #e08a5c;
    --accent-soft: #33241c;
    --ok: #6fbf8e;
    --ok-soft: #1c2a21;
    --warn: #d3a349;
    --warn-soft: #2c2518;
    --bad: #e0705f;
    --bad-soft: #2e1d1a;
    --info: #7fa3d8;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px -12px rgba(0, 0, 0, 0.6);
  }
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14.5px/1.55 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- layout ---------- */

#app { display: grid; grid-template-columns: 216px 1fr; min-height: 100vh; }

nav.side {
  border-right: 1px solid var(--line);
  background: var(--panel);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  padding: 18px 18px 14px;
  border-bottom: 1px solid var(--line);
}
.brand b { display: block; font-size: 14.5px; letter-spacing: -0.01em; }
.brand span { font-size: 11.5px; color: var(--dim); }

nav.side .links { padding: 10px 8px; flex: 1; overflow-y: auto; }
nav.side a {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 10px;
  border-radius: 7px;
  color: var(--text);
  font-size: 13.5px;
  margin-bottom: 1px;
}
nav.side a:hover { background: var(--panel-2); text-decoration: none; }
nav.side a[aria-current="page"] { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
nav.side a .k { width: 16px; text-align: center; opacity: 0.75; }
nav.side .foot { padding: 12px 14px; border-top: 1px solid var(--line); font-size: 12px; color: var(--dim); }

main { min-width: 0; padding: 26px 30px 70px; max-width: 1240px; }

/* ---------- typography ---------- */

h1 { font-size: 21px; letter-spacing: -0.02em; margin: 0 0 3px; }
h2 { font-size: 16px; letter-spacing: -0.01em; margin: 26px 0 10px; }
h3 {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.09em;
  color: var(--dim); font-weight: 600; margin: 0 0 10px;
}
.sub { color: var(--dim); font-size: 13px; margin: 0 0 20px; }
.muted { color: var(--dim); }
.small { font-size: 12.5px; }
.mono { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 12.5px; }

/* ---------- controls ---------- */

button, .btn {
  font: inherit; font-size: 13px; padding: 6px 12px; border-radius: 7px;
  border: 1px solid var(--line-2); background: var(--panel); color: var(--text);
  cursor: pointer; display: inline-flex; align-items: center; gap: 6px;
}
button:hover, .btn:hover { border-color: var(--dim-2); text-decoration: none; }
button:disabled { opacity: 0.5; cursor: not-allowed; }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 500; }
button.primary:hover { filter: brightness(1.07); }
button.ok { color: var(--ok); border-color: var(--ok); }
button.danger { color: var(--bad); border-color: var(--bad); }
button.ghost { border-color: transparent; background: transparent; color: var(--dim); }
button.ghost:hover { background: var(--panel-2); color: var(--text); }
button.sm { padding: 3px 8px; font-size: 12px; }

input, select, textarea {
  font: inherit; font-size: 13.5px; padding: 7px 10px; border-radius: 7px;
  border: 1px solid var(--line-2); background: var(--panel); color: var(--text);
  width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
textarea { resize: vertical; min-height: 120px; line-height: 1.6; }
label { display: block; font-size: 12px; color: var(--dim); margin-bottom: 4px; font-weight: 500; }
.field { margin-bottom: 13px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.row > * { flex: 1; min-width: 130px; }
.row > .fixed { flex: 0 0 auto; min-width: 0; }

/* ---------- cards / tables ---------- */

.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px 20px; margin-bottom: 16px;
}
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(122px, 1fr)); gap: 10px; margin-bottom: 22px; }
.stat {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px 14px;
}
.stat b { display: block; font-size: 22px; letter-spacing: -0.02em; line-height: 1.2; }
.stat span { font-size: 11.5px; color: var(--dim); }

table { width: 100%; border-collapse: collapse; }
thead th {
  text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: 0.07em;
  color: var(--dim); font-weight: 600; padding: 0 12px 8px; border-bottom: 1px solid var(--line);
}
tbody td { padding: 9px 12px; border-bottom: 1px solid var(--line); font-size: 13.5px; }
tbody tr:hover { background: var(--panel-2); }
tbody tr.clickable { cursor: pointer; }
.table-wrap {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  overflow-x: auto;
}
.table-wrap table { min-width: 420px; }
tbody tr:last-child td { border-bottom: 0; }

/* lista principala: doar website + email, cat mai calma */
.lista-firme th:first-child, .lista-firme td:first-child { width: 34px; padding-right: 0; }
.lista-firme td:nth-child(2) { width: 48%; }
.lista-firme td a { color: var(--text); }
.lista-firme td a:hover { color: var(--accent); }
.lista-firme .gol { color: var(--dim-2); }

/* ---------- chips / badges ---------- */

.chip {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11.5px; padding: 2px 8px; border-radius: 20px;
  background: var(--panel-2); color: var(--dim); white-space: nowrap;
}
.chip.ok { background: var(--ok-soft); color: var(--ok); }
.chip.warn { background: var(--warn-soft); color: var(--warn); }
.chip.bad { background: var(--bad-soft); color: var(--bad); }
.chip.accent { background: var(--accent-soft); color: var(--accent); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }

.scor { font-variant-numeric: tabular-nums; font-weight: 600; }
.scor.ok { color: var(--ok); }
.scor.warn { color: var(--warn); }
.scor.bad { color: var(--bad); }

.bara { height: 5px; background: var(--panel-2); border-radius: 3px; overflow: hidden; }
.bara i { display: block; height: 100%; background: var(--accent); }

/* ---------- evidence / opportunity ---------- */

.dovada {
  border-left: 2px solid var(--line-2); padding: 2px 0 2px 12px; margin-bottom: 12px;
}
.dovada.OBSERVED { border-color: var(--ok); }
.dovada.INFERENCE { border-color: var(--info); }
.dovada.HYPOTHESIS { border-color: var(--warn); }
.dovada b { font-weight: 500; display: block; }
.dovada .meta { font-size: 12px; color: var(--dim); margin-top: 2px; }

.pasi { counter-reset: pas; list-style: none; padding: 0; margin: 8px 0 0; }
.pasi li {
  counter-increment: pas; padding: 3px 0 3px 26px; position: relative; font-size: 13.5px;
}
.pasi li::before {
  content: counter(pas); position: absolute; left: 0; top: 3px;
  width: 18px; height: 18px; border-radius: 50%; background: var(--panel-2);
  color: var(--dim); font-size: 11px; display: grid; place-items: center;
}

.propunere p { font-size: 14.5px; line-height: 1.65; margin-bottom: 11px; }
.propunere p:last-child { margin-bottom: 0; }

.email-corp {
  white-space: pre-wrap; word-wrap: break-word; margin: 0;
  font: 14px/1.7 ui-sans-serif, system-ui, sans-serif;
}
.email-subiect {
  font-weight: 600; padding-bottom: 11px; margin-bottom: 13px;
  border-bottom: 1px solid var(--line);
}

/* ---------- split view ---------- */

.split { display: grid; grid-template-columns: 320px 1fr; gap: 16px; align-items: start; }
.split .lista {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  max-height: calc(100vh - 190px); overflow-y: auto;
}
.split .lista .it {
  padding: 10px 13px; border-bottom: 1px solid var(--line); cursor: pointer;
}
.split .lista .it:hover { background: var(--panel-2); }
.split .lista .it[aria-selected="true"] { background: var(--accent-soft); box-shadow: inset 2px 0 0 var(--accent); }
.split .lista .it b { font-size: 13.5px; font-weight: 500; display: block; }
.split .lista .it .meta { font-size: 11.5px; color: var(--dim); display: flex; gap: 6px; margin-top: 2px; }

/* ---------- modal ---------- */

.mask {
  position: fixed; inset: 0; background: rgba(20, 17, 13, 0.42);
  display: grid; place-items: center; padding: 20px; z-index: 40;
}
.modal {
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  box-shadow: var(--shadow); width: min(560px, 100%); max-height: 88vh; overflow-y: auto;
  padding: 22px 24px;
}
.modal h2 { margin: 0 0 4px; font-size: 17px; }
.modal .actiuni { display: flex; gap: 8px; justify-content: flex-end; margin-top: 18px; }

/* ---------- toast ---------- */

#toasts { position: fixed; right: 16px; bottom: 16px; display: grid; gap: 8px; z-index: 60; }
.toast {
  background: var(--panel); border: 1px solid var(--line-2); border-left: 3px solid var(--accent);
  border-radius: 8px; padding: 10px 14px; box-shadow: var(--shadow); font-size: 13px;
  max-width: 380px;
}
.toast.ok { border-left-color: var(--ok); }
.toast.bad { border-left-color: var(--bad); }

/* ---------- login ---------- */

.login-wrap { display: grid; place-items: center; min-height: 100vh; padding: 20px; }
.login { width: min(360px, 100%); }

/* ---------- misc ---------- */

.bara-sus {
  display: flex; justify-content: space-between; align-items: flex-start;
  gap: 16px; flex-wrap: wrap; margin-bottom: 18px;
}
.actiuni { display: flex; gap: 8px; flex-wrap: wrap; }
.gol-mesaj { text-align: center; color: var(--dim); padding: 46px 20px; }
.spin { display: inline-block; animation: rot 0.9s linear infinite; }
@keyframes rot { to { transform: rotate(360deg); } }
hr { border: 0; border-top: 1px solid var(--line); margin: 18px 0; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
dl.kv { display: grid; grid-template-columns: 128px 1fr; gap: 5px 12px; margin: 0; font-size: 13.5px; }
dl.kv dt { color: var(--dim); font-size: 12.5px; }
dl.kv dd { margin: 0; word-break: break-word; }

@media (max-width: 940px) {
  #app { grid-template-columns: 1fr; }
  nav.side { position: static; height: auto; flex-direction: row; align-items: center; overflow-x: auto; }
  nav.side .links { display: flex; gap: 4px; padding: 8px; }
  nav.side .brand { border-bottom: 0; border-right: 1px solid var(--line); white-space: nowrap; }
  nav.side .foot { display: none; }
  main { padding: 18px 16px 60px; }
  .split, .grid-2 { grid-template-columns: 1fr; }
  .split .lista { max-height: 300px; }
}
