:root {
  --ink: #1b2430;
  --muted: #5d6b7c;
  --line: #d5dce4;
  --paper: #f3f5f8;
  --panel: #ffffff;
  --header: #14233a;
  --accent: #1d5fd1;
  --l0: #d3d8de;
  --l1: #4a90e2;
  --l2: #3fb768;
  --l3: #f2cb2e;
  --l4: #f08a24;
  --l5: #d93a35;
  font-family: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  color: var(--ink);
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--paper); }
h1 { font-size: 1.1rem; margin: 0; font-weight: 600; letter-spacing: .01em; }
h2 { margin: 0 0 .5rem; font-size: 1.15rem; }
#topbar { display: flex; align-items: center; gap: .75rem; padding: .7rem 1.25rem; background: var(--header); color: #fff; }
#topbar .spacer { flex: 1; }
#topbar .who { font-size: .85rem; opacity: .85; }
main { max-width: 1040px; margin: 0 auto; padding: 1.25rem; }
main.center { text-align: center; padding-top: 4rem; }
.status { color: var(--muted); }
.error { color: #a4161a; }

button, .btn, select, input, textarea { font: inherit; }
button, .btn {
  border: 1px solid var(--line); background: var(--panel); color: var(--ink);
  padding: .4rem .8rem; border-radius: 6px; cursor: pointer; text-decoration: none; display: inline-block;
}
#topbar button { background: transparent; color: #fff; border-color: rgba(255,255,255,.4); }
button:hover { border-color: var(--accent); }
button.primary, .btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.danger { color: #a4161a; }
button:disabled { opacity: .5; cursor: default; }
:focus-visible { outline: 3px solid #8bb4ff; outline-offset: 2px; }
select, input, textarea { border: 1px solid var(--line); border-radius: 6px; padding: .35rem .5rem; background: #fff; color: var(--ink); }
textarea { width: 100%; min-height: 6rem; resize: vertical; }

#banner { background: #fff4d6; border-bottom: 1px solid #e6c870; padding: .65rem 1.25rem; display: flex; gap: 1rem; align-items: center; }
#banner[hidden] { display: none; }
#banner span { flex: 1; font-weight: 500; }

.controls { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; margin-bottom: .9rem; }
.controls input[type=number] { width: 5.5rem; }
.controls .spacer { flex: 1; }
.legend { display: flex; gap: .35rem; align-items: center; font-size: .85rem; color: var(--muted); }
.swatch { width: 1.4rem; height: 1.4rem; border-radius: 4px; display: inline-grid; place-items: center; font-weight: 700; font-size: .8rem; color: #111; }

.grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; }
.dow { text-align: center; font-size: .8rem; color: var(--muted); padding-bottom: .15rem; }
.cell {
  position: relative; min-height: 5.2rem; padding: .4rem .5rem; text-align: left; border-radius: 8px;
  border: 2px solid transparent; color: #111; display: block; width: 100%;
}
.cell.empty { visibility: hidden; }
.cell .dn { font-size: .85rem; font-weight: 600; }
.cell .lv { position: absolute; right: .55rem; bottom: .3rem; font-size: 1.9rem; font-weight: 700; line-height: 1; }
.cell .note-dot { position: absolute; right: .5rem; top: .3rem; font-size: .8rem; opacity: .7; }
.cell.today { border-color: var(--ink); }
.lvl-0 { background: var(--l0); } .lvl-1 { background: var(--l1); } .lvl-2 { background: var(--l2); }
.lvl-3 { background: var(--l3); } .lvl-4 { background: var(--l4); } .lvl-5 { background: var(--l5); color: #fff; }
.swatch.lvl-5 { color: #fff; }

dialog { border: none; border-radius: 10px; padding: 0; width: min(560px, 94vw); box-shadow: 0 10px 40px rgba(0,0,0,.3); color: var(--ink); }
dialog.wide { width: min(900px, 96vw); }
dialog::backdrop { background: rgba(10, 20, 35, .5); }
.dlg-head { display: flex; align-items: center; justify-content: space-between; padding: .9rem 1.1rem; border-bottom: 1px solid var(--line); }
.dlg-body { padding: 1rem 1.1rem; max-height: 70vh; overflow: auto; }
.dlg-foot { display: flex; gap: .5rem; justify-content: flex-end; padding: .8rem 1.1rem; border-top: 1px solid var(--line); }
.row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .35rem 0; border-bottom: 1px solid #edf0f3; }
.overall { display: flex; align-items: center; gap: .6rem; margin-bottom: .75rem; }
.meta { color: var(--muted); font-size: .8rem; margin-top: .5rem; }
.tabs { display: flex; gap: .4rem; margin-bottom: 1rem; }
.tabs button[aria-selected=true] { background: var(--header); color: #fff; border-color: var(--header); }
.inline { display: flex; gap: .5rem; margin: .75rem 0; }
.inline input { flex: 1; }
table { border-collapse: collapse; width: 100%; font-size: .85rem; }
th, td { text-align: left; padding: .35rem .5rem; border-bottom: 1px solid #edf0f3; vertical-align: top; }
.keybox { background: #eef7ee; border: 1px solid #9fd0a4; border-radius: 8px; padding: .75rem; margin: .75rem 0; }
.keybox code { display: block; word-break: break-all; margin: .4rem 0; font-size: .85rem; }
.detail { max-width: 22rem; word-break: break-word; color: var(--muted); }
@media (max-width: 640px) { .cell { min-height: 3.8rem; padding: .25rem .3rem; } .cell .lv { font-size: 1.3rem; } }
@media (prefers-reduced-motion: no-preference) { dialog[open] { animation: pop .12s ease-out; } @keyframes pop { from { transform: translateY(6px); opacity: 0; } } }
.preview img { max-width: 100%; border-radius: 6px; margin-top: .5rem; }
.inline label { align-self: center; white-space: nowrap; }
.slackmsg { background: #f6f8fa; border: 1px solid var(--line); border-radius: 6px; padding: .6rem .8rem; white-space: pre-wrap; font: inherit; }
.chan input:first-child { flex: 0 1 15rem; } .chan input:nth-child(2) { flex: 1; } h3, h4 { margin: .2rem 0 .5rem; }
.export { flex-wrap: wrap; align-items: center; } .export input { flex: 0 1 auto; }
.presets { display: flex; flex-wrap: wrap; gap: .4rem; margin-bottom: .4rem; } .presets button[aria-pressed=true] { background: var(--header); color: #fff; border-color: var(--header); }
.dlg-foot .spacer { flex: 1; } .slackmsg.note { margin-top: .4rem; } .slackmsg.note div { white-space: pre-wrap; margin-top: .2rem; } .preview img { display: block; }
.notice { background: #fff4d6; border: 1px solid #e6c870; border-radius: 6px; padding: .55rem .75rem; margin-bottom: .75rem; display: flex; gap: .75rem; align-items: center; }
.notice[hidden] { display: none; }
.notice span { flex: 1; }
.refresh-status { font-size: .8rem; color: var(--muted); }

/* audit log: a readable list, not a wide table */
.audit-tools { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin-bottom: .6rem; }
.audit-tools input[type=search] { flex: 1 1 14rem; min-width: 10rem; }
details.export { border: 1px solid var(--line); border-radius: 6px; padding: .4rem .75rem; margin-bottom: .8rem; }
details.export > summary { cursor: pointer; font-weight: 600; }
table.audit { table-layout: fixed; }
.audit th:nth-child(1) { width: 8rem; }
.audit th:nth-child(2) { width: 14rem; }
/* long e-mail addresses and notes must wrap inside their column, never run into the next one */
.audit td { overflow-wrap: anywhere; word-wrap: break-word; word-break: break-word; min-width: 0; }
.audit .parts { color: var(--muted); margin-top: .15rem; }
.audit .role { font-size: .75rem; color: var(--muted); }
details.raw summary { font-size: .75rem; color: var(--muted); cursor: pointer; margin-top: .2rem; }
details.raw pre { white-space: pre-wrap; overflow-wrap: anywhere; font-size: .75rem; background: #f6f8fa; padding: .4rem; border-radius: 4px; margin: .3rem 0 0; }

#topbar a.btn { background: transparent; color: #fff; border-color: rgba(255,255,255,.4); }
#topbar a.btn:hover { border-color: #fff; }
