/* Liemux To-Do.
   The token block and the login/topbar rules are lifted from the accountant
   portal so the two sites read as siblings; everything below the divider is
   board-specific.

   Layout rule for this file: nothing may have a fixed width that the viewport
   has to grow to fit. The task list is a CSS grid that collapses to two rows on
   narrow screens rather than a table that scrolls sideways. */

:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #fbfbfc;
  --border: #e3e6ea;
  --text: #1a1d21;
  --text-dim: #646b74;
  --text-faint: #8b929b;
  --accent: #2f6f4f;
  --accent-soft: #e8f2ec;
  --info: #2f5f9f;
  --info-soft: #e7eefa;
  --warn: #8a5a2b;
  --warn-soft: #f6eee3;
  --danger: #a8342c;
  --danger-soft: #fbeceb;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 20, 26, .06), 0 4px 14px rgba(16, 20, 26, .05);
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #14171a; --surface: #1c2024; --surface-2: #21262b; --border: #2f353b;
    --text: #e8eaed; --text-dim: #a2abb5; --text-faint: #79828c;
    --accent: #6fbf90; --accent-soft: #1e2f26;
    --info: #7fb0e8; --info-soft: #1a242f;
    --warn: #d3a06a; --warn-soft: #2d251a;
    --danger: #e0796f; --danger-soft: #2e1e1c;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 14px rgba(0, 0, 0, .25);
  }
}

:root[data-theme="dark"] {
  --bg: #14171a; --surface: #1c2024; --surface-2: #21262b; --border: #2f353b;
  --text: #e8eaed; --text-dim: #a2abb5; --text-faint: #79828c;
  --accent: #6fbf90; --accent-soft: #1e2f26;
  --info: #7fb0e8; --info-soft: #1a242f;
  --warn: #d3a06a; --warn-soft: #2d251a;
  --danger: #e0796f; --danger-soft: #2e1e1c;
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 4px 14px rgba(0,0,0,.25);
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
        "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow-wrap: break-word;
}

a { color: inherit; }

/* ---------------------------------------------------------------- login */
.login-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  padding: 24px;
}
.login-card {
  width: 100%; max-width: 380px; background: var(--surface);
  border: 1px solid var(--border); border-radius: 14px; padding: 34px 30px;
  box-shadow: var(--shadow);
}
.login-card h1 { margin: 0 0 4px; font-size: 21px; font-weight: 660; letter-spacing: -.02em; }
.login-card .lead { margin: 0 0 24px; color: var(--text-dim); font-size: 14px; }
.login-foot { margin-top: 20px; text-align: center; font-size: 12px; color: var(--text-faint); }

.field { margin-bottom: 15px; min-width: 0; }
.field label {
  display: block; font-size: 12px; font-weight: 620; color: var(--text-dim);
  margin-bottom: 6px; text-transform: uppercase; letter-spacing: .05em;
}
.field input, .field select, .field textarea {
  width: 100%; max-width: 100%; padding: 11px 13px; font: inherit; font-size: 16px;
  border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface-2); color: var(--text);
}
.field textarea { resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.btn {
  padding: 11px 22px; font: inherit; font-size: 15px; font-weight: 600;
  color: #fff; background: var(--accent); border: none; border-radius: 8px;
  cursor: pointer;
}
.login-card .btn { width: 100%; margin-top: 6px; }
.btn:hover { filter: brightness(1.07); }
.alert {
  background: var(--danger-soft); color: var(--danger); padding: 10px 13px;
  border-radius: 8px; font-size: 13.5px; margin-bottom: 16px; font-weight: 500;
}

/* --------------------------------------------------------------- topbar */
.topbar { background: var(--surface); border-bottom: 1px solid var(--border); }
.topbar-inner {
  max-width: 1240px; margin: 0 auto; padding: 9px 16px; min-height: 56px;
  display: flex; align-items: center; gap: 8px 18px; flex-wrap: wrap;
}
.brand { display: flex; align-items: baseline; gap: 6px; }
.brand-name { font-weight: 680; letter-spacing: -.02em; }
.brand-sub { color: var(--text-dim); font-size: 13px; }
.nav { display: flex; gap: 4px; }
.nav a {
  text-decoration: none; color: var(--text-dim); font-size: 14px; font-weight: 550;
  padding: 6px 11px; border-radius: 7px;
}
.nav a:hover { background: var(--surface-2); color: var(--text); }
.nav a.active { background: var(--accent-soft); color: var(--accent); }
.topbar-right {
  margin-left: auto; display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
}
.signout {
  font: inherit; font-size: 13.5px; color: var(--text-dim); background: none;
  border: 1px solid var(--border); border-radius: 7px; padding: 6px 12px;
  cursor: pointer; white-space: nowrap;
}
.signout:hover { color: var(--text); border-color: var(--text-faint); }

.wrap { max-width: 1240px; margin: 0 auto; padding: 22px 16px 40px; }
.foot {
  max-width: 1240px; margin: 0 auto; padding: 0 16px 36px;
  color: var(--text-faint); font-size: 12.5px; text-align: center;
}

.btn-sm {
  font: inherit; font-size: 13.5px; font-weight: 560; text-decoration: none;
  color: #fff; background: var(--accent); border: 1px solid transparent;
  border-radius: 7px; padding: 6px 12px; cursor: pointer; white-space: nowrap;
}
.btn-sm:hover { filter: brightness(1.07); }
.btn-sm.ghost { color: var(--text-dim); background: none; border-color: var(--border); }
.btn-sm.ghost:hover { color: var(--text); border-color: var(--text-faint); filter: none; }
.btn-danger {
  font: inherit; font-size: 13.5px; font-weight: 560; color: var(--danger);
  background: var(--danger-soft); border: 1px solid transparent;
  border-radius: 7px; padding: 7px 14px; cursor: pointer;
}

/* -------------------------------------------------------------- filters */
.filterbox {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); margin-bottom: 18px;
}
/* The summary is a phone affordance; on desktop the bar is simply always open. */
.filterbox > summary { display: none; }
.filters {
  display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 12px;
}
.filters select, .filters .search {
  font: inherit; font-size: 13.5px; padding: 7px 10px; min-width: 0; max-width: 100%;
  border: 1px solid var(--border); border-radius: 7px;
  background: var(--surface-2); color: var(--text);
}
.filters .search { flex: 1 1 170px; }
.filters select { flex: 1 1 140px; }
.filters select:focus, .filters .search:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft);
}
.toggle {
  font-size: 13.5px; color: var(--text-dim); display: inline-flex;
  align-items: center; gap: 6px; padding: 0 4px; cursor: pointer; white-space: nowrap;
}

