/* Travian Intel - theme gris clair */
:root {
    --bg: #cfd3d8; --surface: #e3e6ea; --surface-2: #f3f4f6; --line: #aeb5bd;
    --ink: #1f242a; --muted: #5d6671; --accent: #b07a1e; --accent-ink: #ffffff;
    --friend: #1a66c7; --enemy: #c4372a; --ok: #1f7f49; --warn: #a86f12; --bad: #c4372a;
    --radius: 8px;
}
*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; color: var(--ink); background: var(--bg); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 24px; margin: 0 0 16px; }
h2 { font-size: 18px; margin: 28px 0 12px; }
h3 { font-size: 15px; margin: 0 0 10px; }
code, kbd { background: var(--surface-2); border: 1px solid var(--line); padding: 1px 5px; border-radius: 4px; font-size: 12px; }
.container { width: 100%; max-width: 1200px; margin: 0 auto; padding: 0 16px; }
.narrow { max-width: 460px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.nowrap { white-space: nowrap; }
.friend { color: var(--friend); }
.enemy { color: var(--enemy); }
.ic { width: 18px; height: 18px; vertical-align: -4px; }

/* En-tete */
.site-header { background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10; }
.site-header__inner { display: flex; align-items: center; gap: 24px; min-height: 56px; flex-wrap: wrap; }
.brand { font-weight: 700; font-size: 17px; color: var(--ink); display: inline-flex; gap: 8px; align-items: center; }
.brand .ic { color: var(--accent); }
.nav { display: flex; gap: 4px; flex-wrap: wrap; align-items: center; }
.nav a { color: var(--muted); font-weight: 500; padding: 6px 10px; border-radius: 6px; }
.nav a:hover, .nav a.is-active { color: var(--ink); background: var(--surface-2); text-decoration: none; }
.nav--user { margin-left: auto; }
.nav--user form { margin: 0; }
.site-main { padding: 24px 0 60px; }

/* Boutons et formulaires */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: var(--radius); background: var(--accent); color: var(--accent-ink); font-weight: 600; border: 0; cursor: pointer; font-size: 14px; }
.btn:hover { text-decoration: none; filter: brightness(1.08); }
.btn--ghost { background: var(--surface-2); color: var(--ink); border: 1px solid var(--line); }
.btn--danger { background: var(--bad); color: #fff; }
.link { background: none; border: 0; color: var(--accent); cursor: pointer; padding: 0; font: inherit; }
.link:hover { text-decoration: underline; }
input, select, textarea { background: var(--bg); color: var(--ink); border: 1px solid var(--line); border-radius: 6px; padding: 8px 10px; font: inherit; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
textarea { width: 100%; font-family: ui-monospace, Consolas, monospace; font-size: 12px; resize: vertical; }
.form { display: flex; flex-direction: column; gap: 14px; }
.form label { display: flex; flex-direction: column; gap: 4px; font-weight: 500; }
.form--inline { flex-direction: row; flex-wrap: wrap; align-items: flex-end; gap: 10px; }
.form--inline label { flex-direction: column; }
.form--inline .grow { flex: 1; min-width: 200px; }
.form--inline input { width: 100%; }
.filters, .actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 16px; }
.filters input[type=search] { min-width: 240px; }
.search { position: relative; margin: 20px 0; }
.search .ic { position: absolute; left: 12px; top: 11px; color: var(--muted); }
.search input { width: 100%; padding: 10px 12px 10px 38px; font-size: 15px; }

/* Blocs */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 14px; }
.page-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 8px; }
.page-head h1, .page-head h2 { margin-bottom: 8px; }
.alert { padding: 10px 14px; border-radius: var(--radius); margin-bottom: 14px; border: 1px solid transparent; }
.alert--success { background: rgba(76, 195, 138, .12); border-color: rgba(76, 195, 138, .35); color: var(--ok); }
.alert--error { background: rgba(229, 83, 75, .12); border-color: rgba(229, 83, 75, .35); color: var(--bad); }
.alert--warn { background: rgba(231, 178, 74, .1); border-color: rgba(231, 178, 74, .35); color: var(--warn); }
.steps { padding-left: 20px; margin: 0 0 16px; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; display: flex; flex-direction: column; }
.stat__value { font-size: 26px; font-weight: 700; }
.stat__label { color: var(--muted); font-size: 12px; }
.notice { text-align: center; padding: 40px 0; }
.notice__code { font-size: 64px; font-weight: 800; color: var(--line); line-height: 1; }

