:root {
  --bg: #f3f4f6; --card: #fff; --ink: #111827; --muted: #6b7280; --line: #cbd5e1;
  --brand: #14315c; --brand2: #1d4f91; --ok: #166534; --bad: #b91c1c; --warn: #b45309;
  --sun: #bcd3f2; --sat: #eef2f7; --me: #fff3bf;
}
* { box-sizing: border-box; }
body { margin: 0; font: 15px/1.4 system-ui, -apple-system, Segoe UI, Roboto, sans-serif; background: var(--bg); color: var(--ink); }
button, input, select, textarea { font: inherit; }
header.top { background: var(--brand); color: #fff; padding: 10px 14px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
header.top h1 { font-size: 18px; margin: 0; flex: 1; white-space: nowrap; }
header.top .who { font-size: 13px; opacity: .9; }
nav.tabs { background: #fff; border-bottom: 1px solid var(--line); display: flex; overflow-x: auto; position: sticky; top: 0; z-index: 20; }
nav.tabs button { border: 0; background: none; padding: 12px 14px; cursor: pointer; white-space: nowrap; border-bottom: 3px solid transparent; color: var(--muted); font-weight: 600; }
nav.tabs button.on { color: var(--brand); border-color: var(--brand2); }
nav.tabs .badge { background: var(--bad); color: #fff; border-radius: 9px; padding: 0 6px; font-size: 12px; margin-left: 4px; }
main { padding: 12px; max-width: 1500px; margin: 0 auto; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 12px; margin-bottom: 12px; }
.card h2 { margin: 0 0 8px; font-size: 16px; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.grow { flex: 1; }
.muted { color: var(--muted); font-size: 13px; }
.btn { border: 1px solid var(--brand2); background: var(--brand2); color: #fff; border-radius: 6px; padding: 7px 12px; cursor: pointer; font-weight: 600; }
.btn.sec { background: #fff; color: var(--brand2); }
.btn.ok { background: var(--ok); border-color: var(--ok); }
.btn.bad { background: var(--bad); border-color: var(--bad); }
.btn.sm { padding: 3px 8px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
input, select, textarea { border: 1px solid var(--line); border-radius: 6px; padding: 7px 9px; background: #fff; max-width: 100%; }
textarea { width: 100%; min-height: 70px; }
label.f { display: block; font-size: 13px; color: var(--muted); margin: 8px 0 3px; }

/* login */
.login { max-width: 380px; margin: 40px auto; }
.seg { display: flex; border: 1px solid var(--brand2); border-radius: 6px; overflow: hidden; margin-bottom: 12px; }
.seg button { flex: 1; padding: 8px; border: 0; background: #fff; color: var(--brand2); font-weight: 600; cursor: pointer; }
.seg button.on { background: var(--brand2); color: #fff; }
.login input { width: 100%; margin-bottom: 8px; font-size: 18px; }
.err { color: var(--bad); font-size: 14px; min-height: 20px; }

/* schedule grid */
.gridwrap { overflow: auto; max-height: 75vh; border: 1px solid #111; background: #fff; }
table.grid { border-collapse: collapse; font-size: 14px; min-width: 100%; }
table.grid th, table.grid td { border: 1px solid #555; text-align: center; min-width: 30px; height: 28px; padding: 0 2px; }
table.grid thead th { background: #fff; position: sticky; z-index: 2; font-weight: 600; }
table.grid thead tr:nth-child(1) th { top: 0; }
table.grid thead tr:nth-child(2) th { top: 28px; }
table.grid th.who { position: sticky; left: 0; z-index: 3; background: #fff; min-width: 74px; text-align: left; padding: 0 6px; }
table.grid thead th.who { z-index: 4; }
table.grid tbody th.who small { display: block; font-weight: 400; color: var(--muted); font-size: 10px; line-height: 1; }
table.grid tr.me th.who, table.grid tr.me td { background: var(--me); }
.sun { background: var(--sun) !important; }
.wkend:not(th) { background: var(--sat); }
table.grid tr.me td.wkend { background: #f5e9b0; }
.hol { color: var(--bad); }
.today { outline: 3px solid #f59e0b; outline-offset: -3px; }
td.c { cursor: default; font-weight: 600; }
td.c-V, td.c-H { color: var(--bad); }
td.c-T { background: #ffe94d !important; }
td.c-W { background: #f4b183 !important; }
td.c-PAR { background: #bfbfbf !important; }
td.c-P { background: #d9f2d0 !important; }
td.c-X { color: #555; }
body.editing td.c, body.editing td.e { cursor: pointer; }
body.editing td.c:hover, body.editing td.e:hover { background: #fde68a !important; }
.legend { display: flex; gap: 6px 14px; flex-wrap: wrap; font-size: 13px; margin: 8px 0; }
.legend span b { display: inline-block; min-width: 22px; text-align: center; border: 1px solid #555; padding: 0 3px; margin-right: 4px; background: #fff; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { border: 1px solid var(--line); border-radius: 16px; padding: 4px 10px; background: #fff; cursor: pointer; font-size: 14px; }
.chip.on { background: var(--brand2); color: #fff; border-color: var(--brand2); }
.chip:disabled { opacity: .4; cursor: not-allowed; text-decoration: line-through; }

/* tables / lists */
table.t { border-collapse: collapse; width: 100%; font-size: 14px; }
table.t th, table.t td { border-bottom: 1px solid #e5e7eb; padding: 6px 8px; text-align: left; vertical-align: top; }
table.t th { background: #f9fafb; position: sticky; top: 0; }
.tablewrap { overflow-x: auto; }
.st { display: inline-block; padding: 1px 8px; border-radius: 10px; font-size: 12px; font-weight: 600; background: #e5e7eb; }
.st.pending { background: #fef3c7; color: var(--warn); }
.st.open { background: #dbeafe; color: #1e40af; }
.st.completed, .st.approved { background: #dcfce7; color: var(--ok); }
.st.denied, .st.cancelled, .st.withdrawn { background: #fee2e2; color: var(--bad); }
.item { border: 1px solid var(--line); border-radius: 8px; padding: 10px; margin-bottom: 8px; background: #fff; }
.item .head { font-weight: 700; }
.kpis { display: flex; gap: 8px; flex-wrap: wrap; }
.kpi { background: #f3f4f6; border-radius: 6px; padding: 6px 10px; font-size: 13px; }
.kpi b { font-size: 18px; display: block; }

/* modal + toast */
.modal-bg { position: fixed; inset: 0; background: rgba(0,0,0,.45); display: flex; align-items: flex-start; justify-content: center; padding: 30px 12px; z-index: 50; overflow: auto; }
.modal { background: #fff; border-radius: 10px; padding: 16px; width: 100%; max-width: 460px; }
.modal h3 { margin: 0 0 8px; }
#toast { position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%); background: #111827; color: #fff; padding: 9px 16px; border-radius: 8px; opacity: 0; transition: opacity .2s; pointer-events: none; z-index: 99; max-width: 90vw; }
#toast.show { opacity: 1; }
#toast.err { background: var(--bad); }
.pin { font: 700 28px ui-monospace, monospace; letter-spacing: 4px; text-align: center; padding: 10px; background: #f3f4f6; border-radius: 8px; }
@media (max-width: 600px) { main { padding: 8px; } table.grid { font-size: 13px; } }
@media print { header.top, nav.tabs, .noprint { display: none !important; } .gridwrap { max-height: none; overflow: visible; } }
