* { box-sizing: border-box; }
body { margin: 0; font-family: "Segoe UI", system-ui, sans-serif; font-size: 14px; color: #1b1b1b; background: #f3f4f6; }
header { display: flex; align-items: center; gap: 16px; padding: 8px 16px; background: #1f3a5f; color: #fff; }
header h1 { font-size: 18px; margin: 0; flex: 1; }
header a, header button { color: #fff; }
button, select, input { font: inherit; padding: 5px 8px; }
button { cursor: pointer; }
header button { background: transparent; border: 1px solid #fff8; border-radius: 4px; }
.error { color: #b00020; min-height: 1.2em; }
.login-box { max-width: 320px; margin: 12vh auto; padding: 24px; background: #fff; border-radius: 8px; box-shadow: 0 2px 8px #0002; display: grid; gap: 10px; }
.login-box h1 { margin: 0 0 8px; font-size: 20px; }
main.layout { display: grid; grid-template-columns: 280px minmax(0, 1fr); gap: 12px; padding: 12px; height: calc(100vh - 48px); }
aside, section.chart-panel { background: #fff; border-radius: 6px; padding: 10px; box-shadow: 0 1px 4px #0002; min-height: 0; }
aside { display: flex; flex-direction: column; gap: 8px; }
aside select, aside input:not([type=checkbox]) { width: 100%; }
aside h2 { margin: 4px 0 0; font-size: 12px; text-transform: uppercase; color: #667; }
#points { overflow: auto; flex: 1; }
#points label { display: flex; align-items: center; gap: 6px; padding: 2px 0; word-break: break-all; }
#points input { width: auto; margin: 0; flex: none; }
section.chart-panel { display: flex; flex-direction: column; gap: 8px; }
.toolbar { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: flex-end; }
.group { display: flex; gap: 4px; align-items: center; flex-wrap: wrap; padding: 14px 8px 6px; border: 1px solid #d5d9e0; border-radius: 4px; position: relative; }
.group .gl { position: absolute; top: -8px; left: 8px; padding: 0 4px; background: #fff; font-size: 11px; color: #667; }
#chart { flex: 1 1 0; min-height: 0; overflow: hidden; }
table { border-collapse: collapse; }
th, td { border: 1px solid #ccc; padding: 3px 8px; text-align: right; }
th:first-child, td:first-child { text-align: left; }

.admin { max-width: 760px; margin: 16px auto; background: #fff; padding: 16px; border-radius: 6px; }
.admin form { display: flex; gap: 6px; flex-wrap: wrap; margin: 12px 0; }

header #user a { margin: 0 6px; }
.cards { display: flex; flex-wrap: wrap; gap: 14px; padding: 14px; }
.card { width: 260px; padding: 12px; border-radius: 4px; color: #1b1b1b; cursor: pointer; text-decoration: none; box-shadow: 0 1px 4px #0003; display: block; }
.card:hover { filter: brightness(1.05); box-shadow: 0 2px 8px #0005; }
.card.online { background: #5aa87a; }
.card.stale { background: #ffd23f; }
.card.offline { background: #4a7dea; }
.card h2 { margin: 0 0 10px; font-size: 15px; font-weight: 500; }
.card .row { display: flex; justify-content: space-between; gap: 8px; margin: 6px 0; }
.card .value { background: #f4f6ff; border: 1px solid #fff8; padding: 2px 8px; flex: 1; text-align: center; }
.toolbar button { min-width: 34px; }
.toolbar button.on { background: #cfe3ff; }
.num { width: 90px; }
.bottom { flex: none; max-height: 200px; overflow: auto; }
.bottom table { width: 100%; }
td.swatch { text-align: left; font-weight: 600; }
@media print {
  header, aside, .toolbar { display: none !important; }
  body { background: #fff; }
  main.layout { display: block; height: auto; padding: 0; }
  section.chart-panel { display: block; box-shadow: none; padding: 0; }
  #chart { display: none; }
  #chartPrint { display: block; width: 100%; max-height: 480px; object-fit: contain; margin-bottom: 12px; }
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .bottom { max-height: none; }
}
.bottom td input.num { width: 68px; padding: 3px 4px; }
.bottom td select { padding: 3px 2px; }
.bottom th, .bottom td { padding: 3px 5px; }
@media screen { #chartPrint { display: none; } }
#views { max-height: 140px; overflow: auto; border: 1px solid #d5d9e0; border-radius: 4px; }
#views:empty::before { content: "Aucune vue enregistrée"; display: block; padding: 6px; color: #889; font-size: 12px; }
#views .view { display: flex; align-items: center; gap: 4px; padding: 2px 4px; }
#views .view:hover { background: #eef3ff; }
#views .view .apply { flex: 1; text-align: left; border: 0; background: transparent; cursor: pointer; padding: 3px 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#views .view .del { border: 0; background: transparent; color: #b00020; cursor: pointer; }
#views .view .tool { color: #345; }
.save-view { display: flex; gap: 4px; }
.save-view input { flex: 1; min-width: 0; }
@media print { #views, .save-view { display: none; } }
