:root {
    --bg: #f4f5f7;
    --panel: #ffffff;
    --border: #dfe1e6;
    --text: #172b4d;
    --muted: #6b778c;
    --primary: #0052cc;
    --primary-dark: #0747a6;
    --today: #e6fcff;
    --today-border: #00b8d9;
    --danger: #de350b;
    --radius: 6px;
    --status-new: #c62828;
    --status-open: #d9822b;
    --status-closed: #2e7d32;
    --status-moved: #5e6c84;
    --overdue-accent: #de350b;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
}

a { color: var(--primary); }

/* Auth pages */
.auth-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.auth-card {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 2rem;
    width: 360px;
    box-shadow: 0 1px 3px rgba(9, 30, 66, 0.1);
}

.auth-card-wide { width: 560px; }

.auth-card h1 { margin-top: 0; }

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

.alert { padding: 0.6rem 0.8rem; border-radius: var(--radius); margin-bottom: 1rem; font-size: 0.9rem; }
.alert-error { background: #ffebe6; color: var(--danger); border: 1px solid #ffbdad; }
.alert-ok { background: #e3fcef; color: #006644; border: 1px solid #abf5d1; }

form label { display: block; font-size: 0.85rem; margin-bottom: 0.3rem; color: var(--muted); }

input[type="email"], input[type="text"], textarea, select {
    width: 100%;
    padding: 0.55rem 0.65rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.95rem;
    margin-bottom: 1rem;
    font-family: inherit;
}

button {
    cursor: pointer;
    border: none;
    border-radius: var(--radius);
    padding: 0.6rem 1rem;
    font-size: 0.95rem;
    background: var(--primary);
    color: #fff;
}

button:hover { background: var(--primary-dark); }
button.secondary { background: #42526e; }
button.link-button { background: none; color: var(--muted); padding: 0; text-decoration: underline; }

.setup-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; }
.setup-panel h2 { font-size: 1rem; margin-top: 0; }

/* Board page */
.board-page { min-height: 100vh; display: flex; flex-direction: column; }

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

.board-header h1 { font-size: 1.15rem; margin: 0; display: inline-block; }
.board-header-left { display: flex; align-items: baseline; gap: 0.9rem; }
.join-code { font-size: 0.8rem; color: var(--muted); }
.board-header-right { display: flex; align-items: center; gap: 1rem; }
.filter-label { font-size: 0.8rem; color: var(--muted); display: flex; align-items: center; gap: 0.4rem; }
.filter-label select { margin-bottom: 0; width: auto; }
.me { font-size: 0.85rem; color: var(--muted); }
.add-task-button { font-weight: 600; white-space: nowrap; }

.filter-bar {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.6rem 1.25rem;
    background: var(--panel);
    border-bottom: 1px solid var(--border);
}

.filter-bar-label { font-size: 0.85rem; color: var(--muted); }

.day-filters { display: flex; gap: 0.4rem; }
.day-filters button {
    background: var(--bg);
    color: var(--text);
    border: 1px solid var(--border);
    padding: 0.35rem 0.75rem;
    font-size: 0.85rem;
}
.day-filters button.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.day-filters button:hover { background: #dfe1e6; }
.day-filters button.active:hover { background: var(--primary-dark); }

.status-filters { display: flex; gap: 0.4rem; }
.status-filters button {
    background: var(--bg);
    color: var(--text);
    border: 1px solid var(--border);
    padding: 0.35rem 0.75rem;
    font-size: 0.85rem;
}
.status-filters button:hover { background: #dfe1e6; }
.status-filters button.active { color: #fff; border-color: transparent; }
.status-filters button[data-status=""].active { background: var(--primary); }
.status-filters button[data-status="new"].active { background: var(--status-new); }
.status-filters button[data-status="open"].active { background: var(--status-open); }
.status-filters button[data-status="new,open"].active { background: linear-gradient(90deg, var(--status-new), var(--status-open)); }
.status-filters button[data-status="closed"].active { background: var(--status-closed); }

.filter-select {
    width: 150px;
    margin-bottom: 0;
    padding: 0.35rem 0.5rem;
    font-size: 0.85rem;
}
.filter-select:first-of-type { margin-left: auto; }

.search-filter {
    width: 220px;
    margin-bottom: 0;
    padding: 0.35rem 0.65rem;
    font-size: 0.85rem;
}

.board {
    flex: 1;
    display: flex;
    gap: 0.75rem;
    padding: 1rem 1.25rem;
    overflow-x: auto;
    align-items: flex-start;
}

.board-loading { color: var(--muted); padding: 2rem; }

.board-column {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    flex: 0 0 220px;
    display: flex;
    flex-direction: column;
    max-height: calc(100vh - 160px);
}

.undated-column { border-color: #998dd9; background: #f3f0fc; }
.board-column.is-today { border-color: var(--today-border); background: var(--today); }

/* Overdue is a fixed-size summary column, exempt from the day-filter size tiers */
.overdue-column { border-color: var(--overdue-accent); background: #fff5f3; flex-basis: 260px !important; }
.overdue-column .column-header { color: var(--overdue-accent); }

.column-header {
    display: flex;
    flex-direction: column;
    justify-content: center;
    height: 3.1rem;
    padding: 0 0.6rem;
    font-size: 0.85rem;
    font-weight: 600;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    background: inherit;
    border-top-left-radius: var(--radius);
    border-top-right-radius: var(--radius);
}
.column-header-top,
.column-header-bottom {
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.25;
}
.column-header-bottom { font-weight: 400; font-size: 0.78rem; color: var(--muted); }
.overdue-column .column-header-bottom { color: var(--overdue-accent); }

.column-list {
    padding: 0;
    overflow-y: auto;
    flex: 1;
    min-height: 60px;
}

/* Squares are literal square blocks (1:1 aspect ratio) stacked flush, like building blocks */
.square-card {
    position: relative;
    background: var(--status-new);
    color: #fff;
    border: none;
    border-bottom: 2px solid rgba(0, 0, 0, 0.2);
    border-radius: 0;
    padding: 0.5rem 0.65rem;
    margin: 0;
    cursor: grab;
    width: 100%;
    aspect-ratio: 1 / 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.square-notes-count {
    position: absolute;
    bottom: 4px;
    right: 6px;
    font-size: 0.65rem;
    font-weight: 700;
    color: #fff;
    background: rgba(0, 0, 0, 0.35);
    padding: 1px 5px;
    border-radius: 8px;
    line-height: 1.3;
}
.square-notes-count:empty { display: none; }

.square-move-button {
    display: none;
    position: absolute;
    bottom: 4px;
    left: 6px;
    font-size: 0.65rem;
    font-weight: 700;
    color: #fff;
    background: rgba(0, 0, 0, 0.35);
    border: none;
    padding: 2px 7px;
    border-radius: 8px;
    line-height: 1.4;
    cursor: pointer;
}
.square-move-button:hover { background: rgba(0, 0, 0, 0.55); }
.square-card.is-overdue .square-move-button { display: inline-block; }

.column-list .square-card:first-child { border-top-left-radius: var(--radius); border-top-right-radius: var(--radius); }
.column-list .square-card:last-child { border-bottom: none; border-bottom-left-radius: var(--radius); border-bottom-right-radius: var(--radius); }

.square-card:active { cursor: grabbing; }
.square-ghost { opacity: 0.4; }
.square-fallback { opacity: 0.9; box-shadow: 0 4px 10px rgba(9, 30, 66, 0.35); }

.square-card.status-new { background: var(--status-new); }
.square-card.status-open { background: var(--status-open); }
.square-card.status-closed { background: var(--status-closed); }
.square-card.status-moved { background: var(--status-moved); }

.square-card.filtered-out { display: none; }

.square-number { font-size: 0.7rem; font-weight: 700; color: rgba(255, 255, 255, 0.85); flex-shrink: 0; }
.square-title {
    font-size: 0.85rem;
    margin-top: 0.15rem;
    font-weight: 600;
    color: #fff;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.square-assignee { font-size: 0.72rem; color: rgba(255, 255, 255, 0.85); margin-top: 0.2rem; flex-shrink: 0; }
.square-description {
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.85);
    margin-top: 0.3rem;
    white-space: pre-wrap;
    overflow: hidden;
    flex: 1;
}

/* Size variants: every square is a true square (1:1) — fewer days shown = bigger blocks = more info fits */
.board.size-tiny .board-column { flex-basis: 76px; }
.board.size-tiny .square-card { padding: 0.3rem; align-items: center; justify-content: center; }
.board.size-tiny .square-number { font-size: 0.9rem; }
.board.size-tiny .square-title,
.board.size-tiny .square-assignee,
.board.size-tiny .square-description { display: none; }

.board.size-small .board-column { flex-basis: 140px; }
.board.size-small .square-assignee,
.board.size-small .square-description { display: none; }
.board.size-small .square-title { -webkit-line-clamp: 4; }

.board.size-medium .board-column { flex-basis: 210px; }
.board.size-medium .square-description { display: none; }

.board.size-large .board-column { flex-basis: 270px; }

.board.size-xlarge .board-column { flex-basis: 330px; }
.board.size-xlarge .square-card { padding: 0.75rem; }

/* Modal */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(9, 30, 66, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}
.modal-overlay[hidden] { display: none; }

.modal {
    background: var(--panel);
    border-radius: var(--radius);
    width: 860px;
    max-width: 94vw;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: 0 10px 30px rgba(9, 30, 66, 0.3);
}

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

.modal-close {
    background: none;
    color: var(--muted);
    font-size: 1.5rem;
    line-height: 1;
    padding: 0;
}
.modal-close:hover { background: none; color: var(--text); }

.modal-tabs {
    display: flex;
    gap: 0.25rem;
    padding: 0 1.25rem;
    border-bottom: 1px solid var(--border);
}
.modal-tab {
    background: none;
    color: var(--muted);
    border-radius: 0;
    padding: 0.6rem 0.75rem;
    border-bottom: 2px solid transparent;
    font-size: 0.9rem;
}
.modal-tab:hover { background: none; color: var(--text); }
.modal-tab.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }
.modal-tab[hidden] { display: none; }

.modal-pane { padding: 1.1rem 1.25rem 1.25rem; }
.modal-pane[hidden] { display: none; }

.modal-field-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 0 1rem; }

.modal-actions { display: flex; justify-content: flex-end; gap: 0.6rem; margin-top: 0.4rem; }

.log-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.75rem; }
.log-list li { border-bottom: 1px solid var(--border); padding-bottom: 0.6rem; }
.log-details { display: block; font-size: 0.9rem; white-space: pre-wrap; }
.log-meta { display: block; font-size: 0.75rem; color: var(--muted); margin-top: 0.2rem; }

.note-form { display: flex; flex-direction: column; gap: 0.5rem; margin-bottom: 1rem; }
.note-form textarea { margin-bottom: 0; }
.note-form button { align-self: flex-end; }

/* Admin */
.admin-main { max-width: 900px; margin: 0 auto; padding: 1.5rem 1.25rem 4rem; }

.admin-section {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem 1.5rem;
    margin-bottom: 1.5rem;
}
.admin-section h2 { margin-top: 0; margin-bottom: 0.3rem; font-size: 1.1rem; }

.admin-table { width: 100%; border-collapse: collapse; margin-top: 0.75rem; }
.admin-table th {
    text-align: left;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--muted);
    padding: 0.4rem 0.5rem;
    border-bottom: 1px solid var(--border);
}
.admin-table td { padding: 0.5rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
.admin-table tr:last-child td { border-bottom: none; }

.admin-badge {
    display: inline-block;
    background: var(--primary);
    color: #fff;
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    padding: 0.1rem 0.4rem;
    border-radius: 3px;
    margin-left: 0.4rem;
}

.admin-inline-form, .admin-add-form {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}
.admin-inline-form input, .admin-add-form input {
    margin-bottom: 0;
    flex: 1;
}
.admin-inline-form button, .admin-add-form button {
    padding: 0.4rem 0.9rem;
    font-size: 0.85rem;
    white-space: nowrap;
}
.admin-add-form { margin-top: 1rem; }

/* Customer onboarding */
.ob-main { max-width: 1100px; margin: 0 auto; padding: 1.5rem 1.25rem 4rem; }

.ob-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    max-width: 1100px;
    margin: 1rem auto 0;
    padding: 0 1.25rem;
}
.ob-nav a {
    font-size: 0.8rem;
    text-decoration: none;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 0.25rem 0.7rem;
}
.ob-nav a:hover { border-color: var(--primary); }

.ob-main .admin-section { scroll-margin-top: 1rem; }
.ob-main .admin-section h2 { margin-bottom: 0.2rem; }

.ob-empty { color: var(--muted); font-size: 0.9rem; font-style: italic; margin: 0.75rem 0 0; }

.ob-row {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    padding: 0.7rem 0;
    border-bottom: 1px solid var(--border);
}
.ob-row:last-of-type { border-bottom: none; }
.ob-row--add {
    border-bottom: none;
    border-top: 1px solid var(--border);
    margin-top: 0.25rem;
    padding-top: 0.9rem;
}

/* Fields flow along one line and wrap; notes and addresses claim a line of their own. */
.ob-fields {
    flex: 1;
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 0.5rem 0.7rem;
    min-width: 0;
}

.ob-field { display: flex; flex-direction: column; margin-bottom: 0; flex: 1 1 120px; min-width: 0; }
.ob-field > span {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--muted);
    margin-bottom: 0.2rem;
    white-space: nowrap;
}
.ob-field input, .ob-field select, .ob-field textarea {
    margin-bottom: 0;
    padding: 0.35rem 0.5rem;
    font-size: 0.85rem;
}
.ob-field--name { flex: 2 1 180px; }
.ob-field--notes { flex: 3 1 220px; }
.ob-field--wide { flex: 1 1 100%; }

.ob-fields--general .ob-field { flex: 0 1 200px; }
.ob-fields--general .ob-field--wide { flex: 1 1 100%; }
.ob-fields--site .ob-field { flex: 1 1 170px; }

.ob-row-actions { flex: 0 0 auto; align-self: flex-end; margin-left: auto; }
.ob-row-actions button { padding: 0.4rem 0.9rem; font-size: 0.85rem; }

.ob-delete { flex: 0 0 auto; margin-top: 1.05rem; }
.ob-delete button {
    background: none;
    border: 1px solid var(--border);
    color: var(--muted);
    border-radius: var(--radius);
    font-size: 1rem;
    line-height: 1;
    padding: 0.3rem 0.5rem;
    cursor: pointer;
}
.ob-delete button:hover { border-color: var(--danger); color: var(--danger); }

@media (max-width: 700px) {
    .ob-field, .ob-field--name, .ob-field--notes { flex: 1 1 100%; }
    .ob-row-actions { flex: 1 1 100%; display: flex; justify-content: flex-end; }
}

/* Team management */
.user-revoked td { opacity: 0.55; }
.admin-table td:has(.user-actions), .user-actions { white-space: nowrap; }
.admin-table th:nth-child(3), .admin-table td:nth-child(3) { white-space: nowrap; }
.user-actions form { display: inline; }
.link-action {
    background: none;
    border: none;
    color: var(--primary);
    font-size: 0.85rem;
    padding: 0 0.4rem 0 0;
    cursor: pointer;
    text-decoration: underline;
}
.link-action:hover { color: var(--primary-dark); }
.inline-check {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.85rem;
    color: var(--muted);
    white-space: nowrap;
    margin-bottom: 0;
}
.inline-check input { width: auto; margin: 0; }

/* Ticket numbers are stored as digits and always shown as T123456. */
.ob-ticket { display: flex; align-items: stretch; }
.ob-ticket .ob-ticket-prefix {
    display: flex;
    align-items: center;
    padding: 0 0.4rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-right: none;
    border-radius: var(--radius) 0 0 var(--radius);
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--muted);
}
.ob-ticket input {
    border-radius: 0 var(--radius) var(--radius) 0;
    min-width: 0;
}

/* Sites and their contacts */
.site-block {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.9rem 1rem 1rem;
    margin-top: 1rem;
    background: #fbfcfd;
}
.site-block--new { background: none; border-style: dashed; }

.site-block-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 0.6rem;
}
.site-block-head h3 { margin: 0; font-size: 0.95rem; }
.site-block-actions { display: flex; gap: 0.75rem; }
.site-block-actions form { display: inline; }

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

.site-contacts {
    margin-top: 0.9rem;
    padding-top: 0.6rem;
    border-top: 1px solid var(--border);
}
.site-contacts h4 {
    margin: 0;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--muted);
}
.ob-row--contact { padding: 0.5rem 0; }
.ob-fields--contact .ob-field { flex: 1 1 120px; }
.ob-fields--contact .ob-field--email { flex: 2 1 200px; }