/* --------------------------------------------------------------- avatars */
.avatar {
  width: 26px; height: 26px; border-radius: 50%; object-fit: cover;
  border: 1px solid var(--border); vertical-align: middle;
  background: var(--surface-2); flex: none;
}
.avatar-me { width: 28px; height: 28px; }
.avatar-fallback, .avatar-none {
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 620; color: var(--text-faint);
}
.detail-people .avatar { width: 34px; height: 34px; }

/* ------------------------------------------------------------- task list */
.tasklist {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden;
}
.tasklist-head, .task-row {
  display: grid;
  /* 84px on the two avatar columns: "REQUESTOR" measures ~74px at this weight,
     so 84px leaves real slack; it wrapped onto two lines at the old 62px. */
  grid-template-columns: 30px minmax(0, 1fr) 84px 84px 106px 148px 100px;
  gap: 10px;
  align-items: center;
  padding: 9px 12px;
}
.tasklist-head {
  background: var(--surface-2); border-bottom: 1px solid var(--border);
  font-size: 11.5px; font-weight: 620; text-transform: uppercase;
  letter-spacing: .05em; color: var(--text-faint);
}
.tasklist-head .h-who, .task-row .t-who { text-align: center; }
.tasklist-head span { white-space: nowrap; }
.task { border-bottom: 1px solid var(--border); }
.task:last-child { border-bottom: none; }
.task-row:hover { background: var(--surface-2); }
/* display:contents lets the meta cells sit in the parent grid on wide screens
   and become a wrapping flex row on narrow ones, from one piece of markup. */
.row-meta { display: contents; }

.t-title { min-width: 0; }
.t-title a { text-decoration: none; font-weight: 540; overflow-wrap: anywhere; }
.t-title a:hover { text-decoration: underline; }
.task-row.dim .t-title a { color: var(--text-dim); }
.subcount {
  margin-left: 8px; font-size: 11.5px; color: var(--text-faint);
  border: 1px solid var(--border); border-radius: 20px; padding: 1px 8px;
  white-space: nowrap;
}
.toggle-btn {
  background: none; border: none; cursor: pointer; color: var(--text-dim);
  font-size: 13px; line-height: 1; padding: 6px; border-radius: 5px;
  justify-self: start;
}
.toggle-btn:hover { background: var(--border); color: var(--text); }

