/* Core One — Time Off (public/timeoff.js): My Time Off, the new-request flow, To Approve, the team calendar, who is out,
   balances and allocations. Colours come from the theme tokens, so light and dark both work; layout uses logical
   properties, so Arabic mirrors without extra rules. Anything only known at run time (a leave type's colour, a bar's width)
   is set from data-bg / data-w by paintStyles(), because the CSP forbids style="". Phone first: every screen is one column
   under 720px, and the tables scroll inside their own box rather than the page. */

.to-page { padding: 18px 16px 72px; max-width: 1100px; margin: 0 auto; }
.to-page.narrow { max-width: 760px; }
.to-h { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin: 22px 0 10px; }
.to-h h2 { font-size: 15px; font-weight: 650; letter-spacing: -.01em; margin: 0; }
.to-h small { color: var(--muted); font-size: 12.5px; }
.to-none { color: var(--muted); font-size: 13px; margin: 6px 0; }
.to-hint { color: var(--muted); font-size: 12px; line-height: 1.45; margin: 4px 0 0; }
.to-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--faint); flex: 0 0 auto; }
.to-chip { display: inline-block; padding: 1px 9px; border-radius: 999px; font-size: 11.5px; line-height: 18px; white-space: nowrap; background: var(--canvas); color: var(--muted); border: 1px solid var(--line-2); }
.to-chip.ok { background: color-mix(in srgb, var(--success) 14%, var(--paper)); color: var(--success); border-color: transparent; }
.to-chip.warn { background: color-mix(in srgb, var(--warn) 15%, var(--paper)); color: var(--warn); border-color: transparent; }
.to-chip.bad { background: color-mix(in srgb, var(--danger) 14%, var(--paper)); color: var(--danger); border-color: transparent; }
.to-req-note.warn { color: var(--warn); }
.to-attach { cursor: pointer; margin-inline-start: 6px; }
.to-chip.info { background: var(--accent-soft); color: var(--accent); border-color: transparent; }

/* balance cards */
.to-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
.to-card { display: flex; flex-direction: column; gap: 6px; padding: 14px 16px; background: var(--paper); border: 1px solid var(--line); border-radius: var(--r-md); box-shadow: var(--e1); text-align: start; color: inherit; font: inherit; cursor: pointer; }
.to-card:hover { box-shadow: var(--e2); border-color: var(--faint); }
.to-card-t { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 13.5px; min-width: 0; }
.to-card-t span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.to-big { font-size: 30px; font-weight: 680; letter-spacing: -.03em; line-height: 1.05; }
.to-big small { font-size: 13px; font-weight: 500; color: var(--muted); letter-spacing: 0; margin-inline-start: 4px; }
.to-big.neg { color: var(--danger); }
.to-sub { color: var(--muted); font-size: 12.5px; line-height: 1.4; }
.to-bar { height: 5px; border-radius: 999px; background: var(--line-2); overflow: hidden; margin-top: 2px; }
.to-bar i { display: block; height: 100%; background: var(--accent); border-radius: 999px; }
.to-bar i.hot { background: var(--warn); }
.to-others { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }

/* the year */
.to-year { display: grid; grid-template-columns: repeat(auto-fill, minmax(176px, 1fr)); gap: 14px; }
.to-mon { background: var(--paper); border: 1px solid var(--line); border-radius: var(--r-md); padding: 10px 12px 12px; }
.to-mon h4 { margin: 0 0 6px; font-size: 12.5px; font-weight: 640; color: var(--ink-2); }
.to-days { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.to-days b { font-size: 9.5px; font-weight: 500; color: var(--faint); text-align: center; }
.to-d { aspect-ratio: 1; border-radius: 4px; font-size: 10px; display: grid; place-items: center; color: var(--ink-2); cursor: pointer; border: 0; background: transparent; padding: 0; font-family: inherit; }
.to-d:hover { background: var(--canvas); }
.to-d.off { color: var(--faint); cursor: default; background: color-mix(in srgb, var(--line-2) 60%, transparent); }
.to-d.hol { color: var(--faint); background: color-mix(in srgb, var(--warn) 14%, var(--paper)); cursor: default; }
.to-d.today { outline: 1.5px solid var(--accent); outline-offset: -1px; font-weight: 700; }
.to-d.abs { color: #fff; font-weight: 600; }
.to-d.abs.half { background-image: linear-gradient(90deg, transparent 50%, color-mix(in srgb, var(--paper) 55%, transparent) 50%); }
.to-d.abs.pend { background-image: repeating-linear-gradient(135deg, transparent 0 3px, color-mix(in srgb, var(--paper) 45%, transparent) 3px 5px); }
.to-d.blank { visibility: hidden; }
.to-legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 12px; color: var(--muted); margin-top: 8px; }
.to-legend span { display: inline-flex; align-items: center; gap: 6px; }

/* requests */
.to-list { display: flex; flex-direction: column; gap: 8px; }
.to-req { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px 12px; align-items: center; padding: 11px 14px; background: var(--paper); border: 1px solid var(--line); border-radius: var(--r-md); }
.to-req-t { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.to-req-t b { font-weight: 600; font-size: 13.5px; }
.to-req-t small { color: var(--muted); font-size: 12.5px; }
.to-req-a { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; align-items: center; }
.to-req-note { grid-column: 1 / -1; font-size: 12.5px; color: var(--ink-2); background: var(--canvas); border-radius: var(--r-xs); padding: 6px 9px; }
.to-req-note.bad { color: var(--danger); }
.to-person { display: flex; align-items: center; gap: 10px; min-width: 0; }

/* the new-request flow */
.to-form { display: flex; flex-direction: column; gap: 16px; }
.to-box { background: var(--paper); border: 1px solid var(--line); border-radius: var(--r-md); box-shadow: var(--e1); padding: 16px 18px; }
.to-box h3 { font-size: 13px; font-weight: 640; margin: 0 0 10px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.to-types { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.to-type { display: flex; flex-direction: column; gap: 2px; align-items: flex-start; padding: 9px 11px; border: 1px solid var(--line); border-radius: var(--r-xs); background: var(--paper); color: inherit; font: inherit; text-align: start; cursor: pointer; }
.to-type small { color: var(--muted); font-size: 12px; }
.to-type.on { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.to-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; align-items: end; }
.to-gap { height: 10px; }
.to-lab.row { flex-direction: row; gap: 8px; align-items: center; }
.to-row label, .to-lab { display: flex; flex-direction: column; gap: 4px; font-size: 12.5px; color: var(--muted); }
.to-row input, .to-row select, .to-row textarea, .to-box textarea, .to-box select, .to-box input[type=text], .to-box input[type=number], .to-box input[type=date] { font: inherit; color: var(--ink); background: var(--paper); border: 1px solid var(--line); border-radius: var(--r-xs); padding: 8px 10px; min-width: 0; width: 100%; box-sizing: border-box; }
.to-seg { display: inline-flex; border: 1px solid var(--line); border-radius: var(--r-xs); overflow: hidden; flex-wrap: wrap; }
.to-seg button { border: 0; background: var(--paper); color: var(--ink-2); font: inherit; padding: 7px 12px; cursor: pointer; border-inline-end: 1px solid var(--line); }
.to-seg button:last-child { border-inline-end: 0; }
.to-seg button.on { background: var(--accent); color: #fff; }
.to-preview { border-radius: var(--r-md); padding: 14px 16px; background: var(--canvas); border: 1px solid var(--line-2); display: flex; flex-direction: column; gap: 6px; font-size: 13.5px; }
.to-preview.bad { border-color: color-mix(in srgb, var(--danger) 40%, var(--line)); }
.to-preview .big { font-size: 15px; font-weight: 640; }
.to-preview ul { margin: 2px 0 0; padding-inline-start: 18px; }
.to-preview li.bad { color: var(--danger); } .to-preview li.warn { color: var(--warn); }
.to-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }

/* To Approve */
.to-appr { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 4px 12px; padding: 14px 16px; background: var(--paper); border: 1px solid var(--line); border-radius: var(--r-md); }
.to-appr.sel { border-color: var(--accent); }
.to-chk { display: flex; align-items: flex-start; padding-top: 6px; }
.to-appr-m { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.to-appr-l { display: flex; flex-wrap: wrap; gap: 4px 8px; align-items: center; font-size: 13px; }
.to-appr-a { grid-column: 2; display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; }
.to-warn { color: var(--warn); font-size: 12.5px; } .to-bad { color: var(--danger); font-size: 12.5px; }
.to-bulk { position: sticky; bottom: 0; z-index: 4; display: flex; gap: 10px; align-items: center; justify-content: space-between; padding: 10px 14px; margin-top: 12px; background: var(--paper); border: 1px solid var(--line); border-radius: var(--r-md); box-shadow: var(--e2); }

/* the calendar */
.to-cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; margin-top: 16px; align-items: start; }
.to-search { font: inherit; padding: 6px 10px; border: 1px solid var(--line); border-radius: var(--r-xs); background: var(--paper); color: var(--ink); min-width: 0; flex: 1 1 160px; max-width: 280px; }
.to-tools { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 12px; }
.to-inline { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--muted); }
.to-inline input { font: inherit; padding: 5px 8px; border: 1px solid var(--line); border-radius: var(--r-xs); background: var(--paper); color: var(--ink); }
.to-tools select { font: inherit; padding: 6px 8px; border: 1px solid var(--line); border-radius: var(--r-xs); background: var(--paper); color: var(--ink); max-width: 100%; }
.to-scroll { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--r-md); background: var(--paper); }
.to-cal { border-collapse: separate; border-spacing: 0; width: 100%; font-size: 12px; }
.to-cal th, .to-cal td { padding: 0; text-align: center; border-bottom: 1px solid var(--line-2); min-width: 28px; height: 30px; }
.to-cal th { font-weight: 500; color: var(--muted); height: 40px; line-height: 1.15; }
.to-cal th.today { color: var(--accent); font-weight: 700; }
.to-cal th small { display: block; font-size: 10px; color: var(--faint); }
.to-cal td.who, .to-cal th.who { position: sticky; inset-inline-start: 0; z-index: 2; background: var(--paper); text-align: start; padding-inline: 10px; min-width: 150px; max-width: 190px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; border-inline-end: 1px solid var(--line-2); }
.to-cal td.off { background: color-mix(in srgb, var(--line-2) 55%, transparent); }
.to-cal td.hol { background: color-mix(in srgb, var(--warn) 12%, var(--paper)); }
.to-cal td.today { box-shadow: inset 0 0 0 1px var(--accent); }
.to-cal td i { display: block; height: 18px; margin: 0 -1px; background: var(--faint); }
.to-cal td i.away { background: color-mix(in srgb, var(--muted) 45%, var(--paper)); }
.to-cal td i.half { height: 9px; }
.to-cal td i.pend { background-image: repeating-linear-gradient(135deg, transparent 0 3px, color-mix(in srgb, var(--paper) 55%, transparent) 3px 5px); }
.to-agenda { display: none; }
.to-day-h { font-size: 12px; font-weight: 640; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 14px 0 6px; }

/* tables */
.to-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.to-table th { text-align: start; font-weight: 600; color: var(--muted); font-size: 12px; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.to-table td { padding: 8px 10px; border-bottom: 1px solid var(--line-2); }
.to-table .r { text-align: end; font-variant-numeric: tabular-nums; }
.to-table tr.link { cursor: pointer; } .to-table tr.link:hover { background: var(--canvas); }
.to-table .neg { color: var(--danger); font-weight: 600; }
.to-seclist { display: flex; flex-direction: column; }
.to-checks { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 4px 12px; max-height: 220px; overflow: auto; border: 1px solid var(--line); border-radius: var(--r-xs); padding: 8px 10px; }
.to-checks label { display: flex; gap: 7px; align-items: center; font-size: 13px; color: var(--ink); }

@media (max-width: 720px) {
  .to-page { padding: 12px 12px 90px; }
  .to-big { font-size: 26px; }
  .to-req { grid-template-columns: 1fr; }
  .to-req-a { justify-content: flex-start; }
  .to-appr { grid-template-columns: auto minmax(0, 1fr); padding: 12px; }
  .to-appr-a .btn { flex: 1 1 auto; min-height: 40px; }
  .to-bulk { bottom: 56px; }
  .to-agenda.on { display: block; }
  .to-scroll.gridview { display: none; }
  .to-scroll.gridview.on { display: block; }
  .to-table-wrap { overflow-x: auto; }
}
@media (min-width: 721px) { .to-viewtoggle { display: none; } }
.to-dim { opacity: .55; }
.warncard .to-table td { border-color: color-mix(in srgb, var(--warn) 25%, var(--line-2)); }
.to-alerts { margin: 4px 0 10px; padding-inline-start: 18px; font-size: 13px; }
.to-alerts li { margin: 3px 0; }