.ob-field--details, .ob-field--update { flex: 1 1 100%; }
.ob-field--details textarea, .ob-field--update textarea { resize: vertical; }
.ob-field--quantity { flex: 0 1 90px; }

/* Document library */
.doc-form .ob-fields { gap: 0.7rem 0.8rem; }
.doc-form textarea { font-family: inherit; line-height: 1.5; resize: vertical; }
.doc-form input[type="file"] { padding: 0.35rem 0; border: none; }
.doc-file-line { margin-bottom: 0.3rem; }

.doc-summary { display: block; font-size: 0.8rem; color: var(--muted); }
.doc-category { margin: 1.1rem 0 0; font-size: 0.9rem; }
.doc-checklist td:first-child, .doc-checklist th:first-child { width: 1.5rem; }
.doc-checklist input[type="checkbox"] { width: auto; margin: 0; }
.doc-checklist input[type="date"], .doc-checklist input[type="text"] {
    margin-bottom: 0;
    padding: 0.3rem 0.45rem;
    font-size: 0.85rem;
}
.user-actions a { margin-right: 0.6rem; font-size: 0.85rem; }

/* Printable document sheet */
.print-page { background: #e9ebee; }
.print-toolbar {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem 1.25rem;
    background: var(--panel);
    border-bottom: 1px solid var(--border);
}
.print-sheet {
    background: #fff;
    max-width: 760px;
    margin: 1.5rem auto 3rem;
    padding: 3rem 3.25rem;
    box-shadow: 0 1px 6px rgba(9, 30, 66, 0.15);
    line-height: 1.6;
}
.print-head { border-bottom: 2px solid var(--text); padding-bottom: 0.9rem; margin-bottom: 1.5rem; }
.print-company {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--muted);
}
.print-head h1 { margin: 0.3rem 0 0; font-size: 1.6rem; }
.print-summary { margin: 0.5rem 0 0; color: var(--muted); }
.print-foot {
    margin-top: 2.5rem;
    padding-top: 0.8rem;
    border-top: 1px solid var(--border);
    font-size: 0.75rem;
    color: var(--muted);
}