/* ------------------------------------------------------ unfolded details */
.task-panel {
  background: var(--surface-2); border-top: 1px dashed var(--border);
  padding: 14px 14px 16px 40px;
}
.panel-desc {
  white-space: pre-wrap; overflow-wrap: anywhere;
  font-size: 14px; color: var(--text-dim); margin-bottom: 14px;
}
.panel-facts {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px 18px; margin-bottom: 14px;
}
.fact { min-width: 0; }
.fact-k {
  display: block; font-size: 11px; font-weight: 620; text-transform: uppercase;
  letter-spacing: .05em; color: var(--text-faint); margin-bottom: 4px;
}
.fact-v { display: flex; align-items: center; gap: 7px; font-size: 13.5px; }

.panel-subs h3 {
  margin: 0 0 4px; font-size: 11px; font-weight: 620; text-transform: uppercase;
  letter-spacing: .05em; color: var(--text-faint);
}
.subrow {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; flex-wrap: wrap; padding: 9px 0; border-top: 1px solid var(--border);
}
.sub-title { text-decoration: none; font-size: 14px; font-weight: 540; min-width: 0; }
.sub-title:hover { text-decoration: underline; }
.subrow.dim .sub-title { color: var(--text-dim); }
.sub-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.sub-meta select.status { width: auto; min-width: 132px; }
.panel-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 14px; }

.muted { color: var(--text-faint); }
.date { color: var(--text-dim); font-size: 13.5px; white-space: nowrap; }

/* A blown deadline is the one thing on this page that should shout. */
.overdue { color: var(--danger); font-weight: 700; font-size: 13.5px; white-space: nowrap; }

/* --------------------------------------------------- priority + status */
.chip {
  display: inline-block; font-size: 11.5px; font-weight: 620; padding: 2px 9px;
  border-radius: 20px; white-space: nowrap;
}
.pri-very_low  { background: var(--surface-2); color: var(--text-faint); border: 1px solid var(--border); }
.pri-low       { background: var(--surface-2); color: var(--text-dim);   border: 1px solid var(--border); }
.pri-medium    { background: var(--info-soft); color: var(--info); }
.pri-high      { background: var(--warn-soft); color: var(--warn); }
.pri-very_high { background: var(--danger-soft); color: var(--danger); }

.t-pri, .t-date { min-width: 0; }
.t-date { text-align: right; }

.statusform { margin: 0; min-width: 0; }
select.status {
  font: inherit; font-size: 12.5px; font-weight: 600; padding: 6px 8px;
  border-radius: 7px; border: 1px solid transparent; cursor: pointer;
  width: 100%; max-width: 100%; -webkit-appearance: none; appearance: none;
}
select.status:focus { outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }
.status-not_started { background: var(--surface-2); color: var(--text-dim); border-color: var(--border); }
.status-in_progress { background: var(--info-soft); color: var(--info); }
.status-done        { background: var(--accent-soft); color: var(--accent); }
.status-declined    { background: var(--danger-soft); color: var(--danger); }
select.status option { color: var(--text); background: var(--surface); font-weight: 500; }

/* --------------------------------------------------------------- kanban */
.kanban { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; align-items: start; }
.column {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden; min-width: 0;
}
.column-head {
  padding: 10px 13px; font-size: 12px; font-weight: 660; text-transform: uppercase;
  letter-spacing: .05em; border-bottom: 1px solid var(--border);
  display: flex; justify-content: space-between; gap: 8px;
}
.column-head .count { opacity: .7; }
.column-body { padding: 10px; display: flex; flex-direction: column; gap: 9px; min-height: 60px; }
.column-empty { margin: 4px 3px; color: var(--text-faint); font-size: 13px; }
.card {
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 8px; padding: 10px 11px; min-width: 0;
}
.card-title { display: block; text-decoration: none; font-weight: 560; font-size: 14px; overflow-wrap: anywhere; }
.card-title:hover { text-decoration: underline; }
.card-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.card-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; margin-top: 9px; }
.card-people { display: flex; gap: 4px; }
.card-people .avatar { width: 22px; height: 22px; }
.key {
  font-family: var(--mono); font-size: 12.5px; color: var(--text-dim);
  text-decoration: none; white-space: nowrap;
}
.key:hover { color: var(--accent); }
.key.sub { color: var(--text-faint); }

