:root {
  --bg: #0f1216;
  --card: #171b21;
  --line: #262c35;
  --txt: #e7ecf2;
  --muted: #93a0b0;
  --accent: #2f81f7;
  --ok: #1f8f5f;
  --ko: #c0392b;
  --new: #f0a52c;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--txt);
  font: 15px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

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

.topbar {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 20px; background: #12161b;
  border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5;
}
.brand { font-weight: 650; color: var(--txt); font-size: 16px; }
.brand:hover { text-decoration: none; }
.domain { color: var(--muted); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; }
.topbar nav { margin-left: auto; display: flex; gap: 8px; align-items: center; }

main { max-width: 1000px; margin: 0 auto; padding: 20px 16px 60px; }

.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: 12px; padding: 16px 18px; margin-bottom: 16px;
}
.card.highlight { border-color: #33507d; background: #161d29; }
.card h2 { font-size: 15px; margin: 0 0 12px; font-weight: 650; }
.card-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; justify-content: space-between; }
.card-head h2 { margin-bottom: 8px; }

.muted { color: var(--muted); font-weight: 400; }
.small { font-size: 12.5px; }
.strong { font-weight: 600; }
.right { text-align: right; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }

/* Formulaires */
.grid-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; align-items: end; }
.grid-form .full { grid-column: 1 / -1; }
.grid-form .wide { grid-column: span 2; }
label { display: block; font-size: 12.5px; color: var(--muted); }
input, textarea, select {
  width: 100%; margin-top: 5px; padding: 9px 10px;
  background: #0d1116; color: var(--txt);
  border: 1px solid var(--line); border-radius: 8px; font: inherit;
}
input:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
textarea { resize: vertical; }
.addr-input { display: flex; align-items: center; gap: 6px; }
.addr-input span { color: var(--muted); font-family: ui-monospace, Menlo, monospace; font-size: 13px; white-space: nowrap; }
.search { display: flex; gap: 8px; align-items: flex-end; }
.search input { min-width: 240px; }

.btn {
  display: inline-block; padding: 9px 14px; border-radius: 8px;
  border: 1px solid var(--line); background: #1e242c; color: var(--txt);
  font: inherit; cursor: pointer; white-space: nowrap;
}
.btn:hover { background: #262d37; text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.btn.primary:hover { filter: brightness(1.1); }
.btn.danger { background: transparent; border-color: #5a2a26; color: #e4796e; }
.btn.danger:hover { background: #3a1e1b; }
.btn.ghost { background: transparent; }
.btn.small { padding: 4px 9px; font-size: 12.5px; }
.row-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row-actions form { margin: 0; }
.row-actions label { display: flex; align-items: center; gap: 6px; }
.row-actions input[type="checkbox"] { width: auto; margin: 0; }
.inline-reset { flex-wrap: nowrap; }
.inline-reset input { margin-top: 0; min-width: 165px; }

/* Tableaux */
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; }
th, td { padding: 9px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
tbody tr:hover { background: #1b212a; }
tr.inactive { opacity: .5; }
table.headers th { width: 70px; text-transform: none; letter-spacing: 0; }
table.headers td, table.headers th { border: none; padding: 3px 8px 3px 0; }

.tag { display: inline-block; padding: 1px 7px; border-radius: 999px; font-size: 11.5px; background: #262d37; color: var(--muted); }
.tag.new { background: var(--new); color: #241a05; font-weight: 600; }
.tag.off { background: #402626; color: #e4796e; }
.tag.out { background: #1d3a2b; color: #6fd39b; }

.flash { padding: 10px 14px; border-radius: 8px; margin-bottom: 14px; font-size: 14px; }
.flash.ok { background: #14301f; border: 1px solid #1f5c3b; color: #86e0ae; }
.flash.ko { background: #331a17; border: 1px solid #6b2f27; color: #f0a89e; }

/* Liste de messages */
.msglist { list-style: none; margin: 0; padding: 0; }
.msglist li { border-bottom: 1px solid var(--line); }
.msglist li:last-child { border-bottom: none; }
.msglist a { display: block; padding: 10px 8px; color: var(--txt); border-left: 3px solid transparent; }
.msglist a:hover { background: #1b212a; text-decoration: none; }
.msglist li.unseen a { border-left-color: var(--new); }
.msglist li.unseen .subject { font-weight: 650; }
.msg-line { display: flex; justify-content: space-between; gap: 12px; }
.from { color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.subject { margin-top: 2px; }

.links { list-style: none; margin: 0; padding: 0; }
.links li { padding: 6px 0; border-bottom: 1px solid var(--line); display: flex; gap: 10px; align-items: center; justify-content: space-between; }
.links li:last-child { border-bottom: none; }
.links a { word-break: break-all; font-size: 13px; }

.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  font: 600 18px/1 ui-monospace, Menlo, monospace; letter-spacing: .12em;
  padding: 10px 14px; border-radius: 8px; cursor: pointer;
  background: #0d1116; border: 1px solid var(--line); color: var(--txt);
}
.chip:hover { border-color: var(--accent); }
.chip span { letter-spacing: 0; font-family: inherit; }

.body-text { white-space: pre-wrap; word-wrap: break-word; margin: 0; font: 13.5px/1.6 ui-monospace, Menlo, monospace; color: #cbd5e1; max-height: 60vh; overflow: auto; }
.body-html { width: 100%; height: 60vh; border: 1px solid var(--line); border-radius: 8px; background: #fff; }

details summary { cursor: pointer; color: var(--muted); margin-bottom: 10px; }
details.fiche { margin-top: 12px; }

.login-card { max-width: 380px; margin: 12vh auto; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 26px; }
.login-card h1 { font-size: 20px; margin: 0 0 6px; }
.login-card p { margin-top: 0; font-size: 13px; }
.login-card button { width: 100%; margin-top: 14px; }

.copied { background: var(--ok) !important; border-color: var(--ok) !important; color: #fff !important; }

@media (max-width: 620px) {
  .search input { min-width: 0; }
  table.compact th:nth-child(4), table.compact td:nth-child(4) { display: none; }
}
