/* ------------------------------------------------------------------
   Project Tracker
   Warm paper, white cards, generous spacing — a Basecamp-ish feel.
   One stylesheet, no build step, no third-party requests.
   ------------------------------------------------------------------ */

:root {
    --paper: #f6f2ea;
    --card: #ffffff;
    --card-2: #faf7f1;
    --line: #e2dcd1;
    --line-soft: #ece7dd;

    --ink: #1f1c19;
    --ink-2: #55504a;
    --ink-3: #857e75;

    --green: #1c7c54;
    --green-soft: #e4f0ea;
    --blue: #1a5fb4;
    --blue-soft: #e5edf8;
    --amber: #9a6b18;
    --amber-soft: #f8efdc;
    --red: #a3372c;
    --red-soft: #f8e6e3;
    --grey-soft: #efece6;

    --radius: 8px;
    --radius-sm: 5px;
    --shadow: 0 1px 2px rgba(31, 28, 25, .05), 0 4px 14px -8px rgba(31, 28, 25, .18);
    --shadow-lift: 0 2px 4px rgba(31, 28, 25, .07), 0 10px 26px -12px rgba(31, 28, 25, .3);

    --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --paper: #171614;
        --card: #211f1c;
        --card-2: #262320;
        --line: #383430;
        --line-soft: #2d2a26;

        --ink: #eae6e0;
        --ink-2: #b5afa6;
        --ink-3: #8b847a;

        --green: #6fc39b;
        --green-soft: #16241d;
        --blue: #7aa9e8;
        --blue-soft: #16202e;
        --amber: #d9ab5c;
        --amber-soft: #251e12;
        --red: #e08a7e;
        --red-soft: #2a1a17;
        --grey-soft: #2a2723;

        --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 4px 14px -8px rgba(0, 0, 0, .7);
        --shadow-lift: 0 2px 4px rgba(0, 0, 0, .5), 0 10px 26px -12px rgba(0, 0, 0, .9);
    }
}

:root[data-theme="dark"] {
    --paper: #171614;
    --card: #211f1c;
    --card-2: #262320;
    --line: #383430;
    --line-soft: #2d2a26;
    --ink: #eae6e0;
    --ink-2: #b5afa6;
    --ink-3: #8b847a;
    --green: #6fc39b;
    --green-soft: #16241d;
    --blue: #7aa9e8;
    --blue-soft: #16202e;
    --amber: #d9ab5c;
    --amber-soft: #251e12;
    --red: #e08a7e;
    --red-soft: #2a1a17;
    --grey-soft: #2a2723;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 4px 14px -8px rgba(0, 0, 0, .7);
    --shadow-lift: 0 2px 4px rgba(0, 0, 0, .5), 0 10px 26px -12px rgba(0, 0, 0, .9);
}

* { box-sizing: border-box; }

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

body {
    margin: 0;
    background: var(--paper);
    color: var(--ink);
    font-family: var(--sans);
    font-size: 16px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--blue); text-decoration: underline; text-underline-offset: 2px; }
a:hover { text-decoration: none; }

h1, h2, h3, h4 { margin: 0 0 .35em; line-height: 1.2; font-weight: 700; letter-spacing: -.01em; }
h1 { font-size: 1.75rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.02rem; }

p { margin: 0 0 1em; }
p:last-child { margin-bottom: 0; }

.muted { color: var(--ink-3); }
.small { font-size: 13.5px; }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.grow { flex: 1 1 auto; min-width: 0; }

:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }

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

.topbar {
    background: var(--card);
    border-bottom: 1px solid var(--line);
}

.topbar-inner {
    max-width: 1160px;
    margin: 0 auto;
    padding: 0 22px;
    display: flex;
    align-items: center;
    gap: 22px;
    min-height: 60px;
    flex-wrap: wrap;
}

.brand {
    font-weight: 700;
    font-size: 16px;
    color: var(--ink);
    text-decoration: none;
    letter-spacing: -.02em;
    white-space: nowrap;
}

.topnav { display: flex; gap: 2px; flex-wrap: wrap; }

.topnav a {
    color: var(--ink-2);
    text-decoration: none;
    font-size: 14.5px;
    font-weight: 500;
    padding: 7px 13px;
    border-radius: var(--radius-sm);
}

.topnav a:hover { background: var(--grey-soft); color: var(--ink); }
.topnav a.active { background: var(--ink); color: var(--card); }

.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 12px; }

