/* Task Manager - application styles */

:root {
    --bg: #f4f6f8;
    --surface: #ffffff;
    --border: #d9dee4;
    --text: #1f2933;
    --muted: #616e7c;
    --primary: #2563a8;
    --primary-dark: #1d4f85;
    --danger: #b3261e;
    --success: #1e7e34;
    --warning: #b26a00;
    --radius: 8px;
    --shadow: 0 1px 3px rgba(16, 24, 40, 0.08);
    /* Chevron-down icon used by the custom multi-select dropdowns. */
    --chevron-down: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23616e7c' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
}

* {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
}

body {
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 15px;
    line-height: 1.5;
    color: var(--text);
    background: var(--bg);
}

a {
    color: var(--primary);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

h1 {
    font-size: 1.5rem;
    margin: 0 0 0.75rem;
}

h2 {
    font-size: 1.15rem;
    margin: 0 0 0.5rem;
}

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

/* ---------- Top bar ---------- */

.topbar {
    display: flex;
    align-items: center;
    gap: 1.25rem;
    padding: 0.6rem 1.25rem;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
}

.topbar-brand {
    font-weight: 700;
    font-size: 1.05rem;
}

.topbar-nav {
    display: flex;
    gap: 1rem;
}

.topbar-user {
    margin-left: auto;
    color: var(--muted);
}

.topbar-trash {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.35rem;
    border: 1px solid transparent;
    border-radius: var(--radius);
    color: var(--muted);
}

.topbar-trash img {
    width: 1.05rem;
    height: 1.05rem;
}

.topbar-trash:hover {
    background: #eef2f6;
    color: var(--danger);
}

.company-switcher-wrap {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.company-switcher {
    padding: 0.25rem 1.75rem 0.25rem 0.4rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background-color: var(--surface);
    /* The compact top-bar control uses a slightly smaller chevron. */
    background-position: right 0.5rem center;
    background-size: 0.85rem 0.85rem;
    font-size: 0.9rem;
}

.main {
    flex: 1;
    width: 100%;
    max-width: 1100px;
    margin: 0 auto;
    padding: 1.5rem 1.25rem 3rem;
}

/* ---------- Cards & layout ---------- */

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1rem 1.25rem;
    margin-bottom: 1rem;
}

.auth-card {
    max-width: 420px;
    margin: 4rem auto 0;
}

.view-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1rem;
}

/* The MCP-accounts section sits below the human users table on the Users
   page; a clear gap keeps the two tables from running together. */
.mcp-section {
    margin-top: 2rem;
}

.view-header h1 {
    margin: 0;
}

.btn-row {
    display: flex;
    gap: 0.5rem;
}

.detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 1rem 2rem;
}

/* Wide screens: give the tags column half the width instead of a fourth
   (20% status, 20% assignee, 10% priority, 50% tags). The threshold is the
   width at which the base rule already fits four 220px columns (4*220px +
   3*32px gap + 80px of padding = 1056px), so this only changes the column
   ratio, never the column count. Below it, narrow screens keep the current
   wrap-to-next-line behavior. */
@media (min-width: 1056px) {
    .detail-grid {
        grid-template-columns: minmax(0, 2fr) minmax(0, 2fr) minmax(0, 1fr) minmax(0, 5fr);
    }
}

.detail-grid #detail-status,
.detail-grid #detail-assignee,
.detail-grid #detail-priority {
    width: auto;
    max-width: 100%;
}

/* Plain centered "Label: value" line below the quick-edit card. */
.detail-meta {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: baseline;
    gap: 0.35rem 1.75rem;
    font-size: 0.9em;
    margin-bottom: 1rem;
}

/* Chips in the detail grid match the <select> height exactly: select's
   line box (1.2em) + its vertical padding (2 * 0.45rem) + border (2px). */
.detail-grid .tags-cell {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.25rem;
}

.detail-grid .tags-cell .chip {
    display: inline-flex;
    align-items: center;
    height: calc(1.2em + 0.9rem + 2px);
    margin: 0;
    padding: 0 0.5rem;
    font-size: inherit;
}

