:root {
  --bg: #f6f5f2;
  --panel: #ffffff;
  --ink: #1d1b19;
  --muted: #6f6a63;
  --line: #e2ded7;
  --accent: #b23b2e;
  --accent-soft: #fbecea;
  --ok: #2f7d55;
  --warn: #b7791f;
  --block: #a13a3a;
  --owner: #6d3fa8;
  --manager: #1f6a8f;
  --radius: 10px;
  color-scheme: light;
}

* { box-sizing: border-box; }

/* The hidden attribute is only a weak UA default, so any explicit display on an
   element beats it. Several components here set display, so enforce it properly. */
[hidden] { display: none !important; }

body {
  margin: 0;
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
}

button { font: inherit; cursor: pointer; }
input, select, textarea { font: inherit; }

/* ---------- login ---------- */
.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.login-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 32px;
  width: 100%;
  max-width: 360px;
  box-shadow: 0 6px 24px rgba(0,0,0,.06);
}
.login-wrap { width: 100%; max-width: 360px; }
.login-card h1 { margin: 0; font-size: 26px; letter-spacing: -.3px; }
.login-card .sub { margin: 2px 0 24px; color: var(--muted); text-transform: uppercase; font-size: 11px; letter-spacing: 1.4px; }
/* When the logo stands in for the heading, centre the tagline under it. */
.login-card .logo:not([hidden]) ~ .sub { text-align: center; margin-top: -8px; }
/* Landscape badge mark (~1.4:1). Centred, with the card's own padding as breathing room. */
.login-card .logo {
  display: block; width: 190px; max-width: 70%;
  height: auto; margin: 0 auto 18px;
}

/* Sits under the card: tells a lost customer where to actually go. */
.public-note {
  margin: 18px 4px 0; text-align: center; font-size: 13px;
  line-height: 1.6; color: var(--muted);
}
.public-note a { color: var(--accent); font-weight: 600; }
.public-note a:hover { text-decoration: none; }
.login-card label, .form-grid label { display: block; margin-bottom: 14px; font-size: 13px; color: var(--muted); }
.login-card input, .form-grid input, .form-grid select, .form-grid textarea {
  display: block; width: 100%; margin-top: 5px; padding: 9px 11px;
  border: 1px solid var(--line); border-radius: 7px; background: #fff; color: var(--ink);
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }

button.primary, .login-card button[type=submit] {
  background: var(--accent); color: #fff; border: 0;
  padding: 10px 16px; border-radius: 7px; font-weight: 600; width: 100%;
}
button.primary { width: auto; }
button.primary:hover, .login-card button[type=submit]:hover { filter: brightness(1.07); }
button.link { background: none; border: 0; color: var(--muted); text-decoration: underline; padding: 4px 6px; }
button.link:hover { color: var(--ink); }
.error { color: var(--accent); font-size: 13px; margin: 0 0 12px; }

