:root {
  --paper: #edf0ea;
  --surface: #ffffff;
  --ink: #131a1f;
  --ink-soft: #55636b;
  --line: #d8ded4;
  --finance: #8a5a16;
  --finance-wash: #f6ecdb;
  --admin: #1f5f63;
  --admin-wash: #e1efee;
  --alert: #9e2f1d;
  --alert-wash: #f8e6e2;
  --ok: #2d6b40;
  --radius: 10px;
  --sans: 'Inter Tight', 'Segoe UI', system-ui, -apple-system, sans-serif;
  --serif: 'Newsreader', Georgia, 'Times New Roman', serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -0.01em; }
p { margin: 0; }

/* ---------- login ---------- */
.login {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: var(--ink);
  z-index: 50;
  padding: 24px;
}
.login-card {
  width: min(360px, 100%);
  background: var(--surface);
  border-radius: 14px;
  padding: 32px 28px;
  display: grid;
  gap: 10px;
}
.login-card h1 { font-family: var(--serif); font-size: 30px; font-weight: 500; }
.login-card p { color: var(--ink-soft); margin-bottom: 8px; }
.login-card label { font-size: 13px; color: var(--ink-soft); }
.login-card input {
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbfcfa;
}
.login-card button {
  margin-top: 6px;
  padding: 11px;
  border: 0;
  border-radius: var(--radius);
  background: var(--ink);
  color: #fff;
  cursor: pointer;
}
.login-error { color: var(--alert); min-height: 20px; font-size: 13px; }

/* ---------- shell ---------- */
.app { display: grid; grid-template-columns: 214px 1fr; min-height: 100%; }

.rail {
  background: var(--ink);
  color: #cfd7d2;
  display: flex;
  flex-direction: column;
  padding: 20px 14px;
  gap: 24px;
  position: sticky;
  top: 0;
  height: 100vh;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark {
  width: 30px; height: 30px;
  display: grid; place-items: center;
  border-radius: 8px;
  background: var(--finance);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
}
.brand-name { color: #fff; font-family: var(--serif); font-size: 18px; }

#nav { display: grid; gap: 2px; }
#nav button {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  background: none;
  border: 0;
  color: #a8b4ae;
  padding: 9px 11px;
  border-radius: 8px;
  cursor: pointer;
  text-align: left;
}
#nav button:hover { color: #fff; background: rgba(255,255,255,0.06); }
#nav button.active { background: rgba(255,255,255,0.12); color: #fff; }
#nav em {
  font-style: normal;
  font-size: 12px;
  background: var(--finance);
  color: #fff;
  border-radius: 20px;
  padding: 1px 7px;
}
#nav em:empty { display: none; }

.rail-foot { margin-top: auto; display: grid; gap: 6px; }
.rail-foot .ghost {
  background: rgba(255,255,255,0.08);
  color: #dfe6e1;
  border: 0;
  padding: 9px;
  border-radius: 8px;
  cursor: pointer;
}
.rail-foot .quiet { background: none; color: #87948e; }

.main { min-width: 0; }
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 16px;
  padding: 22px 28px 14px;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  background: var(--paper);
  z-index: 5;
}
.topbar h2 { font-family: var(--serif); font-size: 26px; font-weight: 500; }
.topbar p { color: var(--ink-soft); font-size: 13px; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.sync-state { font-size: 12px; color: var(--ink-soft); }
.view { padding: 22px 28px 80px; display: grid; gap: 18px; }

/* ---------- shared bits ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
}
.card > h3 { font-size: 14px; margin-bottom: 10px; }
.grid { display: grid; gap: 14px; }
.cols-2 { grid-template-columns: 1fr 1fr; }
.cols-3 { grid-template-columns: repeat(3, 1fr); }
.cols-4 { grid-template-columns: repeat(4, 1fr); }

.ghost {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px 12px;
  cursor: pointer;
}
.ghost:hover { border-color: var(--ink-soft); }
.primary {
  background: var(--ink);
  color: #fff;
  border: 0;
  border-radius: 8px;
  padding: 8px 14px;
  cursor: pointer;
}
.mini { font-size: 12px; padding: 4px 9px; border-radius: 7px; }
input, select, textarea {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  background: var(--surface);
  width: 100%;
}
textarea { resize: vertical; min-height: 90px; font-family: inherit; }
:focus-visible { outline: 2px solid var(--admin); outline-offset: 2px; }

.tag {
  font-size: 11.5px;
  padding: 2px 8px;
  border-radius: 20px;
  white-space: nowrap;
}
.tag-finance { background: var(--finance-wash); color: var(--finance); }
.tag-admin { background: var(--admin-wash); color: var(--admin); }
.tag-direct { background: #e6ecf6; color: #2b4a7d; }
.tag-cc { background: #eceee9; color: var(--ink-soft); }
.tag-urgent { background: var(--alert-wash); color: var(--alert); }

.empty { color: var(--ink-soft); font-size: 14px; padding: 6px 0; }

/* ---------- brief and figures ---------- */
.brief { border-left: 3px solid var(--finance); }
.brief p { font-family: var(--serif); font-size: 17.5px; line-height: 1.6; max-width: 68ch; }
.brief-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }

.figure { display: grid; gap: 2px; }
.figure .label { font-size: 12.5px; color: var(--ink-soft); }
.figure .value { font-family: var(--serif); font-size: 27px; font-variant-numeric: tabular-nums; }
.figure input { border: 0; padding: 0; font: inherit; background: none; }
.figure .note { font-size: 11.5px; color: var(--ink-soft); }

/* ---------- task rows ---------- */
.rows { display: grid; }
.row {
  display: grid;
  grid-template-columns: 22px 1fr;
  gap: 4px 12px;
  align-items: start;
  padding: 11px 0;
  border-bottom: 1px solid var(--line);
}
.row:last-child { border-bottom: 0; }
.check {
  width: 19px;
  height: 19px;
  flex: 0 0 19px;
  padding: 0;
  border: 1.5px solid var(--line);
  border-radius: 5px;
  background: none;
  cursor: pointer;
  margin-top: 2px;
}
.check:hover { border-color: var(--ok); }
.row.done .check { background: var(--ok); border-color: var(--ok); }
.row.done .title { text-decoration: line-through; color: var(--ink-soft); }
.row .title { font-weight: 500; }
.row .meta { font-size: 12.5px; color: var(--ink-soft); display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 3px; }
.row .acts, .step-row .acts { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; grid-column: 2; }
.row.overdue .title { color: var(--alert); }

/* ---------- mail ---------- */
.mail { border-bottom: 1px solid var(--line); padding: 13px 0; }
.mail:last-child { border-bottom: 0; }
.mail-head { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; }
.mail-from { font-weight: 500; }
.mail-subject { color: var(--ink-soft); font-size: 13.5px; }
.mail-when { font-size: 12px; color: var(--ink-soft); white-space: nowrap; }
.mail-summary { margin: 7px 0; max-width: 78ch; }
.mail-action {
  font-size: 13.5px;
  background: var(--paper);
  border-radius: 8px;
  padding: 7px 10px;
  margin: 7px 0;
}
.mail-tags { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin-top: 6px; }
.mail.handled { opacity: 0.55; }

