:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --border: #e3e6ea;
  --border-strong: #cdd3da;
  --text: #16202b;
  --muted: #667585;
  --accent: #1f6feb;
  --accent-dark: #1758bd;
  --ok-bg: #e7f6ed;
  --ok-text: #14603a;
  --warn-bg: #fdf3e2;
  --warn-text: #7a4c05;
  --err-bg: #fdeaea;
  --err-text: #8c1d1d;
  --approve: #15803d;
  --decline: #b42318;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 1px 3px rgba(16, 24, 40, .04);
  color-scheme: light;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

h1 { font-size: 1.45rem; margin: 0 0 .2rem; letter-spacing: -.01em; }
h2 { font-size: 1rem; margin: 0; letter-spacing: -.005em; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code.code { background: #eef1f4; padding: .15rem .4rem; border-radius: 5px; font-size: .9em; }

.muted { color: var(--muted); }
.small { font-size: .85rem; }
.block { display: block; }
.num { text-align: right; }
.danger { color: var(--decline); font-weight: 600; }
.pad { padding: .9rem 1.1rem; }
.hint { font-size: .82rem; color: var(--muted); margin: .35rem 0 0; }
.border-top { border-top: 1px solid var(--border); }

/* ---------- top bar ---------- */
.topbar { background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 20; }
.topbar-inner {
  max-width: 1180px; margin: 0 auto; padding: .55rem 1.1rem;
  display: flex; align-items: center; gap: 1.1rem; flex-wrap: wrap;
}
.brand { font-weight: 650; color: var(--text); display: flex; align-items: center; gap: .4rem; }
.brand:hover { text-decoration: none; }
.brand-mark { font-size: 1.1rem; }
.brand-mark.big { font-size: 2rem; display: block; }
.nav { display: flex; gap: .2rem; flex-wrap: wrap; }
.nav a {
  padding: .35rem .6rem; border-radius: 7px; color: var(--muted); font-weight: 500; font-size: .92rem;
}
.nav a:hover { background: #f0f2f5; color: var(--text); text-decoration: none; }
.nav a.active { background: #e8eefc; color: var(--accent-dark); }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: .6rem; }
/* Every page that matters already has its own call to action, so drop the
   duplicate from the header once the bar starts wrapping. */
@media (max-width: 720px) { .topbar-right .btn-primary { display: none; } }

.menu { position: relative; }
.menu summary {
  cursor: pointer; list-style: none; font-size: .9rem; color: var(--muted);
  padding: .35rem .55rem; border-radius: 7px; border: 1px solid var(--border);
}
.menu summary::-webkit-details-marker { display: none; }
.menu[open] summary { background: #f0f2f5; }
.menu-panel {
  position: absolute; right: 0; top: calc(100% + .4rem); background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
  min-width: 220px; padding: .5rem; display: grid; gap: .15rem; z-index: 30;
}
.menu-meta { padding: .4rem .5rem .6rem; font-size: .85rem; border-bottom: 1px solid var(--border); margin-bottom: .3rem; }
.menu-panel a, .linklike {
  display: block; width: 100%; text-align: left; padding: .4rem .5rem; border-radius: 6px;
  background: none; border: 0; font: inherit; color: var(--text); cursor: pointer;
}
.menu-panel a:hover, .linklike:hover { background: #f0f2f5; text-decoration: none; }

/* ---------- layout ---------- */
.page { max-width: 1180px; margin: 0 auto; padding: 1.4rem 1.1rem 2.5rem; }
.narrow { max-width: 720px; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.1rem; }
.page-head p { margin: 0; font-size: .9rem; }
.row { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; align-items: start; }
@media (max-width: 860px) { .cols { grid-template-columns: 1fr; } }

.foot {
  max-width: 1180px; margin: 0 auto; padding: 1rem 1.1rem 2rem;
  color: var(--muted); font-size: .82rem; display: flex; gap: 1rem;
}

/* ---------- cards ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 1rem; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: .8rem; padding: .8rem 1.1rem; border-bottom: 1px solid var(--border); }
.card-head:last-child { border-bottom: 0; }
.empty-state { padding: 2.2rem 1.1rem; text-align: center; }
.empty-state h1, .empty-state h2 { margin-bottom: .4rem; }

.banner {
  display: block; background: #e8eefc; border: 1px solid #c7d7f7; color: var(--accent-dark);
  border-radius: var(--radius); padding: .75rem 1.1rem; margin-bottom: 1rem; font-size: .93rem;
}
.banner:hover { text-decoration: none; background: #dfe8fb; }

/* ---------- stats ---------- */
.stat-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: .75rem; margin-bottom: 1rem; }
.stat-row.inset { margin: 0; padding: .9rem 1.1rem; }
.stat-row.inset .stat { background: #f8f9fb; }
@media (max-width: 720px) { .stat-row { grid-template-columns: repeat(2, 1fr); } }
.stat {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: .85rem 1rem;
}
.stat-label { display: block; font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.stat-value { display: block; font-size: 1.8rem; font-weight: 650; letter-spacing: -.02em; line-height: 1.15; }
.stat-unit { font-size: .78rem; color: var(--muted); }
.stat-accent { border-color: #bcd0f5; background: #f4f8ff; }
.stat-accent .stat-value { color: var(--accent-dark); }
.stat-danger { border-color: #f2c4c0; background: #fdf5f4; }
.stat-danger .stat-value { color: var(--decline); }

/* ---------- lists & tables ---------- */
.list { list-style: none; margin: 0; padding: 0; }
.list li {
  display: flex; align-items: center; justify-content: space-between; gap: .8rem;
  padding: .65rem 1.1rem; border-bottom: 1px solid var(--border);
}
.list li:last-child { border-bottom: 0; }
.list-main { display: flex; align-items: center; gap: .6rem; color: var(--text); min-width: 0; }
.list-main:hover { text-decoration: none; }
a.list-main:hover strong { text-decoration: underline; }
.list-main .block { font-size: .84rem; }

.table-scroll { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: .9rem; }
/* Editable rows have too many columns to compress — scroll them instead. */
.table-wide { min-width: 1040px; }
.table th {
  text-align: left; font-size: .75rem; text-transform: uppercase; letter-spacing: .04em;
  color: var(--muted); padding: .6rem 1.1rem; border-bottom: 1px solid var(--border); white-space: nowrap;
}
.table td { padding: .55rem 1.1rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tr:hover td { background: #fafbfc; }
.row-muted td { opacity: .6; }
.actions { white-space: nowrap; display: flex; gap: .3rem; justify-content: flex-end; }
.inline { display: inline; }

.detail { margin: 0; display: grid; }
.detail > div { display: grid; grid-template-columns: 170px 1fr; gap: 1rem; padding: .65rem 1.1rem; border-bottom: 1px solid var(--border); }
.detail > div:last-child { border-bottom: 0; }
.detail dt { color: var(--muted); font-size: .85rem; }
.detail dd { margin: 0; }
@media (max-width: 560px) { .detail > div { grid-template-columns: 1fr; gap: .15rem; } }

/* ---------- pills, swatches ---------- */
.swatch { display: inline-block; width: 10px; height: 10px; border-radius: 3px; flex: none; }
.swatch-pending { background: repeating-linear-gradient(45deg, #94a3b8 0 3px, #e2e8f0 3px 6px); }
.pill {
  display: inline-block; font-size: .72rem; font-weight: 600; text-transform: uppercase;
  letter-spacing: .04em; padding: .18rem .45rem; border-radius: 999px; white-space: nowrap;
}
.pill-pending { background: var(--warn-bg); color: var(--warn-text); }
.pill-approved { background: var(--ok-bg); color: var(--ok-text); }
.pill-declined { background: var(--err-bg); color: var(--err-text); }
.pill-cancelled { background: #eef1f4; color: var(--muted); }

/* ---------- forms ---------- */
label { display: block; font-size: .88rem; font-weight: 550; }
input[type=text], input[type=email], input[type=password], input[type=date], input[type=month],
input[type=number], select, textarea {
  width: 100%; margin-top: .25rem; padding: .5rem .6rem; font: inherit; color: var(--text);
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: 8px;
}
input:focus, select:focus, textarea:focus { outline: 2px solid #bcd0f5; outline-offset: 0; border-color: var(--accent); }
textarea { resize: vertical; }
input[type=color] { width: 46px; height: 34px; padding: 2px; margin-top: .25rem; border: 1px solid var(--border-strong); border-radius: 8px; background: var(--surface); }
label.check { display: flex; align-items: center; gap: .45rem; font-weight: 500; }
label.check input { width: auto; margin: 0; }

.stack { display: grid; gap: .85rem; }
form.card.stack, .card .stack.pad { padding: 1.1rem; }
.pair { display: grid; grid-template-columns: 1fr 1fr; gap: .85rem; }
@media (max-width: 560px) { .pair { grid-template-columns: 1fr; } }

.grid-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .75rem; align-items: end; }
.grid-form-actions { display: flex; align-items: end; }

.filters { display: flex; gap: .75rem; align-items: flex-end; flex-wrap: wrap; padding: .9rem 1.1rem; }
.filters label { font-size: .82rem; }
.filters input, .filters select { min-width: 150px; }
/* The min-width above must not stretch a checkbox away from its own label. */
.filters input[type=checkbox] { min-width: 0; width: auto; }
.filters label.check { padding-bottom: .45rem; }

.inline-input { margin-top: 0; padding: .3rem .4rem; font-size: .88rem; min-width: 90px; }
.inline-input.num { text-align: right; width: 80px; min-width: 0; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .35rem;
  padding: .48rem .85rem; border-radius: 8px; border: 1px solid transparent;
  font: inherit; font-weight: 550; font-size: .9rem; cursor: pointer; white-space: nowrap;
}
.btn:hover { text-decoration: none; }
.btn-sm { padding: .3rem .55rem; font-size: .83rem; }
.btn-block { width: 100%; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-dark); }
.btn-ghost { background: var(--surface); border-color: var(--border-strong); color: var(--text); }
.btn-ghost:hover { background: #f0f2f5; }
.btn-approve { background: var(--approve); color: #fff; }
.btn-approve:hover { filter: brightness(.93); }
.btn-decline { background: var(--surface); border-color: #e5b4af; color: var(--decline); }
.btn-decline:hover { background: #fdf1f0; }
.btn-danger-text { color: var(--decline); }
.cancel-row { margin-top: -.4rem; }

/* ---------- flashes ---------- */
.flash { border-radius: var(--radius); padding: .7rem .95rem; margin-bottom: 1rem; font-size: .92rem; border: 1px solid transparent; }
.flash-ok { background: var(--ok-bg); color: var(--ok-text); border-color: #bfe3cd; }
.flash-warn { background: var(--warn-bg); color: var(--warn-text); border-color: #f0d9ab; }
.flash-error { background: var(--err-bg); color: var(--err-text); border-color: #f0c0bd; }
.inset-flash { margin: 0 1.1rem 1.1rem; }

/* ---------- tabs ---------- */
.tabs { display: flex; gap: .25rem; align-items: center; flex-wrap: wrap; margin-bottom: .9rem; }
.tabs a {
  padding: .32rem .6rem; border-radius: 7px; font-size: .87rem; color: var(--muted);
  text-transform: capitalize; border: 1px solid transparent;
}
.tabs a:hover { background: #f0f2f5; text-decoration: none; }
.tabs a.active { background: var(--surface); border-color: var(--border-strong); color: var(--text); font-weight: 550; }
.tab-sep { width: 1px; height: 20px; background: var(--border-strong); margin: 0 .4rem; }

/* ---------- auth ---------- */
.auth-wrap { min-height: 88vh; display: grid; place-items: center; padding: 2rem 1.1rem; }
.auth-card {
  width: 100%; max-width: 400px; background: var(--surface); border: 1px solid var(--border);
  border-radius: 14px; box-shadow: 0 4px 20px rgba(16, 24, 40, .07); padding: 1.8rem;
}
.auth-head { text-align: center; margin-bottom: 1.3rem; }
.auth-head h1 { margin: .5rem 0 .3rem; }
.auth-head p { margin: 0; font-size: .9rem; }
.auth-alt { text-align: center; font-size: .88rem; color: var(--muted); margin: 1.1rem 0 0; }

/* ---------- approvals ---------- */
.approval-head { display: flex; justify-content: space-between; gap: 1rem; padding: 1rem 1.1rem .3rem; }
.approval-meta { margin: .3rem 0 0; font-size: .9rem; color: var(--muted); display: flex; align-items: center; gap: .4rem; flex-wrap: wrap; }
.approval-meta strong { color: var(--text); }
.quote { margin: .6rem 0 0; padding-left: .7rem; border-left: 3px solid var(--border-strong); color: var(--muted); font-size: .9rem; }
.clash { margin: .5rem 1.1rem 0; background: var(--warn-bg); color: var(--warn-text); border-radius: 8px; padding: .5rem .7rem; font-size: .87rem; }
.approval-actions { display: flex; gap: .5rem; padding: .9rem 1.1rem 1.1rem; flex-wrap: wrap; }
.approval-actions input[type=text] { flex: 1 1 220px; margin-top: 0; }

/* ---------- calendar ---------- */
.legend { display: flex; gap: .9rem; flex-wrap: wrap; margin-bottom: .8rem; font-size: .82rem; color: var(--muted); }
.legend-item { display: flex; align-items: center; gap: .35rem; }

.cal-scroll { overflow-x: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.cal { width: 100%; min-width: 780px; border-collapse: collapse; table-layout: fixed; }
.cal th {
  font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted);
  padding: .5rem .6rem; border-bottom: 1px solid var(--border); text-align: left; font-weight: 600;
}
.cal th.we { color: var(--border-strong); }
.cal-cell {
  border: 1px solid var(--border); border-top: 0; border-left: 0;
  vertical-align: top; height: 96px; padding: .3rem .35rem; width: 14.28%;
}
.cal-cell:last-child { border-right: 0; }
.cal-day { display: flex; align-items: center; justify-content: space-between; }
.cal-num { font-size: .8rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.cal-add {
  opacity: 0; font-size: .95rem; line-height: 1; color: var(--muted);
  padding: 0 .2rem; border-radius: 4px; transition: opacity .12s;
}
.cal-cell:hover .cal-add { opacity: 1; }
.cal-add:hover { background: #e8eefc; color: var(--accent-dark); text-decoration: none; }
.cal-cell.outside { background: #fbfbfc; }
.cal-cell.outside .cal-num { color: #b8c0c9; }
.cal-cell.weekend { background: #f5f6f8; }
.cal-cell.holiday { background: #fdf7e9; }
.cal-cell.today { box-shadow: inset 0 0 0 2px var(--accent); }
.cal-cell.today .cal-num { color: var(--accent-dark); font-weight: 700; }
.cal-holiday { font-size: .7rem; color: var(--warn-text); margin-top: .1rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* A tint of the leave-type colour carries identity in the dot, while the text
   sits on a near-white background. Saturated mid-lightness fills cannot
   reliably clear 4.5:1 for small text either with white or with dark ink, and
   admins can pick any colour — so no text ever sits on the raw colour. */
.chip {
  display: flex; align-items: center; gap: .28rem;
  margin-top: .18rem; padding: .12rem .35rem .14rem;
  border-radius: 5px; font-size: .74rem; font-weight: 550; line-height: 1.35;
  color: var(--text);
  background: #eef1f4;
  background: color-mix(in srgb, var(--chip, var(--accent)) 15%, #fff);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--chip, var(--accent)) 28%, #fff);
  overflow: hidden; white-space: nowrap;
}
.chip::before {
  content: ""; flex: none; width: 6px; height: 6px; border-radius: 2px;
  background: var(--chip, var(--accent));
}
.chip > span { overflow: hidden; text-overflow: ellipsis; }
.chip:hover { text-decoration: none; background: color-mix(in srgb, var(--chip, var(--accent)) 26%, #fff); }
.chip-pending {
  background: #fff;
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--chip, var(--accent)) 45%, #fff);
  background-image: repeating-linear-gradient(45deg, rgba(16, 24, 40, .05) 0 4px, transparent 4px 8px);
}
.chip-pending::before { opacity: .55; }

/* ---------- stats ---------- */
/* Chart marks: one hue for magnitude (identity is not in play), 4px rounded
   data-ends anchored to the baseline, a recessive track behind each bar, and a
   value label beside every mark so colour is never the only thing carrying
   meaning. Leave-type colours are validated for colour-vision separation, but
   the written name always sits next to the swatch regardless. */
.stat-warn { border-color: #f0d9ab; background: var(--warn-bg); }
.stat-warn .stat-value { color: var(--warn-text); }

.banner-warn { background: var(--warn-bg); border-color: #f0d9ab; color: var(--warn-text); }
.banner-warn:hover { background: var(--warn-bg); }

.nowrap { white-space: nowrap; }

/* Horizontal bars inside table rows */
.bar-cell { width: 34%; min-width: 90px; }
.bar-track { background: #eef1f4; border-radius: 4px; height: 8px; overflow: hidden; }
.bar-fill {
  height: 100%; border-radius: 4px; min-width: 2px;
  background: var(--accent);
}

/* Monthly column chart */
.chart-months {
  display: grid; grid-template-columns: repeat(12, 1fr); gap: 2px;
  align-items: end; padding: 1.1rem 1.1rem .4rem; height: 210px;
}
.cm-col { display: flex; flex-direction: column; align-items: center; height: 100%; gap: .25rem; }
.cm-track {
  position: relative; flex: 1; width: 100%; padding-top: 1rem;
  background: linear-gradient(to top, #eef1f4 1px, transparent 1px);
}
/* The value rides on top of its own bar rather than sitting in a detached
   label row, so a number is never read against the wrong column. */
.cm-value {
  position: absolute; left: 0; right: 0; bottom: var(--h, 0%);
  font-size: .72rem; color: var(--muted); font-variant-numeric: tabular-nums;
  line-height: 1; text-align: center; margin-bottom: 3px;
}
.cm-value.is-zero { visibility: hidden; }
.cm-bar {
  position: absolute; left: 0; right: 0; bottom: 0; height: var(--h, 0%);
  background: var(--accent); border-radius: 4px 4px 0 0; min-height: 2px;
}
.cm-col:hover .cm-bar { background: var(--accent-dark); }
.cm-label { font-size: .7rem; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
@media (max-width: 620px) {
  .chart-months { height: 170px; padding-left: .5rem; padding-right: .5rem; }
  .cm-label { font-size: .6rem; }
  .cm-value { font-size: .62rem; }
}
/* Eight columns with names and dates in them: scroll rather than squash. */
.table-people { min-width: 860px; }
.table-people td:first-child { white-space: nowrap; }
