/* Leave Tracker frontend — system sans-serif only, no external requests. */
:root {
  --font: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --ink: #1c2430;
  --muted: #5b6675;
  --line: #d9dee5;
  --bg: #f4f6f8;
  --card: #ffffff;
  --accent: #2563eb;
  --holiday: #efe6c8;
  --weekend: #f0f2f5;
  --red: #b91c1c;
  --amber: #92400e;
  --green: #166534;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  font-size: 14px;
  line-height: 1.45;
}
h1 { font-size: 22px; margin: 0 0 8px; }
h2 { font-size: 19px; margin: 4px 0 14px; }
h3 { font-size: 15px; margin: 0 0 10px; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12px; }

.topbar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 16px; background: #16202e; color: #fff;
}
.brand { font-weight: 700; font-size: 16px; }
.whoami { font-size: 13px; color: #cbd5e1; margin-right: 8px; }

.btn {
  font-family: var(--font); font-size: 13px; cursor: pointer;
  border: 1px solid var(--line); background: #fff; color: var(--ink);
  border-radius: 6px; padding: 6px 12px;
}
.btn:hover { background: #eef2f7; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: #1d4ed8; }
.btn-small { padding: 4px 9px; font-size: 12px; }
.btn-block { width: 100%; margin-top: 10px; }
.btn-danger { border-color: var(--red); color: var(--red); }

/* Gate */
.gate { display: flex; justify-content: center; padding: 48px 16px; }
.gate-card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 24px; width: 100%; max-width: 400px; }
.gate-sub { color: var(--muted); margin: 0 0 16px; }
.gate-tabs { display: flex; gap: 8px; margin-bottom: 16px; }
.gate-tab { flex: 1; font-family: var(--font); padding: 8px; border: 1px solid var(--line); background: #fff; border-radius: 6px; cursor: pointer; }
.gate-tab.active { background: #16202e; color: #fff; border-color: #16202e; }
.gate-form label, .form-grid label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 10px; }
.gate-form input, .form-grid input, .form-grid select, .toolbar input, .toolbar select {
  display: block; width: 100%; margin-top: 4px; font-family: var(--font); font-size: 14px;
  padding: 7px 9px; border: 1px solid var(--line); border-radius: 6px; background: #fff;
}
.toolbar input, .toolbar select { width: auto; display: inline-block; }
.hint { color: var(--muted); font-size: 12px; margin: -6px 0 10px; }
.form-error { background: #fef2f2; border: 1px solid #fecaca; color: var(--red); border-radius: 6px; padding: 8px 10px; margin-bottom: 10px; font-size: 13px; }

/* App shell */
#app { max-width: 1240px; margin: 0 auto; padding: 0 16px 40px; }
.tabbar {
  display: flex; gap: 4px; overflow-x: auto; padding: 12px 0; margin-bottom: 8px;
  border-bottom: 1px solid var(--line); scrollbar-width: thin;
}
.tabbtn {
  font-family: var(--font); white-space: nowrap; cursor: pointer; font-size: 13px;
  border: 1px solid transparent; background: transparent; border-radius: 20px; padding: 6px 13px;
}
.tabbtn.active { background: #16202e; color: #fff; }
.tabpane { padding-top: 8px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 14px; margin-bottom: 14px; }
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 12px; }
.toolbar label { font-size: 12px; font-weight: 600; color: var(--muted); }
.row-between { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 10px; align-items: end; }

.statgrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; margin-bottom: 14px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 12px; }
.stat .num { font-size: 24px; font-weight: 700; }
.stat .lbl { color: var(--muted); font-size: 12px; }

table.data { width: 100%; border-collapse: collapse; background: #fff; font-size: 13px; }
table.data th, table.data td { border-bottom: 1px solid var(--line); padding: 7px 9px; text-align: left; }
table.data th { color: var(--muted); font-size: 12px; cursor: default; }
table.data th.sortable { cursor: pointer; text-decoration: underline; }
table.data tr.clickable { cursor: pointer; }
table.data tr.clickable:hover { background: #f8fafc; }
.badge {
  display: inline-block; font-size: 11px; font-weight: 700; border-radius: 20px; padding: 2px 8px;
  background: #e5e7eb; color: #374151; white-space: nowrap;
}
.badge.pending { background: #fef3c7; color: var(--amber); }
.badge.approved { background: #dcfce7; color: var(--green); }
.badge.denied, .badge.overdrawn { background: #fee2e2; color: var(--red); }
.badge.cancelled { background: #e5e7eb; color: #6b7280; }
.badge.nc { background: #fee2e2; color: var(--red); }
.badge.low { background: #fef3c7; color: var(--amber); }
.badge.ok { background: #dcfce7; color: var(--green); }
.flag { font-size: 11px; color: var(--amber); }

/* Wallchart */
.wc-scroll { overflow-x: auto; overflow-y: auto; max-height: 70vh; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
table.wc { border-collapse: separate; border-spacing: 0; font-size: 12px; }
table.wc th, table.wc td { border-right: 1px solid #eceff3; border-bottom: 1px solid #eceff3; text-align: center; min-width: 30px; height: 30px; padding: 0; }
table.wc th.person, table.wc td.person {
  position: sticky; left: 0; z-index: 2; background: #fff; text-align: left;
  min-width: 132px; max-width: 132px; padding: 0 8px; white-space: nowrap;
}
table.wc thead th { position: sticky; top: 0; z-index: 3; background: #f8fafc; height: auto; padding: 4px 0; }
table.wc thead th.person { z-index: 4; }
table.wc th.today, table.wc td.today { background: #dbeafe !important; outline: 1px solid var(--accent); outline-offset: -1px; }
table.wc th.weekend, table.wc td.weekend { background: var(--weekend); }
table.wc th.holiday, table.wc td.holiday { background: var(--holiday); }
table.wc .daynum { font-weight: 700; display: block; line-height: 1.2; }
table.wc .daylet { color: var(--muted); font-size: 11px; display: block; line-height: 1.2; }
.wc-cell-solid { width: 100%; height: 100%; min-height: 29px; }
.wc-cell-pending { width: 20px; height: 20px; margin: 4px auto; border: 2px solid; border-radius: 4px; background: transparent; }
.person-cell { display: flex; align-items: center; gap: 7px; }
.initials {
  width: 26px; height: 26px; border-radius: 50%; color: #fff; font-weight: 700; font-size: 11px;
  display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.legend { display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 12px; font-size: 12px; }
.legend-item { display: inline-flex; align-items: center; gap: 5px; }
.legend-swatch { width: 14px; height: 14px; border-radius: 3px; display: inline-block; }
.legend-swatch.outline { background: transparent; border: 2px solid #64748b; }
.legend-swatch.holiday { background: var(--holiday); border: 1px solid #d6c58a; }

/* Calendar picker + team calendar */
.picker-box { border: 1px solid var(--line); border-radius: 8px; padding: 12px; margin: 12px 0; background: #fbfcfe; }
.cal-title { font-weight: 700; min-width: 130px; text-align: center; display: inline-block; }
.pk-grid, .cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 3px; }
.pk-dow, .cal-dow { font-size: 11px; font-weight: 700; color: var(--muted); text-align: center; padding: 3px 0; }
.pk-day, .cal-day {
  font-family: var(--font); border: 1px solid var(--line); background: #fff; border-radius: 6px;
  min-height: 40px; padding: 4px; cursor: pointer; text-align: left; font-size: 12px; position: relative;
}
.pk-day:hover { border-color: var(--accent); }
.pk-day.other-month { opacity: 0.35; }
.pk-day.today { outline: 2px solid var(--accent); outline-offset: -1px; }
.pk-day.holiday { background: var(--holiday); }
.pk-day.in-range { background: #dbeafe; border-color: var(--accent); }
.pk-day.range-end { background: var(--accent); color: #fff; }
.pk-day .hol-dot { position: absolute; right: 3px; top: 2px; font-size: 10px; }
.pk-selected { font-weight: 700; margin: 10px 0 2px; }
.cal-day { cursor: default; min-height: 64px; }
.cal-day.today { outline: 2px solid var(--accent); outline-offset: -1px; }
.cal-day.weekend { background: var(--weekend); }
.cal-day.holiday { background: var(--holiday); }
.cal-chip { display: block; font-size: 10px; border-radius: 9px; padding: 1px 5px; margin-top: 2px; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.warn { background: #fffbeb; border: 1px solid #fde68a; color: #92400e; border-radius: 6px; padding: 10px 12px; margin: 10px 0; font-size: 13px; }

/* Modal + toast */
.modal-backdrop { position: fixed; inset: 0; background: rgba(15, 23, 42, 0.55); display: flex; align-items: flex-start; justify-content: center; padding: 40px 16px; z-index: 50; overflow-y: auto; }
.modal { background: #fff; border-radius: 10px; padding: 20px; width: 100%; max-width: 560px; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; flex-wrap: wrap; }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: #16202e; color: #fff; padding: 10px 16px; border-radius: 8px; z-index: 60; font-size: 13px; max-width: 90vw; }

.dash-cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 14px; margin-bottom: 14px; }
.org-node { border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px; margin: 6px 0 6px 0; background: #fff; }
.org-children { margin-left: 24px; border-left: 2px solid var(--line); padding-left: 12px; }
.req-row { background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; margin-bottom: 8px; display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; }

@media (max-width: 640px) {
  #app { padding: 0 8px 32px; }
  table.wc th.person, table.wc td.person { min-width: 108px; max-width: 108px; }
  .cal-day { min-height: 52px; }
  .gate { padding: 24px 12px; }
}