.avatar {
    width: 30px; height: 30px;
    border-radius: 50%;
    background: var(--green);
    color: #fff;
    font-size: 11.5px;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    letter-spacing: .02em;
    text-decoration: none;
    flex: 0 0 auto;
}

.bell {
    position: relative;
    color: var(--ink-2);
    text-decoration: none;
    font-size: 14px;
    padding: 6px 10px;
    border-radius: var(--radius-sm);
}
.bell:hover { background: var(--grey-soft); }
.bell .count {
    background: var(--red); color: #fff;
    font-size: 10.5px; font-weight: 700;
    border-radius: 9px; padding: 1px 6px; margin-left: 4px;
}

.linkbtn {
    background: none; border: 0; padding: 0;
    color: var(--ink-3); font: inherit; font-size: 13.5px;
    cursor: pointer; text-decoration: underline;
}
.linkbtn:hover { color: var(--ink); }

main { max-width: 1160px; margin: 0 auto; padding: 28px 22px 90px; }

.page-head {
    display: flex; align-items: flex-start; gap: 16px;
    flex-wrap: wrap; margin-bottom: 22px;
}

.eyebrow {
    font-size: 12.5px; font-weight: 600; letter-spacing: .04em;
    text-transform: uppercase; color: var(--ink-3); margin: 0 0 4px;
}

/* ---------------- cards ---------------- */

.card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 20px;
}

.card-head {
    padding: 14px 18px;
    border-bottom: 1px solid var(--line-soft);
    display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
}
.card-head h2, .card-head h3 { margin: 0; font-size: 15px; }
.card-body { padding: 18px; }
.card-body > :last-child { margin-bottom: 0; }

.cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 18px;
}
.cards .card { margin: 0; }

/* project tiles */
.project-tile { display: block; text-decoration: none; color: inherit; transition: box-shadow .12s ease; }
.project-tile:hover { box-shadow: var(--shadow-lift); }
.project-tile .swatch { height: 5px; border-radius: var(--radius) var(--radius) 0 0; }
.project-tile h3 { margin: 0 0 4px; }
.project-tile .meta { font-size: 13px; color: var(--ink-3); }

/* ---------------- board ---------------- */

.board {
    display: grid;
    grid-template-columns: repeat(5, minmax(220px, 1fr));
    gap: 14px;
    align-items: start;
    overflow-x: auto;
    padding-bottom: 8px;
}

.column {
    background: var(--card-2);
    border: 1px solid var(--line-soft);
    border-radius: var(--radius);
    min-width: 220px;
}

.column-head {
    padding: 11px 14px;
    display: flex; align-items: center; gap: 8px;
    border-bottom: 1px solid var(--line-soft);
}
.column-head h3 { margin: 0; font-size: 13px; font-weight: 700; letter-spacing: .01em; }
.column-head .n {
    margin-left: auto; font-family: var(--mono); font-size: 11.5px;
    color: var(--ink-3); background: var(--grey-soft);
    padding: 1px 7px; border-radius: 9px;
}
.column-head .dot { width: 8px; height: 8px; border-radius: 50%; flex: 0 0 auto; }
.dot-todo { background: var(--ink-3); }
.dot-doing { background: var(--blue); }
.dot-blocked { background: var(--red); }
.dot-review { background: var(--amber); }
.dot-done { background: var(--green); }

.column-body { padding: 10px; display: flex; flex-direction: column; gap: 9px; min-height: 60px; }

.task-card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    padding: 11px 12px;
    text-decoration: none;
    color: inherit;
    display: block;
    box-shadow: 0 1px 1px rgba(31, 28, 25, .04);
}
.task-card:hover { border-color: var(--ink-3); }
.task-card .t { font-size: 14px; font-weight: 600; line-height: 1.35; margin-bottom: 7px; }
.task-card .r { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; font-size: 12px; color: var(--ink-3); }
.task-card .avatar { width: 22px; height: 22px; font-size: 9.5px; }

.empty-column { color: var(--ink-3); font-size: 12.5px; text-align: center; padding: 14px 6px; }

/* ---------------- pills ---------------- */