/* --------------------------------------------------------------- panels */
.panel {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px; margin-bottom: 18px;
}
.form-panel { max-width: 720px; }
.panel h1 { margin: 0 0 4px; font-size: 20px; font-weight: 660; letter-spacing: -.02em; }
.panel h2 { margin: 0; font-size: 15px; font-weight: 660; }
.detail-title { margin: 0; font-size: 19px; font-weight: 660; letter-spacing: -.02em; }
.panel .lead { margin: 0 0 20px; color: var(--text-dim); font-size: 14px; }
.detail-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; flex-wrap: wrap; margin-bottom: 16px;
}
.detail-people { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.people-label {
  font-size: 11px; font-weight: 620; text-transform: uppercase;
  letter-spacing: .05em; color: var(--text-faint);
}
.field-row { display: flex; gap: 14px; flex-wrap: wrap; }
.field-row .field { flex: 1 1 150px; }
.hint { color: var(--text-faint); font-size: 12.5px; margin: 4px 0 16px; }
.actions { display: flex; align-items: center; gap: 12px; margin-top: 6px; flex-wrap: wrap; }
.meta-line {
  margin: 18px 0 0; padding-top: 14px; border-top: 1px solid var(--border);
  color: var(--text-faint); font-size: 12.5px;
}
.danger-zone { margin-top: 6px; }
.empty {
  background: var(--surface); border: 1px dashed var(--border);
  border-radius: var(--radius); padding: 36px 20px; text-align: center; color: var(--text-dim);
}
.empty p { margin: 0 0 14px; }

/* Any table that survives (the detail page's subtask list) scrolls inside its
   own box rather than widening the page. */
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.tasks { width: 100%; border-collapse: collapse; }
.tasks td { padding: 9px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.tasks tr:last-child td { border-bottom: none; }
.tasks .row.dim .summary a { color: var(--text-dim); }
.tasks .summary a { text-decoration: none; font-weight: 540; }
.tasks .summary a:hover { text-decoration: underline; }
.col-key { width: 76px; }
.col-who { width: 60px; text-align: center; }
.col-pri { width: 106px; }
.col-status { width: 150px; }
.col-date { width: 104px; white-space: nowrap; }

/* ----------------------------------------------------------- responsive */
@media (max-width: 1000px) {
  .tasklist-head, .task-row {
    grid-template-columns: 30px minmax(0, 1fr) 84px 84px 100px 140px 96px;
    gap: 8px;
  }
}

/* Portrait phones and small tablets: the row folds into two lines and the
   avatars move into the unfolded panel, where they have room for names. */
@media (max-width: 860px) {
  .tasklist-head { display: none; }
  .task-row {
    grid-template-columns: 30px minmax(0, 1fr);
    grid-template-areas:
      "toggle title"
      ".      meta";
    row-gap: 8px;
    padding: 11px 12px;
  }
  .task-row > .toggle-btn { grid-area: toggle; align-self: start; margin-top: 1px; }
  .t-title { grid-area: title; }
  .row-meta {
    display: flex; grid-area: meta; flex-wrap: wrap; align-items: center; gap: 8px;
  }
  .t-who { display: none; }
  .t-date { text-align: left; }
  .t-status select.status { width: auto; min-width: 136px; }
  .task-panel { padding-left: 14px; }
  .kanban { grid-template-columns: repeat(2, minmax(0, 1fr)); }

  .filterbox > summary {
    display: flex; align-items: center; justify-content: space-between; gap: 10px;
    padding: 12px 13px; cursor: pointer; font-size: 14px; font-weight: 600;
    list-style: none;
  }
  .filterbox > summary::-webkit-details-marker { display: none; }
  .filterbox > summary::after { content: '\25b8'; color: var(--text-dim); }
  .filterbox[open] > summary::after { content: '\25be'; }
  .filterbox[open] > summary { border-bottom: 1px solid var(--border); }
  .filter-state { font-weight: 500; font-size: 13px; color: var(--text-dim); margin-left: auto; }
  .filter-count {
    background: var(--accent-soft); color: var(--accent);
    border-radius: 20px; padding: 2px 9px; font-weight: 620; font-size: 12px;
  }
}

@media (max-width: 620px) {
  .kanban { grid-template-columns: minmax(0, 1fr); }
  .topbar-inner { gap: 8px 12px; padding: 8px 12px; }
  .nav a { padding: 6px 9px; }
  .brand-sub { display: none; }
  .avatar-me { width: 26px; height: 26px; }
  .wrap { padding: 16px 12px 32px; }
  .filters { padding: 10px; gap: 7px; }
  .filters select { flex: 1 1 calc(50% - 4px); }
  .filters .search { flex: 1 1 100%; }
  .panel { padding: 16px; }
  .panel-facts { grid-template-columns: repeat(auto-fit, minmax(128px, 1fr)); }
}

/* Narrow phones: the topbar drops the nav onto its own line rather than
   pushing Sign out off the edge. */
@media (max-width: 430px) {
  /* Second row: New task on the left, identity and Sign out together on the
     right, rather than three items drifting apart across the width. */
  .topbar-right { width: 100%; margin-left: 0; justify-content: flex-end; }
  .topbar-right > .btn-sm:first-child { margin-right: auto; }
  .task-row { padding: 11px 10px; }
  .task-panel { padding: 12px 10px 14px; }
  .sub-meta { width: 100%; }
}