.row {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.row.spread {
    justify-content: space-between;
}

.back-link {
    margin-bottom: 0.5rem;
}

.empty {
    color: var(--muted);
    padding: 1.5rem 0;
    text-align: center;
}

.loading {
    color: var(--muted);
}

.muted {
    color: var(--muted);
}

.small-text {
    font-size: 0.85rem;
}

/* ---------- Forms ---------- */

.stack {
    display: flex;
    flex-direction: column;
    gap: 0.9rem;
}

.field {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

/* Only the label (first span) is emphasized; value spans stay plain. */
.field > span:first-child {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--muted);
}

fieldset.field {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.6rem 0.9rem;
}

fieldset.field legend {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--muted);
    padding: 0 0.3rem;
}

.check {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.15rem 0;
    font-weight: 400;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="search"],
input[type="date"],
select {
    padding: 0.45rem 0.6rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font: inherit;
    background: var(--surface);
    color: var(--text);
    width: 100%;
}

/* Native dropdowns: drop the platform arrow and draw the same chevron as
   the custom multi-select dropdowns, so every dropdown in the app looks
   alike. The chevron sits 0.75rem from the right edge (Bootstrap style);
   the extra right padding keeps long values clear of it. */
select {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    padding-right: 2.25rem;
    background-image: var(--chevron-down);
    background-position: right 0.75rem center;
    background-size: 1rem 1rem;
    background-repeat: no-repeat;
}

/* Hide arrow icon in input fields with a datalist */
input[list]::-webkit-calendar-picker-indicator {
    display: none !important;
}

/* Read-only code blocks (e.g. the MCP client config shown with a token):
   a compact monospace block that keeps the exact whitespace for copying. */
.code-snippet {
    margin: 0;
    padding: 0.5rem 0.6rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg);
    color: var(--text);
    font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas,
        "Liberation Mono", monospace;
    font-size: 0.8rem;
    line-height: 1.4;
    white-space: pre;
    overflow-x: auto;
}

input:focus,
select:focus,
.rich-text:focus {
    outline: 2px solid var(--primary);
    outline-offset: 1px;
    border-color: var(--primary);
}

/* ---------- Buttons ---------- */

.btn {
    display: inline-block;
    padding: 0.45rem 0.9rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text);
    font: inherit;
    font-weight: 600;
    cursor: pointer;
}

.btn:hover {
    background: #eef2f6;
    text-decoration: none;
}

.btn:disabled {
    opacity: 0.6;
    cursor: default;
}

.btn.primary {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}

.btn.primary:hover {
    background: var(--primary-dark);
}

.btn.danger {
    color: var(--danger);
    border-color: #e5b8b5;
}

.btn.danger:hover {
    background: #fbeeed;
}

.btn.small {
    padding: 0.25rem 0.6rem;
    font-size: 0.85rem;
}

/* Icon-only button: the SVG has no intrinsic size, so it must be given one
   or it renders as an empty, oversized box. */
.btn.icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.25rem 0.4rem;
}

.btn.icon-btn img {
    width: 15px;
    height: 15px;
}

.danger-link {
    color: var(--danger);
}

/* ---------- Tables ---------- */

.table {
    width: 100%;
    border-collapse: collapse;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
}