.pill {
    display: inline-block;
    font-size: 11.5px; font-weight: 600;
    padding: 2px 8px; border-radius: 10px;
    white-space: nowrap; border: 1px solid transparent;
}
.pill-todo    { background: var(--grey-soft);  color: var(--ink-2); }
.pill-doing   { background: var(--blue-soft);  color: var(--blue); }
.pill-blocked { background: var(--red-soft);   color: var(--red); }
.pill-review  { background: var(--amber-soft); color: var(--amber); }
.pill-done    { background: var(--green-soft); color: var(--green); }
.pill-high    { background: var(--red-soft);   color: var(--red); }
.pill-low     { background: var(--grey-soft);  color: var(--ink-3); }
.pill-overdue { background: var(--red); color: #fff; }
.pill-soon    { background: var(--amber-soft); color: var(--amber); }
.pill-case    { background: var(--blue-soft); color: var(--blue); font-family: var(--mono); font-size: 11px; }

/* ---------------- lists / tables ---------------- */

.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 14px; }
table.data th, table.data td {
    text-align: left; padding: 11px 16px;
    border-bottom: 1px solid var(--line-soft); vertical-align: middle;
}
table.data thead th {
    font-size: 12px; font-weight: 600; letter-spacing: .03em;
    text-transform: uppercase; color: var(--ink-3);
    background: var(--card-2); border-bottom: 1px solid var(--line);
    white-space: nowrap;
}
table.data tbody tr:last-child td { border-bottom: 0; }
table.data tbody tr:hover { background: var(--card-2); }
table.data td.num { font-family: var(--mono); font-variant-numeric: tabular-nums; white-space: nowrap; }

/* ---------------- forms ---------------- */

.field { margin-bottom: 17px; }
.field:last-child { margin-bottom: 0; }

label { display: block; font-size: 14px; font-weight: 600; margin-bottom: 5px; }
label .opt { font-weight: 400; color: var(--ink-3); }

input[type=text], input[type=email], input[type=password], input[type=date],
input[type=number], input[type=color], select, textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: var(--card);
    color: var(--ink);
    font: inherit;
    font-size: 15px;
}
input[type=color] { padding: 4px; height: 42px; }
input[type=file] { font-size: 14px; max-width: 100%; }
textarea { min-height: 96px; resize: vertical; line-height: 1.55; }

input:focus, select:focus, textarea:focus {
    outline: 0;
    border-color: var(--blue);
    box-shadow: 0 0 0 3px var(--blue-soft);
}

.field-error { color: var(--red); font-size: 13px; margin-top: 5px; }
.field-hint { color: var(--ink-3); font-size: 13px; margin-top: 5px; }

.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 17px; }
.input-group { display: flex; gap: 8px; align-items: stretch; }
.input-group input { flex: 1 1 auto; min-width: 0; }
.input-group .btn { flex: 0 0 auto; }

/* ---------------- buttons ---------------- */

.btn {
    display: inline-block;
    font: inherit; font-size: 14.5px; font-weight: 600;
    padding: 9px 17px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--green);
    background: var(--green);
    color: #fff;
    cursor: pointer;
    text-decoration: none;
    white-space: nowrap;
}
.btn:hover { filter: brightness(1.08); text-decoration: none; }

.btn-secondary { background: var(--card); color: var(--ink-2); border-color: var(--line); }
.btn-secondary:hover { background: var(--grey-soft); filter: none; }
.btn-danger { background: var(--card); color: var(--red); border-color: var(--red); }
.btn-danger:hover { background: var(--red-soft); filter: none; }
.btn-small { font-size: 13px; padding: 6px 12px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.actions { display: flex; gap: 9px; align-items: center; flex-wrap: wrap; margin-top: 20px; }

/* ---------------- alerts ---------------- */

.alert {
    padding: 13px 17px;
    border-radius: var(--radius-sm);
    border: 1px solid;
    margin-bottom: 20px;
    font-size: 14.5px;
}
.alert-success { background: var(--green-soft); border-color: var(--green); color: var(--green); }
.alert-error { background: var(--red-soft); border-color: var(--red); color: var(--red); }
.alert-info { background: var(--blue-soft); border-color: var(--blue); color: var(--blue); }
.alert ul { margin: 7px 0 0; padding-left: 19px; }

/* ---------------- comments & activity ---------------- */

.comment { display: flex; gap: 12px; padding: 15px 0; border-bottom: 1px solid var(--line-soft); }
.comment:last-of-type { border-bottom: 0; }
.comment .body { flex: 1 1 auto; min-width: 0; }
.comment .who { font-size: 14px; font-weight: 600; margin-bottom: 2px; }
.comment .when { font-size: 12.5px; color: var(--ink-3); font-weight: 400; margin-left: 6px; }
.comment .text { font-size: 14.5px; white-space: pre-wrap; overflow-wrap: anywhere; }

.activity { list-style: none; margin: 0; padding: 0; }
.activity li {
    display: flex; gap: 11px; align-items: baseline;
    padding: 9px 0; border-bottom: 1px solid var(--line-soft); font-size: 14px;
}
.activity li:last-child { border-bottom: 0; }
.activity .when { margin-left: auto; font-size: 12.5px; color: var(--ink-3); white-space: nowrap; }

.attachment {
    display: flex; align-items: center; gap: 10px;
    padding: 9px 0; border-bottom: 1px solid var(--line-soft); font-size: 14px;
}
.attachment:last-child { border-bottom: 0; }

/* ---------------- stats ---------------- */

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; margin-bottom: 22px; }
.stat {
    background: var(--card); border: 1px solid var(--line);
    border-radius: var(--radius); padding: 15px 17px; box-shadow: var(--shadow);
}
.stat b { display: block; font-size: 1.9rem; font-weight: 700; line-height: 1; margin-bottom: 6px; font-variant-numeric: tabular-nums; }
.stat span { font-size: 13px; color: var(--ink-3); }
.stat.red b { color: var(--red); }
.stat.amber b { color: var(--amber); }
.stat.green b { color: var(--green); }

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

