:root {
  --bg: #f5f6f8; --surface: #fff; --surface-2: #f0f2f5; --text: #1b1f24; --muted: #5f6b7a;
  --border: #dde1e6; --accent: #0b6e4f; --accent-text: #fff; --danger: #b42318;
  --warn-bg: #fff4d6; --warn: #8a5a00; --ok-bg: #e3f4ec; --ok: #0b6e4f; --off-bg: #eceef1; --off: #5f6b7a;
  --shadow: 0 1px 2px rgba(0,0,0,.06), 0 4px 16px rgba(0,0,0,.05);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111418; --surface: #1a1e24; --surface-2: #232830; --text: #e6e9ed; --muted: #9aa5b1;
    --border: #2e343d; --accent: #3fb68b; --accent-text: #0b1410; --danger: #ff7b72;
    --warn-bg: #3a2f12; --warn: #f2c14e; --ok-bg: #12301f; --ok: #5fd3a2; --off-bg: #262b33; --off: #9aa5b1;
    --shadow: none; color-scheme: dark;
  }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
h1 { font-size: 22px; margin: 0 0 8px; }
h2 { font-size: 17px; margin: 0 0 12px; }
a { color: var(--accent); }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.error { color: var(--danger); }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 20px; box-shadow: var(--shadow); }
.narrow { max-width: 420px; margin: 10vh auto 0; }
@media (max-width: 460px) { .narrow { margin: 16px; } }
.brand { font-weight: 700; color: var(--accent); letter-spacing: .02em; margin-bottom: 16px; }
.signin { margin: 20px 0 8px; min-height: 44px; }
.dev { margin-top: 24px; padding-top: 16px; border-top: 1px dashed var(--border); display: grid; gap: 8px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 20px; }
form.inline { display: inline; margin: 0; }

.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--accent); background: var(--accent); color: var(--accent-text);
  padding: 8px 14px; border-radius: 8px; font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; }
.btn.ghost { background: transparent; color: var(--text); border-color: var(--border); }
.btn.small { padding: 4px 10px; font-size: 13px; }
.btn.danger { background: transparent; color: var(--danger); border-color: var(--danger); }
.btn:disabled { opacity: .5; cursor: default; }
input, select, textarea { font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; width: 100%; }
textarea { min-height: 70px; }
label { display: grid; gap: 4px; font-size: 13px; color: var(--muted); }
label.check { display: flex; align-items: center; gap: 8px; color: var(--text); font-size: 15px; }
label.check input { width: auto; }

/* App shell */
header.top { display: flex; align-items: center; gap: 12px; padding: 12px 16px; background: var(--surface); border-bottom: 1px solid var(--border); }
header.top .brand { margin: 0; }
header.top .spacer { flex: 1; }
header.top img.avatar, .avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--surface-2); object-fit: cover; flex: none; }
.wrap { max-width: 1100px; margin: 0 auto; padding: 20px 16px 60px; }