.table th,
.table td {
    text-align: left;
    padding: 0.6rem 0.8rem;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

.table thead th {
    background: #d8d8d8;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--muted);
}

.table thead th.sortable {
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
}

.table thead th.sortable:hover {
    color: var(--text);
}

.table thead th.sortable .sort-arrow {
    display: inline-block;
    width: 1em;
    margin-left: 0.35em;
}

.table thead th.sortable.active {
    color: var(--text);
}

.table tbody tr:hover {
    background: #f7fafc;
}

.load-more {
    display: flex;
    justify-content: center;
    padding: 0.75rem 0;
}

.task-title {
    font-weight: 600;
}

.actions {
    white-space: nowrap;
}

.actions .btn {
    margin-right: 0.3rem;
}

/* ---------- Badges & chips ---------- */

.badge {
    display: inline-block;
    padding: 0.1rem 0.55rem;
    border-radius: 999px;
    font-size: 0.8rem;
    font-weight: 600;
    white-space: nowrap;
}

.badge-new {
    background: #e7f0fb;
    color: var(--primary-dark);
}

.badge-approved {
    background: #ece7fb;
    color: #6b46c1;
}

.badge-in_progress {
    background: #fff4e0;
    color: var(--warning);
}

.badge-completed {
    background: #e6f4ea;
    color: var(--success);
}

.badge-canceled {
    background: #ffe5e5;
    color: indianred;
}

.badge-archived {
    background: #ececec;
    color: #555;
    margin-left: 0.5rem;
    vertical-align: middle;
    text-transform: uppercase;
}

.chip {
    display: inline-block;
    padding: 0.05rem 0.5rem;
    margin: 0.1rem 0.25rem 0.1rem 0;
    border-radius: 999px;
    background: #eef2f6;
    border: 1px solid var(--border);
    font-size: 0.8rem;
}

.tags-cell {
    min-height: 1.4rem;
}

/* ---------- Filter bar ---------- */

.filter-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem 1rem;
    align-items: flex-end;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.75rem 1rem;
    margin-bottom: 1rem;
    box-shadow: var(--shadow);
}

.filter-label {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    min-width: 130px;
}

.filter-label > span {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--muted);
}

.filter-title {
    min-width: 180px;
}

/* Chromium sizes <select> shorter than <input>/<button> for the same
   padding/font; pin all five controls to one height. */
.filter-bar input,
.filter-bar select,
.filter-bar .btn {
    height: 2.4rem;
}

/* The print button sits on the right side of the filter box. */
.filter-bar .print-btn {
    margin-left: auto;
}

/* ---------- Multi-select dropdown ---------- */

.multi-select {
    position: relative;
    width: 100%;
}

.multi-select-btn {
    width: 100%;
    padding: 0.45rem 0.6rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text);
    font: inherit;
    text-align: left;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.5rem;
}

.multi-select-btn:hover {
    background: #eef2f6;
}

/* Chevron-down indicator, roughly double the old "▾" glyph's visual size. */
.multi-select-btn::after {
    content: "";
    flex: none;
    width: 1rem;
    height: 1rem;
    background: var(--chevron-down) center / 1rem 1rem no-repeat;
}

/* Same fixed height as the other filter controls. */
.filter-bar .multi-select-btn {
    height: 2.4rem;
}

.multi-select-panel {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    min-width: 100%;
    max-height: 16rem;
    overflow-y: auto;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 4px 16px rgba(16, 24, 40, 0.12);
    padding: 0.35rem;
    z-index: 40;
}

.multi-select-option {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.3rem 0.45rem;
    border-radius: 6px;
    cursor: pointer;
    white-space: nowrap;
}

.multi-select-option:hover {
    background: #eef2f6;
}

/* Native checkboxes ignore border styles (only outline works, and the
   default ring wraps the tall hit area). Render the box ourselves so focus
   can be shown as a colored border without an outline. */
.multi-select-option input[type="checkbox"] {
    -webkit-appearance: none;
    appearance: none;
    width: 1rem;
    height: 1rem;
    flex: none;
    margin: 0;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--surface);
    cursor: pointer;
}

.multi-select-option input[type="checkbox"]:checked {
    background: var(--primary) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M3 8.5l3.5 3.5L13 5' fill='none' stroke='white' stroke-width='2'/%3E%3C/svg%3E") center / 0.85rem no-repeat;
}

.multi-select-option input[type="checkbox"]:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: inset 0 0 0 1px var(--primary);
}

/* ---------- Messages ---------- */

.error {
    color: var(--danger);
    margin: 0;
}

.notice {
    background: #e7f0fb;
    border: 1px solid #bcd4ef;
    color: var(--primary-dark);
    border-radius: var(--radius);
    padding: 0.6rem 0.8rem;
    margin: 0 0 0.75rem;
}

/* Empty message boxes take no space at all. Dynamically created boxes
   (el() + textContent) are truly empty when cleared, so :empty is
   reliable; statically created ones always contain text. */