@media print {
    .print-toolbar { display: none; }
    .print-page { background: #fff; }
    .print-sheet { box-shadow: none; margin: 0; max-width: none; padding: 0; }
}

/* Task list on the onboarding pack */
.task-list td { padding: 0.45rem 0.5rem; }
.task-row { cursor: pointer; }
.task-row:hover td, .task-row:focus-visible td { background: var(--bg); }
.task-row:focus-visible { outline: 2px solid var(--primary); outline-offset: -2px; }
.task-list td:first-child, .task-list th:first-child { width: 3.5rem; }

.task-status {
    display: inline-block;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: #fff;
    padding: 0.12rem 0.45rem;
    border-radius: 3px;
    white-space: nowrap;
}
.task-status--new { background: var(--status-new); }
.task-status--open { background: var(--status-open); }
.task-status--closed { background: var(--status-closed); }
.task-status--moved { background: var(--status-moved); }

/* Printed onboarding pack */
.print-sheet--pack { max-width: 900px; }

.print-stamp { border-collapse: collapse; margin-top: 1rem; font-size: 0.8rem; width: 100%; }
.print-stamp th {
    text-align: left;
    font-weight: 600;
    color: var(--muted);
    padding: 0.15rem 0.75rem 0.15rem 0;
    white-space: nowrap;
    width: 1%;
}
.print-stamp td { padding: 0.15rem 1.5rem 0.15rem 0; }

.print-block { margin-top: 1.8rem; break-inside: auto; }
.print-block h2 {
    font-size: 1rem;
    margin: 0 0 0.5rem;
    padding-bottom: 0.3rem;
    border-bottom: 1px solid var(--border);
    break-after: avoid;
}
.print-block h3 {
    font-size: 0.85rem;
    margin: 0.9rem 0 0.3rem;
    color: var(--muted);
    break-after: avoid;
}
.print-empty { color: var(--muted); font-style: italic; margin: 0.3rem 0; font-size: 0.9rem; }

.print-table { width: 100%; border-collapse: collapse; font-size: 0.82rem; }
.print-table th {
    text-align: left;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--muted);
    border-bottom: 1px solid var(--border);
    padding: 0.3rem 0.4rem 0.3rem 0;
    vertical-align: bottom;
}
.print-table td {
    padding: 0.35rem 0.4rem 0.35rem 0;
    border-bottom: 1px solid #eef0f3;
    vertical-align: top;
}
.print-table tr { break-inside: avoid; }
.print-table--pairs th { width: 11rem; text-transform: none; font-size: 0.82rem; letter-spacing: 0; }
.print-tick { font-size: 1rem; line-height: 1; }