.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; margin-top: 16px; }
.tile { display: block; padding: 18px; border-radius: 12px; background: var(--surface); border: 1px solid var(--border); text-decoration: none; color: var(--text); box-shadow: var(--shadow); }
.tile:hover { border-color: var(--accent); }
.tile .name { font-weight: 700; font-size: 16px; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 16px; overflow-x: auto; }
.tabs button { background: none; border: 0; border-bottom: 2px solid transparent; padding: 10px 14px; font: inherit; color: var(--muted); cursor: pointer; white-space: nowrap; }
.tabs button.on { color: var(--text); border-bottom-color: var(--accent); font-weight: 600; }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.toolbar input { max-width: 260px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { font-size: 12px; padding: 2px 8px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); white-space: nowrap; }
.chip.filter { cursor: pointer; font-size: 13px; padding: 4px 12px; }
.chip.filter.on { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.badge { font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 6px; }
.badge.pending { background: var(--warn-bg); color: var(--warn); }
.badge.active { background: var(--ok-bg); color: var(--ok); }
.badge.disabled { background: var(--off-bg); color: var(--off); }

.list { display: grid; gap: 8px; }
.row { display: grid; grid-template-columns: 36px minmax(0, 2fr) minmax(0, 1.4fr) minmax(0, 2fr) auto; gap: 12px; align-items: center;
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; cursor: pointer; }
.row:hover { border-color: var(--accent); }
.row .who { min-width: 0; }
.row .who div, .row .odoo { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 760px) {
  .row { grid-template-columns: 36px minmax(0, 1fr) auto; }
  .row .odoo, .row .chips { grid-column: 2 / -1; }
}

/* Drawer editor */
.scrim { position: fixed; inset: 0; background: rgba(0,0,0,.35); display: none; z-index: 10; }
.scrim.open { display: block; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(480px, 100vw); background: var(--surface); border-left: 1px solid var(--border);
  transform: translateX(100%); transition: transform .18s ease; z-index: 11; display: flex; flex-direction: column; }
.drawer.open { transform: none; }
.drawer .body { padding: 20px; overflow-y: auto; flex: 1; display: grid; gap: 18px; align-content: start; }
.drawer .foot { padding: 12px 20px; border-top: 1px solid var(--border); display: flex; gap: 8px; justify-content: flex-end; }
.section { display: grid; gap: 8px; }
.section h3 { margin: 0; font-size: 13px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.access-row { display: grid; grid-template-columns: 1fr 160px; gap: 8px; align-items: center; }
.results { display: grid; gap: 4px; max-height: 220px; overflow-y: auto; }
.result { display: flex; justify-content: space-between; gap: 8px; align-items: center; padding: 6px 8px; border-radius: 8px; background: var(--surface-2); }
.result small { color: var(--muted); }
.linked { padding: 8px 10px; border-radius: 8px; background: var(--ok-bg); display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.secret { font-family: ui-monospace, Consolas, monospace; word-break: break-all; background: var(--warn-bg); color: var(--text); padding: 10px; border-radius: 8px; }

table.log { width: 100%; border-collapse: collapse; font-size: 13px; }
table.log td, table.log th { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--border); vertical-align: top; }
table.log td.detail { font-family: ui-monospace, Consolas, monospace; font-size: 12px; color: var(--muted); word-break: break-word; }
.table-wrap { overflow-x: auto; }

.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 8px; z-index: 20; display: none; max-width: calc(100vw - 32px); }
.toast.show { display: block; }
.toast.err { background: var(--danger); color: #fff; }

/* ── Staff portal ─────────────────────────────────────────────────────────── */
.nav { display: flex; gap: 2px; margin-left: 8px; }
.nav a { color: var(--muted); text-decoration: none; padding: 6px 10px; border-radius: 8px; font-weight: 600; font-size: 14px; }
.nav a:hover { background: var(--surface-2); color: var(--text); }
.nav a.on { color: var(--text); background: var(--surface-2); }
@media (max-width: 520px) { header.top { flex-wrap: wrap; } .nav { order: 3; width: 100%; margin: 4px 0 0; } }

.hero { padding: 8px 0 20px; }
.hero h1 { font-size: 26px; margin: 2px 0 2px; }
.hero p { margin: 0; }

.home-grid { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 20px; align-items: start; }
.home-side { display: grid; gap: 16px; }
.home-side .card { padding: 16px; }
.home-side h2 { margin-bottom: 8px; }
@media (max-width: 860px) { .home-grid { grid-template-columns: 1fr; } .home-side { order: -1; } }

.section-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 12px; }
.section-head h2 { margin: 0; }
.card .section-head { margin-bottom: 8px; }

.news-list { display: grid; gap: 12px; }
.news h3 { margin: 4px 0 6px; font-size: 18px; }
.news.pinned { border-color: var(--accent); }
.news-meta { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.news-body { white-space: pre-wrap; overflow-wrap: anywhere; }
.news-actions { display: flex; gap: 8px; margin-top: 12px; }
.badge.pinned { background: var(--ok-bg); color: var(--ok); }

.app-list { display: grid; gap: 6px; }
.app-link { display: grid; grid-template-columns: 28px minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 8px; border-radius: 8px;
  text-decoration: none; color: var(--text); border: 1px solid var(--border); }
.app-link:hover { border-color: var(--accent); }
.app-dot { width: 28px; height: 28px; border-radius: 8px; background: var(--accent); color: var(--accent-text); display: grid; place-items: center; font-weight: 700; font-size: 13px; }
.app-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#leaveSummary { display: grid; gap: 4px; color: var(--text); }
.review-link { font-weight: 600; }

.leave-grid { display: grid; grid-template-columns: 360px minmax(0, 1fr); gap: 20px; align-items: start; }
@media (max-width: 860px) { .leave-grid { grid-template-columns: 1fr; } }
.form-grid { display: grid; gap: 12px; }
.form-grid h2 { margin: 0; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.apply-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.leave-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 12px; align-items: start; background: var(--surface);
  border: 1px solid var(--border); border-radius: 10px; padding: 12px; }
.leave-row .leave-person { grid-column: 1 / -1; padding-bottom: 6px; border-bottom: 1px solid var(--border); }
.leave-main { display: grid; gap: 2px; min-width: 0; }
.leave-side { display: grid; gap: 8px; justify-items: end; }
.quote { border-left: 3px solid var(--border); padding-left: 8px; white-space: pre-wrap; overflow-wrap: anywhere; }
.badge.approved { background: var(--ok-bg); color: var(--ok); }
.badge.rejected { background: #fde8e6; color: var(--danger); }
.badge.cancelled { background: var(--off-bg); color: var(--off); }
@media (prefers-color-scheme: dark) { .badge.rejected { background: #3b1715; } }
