/* Leave System - one stylesheet. --brand is set from Settings → Main color. */
:root {
  --brand: #0b3b8c;
  --bg: #f3f5f9;
  --surface: #ffffff;
  --text: #1a2333;
  --muted: #667085;
  --line: #dfe4ec;
  --soft: #f6f8fb;
  --ok: #1e7e34;
  --ok-bg: #e7f5ec;
  --warn: #9a6700;
  --warn-bg: #fff6dd;
  --bad: #c62828;
  --bad-bg: #fdecea;
  --grey: #5f6b7a;
  --grey-bg: #eef0f3;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  --sidebar: 248px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); }
h1 { font-size: 1.5rem; margin: 0; letter-spacing: -.01em; }
h2 { font-size: 1.05rem; margin: 0 0 12px; }
a { color: var(--brand); }
code, .code { font-family: ui-monospace, Consolas, monospace; font-size: .85em; }
.code { display: block; background: var(--soft); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; overflow-x: auto; white-space: pre; }
.muted { color: var(--muted); }
.small { font-size: .82rem; }
.error, .neg { color: var(--bad); }
.spacer { flex: 1; }
[hidden] { display: none !important; }
.ico { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* ---------- buttons and inputs */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--line); background: var(--surface); color: var(--text);
  border-radius: 8px; padding: 8px 14px; font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; white-space: nowrap;
}
.btn:hover { background: var(--soft); }
.btn:disabled { opacity: .6; cursor: wait; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand); filter: brightness(1.08); }
.btn-success { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn-success:hover { background: var(--ok); filter: brightness(1.08); }
.btn-danger { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn-danger:hover { background: var(--bad); filter: brightness(1.08); }
.btn-danger-outline { color: var(--bad); border-color: #f1c4c0; }
.btn-small { padding: 4px 10px; font-size: .85rem; }
.btn-block { width: 100%; padding: 11px; }
.link { background: none; border: 0; padding: 0; color: var(--brand); font: inherit; font-weight: 600; cursor: pointer; text-align: left; }
.link:hover { text-decoration: underline; }
.icon-btn { background: none; border: 0; padding: 6px; border-radius: 8px; cursor: pointer; color: inherit; font-size: 1.4rem; line-height: 1; }
.icon-btn:hover { background: var(--soft); }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

input, select, textarea {
  font: inherit; color: inherit; background: var(--surface);
  border: 1px solid #cfd6e2; border-radius: 8px; padding: 8px 10px; min-height: 38px; max-width: 100%;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 18%, transparent); }
input[type=checkbox], input[type=radio] { min-height: 0; width: 16px; height: 16px; accent-color: var(--brand); }
input[type=color] { padding: 2px; width: 70px; }
textarea { resize: vertical; width: 100%; }
.field { display: flex; flex-direction: column; gap: 5px; border: 0; padding: 0; margin: 0; min-width: 0; }
.field > span { font-weight: 600; font-size: .88rem; }
.field small { color: var(--muted); font-size: .8rem; }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
.check small { display: block; color: var(--muted); }
.multi { display: flex; flex-wrap: wrap; gap: 8px 18px; max-height: 260px; overflow-y: auto; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 18px; }
.form-grid .full { grid-column: 1 / -1; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.form-error { color: var(--bad); background: var(--bad-bg); border-radius: 8px; padding: 8px 12px; margin: 0; }
.inline { display: inline-flex; align-items: center; gap: 6px; font-size: .88rem; color: var(--muted); }

.segmented { display: inline-flex; flex-wrap: wrap; border: 1px solid #cfd6e2; border-radius: 9px; overflow: hidden; width: fit-content; }
.segmented label { cursor: pointer; }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented span { display: block; padding: 7px 14px; font-weight: 600; font-size: .88rem; border-right: 1px solid #cfd6e2; }
.segmented label:last-child span { border-right: 0; }
.segmented input:checked + span { background: var(--brand); color: #fff; }
.segmented input:focus-visible + span { outline: 2px solid var(--brand); outline-offset: -3px; }
.date-list { display: flex; flex-wrap: wrap; gap: 8px; }
.summary { margin: 0; font-weight: 600; color: var(--brand); min-height: 1.5em; }

/* ---------- layout */
.shell { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar); flex: none; background: var(--surface); border-right: 1px solid var(--line);
  position: sticky; top: 0; height: 100vh; overflow-y: auto; padding: 16px 12px;
}
.brand, .auth-brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 18px; }
.brand img, .auth-brand img { width: 40px; height: 40px; object-fit: contain; border-radius: 8px; }
.brand strong, .auth-brand strong { display: block; line-height: 1.2; }
.brand small, .auth-brand small { color: var(--muted); }
.brand-mark { width: 40px; height: 40px; border-radius: 10px; background: var(--brand); color: #fff; display: grid; place-items: center; font-weight: 800; font-size: 1.1rem; flex: none; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 8px; color: var(--text); text-decoration: none; font-weight: 500; }
.nav a:hover { background: var(--soft); }
.nav a.active { background: color-mix(in srgb, var(--brand) 10%, transparent); color: var(--brand); font-weight: 700; }
.nav-group { font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: 16px 10px 6px; font-weight: 700; }
.nav-badge { margin-left: auto; background: var(--bad); color: #fff; font-style: normal; font-size: .72rem; font-weight: 700; border-radius: 999px; padding: 1px 7px; }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 10px; background: color-mix(in srgb, var(--bg) 85%, transparent); backdrop-filter: blur(6px); padding: 10px 28px; border-bottom: 1px solid var(--line); }
.menu-btn { display: none; }
.user-menu { position: relative; }
.user-btn { display: flex; align-items: center; gap: 10px; background: none; border: 0; cursor: pointer; padding: 4px 8px; border-radius: 10px; font: inherit; color: inherit; text-align: left; }
.user-btn:hover { background: var(--surface); }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--brand); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: .82rem; }
.user-text b { display: block; font-size: .9rem; line-height: 1.2; }
.user-text small { color: var(--muted); }
.dropdown { position: absolute; right: 0; top: calc(100% + 6px); background: var(--surface); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 12px 28px rgba(16, 24, 40, .14); min-width: 190px; padding: 6px; z-index: 30; }
.dropdown a, .dropdown button { display: flex; align-items: center; gap: 8px; width: 100%; padding: 8px 10px; border-radius: 7px; background: none; border: 0; font: inherit; color: var(--text); text-decoration: none; cursor: pointer; }
.dropdown a:hover, .dropdown button:hover { background: var(--soft); }
.view { padding: 24px 28px 48px; max-width: 1280px; width: 100%; outline: none; }
.scrim { display: none; }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 14px; flex-wrap: wrap; margin-bottom: 18px; }
.page-head p { margin: 4px 0 0; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px 20px; margin-bottom: 18px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; }
.card-head h2, .card-head p { margin: 0; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 0 18px; }
.grid-apply { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(280px, 1fr); gap: 18px; align-items: start; }
.notice { display: block; background: var(--warn-bg); color: #5c4400; border: 1px solid #f3dfa0; border-radius: var(--radius); padding: 12px 16px; margin-bottom: 18px; text-decoration: none; }
.notice-action { background: color-mix(in srgb, var(--brand) 8%, white); border-color: color-mix(in srgb, var(--brand) 25%, white); color: var(--brand); font-weight: 600; }
.loading { display: flex; align-items: center; gap: 10px; color: var(--muted); padding: 24px 4px; }
.page-loading { justify-content: center; min-height: 60vh; }
.spinner { width: 18px; height: 18px; border: 2px solid var(--line); border-top-color: var(--brand); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.empty { text-align: center; color: var(--muted); padding: 28px 12px; }

/* ---------- sign-in pages */
.center-page { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px;
  background: radial-gradient(circle at 20% 0%, color-mix(in srgb, var(--brand) 22%, transparent), transparent 55%), var(--bg); }
.auth-card { width: 100%; max-width: 420px; padding: 28px; margin: 0; }
.auth-card h1 { margin-bottom: 6px; }
.auth-card > .muted { margin-top: 0; }
.auth-card form { margin-top: 18px; }

/* ---------- public request page (/request) */
.request-page { place-items: start center; }
.request-card { width: 100%; max-width: 560px; padding: 28px; margin: 24px 0; }
.request-card h1 { margin-bottom: 4px; }
.request-card .form-grid { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.email-saved { background: var(--soft); border: 1px solid var(--line); border-radius: 8px; padding: 9px 12px; display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center; }
.done { text-align: center; padding: 10px 0; }
.done-mark { width: 64px; height: 64px; margin: 6px auto 14px; border-radius: 50%; background: var(--ok-bg); color: var(--ok); display: grid; place-items: center; font-size: 2rem; font-weight: 800; }
@media (max-width: 640px) { .request-card { padding: 20px 16px; margin: 0; } }

/* ---------- balance */
.balance-total { display: flex; justify-content: space-between; align-items: flex-end; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.balance-total strong { font-size: 2rem; margin: 0 6px; color: var(--brand); }
.balance-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
.bal-card { border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; background: var(--soft); display: flex; flex-direction: column; }
.bal-title { font-weight: 600; font-size: .85rem; }
.bal-card strong { font-size: 1.6rem; line-height: 1.2; }
.meter { height: 6px; background: var(--line); border-radius: 99px; overflow: hidden; margin-top: 8px; }
.meter span { display: block; height: 100%; background: var(--brand); border-radius: 99px; }
.meter span.high { background: #e0a100; }
.meter span.full { background: var(--bad); }

/* ---------- tables */
.table-wrap { overflow-x: auto; margin: 0 -4px; }
.table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.table th { text-align: left; font-size: .76rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 700; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: 10px; border-bottom: 1px solid #edf0f5; vertical-align: top; }
.table tbody tr:hover { background: #fafbfd; }
.table .num { text-align: center; }
.table .sel { width: 34px; }
.table .actions { text-align: right; white-space: nowrap; }
.matrix td:first-child { min-width: 260px; }
.group-row th { background: var(--soft); color: var(--text); padding-top: 12px; }
.people { list-style: none; margin: 0; padding: 0; }
.people li { display: flex; flex-direction: column; padding: 9px 0; border-bottom: 1px solid #edf0f5; }
.people li:last-child { border-bottom: 0; }

.badge { display: inline-block; font-size: .75rem; font-weight: 700; padding: 2px 9px; border-radius: 999px; white-space: nowrap; }
.badge-pending { background: var(--warn-bg); color: var(--warn); }
.badge-approved { background: var(--ok-bg); color: var(--ok); }
.badge-rejected { background: var(--bad-bg); color: var(--bad); }
.badge-cancelled { background: var(--grey-bg); color: var(--grey); }

.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; padding: 12px 14px; }
.filters input[type=search] { flex: 1 1 240px; }
.bulk { position: sticky; top: 60px; z-index: 10; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; background: var(--text); color: #fff; border-radius: 10px; padding: 8px 14px; margin-bottom: 12px; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 18px; overflow-x: auto; }
.tabs a { padding: 9px 14px; text-decoration: none; color: var(--muted); font-weight: 600; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs a.active { color: var(--brand); border-bottom-color: var(--brand); }

/* ---------- details / dialogs / toasts */
.details { display: flex; flex-direction: column; }
.kv { display: grid; grid-template-columns: 140px 1fr; gap: 10px; padding: 8px 0; border-bottom: 1px solid #edf0f5; }
.kv > span { color: var(--muted); font-size: .88rem; }
.modal-backdrop { position: fixed; inset: 0; background: rgba(16, 24, 40, .45); display: grid; place-items: center; padding: 16px; z-index: 100; animation: fade .15s ease; }
.modal { background: var(--surface); border-radius: 14px; width: 100%; max-width: 520px; max-height: calc(100vh - 32px); overflow-y: auto; box-shadow: 0 24px 48px rgba(16, 24, 40, .25); animation: rise .18s ease; }
.modal-wide { max-width: 860px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--surface); }
.modal-head h2 { margin: 0; }
.modal-body { padding: 18px 20px 20px; }
.modal-body > p:first-child { margin-top: 0; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; margin-top: 18px; }
#toasts { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 200; max-width: min(420px, calc(100vw - 32px)); }
.toast { background: var(--text); color: #fff; padding: 11px 16px; border-radius: 10px; box-shadow: 0 10px 24px rgba(16, 24, 40, .2); transition: opacity .3s, transform .3s; border-left: 4px solid var(--ok); }
.toast-error { border-left-color: #ff6b5e; }
.toast.hide { opacity: 0; transform: translateY(8px); }
@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } }

/* ---------- calendar */
.cal-toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.cal-toolbar h2 { margin: 0 6px; min-width: 150px; text-align: center; }
.cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); border-top: 1px solid var(--line); border-left: 1px solid var(--line); }
.cal-head { font-size: .75rem; font-weight: 700; text-transform: uppercase; color: var(--muted); padding: 6px 8px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); background: var(--soft); }
.cal-cell { min-height: 96px; padding: 6px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.cal-cell.off { background: #f8f9fb; }
.cal-cell.empty { background: #fbfbfc; }
.cal-cell.today .cal-date { background: var(--brand); color: #fff; border-radius: 6px; padding: 0 6px; width: fit-content; }
.cal-date { font-weight: 700; font-size: .85rem; display: flex; gap: 6px; align-items: baseline; flex-wrap: wrap; }
.hol { font-size: .7rem; color: var(--bad); font-weight: 600; }
.chip { display: block; font-size: .74rem; font-weight: 600; padding: 2px 6px; border-radius: 5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal-agenda .chip { display: inline-block; margin: 3px 3px 0 0; }
.chip-approved { background: color-mix(in srgb, var(--brand) 14%, white); color: var(--brand); }
.chip-pending { background: repeating-linear-gradient(45deg, var(--warn-bg), var(--warn-bg) 5px, #fff 5px, #fff 10px); color: var(--warn); border: 1px dashed #e8c766; }
.cal-agenda { display: none; list-style: none; padding: 0; margin: 0; }
.cal-agenda li { padding: 10px 0; border-bottom: 1px solid #edf0f5; }

.print-only { display: none; }

/* ---------- phones and tablets */
@media (max-width: 900px) {
  .grid-apply { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; top: 0; z-index: 50; transform: translateX(-100%); transition: transform .2s ease; box-shadow: 0 0 40px rgba(0, 0, 0, .2); }
  .nav-open .sidebar { transform: none; }
  .nav-open .scrim { display: block; position: fixed; inset: 0; background: rgba(16, 24, 40, .35); z-index: 40; }
  .menu-btn { display: inline-flex; }
  .topbar { padding: 8px 16px; }
  .view { padding: 18px 16px 40px; }
}
@media (max-width: 640px) {
  .form-grid { grid-template-columns: 1fr; }
  .grid-2 { grid-template-columns: 1fr; }
  .user-text { display: none; }
  .card { padding: 14px; }
  .kv { grid-template-columns: 1fr; gap: 2px; }
  .cal-grid { display: none; }
  .cal-agenda { display: block; }
  /* tables become cards */
  .table thead { display: none; }
  .table, .table tbody, .table tr, .table td { display: block; width: 100%; }
  .table tr { border: 1px solid var(--line); border-radius: 10px; margin-bottom: 10px; padding: 6px 10px; }
  .table td { border: 0; padding: 4px 0; display: flex; gap: 10px; text-align: left !important; }
  .table td::before { content: attr(data-label); flex: 0 0 110px; color: var(--muted); font-size: .78rem; font-weight: 600; }
  .table td.sel::before, .table td.actions::before, .table td[data-label=""]::before { content: none; }
  .table td.actions { justify-content: flex-end; flex-wrap: wrap; }
  .table-wrap { margin: 0; }
}

/* ---------- print (Reports → Print / Save PDF) */
@media print {
  .sidebar, .topbar, .no-print, .page-actions, .bulk, #toasts { display: none !important; }
  .print-only { display: block; }
  body, .view { background: #fff; padding: 0; }
  .card { box-shadow: none; border: 0; padding: 0; }
  .table { font-size: 10pt; }
  .table td, .table th { border: 1px solid #ccc; padding: 4px 6px; }
}