.centred { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 30px 20px; }
.signin { width: 100%; max-width: 400px; }
.signin .card { margin: 0; box-shadow: var(--shadow-lift); }
.signin .card-body { padding: 28px; }

.footer {
    border-top: 1px solid var(--line);
    margin-top: 44px; padding: 18px 22px;
    font-size: 13px; color: var(--ink-3); text-align: center;
}

@media (max-width: 900px) {
    .board { grid-template-columns: repeat(5, minmax(210px, 1fr)); }
}
@media (max-width: 620px) {
    main { padding: 20px 15px 70px; }
    h1 { font-size: 1.45rem; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* ---------------- update composer: drag, drop, paste ---------------- */

.composer {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--card);
    overflow: hidden;
    transition: border-color .12s ease, background .12s ease;
}

.composer.dragging {
    border-color: var(--green);
    background: var(--green-soft);
}

.composer textarea {
    border: 0;
    border-radius: 0;
    background: transparent;
    min-height: 96px;
    padding: 13px 14px;
}
.composer textarea:focus { box-shadow: none; }

.composer-foot {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    padding: 10px 12px;
    border-top: 1px solid var(--line-soft);
    background: var(--card-2);
}

.composer-hint { font-size: 12.5px; color: var(--ink-3); }
.composer-foot .grow { flex: 1 1 auto; }

/* the "or drop files" affordance, only while dragging */
.composer-overlay {
    display: none;
    padding: 10px 14px;
    font-size: 13.5px;
    font-weight: 600;
    color: var(--green);
    border-top: 1px dashed var(--green);
}
.composer.dragging .composer-overlay { display: block; }

/* chosen-but-not-yet-uploaded files */
.previews {
    display: flex;
    flex-wrap: wrap;
    gap: 9px;
    padding: 0 12px 12px;
}
.previews:empty { display: none; }

.preview {
    position: relative;
    display: flex;
    align-items: center;
    gap: 9px;
    background: var(--card-2);
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    padding: 7px 9px 7px 7px;
    max-width: 260px;
}

.preview img {
    width: 40px; height: 40px;
    object-fit: cover;
    border-radius: 4px;
    display: block;
    flex: 0 0 auto;
    background: var(--grey-soft);
}

.preview .doc {
    width: 40px; height: 40px;
    border-radius: 4px;
    background: var(--grey-soft);
    color: var(--ink-3);
    font-size: 10px; font-weight: 700;
    display: flex; align-items: center; justify-content: center;
    flex: 0 0 auto;
    text-transform: uppercase;
    letter-spacing: .02em;
}

.preview .info { min-width: 0; }
.preview .nm {
    font-size: 12.5px; font-weight: 600;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    max-width: 150px;
}
.preview .sz { font-size: 11.5px; color: var(--ink-3); }
.preview.too-big { border-color: var(--red); background: var(--red-soft); }
.preview.too-big .sz { color: var(--red); font-weight: 600; }

.preview .drop-x {
    border: 0; background: none; cursor: pointer;
    color: var(--ink-3); font-size: 16px; line-height: 1;
    padding: 2px 4px; border-radius: 3px; flex: 0 0 auto;
}
.preview .drop-x:hover { background: var(--line); color: var(--ink); }

/* attachments shown inside a posted update */
.comment-files { display: flex; flex-wrap: wrap; gap: 9px; margin-top: 10px; }

.comment-files a.thumb {
    display: block; line-height: 0;
    border: 1px solid var(--line); border-radius: var(--radius-sm);
    overflow: hidden; background: var(--card-2);
}
.comment-files a.thumb img {
    max-width: 220px; max-height: 170px;
    display: block; object-fit: cover;
}
.comment-files a.thumb:hover { border-color: var(--ink-3); }

.file-chip {
    display: inline-flex; align-items: center; gap: 7px;
    background: var(--card-2); border: 1px solid var(--line);
    border-radius: var(--radius-sm); padding: 6px 11px;
    font-size: 13px; text-decoration: none; color: var(--ink);
}
.file-chip:hover { border-color: var(--ink-3); text-decoration: none; }
.file-chip .sz { color: var(--ink-3); font-size: 12px; }

/* ---------------- rich text editor (Trix) ---------------- */

.composer trix-toolbar {
    padding: 8px 10px;
    border-bottom: 1px solid var(--line-soft);
    background: var(--card-2);
}

.composer trix-toolbar .trix-button-group {
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    margin: 0 8px 0 0;
    background: var(--card);
    overflow: hidden;
}
.composer trix-toolbar .trix-button-group:last-child { margin-right: 0; }

.composer trix-toolbar .trix-button {
    border: 0;
    border-right: 1px solid var(--line-soft);
    background: transparent;
    color: var(--ink-2);
    height: 30px;
    padding: 0 11px;
    font-size: 13px;
}
.composer trix-toolbar .trix-button:last-child { border-right: 0; }
.composer trix-toolbar .trix-button:hover { background: var(--grey-soft); color: var(--ink); }
.composer trix-toolbar .trix-button.trix-active { background: var(--green); color: #fff; }
.composer trix-toolbar .trix-button:disabled { opacity: .35; }

/* Trix ships black SVG icons; tint them to the text colour instead. */
.composer trix-toolbar .trix-button::before { opacity: .72; }
.composer trix-toolbar .trix-button.trix-active::before { filter: invert(1) brightness(2); opacity: 1; }

.composer trix-editor {
    border: 0;
    border-radius: 0;
    background: transparent;
    color: var(--ink);
    min-height: 110px;
    padding: 13px 14px;
    font-size: 15px;
    line-height: 1.6;
}
.composer trix-editor:empty::before { color: var(--ink-3); }
.composer trix-editor:focus { outline: none; }

.composer trix-editor h1 { font-size: 1.2rem; margin: 0 0 .4em; }
.composer trix-editor blockquote,
.rich blockquote {
    border-left: 3px solid var(--line);
    margin: 0 0 .8em;
    padding: 2px 0 2px 14px;
    color: var(--ink-2);
}
.composer trix-editor pre,
.rich pre {
    background: var(--grey-soft);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    font-family: var(--mono);
    font-size: 13px;
    overflow-x: auto;
    white-space: pre-wrap;
}

/* the toolbar's link dialog */
.composer .trix-dialog {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-lift);
    padding: 12px;
}
.composer .trix-dialog input[type=url] { font-size: 14px; }
.composer .trix-dialog .trix-button { border: 1px solid var(--line); border-radius: var(--radius-sm); }

/* Trix's own file handling is off; ours lives in the footer */
.composer trix-toolbar .trix-button-group--file-tools { display: none; }

/* ---------------- posted rich text ---------------- */

.rich { font-size: 14.5px; line-height: 1.6; overflow-wrap: anywhere; }
.rich > :first-child { margin-top: 0; }
.rich > :last-child { margin-bottom: 0; }
.rich p { margin: 0 0 .7em; }
.rich h1 { font-size: 1.15rem; margin: .6em 0 .35em; }
.rich h2 { font-size: 1.05rem; margin: .6em 0 .35em; }
.rich ul, .rich ol { margin: 0 0 .7em; padding-left: 22px; }
.rich li { margin-bottom: .25em; }
.rich code { background: var(--grey-soft); padding: .1em .35em; border-radius: 3px; font-family: var(--mono); font-size: .88em; }
.rich a { color: var(--blue); }
.rich del { color: var(--ink-3); }

/* ---------------- invoice statuses ---------------- */

.pill-inv-submitted { background: var(--amber-soft); color: var(--amber); }
.pill-inv-approved  { background: var(--blue-soft);  color: var(--blue); }
.pill-inv-partpaid  { background: var(--blue-soft);  color: var(--blue); }
.pill-inv-paid      { background: var(--green-soft); color: var(--green); }
.pill-inv-rejected  { background: var(--red-soft);   color: var(--red); }
