/* farm.css — Vertical Farm Simulator (mêmes couleurs et polices que le tableau de bord d'Arthur et le Startup Lab) */
:root {
  --bg: #f6f5f2; --card: #ffffff; --ink: #1d1d1f; --muted: #6e6e73; --faint: #a1a1a6; --line: #e7e5e0; --line2: #efede8;
  --accent: #2f5bea; --accent-soft: #e8eefd; --warn: #c2410c; --warn-soft: #fff1e8; --ok: #15803d; --ok-soft: #e7f6ec; --bad: #b91c1c;
  --canvas: #e9e7e1; --mono: 'JetBrains Mono', ui-monospace, Menlo, monospace;
  --radius: 10px; --shadow: 0 1px 2px rgba(0,0,0,.04), 0 4px 16px rgba(0,0,0,.04);
  --c-led: #d97706; --c-hvac: #0284c7; --c-shuttle: #f59e0b; --c-lift: #0891b2; --c-station: #16a34a; --c-pump: #0d9488; --c-other: #6b7280;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #16171a; --card: #1f2024; --ink: #ececee; --muted: #9a9aa2; --faint: #6b6b73; --line: #2e2f35; --line2: #27282d;
    --accent: #7c9bff; --accent-soft: #252c44; --warn: #fb923c; --warn-soft: #3a2a1f; --ok: #4ade80; --ok-soft: #17301f; --bad: #f87171; --shadow: none; --canvas: #1b1c21;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--ink); font: 13.5px/1.45 Inter, system-ui, sans-serif; -webkit-font-smoothing: antialiased; overflow: hidden; }
.hidden { display: none !important; }
a { color: var(--accent); text-decoration: none; }
input, select, textarea, button { font: inherit; color: inherit; }
input, select, textarea { background: var(--card); border: 1px solid var(--line); border-radius: 7px; padding: 5px 8px; outline: none; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
input[type=number] { font-family: var(--mono); font-size: 12.5px; text-align: right; }
.btn { border: 1px solid var(--line); background: var(--card); border-radius: 7px; padding: 6px 11px; cursor: pointer; font-weight: 500; white-space: nowrap; }
.btn:hover { border-color: var(--faint); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.05); }
.btn.danger, .menu a.danger { color: var(--bad); }
.btn.sm { padding: 4px 9px; font-size: 12.5px; }
.btn:disabled { opacity: .5; cursor: default; }
.icon-btn { width: 30px; height: 30px; border: 1px solid var(--line); background: var(--card); border-radius: 7px; cursor: pointer; font-size: 15px; display: grid; place-items: center; }
.link-btn { border: 0; background: none; color: var(--accent); cursor: pointer; padding: 2px 4px; font-size: 12.5px; }
.muted { color: var(--muted); } .small { font-size: 12px; } .mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.nolog, .loading { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.loading { position: fixed; inset: 0; z-index: 50; background: var(--bg); color: var(--muted); gap: 8px; grid-auto-flow: row; align-content: center; justify-items: center; }
.spin { width: 28px; height: 28px; border: 3px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.nolog-card { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 32px; max-width: 380px; text-align: center; box-shadow: var(--shadow); }
.nolog-card h1 { font-family: Fraunces, Georgia, serif; font-weight: 600; margin: 8px 0; }
.mark { font-size: 32px; }

/* ---------- structure ---------- */
.app { display: grid; grid-template-rows: auto 1fr auto; height: 100vh; }
.bar { display: flex; align-items: center; gap: 12px; padding: 7px 14px; background: var(--card); border-bottom: 1px solid var(--line); z-index: 20; }
.back { color: var(--muted); font-size: 18px; padding: 2px 6px; border-radius: 6px; }
.back:hover { background: var(--line2); color: var(--ink); }
.brand { font-family: Fraunces, Georgia, serif; font-weight: 600; font-size: 18px; display: flex; align-items: center; gap: 8px; }
.brand-mark { font-size: 16px; }
.sep { width: 1px; height: 22px; background: var(--line); }
.scen { display: flex; align-items: center; gap: 6px; }
.scen select { max-width: 220px; }
.scen input { width: 200px; }
.bar-right { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.menu-wrap { position: relative; }
.menu { position: absolute; right: 0; top: 36px; background: var(--card); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 10px 30px rgba(0,0,0,.14); padding: 6px; min-width: 230px; z-index: 40; }
.menu a, .menu label { display: block; padding: 7px 10px; border-radius: 6px; color: var(--ink); cursor: pointer; font-size: 13px; }
.menu a:hover, .menu label:hover { background: var(--line2); }
.menu hr { border: 0; border-top: 1px solid var(--line); margin: 4px 0; }

.work { display: grid; grid-template-columns: 250px 1fr 320px; min-height: 0; }
.side { background: var(--card); display: flex; flex-direction: column; min-height: 0; overflow: hidden; }
.side.left { border-right: 1px solid var(--line); }
.side.right { border-left: 1px solid var(--line); }
.panel { padding: 10px 12px; border-bottom: 1px solid var(--line); overflow: auto; }
.panel.grow { flex: 1; }
.panel-h, .dash-h { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; gap: 8px; }
.panel h3, .props h3 { margin: 0; font-size: 11.5px; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); font-weight: 600; }

/* catalogue */
.cat-g { margin-bottom: 8px; }
.cat-g h4 { margin: 4px 0 3px; font-size: 11.5px; color: var(--faint); font-weight: 600; }
.cat-item { display: flex; align-items: center; gap: 8px; padding: 5px 7px; border-radius: 7px; cursor: pointer; border: 1px solid transparent; }
.cat-item:hover { background: var(--line2); }
.cat-item .sw { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.cat-item .ic { width: 20px; text-align: center; }
.cat-item .nm { flex: 1; }
.cat-item .role { font-size: 10.5px; color: var(--faint); }

/* implantation */
.obj { display: flex; align-items: center; gap: 7px; padding: 4px 6px; border-radius: 7px; cursor: pointer; }
.obj:hover { background: var(--line2); }
.obj.on { background: var(--accent-soft); }
.obj .sw { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.obj .nm { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.obj .eye { border: 0; background: none; cursor: pointer; opacity: .6; font-size: 13px; padding: 0 2px; }
.obj .eye.off { opacity: .25; }
.obj.hid .nm { color: var(--faint); }

/* centre */
.center { display: grid; grid-template-rows: auto 1fr auto; min-height: 0; background: var(--canvas); }
.toolbar, .simbar { display: flex; align-items: center; gap: 8px; padding: 6px 10px; background: var(--card); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.simbar { border-bottom: 0; border-top: 1px solid var(--line); }
.sp { flex: 1; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 7px; overflow: hidden; background: var(--card); }
.seg button { border: 0; background: none; padding: 4px 9px; cursor: pointer; font-size: 12.5px; color: var(--muted); border-right: 1px solid var(--line); }
.seg button:last-child { border-right: 0; }
.seg button.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.seg.toggles { gap: 0; }
.seg.toggles label { padding: 4px 8px; font-size: 12.5px; color: var(--muted); display: flex; gap: 4px; align-items: center; border-right: 1px solid var(--line); cursor: pointer; }
.seg.toggles label:last-child { border-right: 0; }
.viewport { position: relative; min-height: 200px; overflow: hidden; }
.viewport canvas { display: block; }
.clock { font-family: var(--mono); font-weight: 500; font-size: 13px; padding: 3px 8px; background: var(--line2); border-radius: 6px; min-width: 110px; text-align: center; }
.lbl { font: 11px/1.2 var(--mono); color: var(--ink); background: color-mix(in srgb, var(--card) 85%, transparent); padding: 2px 5px; border-radius: 4px; border: 1px solid var(--line); white-space: nowrap; }
.lbl.name { font-family: Inter, system-ui, sans-serif; font-weight: 500; }
.lbl.dim.sel { color: #b45309; border-color: #f59e0b; }

/* propriétés */
.tabs2 { display: flex; gap: 2px; padding: 8px 10px 0; border-bottom: 1px solid var(--line); }
.tabs2 button { border: 0; background: none; padding: 6px 10px; cursor: pointer; color: var(--muted); font-weight: 500; border-bottom: 2px solid transparent; margin-bottom: -1px; font-size: 13px; }
.tabs2 button.on { color: var(--ink); border-bottom-color: var(--accent); }
.tabpane { padding: 10px 12px; overflow: auto; flex: 1; }
.props h2 { margin: 0 0 2px; font-family: Fraunces, Georgia, serif; font-weight: 600; font-size: 17px; }
.props .type { color: var(--muted); font-size: 12px; margin-bottom: 8px; }
.props h3 { margin: 12px 0 6px; }
.field { display: grid; grid-template-columns: 1fr 96px; align-items: center; gap: 8px; padding: 3px 0; }
.field label { font-size: 12.5px; color: var(--ink); }
.field label small { display: block; color: var(--faint); font-size: 11px; }
.field .unit { display: flex; align-items: center; gap: 4px; }
.field .unit input, .field .unit select { width: 100%; min-width: 0; }
.field .unit span { font-size: 11px; color: var(--faint); min-width: 26px; }
.field.ro .val { font-family: var(--mono); font-size: 12.5px; text-align: right; }
.xyz { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.xyz label { font-size: 11px; color: var(--faint); display: block; }
.xyz input { width: 100%; }
.props .actions { display: flex; gap: 6px; margin-top: 12px; flex-wrap: wrap; }
.note { background: var(--line2); border-radius: 8px; padding: 8px 10px; font-size: 12px; color: var(--muted); margin: 8px 0; }
.note.warn { background: var(--warn-soft); color: var(--warn); }
.props .empty { color: var(--muted); padding: 20px 0; text-align: center; }
.props .kv { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; font-size: 12.5px; }
.props .kv b { font-family: var(--mono); font-weight: 500; }
.badge { display: inline-block; font-size: 10.5px; padding: 1px 6px; border-radius: 99px; background: var(--line2); color: var(--muted); }
.badge.active { background: var(--ok-soft); color: var(--ok); }
.events { font-family: var(--mono); font-size: 11.5px; }
.events div { padding: 2px 0; border-bottom: 1px solid var(--line2); display: grid; grid-template-columns: 90px 1fr; gap: 8px; }
.events .t { color: var(--faint); }

/* tableau de bord */
.dash { background: var(--card); border-top: 1px solid var(--line); height: 290px; display: flex; flex-direction: column; }
.dash.min { height: auto; }
.dash.min .dash-body { display: none; }
.dash-h { padding: 0 12px; margin: 0; border-bottom: 1px solid var(--line); }
.dash-h .tabs2 { border: 0; padding: 4px 0 0; }
.dash-body { flex: 1; overflow: auto; padding: 10px 12px; display: grid; grid-template-columns: 300px 1fr; gap: 12px; }
.kpis { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; align-content: start; }
.kpi { background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; }
.kpi .n { font-family: var(--mono); font-size: 16px; font-weight: 500; line-height: 1.15; }
.kpi .l { color: var(--muted); font-size: 10.5px; margin-top: 1px; }
.kpi.warn .n { color: var(--warn); }
.charts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; min-width: 0; }
.chart { background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; min-width: 0; }
.chart h4 { margin: 0 0 2px; font-size: 11px; color: var(--muted); font-weight: 600; display: flex; justify-content: space-between; }
.chart canvas { width: 100%; height: 150px; display: block; }
.bars { display: grid; gap: 4px; align-content: start; }
.bar-row { display: grid; grid-template-columns: 150px 1fr 90px; gap: 8px; align-items: center; font-size: 12px; }
.bar-row .meter { height: 8px; background: var(--line2); border-radius: 4px; overflow: hidden; }
.bar-row .meter i { display: block; height: 100%; background: var(--accent); }
.bar-row b { font-family: var(--mono); font-weight: 500; text-align: right; }
.tbl { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.tbl th, .tbl td { text-align: left; padding: 4px 8px; border-bottom: 1px solid var(--line); }
.tbl td.n, .tbl th.n { text-align: right; font-family: var(--mono); }
.tbl tr.tot td { font-weight: 600; border-top: 2px solid var(--line); }
.econ-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }
.bn { display: grid; gap: 6px; align-content: start; }
.bn .item { display: grid; grid-template-columns: 1fr auto; gap: 8px; padding: 6px 10px; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; font-size: 12.5px; }
.bn .item b { font-family: var(--mono); font-weight: 500; }
.bn .item.top { border-color: var(--warn); }

/* dialogue, toast */
dialog { border: 1px solid var(--line); border-radius: 14px; padding: 0; background: var(--card); color: var(--ink); max-width: min(720px, 92vw); box-shadow: 0 20px 60px rgba(0,0,0,.25); }
dialog::backdrop { background: rgba(0,0,0,.35); }
dialog form { padding: 18px 20px; }
dialog h3 { margin: 0 0 10px; font-family: Fraunces, Georgia, serif; font-weight: 600; font-size: 18px; }
.dlg-actions { display: flex; gap: 8px; margin-top: 14px; }
.grow { flex: 1; }
#dlgBody label { display: block; margin: 8px 0 4px; font-size: 12.5px; color: var(--muted); }
#dlgBody input[type=text], #dlgBody select, #dlgBody textarea { width: 100%; }
.about { font-size: 13px; line-height: 1.5; max-height: 60vh; overflow: auto; }
.about h4 { margin: 12px 0 4px; }
.about ul { margin: 4px 0; padding-left: 18px; }
.cmp { font-size: 12.5px; }
.cmp td.better { color: var(--ok); font-weight: 600; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(20px); background: var(--ink); color: var(--bg); padding: 8px 14px; border-radius: 10px; font-size: 13px; opacity: 0; pointer-events: none; transition: .2s; z-index: 60; }
.toast.show { opacity: 1; transform: translateX(-50%); }

@media (max-width: 1100px) {
  .work { grid-template-columns: 220px 1fr 280px; }
  .charts { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  body { overflow: auto; }
  .app { height: auto; min-height: 100vh; }
  .work { grid-template-columns: 1fr; }
  .side { max-height: 300px; }
  .center { min-height: 60vh; }
  .dash-body { grid-template-columns: 1fr; }
  .scen input { width: 120px; }
}