@media print {
    .print-block { break-inside: auto; }
}

/* Document section editor */
.doc-section {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.8rem 1rem 1rem;
    margin-top: 1rem;
    background: #fbfcfd;
}
.doc-section--new { background: none; border-style: dashed; }

.doc-section-head {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin-bottom: 0.5rem;
}
.doc-section-number {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.4rem;
    height: 1.4rem;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    font-size: 0.75rem;
    font-weight: 700;
    flex: 0 0 auto;
}
.doc-section-actions { margin-left: auto; display: flex; gap: 0.75rem; }
.doc-section-actions form { display: inline; }
.doc-section textarea { font-family: inherit; line-height: 1.5; resize: vertical; }

/* Printed document sections */
.print-section { margin-top: 1.6rem; }
.print-section h2 {
    font-size: 1.05rem;
    margin: 0 0 0.4rem;
    break-after: avoid;
}
.print-sheet p { margin: 0 0 0.8rem; }
.print-sheet ul, .print-sheet ol { margin: 0 0 0.8rem; padding-left: 1.4rem; }
.print-sheet li { margin-bottom: 0.25rem; }

/* Customer notes */
.customer-notes { margin-top: 1rem; }
.customer-notes .log-meta { display: flex; align-items: center; gap: 0.5rem; }
.note-delete { display: inline; }
.note-delete .link-action { font-size: 0.75rem; padding: 0; }

