:root {
  color-scheme: dark;
  --navy: #020739;
  --yellow: #fcb603;
  --text: #e5ebf7;
  --muted: #a7b7cf;
  --line: #334363;
  --surface: #121c30;
  --canvas: #090f1d;
  --shadow: 0 10px 28px rgb(0 0 0 / 25%);
  font: 15px/1.45 system-ui, sans-serif;
  color: var(--text);
  background: var(--canvas);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body, h1, h2, h3, p { margin: 0; }
h1, h2, h3 { line-height: 1.2; }
h1 { font-size: clamp(1.15rem, 2vw, 1.5rem); }
h2 { font-size: clamp(1.25rem, 2vw, 1.65rem); letter-spacing: -.025em; }
h3 { font-size: 1rem; }

button, input, select, textarea { font: inherit; }
button, input:not([type="checkbox"]), select, textarea {
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface);
  color: inherit;
  padding: .55rem .75rem;
}
button { cursor: pointer; font-weight: 650; }
button:hover { background: #23334e; border-color: #657da7; }
:where(button, input, select, textarea, [tabindex]):focus-visible {
  outline: 2px solid #91adff;
  outline-offset: 2px;
}
input[type="checkbox"] {
  width: 1rem;
  height: 1rem;
  flex: none;
  accent-color: #65d4a7;
  cursor: pointer;
}
button.primary { background: var(--yellow); border-color: var(--yellow); color: var(--navy); }
button.primary:hover { background: #ffd05c; border-color: #e4a100; }
label { display: grid; gap: .3rem; }

.top {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  background: linear-gradient(110deg, var(--navy), #15265a);
  border-bottom: 3px solid var(--yellow);
  color: white;
  padding: 1.1rem max(1rem, calc((100vw - 1440px) / 2));
}
.brand, .actions, .toolbar, .month-controls, .progress {
  display: flex;
  gap: .65rem;
  align-items: center;
}
.brand { gap: .85rem; }
.brand span {
  color: var(--navy);
  background: var(--yellow);
  border-radius: 9px;
  padding: .48rem .68rem;
  font-weight: 900;
  letter-spacing: .04em;
}
.actions, .toolbar, .progress { flex-wrap: wrap; }
.top button {
  background: #ffffff12;
  border-color: #ffffff42;
  font-size: .85rem;
}
.top button[aria-pressed="true"] { color: var(--navy); background: var(--yellow); }
.top button:hover { background: #ffffff28; }
.top button:focus-visible { outline-color: var(--yellow); }
main { max-width: 1472px; margin: auto; padding: 1.2rem 1rem 2rem; }
nav {
  display: inline-flex;
  flex-wrap: wrap;
  gap: .25rem;
  margin-bottom: 1rem;
  padding: .3rem;
  background: #172239;
  border-radius: 12px;
}
nav button { border-color: transparent; background: transparent; color: var(--muted); }
nav [aria-current], nav [aria-current]:hover { background: var(--yellow); color: var(--navy); }
.toolbar { justify-content: space-between; margin-bottom: 1rem; }
.month-controls h2 { min-width: 10rem; text-align: center; }
.month-controls button {
  inline-size: 2.4rem;
  block-size: 2.4rem;
  padding: 0;
  font-size: 1.45rem;
  line-height: 1;
}
.month-controls #today {
  inline-size: auto;
  padding: 0 .72rem;
  font-size: .85rem;
  background: #373020;
  border-color: #806523;
  color: #ffdc78;
}
.month-controls #today:hover { background: #514323; }
.market { display: flex; align-items: center; gap: .5rem; color: var(--muted); font-weight: 650; }
.market select { color: var(--text); min-width: 9rem; }
.progress { margin-bottom: .85rem; }
.progress span, #status {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: .5rem .8rem;
  color: var(--muted);
  font-size: .85rem;
  font-weight: 650;
}
.progress span:first-child { border-inline-start: 4px solid #5478dd; }
.progress span:nth-child(2) { border-inline-start: 4px solid #d79200; }
#status { margin-bottom: .8rem; }

.calendar-scroll {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: var(--surface);
  box-shadow: var(--shadow);
  scrollbar-color: #566a90 #10192b;
}
.weekdays, .days {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  min-width: 840px;
}
.weekdays { background: #172649; color: white; }
.weekdays span {
  padding: .7rem .85rem;
  font-size: .79rem;
  font-weight: 700;
  letter-spacing: .045em;
}
.weekdays span:nth-child(n+6) { background: #26365d; }
.day {
  min-height: 112px;
  padding: .42rem;
  border-block-end: 1px solid var(--line);
  border-inline-end: 1px solid var(--line);
  background: var(--surface);
}
.day:nth-child(7n) { border-inline-end: 0; }
.day:nth-child(7n), .day:nth-child(7n-1) { background: #101929; }
.day.empty { background: #0c1424; }
.day.is-today {
  position: relative;
  box-shadow: inset 0 0 0 1px var(--yellow);
}
.day.is-past > * { opacity: .66; }
.day.is-available {
  position: relative;
  background: #153b30;
  color: #bcf6d8;
}
.day.is-available.is-past { background: #152a25; }
.is-available .day-number:hover,
.is-available .day-number[aria-current="date"] { background: transparent; color: inherit; }
.is-available .day-number::after {
  content: '';
  position: absolute;
  inset: 0;
}
.is-available .day-number:focus-visible::after {
  outline: 2px solid currentColor;
  outline-offset: -4px;
}
.availability {
  display: block;
  padding: .08rem .45rem;
  font-size: .8rem;
  font-weight: 650;
  pointer-events: none;
}
.day-number {
  display: block;
  width: 100%;
  text-align: start;
  border: 0;
  background: transparent;
  border-radius: 6px;
  padding: .28rem .45rem;
  margin-bottom: .35rem;
  font-size: .85rem;
  font-variant-numeric: tabular-nums;
}
.day-number[aria-current="date"] { background: #373020; color: #ffdb72; }
.entry {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: start;
  gap: .22rem;
  margin-top: .3rem;
  background: #1a2c50;
  color: #cad8ff;
  border-inline-start: 3px solid #6888e8;
  border-radius: 7px;
  padding: .2rem .3rem;
}
.entry.post { background: #34291b; color: #ffe0a1; border-inline-start-color: #dda425; }
.entry input { margin: .28rem .1rem; }
.entry button {
  min-width: 0;
  border: 0;
  background: transparent;
  font-size: .76rem;
  line-height: 1.35;
  text-align: start;
  padding: .18rem .1rem;
  overflow-wrap: anywhere;
}
.entry button:hover { text-decoration: underline; }
.entry.done { background: #16322e; border-inline-start-color: #4d9e7d; color: #a9e7cf; }
.entry.done button { text-decoration: line-through; }

.catalog {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 340px), 1fr));
  gap: 1rem;
}
.format-group { display: grid; align-content: start; gap: .65rem; }
.format-group > h3 {
  padding: .65rem .8rem;
  border-radius: 9px;
  background: #1b2d51;
  color: #c4d3ff;
}
.format-group:nth-child(2) > h3 { background: #34291b; color: #ffe0a1; }
.format-card, .day-item {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: .9rem;
  display: grid;
  gap: .55rem;
  overflow-wrap: anywhere;
}
.format-card { box-shadow: 0 2px 6px rgb(0 0 0 / 14%); }
.format-card p, fieldset p { color: var(--muted); }
.format-card .market-tags {
  justify-self: start;
  background: #22324b;
  border-radius: 6px;
  padding: .25rem .45rem;
  font-size: .8rem;
}
dialog {
  width: min(94vw, 560px);
  max-height: 90vh;
  max-height: 90dvh;
  border: 1px solid var(--line);
  border-top: 4px solid var(--yellow);
  border-radius: 15px;
  padding: clamp(.9rem, 3vw, 1.35rem);
  color: var(--text);
  background: var(--surface);
  box-shadow: 0 22px 64px #0008;
}
.dialog-heading { display: flex; justify-content: space-between; align-items: center; gap: .6rem; }
button.icon-close {
  display: grid;
  place-items: center;
  width: 2.2rem;
  height: 2.2rem;
  padding: 0;
  font-size: 1.5rem;
  line-height: 1;
}
dialog::backdrop { background: #000a; }
#format-form, #day-items { display: grid; gap: .75rem; }
#add-item { display: flex; align-items: end; flex-wrap: wrap; gap: .65rem; margin-top: .9rem; }
.check-label { display: flex; align-items: center; }
.day-market { margin-bottom: .85rem; }
fieldset { min-inline-size: 0; border: 1px solid var(--line); border-radius: 9px; }
fieldset p { margin-bottom: .45rem; font-size: .9rem; }
#format-markets { display: flex; flex-wrap: wrap; gap: .25rem .8rem; }
textarea { resize: vertical; }

@media (max-width: 540px) {
  .top { gap: .7rem; }
  main { padding: .85rem .75rem 1.5rem; }
  .month-controls { gap: .35rem; }
  .month-controls h2 { min-width: 8.5rem; }
  .market select { min-width: 0; }
  .weekdays, .days { min-width: 770px; }
}

:root[data-theme="light"] {
  color-scheme: light;
  --text: #18233c;
  --muted: #52617a;
  --line: #dfe6ef;
  --surface: #fff;
  --canvas: #f2f5fa;
  --shadow: 0 10px 28px rgb(20 37 75 / 7%);
}
[data-theme="light"] button:hover { background: #eef3fa; }
[data-theme="light"] .top button:hover { background: #ffffff28; }
[data-theme="light"] .top button[aria-pressed="true"]:hover { background: #ffd05c; }
[data-theme="light"] nav { background: #e6ecf5; }
[data-theme="light"] nav [aria-current]:hover,
[data-theme="light"] button.primary:hover { background: #ffd05c; }
[data-theme="light"] .month-controls #today { background: #fff1c9; border-color: #d8a639; color: #684b00; }
[data-theme="light"] .day:nth-child(7n),
[data-theme="light"] .day:nth-child(7n-1) { background: #f8fafd; }
[data-theme="light"] .day.empty { background: #edf1f7; }
[data-theme="light"] .day.is-available { background: #d7f3e3; color: #17533b; }
[data-theme="light"] .day.is-available.is-past { background: #e5efe8; }
[data-theme="light"] .day-number[aria-current="date"] { background: #fff1c9; color: #514000; }
[data-theme="light"] .is-available .day-number:hover,
[data-theme="light"] .is-available .day-number[aria-current="date"] { background: transparent; color: inherit; }
[data-theme="light"] .entry,
[data-theme="light"] .format-group > h3 { background: #e8efff; color: #243f82; }
[data-theme="light"] .entry.post,
[data-theme="light"] .format-group:nth-child(2) > h3 { background: #fff1cb; color: #624400; }
[data-theme="light"] .entry.done { background: #eaf5ef; color: #315e4e; }
[data-theme="light"] .entry button:hover { background: transparent; }
[data-theme="light"] .format-card .market-tags { background: #edf2f8; }

#theme-toggle {
  width: 2.35rem;
  height: 2.35rem;
  display: grid;
  place-items: center;
  padding: 0;
}
#theme-toggle svg { width: 1rem; height: 1rem; }
#theme-toggle .theme-moon,
[data-theme="light"] #theme-toggle .theme-sun { display: none; }
[data-theme="light"] #theme-toggle .theme-moon { display: block; }

.calendar-scroll {
  --saturday-line: #5b81a9;
  --sunday-line: #987152;
}
.weekdays small {
  display: block;
  font-size: .7rem;
  font-weight: 500;
  letter-spacing: normal;
}
.weekdays > :nth-child(6),
.days > :nth-child(7n-1) { border-inline-start: 1px solid var(--saturday-line); border-inline-end: 0; }
.weekdays > :nth-child(7),
.days > :nth-child(7n) { border-inline-end: 1px solid var(--sunday-line); }
.weekdays > :nth-child(7),
.days > :nth-child(7n) { border-inline-start: 1px solid var(--sunday-line); }
.weekdays > :nth-child(6) { border-block-start: 1px solid var(--saturday-line); }
.weekdays > :nth-child(7) { border-block-start: 1px solid var(--sunday-line); }
.days > :nth-last-child(2) { border-block-end-color: var(--saturday-line); }
.days > :last-child { border-block-end-color: var(--sunday-line); }

#integrations-dialog > *, #gist-form > label { margin-bottom: .75rem; }
#integrations-dialog > :last-child { margin-bottom: 0; }
#integrations-dialog p { color: var(--muted); }
button:disabled { opacity: .55; cursor: default; }

#reminders {
  display: grid;
  gap: .6rem;
  border-top: 1px solid var(--line);
  padding-top: .9rem;
}
#reminders .check-label { gap: .55rem; font-weight: 650; }
.reminder-row { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem 1.2rem; }
.time-label { display: flex; align-items: center; gap: .5rem; font-weight: 650; }

.hint { color: var(--muted); font-size: .85rem; margin: -.4rem 0 .8rem; }
.entry { cursor: grab; }
.entry:active { cursor: grabbing; }
.entry button { pointer-events: none; }
.entry:hover button { text-decoration: underline; }
.entry.dragging { opacity: .4; }
.day.drop-target {
  outline: 2px dashed var(--yellow);
  outline-offset: -4px;
  background-image: linear-gradient(#fcb60326, #fcb60326);
}

.calendar-tools { display: grid; justify-items: end; gap: .55rem; }
.calendar-tools .actions { justify-content: flex-end; }
.entry { user-select: none; -webkit-user-select: none; }
.entry.selected { outline: 2px solid var(--yellow); outline-offset: 1px; }

.countries {
  display: grid;
  gap: .7rem;
  margin-bottom: 1.4rem;
  padding: 1rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
}
.countries .hint { margin: 0; }
.country-list { display: flex; flex-wrap: wrap; gap: .55rem; }
.country-chip {
  display: flex;
  align-items: center;
  gap: .55rem;
  padding: .3rem .35rem .3rem .75rem;
  border: 1px solid var(--line);
  border-radius: 9px;
}
.country-chip .market-tags {
  background: #22324b;
  border-radius: 6px;
  padding: .2rem .4rem;
  color: var(--muted);
  font-size: .78rem;
}
[data-theme="light"] .country-chip .market-tags { background: #edf2f8; }
.country-chip button { padding: .25rem .55rem; font-size: .8rem; }
.country-form { display: flex; flex-wrap: wrap; align-items: end; gap: .65rem 1rem; }
.country-form .check-label { gap: .5rem; padding-bottom: .55rem; }
@media (max-width: 540px) {
  .calendar-tools { justify-items: start; width: 100%; }
  .calendar-tools .actions { justify-content: flex-start; }
}

.day-notes { display: grid; gap: .6rem; margin-bottom: .9rem; }
.tag-field { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem; }
.tag-list, .day-tags { display: flex; flex-wrap: wrap; gap: .3rem; }
.tag-field input { flex: 1 1 10rem; min-width: 0; }
.day-tag {
  display: inline-flex;
  align-items: center;
  gap: .15rem;
  padding: .1rem .45rem;
  border-radius: 99px;
  background: #3a2f55;
  color: #e3d6ff;
  font-size: .72rem;
  font-weight: 650;
  line-height: 1.4;
}
.day-tag button {
  border: 0;
  background: transparent;
  padding: 0 .15rem;
  font-size: .9rem;
  line-height: 1;
}
.day-tag button:hover { background: transparent; color: var(--yellow); }
.day-meta { display: grid; gap: .25rem; margin: 0 .2rem .3rem; cursor: pointer; }
.day-note-text {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  overflow-wrap: anywhere;
  color: var(--muted);
  font-size: .72rem;
  font-style: italic;
}
.is-available .day-note-text { color: inherit; }
[data-theme="light"] .day-tag { background: #efe7ff; color: #4a2f86; }

.day { position: relative; }
.note-pen {
  position: absolute;
  inset-block-start: .3rem;
  inset-inline-end: .3rem;
  z-index: 2;
  display: grid;
  place-items: center;
  width: 1.6rem;
  height: 1.6rem;
  padding: 0;
  border-color: transparent;
  background: transparent;
  color: var(--muted);
  opacity: .6;
}
.note-pen svg { width: .95rem; height: .95rem; }
.note-pen:hover, .note-pen:focus-visible { opacity: 1; background: var(--canvas); border-color: var(--line); }
.note-pen.has-note { color: var(--yellow); opacity: 1; }
.is-available .note-pen { color: inherit; }
.is-available .note-pen.has-note { color: #ffd05c; }
[data-theme="light"] .note-pen.has-note { color: #b57f00; }
[data-theme="light"] .is-available .note-pen.has-note { color: #7a5500; }

input[type="radio"] {
  width: 1rem;
  height: 1rem;
  flex: none;
  padding: 0;
  border: 0;
  accent-color: #65d4a7;
  cursor: pointer;
}
#country-edit-form { display: grid; gap: .75rem; }
#country-edit-form fieldset { display: grid; gap: .5rem; padding: .7rem .8rem; }
#country-edit-form .check-label { gap: .5rem; }
.targets input[type="number"] { width: 9.5rem; }

.matrix-scroll { overflow-x: auto; border: 1px solid var(--line); border-radius: 10px; }
#matrix-table { border-collapse: collapse; width: 100%; font-size: .85rem; }
#matrix-table th, #matrix-table td {
  padding: .45rem .6rem;
  border-bottom: 1px solid var(--line);
  text-align: center;
  vertical-align: middle;
}
#matrix-table thead th { background: #172649; color: white; font-size: .78rem; white-space: nowrap; }
#matrix-table .matrix-country span { display: block; }
#matrix-table .matrix-name {
  position: sticky;
  inset-inline-start: 0;
  min-width: 11rem;
  text-align: start;
  background: var(--surface);
  font-weight: 650;
}
#matrix-table thead th:first-child { text-align: start; position: sticky; inset-inline-start: 0; }
#matrix-table .matrix-name span { display: block; }
#matrix-table .matrix-group th { text-align: start; background: #1b2d51; color: #c4d3ff; }
#matrix-table .matrix-group.post th { background: #34291b; color: #ffe0a1; }
[data-theme="light"] #matrix-table .matrix-group th { background: #e8efff; color: #243f82; }
[data-theme="light"] #matrix-table .matrix-group.post th { background: #fff1cb; color: #624400; }
#matrix-table input[type="checkbox"] { margin: 0; }
.matrix-off { color: var(--muted); }
.matrix-all {
  margin-top: .25rem;
  padding: .1rem .45rem;
  font-size: .7rem;
  font-weight: 600;
}
#matrix-table thead .matrix-all { background: #ffffff12; border-color: #ffffff42; color: white; }

/* Market groups, designer filter and designer marks */
.filters { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: .55rem 1rem; }
@media (max-width: 540px) { .filters { justify-content: flex-start; } }
#person-edit-form { display: grid; gap: .75rem; }
.color-input { inline-size: 3.2rem; block-size: 2.4rem; padding: .15rem; cursor: pointer; }
.person-dot {
  display: inline-block;
  inline-size: .72rem;
  block-size: .72rem;
  margin-top: .42rem;
  border-radius: 50%;
  flex: none;
  box-shadow: 0 0 0 1.5px rgb(255 255 255 / 75%), 0 0 0 2.5px rgb(0 0 0 / 25%);
}
.person-dot.large { inline-size: 1.05rem; block-size: 1.05rem; margin-top: 0; }

.assign-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .55rem .8rem;
  margin-bottom: .85rem;
  padding: .55rem .8rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-inline-start: 4px solid var(--yellow);
  border-radius: 9px;
}
.assign-field { display: flex; align-items: center; gap: .5rem; color: var(--muted); font-weight: 650; }
.assign-bar button:disabled { opacity: .5; cursor: not-allowed; }

/* Designer dots: small colour circles in the bottom-right corner of an item, one per designer */
.entry.has-person { position: relative; padding-bottom: .85rem; }
.entry-people {
  position: absolute;
  inset-inline-end: .3rem;
  inset-block-end: .22rem;
  display: flex;
  flex-direction: row-reverse;
  gap: 3px;
  pointer-events: none;
}
.entry-people .person-dot { inline-size: .55rem; block-size: .55rem; margin: 0; box-shadow: 0 0 0 1px rgb(255 255 255 / 80%), 0 0 0 2px rgb(0 0 0 / 20%); }
.people-picks { display: flex; flex-wrap: wrap; gap: .4rem .9rem; border: 0; padding: 0; margin: 0; }
.people-picks legend { color: var(--muted); font-weight: 650; padding: 0; margin-bottom: .3rem; }
.people-picks[hidden] { display: none; }
.people-pick { display: inline-flex; align-items: center; gap: .35rem; }
.people-pick .person-dot { margin: 0; inline-size: .8rem; block-size: .8rem; }

/* Header refresh button */
#refresh-sync { display: inline-flex; align-items: center; gap: .4rem; }
#refresh-sync:disabled { opacity: .75; cursor: progress; }
#refresh-sync.syncing .refresh-icon { animation: refresh-spin .9s linear infinite; }
@keyframes refresh-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { #refresh-sync.syncing .refresh-icon { animation: none; } }
.format-limit { font-weight: 650; }