/* Tableaux */
.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; }
.list th, .list td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.list th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .03em; }
.list tbody tr:hover { background: var(--surface-2); }
.list .actions { display: flex; gap: 12px; flex-wrap: wrap; margin: 0; }
.list .actions form { margin: 0; display: flex; gap: 6px; align-items: center; }
.list .actions input { padding: 4px 8px; }
.is-disabled td { opacity: .5; }
.num { text-align: right !important; font-variant-numeric: tabular-nums; }
.troops { width: auto; min-width: 100%; font-size: 13px; margin: 4px 0 6px; }
.troops th, .troops td { padding: 5px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.troops thead th { font-size: 11px; color: var(--muted); font-weight: 600; text-align: right; white-space: nowrap; }
.troops tbody th { text-align: left; color: var(--muted); font-weight: 500; white-space: nowrap; width: 1%; }
.troops .zero { color: var(--line); }
.troops td .sub { display: block; font-size: 12px; line-height: 1.2; }
.troops td .sub--lost { color: var(--enemy); }
.troops td .sub--captured { color: var(--warn); }
.troops td .sub--wounded { color: var(--friend); }
.troops__extra td { font-weight: 700; }
.troops td { vertical-align: top; }
.troops thead th.role-chief { color: var(--bad); }
.troops thead th.role-ram, .troops thead th.role-cata { color: var(--warn); }

/* Badges et etiquettes */
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 600; background: var(--surface-2); border: 1px solid var(--line); white-space: nowrap; }
.badge--attack { color: var(--enemy); }
.badge--spy { color: var(--friend); }
.tag { display: inline-block; padding: 1px 7px; border-radius: 4px; font-size: 11px; font-weight: 600; margin-right: 4px; background: var(--surface-2); }
.tag--chef { background: rgba(229, 83, 75, .2); color: var(--bad); }
.tag--siege { background: rgba(231, 178, 74, .18); color: var(--warn); }
.tag--offensif { background: rgba(255, 122, 107, .15); color: var(--enemy); }
.tag--defensif { background: rgba(92, 184, 255, .15); color: var(--friend); }

/* Fraicheur des infos */
.fresh-fresh { color: var(--ok); }
.fresh-stale { color: var(--warn); }
.fresh-old { color: var(--muted); }
tr.fresh-fresh, tr.fresh-stale, tr.fresh-old { color: inherit; }
.intel { border-left: 3px solid var(--line); padding: 8px 0 8px 12px; margin: 10px 0; }
.intel--fresh { border-left-color: var(--ok); }
.intel--stale { border-left-color: var(--warn); }
.intel--old { border-left-color: var(--bad); }
.intel__head { display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; margin-bottom: 2px; }
.villages { display: grid; grid-template-columns: 1fr; gap: 14px; }
.villages .card { margin: 0; }
.inline-list { list-style: none; padding: 0; margin: 4px 0; display: flex; gap: 18px; flex-wrap: wrap; }