/* ---------- chrome ---------- */
.topbar {
  display: flex; align-items: center; gap: 20px; flex-wrap: wrap;
  padding: 10px 20px; background: var(--panel); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 20;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-text { display: flex; flex-direction: column; line-height: 1.1; }
/* The mark already reads "Daddy Deli", so beside it we keep only the subtitle. */
.brand-logo { height: 34px; width: auto; display: block; }
.brand-logo:not([hidden]) ~ .brand-text strong { display: none; }
.brand-logo:not([hidden]) ~ .brand-text span { font-size: 11px; }
.brand strong { font-size: 16px; }
.brand span { font-size: 10px; letter-spacing: 1.3px; text-transform: uppercase; color: var(--muted); }
.tabs { display: flex; gap: 4px; margin-left: 8px; }
.tab {
  background: none; border: 0; padding: 7px 13px; border-radius: 7px; color: var(--muted); font-weight: 500;
}
.tab.active { background: var(--accent-soft); color: var(--accent); }
.who { margin-left: auto; display: flex; align-items: center; gap: 10px; font-size: 13px; }
.badge {
  background: var(--accent); color: #fff; border-radius: 999px;
  padding: 1px 7px; font-size: 11px; margin-left: 4px;
}
.role-chip {
  font-size: 10px; text-transform: uppercase; letter-spacing: .8px;
  padding: 2px 8px; border-radius: 999px; background: var(--line); color: var(--muted); font-weight: 700;
}
.role-chip.owner { background: #efe6fb; color: var(--owner); }
.role-chip.manager { background: #e2f0f7; color: var(--manager); }

main { padding: 20px; max-width: 1180px; margin: 0 auto; }
.view h2 { margin: 0 0 14px; font-size: 19px; }

/* ---------- calendar ---------- */
.cal-head { display: flex; align-items: center; gap: 14px; margin-bottom: 12px; flex-wrap: wrap; }
.cal-nav { display: flex; align-items: center; gap: 8px; }
.cal-nav h2 { margin: 0; min-width: 190px; }
.cal-nav button:not(.link) {
  background: var(--panel); border: 1px solid var(--line); border-radius: 7px;
  width: 32px; height: 32px; line-height: 1;
}
.cal-head .primary { margin-left: auto; }

.weekdays {
  display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px;
  font-size: 11px; text-transform: uppercase; letter-spacing: .8px; color: var(--muted);
  padding: 0 2px 6px;
}
.calendar { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.day {
  background: var(--panel); border: 1px solid var(--line); border-radius: 8px;
  min-height: 108px; padding: 6px; display: flex; flex-direction: column; gap: 4px;
  position: relative;
}

/* Add-event affordance, pinned to the day's top-right. Faint until the day is
   hovered so 42 plus signs don't shout over the actual events. */
.day-add {
  position: absolute; top: 3px; right: 3px;
  width: 22px; height: 22px; padding: 0; line-height: 1;
  border: 0; border-radius: 6px; background: transparent;
  color: var(--muted); font-size: 16px; font-weight: 600;
  opacity: 0; transition: opacity .12s, background .12s, color .12s;
}
.day:hover .day-add { opacity: 1; }
.day-add:hover { background: var(--accent-soft); color: var(--accent); }
.day-add:focus-visible { opacity: 1; outline: 2px solid var(--accent); outline-offset: -1px; }
.day.outside .day-add { display: none; }

/* No hover on touch screens, so always show it there. */
@media (hover: none) {
  .day-add { opacity: .55; }
}
.day.outside { background: transparent; border-color: transparent; }
.day.outside .day-num { color: #c3bdb4; }
.day.today { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.day-num { font-size: 12px; color: var(--muted); font-weight: 600; }
.day.today .day-num { color: var(--accent); }

.chip {
  text-align: left; width: 100%; border: 0; border-radius: 5px;
  background: var(--accent-soft); color: var(--accent);
  padding: 3px 6px; font-size: 12px; font-weight: 500;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.chip:hover { filter: brightness(.96); }
.chip .chip-progress { opacity: .7; font-weight: 400; font-size: 11px; }
.chip.done { background: #e6f2ec; color: var(--ok); }

/* ---------- tasks ---------- */
/* Sort/filter controls above the all-tasks list. */
.filter-bar {
  display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap;
  margin-bottom: 14px; padding: 12px 14px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 8px;
}
.filter-bar label {
  display: flex; flex-direction: column; gap: 4px;
  font-size: 11px; text-transform: uppercase; letter-spacing: .7px; color: var(--muted);
}
.filter-bar select, .filter-bar input[type=search] {
  padding: 7px 9px; border: 1px solid var(--line); border-radius: 7px;
  background: #fff; color: var(--ink); font-size: 14px; text-transform: none; letter-spacing: 0;
}
.filter-bar input[type=search] { flex: 1; min-width: 150px; }

.section-head h2 { margin: 0; }

.task-list { display: flex; flex-direction: column; gap: 8px; }
/* Status stripe, matching the task cards in the event drawer. */
.all-task { border-left: 3px solid var(--line); }
.all-task.status-in_progress { border-left-color: var(--warn); }
.all-task.status-blocked { border-left-color: var(--block); }
.all-task.status-done { border-left-color: var(--ok); }
.all-task.status-done .task-title { color: var(--muted); text-decoration: line-through; }
.task {
  background: var(--panel); border: 1px solid var(--line); border-radius: 8px;
  padding: 10px 12px; display: flex; align-items: flex-start; gap: 10px; flex-wrap: wrap;
}
.task-main { flex: 1; min-width: 200px; }
.task-title { font-weight: 500; }
.task-meta { font-size: 12px; color: var(--muted); margin-top: 2px; }
.status {
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .6px;
  padding: 3px 8px; border-radius: 999px; border: 0;
}
.status.todo { background: var(--line); color: var(--muted); }
.status.in_progress { background: #fdf0da; color: var(--warn); }
.status.blocked { background: #fbe7e7; color: var(--block); }
.status.done { background: #e6f2ec; color: var(--ok); }
select.status { cursor: pointer; }

/* Assignment control: dropdown of accounts, plus a free-text box for people
   who have no login (a KP, a contractor). */
.assignee-picker { display: inline-flex; gap: 6px; align-items: center; flex-wrap: wrap; }
/* One chip per person on the task. */
.assignee-picker .chips { display: inline-flex; gap: 4px; flex-wrap: wrap; align-items: center; }
.chips-empty { font-size: 12px; color: var(--muted); font-style: italic; }
.person-chip {
  display: inline-flex; align-items: center; gap: 4px;
  background: var(--accent-soft); color: var(--accent);
  border-radius: 999px; padding: 2px 5px 2px 9px;
  font-size: 12px; font-weight: 600; white-space: nowrap;
}
/* Someone without a login reads differently from a team member. */
.person-chip.external { background: var(--line); color: var(--muted); }
.chip-x {
  background: none; border: 0; padding: 0 2px; cursor: pointer;
  font-size: 14px; line-height: 1; color: inherit; opacity: .6;
}
.chip-x:hover { opacity: 1; }
.assignee-picker select, .assignee-text {
  padding: 7px 9px; border: 1px solid var(--line); border-radius: 7px;
  background: #fff; color: var(--ink); max-width: 100%;
}
.assignee-text { min-width: 150px; }
.inline-assign { margin-top: 6px; }
.inline-assign select, .inline-assign .assignee-text {
  font-size: 12px; padding: 4px 7px; border-radius: 6px;
}
/* Marks an assignee who cannot sign in to update the task themselves. */
.ext-tag {
  display: inline-block; margin-left: 6px; padding: 1px 6px;
  font-size: 9px; font-weight: 800; text-transform: uppercase; letter-spacing: .6px;
  background: var(--line); color: var(--muted); border-radius: 999px;
}

/* ---------- drawer ---------- */
.drawer-backdrop, .modal-backdrop {
  position: fixed; inset: 0; background: rgba(28,24,20,.35); z-index: 30;
}
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(560px, 100%);
  background: var(--bg); z-index: 31; display: flex; flex-direction: column;
  box-shadow: -8px 0 28px rgba(0,0,0,.14);
}
/* The task drawer stacks above the event drawer, so it needs higher layers. */
.task-backdrop { z-index: 40; }
.task-drawer { z-index: 41; width: min(500px, 100%); }
.drawer-kicker {
  margin: 0 0 2px; font-size: 11px; text-transform: uppercase;
  letter-spacing: .8px; color: var(--muted); font-weight: 600;
}
.drawer-head .grow { flex: 1; min-width: 0; }

/* A task title that opens its own drawer. */
.link-title {
  background: none; border: 0; padding: 0; text-align: left;
  font: inherit; font-weight: 500; color: var(--ink); cursor: pointer;
}
.link-title:hover { color: var(--accent); text-decoration: underline; }

/* Label/value rows inside the task drawer. */
.drawer-row {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 5px 0; font-size: 14px;
}
.row-label {
  min-width: 62px; font-size: 11px; text-transform: uppercase;
  letter-spacing: .7px; color: var(--muted); font-weight: 700;
}
.due-input {
  padding: 6px 9px; border: 1px solid var(--line); border-radius: 7px; background: #fff;
}
.row-actions { display: inline-flex; gap: 2px; white-space: nowrap; }
.link.danger { color: var(--block); }
.link.danger:hover { color: var(--block); font-weight: 600; }

.drawer-head {
  display: flex; align-items: flex-start; gap: 12px; padding: 16px 18px;
  border-bottom: 1px solid var(--line); background: var(--panel);
}
.drawer-head h2 { margin: 0; font-size: 18px; flex: 1; }
.drawer-head .link { font-size: 22px; text-decoration: none; line-height: 1; }
.drawer-body { padding: 18px; overflow-y: auto; flex: 1; }

.card {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 8px; padding: 14px; margin-bottom: 14px;
}

/* Section heading above a run of cards. */
.section-head {
  display: flex; align-items: center; gap: 9px;
  margin: 20px 2px 10px;
}
.section-head h3 {
  margin: 0; font-size: 13px; text-transform: uppercase;
  letter-spacing: .8px; color: var(--muted);
}
.progress-pill {
  font-size: 11px; font-weight: 700; padding: 2px 9px; border-radius: 999px;
  background: var(--line); color: var(--muted);
}
.progress-pill.all-done { background: #e6f2ec; color: var(--ok); }

/* One card per task, with a colour stripe showing status at a glance. */
.task-card { padding: 12px 14px; border-left: 3px solid var(--line); }
.task-card.status-in_progress { border-left-color: var(--warn); }
.task-card.status-blocked { border-left-color: var(--block); }
.task-card.status-done { border-left-color: var(--ok); }
.task-card.status-done .task-title { color: var(--muted); }

.task-card-head { display: flex; align-items: flex-start; gap: 10px; flex-wrap: wrap; }
.task-card-head .task-main { flex: 1; min-width: 180px; }

.task-del {
  background: none; border: 0; color: var(--muted);
  font-size: 15px; line-height: 1; padding: 3px 5px; border-radius: 6px;
}
.task-del:hover { background: #fbe7e7; color: var(--block); }

/* Notes belonging to a task, divided off inside its card. */
.task-notes { margin-top: 11px; padding-top: 10px; border-top: 1px solid var(--line); }
.task-notes-label {
  font-size: 10px; text-transform: uppercase; letter-spacing: .7px;
  color: var(--muted); font-weight: 700; margin-bottom: 7px;
}

.add-task-card { border-style: dashed; background: transparent; }
.add-task-card .task-input {
  width: 100%; padding: 9px 11px; border: 1px solid var(--line);
  border-radius: 7px; background: #fff;
}
.card h3 { margin: 0 0 10px; font-size: 13px; text-transform: uppercase; letter-spacing: .8px; color: var(--muted); }
.meta-line { font-size: 13px; color: var(--muted); margin: 3px 0; }

/* ---------- notes ---------- */
.note {
  border-left: 3px solid var(--line); padding: 7px 0 7px 11px; margin-bottom: 10px; font-size: 14px;
}
.note.manager { border-left-color: var(--manager); }
.note.owner { border-left-color: var(--owner); }
.note-head { font-size: 11px; color: var(--muted); margin-bottom: 3px; display: flex; gap: 7px; align-items: center; }
.vis-tag {
  font-size: 9px; font-weight: 800; text-transform: uppercase; letter-spacing: .7px;
  padding: 1px 6px; border-radius: 999px; background: var(--line); color: var(--muted);
}
.vis-tag.manager { background: #e2f0f7; color: var(--manager); }
.vis-tag.owner { background: #efe6fb; color: var(--owner); }
.note-body { white-space: pre-wrap; word-break: break-word; }

.note-form { display: flex; flex-direction: column; gap: 8px; }
.note-form textarea {
  width: 100%; border: 1px solid var(--line); border-radius: 7px; padding: 8px 10px;
  resize: vertical; min-height: 62px;
}
.note-form-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.note-form select { border: 1px solid var(--line); border-radius: 7px; padding: 7px 9px; }

/* ---------- modal ---------- */
.modal {
  position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%);
  background: var(--panel); border-radius: var(--radius); padding: 22px;
  width: min(460px, calc(100% - 32px)); max-height: 86vh; overflow-y: auto; z-index: 32;
}
.modal h3 { margin: 0 0 16px; font-size: 17px; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 8px; }
.form-grid .row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
/* Checkbox sits inline with its text rather than stacking like the other fields. */
.form-grid label.checkline {
  display: flex; align-items: center; gap: 8px;
  color: var(--ink); font-size: 14px; margin-bottom: 14px;
}
.form-grid label.checkline input { width: auto; margin: 0; }

.team-list { display: flex; flex-direction: column; gap: 6px; margin-bottom: 20px; }
.team-row {
  background: var(--panel); border: 1px solid var(--line); border-radius: 8px;
  padding: 10px 12px; display: flex; align-items: center; gap: 10px;
}
.team-row .grow { flex: 1; }
.team-row.inactive { opacity: .55; }
.team-row.inactive .role-chip { filter: grayscale(1); }
.empty { color: var(--muted); font-size: 14px; padding: 18px 0; text-align: center; }

@media (max-width: 720px) {
  .topbar { gap: 10px; padding: 10px 14px; }
  .who { width: 100%; margin-left: 0; order: 3; }
  main { padding: 14px; }
  .day { min-height: 74px; }
  .day-num { font-size: 11px; }
  .chip { font-size: 11px; }
  .form-grid .row2 { grid-template-columns: 1fr; }
}
