/* Medpark palette, shared with the form */
:root {
  --teal: #0E8C99;
  --teal-dark: #0A6C77;
  --teal-tint: #E4F2F4;
  --ink: #333333;
  --ink-soft: #4D4D4D;
  --muted: #6B7278;
  --line: #DFE4E6;
  --page: #F5F8F9;
  --card: #FFFFFF;
  --danger: #B3261E;
  --danger-tint: #FCEEEE;

  /* status colours: [text, background] */
  --st-started: #0A6C77;     --st-started-bg: #E4F2F4;
  --st-progress: #8A5A00;    --st-progress-bg: #FFF2D6;
  --st-done: #22703A;        --st-done-bg: #E3F4E8;
  --st-rejected: #6B7278;    --st-rejected-bg: #ECEFF0;
  --st-hold: #6A4C93;        --st-hold-bg: #EFE9F7;
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  min-height: 100vh;
  font: 14px/1.45 "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--ink);
  background: var(--page);
}
[hidden] { display: none !important; }
button, input, select, textarea { font: inherit; color: inherit; }

/* ---------- top bar ---------- */

.topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  padding: 12px 24px;
  background: var(--card);
  border-bottom: 1px solid var(--line);
  border-top: 4px solid var(--teal);
}
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.logo {
  flex: none; width: 34px; height: 34px; display: grid; place-items: center;
  border-radius: 9px; background: var(--teal-tint); color: var(--teal-dark);
  font-size: 22px; font-weight: 600; line-height: 1;
}
h1 { margin: 0; font-size: 18px; font-weight: 650; color: var(--ink-soft); }
.sub { margin: 0; color: var(--muted); font-size: 13px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 7px 14px; border-radius: 8px; cursor: pointer; text-decoration: none;
  border: 1.5px solid var(--teal); background: var(--teal); color: #fff; font-weight: 600;
}
.btn:hover { background: var(--teal-dark); border-color: var(--teal-dark); }
.btn.ghost { background: #fff; color: var(--teal-dark); border-color: var(--line); }
.btn.ghost:hover { background: var(--teal-tint); border-color: var(--teal); }
.btn.wide { width: 100%; padding: 11px; font-size: 15px; }
.btn:disabled { opacity: .7; cursor: progress; }
.btn:focus-visible, .chip:focus-visible, th button:focus-visible, .comment:focus-visible {
  outline: 3px solid rgba(14, 140, 153, .35); outline-offset: 2px;
}

/* ---------- sign in ---------- */

.login { display: grid; place-items: center; padding: 10vh 16px; }
.card {
  width: 100%; max-width: 380px; padding: 26px 26px 22px;
  background: var(--card); border-radius: 14px; border-top: 4px solid var(--teal);
  box-shadow: 0 20px 50px -12px rgba(10, 60, 70, .25), 0 2px 6px rgba(10, 60, 70, .08);
}
.card h2 { margin: 0 0 4px; font-size: 20px; color: var(--ink-soft); }
.card .sub { margin-bottom: 18px; }
.card label { display: block; margin-bottom: 6px; font-weight: 600; color: var(--ink-soft); }
.card input {
  width: 100%; padding: 10px 12px; margin-bottom: 14px;
  border: 1.5px solid var(--line); border-radius: 10px; background: #fff;
}
.card input:focus, .search:focus, .comment-editor:focus {
  outline: none; border-color: var(--teal); box-shadow: 0 0 0 3px rgba(14, 140, 153, .18);
}
.form-error {
  margin: -4px 0 14px; padding: 9px 12px; border-radius: 9px;
  background: var(--danger-tint); color: var(--danger);
}

/* ---------- toolbar ---------- */

#board { padding: 16px 24px 40px; }
.toolbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  margin-bottom: 12px;
}
.filters { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 5px 11px; border-radius: 999px; cursor: pointer;
  border: 1.5px solid var(--line); background: #fff; color: var(--ink-soft); font-weight: 600;
}
.chip .count {
  min-width: 20px; padding: 0 6px; border-radius: 999px;
  background: var(--page); color: var(--muted); font-size: 12px; text-align: center;
  font-variant-numeric: tabular-nums;
}
.chip:hover { border-color: var(--teal); }
.chip[aria-pressed="true"] { background: var(--teal); border-color: var(--teal); color: #fff; }
.chip[aria-pressed="true"] .count { background: rgba(255, 255, 255, .25); color: #fff; }
.search {
  width: 280px; max-width: 100%; padding: 8px 12px;
  border: 1.5px solid var(--line); border-radius: 9px; background: #fff;
}

/* ---------- grid ---------- */

.grid-wrap {
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  overflow: auto; max-height: calc(100vh - 170px);
}
.grid { width: 100%; border-collapse: separate; border-spacing: 0; table-layout: fixed; }
.grid th, .grid td {
  padding: 9px 12px; text-align: left; vertical-align: top;
  border-bottom: 1px solid var(--line); border-right: 1px solid var(--line);
}
.grid th:last-child, .grid td:last-child { border-right: 0; }
.grid thead th {
  position: sticky; top: 0; z-index: 2;
  background: #EEF4F5; color: var(--ink-soft); font-size: 12.5px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .03em;
}
.grid th button {
  all: unset; cursor: pointer; display: inline-flex; align-items: center; gap: 4px; border-radius: 4px;
}
.grid th button::after { content: "↕"; opacity: .3; font-size: 11px; }
.grid th[aria-sort="ascending"] button::after { content: "↑"; opacity: 1; }
.grid th[aria-sort="descending"] button::after { content: "↓"; opacity: 1; }
.grid tbody tr:hover td { background: #FAFCFC; }
.grid tbody tr.fresh td { animation: fresh 3s ease-out; }
@keyframes fresh { from { background: #FFF6CC; } to { background: transparent; } }

.c-nr { width: 64px; font-variant-numeric: tabular-nums; color: var(--muted); }
.c-issue { width: 34%; white-space: pre-wrap; overflow-wrap: anywhere; }
.c-who { width: 15%; }
.c-date { width: 130px; white-space: nowrap; font-variant-numeric: tabular-nums; color: var(--ink-soft); }
.c-status { width: 140px; }
.c-comments { width: auto; }
td.c-nr { font-weight: 600; }

select.status {
  width: 100%; padding: 4px 8px; border-radius: 999px; cursor: pointer;
  border: 1.5px solid transparent; font-weight: 600; font-size: 13px;
}
select.status:focus-visible { outline: 3px solid rgba(14, 140, 153, .35); outline-offset: 1px; }
select.status option { background: #fff; color: var(--ink); }
[data-status="Started"].status     { color: var(--st-started);  background: var(--st-started-bg); }
[data-status="In progress"].status { color: var(--st-progress); background: var(--st-progress-bg); }
[data-status="Done"].status        { color: var(--st-done);     background: var(--st-done-bg); }
[data-status="Rejected"].status    { color: var(--st-rejected); background: var(--st-rejected-bg); }
[data-status="On hold"].status     { color: var(--st-hold);     background: var(--st-hold-bg); }
tr[data-status="Done"] td:not(.c-status), tr[data-status="Rejected"] td:not(.c-status) { color: var(--muted); }

.comment {
  all: unset; display: block; width: 100%; min-height: 22px; cursor: text; border-radius: 6px;
  white-space: pre-wrap; overflow-wrap: anywhere; box-sizing: border-box;
}
.comment:hover { background: var(--teal-tint); outline: 4px solid var(--teal-tint); }
.comment.empty { color: #A3AAAF; font-style: italic; }
.comment-editor {
  width: 100%; min-height: 70px; padding: 6px 8px; resize: vertical;
  border: 1.5px solid var(--teal); border-radius: 8px; background: #fff;
}
.hint { display: block; margin-top: 4px; font-size: 11.5px; color: var(--muted); }

.empty-state { margin: 0; padding: 40px 16px; text-align: center; color: var(--muted); }

/* ---------- toast ---------- */

.toast {
  position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%); z-index: 10;
  max-width: calc(100vw - 32px); padding: 10px 16px; border-radius: 10px;
  background: #23363A; color: #fff; font-weight: 600; box-shadow: 0 10px 30px rgba(0, 0, 0, .2);
}
.toast[data-kind="warn"] { background: #8A5A00; }
.toast[data-kind="error"] { background: var(--danger); }

/* ---------- narrow screens: one card per task ---------- */

@media (max-width: 760px) {
  .topbar { position: static; padding: 10px 16px; }
  #board { padding: 12px 16px 32px; }
  .search { width: 100%; }
  .grid-wrap { max-height: none; overflow: visible; background: none; border: 0; }
  .grid, .grid tbody, .grid tr, .grid td { display: block; width: auto; }
  .grid thead { display: none; }
  .grid tr {
    margin-bottom: 10px; padding: 6px 0; background: var(--card);
    border: 1px solid var(--line); border-radius: 12px;
  }
  .grid td { border: 0; padding: 5px 14px; }
  .grid td::before {
    content: attr(data-label); display: block;
    font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; color: var(--muted);
  }
  .c-status select.status { width: auto; }
}

@media (prefers-reduced-motion: reduce) {
  .grid tbody tr.fresh td { animation: none; }
}