.error:empty,
.notice:empty {
    display: none;
}

/* ---------- Company selection ---------- */

.company-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 1rem;
    margin-top: 1rem;
}

.company-card {
    text-align: left;
    padding: 1rem 1.2rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    cursor: pointer;
    font: inherit;
}

.company-card:hover {
    border-color: var(--primary);
    box-shadow: 0 2px 8px rgba(37, 99, 168, 0.2);
}

.company-name {
    font-weight: 700;
    font-size: 1.05rem;
}

.company-contact {
    color: var(--muted);
    font-size: 0.9rem;
}

/* ---------- Rich text ---------- */

.rich-text {
    min-height: 12rem;
    max-height: 18rem;
    overflow-y: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.5rem 0.6rem;
    background: var(--surface);
}

.rich-text:empty::before {
    content: attr(data-placeholder);
    color: var(--muted);
    pointer-events: none;
    white-space: pre-line;
}

.rich-text-img {
    max-width: 260px;
    max-height: 180px;
    border-radius: 4px;
    margin: 0.25rem 0.25rem 0.25rem 0;
    vertical-align: middle;
    cursor: pointer;
}

.rich-text-img-selected {
    outline: 2px solid var(--primary);
    outline-offset: 1px;
    opacity: 0.85;
}

.rich-content {
    line-height: 1.55;
    overflow-wrap: anywhere;
}

.rich-content .mention {
    color: #0b5fff;
    background: rgba(11, 95, 255, 0.08);
    font-weight: 600;
    border-radius: 4px;
    padding: 0 0.15em;
}

.rich-content .task-mention {
    font-weight: 600;
}

.mention-menu {
    position: fixed;
    z-index: 100;
    max-height: 240px;
    overflow-y: auto;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 6px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
    min-width: 160px;
}

