/* Rulix — editorial UI. Two schemes: Paper (light, default) and Noir (dark), toggled via
   data-theme="noir" on <html>. Bold masthead nav, flat cards, crisp corners, Bricolage display type. */
:root {
  --bg:#f3ede1; --ink:#191510; --muted:#6f665a; --line:#e0d8c6; --rule:#191510;
  --accent:#ff4a24; --accent-ink:#fffaf5; --panel:#fffdf8; --pill:#ece3d2;
  --ok:#0f7a4f; --warn:#c23b0e; --amber:#9a6b00; --r:4px;
  --sidebar:#191510; --sidebar-ink:#f3ede1; --sidebar-active:#2a231b;
  --disp:'Bricolage Grotesque','Manrope',system-ui,sans-serif;
}
:root[data-theme="noir"] {
  --bg:#161210; --ink:#f2ebdd; --muted:#a99f8e; --line:#2d2820; --rule:#f2ebdd;
  --accent:#ff5a34; --accent-ink:#180d08; --panel:#1e1913; --pill:#272219;
  --ok:#54cf92; --warn:#ff8258; --amber:#e0b053;
  --sidebar:#0f0c0a; --sidebar-ink:#f2ebdd; --sidebar-active:#272219;
}
* { box-sizing:border-box; } html,body { height:100%; }
body { margin:0; font:15px/1.55 'Manrope',system-ui,-apple-system,Segoe UI,Roboto,sans-serif; color:var(--ink); background:var(--bg); }
a { color:var(--accent); text-decoration:none; }
h1 { font-family:var(--disp); font-weight:800; font-size:2rem; letter-spacing:-.02em; line-height:1.02; margin:0 0 6px; }
h2 { font-size:.72rem; text-transform:uppercase; letter-spacing:.12em; color:var(--ink); font-weight:700; margin:0 0 12px; }
.muted { color:var(--muted); } .small { font-size:.85rem; } .warn { color:var(--warn); font-weight:600; }
#app.loading, #app.centered { display:flex; align-items:center; justify-content:center; min-height:100vh; }
.centered .wrap { width:min(92vw,440px); } .centered h1 { font-size:2.4rem; } .tag { color:var(--muted); margin:2px 0 20px; }
.btn { display:inline-block; background:var(--accent); color:var(--accent-ink); border:0; border-radius:var(--r); padding:11px 18px; font-size:.95rem; font-weight:700; cursor:pointer; }
footer { margin-top:18px; color:var(--muted); font-size:.8rem; }

/* ---- Masthead shell ---- */
.app-shell { min-height:100vh; display:flex; flex-direction:column; }
.masthead { display:flex; align-items:center; gap:26px; padding:16px 34px; border-bottom:2px solid var(--rule); background:var(--bg); position:sticky; top:0; z-index:20; }
.mh-mark { font-family:var(--disp); font-weight:800; font-size:1.5rem; letter-spacing:-.02em; display:flex; align-items:baseline; gap:2px; }
.mh-mark .dot { color:var(--accent); }
.mh-mark .mh-ver { margin-left:8px; font-family:'Manrope'; font-size:.62rem; font-weight:700; letter-spacing:.06em; color:var(--muted); }
.mh-nav { display:flex; gap:20px; flex-wrap:wrap; }
.navitem { color:var(--muted); font-weight:600; font-size:.92rem; padding:4px 0 3px; border-bottom:2px solid transparent; display:inline-flex; gap:6px; align-items:center; }
.navitem:hover { color:var(--ink); } .navitem.active { color:var(--ink); border-bottom-color:var(--accent); }
.navitem .soon { font-size:.58rem; text-transform:uppercase; letter-spacing:.06em; background:var(--pill); color:var(--muted); padding:1px 6px; border-radius:var(--r); }
.mh-right { margin-left:auto; display:flex; align-items:center; gap:14px; }
.mh-theme { background:transparent; border:1.5px solid var(--rule); color:var(--ink); width:34px; height:34px; border-radius:var(--r); cursor:pointer; font-size:1rem; line-height:1; }
.mh-theme:hover { background:var(--pill); }
.mh-user { display:flex; align-items:center; gap:9px; } .mh-user .who .nm { font-weight:700; font-size:.86rem; } .mh-user .who .rt { font-size:.72rem; color:var(--muted); }
.content { flex:1; width:100%; max-width:1160px; margin:0 auto; padding:30px 34px 46px; }

