/* Sun & Moon Staff — brand: Butter Yellow #efe0a9, Sky Blue #a3c2e6, Brown Red #8f4420, Black, White.
   Vollkorn for headings, Nunito Sans for text. Flat colour, no gradients. */
:root {
  --yellow: #efe0a9;
  --blue: #a3c2e6;
  --brown: #8f4420;
  --black: #000;
  --white: #fff;
  --ink: #1d1a16;
  --muted: #6b5f52;
  --line: #e4d6a4;
  --paper: #fbf6e4;
  --bad: #b3261e;
  --radius: 10px;
  font-family: 'Nunito Sans', system-ui, sans-serif;
  color: var(--ink);
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--paper); min-height: 100vh; font-size: 15px; line-height: 1.45; }
h1, h2, h3 { font-family: 'Vollkorn', Georgia, serif; font-weight: 700; margin: 0 0 .5em; letter-spacing: .01em; }
h1 { font-size: 1.7rem; text-transform: uppercase; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.05rem; font-weight: 500; }
a { color: var(--brown); }
.muted { color: var(--muted); }
.error { color: var(--bad); font-weight: 600; }
small { font-size: .8em; }
button, input, select, textarea { font: inherit; color: inherit; }

/* ---------- buttons & forms ---------- */
.btn {
  display: inline-flex; align-items: center; gap: .4em; padding: .55em 1em; border-radius: 999px;
  border: 1.5px solid var(--black); background: var(--white); cursor: pointer; font-weight: 700; font-size: .9rem;
  text-decoration: none; color: var(--ink); white-space: nowrap;
}
.btn:hover { background: var(--yellow); }
.btn.primary { background: var(--brown); border-color: var(--brown); color: var(--yellow); }
.btn.primary:hover { background: #7a3a1b; }
.btn.blue { background: var(--blue); }
.btn.danger { border-color: var(--bad); color: var(--bad); }
.btn.small { padding: .3em .75em; font-size: .82rem; }
.btn:disabled { opacity: .5; cursor: default; }
.btn:focus-visible, .cell:focus-visible, input:focus-visible, select:focus-visible { outline: 3px solid var(--blue); outline-offset: 1px; }
label { display: flex; flex-direction: column; gap: .25em; font-weight: 600; font-size: .9rem; margin-bottom: .8em; }
input, select, textarea {
  padding: .55em .7em; border: 1.5px solid #cbbd8a; border-radius: 8px; background: var(--white); font-weight: 400; min-width: 0;
}
textarea { resize: vertical; min-height: 4em; }
.row { display: flex; gap: .6em; flex-wrap: wrap; align-items: center; }
.row.end { justify-content: flex-end; }
.grow { flex: 1; }
.check { flex-direction: row; align-items: center; gap: .5em; font-weight: 600; }

/* ---------- auth pages ---------- */
.auth-body { background: var(--yellow); display: grid; place-items: center; padding: 1.5rem; }
.auth-card { background: var(--white); border: 2px solid var(--black); border-radius: 16px; padding: 2rem; width: 100%; max-width: 420px; }
.auth-card form { margin-top: 1.2rem; }
.auth-logo { width: 72px; height: 72px; display: block; margin: 0 auto 1rem; }
.auth-card h1 { text-align: center; }
.auth-card .row { margin-top: .5rem; }

/* ---------- shell ---------- */
.top {
  background: var(--brown); color: var(--yellow); display: flex; align-items: center; gap: 1rem; padding: .6rem 1.2rem;
  position: sticky; top: 0; z-index: 20; flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: .6rem; color: var(--yellow); text-decoration: none; }
.brand img { width: 38px; height: 38px; background: var(--yellow); border-radius: 50%; padding: 3px; }
.brand span { font-family: 'Vollkorn', serif; font-weight: 700; font-size: 1.1rem; letter-spacing: .06em; text-transform: uppercase; }
.top nav { display: flex; gap: .2rem; flex-wrap: wrap; flex: 1; }
.top nav a { color: var(--yellow); text-decoration: none; padding: .4em .8em; border-radius: 999px; font-weight: 700; font-size: .92rem; position: relative; }
.top nav a:hover { background: rgba(239, 224, 169, .15); }
.top nav a.on { background: var(--yellow); color: var(--brown); }
.badge { display: inline-block; min-width: 1.4em; padding: 0 .4em; border-radius: 999px; background: var(--blue); color: var(--black); font-size: .75rem; text-align: center; margin-left: .3em; }
.who { display: flex; align-items: center; gap: .6rem; font-size: .9rem; }
.who .btn { border-color: var(--yellow); background: transparent; color: var(--yellow); }
.who .btn:hover { background: var(--yellow); color: var(--brown); }
main#view { padding: 1.4rem; max-width: 1400px; margin: 0 auto; }
.card { background: var(--white); border: 1.5px solid var(--line); border-radius: var(--radius); padding: 1.2rem; margin-bottom: 1.2rem; }
.empty { padding: 2rem; text-align: center; color: var(--muted); }

/* ---------- schedule ---------- */
.toolbar { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; margin-bottom: 1rem; }
.weeknav { display: flex; align-items: center; gap: .4rem; }
.weeknav h1 { margin: 0 .4rem; font-size: 1.35rem; }
.chip { font-weight: 800; font-size: .75rem; letter-spacing: .06em; padding: .3em .8em; border-radius: 999px; text-transform: uppercase; }
.chip.draft { background: var(--white); border: 1.5px dashed var(--brown); color: var(--brown); }
.chip.live { background: var(--blue); color: var(--black); }
.toolbar .spacer { flex: 1; }
.grid-wrap { overflow-x: auto; background: var(--white); border: 1.5px solid var(--line); border-radius: var(--radius); }
table.grid { border-collapse: separate; border-spacing: 0; width: 100%; min-width: 860px; }
.grid th, .grid td { border-bottom: 1px solid #efe6c4; border-right: 1px solid #efe6c4; padding: 0; text-align: center; }
.grid thead th { background: var(--yellow); font-family: 'Vollkorn', serif; font-weight: 700; padding: .5rem .3rem; position: sticky; top: 0; font-size: .95rem; }
.grid thead th span { display: block; font-family: 'Nunito Sans', sans-serif; font-weight: 600; font-size: .78rem; color: var(--muted); }
.grid thead th.today { background: var(--brown); color: var(--yellow); }
.grid thead th.today span { color: var(--yellow); }
.grid .name { text-align: left; padding: .45rem .8rem; position: sticky; left: 0; background: var(--white); z-index: 2; min-width: 160px; font-weight: 700; }
.grid thead .name { background: var(--yellow); z-index: 3; }
.grid .name small { display: block; font-weight: 400; color: var(--muted); }
.grid tr.me .name { box-shadow: inset 4px 0 0 var(--brown); }
.grid tr.dept td { background: var(--paper); text-align: left; padding: .35rem .8rem; font-family: 'Vollkorn', serif; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; font-size: .85rem; color: var(--brown); position: sticky; left: 0; }
.cell { height: 52px; min-width: 84px; cursor: default; position: relative; font-size: .78rem; line-height: 1.15; }
.editable .cell { cursor: pointer; }
.editable .cell:hover { outline: 2px solid var(--brown); outline-offset: -2px; }
.cell b { display: block; font-size: 1.05rem; font-family: 'Vollkorn', serif; }
.cell i { font-style: normal; opacity: .8; }
.cell .note { position: absolute; top: 3px; right: 5px; font-size: .9rem; font-weight: 800; }
.cell.empty-cell { color: #c9bb8a; }
.c-yellow { background: var(--yellow); }
.c-blue { background: var(--blue); }
.c-brown { background: var(--brown); color: var(--yellow); }
.c-black { background: var(--black); color: var(--white); }
.c-white { background: var(--white); box-shadow: inset 0 0 0 2px var(--brown); }
.cell.leave { background: repeating-linear-gradient(135deg, #fff, #fff 6px, #f3e7c0 6px, #f3e7c0 12px); color: var(--brown); font-weight: 800; letter-spacing: .05em; }
.cell.conflict { box-shadow: inset 0 0 0 3px var(--bad); }
.cell .pend { position: absolute; bottom: 3px; left: 5px; font-size: .65rem; font-weight: 800; color: var(--brown); background: var(--white); border-radius: 4px; padding: 0 .3em; border: 1px dashed var(--brown); }
.hrs { font-weight: 800; min-width: 64px; }
.hrs small { display: block; font-weight: 400; color: var(--muted); }
.hrs.over { color: var(--bad); }
.grid tfoot td, .grid tfoot th { background: var(--paper); font-size: .85rem; padding: .35rem; }
.grid tfoot .short { color: var(--bad); font-weight: 800; }
.grid tfoot .met { color: #3d6b2f; font-weight: 700; }
.legend { display: flex; gap: .8rem; flex-wrap: wrap; margin: .8rem 0; font-size: .85rem; }
.legend span { display: inline-flex; align-items: center; gap: .35em; }
.legend i { width: 22px; height: 16px; border-radius: 4px; display: inline-block; border: 1px solid rgba(0,0,0,.15); }
.warnings { margin-top: 1rem; }
.warnings li { margin: .2em 0; }
.warnings .k-coverage::marker, .warnings .k-leave::marker { color: var(--bad); }
.hint { font-size: .82rem; color: var(--muted); margin-top: .6rem; }

/* popover */
.pop {
  position: absolute; z-index: 50; background: var(--white); border: 2px solid var(--black); border-radius: 12px; padding: .7rem;
  width: 250px; box-shadow: 0 8px 24px rgba(0,0,0,.18);
}
.pop h3 { margin-bottom: .4rem; font-size: .95rem; }
.pop .opts { display: grid; grid-template-columns: 1fr 1fr; gap: .35rem; }
.pop .opt { border: 1.5px solid rgba(0,0,0,.25); border-radius: 8px; padding: .4rem; cursor: pointer; text-align: left; font-size: .8rem; }
.pop .opt b { font-family: 'Vollkorn', serif; font-size: 1rem; margin-right: .3em; }
.pop .opt.sel { outline: 3px solid var(--brown); }
.pop .opt.off { background: var(--white); }
.pop input { width: 100%; margin-top: .5rem; font-size: .85rem; }
.pop .row { margin-top: .5rem; }

/* lists */
.list { list-style: none; padding: 0; margin: 0; }
.list li { display: flex; gap: 1rem; align-items: center; padding: .8rem 0; border-bottom: 1px solid #efe6c4; flex-wrap: wrap; }
.list li:last-child { border-bottom: 0; }
.list .main { flex: 1; min-width: 200px; }
.list .main small { display: block; color: var(--muted); }
.status { font-size: .75rem; font-weight: 800; text-transform: uppercase; letter-spacing: .05em; padding: .25em .7em; border-radius: 999px; background: var(--paper); border: 1px solid var(--line); }
.status.approved { background: var(--blue); border-color: var(--blue); }
.status.rejected, .status.declined, .status.cancelled { opacity: .7; }
.status.pending, .status.pending_peer { background: var(--yellow); border-color: var(--yellow); }
.shiftbox { width: 64px; height: 54px; border-radius: 8px; display: grid; place-items: center; text-align: center; font-size: .72rem; line-height: 1.1; }
.shiftbox b { font-family: 'Vollkorn', serif; font-size: 1.15rem; display: block; }
.date-big { min-width: 90px; }
.date-big b { font-family: 'Vollkorn', serif; font-size: 1.1rem; display: block; }

.cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 1.2rem; align-items: start; }
.tabs { display: flex; gap: .4rem; margin-bottom: 1rem; }
.tabs button.on { background: var(--brown); color: var(--yellow); border-color: var(--brown); }

table.plain { width: 100%; border-collapse: collapse; font-size: .9rem; }
table.plain th { text-align: left; font-family: 'Vollkorn', serif; padding: .5rem; border-bottom: 2px solid var(--line); }
table.plain td { padding: .45rem .5rem; border-bottom: 1px solid #efe6c4; vertical-align: middle; }
table.plain input, table.plain select { width: 100%; padding: .35em .5em; }
table.plain tr.inactive td { opacity: .5; }
.code { font-family: ui-monospace, Consolas, monospace; background: var(--paper); border: 1px solid var(--line); padding: .5em .7em; border-radius: 6px; word-break: break-all; display: block; }
ol.steps li { margin-bottom: .4em; }

dialog { border: 2px solid var(--black); border-radius: 14px; padding: 1.4rem; width: min(480px, 94vw); }
dialog::backdrop { background: rgba(0,0,0,.35); }

#toast { position: fixed; bottom: 1.2rem; left: 50%; transform: translateX(-50%); z-index: 100; display: flex; flex-direction: column; gap: .4rem; align-items: center; }
#toast div { background: var(--black); color: var(--white); padding: .7em 1.2em; border-radius: 999px; font-weight: 600; max-width: 90vw; }
#toast div.bad { background: var(--bad); }

@media (max-width: 720px) {
  main#view { padding: .8rem; }
  .top { padding: .5rem .8rem; }
  .brand span { display: none; }
  .top nav { order: 3; flex-basis: 100%; overflow-x: auto; flex-wrap: nowrap; }
  .who span { display: none; }
  .weeknav h1 { font-size: 1.1rem; }
}

@media print {
  .top, .toolbar .btn, .toolbar .spacer, .hint, .warnings, .no-print, #toast { display: none !important; }
  body { background: #fff; }
  main#view { padding: 0; max-width: none; }
  .grid-wrap { border: 0; overflow: visible; }
  table.grid { min-width: 0; font-size: 10px; }
  .cell { height: 36px; min-width: 0; }
  .grid .name { position: static; }
  @page { size: landscape; margin: 10mm; }
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