.mention-menu-item {
    padding: 0.35rem 0.6rem;
    cursor: pointer;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.mention-menu-item:hover {
    background: #f0f5fc;
}

.mention-menu-item.selected {
    background: #e2edfb;
}

.mention-menu-item.no-results {
    color: #888;
    cursor: default;
}

.rich-content img {
    max-width: 100%;
    max-height: 320px;
    border-radius: 4px;
    margin: 0.3rem 0;
    cursor: zoom-in;
}

/* Markdown blocks (see markdown.js). */
.rich-content h1,
.rich-content h2,
.rich-content h3 {
    margin: 0.7em 0 0.3em;
    line-height: 1.3;
}

.rich-content h1 { font-size: 1.35rem; }
.rich-content h2 { font-size: 1.2rem; }
.rich-content h3 { font-size: 1.08rem; }

.rich-content > h1:first-child,
.rich-content > h2:first-child,
.rich-content > h3:first-child {
    margin-top: 0;
}

.rich-content blockquote {
    margin: 0.4em 0;
    padding: 0.1em 0 0.1em 0.8em;
    border-left: 3px solid var(--border);
    color: var(--muted);
}

.rich-content ul,
.rich-content ol {
    margin: 0;
    padding-left: 1.5em;
}

.rich-content li {
    margin: 0.15em 0;
}

.rich-content .task-list {
    list-style: none;
    padding-left: 0.1em;
}

.rich-content .task-list-checkbox {
    margin: 0 0.4em 0 0;
    vertical-align: middle;
}

.rich-content .task-list-checkbox:not(:disabled) {
    cursor: pointer;
}

.rich-content .table-scroll {
    margin: 0.4em 0;
    overflow-x: auto;
}

.rich-content table {
    border-collapse: collapse;
}

.rich-content th,
.rich-content td {
    border: 1px solid var(--border);
    padding: 0.25em 0.55em;
}

.rich-content thead th {
    background: #f0f5fc;
    font-weight: 600;
}

/* <th> is centered by the browser default; the default column
   alignment is left (explicit GFM alignment wins — see below). */
.rich-content th {
    text-align: left;
}

/* Column alignment (GFM ":---:" / "---:" separator cells). Classes
   instead of inline styles: the CSP blocks style attributes. */
.rich-content th.ta-center,
.rich-content td.ta-center {
    text-align: center;
}

.rich-content th.ta-right,
.rich-content td.ta-right {
    text-align: right;
}

/* ---------- Mentions (@-user and #-task tokens) ---------- */

.mention {
    color: #0b5fff;
    background: rgba(11, 95, 255, 0.08);
    font-weight: 600;
    border-radius: 4px;
    padding: 0 0.15em;
}

.task-mention {
    font-weight: 600;
}

.mention-menu {
    position: fixed;
    max-width: 22rem;
    max-height: 14rem;
    overflow-y: auto;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 4px 16px rgba(16, 24, 40, 0.16);
    padding: 0.25rem;
    z-index: 60;
    font-size: 0.9rem;
}

.mention-menu-item {
    padding: 0.3rem 0.5rem;
    border-radius: 6px;
    cursor: pointer;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.mention-menu-item:hover {
    background: #eef2f6;
}

.mention-menu-item.selected {
    background: #e7f0fb;
    color: var(--primary-dark);
}

.mention-menu-item.no-results {
    color: var(--muted);
    cursor: default;
}

/* ---------- Attachments (task detail) ---------- */

/* One card, two sections: the description takes the remaining width, the
   attachments section a fixed 25% beside it, separated by a subtle border. */
.description-card {
    display: flex;
    gap: 1.25rem;
}

.description-column {
    flex: 1;
    min-width: 0;
}

.attachments-box {
    flex: 0 0 25%;
    min-width: 0;
    border-left: 1px solid var(--border);
    padding-left: 1.25rem;
}

.attachment-empty {
    margin: 0;
}

.attachment-list {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.attachment-row {
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
}

.attachment-name-row {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    min-width: 0;
}

.attachment-name {
    display: block;
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-weight: 600;
}

.attachment-meta {
    display: block;
}

.attachment-delete {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.2rem;
    border: 1px solid #e5b8b5;
    border-radius: var(--radius);
    background: var(--surface);
    cursor: pointer;
}

.attachment-delete:hover {
    background: #fbeeed;
}

.attachment-delete img {
    width: 14px;
    height: 14px;
}

/* While a file is dragged over the page: highlight the attachments box
   and show the drop hint inside it. */
.attachments-box.drag-over {
    outline: 2px dashed var(--primary);
    outline-offset: 2px;
}

.attachment-drop-hint {
    display: none;
    margin: 0.5rem 0 0;
    color: var(--primary-dark);
    font-weight: 600;
}

.attachments-box.drag-over .attachment-drop-hint {
    display: block;
}

@media (max-width: 700px) {
    .description-card {
        flex-direction: column;
        gap: 0;
    }

    .attachments-box {
        flex: none;
        border-left: none;
        padding-left: 0;
        border-top: 1px solid var(--border);
        margin-top: 1rem;
        padding-top: 1rem;
    }
}

/* ---------- Change history ---------- */

/* table-layout: fixed + one row per field keeps the columns aligned even
   when a value (e.g. a long description) spans many lines. */
.change-history {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
}

.change-history th,
.change-history td {
    border: 1px solid var(--border);
    padding: 0.5rem 0.75rem;
    vertical-align: top;
    text-align: left;
    overflow-wrap: anywhere;
}

.change-history th {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--muted);
}

.change-history th:first-child {
    width: 140px;
}

.change-history .ch-field {
    font-weight: 600;
}

.change-history .ch-group td {
    background: #f5f7fa;
    border-bottom: none;
}

.change-history .ch-group .ch-who {
    font-weight: 600;
    margin-right: 0.75rem;
}

.change-history .ch-group .muted {
    font-weight: 400;
}

/* ---------- Comments ---------- */

.comment-list {
    display: flex;
    flex-direction: column;
    gap: 0.9rem;
    margin-top: 1rem;
}

.comment {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.6rem 0.9rem;
    background: #fafbfc;
}

/* Same 0.5rem gap above the Edit/Delete row as the comment-form
   gap above the Save/Cancel row in edit mode. */
.comment > .row {
    margin-top: 0.5rem;
}

.comment-header {
    display: flex;
    gap: 0.75rem;
    align-items: baseline;
    margin-bottom: 0.3rem;
}

.comment-author {
    font-weight: 700;
}

.comment-form {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

/* ---------- Time entries ---------- */

.time-entry-list {
    display: flex;
    flex-direction: column;
    gap: 0.9rem;
}

.time-entry {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.6rem 0.9rem;
    background: #fafbfc;
}

.time-entry-header {
    display: flex;
    gap: 1rem;
    align-items: baseline;
    flex-wrap: wrap;
    margin-bottom: 0.3rem;
}

.time-entry-author {
    font-weight: 700;
}

/* "My time": the first cell is a link to the task the entry belongs to
   (kept bold like the author name). Task titles may run up to 250 chars;
   the link is ellipsized responsively and the full title lives in the
   tooltip. */
.time-entry-task {
    font-weight: 700;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* One "YYYY-MM-DD hh:mm" string, pushed to the right side of the header
   line so the name/task link stays on the left. */
.time-entry-date {
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    margin-left: auto;
}

.time-entry-actions {
    display: inline-flex;
    gap: 0.4rem;
    align-items: center;
}

.time-entry-view .time-entry-list {
    margin-bottom: 1rem;
}

.time-entry-top-row {
    flex-wrap: wrap;
    align-items: flex-end;
}

.time-entry-field {
    width: 160px;
    flex-shrink: 0;
}

.time-entry-save-slot {
    margin-left: auto;
}

.time-entries-title {
    margin-top: 0.5rem;
}

.time-total {
    font-size: 1.05rem;
    font-weight: 700;
    margin: 1.25rem 0 0;
    text-align: right;
}

/* ---------- Print ("My time") ---------- */

/* The period heading is invisible on screen; the print layout shows it
   where the filter box was. */
.period-heading {
    display: none;
    margin: 0 0 1rem;
}

/* Applied to <body> by the print button around window.print(): a white
   page, no toolbar, no filter box, no per-entry Edit/Delete buttons. */
body.print-my-time {
    background: #fff;
}

body.print-my-time .topbar,
body.print-my-time .filter-bar,
body.print-my-time .time-entry-actions,
body.print-my-time .view-header {
    display: none;
}

/* The period heading takes the top of the page; no leftover space. */
body.print-my-time .main {
    padding-top: 0;
}

body.print-my-time .period-heading {
    display: block;
}

/* ---------- Modal ---------- */

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.45);
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 4rem 1rem 1rem;
    overflow-y: auto;
    z-index: 50;
}

/* Image preview: vertically centered and never scrollable. The dialog
   (header + image) is sized to fit within 90vh by .image-modal-img. */
.modal-overlay-image {
    align-items: center;
    padding: 1rem;
    overflow: hidden;
}

.modal-dialog {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: 0 10px 30px rgba(16, 24, 40, 0.25);
    width: 100%;
    max-width: 460px;
}

.modal-wide {
    max-width: 900px;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.8rem 1.25rem;
    border-bottom: 1px solid var(--border);
}

.modal-header h2 {
    margin: 0;
}

.modal-close {
    border: none;
    background: none;
    font-size: 1.4rem;
    line-height: 1;
    cursor: pointer;
    color: var(--muted);
    padding: 0 0.3rem;
}

.modal-body {
    padding: 1rem 1.25rem 1.25rem;
}

.modal-image {
    width: auto;
    max-width: 90vw;
}

.modal-image .modal-body {
    padding: 0;
}

.image-modal-img {
    display: block;
    width: auto;
    height: auto;
    max-width: 90vw;
    /* 3.5rem = modal header (0.8rem*2 padding + h2 line + 1px border),
       so header + image stay within 90vh. */
    max-height: calc(90vh - 3.5rem);
}

/* ---------- Responsive ---------- */

@media (max-width: 700px) {
    .topbar {
        gap: 0.6rem;
    }

    .topbar-user {
        display: none;
    }

    .table {
        display: block;
        overflow-x: auto;
    }
}
