:root {
  --azur: #1e9ddb;
  --azur-deep: #0b7cb8;
  --azur-pale: #e6f5fc;
  --ink: #0b2540;
  --ink-soft: #4a6178;
  --bg: #f3f7fa;
  --paper: #ffffff;
  --line: #dce6ed;
  --ok: #1f9e6b;
  --ok-bg: #e6f6ef;
  --warn: #d97b1f;
  --warn-bg: #fdf1e1;
  --bad: #d64545;
  --bad-bg: #fce9e9;
  --font-display: 'Sora', 'Segoe UI', sans-serif;
  --font-body: 'Inter', 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, monospace;
  --radius: 10px;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: var(--font-body); background: var(--bg); color: var(--ink); font-size: 14px; }
a { color: var(--azur-deep); }
button { font-family: inherit; }

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

/* ---- Sidebar ---- */
.sidebar {
  width: 232px; background: var(--ink); color: #dcebf5; flex-shrink: 0;
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 22px 20px 18px; border-bottom: 1px solid rgba(255,255,255,.08); }
.brand-mark { width: 34px; height: 34px; border-radius: 9px; background: linear-gradient(135deg, var(--azur), #6fd1f5); position: relative; flex-shrink: 0; box-shadow: 0 2px 8px rgba(30,157,219,.5); }
.brand-mark::after { content: ""; position: absolute; inset: 8px; border: 2px solid rgba(255,255,255,.85); border-radius: 4px; border-bottom: none; border-right: none; transform: rotate(-45deg); }
.brand-text { font-family: var(--font-display); font-weight: 700; font-size: 15.5px; line-height: 1.2; }
.brand-sub { font-size: 10.5px; color: #7fa9c2; letter-spacing: .6px; text-transform: uppercase; margin-top: 1px; }
.nav { flex: 1; padding: 12px 10px; display: flex; flex-direction: column; gap: 2px; overflow-y: auto; }
.nav-label { font-size: 10px; text-transform: uppercase; letter-spacing: 1px; color: #5c7e97; padding: 14px 10px 6px; }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 8px; color: #b9d3e4; text-decoration: none; cursor: pointer; font-size: 13.5px; font-weight: 500; border: 0; background: none; width: 100%; text-align: left; }
.nav-item:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav-item.active { background: var(--azur); color: #fff; box-shadow: 0 2px 10px rgba(30,157,219,.35); }
.nav-item .ico { width: 18px; text-align: center; opacity: .9; }
.sidefoot { padding: 14px 16px; border-top: 1px solid rgba(255,255,255,.08); display: flex; align-items: center; gap: 10px; }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--azur-pale); color: var(--azur-deep); display: flex; align-items: center; justify-content: center; font-weight: 600; font-size: 12px; }
.foot-name { font-size: 12.5px; font-weight: 600; color: #e7f2f9; }
.foot-role { font-size: 10.5px; color: #6e92ab; }
.sidefoot button { margin-left: auto; background: none; border: 0; color: #7fa9c2; cursor: pointer; font-size: 16px; }

/* ---- Main ---- */
.main { flex: 1; padding: 26px 30px 60px; max-width: 1280px; }
.page-title { font-family: var(--font-display); font-weight: 700; font-size: 22px; }
.page-desc { font-size: 13px; color: var(--ink-soft); margin: 4px 0 20px; }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.spread { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }

.card { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.card + .card { margin-top: 16px; }
.card-title { font-family: var(--font-display); font-weight: 600; font-size: 15px; margin-bottom: 12px; }
.grid { display: grid; gap: 16px; }
.grid.k4 { grid-template-columns: repeat(4, 1fr); }
.grid.k3 { grid-template-columns: repeat(3, 1fr); }
.grid.k2 { grid-template-columns: repeat(2, 1fr); }
@media (max-width: 1100px) { .grid.k4 { grid-template-columns: repeat(2, 1fr); } .grid.k3 { grid-template-columns: 1fr 1fr; } }
@media (max-width: 720px) { .grid.k4, .grid.k3, .grid.k2 { grid-template-columns: 1fr; } .sidebar { width: 60px; } .brand-text, .brand-sub, .nav-label, .foot-name, .foot-role, .nav-item span:not(.ico) { display: none; } }

/* ---- KPI ---- */
.kpi { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.kpi-top { display: flex; justify-content: space-between; align-items: center; }
.kpi-label { font-size: 12px; color: var(--ink-soft); font-weight: 500; }
.kpi-val { font-family: var(--font-display); font-weight: 700; font-size: 24px; margin-top: 6px; }
.kpi-sub { font-size: 11.5px; color: var(--ink-soft); margin-top: 3px; }
.kpi-badge { font-size: 11px; font-weight: 600; padding: 2px 7px; border-radius: 20px; }
.kpi-badge.up { color: var(--ok); background: var(--ok-bg); }
.kpi-badge.down { color: var(--bad); background: var(--bad-bg); }

/* ---- Tables ---- */
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .4px; color: var(--ink-soft); font-weight: 600; padding: 8px 10px; border-bottom: 1px solid var(--line); }
td { padding: 9px 10px; border-bottom: 1px solid var(--line); font-size: 13px; vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #f8fbfc; }
.mono { font-family: var(--font-mono); font-size: 12.5px; }
.num { text-align: right; font-family: var(--font-mono); font-size: 12.5px; white-space: nowrap; }
.table-wrap { overflow-x: auto; }
.muted { color: var(--ink-soft); }
.right { text-align: right; }

/* ---- Pills / tags ---- */
.pill { display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; font-weight: 600; padding: 2px 9px; border-radius: 20px; }
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill.ok { color: var(--ok); background: var(--ok-bg); }
.pill.warn { color: var(--warn); background: var(--warn-bg); }
.pill.bad { color: var(--bad); background: var(--bad-bg); }
.pill.neutral { color: var(--ink-soft); background: #eef2f5; }
.pill.info { color: var(--azur-deep); background: var(--azur-pale); }
.tag { display: inline-block; font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 6px; background: var(--azur-pale); color: var(--azur-deep); }

/* ---- Buttons / inputs ---- */
.btn { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; padding: 9px 14px; border-radius: 8px; border: 1px solid var(--line); background: var(--paper); color: var(--ink); cursor: pointer; }
.btn:hover { border-color: var(--azur); }
.btn.primary { background: var(--azur); color: #fff; border-color: var(--azur); }
.btn.primary:hover { background: var(--azur-deep); }
.btn.ghost { border-color: transparent; background: transparent; color: var(--ink-soft); }
.btn.danger { color: var(--bad); border-color: var(--bad-bg); }
.btn.sm { padding: 5px 9px; font-size: 12px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
input, select, textarea { font-family: inherit; font-size: 13px; padding: 9px 11px; border: 1px solid var(--line); border-radius: 8px; background: var(--paper); color: var(--ink); width: 100%; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--azur-pale); border-color: var(--azur); }
label { font-size: 12px; font-weight: 600; color: var(--ink-soft); display: block; margin-bottom: 5px; }
.field { margin-bottom: 14px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.toolbar .search { flex: 1; min-width: 180px; max-width: 320px; }
.pager { display: flex; gap: 8px; align-items: center; justify-content: flex-end; margin-top: 12px; font-size: 12.5px; color: var(--ink-soft); }

/* ---- Modal ---- */
.overlay { position: fixed; inset: 0; background: rgba(11,37,64,.42); display: flex; align-items: flex-start; justify-content: center; padding: 40px 16px; z-index: 1000; overflow-y: auto; }
.modal { background: var(--paper); border-radius: 14px; width: 100%; max-width: 560px; box-shadow: 0 20px 60px rgba(11,37,64,.25); }
.modal.lg { max-width: 860px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 18px 20px; border-bottom: 1px solid var(--line); }
.modal-head h3 { font-family: var(--font-display); font-size: 16px; }
.modal-body { padding: 20px; }
.modal-foot { padding: 14px 20px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 10px; }
.modal-head button.x { background: none; border: 0; font-size: 20px; cursor: pointer; color: var(--ink-soft); line-height: 1; }

/* ---- Toast ---- */
#toasts { position: fixed; bottom: 20px; right: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 2000; }
.toast { background: var(--ink); color: #fff; padding: 11px 16px; border-radius: 9px; font-size: 13px; box-shadow: 0 8px 24px rgba(11,37,64,.3); max-width: 340px; }
.toast.err { background: var(--bad); }
.toast.ok { background: var(--ok); }

/* ---- Login ---- */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(160deg, #0b2540, #0b7cb8); }
.login-card { background: var(--paper); border-radius: 16px; padding: 34px; width: 360px; box-shadow: 0 24px 70px rgba(0,0,0,.3); }
.login-card h1 { font-family: var(--font-display); font-size: 20px; margin-bottom: 4px; }
.login-card p { font-size: 12.5px; color: var(--ink-soft); margin-bottom: 22px; }

/* ---- Planning grid ---- */
.pg { display: grid; grid-template-columns: 150px repeat(7, 1fr); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: var(--paper); }
.pg-cell { border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: 6px; min-height: 60px; font-size: 11px; }
.pg-head { background: #f8fbfc; font-weight: 600; text-align: center; text-transform: uppercase; letter-spacing: .3px; color: var(--ink-soft); font-size: 11px; padding: 9px 4px; }
.pg-head.today { color: var(--azur-deep); background: var(--azur-pale); }
.pg-emp { display: flex; align-items: center; gap: 7px; font-weight: 600; font-size: 12px; }
.pg-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.shift { border-left: 3px solid var(--azur); border-radius: 5px; padding: 4px 6px; font-size: 10.5px; margin-bottom: 4px; font-weight: 600; line-height: 1.3; cursor: pointer; }
.shift small { display: block; font-weight: 400; color: var(--ink-soft); }
.shift.realise { opacity: .7; }
.shift.annule { text-decoration: line-through; opacity: .5; }

/* ---- Map ---- */
#map { height: 560px; border-radius: var(--radius); border: 1px solid var(--line); }
.leaflet-marker-pin { display: flex; align-items: center; justify-content: center; font-weight: 700; color: #fff; font-size: 11px; border-radius: 50% 50% 50% 0; transform: rotate(-45deg); border: 2px solid #fff; box-shadow: 0 2px 6px rgba(0,0,0,.3); }
.leaflet-marker-pin span { transform: rotate(45deg); }

/* ---- Bars (compta) ---- */
.bars { display: flex; align-items: flex-end; gap: 14px; height: 200px; padding-top: 10px; }
.bar-group { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; height: 100%; justify-content: flex-end; }
.bar-pair { display: flex; gap: 3px; align-items: flex-end; height: 100%; width: 100%; justify-content: center; }
.bar { width: 26px; border-radius: 4px 4px 0 0; min-height: 2px; }
.bar.fact { background: var(--azur); }
.bar.cost { background: #f0b27a; }
.bar-lbl { font-size: 10.5px; color: var(--ink-soft); }
.legend { display: flex; gap: 16px; font-size: 11.5px; color: var(--ink-soft); margin-top: 10px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; }

.tabs { display: flex; gap: 6px; border-bottom: 1px solid var(--line); margin-bottom: 16px; flex-wrap: wrap; }
.tabs button { border: 0; background: none; padding: 9px 14px; font-size: 13px; font-weight: 600; color: var(--ink-soft); cursor: pointer; border-bottom: 2px solid transparent; }
.tabs button.active { color: var(--azur-deep); border-bottom-color: var(--azur); }
.empty { text-align: center; color: var(--ink-soft); padding: 40px; font-size: 13px; }
.spin { text-align: center; padding: 40px; color: var(--ink-soft); }
