/* ==========================================================================
   Installateurs Bornes — design minimaliste premium
   Papier clair, encre graphite, accent pin profond. Hairlines plutôt qu'ombres.
   Navigation horizontale fine. Identifiants en style tabulaire pour la précision.
   ========================================================================== */
:root {
	--ib-bg: #F7F8F6;
	--ib-surface: #FFFFFF;
	--ib-ink: #1A1D1F;
	--ib-muted: #767D80;
	--ib-faint: #9CA2A4;
	--ib-line: #E4E6E3;
	--ib-accent: #1F4B43;
	--ib-accent-soft: #E8EFEC;
	--ib-warn: #B8863B;
	--ib-warn-soft: #F6EFE1;
	--ib-danger: #B3454A;
	--ib-danger-soft: #F7E9E9;
	--ib-radius: 3px;
	--ib-font-display: 'Sora', -apple-system, sans-serif;
	--ib-font-body: 'Manrope', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
	--ib-font-mono: 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
	margin: 0;
	font-family: var(--ib-font-body);
	background: var(--ib-bg);
	color: var(--ib-ink);
	-webkit-font-smoothing: antialiased;
	font-size: 14px;
	line-height: 1.5;
}
a { color: inherit; text-decoration: none; }
h1, h2, h3 { font-family: var(--ib-font-display); font-weight: 600; letter-spacing: -.01em; margin: 0; }
:focus-visible { outline: 2px solid var(--ib-accent); outline-offset: 2px; }

.ib-app { display: flex; flex-direction: column; min-height: 100vh; }

/* ---------- Navigation horizontale ---------- */
.ib-topnav {
	background: var(--ib-surface);
	border-bottom: 1px solid var(--ib-line);
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 0 28px;
	height: 60px;
	flex-shrink: 0;
	gap: 24px;
}
.ib-brand { display: flex; align-items: center; gap: 9px; font-family: var(--ib-font-display); font-weight: 700; font-size: 15px; white-space: nowrap; }
.ib-brand-mark { width: 7px; height: 7px; border-radius: 1px; background: var(--ib-accent); flex-shrink: 0; }
.ib-brand span { color: var(--ib-muted); font-weight: 500; }

.ib-nav { display: flex; gap: 2px; flex: 1; overflow-x: auto; }
.ib-nav a {
	color: var(--ib-muted);
	padding: 0 14px;
	height: 60px;
	display: flex;
	align-items: center;
	font-size: 13px;
	font-weight: 600;
	white-space: nowrap;
	border-bottom: 2px solid transparent;
}
.ib-nav a:hover { color: var(--ib-ink); }
.ib-nav a.active { color: var(--ib-ink); border-bottom-color: var(--ib-accent); }

.ib-nav-right { display: flex; align-items: center; gap: 16px; flex-shrink: 0; }
.ib-user-chip { display: flex; flex-direction: column; align-items: flex-end; line-height: 1.25; }
.ib-user-chip strong { font-size: 13px; font-weight: 600; }
.ib-user-chip span { font-size: 10.5px; color: var(--ib-muted); text-transform: uppercase; letter-spacing: .05em; }
.ib-logout { font-size: 12px; color: var(--ib-muted); border: 1px solid var(--ib-line); border-radius: var(--ib-radius); padding: 6px 12px; }
.ib-logout:hover { color: var(--ib-ink); border-color: var(--ib-ink); }

/* ---------- Main ---------- */
.ib-main { flex: 1; padding: 36px 28px 60px; max-width: 1180px; width: 100%; margin: 0 auto; }
.ib-topbar { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 28px; flex-wrap: wrap; gap: 12px; }
.ib-topbar h1 { font-size: 21px; }