/* ---- Buttons ---- */
button.ghost { background:transparent; color:var(--ink); border:2px solid var(--rule); border-radius:var(--r); padding:8px 14px; cursor:pointer; font-size:.9rem; font-weight:700; }
button.ghost.full { width:100%; margin-top:8px; } button.ghost:hover { background:var(--pill); }
button.ghost.sm { padding:7px 12px; font-size:.85rem; }
button.ok { background:var(--ok); color:#fff; border:0; border-radius:var(--r); padding:8px 14px; cursor:pointer; font-size:.88rem; font-weight:700; }
.actions { display:flex; gap:8px; white-space:nowrap; }

/* ---- Cards / rows / tiles ---- */
.card { background:var(--panel); border:2px solid var(--rule); border-radius:var(--r); padding:20px 22px; margin-top:16px; }
.card.nopad { padding:0; overflow:hidden; } .card.empty { text-align:center; padding:40px 20px; color:var(--muted); }
.card.banner { background:var(--pill); border-color:var(--rule); }
.row { display:flex; justify-content:space-between; gap:16px; padding:11px 0; border-top:1.5px solid var(--line); }
.row:first-of-type { border-top:0; } .row .k { color:var(--muted); } .row .v { font-weight:600; text-align:right; }
.tiles { display:grid; grid-template-columns:repeat(auto-fit,minmax(150px,1fr)); gap:0; margin-top:18px; border:2px solid var(--rule); border-radius:var(--r); overflow:hidden; background:var(--panel); }
.tile { padding:18px 20px; border-right:1.5px solid var(--line); }
.tile:last-child { border-right:0; }
.tile .num { font-family:var(--disp); font-size:2.2rem; font-weight:800; letter-spacing:-.02em; line-height:1; }
.tile .lbl { color:var(--muted); font-size:.7rem; font-weight:700; text-transform:uppercase; letter-spacing:.1em; margin-top:8px; }
.tile-warn { background:var(--pill); } .tile-warn .num { color:var(--warn); }

/* ---- Tables ---- */
table { width:100%; border-collapse:collapse; font-size:.92rem; }
th { text-align:left; color:var(--muted); font-weight:700; font-size:.68rem; text-transform:uppercase; letter-spacing:.1em; padding:12px 18px; border-bottom:2px solid var(--rule); }
td { padding:13px 18px; border-bottom:1.5px solid var(--line); vertical-align:middle; }
tbody tr:last-child td { border-bottom:0; }
.card.nopad tbody tr[onclick] { cursor:pointer; } .card.nopad tbody tr[onclick]:hover { background:var(--pill); }

/* ---- Avatars / identity ---- */
.avatar { width:52px; height:52px; border-radius:50%; background:var(--ink); color:var(--bg); display:inline-flex; align-items:center; justify-content:center; font-weight:700; }
.avatar.sm { width:34px; height:34px; font-size:.78rem; } .avatar.xs { width:26px; height:26px; font-size:.66rem; vertical-align:middle; margin-right:6px; }
.avatar.photo { object-fit:cover; }
.profile { display:flex; align-items:center; gap:16px; margin:6px 0 4px; } .profile .name { font-family:var(--disp); font-size:1.9rem; font-weight:800; letter-spacing:-.02em; } .tags { margin-top:8px; display:flex; gap:8px; }

/* ---- Pills / chips / badges ---- */
.pill { background:var(--pill); border-radius:var(--r); padding:3px 10px; font-size:.72rem; font-weight:700; letter-spacing:.04em; color:var(--muted); }
.pill.tier-exec { background:var(--accent); color:var(--accent-ink); } .pill.tier-manager { background:var(--ink); color:var(--bg); }
.pill.tier-leaver { background:var(--pill); color:var(--warn); }
.chips { display:flex; flex-wrap:wrap; gap:8px; } .chip { background:var(--panel); border:1.5px solid var(--rule); border-radius:var(--r); padding:6px 12px; font-size:.9rem; font-weight:600; color:var(--ink); }
.badge { display:inline-block; border-radius:var(--r); padding:3px 10px; font-size:.7rem; font-weight:700; text-transform:uppercase; letter-spacing:.05em; }
.badge.s-requested { background:var(--pill); color:var(--amber); } .badge.s-approved { background:var(--ink); color:var(--bg); } .badge.s-declined, .badge.s-cancelled { background:var(--pill); color:var(--muted); }

/* ---- Forms ---- */
.rowform { display:flex; flex-wrap:wrap; gap:14px; align-items:flex-end; }
.rowform label, .formgrid label { display:flex; flex-direction:column; font-size:.72rem; font-weight:700; text-transform:uppercase; letter-spacing:.06em; color:var(--muted); gap:5px; }
.rowform select, .rowform input, .formgrid input, .formgrid select { font:inherit; text-transform:none; letter-spacing:0; font-weight:500; padding:9px 11px; border:1.5px solid var(--rule); border-radius:var(--r); background:var(--panel); color:var(--ink); }
.rowform button, .formgrid button { background:var(--accent); color:var(--accent-ink); border:0; border-radius:var(--r); padding:10px 18px; cursor:pointer; font-weight:700; }
.formgrid { display:grid; grid-template-columns:1fr 1fr; gap:14px; }
.formgrid .formactions { grid-column:1 / -1; }
.formgrid label.wide { grid-column:1 / -1; }
.formgrid label.chk { flex-direction:row; align-items:center; gap:8px; color:var(--ink); text-transform:none; letter-spacing:0; font-weight:600; }
.formgrid label.chk input { width:auto; }
td button.ghost.sm { color:var(--muted); border:1.5px solid var(--line); padding:7px 12px; } td button.ghost.sm:hover { background:var(--pill); color:var(--ink); }
@media (max-width:600px){ .formgrid { grid-template-columns:1fr; } }

.pagehead { display:flex; align-items:center; justify-content:space-between; gap:12px; flex-wrap:wrap; }
.pagehead h1 { margin:0; }

/* ---- Section toggle (tabs) ---- */
.pagehead .toggle { display:inline-flex; gap:2px; background:var(--panel); border:2px solid var(--rule); border-radius:var(--r); padding:3px; }
.pagehead .toggle .tg { padding:6px 14px; border-radius:2px; font-size:.85rem; color:var(--muted); font-weight:700; }
.pagehead .toggle .tg.active { background:var(--ink); color:var(--bg); }

/* ---- Department cards ---- */
.deptgrid { display:grid; grid-template-columns:repeat(auto-fill,minmax(220px,1fr)); gap:14px; margin-top:16px; }
.deptcard { display:block; background:var(--panel); border:2px solid var(--rule); border-radius:var(--r); padding:16px 18px; color:var(--ink); transition:transform .1s; }
.deptcard:hover { transform:translateY(-2px); }
.deptcard .deptname { font-weight:700; font-size:1.02rem; }
.deptcard .deptcount { color:var(--muted); font-size:.78rem; font-weight:700; text-transform:uppercase; letter-spacing:.06em; margin:2px 0 12px; }
.deptcard .deptav { display:flex; } .deptcard .deptav .avatar.xs { margin-right:-6px; border:2px solid var(--panel); }
.deptcard .avatar.xs.more { background:var(--pill); color:var(--muted); }

/* ---- Org move panel ---- */
tr.mvrow > td { background:var(--pill); }
.mvform .formactions { display:flex; align-items:center; gap:10px; margin-top:6px; }
.mvform .formactions .mvmsg { margin-left:auto; }

/* ---- Company calendar ---- */
.cal-head { display:flex; align-items:center; gap:12px; }
.cal-head h2 { margin:0; color:var(--ink); text-transform:none; letter-spacing:0; font-size:1.15rem; font-family:var(--disp); font-weight:700; }
.cal-head button.ghost.sm { padding:4px 12px; line-height:1; }
.cal-grid { display:grid; grid-template-columns:repeat(7,1fr); gap:6px; margin-top:12px; }
.cal-dow { text-align:center; font-size:.66rem; text-transform:uppercase; letter-spacing:.1em; font-weight:700; color:var(--muted); padding:2px 0; }
.cal-cell { min-height:74px; border:1.5px solid var(--line); border-radius:var(--r); padding:5px 6px; background:var(--panel); overflow:hidden; }
.cal-cell.empty { border:0; background:transparent; }
.cal-cell.weekend { background:var(--bg); }
.cal-cell.holiday { background:var(--pill); border-color:var(--rule); }
.cal-cell.mine { box-shadow:inset 0 0 0 2px var(--accent); }
.cal-cell.clash { background:var(--pill); border-color:var(--warn); }
.cal-cell.today .cal-day { color:var(--accent); font-weight:800; }
.cal-day { font-size:.82rem; font-weight:700; color:var(--ink); display:flex; justify-content:space-between; align-items:center; }
.cal-clash { color:var(--warn); font-size:.8rem; }
.cal-hol { font-size:.64rem; color:var(--amber); font-weight:700; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; margin-top:2px; }
.cal-chip { font-size:.66rem; background:var(--pill); color:var(--muted); border-radius:3px; padding:1px 5px; margin-top:2px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.cal-chip.me { background:var(--accent); color:var(--accent-ink); }
.cal-more { font-size:.64rem; color:var(--muted); margin-top:2px; }
.cal-legend { display:flex; gap:16px; margin-top:12px; font-size:.76rem; color:var(--muted); }
.cal-legend .lg { display:inline-flex; align-items:center; gap:6px; }
.cal-legend .lg::before { content:""; width:12px; height:12px; border-radius:2px; border:1.5px solid var(--line); }
.cal-legend .lg.holiday::before { background:var(--pill); border-color:var(--rule); }
.cal-legend .lg.mine::before { background:var(--panel); box-shadow:inset 0 0 0 2px var(--accent); }
.cal-legend .lg.clash::before { background:var(--pill); border-color:var(--warn); }
@media (max-width:600px){ .cal-cell { min-height:56px; } .cal-chip,.cal-hol { display:none; } }

/* ---- Org chart ---- */
.orgcard { overflow:hidden; }
.orglegend { display:flex; flex-wrap:wrap; gap:14px; margin-bottom:14px; font-size:.78rem; color:var(--muted); }
.orglegend .orglg { display:inline-flex; align-items:center; gap:6px; }
.orglegend .sw { width:12px; height:12px; border-radius:2px; display:inline-block; }
.orgscroll { overflow-x:auto; padding:8px 4px 12px; }
.tree { display:inline-block; min-width:100%; text-align:center; }
.tree ul { display:flex; justify-content:center; position:relative; padding-top:22px; margin:0; list-style:none; }
.tree li { list-style:none; position:relative; padding:22px 10px 0; }
.tree li::before, .tree li::after { content:''; position:absolute; top:0; right:50%; border-top:2px solid var(--line); width:50%; height:22px; }
.tree li::after { right:auto; left:50%; border-left:2px solid var(--line); }
.tree li:only-child::after, .tree li:only-child::before { display:none; }
.tree li:only-child { padding-top:22px; }
.tree li:first-child::before, .tree li:last-child::after { border:0 none; }
.tree li:last-child::before { border-right:2px solid var(--line); }
.tree ul ul::before { content:''; position:absolute; top:0; left:50%; border-left:2px solid var(--line); width:0; height:22px; }
.tree > ul { padding-top:0; }
.tree > ul > li:only-child { padding-top:0; }
.node { position:relative; display:inline-block; min-width:150px; max-width:210px; background:var(--panel); border:2px solid var(--rule); border-radius:var(--r); padding:12px 14px 11px; cursor:pointer; text-align:center; transition:transform .1s; overflow:hidden; }
.node:hover { transform:translateY(-2px); }
.node .node-bar { position:absolute; top:0; left:0; right:0; height:4px; }
.node .node-title { font-size:.66rem; text-transform:uppercase; letter-spacing:.08em; color:var(--muted); font-weight:700; margin-top:4px; }
.node .node-name { font-weight:700; font-size:.95rem; color:var(--ink); margin-top:3px; }
.node .node-tag { display:inline-block; margin-top:7px; font-size:.62rem; font-weight:700; text-transform:uppercase; letter-spacing:.05em; background:var(--pill); color:var(--muted); border-radius:var(--r); padding:2px 8px; }
@media (max-width:600px){ .node { min-width:120px; } }

/* ---- Absence bar chart ---- */
.barchart { display:flex; flex-direction:column; gap:8px; margin:6px 0; }
.barrow { display:grid; grid-template-columns:130px 1fr 28px; align-items:center; gap:10px; }
.barrow .barlbl { font-size:.86rem; color:var(--ink); white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.barrow .bartrack { background:var(--pill); border-radius:3px; height:16px; overflow:hidden; }
.barrow .bar { display:block; height:100%; background:var(--accent); border-radius:3px; min-width:3px; }
.barrow .barval { text-align:right; font-weight:800; font-size:.86rem; font-family:var(--disp); }

/* ---- Toolbars ---- */
.toolbar { display:flex; align-items:center; gap:12px; margin:6px 0 2px; flex-wrap:wrap; }
.toolbar-actions { margin-left:auto; display:inline-flex; gap:8px; align-items:center; }
.pagehead .toolbar-actions { margin-left:auto; }

/* ---- Case notes ---- */
.notes { display:flex; flex-direction:column; gap:10px; }
.note { border-left:3px solid var(--accent); padding:4px 0 4px 12px; }
.note .note-h { font-weight:700; font-size:.9rem; }

/* ---- Jaxx assistant ---- */
.jx-launch { position:fixed; right:20px; bottom:20px; z-index:40; background:var(--accent); color:var(--accent-ink); border:0; border-radius:var(--r); padding:12px 20px; font-weight:800; font-size:.95rem; cursor:pointer; box-shadow:0 6px 18px rgba(0,0,0,.22); }
.jx-launch:hover { filter:brightness(1.04); }
.jx-panel { position:fixed; right:20px; bottom:20px; z-index:41; width:min(92vw,360px); height:min(70vh,520px); background:var(--panel); border:2px solid var(--rule); border-radius:var(--r); box-shadow:0 12px 40px rgba(0,0,0,.28); display:none; flex-direction:column; overflow:hidden; }
.jx-panel.open { display:flex; }
.jx-head { display:flex; align-items:center; justify-content:space-between; padding:13px 16px; background:var(--ink); color:var(--bg); }
.jx-head strong { font-family:var(--disp); font-size:1.05rem; letter-spacing:-.01em; }
.jx-x { background:transparent; border:0; color:var(--bg); font-size:1.3rem; line-height:1; cursor:pointer; padding:0 4px; }
.jx-scope { font-size:.72rem; color:var(--muted); background:var(--pill); padding:8px 16px; border-bottom:1.5px solid var(--line); }
.jx-thread { flex:1; overflow-y:auto; padding:14px; display:flex; flex-direction:column; gap:10px; }
.jx-hint { color:var(--muted); font-size:.86rem; }
.jx-msg { max-width:85%; padding:9px 12px; border-radius:var(--r); font-size:.9rem; line-height:1.45; white-space:pre-wrap; }
.jx-msg.jx-q { align-self:flex-end; background:var(--accent); color:var(--accent-ink); }
.jx-msg.jx-a { align-self:flex-start; background:var(--pill); color:var(--ink); }
.jx-badge { display:block; font-size:.6rem; text-transform:uppercase; letter-spacing:.08em; color:var(--accent); font-weight:800; margin-bottom:2px; }
.jx-form { display:flex; gap:8px; padding:10px; border-top:1.5px solid var(--line); }
.jx-form input { flex:1; font:inherit; padding:9px 12px; border:1.5px solid var(--rule); border-radius:var(--r); background:var(--panel); color:var(--ink); }
.jx-form button { background:var(--accent); color:var(--accent-ink); border:0; border-radius:var(--r); padding:9px 16px; cursor:pointer; font-weight:800; }

/* ---- Person photo + identity ---- */
.personcols { display:flex; gap:16px; align-items:flex-start; margin-top:16px; }
.personcols .card { flex:1; margin-top:0; min-width:0; }
.photobox { flex:0 0 208px; background:var(--panel); border:2px solid var(--rule); border-radius:var(--r); padding:14px; text-align:center; }
.personphoto { width:176px; height:176px; border-radius:var(--r); object-fit:cover; display:block; margin:0 auto 10px; background:var(--pill); }
.personphoto.placeholder { display:flex; align-items:center; justify-content:center; font-family:var(--disp); font-size:2.4rem; font-weight:800; color:var(--muted); }
.ok-text { color:var(--ok); font-weight:700; }
@media (max-width:640px){ .personcols { flex-direction:column; } .photobox { flex-basis:auto; width:100%; } }

/* ---- Exec KPI dashboard ---- */
.dashgrid { display:grid; grid-template-columns:repeat(auto-fit,minmax(300px,1fr)); gap:16px; margin-top:18px; align-items:start; }
.dashgrid .card { margin:0; }
.dashgrid h2 { margin:0 0 10px; font-family:var(--disp); font-weight:700; font-size:1.2rem; text-transform:none; letter-spacing:-.01em; color:var(--ink); }
table.mini { width:100%; border-collapse:collapse; }
table.mini th { text-align:left; font-size:.66rem; text-transform:uppercase; letter-spacing:.08em; color:var(--muted); font-weight:700; padding:3px 6px; border-bottom:1.5px solid var(--line); }
table.mini td { padding:6px 6px; border-bottom:1.5px solid var(--line); font-size:.9rem; }
table.mini tr:last-child td { border-bottom:none; }
table.mini td.num-c { text-align:right; white-space:nowrap; font-family:var(--disp); font-weight:700; }
table.mini tbody tr[onclick] { cursor:pointer; }
table.mini tbody tr[onclick]:hover { background:var(--pill); }

@media (max-width:760px){ .masthead { gap:14px; padding:14px 18px; } .content { padding:22px 18px 40px; } .mh-nav { gap:12px; } .mh-user .who { display:none; } }

/* Inline-SVG charts (S1 dashboards) */
.chartwrap { display:flex; flex-direction:column; align-items:center; gap:8px; }
.donut { width:140px; height:140px; }
.donut-num { font-family:var(--disp); font-weight:800; font-size:26px; fill:var(--ink); }
.donut-sub { font-size:12px; fill:var(--muted); }
.chartlabel { font-size:13px; color:var(--muted); text-align:center; }
.hbars { width:100%; height:auto; }
.hbars .bar-lbl { font-size:13px; fill:var(--ink); }
.hbars .bar-val { font-size:13px; font-weight:600; fill:var(--muted); }
.chartcard { display:flex; flex-direction:column; }
.chartcard h2 { margin-top:0; }

/* On-page search (S10) */
.pagehead { flex-wrap:wrap; gap:12px; }
.pagesearch { margin-left:auto; padding:8px 12px; border:2px solid var(--rule); border-radius:var(--r); background:var(--panel); color:var(--ink); font:inherit; font-size:.9rem; min-width:200px; }
.pagesearch:focus { outline:2px solid var(--accent); outline-offset:1px; }
