/* style.css — Task Portal
   Values come straight from the token table in the design handoff. */

:root {
  --ink: #1c1b1a;
  --ink-80: #4a4844;
  --ink-60: #57544f;
  --muted: #6f6c68;
  --muted-light: #8b8781;
  --disabled: #a5a19b;
  --border-strong: #c2beb7;
  --border: #e0ddd7;
  --border-soft: #e6e3de;
  --border-input: #ddd9d3;
  --hairline: #eeebe6;
  --raised: #fbfaf9;
  --sunken: #f4f3f1;
  --hover: #f7f6f4;
  --input: #fdfdfc;
  --white: #ffffff;
  --blue: #2f6fb2;
  --green: #5c8f5c;
  --amber: #c98a2e;
  --red: #b4463c;
  --red-border: #d9a49d;
  --red-border-soft: #e6d2cf;
  --sans: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, Menlo, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--sunken);
  font-family: var(--sans);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; color: var(--ink); }
[hidden] { display: none !important; }

/* ---------- offline banner ---------- */

#offline {
  position: fixed;
  left: 0; right: 0; top: 0;
  z-index: 100;
  background: var(--red);
  color: #fff;
  text-align: center;
  padding: 6px 12px;
  font: 400 12px var(--sans);
}

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

.auth-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 20px;
  background: var(--hover);
}
.auth-col { width: 100%; max-width: 340px; display: flex; flex-direction: column; gap: 18px; }
.auth-title {
  text-align: center;
  font: 600 15px var(--sans);
  letter-spacing: -.01em;
  color: var(--ink);
}
.auth-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--white);
  border: 1px solid var(--border-soft);
  border-radius: 12px;
  padding: 20px;
}
.field { display: flex; flex-direction: column; gap: 4px; }
.field-label {
  font: 500 9.5px var(--sans);
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--muted-light);
}
.auth-input {
  border: 1px solid var(--border-input);
  border-radius: 8px;
  min-height: 46px;
  padding: 10px 12px;
  font: 400 14.5px var(--sans);
  background: var(--input);
}
.auth-input.is-error { border-color: var(--red-border); }
.auth-error { font: 400 12.5px/1.4 var(--sans); color: var(--red); }
.auth-submit {
  margin-top: 4px;
  border: 0;
  background: var(--ink);
  color: #fff;
  border-radius: 8px;
  min-height: 48px;
  font: 500 14.5px var(--sans);
}
.auth-submit[disabled] { opacity: .6; cursor: default; }

/* ---------- shell ---------- */

.shell { min-height: 100vh; display: flex; }