.ib-btn {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	padding: 8px 15px;
	border-radius: var(--ib-radius);
	border: 1px solid var(--ib-line);
	background: var(--ib-surface);
	color: var(--ib-ink);
	font-size: 13px;
	font-weight: 600;
	font-family: var(--ib-font-body);
	cursor: pointer;
}
.ib-btn:hover { border-color: var(--ib-ink); }
.ib-btn-primary { background: var(--ib-accent); border-color: var(--ib-accent); color: #fff; }
.ib-btn-primary:hover { background: #163933; border-color: #163933; }
.ib-btn-small { padding: 5px 10px; font-size: 12px; }
.ib-btn-danger { color: var(--ib-danger); border-color: #e6cdcd; }
.ib-btn-danger:hover { border-color: var(--ib-danger); }
.ib-btn-block { width: 100%; justify-content: center; margin-top: 6px; }

/* Flash + Toast */
.ib-flash { padding: 10px 14px; border-radius: var(--ib-radius); margin-bottom: 16px; font-size: 13px; border: 1px solid transparent; }
.ib-flash-success { background: var(--ib-accent-soft); color: var(--ib-accent); border-color: #d4e2dd; }
.ib-flash-error { background: var(--ib-danger-soft); color: var(--ib-danger); border-color: #ecd5d5; }
.ib-toast {
	position: fixed; top: 18px; left: 50%; transform: translateX(-50%);
	z-index: 9999; padding: 11px 20px; border-radius: var(--ib-radius); font-size: 13px; font-weight: 600;
	box-shadow: 0 10px 30px rgba(20,22,20,.14); opacity: 1; transition: opacity .35s ease;
	border: 1px solid var(--ib-line);
}
.ib-toast-hide { opacity: 0; }
.ib-toast.ib-flash-success { background: var(--ib-ink); color: #fff; border-color: var(--ib-ink); }
.ib-toast.ib-flash-error { background: var(--ib-danger); color: #fff; border-color: var(--ib-danger); }

/* KPI cards */
.ib-kpi-row { display: flex; gap: 0; flex-wrap: wrap; margin-bottom: 28px; border: 1px solid var(--ib-line); border-radius: var(--ib-radius); overflow: hidden; }
.ib-kpi-card { flex: 1; min-width: 130px; padding: 16px 20px; border-right: 1px solid var(--ib-line); background: var(--ib-surface); }
.ib-kpi-card:last-child { border-right: none; }
.ib-kpi-value { font-family: var(--ib-font-mono); font-size: 25px; font-weight: 600; display: block; font-variant-numeric: tabular-nums; }
.ib-kpi-label { font-size: 11.5px; color: var(--ib-muted); text-transform: uppercase; letter-spacing: .04em; }

/* Charts */
.ib-chart-row { display: flex; gap: 20px; flex-wrap: wrap; margin-bottom: 28px; }
.ib-chart-card { flex: 1; min-width: 300px; max-width: 520px; background: var(--ib-surface); border: 1px solid var(--ib-line); border-radius: var(--ib-radius); padding: 18px; }

/* Settings */
.ib-settings-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; max-width: 1000px; }
.ib-settings-card { background: var(--ib-surface); border: 1px solid var(--ib-line); border-radius: var(--ib-radius); padding: 18px; }
.ib-settings-card h2 { margin: 0 0 12px; font-size: 14px; }
.ib-list-items { list-style: none; margin: 0 0 14px; padding: 0; display: flex; flex-direction: column; gap: 1px; border: 1px solid var(--ib-line); border-radius: var(--ib-radius); overflow: hidden; }
.ib-list-items li { display: flex; align-items: center; justify-content: space-between; background: var(--ib-surface); padding: 8px 12px; font-size: 13px; border-bottom: 1px solid var(--ib-line); }
.ib-list-items li:last-child { border-bottom: none; }
.ib-list-items li form { margin: 0; }
.ib-list-empty { color: var(--ib-faint); border-bottom: none !important; }
.ib-add-item-form { display: flex; gap: 8px; }
.ib-add-item-form input[type=text] { flex: 1; padding: 7px 10px; border-radius: var(--ib-radius); border: 1px solid var(--ib-line); font-size: 13px; font-family: var(--ib-font-body); }

/* Filtres */
.ib-filters { margin-bottom: 18px; }
.ib-filters-row { display: flex; gap: 14px; flex-wrap: wrap; align-items: flex-end; }
.ib-filter-group { display: flex; flex-direction: column; gap: 4px; }
.ib-filter-group label { font-size: 10.5px; font-weight: 700; color: var(--ib-muted); text-transform: uppercase; letter-spacing: .04em; }
.ib-filter-group select, .ib-filter-group input { padding: 7px 10px; border-radius: var(--ib-radius); border: 1px solid var(--ib-line); font-size: 13px; font-family: var(--ib-font-body); background: var(--ib-surface); }

/* Sheet (tableau) */
.ib-section-title { font-family: var(--ib-font-display); font-size: 12px; font-weight: 700; color: var(--ib-muted); margin: 24px 0 12px; text-transform: uppercase; letter-spacing: .06em; }
.ib-sheet-toolbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; flex-wrap: wrap; gap: 10px; }
.ib-sheet-toolbar-right { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.ib-sheet-search { padding: 8px 12px; border-radius: var(--ib-radius); border: 1px solid var(--ib-line); width: 300px; font-size: 13px; font-family: var(--ib-font-body); background: var(--ib-surface); }
.ib-sheet-count { font-size: 12px; color: var(--ib-muted); font-variant-numeric: tabular-nums; }

.ib-sheet-wrap { background: var(--ib-surface); border-radius: var(--ib-radius); border: 1px solid var(--ib-line); overflow: auto; }
table.ib-sheet { width: 100%; border-collapse: collapse; font-size: 13px; }
table.ib-sheet thead th {
	position: sticky; top: 0;
	background: var(--ib-surface);
	text-align: left;
	padding: 11px 16px;
	font-weight: 700;
	font-family: var(--ib-font-body);
	color: var(--ib-muted);
	white-space: nowrap;
	cursor: pointer;
	user-select: none;
	font-size: 10.5px;
	letter-spacing: .05em;
	text-transform: uppercase;
	border-bottom: 1px solid var(--ib-line);
}
table.ib-sheet thead th:hover { color: var(--ib-ink); }
table.ib-sheet thead th.sorted-asc::after { content: " ↑"; color: var(--ib-accent); }
table.ib-sheet thead th.sorted-desc::after { content: " ↓"; color: var(--ib-accent); }
table.ib-sheet tbody td {
	padding: 11px 16px;
	border-bottom: 1px solid var(--ib-line);
	white-space: nowrap;
}
table.ib-sheet tbody tr:last-child td { border-bottom: none; }
table.ib-sheet tbody tr:hover { background: var(--ib-bg); }
.ib-sheet-empty { text-align: center; color: var(--ib-faint); padding: 40px !important; }
.ib-id-link { font-family: var(--ib-font-mono); color: var(--ib-ink); font-weight: 600; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.ib-id-link:hover { color: var(--ib-accent); }

/* Badges (états) — pastille + libellé, esprit "statut" discret */
.ib-badge { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; color: var(--ib-ink); }
.ib-badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0; background: var(--ib-faint); }
.ib-badge-en_cours::before { background: var(--ib-warn); }
.ib-badge-planifie::before { background: var(--ib-accent); }
.ib-badge-finalise::before { background: #3E7C6A; }
.ib-badge-none::before { background: var(--ib-faint); }

/* Forms */
.ib-form { background: var(--ib-surface); border: 1px solid var(--ib-line); border-radius: var(--ib-radius); padding: 26px; max-width: 700px; }
.ib-form label { display: block; font-size: 10.5px; font-weight: 700; color: var(--ib-muted); margin: 14px 0 6px; text-transform: uppercase; letter-spacing: .04em; }
.ib-form input[type=text], .ib-form input[type=email], .ib-form input[type=password],
.ib-form input[type=date], .ib-form input[type=number],
.ib-form select, .ib-form textarea {
	width: 100%; padding: 9px 11px; border-radius: var(--ib-radius); border: 1px solid var(--ib-line); font-size: 14px; font-family: var(--ib-font-body); background: var(--ib-surface); color: var(--ib-ink);
}
.ib-form input:focus, .ib-form select:focus, .ib-form textarea:focus { outline: none; border-color: var(--ib-accent); box-shadow: 0 0 0 3px var(--ib-accent-soft); }
.ib-form input:disabled, .ib-form select:disabled { background: var(--ib-bg); color: var(--ib-faint); }
.ib-form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.ib-form-actions { margin-top: 22px; display: flex; gap: 10px; border-top: 1px solid var(--ib-line); padding-top: 18px; }
.ib-form-hint { font-size: 12px; color: var(--ib-muted); margin-top: 16px; }

.ib-empty { color: var(--ib-faint); font-size: 14px; }

/* Login */
.ib-login-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: var(--ib-bg); }
.ib-login-box { background: var(--ib-surface); border: 1px solid var(--ib-line); border-radius: var(--ib-radius); padding: 34px 32px; width: 340px; position: relative; }
.ib-login-box::before { content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px; background: var(--ib-accent); border-radius: var(--ib-radius) var(--ib-radius) 0 0; }
.ib-login-brand { display: flex; align-items: center; justify-content: center; gap: 9px; font-family: var(--ib-font-display); font-weight: 700; font-size: 16px; margin-bottom: 4px; }
.ib-login-brand .ib-brand-mark { width: 8px; height: 8px; }
.ib-login-sub { text-align: center; font-size: 11.5px; color: var(--ib-muted); text-transform: uppercase; letter-spacing: .05em; margin-bottom: 22px; }
.ib-login-box label { display: block; font-size: 10.5px; font-weight: 700; margin: 12px 0 5px; text-transform: uppercase; letter-spacing: .04em; color: var(--ib-muted); }
.ib-login-box input { width: 100%; padding: 9px 11px; border-radius: var(--ib-radius); border: 1px solid var(--ib-line); font-size: 14px; font-family: var(--ib-font-body); }
.ib-login-box input:focus { outline: none; border-color: var(--ib-accent); box-shadow: 0 0 0 3px var(--ib-accent-soft); }

@media (max-width: 780px) {
	.ib-topnav { flex-wrap: wrap; height: auto; padding: 14px 20px; }
	.ib-nav { order: 3; width: 100%; }
	.ib-form-row { grid-template-columns: 1fr; }
	.ib-kpi-row { flex-direction: column; }
	.ib-kpi-card { border-right: none; border-bottom: 1px solid var(--ib-line); }
	.ib-kpi-card:last-child { border-bottom: none; }
}

@media (prefers-reduced-motion: reduce) {
	.ib-toast { transition: none; }
}
