:root {
  --bg: #f4f6f8;
  --card: #ffffff;
  --ink: #1d2733;
  --muted: #6b7785;
  --line: #e2e7ec;
  --brand: #0d6e74;
  --brand-dark: #08545a;
  --accent: #e8f4f4;
  --error: #b42318;
  --success: #067647;
  --radius: 12px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.5;
}

a { color: var(--brand); }

.inner { max-width: 1150px; margin: 0 auto; padding: 0 20px; }

/* ---------- Logo ---------- */
.logo {
  display: inline-block;
  background: var(--brand);
  color: #fff;
  font-weight: 800;
  letter-spacing: .08em;
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 1.1rem;
}
.logo.small { padding: 4px 8px; font-size: .8rem; }

/* ---------- Pages d'accès ---------- */
.auth {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: linear-gradient(160deg, #0d6e74 0%, #12898f 45%, var(--bg) 45%);
}
.auth .card { width: 100%; max-width: 400px; }
.brand { text-align: center; margin-bottom: 20px; }
.brand h1 { margin: 14px 0 0; font-size: 1.5rem; }
.brand .year { margin: 2px 0 0; color: var(--muted); }
.hint { color: var(--muted); font-size: .9rem; margin-top: 0; }

.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 28px;
  box-shadow: 0 10px 30px rgba(16, 24, 40, .08);
}

/* ---------- Formulaires ---------- */
label { display: block; font-weight: 600; font-size: .9rem; margin: 14px 0 6px; }
input, textarea {
  width: 100%;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font: inherit;
  background: #fff;
}
input:focus, textarea:focus { outline: 2px solid var(--brand); outline-offset: 1px; border-color: transparent; }
textarea { resize: vertical; }