/* Customer list, grouped by status */
.customers-main { max-width: 1200px; }

.customers-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem 2rem;
    flex-wrap: wrap;
}
.customers-head p { margin: 0.2rem 0 0; }
.customers-add { margin-top: 0; flex: 0 1 380px; }

.customers-table td { padding: 0.65rem 0.75rem; }
.customers-table th { padding: 0.4rem 0.75rem; }
.customers-table select { margin-bottom: 0; }
.customers-table td form { margin: 0; }

.customers-table .customer-group th {
    padding-top: 1.4rem;
    padding-bottom: 0.5rem;
    font-size: 0.75rem;
    letter-spacing: 0.05em;
    color: var(--text);
}
.customers-table tbody tr:not(.customer-group):hover td { background: #f8f9fb; }
.customer-group-count {
    display: inline-block;
    margin-left: 0.35rem;
    padding: 0 0.45rem;
    border-radius: 999px;
    background: var(--bg);
    color: var(--muted);
    font-weight: 600;
}

.customer-name { width: 34%; }
.customer-name a { font-weight: 600; color: var(--text); text-decoration: none; }
.customer-name a:hover { color: var(--primary); text-decoration: underline; }
.customer-rename { display: inline-block; margin-left: 0.35rem; vertical-align: middle; }
.customer-rename summary {
    list-style: none;
    cursor: pointer;
    color: var(--muted);
    font-size: 0.85rem;
    opacity: 0;
    padding: 0 0.2rem;
}
.customer-rename summary::-webkit-details-marker { display: none; }
.customers-table tr:hover .customer-rename summary,
.customer-rename summary:focus-visible,
.customer-rename[open] summary { opacity: 1; }
.customer-rename[open] { display: block; margin: 0.5rem 0 0; }
.customer-rename .admin-inline-form input { padding: 0.4rem 0.55rem; font-size: 0.9rem; }

/* Status dropdown styled as a pill, coloured by status */
.status-select {
    width: auto;
    min-width: 9.5rem;
    padding: 0.3rem 1.9rem 0.3rem 0.75rem;
    border-radius: 999px;
    font-size: 0.85rem;
    font-weight: 600;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%23172b4d' stroke-width='1.5'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.7rem center;
    cursor: pointer;
}
.status-select--new_sales    { background-color: #deebff; border-color: #b3d4ff; color: #0747a6; }
.status-select--onboarding   { background-color: #fff4d6; border-color: #ffe08a; color: #7a4f01; }
.status-select--live         { background-color: #e3fcef; border-color: #abf5d1; color: #006644; }
.status-select--mini_project { background-color: #eae6ff; border-color: #c0b6f2; color: #403294; }
.status-select option { background: #fff; color: var(--text); font-weight: 400; }

.status-dot { display: inline-block; width: 0.55rem; height: 0.55rem; border-radius: 50%; margin-right: 0.4rem; }
.status-dot--new_sales    { background: #0065ff; }
.status-dot--onboarding   { background: #ffab00; }
.status-dot--live         { background: #36b37e; }
.status-dot--mini_project { background: #6554c0; }

.progress { display: flex; align-items: center; gap: 0.6rem; min-width: 150px; }
.progress-bar { flex: 1; height: 6px; background: var(--bg); border-radius: 999px; overflow: hidden; }
.progress-bar span { display: block; height: 100%; background: #36b37e; border-radius: 999px; }
.progress-label { font-size: 0.8rem; color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }

.customer-actions { white-space: nowrap; text-align: right; }
.btn-small {
    display: inline-block;
    padding: 0.35rem 0.8rem;
    border-radius: var(--radius);
    font-size: 0.85rem;
    font-weight: 500;
    text-decoration: none;
    background: var(--primary);
    color: #fff;
    border: 1px solid var(--primary);
}
.btn-small:hover { background: var(--primary-dark); border-color: var(--primary-dark); }
.btn-small + .btn-small { margin-left: 0.4rem; }
.btn-small--ghost { background: #fff; color: var(--text); border-color: var(--border); }
.btn-small--ghost:hover { background: var(--bg); border-color: var(--border); }

@media (max-width: 800px) {
    .customers-table thead { display: none; }
    .customers-table tr:not(.customer-group) {
        display: grid;
        grid-template-columns: 1fr auto;
        gap: 0.4rem 0.75rem;
        padding: 0.7rem 0;
        border-bottom: 1px solid var(--border);
    }
    .customers-table tr:not(.customer-group) td { padding: 0; border: none; width: auto; }
    .customers-table td:nth-child(4) { display: none; }
    .customers-table .customer-actions { grid-column: 1 / -1; text-align: left; }
    .customers-add { flex-basis: 100%; }
}