/* Resume d'un rapport */
.summary__parties { display: flex; gap: 24px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.summary__parties strong { font-size: 17px; }
.summary__arrow { font-size: 22px; color: var(--muted); }
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px 18px; margin: 0; }
.facts dt { color: var(--muted); font-size: 12px; }
.facts dd { margin: 0; font-weight: 600; }
.res { display: flex; flex-wrap: wrap; gap: 4px 12px; font-weight: 500 !important; }
.res__dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 5px; }
.res__dot--wood { background: #a0703c; }
.res__dot--clay { background: #c9603a; }
.res__dot--iron { background: #9aa4b1; }
.res__dot--crop { background: #e2c044; }
.raw { white-space: pre-wrap; font-size: 11px; color: var(--muted); max-height: 400px; overflow: auto; margin: 10px 0 0; }
details summary { cursor: pointer; color: var(--muted); }
.pagination { display: flex; gap: 16px; align-items: center; justify-content: center; margin: 18px 0; }

@media (max-width: 640px) {
    .villages { grid-template-columns: 1fr; }
    .nav--user { margin-left: 0; }
    .site-header__inner { gap: 8px; padding-top: 8px; padding-bottom: 8px; }
}

/* Icones d'unites au-dessus des chiffres ; version compacte pour le tableau de bord */
.unit-icon { width: 28px; height: 28px; display: block; margin: 0 auto; object-fit: contain; }
.troops--compact { margin: 0; min-width: 0; }
.troops--compact th, .troops--compact td { padding: 2px 6px; border-bottom: 0; }
.troops--compact tbody th { display: none; }
.troops--compact td.zero { display: none; }
.units .table-wrap { overflow: visible; }

.troops thead th { padding-top: 8px; padding-bottom: 8px; }
.tribe-pick { display: inline-flex; align-items: center; gap: 8px; margin-left: 12px; font-weight: 400; }
.tribe-pick select { padding: 4px 8px; }
.card--danger { border-color: rgba(229, 83, 75, .45); }

/* Tableau de troupes facon jeu : cellules encadrees, icones a leur taille d'origine sur fond clair */
.troops { border-collapse: separate; border-spacing: 2px; margin: 6px 0; font-size: 14px; }
.troops thead th, .troops tbody td { border: 1px solid var(--line); border-radius: 4px; text-align: center; padding: 4px 6px; min-width: 54px; white-space: nowrap; }
.troops thead th { background: #ece7da; padding: 5px 6px 3px; color: #3b3326; font-size: 11px; font-weight: 600; }
.troops thead th.role-chief, .troops thead th.role-ram, .troops thead th.role-cata { color: #3b3326; }
.troops tbody td { background: var(--surface-2); color: var(--ink); font-weight: 600; vertical-align: top; }
.troops tbody td.zero { color: var(--muted); font-weight: 400; }
.troops tbody th { border: 0; background: none; text-align: left; color: var(--muted); font-weight: 500; padding: 4px 8px 4px 0; }
.troops td .sub { display: block; font-size: 12px; font-weight: 600; line-height: 1.25; }
.unit-sprite { display: block; width: 20px; height: 20px; margin: 0 auto; background-repeat: no-repeat; image-rendering: auto; transform: none; }
.unit-icon { width: 20px; height: 20px; display: block; margin: 0 auto; object-fit: contain; }
.troops--compact { border-spacing: 1px; }
.troops--compact thead th, .troops--compact tbody td { min-width: 40px; padding: 2px 4px; }
.troops thead th:first-child:empty { background: none; border: 0; min-width: 0; }
.troops tbody td.num { text-align: center !important; }
.summary__parties a strong { color: inherit; }
.summary__parties a:hover { text-decoration: underline; }
.site-footer { border-top: 1px solid var(--line); padding: 16px 0 24px; color: var(--muted); font-size: 13px; text-align: center; }
body { display: flex; flex-direction: column; min-height: 100vh; }
.site-main { flex: 1; }

/* Graphiques SVG */
.chart { width: 100%; height: auto; display: block; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius); font-family: inherit; }
.chart--empty { padding: 12px; }
.chart__title { font-size: 14px; font-weight: 700; fill: var(--ink); }
.chart__tick { font-size: 11px; fill: var(--muted); }
.chart__grid { stroke: var(--line); stroke-width: 1; stroke-dasharray: 2 3; }
.chart__axis { fill: none; stroke: var(--muted); stroke-width: 1; }
.chart__area { fill-opacity: .55; }
.chart__line { fill: none; stroke-width: 2; }
.chart__dot { fill: var(--ink); }
.charts { display: grid; grid-template-columns: 1fr; gap: 14px; }
.chest-icon { width: 18px; height: 18px; vertical-align: -4px; }
.chart--compact { max-width: 520px; }