button {
  margin-top: 20px;
  width: 100%;
  padding: 12px;
  border: 0;
  border-radius: 8px;
  background: var(--brand);
  color: #fff;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}
button:hover { background: var(--brand-dark); }
button.link {
  width: auto; margin: 0; padding: 0;
  background: none; color: #fff; font-weight: 500;
  text-decoration: underline; opacity: .9;
}
form.inline { display: inline; }

.alert { padding: 10px 14px; border-radius: 8px; margin-bottom: 14px; font-size: .92rem; }
.alert.error   { background: #fef3f2; color: var(--error); }
.alert.success { background: #ecfdf3; color: var(--success); }

/* ---------- Dashboard ---------- */
.topbar { background: var(--brand); color: #fff; }
.topbar .inner:first-child {
  display: flex; justify-content: space-between; align-items: center;
  padding-top: 14px; padding-bottom: 10px; gap: 12px; flex-wrap: wrap;
}
.topbar .title { display: flex; align-items: center; gap: 10px; font-weight: 700; }
.topbar .title em { font-style: normal; opacity: .75; font-weight: 500; }
.topbar .logo { background: #fff; color: var(--brand); }
.topbar .me { display: flex; gap: 14px; align-items: center; font-size: .9rem; }

.tabs { display: flex; gap: 4px; }
.tabs a {
  color: #fff; text-decoration: none; padding: 10px 16px;
  border-radius: 8px 8px 0 0; opacity: .85; font-weight: 600; font-size: .95rem;
}
.tabs a.active { background: var(--bg); color: var(--brand); opacity: 1; }

.dash { padding-top: 24px; padding-bottom: 48px; }
.section-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.section-head h2 { margin: 0; }
.section-head input { max-width: 280px; }
.count {
  background: var(--accent); color: var(--brand); font-size: .85rem;
  padding: 2px 10px; border-radius: 99px; vertical-align: middle;
}
.nudge { background: #fffaeb; color: #93370d; padding: 10px 14px; border-radius: 8px; font-size: .92rem; }

.table-wrap {
  margin-top: 16px; background: var(--card); border-radius: var(--radius);
  box-shadow: 0 4px 16px rgba(16, 24, 40, .05); overflow-x: auto;
}
table { width: 100%; border-collapse: collapse; font-size: .93rem; }
th, td { padding: 12px 14px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
th { background: #fafbfc; font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
tr:last-child td { border-bottom: 0; }
tr.mine td { background: var(--accent); }
td a { text-decoration: none; }
td.sujet { min-width: 240px; }
.edit { font-size: .8rem; margin-left: 6px; }
.muted { color: var(--muted); }
#noresult { padding: 16px; margin: 0; }

.placeholder { text-align: center; padding: 60px 20px; }
.placeholder .gift { font-size: 3rem; }
.placeholder p { color: var(--muted); }

.profile .card { max-width: 720px; }
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.profile button { width: auto; padding: 12px 28px; }

/* ---------- Mobile : tableau en cartes ---------- */
@media (max-width: 760px) {
  .grid { grid-template-columns: 1fr; }
  .section-head input { max-width: none; }
  .tabs a { padding: 10px 12px; font-size: .9rem; }
  thead { display: none; }
  table, tbody, tr, td { display: block; width: 100%; }
  tr { border-bottom: 1px solid var(--line); padding: 8px 0; }
  td { border: 0; padding: 4px 16px; }
  td::before {
    content: attr(data-label);
    display: block; font-size: .72rem; text-transform: uppercase;
    letter-spacing: .04em; color: var(--muted);
  }
  td.sujet { min-width: 0; }
}

/* ---------- Articles ---------- */
.badge {
  display: inline-block; min-width: 20px; padding: 0 6px; margin-left: 4px;
  border-radius: 99px; background: #f79009; color: #fff; font-size: .75rem; text-align: center;
}
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.btn {
  display: inline-block; padding: 10px 16px; border-radius: 8px; border: 1px solid var(--brand);
  background: var(--brand); color: #fff; text-decoration: none; font-weight: 600; font-size: .92rem;
  width: auto; margin: 0; line-height: 1.2; cursor: pointer;
}
.btn:hover { background: var(--brand-dark); }
.btn.ghost { background: #fff; color: var(--brand); }
.btn.ghost:hover { background: var(--accent); }
.btn.small { padding: 6px 12px; font-size: .85rem; }
.btn.danger { color: var(--error); border-color: #fda29b; }
.btn.danger:hover { background: #fef3f2; }

.requests { margin-top: 20px; background: #fffaeb; border: 1px solid #fedf89; border-radius: var(--radius); padding: 14px 18px; }
.requests h3 { margin: 0 0 6px; font-size: 1rem; }
.count.warn { background: #fedf89; color: #93370d; }
.request { display: flex; gap: 14px; justify-content: space-between; align-items: center; padding: 10px 0; border-top: 1px solid #fedf89; }
.request:first-of-type { border-top: 0; }

.search-wide { margin-top: 20px; }
.articles { list-style: none; padding: 0; margin: 14px 0 0; background: var(--card); border-radius: var(--radius); box-shadow: 0 4px 16px rgba(16,24,40,.05); }
.articles li { display: flex; gap: 14px; justify-content: space-between; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.articles li:last-child { border-bottom: 0; }
.articles li:target { background: var(--accent); }
.ref { margin: 0; overflow-wrap: anywhere; }
.ref a { word-break: break-all; }
.meta { margin: 4px 0 0; font-size: .82rem; color: var(--muted); }
.msg { margin: 4px 0 0; font-size: .88rem; }
.ops { display: flex; gap: 6px; flex-shrink: 0; }
.ops form { margin: 0; }
.empty { margin-top: 18px; color: var(--muted); }

.form-page .card { max-width: 760px; }
.form-page button[type=submit] { width: auto; padding: 12px 28px; }
.request-recap { background: #fffaeb; border-radius: 8px; padding: 12px 16px; margin-bottom: 16px; max-width: 760px; }
.request-recap p { margin: 6px 0 0; }
.small { font-size: .82rem; }
select { width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; font: inherit; background: #fff; }
input[type=file] { padding: 9px; background: #fafbfc; }

details.apa { margin-top: 10px; border: 1px dashed var(--line); border-radius: 8px; padding: 8px 14px; }
details.apa summary { cursor: pointer; color: var(--brand); font-weight: 600; font-size: .9rem; }
.apa-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0 12px; }
.apa-grid .full { grid-column: 1 / -1; }
.apa-grid label { font-size: .82rem; margin-top: 10px; }
.apa-grid input, .apa-grid select { padding: 8px 10px; font-size: .9rem; }

@media (max-width: 760px) {
  .articles li, .request { flex-direction: column; align-items: stretch; }
  .apa-grid { grid-template-columns: 1fr 1fr; }
}

/* ---------- Administration ---------- */
.foot { padding-bottom: 28px; text-align: right; font-size: .8rem; }
.foot a { color: var(--muted); }
.center { text-align: center; }
.admin-auth { background: linear-gradient(160deg, #344054 0%, #475467 45%, var(--bg) 45%); }
.admin-bar { background: #344054; padding-bottom: 12px; }
.admin-bar .logo { color: #344054; }
.link-light { color: #fff; opacity: .9; }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 20px; }
.stat { background: var(--card); border-radius: var(--radius); padding: 16px 18px; box-shadow: 0 4px 16px rgba(16,24,40,.05); }
.stat .n { display: block; font-size: 1.8rem; font-weight: 800; color: var(--brand); }
.stat .l { font-size: .85rem; color: var(--muted); }
.admin-block { max-width: 720px; }
.admin-block h2 { margin-top: 0; }
.row { display: flex; gap: 10px; }
.row button { margin: 0; width: auto; padding: 0 24px; }
.config { display: grid; grid-template-columns: max-content 1fr; gap: 4px 16px; margin: 18px 0 0; font-size: .88rem; }
.config dt { color: var(--muted); }
.config dd { margin: 0; }
.ko { color: var(--error); }
@media (max-width: 760px) {
  .stats { grid-template-columns: 1fr 1fr; }
  .row { flex-direction: column; }
  .row button { padding: 12px; }
}

/* ---------- Suggestion de fiche (identification) ---------- */
.lookup { position: relative; }
.lookup-list {
  position: absolute; z-index: 10; left: 0; right: 0; top: calc(100% + 4px);
  list-style: none; margin: 0; padding: 4px; background: #fff;
  border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 10px 24px rgba(16,24,40,.12);
  max-height: 260px; overflow-y: auto;
}
.lookup-list li { padding: 9px 10px; border-radius: 6px; cursor: pointer; }
.lookup-list li:hover, .lookup-list li.active { background: var(--accent); }
.lookup-list li span { color: var(--muted); }
.found { margin: 8px 0 0; font-size: .85rem; color: var(--success); }