.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.filters .chip {
  background: none;
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 5px 13px;
  cursor: pointer;
  font-size: 13px;
}
.filters .chip.on { background: var(--ink); color: #fff; border-color: var(--ink); }

/* ---------- stats ---------- */
.stat { display: grid; gap: 2px; }
.stat .n { font-family: var(--serif); font-size: 30px; font-variant-numeric: tabular-nums; }
.stat .k { font-size: 12.5px; color: var(--ink-soft); }
.chart { width: 100%; height: 180px; display: block; }
.legend { display: flex; gap: 14px; font-size: 12.5px; color: var(--ink-soft); margin-top: 6px; }
.swatch { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: 5px; }

.bar-row { display: grid; grid-template-columns: 140px 1fr 40px; gap: 10px; align-items: center; padding: 5px 0; font-size: 13px; }
.bar { height: 8px; border-radius: 4px; background: var(--admin); }

/* ---------- toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  transform: translateX(-50%);
  background: var(--ink);
  color: #fff;
  padding: 10px 18px;
  border-radius: 24px;
  font-size: 14px;
  z-index: 60;
}

/* ---------- mobile ---------- */
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .rail {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    top: auto;
    height: auto;
    flex-direction: row;
    align-items: center;
    padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
    gap: 0;
    z-index: 20;
  }
  .brand, .rail-foot { display: none; }
  #nav { grid-auto-flow: column; width: 100%; gap: 0; }
  #nav button { flex-direction: column; gap: 2px; justify-content: center; font-size: 12px; padding: 8px 2px; }
  #nav em { position: absolute; transform: translate(26px, -8px); }
  .topbar { padding: 16px 16px 12px; }
  .view { padding: 16px 16px 96px; }
  .cols-2 { grid-template-columns: 1fr; }
  .cols-3, .cols-4 { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 520px) {
  .cols-3, .cols-4 { grid-template-columns: 1fr 1fr; }
  .bar-row { grid-template-columns: 96px 1fr 32px; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* ---------- week board ---------- */
.board {
  display: grid;
  grid-template-columns: repeat(7, minmax(118px, 1fr));
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
}
.col {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 220px;
}
.col.is-today { border-color: var(--finance); box-shadow: inset 0 2px 0 var(--finance); }
.col-head { display: flex; justify-content: space-between; align-items: baseline; font-size: 13px; }
.col-body { display: grid; gap: 7px; flex: 1; border-radius: 8px; padding: 2px; }
.col-body.drop-on, .tray.drop-on { background: var(--admin-wash); outline: 1px dashed var(--admin); }
.tray { display: grid; gap: 7px; border-radius: 8px; padding: 2px; min-height: 60px; }

.wcard {
  border: 1px solid var(--line);
  border-left: 3px solid var(--admin);
  border-radius: 8px;
  padding: 8px 9px;
  background: #fcfdfb;
  cursor: grab;
  display: grid;
  gap: 6px;
}
.wcard.finance { border-left-color: var(--finance); }
.wcard.dragging { opacity: 0.4; }
.wcard.done .wcard-title { text-decoration: line-through; color: var(--ink-soft); }
.wcard-top { display: flex; gap: 8px; align-items: flex-start; }
.wcard-title { font-size: 13.5px; line-height: 1.35; }
.wcard-foot { display: flex; align-items: center; gap: 4px; font-size: 11.5px; }
.wcard-foot .spacer { flex: 1; }
.wcard-foot .mini { padding: 1px 8px; line-height: 1.4; }

.faint { color: var(--ink-soft); font-size: 12px; }
.tag-person { background: #ece7f3; color: #4a3b6b; }
.tag-whatsapp { background: #e4f2e6; color: #23623a; }
.date-move { width: 132px; padding: 3px 7px; font-size: 12px; }

.person .person-open {
  background: none;
  border: 0;
  padding: 0;
  font-family: var(--serif);
  font-size: 22px;
  cursor: pointer;
  text-align: left;
}
.person .person-open:hover { color: var(--finance); }
.person { display: grid; gap: 4px; justify-items: start; }

@media (max-width: 860px) {
  .board { grid-template-columns: repeat(7, 200px); }
  #nav { overflow-x: auto; }
  #nav button { min-width: 62px; font-size: 11px; }
  .date-move { width: 118px; }
}

/* keep wide children inside the main column */
.view > * { min-width: 0; }
.board { max-width: 100%; }
.wcard .check { flex: 0 0 19px; height: 19px; padding: 0; }

/* ---------- more colour ---------- */
:root {
  --routine: #4b3f9e;
  --routine-wash: #eae8f8;
  --idea: #93307f;
  --idea-wash: #f8e8f4;
  --project: #1f6b3a;
  --project-wash: #e2f1e7;
  --mail: #2b4a7d;
  --mail-wash: #e6ecf6;
  --stage-not_started: #6b7780;
  --stage-in_progress: #b8770f;
  --stage-waiting: #6a4fb3;
  --stage-blocked: #9e2f1d;
  --stage-done: #2d6b40;
}

.tag-routine { background: var(--routine-wash); color: var(--routine); }
.tag-idea { background: var(--idea-wash); color: var(--idea); }
.tag-project { background: var(--project-wash); color: var(--project); }

/* coloured card headings */
.card.accent { border-top: 3px solid var(--line); }
.card.accent-finance { border-top-color: var(--finance); }
.card.accent-admin { border-top-color: var(--admin); }
.card.accent-routine { border-top-color: var(--routine); }
.card.accent-idea { border-top-color: var(--idea); }
.card.accent-project { border-top-color: var(--project); }
.card.accent-mail { border-top-color: var(--mail); }
.card.accent-alert { border-top-color: var(--alert); }

.card > h3.dot::before {
  content: '';
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 7px;
  background: currentColor;
  vertical-align: middle;
}
h3.c-finance { color: var(--finance); }
h3.c-admin { color: var(--admin); }
h3.c-routine { color: var(--routine); }
h3.c-idea { color: var(--idea); }
h3.c-project { color: var(--project); }
h3.c-mail { color: var(--mail); }
h3.c-alert { color: var(--alert); }

/* figure tiles */
.figure.tint-0 { background: linear-gradient(180deg, var(--finance-wash), #fff 60%); }
.figure.tint-1 { background: linear-gradient(180deg, var(--alert-wash), #fff 60%); }
.figure.tint-2 { background: linear-gradient(180deg, var(--mail-wash), #fff 60%); }
.figure.tint-3 { background: linear-gradient(180deg, var(--project-wash), #fff 60%); }

/* stage pills */
.stage-select {
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 3px 8px;
  font-size: 11.5px;
  width: auto;
  background: var(--surface);
}
.stage-not_started { color: var(--stage-not_started); border-color: #cfd6cd; }
.stage-in_progress { color: var(--stage-in_progress); border-color: var(--stage-in_progress); background: #fdf6e8; }
.stage-waiting { color: var(--stage-waiting); border-color: var(--stage-waiting); background: #f1eefa; }
.stage-blocked { color: var(--stage-blocked); border-color: var(--stage-blocked); background: var(--alert-wash); }
.stage-done { color: var(--stage-done); border-color: var(--stage-done); background: var(--project-wash); }

/* progress bars and rings */
.progress { height: 9px; border-radius: 6px; background: #e7ebe4; overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--project); border-radius: 6px; }
.progress.finance > span { background: var(--finance); }
.progress.routine > span { background: var(--routine); }
.progress-line { display: flex; align-items: center; gap: 10px; }
.progress-line .progress { flex: 1; }
.pct { font-variant-numeric: tabular-nums; font-size: 13px; color: var(--ink-soft); min-width: 38px; text-align: right; }

/* routine checklist */
.routine-item {
  display: grid;
  grid-template-columns: 22px 1fr auto;
  gap: 10px;
  align-items: start;
  padding: 9px 0;
  border-bottom: 1px solid var(--line);
}
.routine-item:last-child { border-bottom: 0; }
.routine-item.ticked .r-title { text-decoration: line-through; color: var(--ink-soft); }
.routine-item.skipped .r-title { color: var(--ink-soft); font-style: italic; }
.r-title { font-weight: 500; }
.slot-label {
  font-size: 11px;
  letter-spacing: 0.02em;
  color: var(--routine);
  background: var(--routine-wash);
  border-radius: 20px;
  padding: 2px 9px;
}
.streak {
  font-family: var(--serif);
  font-size: 26px;
  color: var(--routine);
  font-variant-numeric: tabular-nums;
}
.spark { display: flex; gap: 3px; align-items: flex-end; height: 42px; }
.spark span { flex: 1; background: var(--routine-wash); border-radius: 2px 2px 0 0; min-height: 3px; }
.spark span.full { background: var(--routine); }

/* nudge */
.nudge {
  background: linear-gradient(180deg, var(--routine-wash), #fff 70%);
  border: 1px solid #d5d1ee;
  border-radius: var(--radius);
  padding: 14px 16px;
  display: grid;
  gap: 8px;
}
.nudge p { max-width: 72ch; }

/* ideas and projects */
.idea-row, .step-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 6px;
  align-items: start;
  padding: 11px 0;
  border-bottom: 1px solid var(--line);
}
.idea-row:last-child, .step-row:last-child { border-bottom: 0; }
.idea-row .acts { display: flex; gap: 6px; flex-wrap: wrap; }
.step-row .acts { grid-column: 1; }
.project-card { display: grid; gap: 8px; }
.project-card h4 { margin: 0; font-family: var(--serif); font-size: 19px; font-weight: 500; }
.project-open { background: none; border: 0; padding: 0; cursor: pointer; text-align: left; font: inherit; }
.project-open:hover { color: var(--project); }

/* inline forms should sit on one line, not stack */
.filters select,
.filters input[type="time"],
.filters input[type="date"],
.filters input[type="number"] { width: auto; }
.filters input[type="text"], .filters input:not([type]) { flex: 1 1 200px; }
.filters { align-items: center; }

.tag-mail { background: var(--mail-wash); color: var(--mail); }
.person .meta { gap: 6px; }

/* notes and actions on tasks, emails and messages */
.notebox { margin-top: 6px; display: grid; gap: 6px; justify-items: start; }
.notebox textarea, .notebox input { width: 100%; max-width: 620px; }
.note-shown {
  background: #fbfcf9;
  border-left: 3px solid var(--admin);
  border-radius: 6px;
  padding: 7px 10px;
  font-size: 13.5px;
  max-width: 72ch;
  white-space: pre-wrap;
}
.note-label {
  display: inline-block;
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-soft);
  margin-right: 8px;
}
.mail-action .note-label { color: var(--finance); }

/* expandable task rows */
.title-btn { background: none; border: 0; padding: 0; font: inherit; font-weight: 500; text-align: left; cursor: pointer; }
.title-btn:hover { color: var(--finance); }
.row.open { background: #fbfcf9; border-radius: 8px; padding: 12px 10px; }
.task-panel { display: grid; gap: 10px; margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--line); }
.task-panel input[type="text"], .task-panel input:not([type]) { flex: 1 1 240px; }
.minibar { display: inline-block; width: 46px; height: 5px; border-radius: 3px; background: #e0e5dd; vertical-align: middle; }
.minibar > span { display: block; height: 100%; border-radius: 3px; background: var(--project); }

.subtasks { display: grid; gap: 5px; }
.subtask { display: flex; align-items: center; gap: 8px; font-size: 13.5px; }
.subtask.done span { text-decoration: line-through; color: var(--ink-soft); }
.subtask .ghost { margin-left: auto; }
.sub-add { max-width: 320px; font-size: 13px; padding: 5px 9px; }

/* email action plan */
.planbox { display: grid; gap: 7px; margin: 8px 0; justify-items: start; }
.plan-step {
  display: grid;
  grid-template-columns: 22px 1fr auto;
  gap: 10px;
  align-items: start;
  width: 100%;
  max-width: 760px;
  background: #fbfcf9;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 13.5px;
}
.plan-num {
  width: 20px; height: 20px;
  display: grid; place-items: center;
  border-radius: 50%;
  background: var(--finance-wash);
  color: var(--finance);
  font-size: 11.5px;
}

/* personal work, kept visually apart from the company */
.tag-personal { background: var(--idea-wash); color: var(--idea); }
.wcard.personal { border-left-color: var(--idea); }

/* small drawings on the dashboard */
.donut { width: 100%; max-width: 150px; display: block; margin: 4px auto 0; }
.donut-n { font-family: var(--serif); font-size: 26px; fill: var(--ink); }
.donut-k { font-size: 10px; fill: var(--ink-soft); }
.weekbars { display: flex; align-items: flex-end; gap: 6px; height: 120px; padding-top: 8px; }
.wb { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; gap: 3px; }
.wb-bar { width: 100%; background: var(--finance); border-radius: 4px 4px 0 0; min-height: 3px; }
.wb-n { font-size: 11px; color: var(--ink-soft); }
.wb-d { font-size: 11px; color: var(--ink-soft); }

/* the status board */
.board-status { grid-template-columns: repeat(5, minmax(150px, 1fr)); }
.stage-col-in_progress { border-top: 3px solid var(--stage-in_progress); }
.stage-col-waiting { border-top: 3px solid var(--stage-waiting); }
.stage-col-blocked { border-top: 3px solid var(--stage-blocked); }
.stage-col-done { border-top: 3px solid var(--stage-done); }
.stage-col-not_started { border-top: 3px solid var(--line); }