.sidebar {
  width: 236px;
  flex: none;
  background: var(--raised);
  border-right: 1px solid var(--border-soft);
  min-height: 100vh;
  padding: 18px 14px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
.sidebar-title { font: 600 15px/1.2 var(--sans); letter-spacing: -.01em; padding: 0 6px; }
.sidebar-nav { display: flex; flex-direction: column; gap: 2px; }
.nav-btn {
  text-align: left;
  border: 0;
  background: transparent;
  color: var(--ink-60);
  border-radius: 6px;
  padding: 8px 10px;
  font: 400 13.5px var(--sans);
  display: flex;
  justify-content: space-between;
  align-items: center;
  min-height: 36px;
}
.nav-btn.is-active { background: #efece7; color: var(--ink); }
.nav-count { font: 400 11px var(--mono); color: var(--disabled); }
.sidebar-projects { display: flex; flex-direction: column; gap: 2px; min-height: 0; overflow-y: auto; }
.sidebar-heading {
  font: 500 10px var(--sans);
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--muted-light);
  padding: 4px 10px 6px;
}
.proj-btn {
  text-align: left;
  border: 0;
  background: transparent;
  color: var(--ink-60);
  border-radius: 6px;
  padding: 7px 10px;
  font: 400 13px var(--sans);
  display: flex;
  justify-content: space-between;
  align-items: center;
  min-height: 34px;
  gap: 8px;
}
.proj-btn.is-active { background: #efece7; color: var(--ink); }
.proj-btn > span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.spacer { flex: 1; }
.btn-new {
  border: 1px solid var(--ink);
  background: var(--ink);
  color: #fff;
  border-radius: 7px;
  min-height: 38px;
  font: 400 13px var(--sans);
}
.btn-print {
  border: 1px solid var(--border-input);
  background: var(--white);
  border-radius: 7px;
  min-height: 36px;
  font: 400 13px var(--sans);
}
.sidebar-foot {
  border-top: 1px solid var(--border-soft);
  padding-top: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.account-email {
  font: 400 11.5px var(--sans);
  color: var(--muted-light);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.signout-link {
  border: 0;
  background: transparent;
  padding: 4px;
  font: 400 11.5px var(--sans);
  color: var(--muted);
  text-decoration: underline;
  text-underline-offset: 2px;
  flex: none;
}

.main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  background: var(--white);
  min-height: 100vh;
  padding-bottom: 76px;
}

/* ---------- header ---------- */

.head {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--white);
  border-bottom: 1px solid var(--border-soft);
  padding: 10px 14px;
}
.head-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.head-titles { min-width: 0; }
.head-title {
  font: 600 18px/1.2 var(--sans);
  letter-spacing: -.01em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.head-sub { font: 400 11.5px var(--sans); color: var(--muted-light); margin-top: 1px; }
.head-actions { display: flex; gap: 6px; align-items: center; }
.icon-btn {
  border: 1px solid var(--border);
  background: var(--white);
  border-radius: 6px;
  width: 34px;
  height: 34px;
  font-size: 14px;
  color: var(--ink-60);
  flex: none;
}
.menu-anchor { position: relative; }
.menu {
  position: absolute;
  right: 0;
  top: 40px;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 6px 20px rgba(0,0,0,.12);
  padding: 6px;
  min-width: 190px;
  z-index: 60;
}
.menu-email {
  padding: 7px 9px 8px;
  font: 400 11.5px var(--sans);
  color: var(--muted-light);
  border-bottom: 1px solid var(--hairline);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.menu-item {
  width: 100%;
  text-align: left;
  border: 0;
  background: transparent;
  padding: 10px 9px;
  font: 400 13.5px var(--sans);
  color: var(--ink);
  min-height: 42px;
}

.chips { display: flex; gap: 6px; margin-top: 9px; overflow-x: auto; padding-bottom: 10px; }
.chip {
  flex: none;
  padding: 6px 11px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--white);
  color: var(--ink-60);
  font: 400 12px var(--sans);
  white-space: nowrap;
  min-height: 32px;
}
.chip.is-active { background: var(--ink); color: #fff; border-color: var(--ink); }

.summary-strip {
  margin-top: 9px;
  width: 100%;
  text-align: left;
  padding: 7px 10px;
  background: var(--hover);
  border: 1px solid var(--border-soft);
  border-radius: 6px;
  font: 400 12px var(--sans);
  color: var(--muted);
  min-height: 34px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.summary-caret { color: var(--disabled); }
.summary-panel {
  margin-top: 10px;
  border: 1px solid #e3e0db;
  border-radius: 8px;
  background: var(--raised);
  padding: 12px;
}
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 9px; }
.stat { display: flex; flex-direction: column; gap: 1px; }
.stat-value { font: 500 21px/1 var(--sans); color: var(--ink); }
.stat-value.is-alert { color: var(--red); }
.stat-label { font: 400 11.5px var(--sans); color: var(--muted); }

/* ---------- list ---------- */

.list { flex: 1; }
.group-head {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 14px 6px;
  background: var(--sunken);
  border: 0;
  border-top: 1px solid var(--border-soft);
  border-bottom: 1px solid var(--border-soft);
  font: 500 10.5px var(--sans);
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--muted);
  text-align: left;
  position: sticky;
  top: 0;
  z-index: 10;
}
.group-head > span:first-child { overflow: hidden; text-overflow: ellipsis; }
.group-count { font: 400 10.5px var(--mono); color: var(--disabled); flex: none; }

.row { border-bottom: 1px solid var(--hairline); background: var(--white); }
.row.is-expanded { background: var(--hover); }
.row-main { display: flex; align-items: center; gap: 10px; padding: 0 14px; min-height: 44px; }
.status-btn {
  flex: none;
  width: 44px;
  height: 44px;
  margin-left: -13px;
  border: 0;
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
}
.status-dot {
  width: 17px;
  height: 17px;
  border-radius: 50%;
  border: 1.5px solid var(--border-strong);
  background: var(--white);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  color: #fff;
  transition: all .18s ease;
}
.status-dot.is-progress { border-color: var(--blue); background: linear-gradient(90deg, var(--blue) 50%, #fff 50%); }
.status-dot.is-done { border-color: var(--green); background: var(--green); }

.row-open {
  flex: 1;
  min-width: 0;
  border: 0;
  background: transparent;
  text-align: left;
  padding: 8px 0;
  display: flex;
  align-items: center;
  gap: 9px;
}
.row-desc {
  flex: 1;
  min-width: 0;
  font: 400 13.5px/1.3 var(--sans);
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.row.is-expanded .row-desc { font-weight: 500; }
.row-desc.is-done { color: var(--disabled); text-decoration: line-through; }
.row-tag {
  flex: none;
  font: 400 10.5px var(--sans);
  color: var(--ink-60);
  background: #f0eeea;
  border-radius: 4px;
  padding: 2px 6px;
}
.row-urgent { flex: none; width: 5px; height: 5px; border-radius: 50%; background: var(--red); }
.row-cx { flex: none; width: 7px; height: 7px; border-radius: 50%; }
.row-meta { flex: none; font: 400 11px var(--mono); color: var(--disabled); }
.row-meta.is-late { color: var(--red); }

.expand { padding: 2px 14px 14px 40px; display: flex; flex-direction: column; gap: 10px; }
.read-block { display: flex; flex-direction: column; gap: 9px; }
.details-text { font: 400 13px/1.55 var(--sans); color: var(--ink-80); white-space: pre-wrap; }
.notes-block { display: flex; flex-direction: column; gap: 3px; }
.meta-line { display: flex; flex-wrap: wrap; gap: 14px; font: 400 11.5px var(--sans); color: var(--muted); }
.row-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.btn {
  border: 1px solid var(--border-input);
  background: var(--white);
  border-radius: 6px;
  padding: 8px 12px;
  font: 400 12.5px var(--sans);
  min-height: 36px;
}
.btn-dark { border-color: var(--ink); background: var(--ink); color: #fff; }
.btn-danger { border-color: var(--red-border-soft); color: var(--red); }
.btn[disabled] { opacity: .55; cursor: default; }

/* ---------- edit form ---------- */

.edit-form { display: flex; flex-direction: column; gap: 9px; }
.edit-row { display: flex; gap: 9px; flex-wrap: wrap; }
.edit-row .field { flex: 1; min-width: 120px; }
.inp {
  border: 1px solid var(--border-input);
  border-radius: 7px;
  min-height: 40px;
  padding: 8px 10px;
  font: 400 13.5px var(--sans);
  background: var(--white);
  width: 100%;
}
.inp-sm { font-size: 13px; }
textarea.inp { min-height: 0; font: 400 13px/1.5 var(--sans); resize: vertical; }
.edit-actions { display: flex; gap: 8px; }
.edit-actions .btn { min-height: 38px; padding: 9px 14px; }

.empty, .loading {
  padding: 56px 20px;
  text-align: center;
  font: 400 13.5px var(--sans);
  color: var(--muted-light);
}

/* ---------- mobile furniture ---------- */

.fab {
  position: fixed;
  right: 16px;
  bottom: 70px;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: 0;
  background: var(--ink);
  color: #fff;
  font-size: 22px;
  box-shadow: 0 3px 12px rgba(0,0,0,.28);
  z-index: 40;
}
.tabbar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  height: 56px;
  background: var(--raised);
  border-top: 1px solid var(--border-soft);
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  z-index: 41;
}
.tab {
  border: 0;
  background: transparent;
  font: 400 11px var(--sans);
  color: var(--ink-60);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
}
.tab.is-active { font-weight: 500; color: var(--ink); }

/* ---------- sheets and dialogs ---------- */

.scrim {
  position: fixed;
  inset: 0;
  background: rgba(28,27,26,.35);
  z-index: 50;
  display: flex;
  justify-content: center;
}
.scrim-bottom { align-items: flex-end; }
.scrim-center { align-items: center; padding: 18px; }

.sheet {
  width: 100%;
  max-width: 520px;
  background: var(--white);
  border-radius: 14px 14px 0 0;
  padding: 14px 16px 22px;
  display: flex;
  flex-direction: column;
  gap: 11px;
  max-height: 92vh;
  overflow: auto;
}
.sheet-head { display: flex; align-items: center; justify-content: space-between; }
.sheet-title { font: 600 14.5px var(--sans); }
.sheet-cancel { border: 0; background: transparent; font: 400 13.5px var(--sans); color: var(--muted); padding: 4px 0; }
.sheet-save { border: 0; background: transparent; font: 500 13.5px var(--sans); color: var(--blue); padding: 4px 0; }
.sheet .inp { min-height: 44px; padding: 10px; font-size: 14px; background: var(--input); }
.sheet .edit-row .field { min-width: 140px; }
.sheet-add {
  border: 0;
  background: var(--ink);
  color: #fff;
  border-radius: 8px;
  min-height: 48px;
  font: 400 14px var(--sans);
  margin-top: 2px;
}

.seg {
  display: flex;
  border: 1px solid var(--border-input);
  border-radius: 7px;
  overflow: hidden;
  min-height: 44px;
}
.seg-btn {
  flex: 1;
  border: 0;
  border-right: 1px solid var(--border-input);
  background: var(--input);
  color: var(--ink);
  font: 400 13px var(--sans);
}
.seg-btn:last-child { border-right: 0; }
.seg-btn.is-active { background: var(--ink); color: #fff; }
.seg-label {
  font: 500 9.5px var(--sans);
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--muted-light);
  margin-bottom: 5px;
}

.dialog {
  width: 100%;
  max-width: 440px;
  background: var(--white);
  border-radius: 12px;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  max-height: 88vh;
  overflow: auto;
}
.dialog-title { font: 600 15px var(--sans); }
.check-list { display: flex; flex-direction: column; gap: 2px; }
.check-row {
  display: flex;
  align-items: center;
  gap: 9px;
  border: 0;
  background: transparent;
  padding: 7px 4px;
  text-align: left;
  font: 400 13.5px var(--sans);
  min-height: 38px;
}
.check-box {
  width: 17px;
  height: 17px;
  flex: none;
  border-radius: 4px;
  border: 1.5px solid var(--border-strong);
  background: var(--white);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
}
.check-box.is-on { border-color: var(--ink); background: var(--ink); }
.dialog .seg { min-height: 42px; }
.dialog .seg-btn { background: var(--white); font-size: 12.5px; }
.dialog .seg-btn.is-active { background: var(--ink); color: #fff; }
.dialog-note { font: 400 12px var(--sans); color: var(--muted-light); }
.dialog-actions { display: flex; gap: 9px; justify-content: flex-end; }
.dialog-actions .btn { min-height: 42px; padding: 10px 16px; font-size: 13px; border-radius: 7px; }

.toast {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: 84px;
  background: var(--ink);
  color: #fff;
  padding: 10px 16px;
  border-radius: 8px;
  font: 400 12.5px var(--sans);
  z-index: 80;
  box-shadow: 0 6px 20px rgba(0,0,0,.2);
  max-width: calc(100vw - 32px);
  text-align: center;
}

/* ---------- desktop ---------- */

@media (min-width: 720px) {
  .main { padding-bottom: 24px; }
  .row-main { min-height: 40px; }
  .toast { bottom: 24px; left: auto; right: 24px; transform: none; }
}

/* ---------- print ---------- */

#printroot { display: none; }

@media print {
  body { background: #fff; }
  body * { visibility: hidden; }
  #printroot, #printroot * { visibility: visible; }
  #printroot {
    display: block !important;
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    padding: 0;
  }
}

.print-page { padding: 24pt; font-family: var(--sans); color: #000; }
.print-title { font: 600 16pt var(--sans); margin-bottom: 2pt; }
.print-sub { font: 400 9pt var(--sans); color: #444; margin-bottom: 14pt; }
.print-group { margin-bottom: 12pt; }
.print-group-head {
  font: 600 10pt var(--sans);
  border-bottom: 1pt solid #000;
  padding-bottom: 3pt;
  margin-bottom: 4pt;
}
.print-row {
  display: flex;
  gap: 8pt;
  align-items: baseline;
  padding: 3pt 0;
  border-bottom: .5pt solid #ccc;
  font: 400 10pt var(--sans);
}
.print-desc { flex: 1; }
.print-meta { font: 400 8.5pt var(--mono); color: #555; }

/* Blank write-in lines at the end of the printout.
   print-color-adjust asks the browser to keep the grey banding instead of
   dropping it as a background; the bottom rule is the fallback for when it
   does drop it anyway, so the lines are always visible to write on. */
.print-blanks { margin-top: 16pt; }
.print-blank {
  height: 20pt;
  border-bottom: .5pt solid #bbb;
  background: #fff;
  -webkit-print-color-adjust: exact;
  print-color-adjust: exact;
}
.print-blank.is-alt { background: #efefef; }
