:root {
    --green-darkest: #102018;
    --green-dark: #173526;
    --green-mid: #24563d;
    --green-bright: #32c46c;
    --green-pale: #d8f5e1;

    --bg: #f4f7f5;
    --panel: #ffffff;
    --line: #d9e2dc;
    --text: #102018;
    --muted: #6b7c70;

    --accent: #32c46c;
    --accent-dark: #0f3d28;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: Arial, Helvetica, sans-serif;
    background: var(--bg);
    color: var(--text);
}

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

/* ── Auth pages (login / register) ─────────────────────────────────────── */

.auth-body {
    background: var(--green-darkest);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.auth-shell {
    display: flex;
    align-items: stretch;
    width: 100%;
    max-width: 820px;
    min-height: 480px;
    border-radius: 20px;
    overflow: hidden;
    box-shadow: 0 24px 64px rgba(0,0,0,0.35);
    margin: 24px;
}

.auth-brand {
    flex: 1;
    background: var(--green-mid);
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: flex-end;
    padding: 40px;
    gap: 12px;
}

.auth-logo {
    border-radius: 10px;
}

.auth-brand-name {
    margin: 0;
    font-size: 1.8rem;
    font-weight: 800;
    color: #fff;
    letter-spacing: -0.02em;
}

.auth-brand-tagline {
    margin: 0;
    font-size: 0.95rem;
    color: rgba(255,255,255,0.65);
    line-height: 1.4;
    max-width: 220px;
}

.auth-card {
    flex: 1.1;
    background: var(--panel);
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 48px 44px;
}

.auth-heading {
    margin: 0 0 4px;
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--green-darkest);
}

.auth-sub {
    margin: 0 0 24px;
    font-size: 0.88rem;
    color: var(--muted);
}

.auth-error {
    margin: 0 0 16px;
    padding: 10px 14px;
    background: #fff0f0;
    border: 1px solid #f5c6c6;
    border-radius: 8px;
    font-size: 0.88rem;
    color: #b00020;
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.auth-label {
    display: flex;
    flex-direction: column;
    gap: 5px;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text);
}

.auth-hint {
    font-weight: 400;
    color: var(--muted);
}

.auth-input {
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    font-size: 0.95rem;
    color: var(--text);
    background: var(--bg);
    outline: none;
    transition: border-color 0.15s;
}

.auth-input:focus {
    border-color: var(--green-bright);
    background: #fff;
}

.auth-btn {
    margin-top: 4px;
    padding: 11px;
    font-size: 0.95rem;
    width: 100%;
    justify-content: center;
}

.auth-switch {
    margin: 20px 0 0;
    font-size: 0.85rem;
    color: var(--muted);
    text-align: center;
}

.auth-switch a {
    color: var(--green-mid);
    font-weight: 600;
    text-decoration: none;
}

.auth-switch a:hover {
    text-decoration: underline;
}

@media (max-width: 580px) {
    .auth-brand { display: none; }
    .auth-card  { padding: 36px 28px; }
    .auth-shell { border-radius: 0; margin: 0; min-height: 100vh; }
}

.icon-sidebar {
    width: 58px;
    background: var(--green-darkest);
    color: var(--green-pale);
    padding-top: 18px;
    text-align: center;
}

.icon-sidebar .logo-mark,
.icon-sidebar .icon-item {
    display: block;
    color: var(--green-pale);
    text-decoration: none;
}

.icon-sidebar .logo-mark {
    font-weight: bold;
    font-size: 22px;
    margin-bottom: 38px;
}

.icon-sidebar .icon-item {
    padding: 16px 0;
    font-size: 18px;
    opacity: 0.75;
}

.icon-sidebar .icon-item:hover,
.icon-sidebar .icon-item.active {
    background: var(--green-bright);
    color: var(--green-darkest);
    opacity: 1;
}

.project-sidebar {
    width: 180px;
    background: var(--green-dark);
    color: white;
    padding: 20px 16px 20px;
    border-top-right-radius: 18px;
    flex-shrink: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.project-sidebar nav {
    flex: 1;
    overflow-y: auto;
}

.project-emblem {
    flex-shrink: 0;
    padding: 16px 8px 4px;
    text-align: center;
}

.project-emblem img {
    width: 64px;
    height: 64px;
    border-radius: 8px;
    object-fit: contain;
    opacity: 0.9;
}

.project-sidebar h2 {
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    opacity: 0.8;
    margin: 0 0 36px;
}

.project-sidebar nav a {
    display: block;
    width: 100%;
    color: white;
    text-decoration: none;
    padding: 12px 14px;
    border-radius: 8px;
    font-weight: bold;
    font-size: 14px;
    margin-bottom: 8px;
    box-sizing: border-box;
}

.project-sidebar nav a:hover,
.project-sidebar nav a.active {
    background: var(--green-bright);
    color: var(--green-darkest);
}

.project-sidebar nav a.nav-child {
    padding-left: 26px;
    font-size: 13px;
    opacity: 0.85;
    margin-bottom: 4px;
}

.project-sidebar nav a.nav-child::before {
    content: '└ ';
    opacity: 0.5;
}

.project-sidebar nav a.nav-child:hover,
.project-sidebar nav a.nav-child.active {
    background: var(--green-bright);
    color: var(--green-darkest);
    opacity: 1;
}

.sidebar-divider {
    border: 0;
    border-top: 1px solid rgba(255,255,255,0.2);
    margin: 22px 10px;
}

.main-area {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.topbar {
    height: 48px;
    background: white;
    border-bottom: 1px solid var(--line);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
}

.project-switcher {
    font-weight: bold;
}

.project-switcher select {
    border: 0;
    font-weight: bold;
    background: transparent;
    color: var(--text);
}

.topbar-stats {
    display: flex;
    align-items: center;
    gap: 18px;
    font-size: 13px;
}

.mini-stat {
    min-width: 160px;
}

.mini-stat label {
    display: block;
    font-size: 11px;
    color: var(--muted);
}

.mini-stat progress {
    width: 160px;
    height: 10px;
}

.content-header {
    background: #eef3ef;
    border-bottom: 1px solid var(--line);
    padding: 16px 28px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.content-header h1 {
    margin: 0;
    font-size: 24px;
}

.content {
    padding: 24px 28px;
}

.card {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 18px;
    margin-bottom: 18px;
}

.btn {
    display: inline-block;
    background: var(--green-bright);
    color: var(--green-darkest);
    padding: 8px 12px;
    border-radius: 6px;
    text-decoration: none;
    font-weight: bold;
    border: 0;
    cursor: pointer;
}

.btn.secondary {
    background: var(--green-pale);
}

.btn.danger {
    background: #c0392b;
    color: #fff;
}

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

.danger-zone {
    border-color: #e8c4c0;
    background: #fff8f7;
}

.danger-zone h2 {
    color: #c0392b;
}

input,
select,
textarea {
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 8px;
}

.task-toolbar {
    display: flex;
    gap: 12px;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 18px;
}

.task-form,
.filter-form {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
}

.task-table {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 12px;
    overflow: hidden;
}

.task-row {
    display: grid;
    grid-template-columns: 38px 1fr 150px 120px 120px 130px 110px 120px 230px;
    gap: 12px;
    align-items: center;
    min-height: 48px;
    padding: 10px 14px;
    border-bottom: 1px solid var(--line);
}

.task-row:nth-child(even) {
    background: #f7faf8;
}

.task-row:last-child {
    border-bottom: 0;
}

.task-row.header {
    background: #eef3ef;
    font-weight: bold;
    color: var(--muted);
    min-height: 40px;
}

.task-title {
    display: flex;
    align-items: center;
    gap: 8px;
}

.task-title a {
    color: var(--text);
    text-decoration: none;
    font-weight: normal;
}

.task-title--subtask a {
    font-style: italic;
}

.task-title a:hover {
    color: var(--green-mid);
    text-decoration: underline;
}

.task-indent {
    display: inline-block;
    width: calc(var(--level) * 22px);
    flex-shrink: 0;
}

.task-status-icon {
    font-size: 18px;
}

.task-meta {
    font-size: 13px;
    color: var(--muted);
}

.task-actions {
    display: flex;
    gap: 6px;
    align-items: center;
}

.task-actions a {
    font-size: 13px;
}

.task-status-action {
    display: flex;
    gap: 6px;
    align-items: center;
    min-width: 140px;
}

.status-pill {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
    background: #eef3ef;
    color: var(--text);
    border: 1px solid var(--line);
}

/* Colored dot for status in task list / kanban header */
.status-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #94a3b8;
    vertical-align: middle;
    margin-right: 4px;
}

/* Workflow settings table (project-settings.php Workflow tab) */
.workflow-table {
    display: grid;
    grid-template-columns: 28px 1fr 44px auto auto auto;
    gap: 4px 8px;
    margin-bottom: 12px;
    align-items: center;
}
.workflow-table-header {
    display: contents;
    font-weight: 700;
    font-size: 12px;
    color: var(--muted);
}
.workflow-table-header > div {
    padding-bottom: 4px;
    border-bottom: 1px solid var(--line);
}
.workflow-row {
    display: contents;
}
.workflow-drag-handle {
    cursor: grab;
    color: var(--muted);
    font-size: 14px;
    text-align: center;
    padding: 4px 0;
}
.workflow-drag-handle:active {
    cursor: grabbing;
}
.workflow-row.dragging > * {
    opacity: 0.4;
}
.workflow-color-swatch {
    display: inline-block;
    width: 20px;
    height: 20px;
    border-radius: 4px;
    border: 1px solid var(--line);
    vertical-align: middle;
}
.workflow-type-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 700;
    color: #fff;
}
.workflow-add-form {
    margin-top: 8px;
    margin-bottom: 4px;
}
.workflow-add-inner {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
    margin-top: 8px;
    padding: 8px;
    background: var(--bg);
    border-radius: 8px;
}
.workflow-add-inner input[type="text"],
.workflow-add-inner select {
    padding: 5px 8px;
    font-size: 13px;
}



.due-date-pill {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
    border: 1px solid var(--line);
    background: #eef3ef;
    color: var(--text);
}

.due-date-pill.due-overdue {
    background: #fee2e2;
    color: #991b1b;
}

.priority-pill {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
    border: 1px solid var(--line);
    background: #eef3ef;
    color: var(--text);
}

.priority-low {
    background: #dcfce7;
}

.priority-medium {
    background: #fef9c3;
}

.priority-high {
    background: #ffedd5;
}

.priority-critical {
    background: #fee2e2;
}

.status-todo {
    background: #f4f4f0;
}

.status-in_progress {
    background: #dbeafe;
}

.status-review {
    background: #fef3c7;
}

.status-done {
    background: #dcfce7;
}

.tag-pill {
    display: inline-block;
    padding: 3px 7px;
    border-radius: 999px;
    font-size: 12px;
    margin-right: 4px;
    margin-bottom: 3px;
    color: #102018;
}

.progress-inline {
    display: flex;
    gap: 8px;
    align-items: center;
}

.progress-inline progress {
    width: 90px;
}

.empty-state {
    background: var(--panel);
    border: 1px dashed var(--line);
    border-radius: 12px;
    padding: 24px;
    color: var(--muted);
}

.error-page-wrap {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 60px 16px;
}

.error-page-card {
    max-width: 480px;
    width: 100%;
    text-align: center;
    padding: 40px 32px;
}

.error-page-icon {
    font-size: 2.4rem;
    margin-bottom: 16px;
    opacity: 0.6;
}

.error-page-title {
    font-size: 1.3rem;
    font-weight: 700;
    margin: 0 0 10px;
    color: var(--text);
}

.error-page-message {
    color: var(--muted);
    margin: 0 0 28px;
    font-size: 0.95rem;
    line-height: 1.6;
}

.error-page-actions {
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
}


.milestone-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 18px;
}

.milestone-card {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 18px;
    box-shadow: 0 8px 18px rgba(16, 32, 24, 0.05);
}

.milestone-card-header {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: flex-start;
    margin-bottom: 12px;
}

.milestone-card h3 {
    margin: 0;
    font-size: 18px;
}

.milestone-percent {
    background: var(--green-pale);
    color: var(--green-darkest);
    border-radius: 999px;
    padding: 4px 9px;
    font-size: 13px;
    font-weight: bold;
}

.milestone-card progress {
    width: 100%;
    height: 12px;
    margin: 8px 0 12px;
}

.milestone-meta {
    color: var(--muted);
    font-size: 13px;
    margin: 8px 0;
}

.milestone-description {
    min-height: 44px;
    color: var(--text);
    line-height: 1.4;
}

.milestone-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 14px;
}

.milestone-form {
    max-width: 760px;
}

.form-grid {
    display: grid;
    grid-template-columns: minmax(220px, 1fr) 160px 100px;
    gap: 12px;
    align-items: end;
}

.form-full {
    margin-top: 12px;
}

.form-full textarea {
    width: 100%;
}

.hidden {
    display: none !important;
}

.milestone-toggle-btn {
    margin-bottom: 18px;
}

.sort-order-input {
    width: 90px;
    max-width: 90px;
}

.section-spacer {
    height: 8px;
}

.task-detail-layout {
    display: grid;
    gap: 18px;
    max-width: 980px;
}

.task-detail-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
}

.task-detail-header h2 {
    margin: 0;
    font-size: 28px;
}

.status-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
}

.status-item {
    background: #f7faf8;
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 12px;
}

.status-item strong {
    display: block;
    font-size: 12px;
    color: var(--muted);
    margin-bottom: 4px;
}

.detail-progress progress {
    width: 100%;
    height: 14px;
}

.card--complete {
    border: 2px solid #2fbf71;
}

.card--complete .card-complete-badge {
    display: inline-block;
    background: #2fbf71;
    color: #fff;
    font-size: 0.75rem;
    font-weight: 700;
    padding: 3px 12px;
    border-radius: 999px;
    margin-bottom: 10px;
    letter-spacing: 0.04em;
}

.card-complete-badge { display: none; }

.card-section-summary {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    list-style: none;
    margin-bottom: 0;
}

.card-section-summary::-webkit-details-marker { display: none; }

.card-section-summary h3 {
    margin: 0;
    flex: 1;
}

.card-section-summary::after {
    content: '▸';
    font-size: 0.75rem;
    color: var(--muted);
    transition: transform 0.15s;
}

details[open] > .card-section-summary::after {
    transform: rotate(90deg);
}

details > .card-section-summary {
    margin-bottom: 0;
}

details[open] > .card-section-summary {
    margin-bottom: 14px;
}

.subtask-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
}

.subtask-section-header h3 {
    margin: 0;
}

.add-subtask-popover[open]::before {
    content: "";
    position: fixed;
    inset: 0;
    background: rgba(23, 38, 23, 0.48);
    z-index: 80;
}

.add-subtask-popover[open] .task-modal-card {
    position: fixed;
    top: 50%;
    left: 50%;
    right: auto;
    transform: translate(-50%, -50%);
    z-index: 90;
    width: min(720px, calc(100vw - 48px));
    max-height: calc(100vh - 72px);
    overflow: auto;
    box-shadow: 0 28px 80px rgba(5, 20, 10, 0.34);
    border-radius: 18px;
    padding: 22px;
}

.subtask-list {
    display: grid;
    gap: 8px;
}

.subtask-item {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: center;
    background: #f7faf8;
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 10px 12px;
}

.subtask-item a {
    font-weight: bold;
    color: var(--text);
    text-decoration: none;
}

.subtask-item a:hover {
    color: var(--green-mid);
    text-decoration: underline;
}

.editable-block {
    cursor: pointer;
    border: 1px dashed transparent;
    border-radius: 10px;
    padding: 10px;
}

.editable-block:hover {
    border-color: var(--line);
    background: #f7faf8;
}

.inline-edit-form {
    display: none;
}

.inline-edit-form.active {
    display: block;
}

.inline-edit-display.hidden {
    display: none;
}

.inline-edit-form textarea {
    width: 100%;
    min-height: 140px;
    margin-bottom: 10px;
}

.project-sidebar h2 {
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    opacity: 0.8;
}
/* Navigation level refinements */
.icon-sidebar {
    flex-shrink: 0;
    transition: width 0.15s ease;
}

.icon-sidebar.compact {
    width: 58px;
}

.icon-sidebar.expanded {
    width: 180px;
    text-align: left;
    padding-left: 0;
    padding-right: 0;
}

.icon-sidebar .logo-mark,
.icon-sidebar .icon-item {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--green-pale);
    text-decoration: none;
    min-height: 52px;
}

.icon-sidebar.compact .logo-mark,
.icon-sidebar.compact .icon-item {
    justify-content: center;
}

.icon-sidebar.expanded .logo-mark,
.icon-sidebar.expanded .icon-item {
    justify-content: flex-start;
    padding-left: 18px;
    padding-right: 18px;
}

.icon-sidebar .logo-mark {
    font-weight: bold;
    font-size: 22px;
    margin-bottom: 34px;
}

.icon-sidebar .icon-symbol {
    display: inline-flex;
    width: 22px;
    justify-content: center;
    flex-shrink: 0;
}

.icon-sidebar .icon-label {
    font-size: 14px;
    font-weight: bold;
    white-space: nowrap;
}

.icon-sidebar.compact .icon-label {
    display: none;
}

.icon-sidebar .icon-item {
    padding-top: 0;
    padding-bottom: 0;
    font-size: 18px;
    opacity: 0.75;
}

.icon-sidebar .icon-item:hover,
.icon-sidebar .icon-item.active {
    background: var(--green-bright);
    color: var(--green-darkest);
    opacity: 1;
}

.project-sidebar {
    width: 180px;
    background: var(--green-dark);
    color: white;
    padding: 20px 0;
    border-top-right-radius: 18px;
    flex-shrink: 0;
    overflow: visible;
}

.project-sidebar h2 {
    padding: 0 28px;
}

.project-sidebar nav {
    padding: 0 26px;
}

.project-sidebar nav a {
    display: flex;
    align-items: center;
    width: 100%;
    max-width: 100%;
    color: white;
    text-decoration: none;
    padding: 12px 14px;
    border-radius: 8px;
    font-weight: bold;
    font-size: 14px;
    margin-bottom: 8px;
    box-sizing: border-box;
}

.project-sidebar nav a:hover,
.project-sidebar nav a.active {
    background: var(--green-bright);
    color: var(--green-darkest);
}

.sidebar-divider {
    margin: 22px 0;
}

.icon-section-label {
    margin-top: 18px;
    padding: 10px 14px 6px;
    color: var(--green-pale);
    opacity: 0.55;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}
.inline-edit-form input[type="text"],
.inline-edit-form input[type="number"],
.inline-edit-form select {
    width: 100%;
    margin-bottom: 8px;
}

.inline-edit-form .btn {
    margin-top: 4px;
    margin-right: 4px;
}

.inline-checkbox {
    display: block;
    margin-bottom: 6px;
    font-size: 14px;
}

/* Modular dashboard */
.dashboard-hero {
    display: flex;
    justify-content: space-between;
    gap: 20px;
    align-items: center;
    background: #ffffff;
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 22px;
    margin-bottom: 22px;
}

.dashboard-hero h2 {
    margin: 0 0 6px;
}

.eyebrow {
    margin: 0 0 6px;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--green-dark);
    font-weight: bold;
}

.muted-text {
    color: #617468;
    margin: 0;
}

.dashboard-hero-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.btn.secondary {
    background: #eef3ef;
    color: var(--green-darkest);
}

.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 18px;
    align-items: start;
    margin-bottom: 18px;
}

/* ── Widget wrapper ─────────────────────────────────────────────────────────
   View mode: wrap is display:block and itself spans columns
   Edit mode: wrap is also display:block, acts as the draggable grid child     */
.widget-wrap {
    display: block;
}
.widget-wrap.widget-size-wide   { grid-column: 1 / -1; }
.widget-wrap.widget-size-normal { grid-column: span 1; }

/* In edit mode the inner .dashboard-widget does NOT control its own span —
   the wrap handles it. The top border is removed so the edit-bar connects.  */
.dashboard-grid.edit-mode .widget-wrap.widget-size-wide {
    grid-column: 1 / -1;
}
.dashboard-grid.edit-mode .widget-wrap.widget-size-normal {
    grid-column: span 1;
}

.dashboard-widget {
    background: #ffffff;
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 18px;
    min-height: 150px;
}

.dashboard-widget-wide {
    grid-column: 1 / -1;
    margin-bottom: 18px;
}
.dashboard-widget-locked { margin-bottom: 18px; }

.dashboard-widget-header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
}

.dashboard-widget-header h3 { margin: 0; }

.widget-locked-badge {
    font-size: 11px;
    color: var(--muted);
    font-style: italic;
}

/* ── Edit mode ─────────────────────────────────────────────────────────────── */
.widget-edit-bar {
    display: none;
    align-items: center;
    gap: 10px;
    padding: 7px 10px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-bottom: none;
    border-radius: 10px 10px 0 0;
    user-select: none;
}
.dashboard-grid.edit-mode .widget-edit-bar { display: flex; }

.dashboard-grid.edit-mode .dashboard-widget {
    border-radius: 0 0 10px 10px;
    border-top: none;
}
/* inner widget never controls its own column span — the wrap does */
.dashboard-grid .widget-wrap .dashboard-widget {
    grid-column: unset;
}

.widget-drag-handle {
    cursor: grab;
    color: var(--muted);
    font-size: 16px;
    flex-shrink: 0;
    padding: 2px 4px;
    border-radius: 4px;
}
.widget-drag-handle:active { cursor: grabbing; }

.widget-edit-title {
    flex: 1;
    font-size: 13px;
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.widget-edit-controls {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.widget-size-btn {
    background: var(--bg);
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 3px 9px;
    font-size: 12px;
    cursor: pointer;
    color: var(--text);
    white-space: nowrap;
}
.widget-size-btn:hover { border-color: var(--accent); color: var(--accent); }

/* Toggle switch */
.widget-toggle-label {
    display: flex;
    align-items: center;
    cursor: pointer;
    gap: 0;
}
.widget-toggle-check { display: none; }
.widget-toggle-track {
    width: 36px;
    height: 20px;
    background: var(--line);
    border-radius: 10px;
    position: relative;
    transition: background .2s;
    flex-shrink: 0;
}
.widget-toggle-check:checked + .widget-toggle-track { background: var(--accent); }
.widget-toggle-thumb {
    position: absolute;
    top: 3px;
    left: 3px;
    width: 14px;
    height: 14px;
    background: #fff;
    border-radius: 50%;
    transition: left .18s;
    box-shadow: 0 1px 3px rgba(0,0,0,.2);
}
.widget-toggle-check:checked + .widget-toggle-track .widget-toggle-thumb { left: 19px; }

/* Disabled widget — hidden in normal view, dimmed in edit mode */
.widget-wrap.widget-disabled { display: none; }
.dashboard-grid.edit-mode .widget-wrap.widget-disabled { display: block; }
.dashboard-grid.edit-mode .widget-wrap.widget-disabled .dashboard-widget {
    opacity: 0.35;
    pointer-events: none;
}
.dashboard-grid.edit-mode .widget-wrap.widget-disabled .widget-edit-bar { opacity: 0.7; }

/* Drag states */
.widget-wrap.widget-dragging { opacity: 0.4; }
.widget-wrap.drag-before { box-shadow: 0 -3px 0 var(--accent); border-radius: 10px; }
.widget-wrap.drag-after  { box-shadow: 0 3px 0 var(--accent);  border-radius: 10px; }

.stats-card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 14px;
}

.dashboard-stat-card {
    border: 1px solid var(--line);
    background: #f7faf8;
    border-radius: 10px;
    padding: 14px;
}

.dashboard-stat-card span,
.dashboard-stat-card small {
    display: block;
    color: #617468;
    font-size: 13px;
}

.dashboard-stat-card strong {
    display: block;
    margin: 6px 0;
    font-size: 24px;
}

.status-pill-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 14px;
}

.status-summary-pill {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    border: 1px solid var(--line);
    background: #eef3ef;
    padding: 7px 10px;
    border-radius: 999px;
    font-size: 13px;
}

.dashboard-task-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.dashboard-task-row {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: center;
    text-decoration: none;
    color: inherit;
    border: 1px solid var(--line);
    background: #f7faf8;
    border-radius: 10px;
    padding: 10px 12px;
}

.dashboard-task-row:hover {
    background: #eef3ef;
    border-color: var(--green-dark);
}

.task-row-title {
    font-weight: bold;
    display: flex;
    align-items: center;
    gap: 6px;
}

.type-badge {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.03em;
    background: #e0f2fe;
    color: #0369a1;
    border-radius: 4px;
    padding: 1px 6px;
    white-space: nowrap;
    flex-shrink: 0;
}

.task-row-meta {
    color: #617468;
    font-size: 13px;
    white-space: nowrap;
}

.empty-widget {
    color: #617468;
    margin-bottom: 0;
}

@media (max-width: 760px) {
    .dashboard-hero {
        align-items: flex-start;
        flex-direction: column;
    }

    .dashboard-hero-actions {
        justify-content: flex-start;
    }

    .dashboard-task-row {
        align-items: flex-start;
        flex-direction: column;
        gap: 4px;
    }
}

/* Activity / audit log */
.activity-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.activity-item {
    border: 1px solid #d6e2d8;
    border-radius: 12px;
    padding: 12px 14px;
    background: #f8fbf8;
}

.activity-message {
    font-weight: 650;
    color: #172617;
}

.activity-message a {
    color: inherit;
    text-decoration: none;
}

.activity-message a:hover {
    text-decoration: underline;
}

.activity-meta {
    margin-top: 4px;
    font-size: 0.84rem;
    color: #60705f;
}

.compact-activity-list .activity-item {
    padding: 10px 12px;
}

/* Project settings tabs + typed tag fields */
.settings-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 14px;
    padding: 8px;
}

.settings-tab {
    border-radius: 999px;
    color: #31503a;
    padding: 8px 14px;
    text-decoration: none;
}

.settings-tab:hover,
.settings-tab.active {
    background: #d8f5e1;
    color: #172617;
}

.tag-input {
    max-width: 520px;
    width: 100%;
}

.tag-settings-table {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin: 16px 0;
}

.tag-settings-row {
    align-items: center;
    border: 1px solid #d6e2d8;
    border-radius: 12px;
    display: grid;
    gap: 12px;
    grid-template-columns: 1fr 1fr 120px;
    padding: 10px 12px;
}

.tag-settings-row.header {
    background: #f2f7f2;
    color: #60705f;
    font-size: 0.84rem;
    font-weight: 700;
    text-transform: uppercase;
}

@media (max-width: 760px) {
    .settings-tabs {
        flex-wrap: wrap;
    }

    .tag-settings-row {
        grid-template-columns: 1fr;
    }
}

.comment-form textarea {
    width: 100%;
    min-height: 90px;
    resize: vertical;
}

.comment-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.comment-card {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 12px 14px;
    background: rgba(255, 255, 255, 0.03);
}

.comment-card-body {
    flex: 1;
    min-width: 0;
}

.comment-meta {
    font-size: 0.85rem;
    color: var(--muted);
    margin-bottom: 6px;
}

.comment-body {
    line-height: 1.5;
}
.view-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 14px;
}

.view-header h2 {
    margin: 0;
}

.view-toggle {
    display: inline-flex;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 4px;
    gap: 4px;
}

.view-toggle a {
    display: inline-block;
    padding: 7px 12px;
    border-radius: 999px;
    color: var(--text);
    text-decoration: none;
    font-weight: 700;
    font-size: 13px;
}

.view-toggle a.active,
.view-toggle a:hover {
    background: var(--green-bright);
    color: var(--green-darkest);
}

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

.kanban-column {
    background: #eef3ef;
    border: 1px solid var(--line);
    border-radius: 14px;
    min-height: 360px;
    padding: 12px;
}

.kanban-column.drag-over {
    outline: 2px dashed var(--green-bright);
    outline-offset: 3px;
}

.kanban-column-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 12px;
}

.kanban-column-header h3 {
    margin: 0;
    font-size: 15px;
}

.kanban-column-header span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 26px;
    height: 26px;
    border-radius: 999px;
    background: var(--panel);
    border: 1px solid var(--line);
    color: var(--muted);
    font-weight: 700;
    font-size: 12px;
}

.kanban-card-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-height: 290px;
}

.kanban-card {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 12px;
    box-shadow: 0 2px 8px rgba(16, 32, 24, 0.06);
    cursor: grab;
}

.repeat-indicator {
    font-size: 11px;
    margin-left: 5px;
    color: var(--muted);
    vertical-align: middle;
}

.kanban-card--done {
    border-color: #2fbf71;
    opacity: 0.75;
}

.kanban-card.dragging {
    opacity: 0.55;
}

.kanban-card.saving {
    opacity: 0.7;
    cursor: progress;
}

.kanban-card-topline {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 8px;
}

.kanban-card-title {
    display: block;
    color: var(--text);
    text-decoration: none;
    font-weight: 800;
    line-height: 1.25;
    margin-bottom: 10px;
}

.kanban-card-title:hover {
    color: var(--green-mid);
    text-decoration: underline;
}

.kanban-card-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    color: var(--muted);
    font-size: 12px;
    margin-top: 8px;
}

.kanban-card-tags {
    margin-top: 10px;
}

.kanban-card-footer {
    margin-top: 10px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
}

.kanban-parent-pill {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
    border: 1px solid var(--line);
    background: #eef3ef;
    color: var(--muted);
}

.kanban-progress {
    margin-top: 10px;
}

@media (max-width: 1200px) {
    .kanban-board {
        grid-template-columns: repeat(4, 280px);
    }
}

@media (max-width: 700px) {
    .view-header {
        align-items: flex-start;
        flex-direction: column;
    }
}

/* Attachments / project documents */
.error-message {
    background: #fff1f1;
    border: 1px solid #f1b8b8;
    border-radius: 10px;
    color: #8a1f1f;
    padding: 10px 12px;
}

.attachment-actions {
    display: grid;
    gap: 14px;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    margin-bottom: 12px;
}

.attachment-form {
    border: 1px solid var(--line);
    border-radius: 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 14px;
}

.attachment-form h4 {
    margin: 0;
}

.attachment-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.attachment-card {
    align-items: center;
    border: 1px solid var(--line);
    border-radius: 14px;
    display: flex;
    gap: 12px;
    padding: 12px 14px;
}

.attachment-icon {
    font-size: 1.5rem;
    width: 34px;
}

.attachment-main {
    flex: 1;
    min-width: 0;
}

.attachment-main a {
    color: inherit;
    text-decoration: none;
}

.attachment-main a:hover {
    text-decoration: underline;
}

.project-documents-list .attachment-card {
    align-items: flex-start;
}

@media (max-width: 760px) {
    .attachment-actions {
        grid-template-columns: 1fr;
    }

    .attachment-card {
        align-items: flex-start;
        flex-direction: column;
    }
}


/* Notifications */
.notification-toplink {
    align-items: center;
    display: inline-flex;
    gap: 6px;
}

.notification-badge {
    align-items: center;
    background: var(--green-mid);
    border-radius: 999px;
    color: #fff;
    display: inline-flex;
    font-size: 12px;
    font-weight: 800;
    justify-content: center;
    min-width: 22px;
    padding: 2px 7px;
}

.notification-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.notification-card {
    align-items: flex-start;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 14px;
    display: flex;
    gap: 14px;
    justify-content: space-between;
    padding: 14px;
}

.notification-card.unread {
    background: #f1fbf4;
    border-color: var(--green-soft);
}

.notification-title {
    color: var(--text);
    display: inline-block;
    font-weight: 800;
    margin-bottom: 4px;
    text-decoration: none;
}

.notification-title:hover {
    color: var(--green-mid);
    text-decoration: underline;
}

.notification-main p {
    margin: 0 0 6px;
}

.small-button {
    padding: 7px 10px;
    white-space: nowrap;
}

.mention-wrapper {
    position: relative;
}

.mention-wrapper textarea {
    width: 100%;
}

.mention-menu {
    display: none;
    position: absolute;
    z-index: 50;
    background: #ffffff;
    border: 1px solid #d6e7dc;
    border-radius: 10px;
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.12);
    overflow: hidden;
}

.mention-menu.active {
    display: block;
}

.mention-option {
    display: block;
    width: 100%;
    padding: 10px 12px;
    border: 0;
    border-bottom: 1px solid #edf4ef;
    background: #ffffff;
    text-align: left;
    cursor: pointer;
}

.mention-option:hover,
.mention-option:focus {
    background: #f2fbf4;
}

.mention-option strong,
.mention-option span {
    display: block;
}

.mention-option span {
    margin-top: 2px;
    font-size: 0.85rem;
    color: #5f7568;
}


.task-search-panel {
    align-items: flex-end;
}

.filter-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 150px;
}

.filter-field-wide {
    min-width: 260px;
    flex: 1 1 260px;
}

.filter-field label,
.filter-check {
    font-size: 0.88rem;
    color: var(--muted);
}

.filter-field input,
.filter-field select {
    width: 100%;
}

.filter-check {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 38px;
    padding: 0 8px;
}

.filter-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

.quick-filter-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 10px 0 18px;
}

.filter-chip {
    display: inline-flex;
    align-items: center;
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 6px 10px;
    text-decoration: none;
    color: var(--text);
    background: var(--panel);
    font-size: 0.9rem;
}

.filter-chip.active {
    border-color: var(--accent);
    background: #e8f6ed;
    color: var(--accent-dark);
    font-weight: 600;
}

.saved-views-panel {
    margin-top: 16px;
}

.saved-views-header {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    align-items: flex-start;
    margin-bottom: 12px;
}

.saved-views-header h2 {
    margin: 0 0 4px;
}

.saved-view-active {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
    padding: 10px 12px;
    border-radius: 12px;
    background: #eef7ff;
    border: 1px solid #cfe8ff;
}

.saved-view-list {
    display: grid;
    gap: 8px;
    margin-bottom: 14px;
}

.saved-view-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 10px 12px;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    background: #fff;
}

.saved-view-item.active {
    border-color: #7dd3fc;
    background: #f0f9ff;
}

.saved-view-item a {
    display: flex;
    flex-direction: column;
    gap: 2px;
    text-decoration: none;
    color: inherit;
    flex: 1;
}

.saved-view-item a span {
    font-size: 0.85rem;
    color: #64748b;
}

.view-scope-pill {
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    background: #f1f5f9;
    color: #475569;
    padding: 3px 8px;
    font-size: 0.75rem;
    white-space: nowrap;
}

.saved-view-form {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    border-top: 1px solid #e5e7eb;
    padding-top: 14px;
}

.saved-view-form input[type="text"] {
    min-width: 240px;
    flex: 1;
}

.btn-link {
    border: 0;
    background: transparent;
    color: #2563eb;
    cursor: pointer;
    padding: 0;
    font: inherit;
}

.btn-link.danger {
    color: #dc2626;
}

/* Cleaner task page controls */
.task-command-bar {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 14px;
}

.saved-view-chip-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    min-height: 38px;
}

.saved-view-chip {
    display: inline-flex;
    align-items: center;
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 7px 12px;
    background: var(--panel);
    color: var(--text);
    text-decoration: none;
    font-weight: 600;
    font-size: 0.9rem;
}

.saved-view-chip.active {
    border-color: var(--accent);
    background: #e8f6ed;
    color: var(--accent-dark);
}

.task-command-actions {
    display: flex;
    align-items: flex-start;
    justify-content: flex-end;
    gap: 10px;
    position: relative;
    flex-shrink: 0;
}

.action-popover {
    position: relative;
}

.action-popover > summary {
    list-style: none;
    user-select: none;
}

.action-popover > summary::-webkit-details-marker {
    display: none;
}

.square-action {
    width: 38px;
    height: 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    font-size: 1rem;
}

.popover-card {
    position: absolute;
    right: 0;
    top: 48px;
    z-index: 20;
    width: min(720px, calc(100vw - 260px));
    box-shadow: 0 18px 45px rgba(13, 42, 28, 0.16);
}

.add-task-popover .popover-card {
    width: min(880px, calc(100vw - 260px));
}

.task-form .full-width-field,
.task-form .full-width-actions {
    flex-basis: 100%;
}

.task-form .full-width-field input {
    width: 100%;
    max-width: 520px;
    margin-top: 6px;
}

.full-width-actions {
    display: flex;
    justify-content: flex-end;
}

.compact-search {
    display: block;
    padding: 14px;
}

.search-line {
    display: grid;
    grid-template-columns: minmax(260px, 1fr) auto auto;
    gap: 10px;
    align-items: center;
}

.search-line input[type="search"] {
    width: 100%;
}

.advanced-filter-details {
    margin-top: 10px;
}

.advanced-filter-details > summary {
    cursor: pointer;
    color: var(--accent-dark);
    font-weight: 700;
    width: max-content;
    padding: 6px 0;
}

.advanced-filter-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 12px;
    align-items: end;
    margin-top: 8px;
    padding-top: 12px;
    border-top: 1px solid var(--line);
}

.advanced-filter-grid .filter-field-wide {
    grid-column: span 2;
}

.saved-views-panel.popover-card {
    margin-bottom: 0;
}

.saved-view-list.compact {
    max-height: 260px;
    overflow: auto;
    padding-right: 4px;
}

@media (max-width: 900px) {
    .task-command-bar {
        flex-direction: column-reverse;
    }

    .task-command-actions {
        width: 100%;
        justify-content: flex-start;
    }

    .popover-card,
    .add-task-popover .popover-card {
        left: 0;
        right: auto;
        width: calc(100vw - 64px);
    }

    .search-line {
        grid-template-columns: 1fr;
    }

    .advanced-filter-grid .filter-field-wide {
        grid-column: auto;
    }
}

/* Task page cleanup round 2 */
.task-command-bar {
    justify-content: flex-end;
}

.task-command-bar > .task-command-actions {
    width: 100%;
}

.add-task-popover[open]::before {
    content: "";
    position: fixed;
    inset: 0;
    background: rgba(23, 38, 23, 0.48);
    z-index: 80;
}

.add-task-popover[open] .task-modal-card {
    position: fixed;
    top: 50%;
    left: 50%;
    right: auto;
    transform: translate(-50%, -50%);
    z-index: 90;
    width: min(920px, calc(100vw - 48px));
    max-height: calc(100vh - 72px);
    overflow: auto;
    box-shadow: 0 28px 80px rgba(5, 20, 10, 0.34);
    border-radius: 18px;
    padding: 22px;
}

.task-modal-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    border-bottom: 1px solid var(--line);
    padding-bottom: 14px;
    margin-bottom: 4px;
}

.task-modal-header h2 {
    margin: 0 0 4px 0;
}

.modal-close {
    border: 1px solid var(--line);
    background: var(--green-pale);
    color: var(--text);
    border-radius: 999px;
    width: 36px;
    height: 36px;
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
}

.task-form .full-width-field-input,
.task-form textarea {
    width: 100%;
}

.task-list-header {
    align-items: center;
}

.task-list-title-row {
    display: flex;
    align-items: center;
    gap: 14px;
    min-width: 0;
}

.task-list-saved-views {
    min-height: 0;
    overflow-x: auto;
    flex-wrap: nowrap;
    padding-bottom: 2px;
}

.task-list-saved-views .saved-view-chip {
    white-space: nowrap;
}

.search-line .btn,
.filter-actions .btn {
    text-align: center;
}

.filter-field .tag-input {
    width: 100%;
    max-width: none;
    margin-top: 4px;
}

@media (max-width: 900px) {
    .task-list-header,
    .task-list-title-row {
        align-items: flex-start;
        flex-direction: column;
    }

    .task-list-saved-views {
        width: 100%;
        flex-wrap: wrap;
    }
}

/* Page-owned headers */
.content-header-title {
    min-width: 0;
}

.content-header-title h1 {
    margin: 0;
}

.content-header-title p {
    margin: 4px 0 0 0;
}

.content-header-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    flex-shrink: 0;
}

.page-header-with-actions {
    gap: 18px;
}

.page-header-with-actions .task-command-actions {
    width: auto;
}

@media (max-width: 900px) {
    .content-header,
    .page-header-with-actions {
        align-items: flex-start;
        flex-direction: column;
    }

    .content-header-actions {
        justify-content: flex-start;
        width: 100%;
    }
}

/* Lists module */
.list-items {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 16px;
}

.list-category-badge {
    display: inline-block;
    font-size: 10px;
    font-weight: 700;
    padding: 1px 7px;
    border-radius: 999px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-left: 6px;
    vertical-align: middle;
}

.list-refresh-chip {
    display: inline-block;
    font-size: 11px;
    color: #617468;
    margin-left: 8px;
    vertical-align: middle;
}

.list-item-completed-by {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: #617468;
    white-space: nowrap;
}

.list-item-xp {
    display: inline-block;
    font-size: 11px;
    font-weight: 700;
    color: #16a34a;
    background: #dcfce7;
    padding: 1px 6px;
    border-radius: 999px;
}

.list-item-row {
    display: grid;
    grid-template-columns: auto 1fr auto auto;
    gap: 12px;
    align-items: center;
    padding: 12px 14px;
    border: 1px solid rgba(40, 91, 64, 0.14);
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.72);
}

.list-item-row.is-done .list-item-body {
    text-decoration: line-through;
    opacity: 0.62;
}

.list-item-row.is-done .list-item-completed-by {
    opacity: 1;
}

.checkbox-button {
    border: 0;
    background: transparent;
    font-size: 1.25rem;
    cursor: pointer;
}

.list-detail-progress {
    margin-bottom: 18px;
}

/* Lists module */
.list-table-card {
    padding: 0;
    overflow: hidden;
}

.list-table-header,
.list-table-row {
    display: grid;
    grid-template-columns: minmax(220px, 1.5fr) minmax(120px, 1fr) 120px 140px 130px 150px minmax(150px, 1fr);
    gap: 14px;
    align-items: center;
    padding: 12px 16px;
}

.list-table-header {
    background: #eef3ef;
    border-bottom: 1px solid var(--line);
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.list-table-row {
    min-height: 58px;
    border-bottom: 1px solid var(--line);
}

.list-table-row:nth-child(even) {
    background: #f7faf8;
}

.list-table-row:last-child {
    border-bottom: 0;
}

.list-table-row .task-title {
    min-width: 0;
}

.list-table-row .task-title a {
    overflow-wrap: anywhere;
}

.progress-inline {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.progress-inline progress {
    width: 70px;
    height: 8px;
}

.progress-inline span {
    white-space: nowrap;
    font-size: 0.85rem;
}

@media (max-width: 1200px) {
    .list-table-header {
        display: none;
    }

    .list-table-row {
        grid-template-columns: 1fr 1fr;
        align-items: start;
    }
}

@media (max-width: 700px) {
    .list-table-row {
        grid-template-columns: 1fr;
    }
}

/* ── Orders module ──────────────────────────────────────────────────────────── */
.order-table-card { padding: 0; overflow: hidden; }

.order-table-header,
.order-table-row {
    display: grid;
    grid-template-columns: 120px minmax(160px,1fr) 80px 100px 110px 110px 120px;
    gap: 14px;
    align-items: center;
    padding: 12px 16px;
}

.order-table-header {
    background: #eef3ef;
    border-bottom: 1px solid var(--line);
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.order-table-row {
    min-height: 54px;
    border-bottom: 1px solid var(--line);
}

.order-table-row:nth-child(even) { background: #f7faf8; }
.order-table-row:last-child { border-bottom: 0; }

.order-table-row a {
    font-weight: 600;
    text-decoration: none;
    color: var(--text);
}

.order-table-row a:hover { text-decoration: underline; }

.order-number-link {
    font-family: monospace;
    font-size: 0.9rem;
}

.order-status-pill,
.order-payment-pill {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 600;
    white-space: nowrap;
}

/* Order detail page */
.order-detail-grid {
    display: grid;
    grid-template-columns: 1fr 320px;
    gap: 20px;
    align-items: start;
}

.order-items-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.order-items-table th {
    background: #eef3ef;
    border-bottom: 2px solid var(--line);
    padding: 10px 12px;
    text-align: left;
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--muted);
}

.order-items-table td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--line);
    vertical-align: middle;
}

.order-items-table tr:last-child td { border-bottom: 0; }

.order-totals {
    margin-top: 4px;
    border-top: 2px solid var(--line);
}

.order-totals-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    border-bottom: 1px solid var(--line);
    font-size: 0.9rem;
}

.order-totals-row:last-child { border-bottom: 0; }

.order-totals-row.total-row {
    font-weight: 700;
    font-size: 1rem;
    border-top: 2px solid var(--line);
    padding-top: 12px;
}

.order-history-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.order-history-item {
    padding: 10px 12px;
    border-left: 3px solid var(--line);
    font-size: 0.85rem;
}

.order-history-item-status {
    font-weight: 600;
    margin-bottom: 2px;
}

.order-history-item-meta {
    color: var(--muted);
    font-size: 0.8rem;
}

.add-item-form {
    display: grid;
    grid-template-columns: 1fr auto auto auto;
    gap: 8px;
    align-items: end;
    padding: 12px 0 0;
}

@media (max-width: 1100px) {
    .order-detail-grid { grid-template-columns: 1fr; }
    .order-table-header { display: none; }
    .order-table-row { grid-template-columns: 1fr 1fr; align-items: start; }
}

@media (max-width: 600px) {
    .order-table-row { grid-template-columns: 1fr; }
    .add-item-form { grid-template-columns: 1fr; }
}

/* List group (category section) — matches milestone-group-header style */
.list-group {
    margin-bottom: 28px;
}

.list-group-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 0 8px;
    border-bottom: 2px solid var(--line);
    margin-bottom: 12px;
}

.list-group-title {
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.list-group-count {
    font-size: 0.82rem;
    color: var(--muted);
}

/* List card view — matches note-card style */
.list-cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 16px;
}

.list-card {
    display: flex;
    flex-direction: column;
    gap: 0;
    background: #fff;
    border: 1px solid #d7e3dc;
    border-radius: 14px;
    padding: 20px;
    text-decoration: none;
    color: var(--text);
    transition: border-color 0.15s, box-shadow 0.15s;
    cursor: pointer;
}

.list-card:hover {
    border-color: #2fbf71;
    box-shadow: 0 2px 10px rgba(47, 191, 113, 0.12);
    text-decoration: none;
}

.list-card--complete {
    opacity: 0.65;
}

.list-card-icon {
    font-size: 1.4rem;
    color: #2fbf71;
    margin-bottom: 10px;
    line-height: 1;
}

.list-card-body {
    flex: 1;
}

.list-card-title {
    font-size: 1rem;
    font-weight: 700;
    margin: 0 0 6px;
    color: #0f3d28;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.list-card-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
    margin-top: 4px;
    font-size: 0.85rem;
    color: var(--text-muted, #6b8a77);
}

.list-card-progress {
    margin-top: 14px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.list-card-progress progress {
    width: 100%;
    height: 6px;
}

.list-card-progress span {
    font-size: 0.82rem;
    color: var(--text-muted, #6b8a77);
}

.list-card-footer {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid #eef3f0;
}

.list-card-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    width: 100%;
    margin-top: 2px;
}

/* View toggle button group */
.view-toggle-btns {
    display: flex;
    gap: 4px;
}

.view-toggle-btns .btn {
    padding: 6px 14px;
    border-radius: 8px;
}

.module-settings-list {
    display: grid;
    gap: 12px;
    margin: 16px 0 20px;
}

.module-toggle-card {
    display: grid;
    grid-template-columns: auto auto 1fr auto;
    align-items: center;
    gap: 14px;
    padding: 14px 16px;
    border: 1px solid #d7e3dc;
    border-radius: 14px;
    background: #f8fbf9;
    cursor: pointer;
}

/* sortable list in project settings adds a drag-handle column */
#module-sort-list .module-toggle-card {
    grid-template-columns: auto auto auto 1fr auto;
}

/* compact variant used in template admin form (no status pill) */
.module-toggle-card--compact {
    grid-template-columns: auto auto 1fr;
    padding: 10px 14px;
}

/* child module (extension of another module) */
.module-toggle-card--child {
    margin-left: 24px;
    border-style: dashed;
    background: #f8fbf9;
}

.module-drag-handle {
    cursor: grab;
    color: #8aab9a;
    font-size: 1.1rem;
    line-height: 1;
    padding: 0 2px;
    user-select: none;
    transition: color 0.15s;
}

.module-toggle-card:hover .module-drag-handle {
    color: #2fbf71;
}

.module-toggle-card.dragging {
    opacity: 0.45;
    border-style: dashed;
}

.module-toggle-icon {
    font-size: 20px;
    line-height: 1;
    color: var(--green-mid);
    width: 28px;
    text-align: center;
}

.module-toggle-card:hover {
    border-color: #2fbf71;
    background: #f3fbf6;
}

.module-toggle-card input[type="checkbox"] {
    width: 18px;
    height: 18px;
}

.module-toggle-content {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.module-toggle-status {
    font-weight: 700;
    color: #0f3d28;
    background: #d8f5e1;
    padding: 5px 10px;
    border-radius: 999px;
}

.members-table .task-row {
    grid-template-columns: 1fr 140px 140px;
}

.members-table .task-row.has-actions {
    grid-template-columns: 1fr 140px 120px;
}

.member-role-badge {
    display: inline-block;
    font-size: 12px;
    font-weight: 600;
    padding: 3px 10px;
    border-radius: 999px;
}

.member-role-badge.member-role-owner   { background: #102018; color: #fff; }
.member-role-badge.member-role-admin   { background: #173526; color: #fff; }
.member-role-badge.member-role-manager { background: #24563d; color: #fff; }
.member-role-badge.member-role-member  { background: #d8f5e1; color: #102018; }
.member-role-badge.member-role-viewer  { background: #f0f0f0; color: #555; }

.logo-icon {
    width: 32px;
    height: 32px;
    object-fit: contain;
    display: block;
    flex-shrink: 0;
}

/* -------------------------------------------------------------------------
   User avatars
   ---------------------------------------------------------------------- */

.user-avatar {
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
    display: inline-block;
    vertical-align: middle;
}

.user-avatar--initials {
    background: #2fbf71;
    color: #fff;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    vertical-align: middle;
    line-height: 1;
    border-radius: 50%;
}

.user-avatar-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Avatar upload section in user settings */
.avatar-upload-section {
    display: flex;
    align-items: flex-start;
    gap: 24px;
    flex-wrap: wrap;
}

.avatar-current .user-avatar,
.avatar-current .user-avatar--initials {
    width: 88px !important;
    height: 88px !important;
    font-size: 2.2rem !important;
}

.avatar-upload-hint {
    font-size: 0.82rem;
    color: var(--text-muted, #6b8a77);
    margin: 6px 0 0;
}

/* -------------------------------------------------------------------------
   Project cards (projects.php)
   ---------------------------------------------------------------------- */

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

.project-card {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 16px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transition: box-shadow 0.15s, border-color 0.15s;
}

.project-card:hover {
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    border-color: var(--green-bright);
}

.project-card-hero {
    background: var(--green-dark);
    padding: 20px 20px 18px;
}

.project-card-initial {
    width: 38px;
    height: 38px;
    background: var(--green-bright);
    color: var(--green-darkest);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 17px;
    margin-bottom: 12px;
}

.project-card-name {
    font-size: 15px;
    font-weight: 700;
    color: #fff;
    margin: 0;
    line-height: 1.3;
}

.project-card-body {
    padding: 16px 20px 12px;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.project-card-description {
    font-size: 13px;
    color: var(--muted);
    margin: 0;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    min-height: 34px;
    line-height: 1.5;
}

.project-card-no-description {
    font-style: italic;
}

.project-owner-badge {
    display: inline-block;
    font-size: 11px;
    font-weight: 600;
    padding: 2px 9px;
    border-radius: 999px;
    background: var(--green-pale);
    color: var(--green-darkest);
    align-self: flex-start;
}

.project-card-footer {
    padding: 12px 20px;
    border-top: 1px solid var(--line);
    display: flex;
    align-items: center;
    gap: 8px;
}

.projects-empty {
    text-align: center;
    padding: 80px 20px;
    color: var(--muted);
}

.projects-empty-icon {
    font-size: 48px;
    margin: 0 0 16px;
    opacity: 0.3;
}

.projects-empty h2 {
    margin: 0 0 8px;
    color: var(--text);
}

/* -------------------------------------------------------------------------
   Admin dashboard
   ---------------------------------------------------------------------- */

.admin-stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 16px;
}

.admin-stat-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 28px 16px;
    background: #fff;
    border: 1px solid #d7e3dc;
    border-radius: 16px;
    text-decoration: none;
    color: var(--text);
    transition: border-color 0.15s, box-shadow 0.15s;
}

.admin-stat-card:hover {
    border-color: #2fbf71;
    box-shadow: 0 2px 8px rgba(47, 191, 113, 0.12);
}

.admin-stat-icon {
    font-size: 1.6rem;
    line-height: 1;
}

.admin-stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: #0f3d28;
    line-height: 1;
}

.admin-stat-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Plan badges */
.plan-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.plan-badge--free       { background: #e8f5e9; color: #2e7d32; }
.plan-badge--pro        { background: #e3f2fd; color: #1565c0; }
.plan-badge--enterprise { background: #f3e5f5; color: #6a1b9a; }

/* System / built-in badge */
.system-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 600;
    background: #f0f0f0;
    color: #666;
    margin-left: 6px;
    vertical-align: middle;
}

/* Required star */
.required-star { color: #c0392b; }

/* Template admin list table */
.template-admin-list {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.template-admin-row {
    display: grid;
    grid-template-columns: 48px 1fr 90px 180px 160px;
    align-items: center;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid #eef3f0;
}

.template-admin-row:last-child { border-bottom: none; }

.template-admin-row--header {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding-bottom: 8px;
}

.template-admin-icon-cell {
    font-size: 1.6rem;
    line-height: 1;
    text-align: center;
}

/* Template admin form layout */
.template-form-card { margin-bottom: 24px; }

.template-admin-form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    margin-bottom: 20px;
}

@media (max-width: 860px) {
    .template-admin-form-grid { grid-template-columns: 1fr; }
    .template-admin-row { grid-template-columns: 40px 1fr 80px 1fr; }
    .template-admin-row > :nth-child(4) { display: none; }
}

.template-admin-col {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.template-admin-form label {
    display: flex;
    flex-direction: column;
    gap: 5px;
    font-weight: 500;
    font-size: 0.9rem;
}

.template-admin-form input[type="text"],
.template-admin-form textarea,
.template-admin-form select {
    font-size: 0.95rem;
    padding: 8px 10px;
    border: 1px solid #c8d8cf;
    border-radius: 8px;
    background: #fff;
    width: 100%;
    box-sizing: border-box;
}

.template-admin-form textarea { resize: vertical; }

.template-icon-field {
    display: flex;
    align-items: center;
    gap: 14px;
}

.template-icon-field input[type="text"] {
    width: 70px;
    font-size: 1.5rem;
    text-align: center;
    padding: 6px;
}

.template-icon-preview {
    font-size: 2.4rem;
    line-height: 1;
    min-width: 2.4rem;
}

.template-modules-label {
    font-weight: 600;
    font-size: 0.88rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin: 0 0 8px;
}

.template-admin-actions {
    display: flex;
    gap: 10px;
    padding-top: 4px;
}

/* -------------------------------------------------------------------------
   Notes module
   ---------------------------------------------------------------------- */

/* Empty state */
.notes-empty {
    text-align: center;
    padding: 64px 24px;
}
.notes-empty-icon {
    font-size: 3rem;
    margin: 0 0 16px;
    color: #2fbf71;
}
.notes-empty h2 { margin: 0 0 8px; }

/* Card grid */
.notes-card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 16px;
}

.note-card {
    display: flex;
    flex-direction: column;
    gap: 0;
    background: #fff;
    border: 1px solid #d7e3dc;
    border-radius: 14px;
    padding: 20px;
    text-decoration: none;
    color: var(--text);
    transition: border-color 0.15s, box-shadow 0.15s;
    cursor: pointer;
}

.note-card:hover {
    border-color: #2fbf71;
    box-shadow: 0 2px 10px rgba(47, 191, 113, 0.12);
}

.note-card-icon {
    font-size: 1.4rem;
    color: #2fbf71;
    margin-bottom: 10px;
    line-height: 1;
}

.note-card-body { flex: 1; }

.note-card-title {
    font-size: 1rem;
    font-weight: 700;
    margin: 0 0 6px;
    color: #0f3d28;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.note-card-desc {
    font-size: 0.85rem;
    color: var(--text-muted, #6b8a77);
    margin: 0 0 12px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.note-card-footer {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid #eef3f0;
}

/* Table view */
.notes-table .task-row {
    grid-template-columns: 40px 1fr 1fr 160px 140px;
}

.task-row--link {
    text-decoration: none;
    color: inherit;
    cursor: pointer;
    transition: background 0.1s;
}

.task-row--link:hover {
    background: #f2faf5;
}

/* Note card tags */
.note-card-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 6px;
}

.note-table-icon {
    font-size: 1.1rem;
    color: #2fbf71;
}


/* Note editor page */
.note-editor-page {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.content-header-back {
    font-size: 0.85rem;
    color: var(--text-muted, #6b8a77);
    text-decoration: none;
    margin-right: 8px;
}

.content-header-back:hover { text-decoration: underline; }

.save-status {
    font-size: 0.85rem;
    color: #2fbf71;
    font-weight: 600;
    align-self: center;
}

/* Note meta fields (title + description inputs above editor) */
.note-meta-fields {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 16px 20px;
}

.note-title-label,
.note-desc-label {
    display: block;
}

.note-title-input {
    width: 100%;
    border: none;
    outline: none;
    font-size: 1.5rem;
    font-weight: 700;
    color: #0f3d28;
    background: transparent;
    padding: 0;
    box-sizing: border-box;
}

.note-title-input::placeholder { color: #b0c8bc; }

.note-desc-input {
    width: 100%;
    border: none;
    outline: none;
    font-size: 0.95rem;
    color: #5a7a68;
    background: transparent;
    padding: 0;
    box-sizing: border-box;
}

.note-desc-input::placeholder { color: #b0c8bc; }

.note-tags-label {
    display: flex;
    align-items: center;
    gap: 10px;
}

.note-tags-field-label {
    font-size: 0.82rem;
    font-weight: 600;
    color: #6b8a77;
    white-space: nowrap;
}

.note-tags-input {
    flex: 1;
    border: none;
    outline: none;
    font-size: 0.9rem;
    color: #2d4a38;
    background: transparent;
    padding: 0;
}

.note-tags-input::placeholder { color: #b0c8bc; }

/* Rich text editor */
.rich-editor {
    display: flex;
    flex-direction: column;
    padding: 0;
    overflow: hidden;
}

.rich-editor-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 2px;
    padding: 8px 10px;
    border-bottom: 1px solid #d7e3dc;
    background: #f8fbf9;
}

.rich-editor-btn {
    padding: 5px 10px;
    border: 1px solid transparent;
    border-radius: 6px;
    background: transparent;
    cursor: pointer;
    font-size: 0.83rem;
    font-weight: 600;
    color: #2d4a38;
    line-height: 1.2;
    white-space: nowrap;
    transition: background 0.12s, border-color 0.12s;
}

.rich-editor-btn:hover {
    background: #e8f5e9;
    border-color: #c0dac8;
}

.rich-editor-btn.active {
    background: #d8f5e1;
    border-color: #2fbf71;
    color: #0f3d28;
}

.rich-editor-sep {
    width: 1px;
    background: #d7e3dc;
    align-self: stretch;
    margin: 2px 4px;
    flex-shrink: 0;
}

.rich-editor-content {
    min-height: 460px;
    padding: 24px 28px;
    outline: none;
    line-height: 1.75;
    font-size: 1rem;
    color: #1a2e23;
    box-sizing: border-box;
}

.rich-editor-content:empty::before {
    content: 'Start writing…';
    color: #b0c8bc;
    pointer-events: none;
}

/* Typography inside the editor and when rendering note content */
.rich-editor-content h2,
.note-content h2 { font-size: 1.4rem; font-weight: 700; margin: 1.2em 0 0.4em; color: #0f3d28; }

.rich-editor-content h3,
.note-content h3 { font-size: 1.1rem; font-weight: 700; margin: 1em 0 0.35em; color: #1a3a26; }

.rich-editor-content p,
.note-content p { margin: 0 0 0.75em; }

.rich-editor-content ul,
.rich-editor-content ol,
.note-content ul,
.note-content ol { padding-left: 1.6em; margin: 0 0 0.75em; }

.rich-editor-content li,
.note-content li { margin-bottom: 0.25em; }

.rich-editor-content blockquote,
.note-content blockquote {
    border-left: 3px solid #2fbf71;
    margin: 0 0 0.75em;
    padding: 6px 0 6px 16px;
    color: #4a6a56;
    font-style: italic;
}

.rich-editor-content hr,
.note-content hr { border: none; border-top: 1px solid #d7e3dc; margin: 1.25em 0; }

.rich-editor-content a,
.note-content a { color: #1a7a45; text-decoration: underline; }

.rich-editor-content mark,
.note-content mark { background: #fff9c4; padding: 1px 3px; border-radius: 3px; }

/* -------------------------------------------------------------------------
   Template picker (new-project.php)
   ---------------------------------------------------------------------- */

.new-project-page {
    max-width: 860px;
}

.template-gallery-label {
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--muted);
    margin: 0 0 14px;
}

.template-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 12px;
    margin-bottom: 8px;
}

.template-card {
    border: 2px solid var(--line);
    border-radius: 14px;
    padding: 28px 16px 22px;
    cursor: pointer;
    text-align: center;
    background: var(--panel);
    transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
    user-select: none;
    outline: none;
}

.template-card:hover,
.template-card:focus-visible {
    border-color: var(--green-bright);
    background: #f3fbf6;
}

.template-card.selected {
    border-color: var(--green-bright);
    background: #edfaf3;
    box-shadow: 0 0 0 3px rgba(50, 196, 108, 0.18);
}

.template-card-featured {
    grid-column: span 1;
}

.template-card-icon {
    font-size: 34px;
    display: block;
    margin-bottom: 12px;
}

.template-card-name {
    font-weight: 700;
    font-size: 13px;
    margin: 0 0 4px;
    color: var(--text);
}

.template-card-tagline {
    font-size: 11px;
    color: var(--muted);
    margin: 0;
}

.template-config-panel {
    display: none;
    border: 2px solid var(--green-bright);
    border-radius: 16px;
    padding: 28px;
    background: var(--panel);
    margin-top: 16px;
}

.template-config-panel.visible {
    display: block;
}

.template-config-header {
    display: flex;
    align-items: flex-start;
    gap: 16px;
    margin-bottom: 24px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--line);
}

.template-config-icon {
    font-size: 36px;
    line-height: 1;
    flex-shrink: 0;
}

.template-config-title {
    margin: 0 0 4px;
    font-size: 18px;
}

.template-config-form {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.template-config-fields {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.template-config-fields label {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-weight: 600;
    font-size: 14px;
}

.template-config-fields input,
.template-config-fields textarea {
    padding: 9px 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    width: 100%;
    box-sizing: border-box;
}

.template-config-fields input:focus,
.template-config-fields textarea:focus {
    outline: none;
    border-color: var(--green-bright);
    box-shadow: 0 0 0 3px rgba(50, 196, 108, 0.18);
}

.template-config-modules {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.template-modules-label {
    font-weight: 700;
    font-size: 14px;
    margin: 0;
}

.template-config-actions {
    display: flex;
    gap: 10px;
    align-items: center;
    padding-top: 4px;
}

.logo-mark {
    display: flex;
    align-items: center;
    gap: 12px;
}
/* Topbar account and notification controls */
.notification-toplink {
    align-items: center;
    border-radius: 999px;
    display: inline-flex;
    height: 36px;
    justify-content: center;
    padding: 4px;
    position: relative;
    text-decoration: none;
    width: 36px;
}

.notification-toplink:hover {
    background: #f3f4f6;
}

.notification-icon {
    display: block;
    height: 28px;
    width: 28px;
}

.notification-toplink .notification-badge {
    position: absolute;
    right: -5px;
    top: -5px;
}

.account-menu {
    position: relative;
}

.account-menu summary {
    align-items: center;
    border-radius: 999px;
    color: var(--text);
    cursor: pointer;
    display: inline-flex;
    gap: 6px;
    list-style: none;
    padding: 8px 12px;
    user-select: none;
}

.account-menu summary::-webkit-details-marker {
    display: none;
}

.account-menu summary:hover,
.account-menu[open] summary {
    background: #f3f4f6;
}

.account-name {
    font-weight: 700;
}

.account-caret {
    color: var(--muted);
    font-size: 11px;
    line-height: 1;
}

.account-dropdown {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 14px;
    box-shadow: 0 18px 40px rgba(15, 23, 42, 0.14);
    min-width: 220px;
    overflow: hidden;
    padding: 8px;
    position: absolute;
    right: 0;
    top: calc(100% + 8px);
    z-index: 50;
}

.account-dropdown-header {
    border-bottom: 1px solid var(--line);
    margin-bottom: 6px;
    padding: 10px 10px 12px;
}

.account-dropdown-header strong,
.account-dropdown-header span {
    display: block;
}

.account-dropdown-header span {
    color: var(--muted);
    font-size: 12px;
    margin-top: 2px;
}

.account-dropdown a {
    border-radius: 10px;
    color: var(--text);
    display: block;
    padding: 9px 10px;
    text-decoration: none;
}

.account-dropdown a:hover {
    background: #f3f4f6;
}

/* ── Dark mode toggle button ──────────────────────────────────────────────── */

.dark-mode-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    background: none;
    border: none;
    border-radius: 10px;
    color: var(--text);
    cursor: pointer;
    font-size: 14px;
    padding: 8px 10px;
    text-align: left;
    font-family: inherit;
}

.dark-mode-toggle:hover {
    background: #f3f4f6;
}

/* ── Dark mode theme ──────────────────────────────────────────────────────── */

[data-theme="dark"] {
    --bg:    #141a16;
    --panel: #1d2620;
    --line:  #2d3d31;
    --text:  #cee0d5;
    --muted: #6e8f76;
    --accent: #2fbf71;
    --accent-dark: #86efac;
    color-scheme: dark;
}

/* ── Page shell ── */
[data-theme="dark"] body                          { background: var(--bg); color: var(--text); }
[data-theme="dark"] .topbar                       { background: var(--panel); border-color: var(--line); }
[data-theme="dark"] .project-switcher select      { color: var(--text); }
[data-theme="dark"] .content-header               { background: #1a2319; border-color: var(--line); }
[data-theme="dark"] .content-header h1            { color: var(--text); }
[data-theme="dark"] .muted-text                   { color: var(--muted); }
[data-theme="dark"] .eyebrow                      { color: var(--green-bright); }

/* ── Cards ── */
[data-theme="dark"] .card                         { background: var(--panel); border-color: var(--line); }
[data-theme="dark"] .danger-zone                  { background: #2a1a1a; border-color: #5a2a2a; }

/* ── Buttons ── */
[data-theme="dark"] .btn.secondary                { background: #273a2d; color: var(--text); }
[data-theme="dark"] .btn.secondary:hover          { background: #2e4434; }

/* ── Inputs & forms ── */
[data-theme="dark"] input,
[data-theme="dark"] select,
[data-theme="dark"] textarea                      { background: #18201a; color: var(--text); border-color: var(--line); }
[data-theme="dark"] input::placeholder,
[data-theme="dark"] textarea::placeholder         { color: var(--muted); }
[data-theme="dark"] .auth-input:focus             { background: #1e2821; }

/* ── Task table ── */
[data-theme="dark"] .task-table                   { background: var(--panel); border-color: var(--line); }
[data-theme="dark"] .task-row                     { border-color: var(--line); }
[data-theme="dark"] .task-row:nth-child(even)     { background: #192119; }
[data-theme="dark"] .task-row.header              { background: #1a2319; color: var(--muted); }
[data-theme="dark"] .task-title a                 { color: var(--text); }

/* ── Status / priority / due-date pills ── */
[data-theme="dark"] .status-pill                  { background: #1e2821; color: var(--text); border-color: var(--line); }
[data-theme="dark"] .due-date-pill                { background: #1e2821; color: var(--text); border-color: var(--line); }
[data-theme="dark"] .due-date-pill.due-overdue    { background: #3b1a1a; color: #f87171; border-color: #5a2a2a; }
[data-theme="dark"] .priority-pill                { background: #1e2821; color: var(--text); border-color: var(--line); }
[data-theme="dark"] .priority-low                 { background: #1a2f1e; color: #86efac; border-color: #2d5237; }
[data-theme="dark"] .priority-medium              { background: #2d2a10; color: #fde047; border-color: #4a4210; }
[data-theme="dark"] .priority-high                { background: #2d1f10; color: #fdba74; border-color: #4a3010; }
[data-theme="dark"] .priority-critical            { background: #3b1a1a; color: #f87171; border-color: #5a2a2a; }
[data-theme="dark"] .status-todo                  { background: #222822; color: var(--text); }
[data-theme="dark"] .status-in_progress           { background: #172438; color: #93c5fd; }
[data-theme="dark"] .status-review                { background: #2d2710; color: #fde047; }
[data-theme="dark"] .status-done                  { background: #1a2f1e; color: #86efac; }

/* ── Dashboard ── */
[data-theme="dark"] .dashboard-hero               { background: var(--panel); border-color: var(--line); }
[data-theme="dark"] .dashboard-widget             { background: var(--panel); border-color: var(--line); }
[data-theme="dark"] .widget-edit-bar              { background: #1a2319; border-color: var(--line); }
[data-theme="dark"] .widget-size-btn              { background: #1a2319; }
[data-theme="dark"] .dashboard-stat-card          { background: #1a2319; }
[data-theme="dark"] .dashboard-stat-card          { background: #192119; border-color: var(--line); }
[data-theme="dark"] .dashboard-stat-card span,
[data-theme="dark"] .dashboard-stat-card small    { color: var(--muted); }
[data-theme="dark"] .dashboard-stat-card strong   { color: var(--text); }
[data-theme="dark"] .status-summary-pill          { background: #192119; border-color: var(--line); color: var(--text); }
[data-theme="dark"] .dashboard-task-row           { background: #192119; border-color: var(--line); color: var(--text); }
[data-theme="dark"] .dashboard-task-row:hover     { background: #1e2821; border-color: var(--green-bright); }
[data-theme="dark"] .task-row-meta                { color: var(--muted); }
[data-theme="dark"] .type-badge                   { background: #0c2a3a; color: #7dd3fc; }
[data-theme="dark"] .empty-widget                 { color: var(--muted); }
[data-theme="dark"] .widget-key                   { color: var(--muted); }

/* ── Activity log ── */
[data-theme="dark"] .activity-item                { background: #192119; border-color: var(--line); }
[data-theme="dark"] .activity-message             { color: var(--text); }
[data-theme="dark"] .activity-message a           { color: var(--text); }
[data-theme="dark"] .activity-meta                { color: var(--muted); }

/* ── Comments ── */
[data-theme="dark"] .comment-card                 { background: #192119; border-color: var(--line); }
[data-theme="dark"] .comment-body                 { color: var(--text); }
[data-theme="dark"] .comment-meta                 { color: var(--muted); }

/* ── Kanban ── */
[data-theme="dark"] .kanban-board                 { background: var(--bg); }
[data-theme="dark"] .kanban-column                { background: #1a2319; border-color: var(--line); }
[data-theme="dark"] .kanban-column-header         { color: var(--muted); }
[data-theme="dark"] .kanban-card                  { background: var(--panel); border-color: var(--line); color: var(--text); }
[data-theme="dark"] .kanban-card-title            { color: var(--text); }

/* ── Lists module ── */
[data-theme="dark"] .list-item-row                { background: #192119; border-color: var(--line); }
[data-theme="dark"] .list-table-header            { background: #1a2319; border-color: var(--line); color: var(--muted); }
[data-theme="dark"] .list-table-row               { border-color: var(--line); }
[data-theme="dark"] .list-table-row:nth-child(even) { background: #192119; }
[data-theme="dark"] .list-refresh-chip            { color: var(--muted); }
[data-theme="dark"] .list-item-completed-by       { color: var(--muted); }
[data-theme="dark"] .list-group-header            { border-color: var(--line); }
[data-theme="dark"] .list-card                    { background: var(--panel); border-color: var(--line); color: var(--text); }
[data-theme="dark"] .list-card:hover              { border-color: var(--green-bright); box-shadow: 0 2px 10px rgba(47,191,113,0.18); }
[data-theme="dark"] .list-card-title              { color: var(--text); }
[data-theme="dark"] .list-card-meta               { color: var(--muted); }
[data-theme="dark"] .list-card-footer             { border-color: var(--line); }
[data-theme="dark"] .list-item-xp                 { background: #14532d; color: #86efac; }

/* ── Orders module ── */
[data-theme="dark"] .order-table-row              { border-color: var(--line); }
[data-theme="dark"] .order-table-row:nth-child(even) { background: #192119; }
[data-theme="dark"] .order-table-header           { background: #1a2319; border-color: var(--line); color: var(--muted); }
[data-theme="dark"] .order-items-table th         { background: #1a2319; border-color: var(--line); color: var(--muted); }
[data-theme="dark"] .order-items-table td         { border-color: var(--line); }
[data-theme="dark"] .order-history-item           { border-color: var(--line); }
[data-theme="dark"] .order-totals-row             { border-color: var(--line); }
[data-theme="dark"] .order-totals-row.total-row   { border-color: var(--line); }

/* ── Milestones ── */
[data-theme="dark"] .milestone-row                { background: #192119; border-color: var(--line); }
[data-theme="dark"] .milestone-card               { background: var(--panel); border-color: var(--line); }

/* ── Notes table ── */
[data-theme="dark"] .notes-table .task-row.header { background: #1a2319; }

/* ── Filter chips & saved views ── */
[data-theme="dark"] .filter-chip                  { background: #192119; border-color: var(--line); color: var(--text); }
[data-theme="dark"] .filter-chip.active           { background: #1a3025; border-color: var(--green-bright); color: var(--green-bright); }
[data-theme="dark"] .saved-view-chip.active       { background: #1a3025; border-color: var(--green-bright); color: var(--green-bright); }
[data-theme="dark"] .saved-views-panel            { background: var(--panel); border-color: var(--line); }
[data-theme="dark"] .saved-view-item              { background: var(--panel); border-color: var(--line); }
[data-theme="dark"] .saved-view-item.active       { background: #182838; border-color: #3a7abf; }
[data-theme="dark"] .saved-view-item a span       { color: var(--muted); }
[data-theme="dark"] .saved-view-active            { background: #182838; border-color: #3a7abf; }
[data-theme="dark"] .saved-view-form              { border-color: var(--line); }
[data-theme="dark"] .view-scope-pill              { background: #252e27; color: var(--muted); }
[data-theme="dark"] .filter-form input,
[data-theme="dark"] .filter-form select           { background: #18201a; color: var(--text); border-color: var(--line); }
[data-theme="dark"] .btn-link                     { color: #60a5fa; }
[data-theme="dark"] .btn-link.danger              { color: #f87171; }

/* ── Account dropdown ── */
[data-theme="dark"] .account-menu summary:hover,
[data-theme="dark"] .account-menu[open] summary   { background: #252e27; }
[data-theme="dark"] .account-dropdown             { background: var(--panel); border-color: var(--line); box-shadow: 0 8px 30px rgba(0,0,0,0.5); }
[data-theme="dark"] .account-dropdown a           { color: var(--text); }
[data-theme="dark"] .account-dropdown a:hover     { background: #252e27; }
[data-theme="dark"] .dark-mode-toggle:hover       { background: #252e27; }
[data-theme="dark"] .account-dropdown-header      { border-color: var(--line); }

/* ── Settings ── */
[data-theme="dark"] .settings-tab                 { color: var(--muted); }
[data-theme="dark"] .settings-tab:hover,
[data-theme="dark"] .settings-tab.active          { background: #1a3025; color: var(--text); }
[data-theme="dark"] .tag-settings-row             { border-color: var(--line); }
[data-theme="dark"] .tag-settings-row.header      { background: #1a2319; color: var(--muted); }
[data-theme="dark"] .module-toggle-card           { background: #192119; border-color: var(--line); }
[data-theme="dark"] .module-toggle-card:hover     { background: #1e2821; border-color: var(--green-bright); }
[data-theme="dark"] .module-toggle-status         { background: #1a3025; color: var(--green-bright); }

/* ── Tabs ── */
[data-theme="dark"] .tab-bar                      { background: #192119; border-color: var(--line); }
[data-theme="dark"] .tab-item                     { color: var(--muted); }
[data-theme="dark"] .tab-item.active              { color: var(--text); border-color: var(--green-bright); }

/* ── Generic tables ── */
[data-theme="dark"] table                         { color: var(--text); }
[data-theme="dark"] th                            { background: #1a2319; color: var(--muted); }
[data-theme="dark"] td                            { border-color: var(--line); }
[data-theme="dark"] tr:nth-child(even) td         { background: #192119; }

/* ── Inline edit ── */
[data-theme="dark"] .inline-edit-form input,
[data-theme="dark"] .inline-edit-form select,
[data-theme="dark"] .inline-edit-form textarea    { background: #18201a; color: var(--text); border-color: var(--line); }
/* ── Popover / modal ── */
[data-theme="dark"] .popover-card                 { background: var(--panel); border-color: var(--line); box-shadow: 0 18px 45px rgba(0,0,0,0.5); }
[data-theme="dark"] .modal-backdrop               { background: rgba(0,0,0,0.7); }
[data-theme="dark"] .modal                        { background: var(--panel); border-color: var(--line); color: var(--text); }

/* ── Auth pages ── */
[data-theme="dark"] .auth-card                    { background: #1d2620; }
[data-theme="dark"] .auth-heading                 { color: var(--text); }
[data-theme="dark"] .auth-input                   { background: #18201a; color: var(--text); border-color: var(--line); }

/* ── Custom Fields ── */

/* Settings: field definition list */
.cf-def-list {
    border: 1px solid var(--line);
    border-radius: 6px;
    overflow: hidden;
    margin-bottom: 20px;
}
.cf-def-row {
    display: grid;
    grid-template-columns: 1.5fr 80px 120px 100px 80px 60px 90px auto;
    gap: 10px;
    align-items: center;
    padding: 10px 14px;
    border-bottom: 1px solid var(--line);
    font-size: 13px;
}
.cf-def-row:last-child { border-bottom: none; }
.cf-def-row--header {
    background: var(--panel);
    font-weight: 600;
    font-size: 12px;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.cf-def-row--inactive { opacity: 0.55; }
.cf-def-name { font-weight: 500; }
.cf-module-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
    color: #fff;
    letter-spacing: 0.02em;
}

/* ── Related Items ───────────────────────────────────────────────────────── */
.related-items-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
}
.related-items-header h3 { margin: 0; }
.related-items-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 14px;
}
.related-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 10px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: var(--panel);
}
.related-item-link {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    min-width: 0;
    text-decoration: none;
    color: var(--text);
}
.related-item-link:hover .related-item-title { text-decoration: underline; }
.related-item-type-badge {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 2px 7px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
    white-space: nowrap;
    color: #fff;
    flex-shrink: 0;
}
.related-item-title {
    font-size: 13px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.related-item-remove {
    background: none;
    border: none;
    color: var(--muted);
    cursor: pointer;
    font-size: 16px;
    line-height: 1;
    padding: 2px 4px;
    border-radius: 4px;
    flex-shrink: 0;
}
.related-item-remove:hover { background: var(--hover); color: #e05252; }
.related-items-empty { margin: 0 0 12px; }

/* Entity type badge colours */
.entity-type-task            { background: #3498db; }
.entity-type-event           { background: #8e24aa; }
.entity-type-list            { background: #27ae60; }
.entity-type-note            { background: #e67e22; }
.entity-type-product         { background: #c0392b; }
.entity-type-member          { background: #16a085; }
.entity-type-membership_plan { background: #d35400; }

/* Search input + dropdown */
.related-items-add { position: relative; }
.entity-search-wrap { position: relative; }
.entity-search-input {
    width: 100%;
    box-sizing: border-box;
    padding: 7px 10px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: var(--bg);
    color: var(--text);
    font-size: 13px;
}
.entity-search-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 2px rgba(52,152,219,.18); }
.entity-search-dropdown {
    position: fixed;
    background: var(--bg);
    border: 1px solid var(--line);
    border-radius: 6px;
    box-shadow: 0 4px 14px rgba(0,0,0,.12);
    z-index: 9999;
    overflow: hidden;
}
.entity-search-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    cursor: pointer;
    font-size: 13px;
}
.entity-search-item:hover { background: var(--hover); }
.entity-search-badge {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 2px 7px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
    color: #fff;
    white-space: nowrap;
    flex-shrink: 0;
}
.entity-search-title {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.entity-search-none {
    padding: 10px 12px;
    font-size: 13px;
    color: var(--muted);
}

/* Dark mode overrides */
[data-theme="dark"] .related-item           { background: var(--panel); border-color: var(--line); }
[data-theme="dark"] .entity-search-dropdown { background: #1e2b1c; box-shadow: 0 4px 16px rgba(0,0,0,.4); }
[data-theme="dark"] .entity-search-item:hover { background: #283826; }

/* ── List view: CF preview under task title ─────────────────────────────── */
.task-cf-preview {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 4px;
}
.task-cf-item {
    font-size: 11px;
    color: var(--muted);
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 4px;
    padding: 1px 6px;
    white-space: nowrap;
}
.task-cf-label {
    font-weight: 600;
    margin-right: 2px;
}

/* Kanban: CF preview */
.kanban-cf-preview {
    margin-top: 8px;
    flex-wrap: wrap;
}

/* Task detail: CF form grid */
.cf-task-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 16px;
}
.cf-task-item { display: flex; flex-direction: column; gap: 5px; }
.cf-task-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.cf-task-form input[type="text"],
.cf-task-form input[type="number"],
.cf-task-form input[type="date"],
.cf-task-form input[type="email"],
.cf-task-form input[type="url"],
.cf-task-form select,
.cf-task-form textarea { width: 100%; box-sizing: border-box; }

/* Required asterisk */
.cf-required { color: #e05252; margin-left: 2px; }

/* Add Task modal: CF section */
.cf-modal-section {
    border-top: 1px solid var(--line);
    padding-top: 10px;
    margin-top: 4px;
}
.cf-modal-section summary {
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    color: var(--muted);
    padding: 4px 0;
}
.cf-modal-fields {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-top: 12px;
}
.cf-modal-fields label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; }
.cf-modal-label { font-weight: 600; font-size: 12px; color: var(--muted); }
.cf-modal-fields input,
.cf-modal-fields select,
.cf-modal-fields textarea { width: 100%; box-sizing: border-box; }

/* Dark mode */
[data-theme="dark"] .cf-def-list              { border-color: var(--line); }
[data-theme="dark"] .cf-def-row               { border-color: var(--line); }
[data-theme="dark"] .cf-def-row--header       { background: #1a2319; }
[data-theme="dark"] .task-cf-item             { background: #1a2319; border-color: var(--line); color: var(--muted); }
[data-theme="dark"] .cf-task-form input,
[data-theme="dark"] .cf-task-form select,
[data-theme="dark"] .cf-task-form textarea    { background: #18201a; color: var(--text); border-color: var(--line); }
[data-theme="dark"] .cf-modal-section         { border-color: var(--line); }
[data-theme="dark"] .cf-modal-fields input,
[data-theme="dark"] .cf-modal-fields select,
[data-theme="dark"] .cf-modal-fields textarea { background: #18201a; color: var(--text); border-color: var(--line); }

/* ── API Keys ── */
.api-key-reveal {
    background: #eafaf2;
    border: 1px solid #2fbf71;
    border-radius: 6px;
    padding: 14px 16px;
    margin-bottom: 20px;
}
.api-key-copy-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 8px;
}
.api-key-copy-row code {
    font-family: monospace;
    font-size: 13px;
    background: #fff;
    border: 1px solid var(--line);
    padding: 6px 10px;
    border-radius: 4px;
    flex: 1;
    overflow-x: auto;
    word-break: break-all;
}
.api-keys-list {
    border: 1px solid var(--line);
    border-radius: 6px;
    overflow: hidden;
    margin-bottom: 20px;
}
.api-key-row {
    display: grid;
    grid-template-columns: 1fr 160px 140px 140px 80px;
    gap: 12px;
    align-items: center;
    padding: 10px 14px;
    border-bottom: 1px solid var(--line);
    font-size: 13px;
}
.api-key-row:last-child { border-bottom: none; }
.api-key-row--header {
    background: var(--panel);
    font-weight: 600;
    font-size: 12px;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.api-key-row code {
    font-family: monospace;
    font-size: 12px;
    background: var(--panel);
    border: 1px solid var(--line);
    padding: 2px 6px;
    border-radius: 4px;
}
.api-key-generate-form { margin-top: 4px; }
.api-usage-ref { margin-top: 20px; }
.api-usage-ref summary { cursor: pointer; }
.api-usage-block { padding: 12px 0 0; }
.api-usage-block pre {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 12px 14px;
    font-size: 12px;
    overflow-x: auto;
    margin: 6px 0 0;
}
.api-usage-block pre code {
    background: none;
    border: none;
    padding: 0;
    font-size: 12px;
}

[data-theme="dark"] .api-key-reveal           { background: #0f3d28; border-color: var(--green-mid); }
[data-theme="dark"] .api-key-copy-row code    { background: #18201a; border-color: var(--line); color: var(--text); }
[data-theme="dark"] .api-keys-list            { border-color: var(--line); }
[data-theme="dark"] .api-key-row              { border-color: var(--line); }
[data-theme="dark"] .api-key-row--header      { background: #1a2319; }
[data-theme="dark"] .api-key-row code         { background: #1a2319; border-color: var(--line); }
[data-theme="dark"] .api-usage-block pre      { background: #1a2319; border-color: var(--line); }

/* ── Webhooks / Integrations ── */
.webhook-list-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}
.webhook-list-header h2 { margin: 0; }

.webhook-saved-msg {
    color: var(--green-mid);
    font-size: 13px;
    margin-bottom: 12px;
}

.webhook-list { border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }

.webhook-row {
    display: grid;
    grid-template-columns: 1fr 1fr 2fr 90px auto;
    gap: 12px;
    align-items: center;
    padding: 10px 14px;
    border-bottom: 1px solid var(--line);
    font-size: 13px;
}
.webhook-row:last-child { border-bottom: none; }

.webhook-row--header {
    background: var(--panel);
    font-weight: 600;
    font-size: 12px;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.webhook-name { font-weight: 500; }

.webhook-url {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-family: monospace;
    font-size: 12px;
}

.webhook-row-actions { display: flex; gap: 6px; align-items: center; }

.webhook-status-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.03em;
}
.webhook-status-enabled  { background: #d4f5e2; color: #1a7a44; }
.webhook-status-disabled { background: #e8eae8; color: #666; }

.webhook-test-result {
    padding: 10px 14px;
    font-size: 12px;
    border-top: 1px solid var(--line);
    background: #f9fdf9;
}
.webhook-test-result pre {
    margin: 6px 0 0;
    white-space: pre-wrap;
    word-break: break-all;
    font-size: 11px;
    color: var(--muted);
}
.webhook-test-ok   { border-left: 3px solid #2fbf71; }
.webhook-test-fail { border-left: 3px solid #e05252; }

/* Webhook form */
.webhook-form .form-row { margin-bottom: 18px; }
.webhook-form .form-row label {
    display: block;
    font-weight: 600;
    font-size: 13px;
    margin-bottom: 6px;
}
.webhook-form .form-row input[type="text"],
.webhook-form .form-row input[type="url"],
.webhook-form .form-row select,
.webhook-form .form-row textarea {
    width: 100%;
    box-sizing: border-box;
}
.webhook-payload-textarea {
    font-family: monospace;
    font-size: 13px;
    line-height: 1.5;
    min-height: 200px;
    resize: vertical;
}
.webhook-vars-ref { margin-top: 8px; }
.webhook-vars-ref summary { cursor: pointer; }
.webhook-vars-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 10px 0 4px;
}
.webhook-vars-grid code {
    background: var(--panel);
    border: 1px solid var(--line);
    padding: 2px 7px;
    border-radius: 4px;
    font-size: 12px;
    cursor: pointer;
    user-select: all;
}
.webhook-vars-grid code:hover { border-color: var(--green-mid); color: var(--green-mid); }

.form-row--checkbox label { display: flex; align-items: center; gap: 8px; font-weight: normal; }
.form-row--checkbox input[type="checkbox"] { width: auto; }

.form-actions { display: flex; gap: 10px; padding-top: 4px; }

/* Dark mode overrides for webhooks */
[data-theme="dark"] .webhook-row--header           { background: #1a2319; }
[data-theme="dark"] .webhook-row                   { border-color: var(--line); }
[data-theme="dark"] .webhook-list                  { border-color: var(--line); }
[data-theme="dark"] .webhook-status-enabled        { background: #0f3d28; color: var(--green-bright); }
[data-theme="dark"] .webhook-status-disabled       { background: #2a2e2a; color: var(--muted); }
[data-theme="dark"] .webhook-test-result           { background: #192119; }
[data-theme="dark"] .webhook-vars-grid code        { background: #1a2319; border-color: var(--line); }
[data-theme="dark"] .webhook-form .form-row input,
[data-theme="dark"] .webhook-form .form-row select,
[data-theme="dark"] .webhook-form .form-row textarea { background: #18201a; color: var(--text); border-color: var(--line); }

/* ── Task icon buttons (delete / duplicate) ── */
.task-icon-btn {
    background: none;
    border: none;
    padding: 2px;
    cursor: pointer;
    opacity: 0.55;
    line-height: 0;
    border-radius: 4px;
    display: inline-flex;
    align-items: center;
}
.task-icon-btn:hover { opacity: 1; background: var(--line); }

.kanban-card-actions {
    display: flex;
    justify-content: flex-end;
    gap: 2px;
    margin-top: 8px;
}

/* Show/hide icons based on theme */
[data-theme="dark"] .icon-light  { display: none; }
[data-theme="dark"] .icon-dark   { display: inline; }
.icon-dark                        { display: none; }
.icon-light                       { display: inline; }

/* Task detail page action buttons */
.task-detail-actions {
    display: flex;
    gap: 6px;
    align-items: center;
    flex-shrink: 0;
}

/* ── Task page — collapsible summary toggle ── */
[data-theme="dark"] .card-section-summary::after  { color: var(--muted); }
[data-theme="dark"] .add-subtask-popover[open]::before { background: rgba(5, 15, 5, 0.6); }

/* ── Task page — status boxes & subtask rows ── */
[data-theme="dark"] .status-item                  { background: #192119; border-color: var(--line); }
[data-theme="dark"] .subtask-item                 { background: #192119; border-color: var(--line); }
[data-theme="dark"] .subtask-item a               { color: var(--text); }
[data-theme="dark"] .editable-block:hover         { background: #252e27; border-color: var(--line); }

/* ── Rich text editor (notes) ── */
[data-theme="dark"] .rich-editor-toolbar          { background: #1a2319; border-color: var(--line); }
[data-theme="dark"] .rich-editor-btn              { color: var(--text); }
[data-theme="dark"] .rich-editor-btn:hover        { background: #252e27; border-color: var(--line); }
[data-theme="dark"] .rich-editor-btn.active       { background: #1a3025; border-color: var(--green-bright); color: var(--green-bright); }
[data-theme="dark"] .rich-editor-sep              { background: var(--line); }
[data-theme="dark"] .rich-editor-content          { color: var(--text); background: var(--panel); }

/* ── Admin dashboard boxes ── */
[data-theme="dark"] .admin-stat-card              { background: var(--panel); border-color: var(--line); color: var(--text); }
[data-theme="dark"] .admin-stat-value             { color: var(--green-bright); }
[data-theme="dark"] .admin-stat-card:hover        { border-color: var(--green-bright); box-shadow: 0 2px 8px rgba(47,191,113,0.18); }

/* ── Admin templates form ── */
[data-theme="dark"] .template-admin-form input[type="text"],
[data-theme="dark"] .template-admin-form textarea,
[data-theme="dark"] .template-admin-form select   { background: #18201a; border-color: var(--line); color: var(--text); }
[data-theme="dark"] .template-admin-row           { border-color: var(--line); }
[data-theme="dark"] .template-admin-row--header   { color: var(--muted); }

/* ── Notes cards & table ── */
[data-theme="dark"] .note-card                    { background: var(--panel); border-color: var(--line); color: var(--text); }
[data-theme="dark"] .note-card:hover              { border-color: var(--green-bright); box-shadow: 0 2px 10px rgba(47,191,113,0.18); }
[data-theme="dark"] .note-card-title              { color: var(--text); }
[data-theme="dark"] .note-card-desc               { color: var(--muted); }
[data-theme="dark"] .note-card-footer             { border-color: var(--line); }
[data-theme="dark"] .task-row--link:hover         { background: #192119; }
[data-theme="dark"] .view-toggle                  { background: var(--panel); border-color: var(--line); }
[data-theme="dark"] .view-toggle a                { color: var(--muted); }

/* ── Misc ── */
[data-theme="dark"] .tag-pill                     { opacity: 0.85; }
[data-theme="dark"] .card--complete               { border-color: #2fbf71; }
[data-theme="dark"] .notification-toplink         { color: var(--text); }
[data-theme="dark"] .member-role-badge.member-role-viewer { background: #252e27; color: var(--muted); }
[data-theme="dark"] .member-role-badge.member-role-member { background: #1a3025; color: var(--green-bright); }

/* ── Calendar module ── */
.cal-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
    flex-wrap: wrap;
    gap: 10px;
}

.cal-toolbar h1 { margin: 0; }

.cal-toolbar-right { display: flex; align-items: center; gap: 10px; }

.cal-source-filters {
    display: flex;
    gap: 6px;
}

/* CSS-based source filtering */
#lyverva-calendar.cal-filter-tasks    [data-source-type="project_event"],
#lyverva-calendar.cal-filter-tasks    [data-source-type="booking"],
#lyverva-calendar.cal-filter-events   [data-source-type="task"],
#lyverva-calendar.cal-filter-events   [data-source-type="milestone"],
#lyverva-calendar.cal-filter-events   [data-source-type="booking"],
#lyverva-calendar.cal-filter-bookings [data-source-type="task"],
#lyverva-calendar.cal-filter-bookings [data-source-type="milestone"],
#lyverva-calendar.cal-filter-bookings [data-source-type="project_event"],
#lyverva-calendar.cal-filter-bookings [data-source-type="event"] {
    display: none !important;
}

#lyverva-calendar {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 24px;
}

/* Calendar event popup */
.cal-event-popup {
    position: absolute;
    z-index: 9900;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: 0 6px 24px rgba(0,0,0,0.14);
    padding: 14px 16px;
    min-width: 220px;
    max-width: 300px;
}

.cal-popup-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 8px;
}

.cal-popup-badge {
    display: inline-block;
    padding: 2px 9px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
    color: #fff;
}

.cal-popup-close {
    background: none;
    border: none;
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    color: var(--muted);
    padding: 0 2px;
    flex-shrink: 0;
}

.cal-popup-close:hover { color: var(--text); }

.cal-popup-title {
    font-weight: 600;
    font-size: 14px;
    line-height: 1.35;
    color: var(--text);
    margin-bottom: 5px;
}

.cal-popup-meta {
    font-size: 12px;
    color: var(--muted);
    margin-bottom: 10px;
    line-height: 1.5;
}

.cal-popup-link {
    display: inline-block;
    font-size: 12px;
    font-weight: 500;
    color: var(--green-mid);
    text-decoration: none;
}

.cal-popup-link:hover { text-decoration: underline; }

[data-theme="dark"] .cal-event-popup { background: var(--panel); border-color: var(--line); box-shadow: 0 6px 24px rgba(0,0,0,0.4); }
[data-theme="dark"] .cal-popup-link  { color: var(--green-bright); }

.cal-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    margin-bottom: 16px;
    font-size: 12px;
    color: var(--muted);
}

.cal-legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
}

.cal-legend-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

/* FullCalendar overrides — light */
.fc .fc-toolbar-title               { font-size: 1rem; font-weight: 600; color: var(--text); }
.fc .fc-button                      { background: var(--green-mid); border-color: var(--green-mid); color: #fff; font-size: 12px; padding: 4px 10px; }
.fc .fc-button:hover                { background: var(--green-dark); border-color: var(--green-dark); }
.fc .fc-button-active,
.fc .fc-button-primary:not(:disabled):active { background: var(--green-dark); border-color: var(--green-dark); }
.fc .fc-button:focus                { box-shadow: 0 0 0 2px rgba(50,196,108,0.35); }
.fc .fc-today-button                { opacity: 0.7; }
.fc .fc-today-button:disabled       { opacity: 0.4; }
.fc-theme-standard td,
.fc-theme-standard th               { border-color: var(--line); }
.fc .fc-col-header-cell-cushion     { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px; text-decoration: none; }
.fc .fc-daygrid-day-number          { color: var(--text); font-size: 12px; text-decoration: none; }
.fc .fc-day-today                   { background: rgba(50,196,108,0.08) !important; }
.fc .fc-event                       { border-radius: 4px; font-size: 11px; padding: 1px 4px; border: none; cursor: pointer; }
.fc .fc-event-title                 { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fc .fc-list-event-title a          { color: inherit; text-decoration: none; }
.fc .fc-list-day-cushion            { background: var(--bg); }
.fc .fc-list-event:hover td         { background: rgba(50,196,108,0.06); }
.fc .fc-popover                     { background: var(--panel); border: 1px solid var(--line); border-radius: 6px; box-shadow: 0 4px 16px rgba(0,0,0,.1); }
.fc .fc-popover-header              { background: var(--bg); border-radius: 6px 6px 0 0; padding: 6px 10px; color: var(--text); }
.fc .fc-more-link                   { color: var(--green-mid); font-size: 11px; }

/* FullCalendar overrides — dark */
[data-theme="dark"] #lyverva-calendar           { background: var(--panel); border-color: var(--line); }
[data-theme="dark"] .fc .fc-toolbar-title       { color: var(--text); }
[data-theme="dark"] .fc .fc-button             { background: var(--green-mid); border-color: var(--green-mid); }
[data-theme="dark"] .fc-theme-standard td,
[data-theme="dark"] .fc-theme-standard th       { border-color: var(--line); }
[data-theme="dark"] .fc .fc-col-header-cell-cushion { color: var(--muted); }
[data-theme="dark"] .fc .fc-daygrid-day-number  { color: var(--text); }
[data-theme="dark"] .fc .fc-day-today           { background: rgba(50,196,108,0.12) !important; }
[data-theme="dark"] .fc .fc-list-day-cushion    { background: var(--bg); }
[data-theme="dark"] .fc .fc-list-event-dot      { border-color: var(--green-bright); }
[data-theme="dark"] .fc .fc-popover            { background: var(--panel); border-color: var(--line); }
[data-theme="dark"] .fc .fc-popover-header     { background: var(--bg); color: var(--text); }
[data-theme="dark"] .fc .fc-more-link          { color: var(--green-bright); }
[data-theme="dark"] .fc .fc-list-empty         { background: var(--panel); color: var(--muted); }
[data-theme="dark"] .cal-legend                { color: var(--muted); }

/* ── Timeline / Gantt module ── */
.timeline-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.timeline-header h1 { margin: 0; }

.timeline-controls {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.timeline-source-filters {
    display: flex;
    gap: 6px;
    border-right: 1px solid var(--line);
    padding-right: 12px;
}

.timeline-view-modes {
    display: flex;
    gap: 6px;
}

.btn-view-mode {
    padding: 5px 14px;
    border: 1px solid var(--line);
    background: var(--panel);
    color: var(--text);
    border-radius: 4px;
    font-size: 13px;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.btn-view-mode:hover      { border-color: var(--green-mid); color: var(--green-mid); }
.btn-view-mode--active    { background: var(--green-mid); border-color: var(--green-mid); color: #fff; }

.timeline-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    margin-bottom: 12px;
    font-size: 12px;
    color: var(--muted);
}

.tl-legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
}

.tl-legend-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.timeline-wrap {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 16px;
    overflow-x: auto;
    margin-bottom: 24px;
}

.timeline-empty {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 48px 32px;
    text-align: center;
    color: var(--muted);
    margin-bottom: 24px;
}

/* Frappe Gantt overrides — light (Frappe CSS loads after, so these use !important) */
.gantt .grid-background               { fill: none !important; }
.gantt .grid-header                   { stroke: var(--line) !important; }
.gantt .grid-row                      { fill: var(--panel) !important; }
.gantt .grid-row:nth-child(even)      { fill: var(--bg) !important; }
.gantt .row-line                      { stroke: var(--line) !important; }
.gantt .tick                          { stroke: var(--line) !important; stroke-width: 0.5 !important; }
.gantt .tick.thick                    { stroke-width: 1 !important; }
.gantt .today-highlight               { fill: rgba(50,196,108,0.12) !important; opacity: 1 !important; }
.gantt .upper-text                    { fill: var(--muted) !important; font-size: 12px; }
.gantt .lower-text                    { fill: var(--muted) !important; font-size: 12px; }

/* ── Table Booking module ───────────────────────────────────────────────── */

.tb-subnav {
    display: flex;
    gap: 4px;
    padding: 0 28px 16px;
    border-bottom: 1px solid var(--line);
    margin: 16px 0 20px;
}

.tb-subnav a {
    padding: 6px 14px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    color: var(--muted);
    text-decoration: none;
    transition: background 0.15s, color 0.15s;
}

.tb-subnav a:hover      { background: var(--line); color: var(--text); }
.tb-subnav a.active     { background: var(--green-mid); color: #fff; }

/* Tables list rows */
.tb-row {
    display: grid;
    grid-template-columns: 1fr 140px 90px 120px 100px;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    border-bottom: 1px solid var(--line);
    font-size: 13px;
    transition: background 0.12s;
}

.tb-row:last-child { border-bottom: none; }
.tb-row:not(.tb-row--header):hover { background: var(--bg); }

.tb-row--header {
    font-size: 11px;
    font-weight: 600;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    background: var(--bg);
    border-bottom: 1px solid var(--line);
}

.tb-name {
    font-weight: 600;
    color: var(--text);
}

/* Bookings list rows */
.bk-row {
    display: grid;
    grid-template-columns: 1fr 120px 70px 200px 110px 80px;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    border-bottom: 1px solid var(--line);
    font-size: 13px;
    transition: background 0.12s;
}

.bk-row:last-child { border-bottom: none; }
.bk-row:not(.bk-row--header):hover { background: var(--bg); }

.bk-row--header {
    font-size: 11px;
    font-weight: 600;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    background: var(--bg);
    border-bottom: 1px solid var(--line);
}

/* Table Map editor */
.tmap-layout {
    display: grid;
    grid-template-columns: 220px 1fr;
    gap: 16px;
    align-items: start;
}

.tmap-sidebar {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.tmap-wrapper {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    overflow: auto;
    padding: 8px;
}

.tmap-grid {
    position: relative;
    background-color: #f8faf9;
    background-image:
        linear-gradient(to right, #d9e2dc 1px, transparent 1px),
        linear-gradient(to bottom, #d9e2dc 1px, transparent 1px);
    background-size: 60px 60px;
    width: 1200px;
    height: 720px;
    flex-shrink: 0;
}

.tmap-item {
    position: absolute;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    border: 2px solid rgba(0,0,0,0.15);
    cursor: grab;
    user-select: none;
    overflow: hidden;
    background: #e2e8e4;
    color: #102018;
    font-size: 11px;
    text-align: center;
    box-sizing: border-box;
    transition: box-shadow 0.12s;
}

.tmap-item:hover     { box-shadow: 0 2px 8px rgba(0,0,0,0.18); }
.tmap-item--dragging { cursor: grabbing; box-shadow: 0 6px 20px rgba(0,0,0,0.25); z-index: 100; opacity: 0.9; }
.tmap-item--circle   { border-radius: 50%; }

.tmap-item-label {
    font-weight: 700;
    font-size: 12px;
    line-height: 1.2;
    max-width: 90%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tmap-item-cap {
    font-size: 10px;
    opacity: 0.7;
    margin-top: 2px;
}

.tmap-item-remove {
    position: absolute;
    top: 2px;
    right: 4px;
    background: none;
    border: none;
    font-size: 13px;
    line-height: 1;
    cursor: pointer;
    color: rgba(0,0,0,0.4);
    padding: 0;
    display: none;
}

.tmap-item:hover .tmap-item-remove { display: block; }

.tmap-status--available    { background: #dcfce7; border-color: #22c55e; color: #166534; }
.tmap-status--booked       { background: #fef9c3; border-color: #f59e0b; color: #854d0e; }
.tmap-status--occupied     { background: #fee2e2; border-color: #ef4444; color: #991b1b; }
.tmap-status--out_of_service { background: #f1f5f9; border-color: #94a3b8; color: #475569; }
.tmap-status--none         { background: #e2e8e4; border-color: #94a3b8; color: #102018; }

.tmap-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    font-size: 12px;
    color: var(--muted);
    margin-bottom: 8px;
}

.tmap-legend-item {
    display: flex;
    align-items: center;
    gap: 5px;
}

.tmap-legend-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.tmap-shape-picker {
    display: flex;
    gap: 8px;
    margin: 4px 0;
}

.tmap-shape-option {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    cursor: pointer;
    font-size: 11px;
    color: var(--muted);
}

.tmap-shape-option input[type=radio] { display: none; }

.tmap-shape-preview {
    width: 34px;
    height: 26px;
    border: 2px solid var(--line);
    border-radius: 4px;
    background: var(--bg);
    transition: border-color 0.12s, background 0.12s;
}

.tmap-shape-preview--square {
    width: 26px;
    height: 26px;
}

.tmap-shape-preview--circle {
    width: 26px;
    height: 26px;
    border-radius: 50%;
}

.tmap-shape-option input:checked ~ .tmap-shape-preview {
    border-color: var(--green-mid);
    background: var(--green-pale);
}

/* Day bookings list */
.bk-day-row {
    display: grid;
    grid-template-columns: 110px 1fr 1fr 90px;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    border-bottom: 1px solid var(--line);
    font-size: 13px;
    transition: background 0.12s;
}

.bk-day-row:last-child { border-bottom: none; }

.bk-day-row--active {
    background: #f0fdf4;
    border-left: 3px solid #22c55e;
    padding-left: 13px;
}

.bk-day-time {
    font-variant-numeric: tabular-nums;
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
}

.bk-day-sep {
    margin: 0 3px;
    color: var(--muted);
    font-weight: 400;
}

.bk-day-table {
    font-weight: 600;
    color: var(--text);
}

.bk-day-customer { color: var(--muted); }
.bk-day-party    { color: var(--muted); text-align: right; }

@media (prefers-color-scheme: dark) {
    .bk-day-row--active { background: #0f2d1a; border-left-color: #22c55e; }
}

/* Time viewer */
.tmap-viewer {
    padding: 12px 16px !important;
}

.tmap-viewer-inner {
    display: flex;
    align-items: center;
    gap: 20px;
}

.tmap-viewer-date {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex-shrink: 0;
}

.tmap-viewer-date label {
    font-size: 11px;
    font-weight: 600;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.tmap-viewer-slider {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.tmap-viewer-time-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.tmap-viewer-time-label {
    font-size: 16px;
    font-weight: 700;
    color: var(--text);
    font-variant-numeric: tabular-nums;
}

#view-time {
    width: 100%;
    accent-color: var(--green-mid);
    cursor: pointer;
    height: 4px;
}

@media (prefers-color-scheme: dark) {
    .tb-row--header, .bk-row--header { background: #1a2b22; }
    .tb-row:not(.tb-row--header):hover,
    .bk-row:not(.bk-row--header):hover { background: #1e3028; }
    .tmap-grid { background-color: #1a2420; background-image: linear-gradient(to right, #2a3d32 1px, transparent 1px), linear-gradient(to bottom, #2a3d32 1px, transparent 1px); }
    .tmap-item { background: #2a3d32; color: #e2f5e9; border-color: rgba(255,255,255,0.12); }
    .tmap-status--available    { background: #14532d; border-color: #22c55e; color: #bbf7d0; }
    .tmap-status--booked       { background: #451a03; border-color: #f59e0b; color: #fde68a; }
    .tmap-status--occupied     { background: #450a0a; border-color: #ef4444; color: #fecaca; }
    .tmap-status--out_of_service { background: #1e293b; border-color: #475569; color: #94a3b8; }
    .tmap-status--none         { background: #2a3d32; border-color: #475569; color: #94a3b8; }
    .tmap-shape-preview        { border-color: #2a3d32; background: #1a2b22; }
}
.gantt .bar-label                     { fill: #fff; font-size: 11px; }
.gantt .bar-label.big                 { fill: var(--text) !important; }

/* Priority bar colours */
.gantt .bar-wrapper.gantt-critical .bar { fill: #e74c3c; }
.gantt .bar-wrapper.gantt-high     .bar { fill: #e67e22; }
.gantt .bar-wrapper.gantt-medium   .bar { fill: #3498db; }
.gantt .bar-wrapper.gantt-low      .bar { fill: #27ae60; }
.gantt .bar-wrapper.gantt-ms       .bar { fill: #8e44ad; }

/* Done tasks */
.gantt .bar-wrapper.gantt-status-done .bar          { fill: #95a5a6; }
.gantt .bar-wrapper.gantt-status-done .bar-progress  { fill: #7f8c8d; }

/* Progress fill (slightly darker than bar) */
.gantt .bar-wrapper.gantt-critical .bar-progress { fill: #c0392b; }
.gantt .bar-wrapper.gantt-high     .bar-progress { fill: #d35400; }
.gantt .bar-wrapper.gantt-medium   .bar-progress { fill: #2980b9; }
.gantt .bar-wrapper.gantt-low      .bar-progress { fill: #219a52; }
.gantt .bar-wrapper.gantt-ms       .bar-progress { fill: #7d3c98; }

/* Event bar colours (by type) */
.gantt .bar-wrapper.gantt-event-conference .bar { fill: #1a73e8 !important; }
.gantt .bar-wrapper.gantt-event-workshop   .bar { fill: #f4511e !important; }
.gantt .bar-wrapper.gantt-event-meeting    .bar { fill: #33b679 !important; }
.gantt .bar-wrapper.gantt-event-webinar    .bar { fill: #8e24aa !important; }
.gantt .bar-wrapper.gantt-event-social     .bar { fill: #e67c73 !important; }
.gantt .bar-wrapper.gantt-event-other      .bar { fill: #616161 !important; }

/* Completed events */
.gantt .bar-wrapper.gantt-event-done .bar         { fill: #95a5a6 !important; }
.gantt .bar-wrapper.gantt-event-done .bar-progress { fill: #7f8c8d !important; }

/* Event progress fills (slightly darker) */
.gantt .bar-wrapper.gantt-event-conference .bar-progress { fill: #1557b0 !important; }
.gantt .bar-wrapper.gantt-event-workshop   .bar-progress { fill: #c23321 !important; }
.gantt .bar-wrapper.gantt-event-meeting    .bar-progress { fill: #1e7e4e !important; }
.gantt .bar-wrapper.gantt-event-webinar    .bar-progress { fill: #6a1880 !important; }
.gantt .bar-wrapper.gantt-event-social     .bar-progress { fill: #c0564d !important; }
.gantt .bar-wrapper.gantt-event-other      .bar-progress { fill: #4a4a4a !important; }

/* Booking status fills */
.gantt .bar-wrapper.gantt-booking-pending   .bar         { fill: #f59e0b !important; }
.gantt .bar-wrapper.gantt-booking-confirmed .bar         { fill: #3b82f6 !important; }
.gantt .bar-wrapper.gantt-booking-completed .bar         { fill: #22c55e !important; }
.gantt .bar-wrapper.gantt-booking-pending   .bar-progress { fill: #c07c06 !important; }
.gantt .bar-wrapper.gantt-booking-confirmed .bar-progress { fill: #1d4ed8 !important; }
.gantt .bar-wrapper.gantt-booking-completed .bar-progress { fill: #15803d !important; }

/* Timeline filter empty state */
.timeline-filter-empty {
    padding: 32px 24px;
    text-align: center;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    color: var(--muted);
    margin-top: 8px;
}

/* Popup */
.gantt-popup {
    padding: 12px 14px;
    min-width: 200px;
    max-width: 280px;
}

.gantt-popup-title {
    font-weight: 600;
    font-size: 13px;
    color: var(--text);
    margin-bottom: 6px;
    line-height: 1.4;
}

.gantt-popup-meta {
    font-size: 12px;
    color: var(--muted);
    margin-bottom: 4px;
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.gantt-popup-badge {
    display: inline-block;
    padding: 1px 7px;
    border-radius: 10px;
    font-size: 11px;
    color: #fff;
    font-weight: 600;
}

.gantt-popup-ms  { font-size: 12px; color: #8e44ad; margin-bottom: 4px; }
.gantt-popup-due { font-size: 12px; color: var(--muted); margin-bottom: 8px; }

.gantt-popup-link {
    display: inline-block;
    font-size: 12px;
    color: var(--green-mid);
    text-decoration: none;
    font-weight: 500;
}

.gantt-popup-link:hover { text-decoration: underline; }

.gantt .popup-wrapper              { background: var(--panel); border: 1px solid var(--line); border-radius: 6px; box-shadow: 0 4px 16px rgba(0,0,0,.12); }
.gantt .popup-wrapper .title       { display: none; }
.gantt .popup-wrapper .subtitle    { display: none; }
.gantt .popup-wrapper .pointer     { display: none; }

/* Frappe Gantt overrides — dark */
[data-theme="dark"] .timeline-wrap              { background: var(--panel); border-color: var(--line); }
[data-theme="dark"] .timeline-empty             { background: var(--panel); border-color: var(--line); color: var(--muted); }
[data-theme="dark"] .btn-view-mode              { background: var(--panel); border-color: var(--line); color: var(--text); }
[data-theme="dark"] .btn-view-mode:hover        { border-color: var(--green-bright); color: var(--green-bright); }
[data-theme="dark"] .btn-view-mode--active      { background: var(--green-mid); border-color: var(--green-mid); color: #fff; }
[data-theme="dark"] .tl-legend-item             { color: var(--muted); }

/* SVG overrides use !important because Frappe Gantt CSS loads after style.css (inline in body) */
[data-theme="dark"] .gantt .grid-background          { fill: var(--panel) !important; }
[data-theme="dark"] .gantt .grid-header              { fill: var(--bg) !important; stroke: var(--line) !important; }
[data-theme="dark"] .gantt .grid-row                 { fill: var(--panel) !important; }
[data-theme="dark"] .gantt .grid-row:nth-child(even) { fill: var(--bg) !important; }
[data-theme="dark"] .gantt .row-line                 { stroke: var(--line) !important; }
[data-theme="dark"] .gantt .tick                     { stroke: var(--line) !important; }
[data-theme="dark"] .gantt .today-highlight          { fill: rgba(50,196,108,0.15) !important; opacity: 1 !important; }
[data-theme="dark"] .gantt .upper-text               { fill: var(--muted) !important; }
[data-theme="dark"] .gantt .lower-text               { fill: var(--muted) !important; }
[data-theme="dark"] .gantt .bar-label.big            { fill: var(--text) !important; }
[data-theme="dark"] .gantt .arrow                    { stroke: var(--muted) !important; }
[data-theme="dark"] .gantt .popup-wrapper            { background: var(--panel) !important; border-color: var(--line) !important; }
[data-theme="dark"] .gantt-popup-title               { color: var(--text); }
[data-theme="dark"] .gantt-popup-link                { color: var(--green-bright); }

/* Timeline save toast */
.tl-toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    padding: 9px 16px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    background: var(--panel);
    border: 1px solid var(--line);
    color: var(--text);
    box-shadow: 0 4px 16px rgba(0,0,0,0.15);
    opacity: 0;
    transform: translateY(6px);
    transition: opacity 0.2s ease, transform 0.2s ease;
    pointer-events: none;
    z-index: 9999;
}

.tl-toast--visible   { opacity: 1; transform: translateY(0); }
.tl-toast--saving    { border-color: var(--line); color: var(--muted); }
.tl-toast--ok        { border-color: #27ae60; color: #27ae60; }
.tl-toast--error     { border-color: #e74c3c; color: #e74c3c; }

[data-theme="dark"] .tl-toast { background: var(--panel); border-color: var(--line); }
[data-theme="dark"] .tl-toast--ok    { border-color: var(--green-bright); color: var(--green-bright); }
[data-theme="dark"] .tl-toast--error { border-color: #e74c3c; color: #e74c3c; }

/* ── Events module ───────────────────────────────────────────────────────── */

.event-card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 16px;
    margin-top: 16px;
}

.event-card {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    transition: box-shadow 0.15s;
}

.event-card:hover {
    box-shadow: 0 4px 14px rgba(0,0,0,0.08);
}

.event-card--muted {
    opacity: 0.65;
}

.event-card-header {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.event-card-title {
    font-size: 15px;
    font-weight: 600;
    margin: 0;
    line-height: 1.3;
}

.event-card-title a {
    color: var(--text);
    text-decoration: none;
}

.event-card-title a:hover {
    color: var(--accent);
}

.event-card-desc {
    margin: 0;
    font-size: 13px;
    line-height: 1.5;
}

.event-card-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    font-size: 13px;
    color: var(--muted);
}

.event-meta-item {
    display: flex;
    align-items: center;
    gap: 4px;
}

.event-card-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: auto;
    padding-top: 6px;
    border-top: 1px solid var(--line);
}

.event-card-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.event-card-organizer {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
}

.event-empty-state {
    padding: 48px 24px;
    text-align: center;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 10px;
    margin-top: 16px;
}

/* Event type pills */
.event-type-pill {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    background: var(--bg);
    border: 1px solid var(--line);
    color: var(--text);
}

.event-type-conference { background: #e8f0fe; border-color: #aecbfa; color: #1a73e8; }
.event-type-workshop   { background: #fce8e6; border-color: #f6aea9; color: #c5221f; }
.event-type-meeting    { background: #e6f4ea; border-color: #a8d5a2; color: #137333; }
.event-type-webinar    { background: #f3e8fd; border-color: #d7aefb; color: #7b1fa2; }
.event-type-social     { background: #fef7e0; border-color: #fce8b2; color: #e37400; }
.event-type-other      { background: var(--bg); border-color: var(--line); color: var(--muted); }

[data-theme="dark"] .event-type-conference { background: #1a2c4d; border-color: #2d4e8a; color: #7baef9; }
[data-theme="dark"] .event-type-workshop   { background: #4d1f1c; border-color: #8a302b; color: #f28b82; }
[data-theme="dark"] .event-type-meeting    { background: #1c3a24; border-color: #2d6040; color: #81c995; }
[data-theme="dark"] .event-type-webinar    { background: #3b1a54; border-color: #6a309a; color: #d7aefb; }
[data-theme="dark"] .event-type-social     { background: #4d3a00; border-color: #8a6800; color: #fdd663; }
[data-theme="dark"] .event-type-other      { background: var(--bg); border-color: var(--line); color: var(--muted); }

/* Event status pills */
.event-status-pill {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
}

.event-status-draft       { background: #f1f3f4; color: #5f6368; }
.event-status-confirmed   { background: #e6f4ea; color: #137333; }
.event-status-in-progress { background: #e8f0fe; color: #1a73e8; }
.event-status-completed   { background: #d8f5e1; color: #0f3d28; }
.event-status-cancelled   { background: #fce8e6; color: #c5221f; }

[data-theme="dark"] .event-status-draft       { background: #2d2d2d; color: #9aa0a6; }
[data-theme="dark"] .event-status-confirmed   { background: #1c3a24; color: #81c995; }
[data-theme="dark"] .event-status-in-progress { background: #1a2c4d; color: #7baef9; }
[data-theme="dark"] .event-status-completed   { background: #173526; color: var(--green-bright); }
[data-theme="dark"] .event-status-cancelled   { background: #4d1f1c; color: #f28b82; }

/* Event detail — staff section */
.event-staff-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 14px;
}

.event-staff-row {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
}

.event-staff-row .user-avatar {
    flex-shrink: 0;
}

.event-staff-add {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.event-staff-add select {
    flex: 1;
    min-width: 180px;
}

/* ── Task list: milestone grouping ───────────────────────────────────────── */

.milestone-group {
    margin-bottom: 28px;
}

.milestone-group-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 0 8px;
    border-bottom: 2px solid var(--line);
    margin-bottom: 0;
}

.milestone-group-title {
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--green-mid, #2fbf71);
}

.milestone-group-title--none {
    color: var(--muted);
}

[data-theme="dark"] .milestone-group-header { border-color: var(--line); }
[data-theme="dark"] .milestone-group-title  { color: var(--green-bright); }

/* ── Autosave: toast & hidden button ────────────────────────────────────── */

.as-hidden {
    display: none !important;
}

.as-toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    background: var(--green-darkest);
    color: #fff;
    padding: 10px 18px;
    border-radius: 8px;
    font-size: 13px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
    z-index: 9999;
}

.as-toast--show {
    opacity: 1;
}

.as-toast--error {
    background: #b91c1c;
}

[data-theme="dark"] .as-toast {
    background: var(--green-bright);
    color: var(--green-darkest);
}

[data-theme="dark"] .as-toast--error {
    background: #ef4444;
    color: #fff;
}
[data-theme="dark"] .milestone-group-title--none { color: var(--muted); }

/* ── Member list table ───────────────────────────────────────────────────── */

.member-row {
    display: grid;
    grid-template-columns: 1fr 110px 110px 170px 110px 1fr 120px;
    gap: 12px;
    align-items: center;
    min-height: 48px;
    padding: 10px 16px;
    border-bottom: 1px solid var(--line);
    cursor: pointer;
    text-decoration: none;
    color: var(--text);
}

.member-row:last-child {
    border-bottom: 0;
}

.member-row:nth-child(even) {
    background: #f7faf8;
}

.member-row.header {
    background: #eef3ef;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--muted);
    min-height: 40px;
    cursor: default;
}

.member-row:not(.header):hover {
    background: #f0f8f3;
}

.member-name {
    font-weight: 600;
    color: var(--text);
}

.member-memberships-cell {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.membership-badge {
    background: var(--green-pale);
    color: var(--green-mid);
    border-radius: 4px;
    padding: 2px 7px;
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
}

[data-theme="dark"] .member-row:nth-child(even)  { background: #192119; }
[data-theme="dark"] .member-row.header            { background: #1a2319; }
[data-theme="dark"] .member-row:not(.header):hover { background: #1e2821; }
[data-theme="dark"] .membership-badge             { background: #1a3325; color: var(--green-bright); }

/* ── Membership / member relationship table ──────────────────────────────── */

.mm-table {
    display: flex;
    flex-direction: column;
    margin: -2px 0;
}

.mm-row {
    display: grid;
    grid-template-columns: 1.4fr 110px 95px 105px 115px 1.2fr 72px;
    gap: 12px;
    align-items: center;
    min-height: 46px;
    padding: 9px 16px;
    border-bottom: 1px solid var(--line);
    font-size: 14px;
    color: var(--text);
}

.mm-row:last-child { border-bottom: 0; }

.mm-row:nth-child(even) { background: #f7faf8; }

.mm-row.header {
    background: #eef3ef;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.045em;
    color: var(--muted);
    min-height: 36px;
    padding: 7px 16px;
}

.mm-row:not(.header):hover { background: #f0f8f3; }

.mm-row-name {
    font-weight: 600;
    color: var(--green-mid);
    text-decoration: none;
}
.mm-row-name:hover { text-decoration: underline; }

.mm-row-muted { color: var(--muted); font-size: 13px; }

.mm-row-actions { display: flex; justify-content: flex-end; }
.mm-row-actions form { margin: 0; }
.mm-row-actions .btn { padding: 4px 10px; font-size: 12px; }

[data-theme="dark"] .mm-row:nth-child(even)   { background: #192119; }
[data-theme="dark"] .mm-row.header             { background: #1a2319; }
[data-theme="dark"] .mm-row:not(.header):hover { background: #1e2821; }

/* ── Payment history table ───────────────────────────────────────────────── */

.pay-table {
    display: flex;
    flex-direction: column;
}

.pay-row {
    display: grid;
    grid-template-columns: 130px 1fr 110px 120px 120px 110px;
    gap: 12px;
    align-items: center;
    min-height: 46px;
    padding: 9px 16px;
    border-bottom: 1px solid var(--line);
    font-size: 14px;
    color: var(--text);
}

.pay-row:last-child { border-bottom: 0; }
.pay-row:nth-child(even) { background: #f7faf8; }
.pay-row:not(.pay-row--header):hover { background: #f0f8f3; }

.pay-row--header {
    background: #eef3ef;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.045em;
    color: var(--muted);
    min-height: 36px;
    padding: 7px 16px;
}

.pay-row--overdue {
    background: #fff8f0 !important;
    border-left: 3px solid #f59e0b;
    padding-left: 13px;
}

.pay-row-period { font-weight: 600; }
.pay-row-plan   { color: var(--muted); font-size: 13px; }
.pay-row-meta   { color: var(--muted); font-size: 13px; }

[data-theme="dark"] .pay-row:nth-child(even)           { background: #192119; }
[data-theme="dark"] .pay-row--header                   { background: #1a2319; }
[data-theme="dark"] .pay-row:not(.pay-row--header):hover { background: #1e2821; }
[data-theme="dark"] .pay-row--overdue                  { background: #2a1f0e !important; border-left-color: #f59e0b; }

/* ── Membership plan cards ───────────────────────────────────────────────── */

.plan-card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 16px;
}

.plan-card {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 18px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    text-decoration: none;
    color: var(--text);
    transition: box-shadow 0.15s, border-color 0.15s;
}

.plan-card:hover {
    box-shadow: 0 4px 16px rgba(0,0,0,0.09);
    border-color: var(--green-mid);
}

.plan-card--inactive {
    opacity: 0.65;
}

.plan-card-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 8px;
}

.plan-card-name {
    font-size: 16px;
    font-weight: 700;
    margin: 0;
    line-height: 1.3;
}

.plan-card-price {
    font-size: 22px;
    font-weight: 700;
    color: var(--green-mid);
}

.plan-card-desc {
    font-size: 13px;
    color: var(--muted);
    margin: 0;
    line-height: 1.5;
}

.plan-card-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    font-size: 13px;
    color: var(--muted);
    border-top: 1px solid var(--line);
    padding-top: 10px;
    margin-top: auto;
}

.plan-card-meta-item {
    display: flex;
    align-items: center;
    gap: 4px;
}

[data-theme="dark"] .plan-card               { background: var(--panel); border-color: var(--line); }
[data-theme="dark"] .plan-card:hover          { border-color: var(--green-bright); }
[data-theme="dark"] .plan-card-price          { color: var(--green-bright); }

/* ── Modal overlay ───────────────────────────────────────────────────────── */

.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    z-index: 9000;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.modal-overlay.active {
    display: flex;
}

.modal-box {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 28px 32px;
    width: 100%;
    max-width: 520px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
}

.modal-box h2 {
    margin: 0 0 20px;
    font-size: 20px;
}

.modal-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 20px;
}

.modal-header h2 {
    margin: 0;
    font-size: 20px;
}

.modal-actions {
    display: flex;
    gap: 10px;
    margin-top: 20px;
}

/* ── Form fields (used in modals) ────────────────────────────────────────── */

.form-field {
    margin-bottom: 14px;
}

.form-field label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 4px;
    color: var(--text);
}

.form-field input,
.form-field select,
.form-field textarea {
    width: 100%;
}

.form-field .required {
    color: #ef4444;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

[data-theme="dark"] .modal-box {
    background: var(--panel);
    border-color: var(--line);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
}

/* ── Products module ─────────────────────────────────────────────────────── */

/* Products list — overrides .task-row column widths for the 6-col product layout */
.products-table .task-row {
    grid-template-columns: 48px 1fr 100px 90px 150px 90px;
    font-size: 13px;
}

.prod-name {
    font-weight: 600;
    color: var(--text);
    text-decoration: none;
}
.prod-name:hover { text-decoration: underline; }

/* Thumbnail in list */
.prod-thumb {
    width: 40px;
    height: 40px;
    border-radius: 6px;
    overflow: hidden;
    flex-shrink: 0;
    background: var(--bg);
    border: 1px solid var(--line);
    display: flex;
    align-items: center;
    justify-content: center;
}

.prod-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.prod-thumb-placeholder {
    font-size: 18px;
    opacity: 0.3;
}

/* Stock badges */
.stock-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
}

.stock-badge--in  { background: #dcfce7; color: #166534; }
.stock-badge--low { background: #fef9c3; color: #854d0e; }
.stock-badge--out { background: #fee2e2; color: #991b1b; }

.stock-badge--large {
    padding: 4px 14px;
    font-size: 14px;
}

[data-theme="dark"] .stock-badge--in  { background: #14532d; color: #86efac; }
[data-theme="dark"] .stock-badge--low { background: #451a03; color: #fde68a; }
[data-theme="dark"] .stock-badge--out { background: #450a0a; color: #fca5a5; }

/* Detail page layout */
.prod-detail-layout {
    display: grid;
    grid-template-columns: 1fr 300px;
    gap: 18px;
    align-items: start;
    max-width: 1100px;
}

.prod-detail-main,
.prod-detail-sidebar {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

/* Inline edit fields in detail */
.prod-field-row { position: relative; }

.prod-sidebar-field {
    margin-bottom: 14px;
}

.prod-sidebar-field label {
    display: block;
    font-size: 11px;
    font-weight: 600;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 4px;
}

.prod-description {
    white-space: pre-wrap;
    line-height: 1.6;
    min-height: 40px;
}

/* Featured image in detail */
.prod-featured-img {
    max-width: 100%;
    max-height: 280px;
    border-radius: 8px;
    object-fit: contain;
    display: block;
}

/* Category / tag checkbox lists */
.prod-checkbox-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.prod-check-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    cursor: pointer;
    padding: 4px 0;
}

.prod-check-item input[type="checkbox"] {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

/* Responsive: stack on narrow screens */
@media (max-width: 860px) {
    .prod-detail-layout {
        grid-template-columns: 1fr;
    }
    .products-table .task-row {
        grid-template-columns: 40px 1fr 80px 60px;
    }
    .products-table .task-row > :nth-child(5),
    .products-table .task-row > :nth-child(6) {
        display: none;
    }
}

/* ── Orders: clickable list rows ─────────────────────────────────────────── */

a.order-table-row {
    text-decoration: none;
    color: inherit;
    cursor: pointer;
    transition: background 0.1s;
}

a.order-table-row:hover {
    background: #f0f8f3;
}

.order-total-cell {
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    font-family: monospace;
    font-size: 0.9rem;
}

/* ── Orders: modal items list (client-side, before creation) ─────────────── */

.modal-items-list {
    margin-top: 8px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.modal-item-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    background: #f0f7f3;
    border-radius: 6px;
    font-size: 0.85rem;
}

.modal-item-name {
    flex: 1;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.modal-item-remove {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--muted);
    font-size: 1.1rem;
    line-height: 1;
    padding: 0 2px;
    flex-shrink: 0;
}

.modal-item-remove:hover { color: #dc2626; }

/* ── Orders: product autocomplete ────────────────────────────────────────── */

.product-autocomplete-wrap {
    position: relative;
}

.product-suggestions {
    position: fixed;
    z-index: 9999;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: 0 4px 18px rgba(0, 0, 0, 0.12);
    max-height: 240px;
    overflow-y: auto;
    display: none;
}

.product-suggestion-item {
    padding: 9px 12px;
    cursor: pointer;
    border-bottom: 1px solid var(--line);
    font-size: 0.88rem;
    transition: background 0.1s;
}

.product-suggestion-item:last-child { border-bottom: 0; }

.product-suggestion-item:hover,
.product-suggestion-item.ps-highlighted { background: #f0f8f3; }

.product-suggestion-name {
    font-weight: 600;
    color: var(--text);
    margin-bottom: 1px;
}

.product-suggestion-meta {
    font-size: 0.78rem;
    color: var(--muted);
}

/* ── Orders: add-item section inside order detail ────────────────────────── */

.add-item-section {
    border-top: 1px solid var(--line);
    padding: 14px 20px;
    background: #f9fcfb;
}

.add-item-section .add-item-form { padding: 0; }

.add-item-search-wrap {
    display: flex;
    flex-direction: column;
}

.add-item-label {
    display: block;
    font-size: 11px;
    font-weight: 600;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 4px;
}

.qty-input {
    width: 64px;
    text-align: center;
    padding: 6px 8px;
    border: 1px solid var(--line);
    border-radius: 6px;
    font-size: 0.9rem;
}

/* ── Orders: totals card (receipt style) ─────────────────────────────────── */

.order-totals-card {
    font-size: 0.9rem;
}

.order-totals-label {
    color: var(--muted);
    font-size: 0.88rem;
}

.order-totals-value {
    font-variant-numeric: tabular-nums;
    font-family: monospace;
}

.order-totals-row--editable .order-totals-label {
    color: var(--text);
}

.order-totals-row--total {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px;
    border-top: 2px solid var(--line);
    font-weight: 700;
    font-size: 1rem;
}

.totals-inline-form {
    display: flex;
    justify-content: flex-end;
}

.totals-input {
    width: 96px;
    text-align: right;
    padding: 4px 8px;
    font-size: 0.9rem;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #f7faf8;
    font-family: monospace;
    transition: border-color 0.15s;
}

.totals-input:focus {
    outline: none;
    border-color: var(--green-bright);
    background: #fff;
}

/* ── Multi-assignee UI ───────────────────────────────────────────────────── */

.assignees-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 6px;
}

.assignee-row {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.88rem;
}

.assignee-name { flex: 1; }

.assignee-remove {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--muted);
    font-size: 1.1rem;
    line-height: 1;
    padding: 0 2px;
    flex-shrink: 0;
    opacity: 0.6;
}

.assignee-remove:hover { color: #dc2626; opacity: 1; }

.assignee-add-form {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 4px;
}

.assignee-add-form select {
    font-size: 0.82rem;
    padding: 3px 6px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: var(--bg);
    color: var(--text);
    flex: 1;
}

/* ── Dark mode: orders additions ─────────────────────────────────────────── */

[data-theme="dark"] a.order-table-row:hover { background: rgba(47, 191, 113, 0.08); }

[data-theme="dark"] .modal-item-row { background: rgba(47, 191, 113, 0.08); }

[data-theme="dark"] .product-suggestions {
    background: var(--green-darkest);
    border-color: rgba(255,255,255,0.1);
    box-shadow: 0 4px 18px rgba(0,0,0,0.4);
}

[data-theme="dark"] .product-suggestion-item { border-color: rgba(255,255,255,0.07); }
[data-theme="dark"] .product-suggestion-item:hover,
[data-theme="dark"] .product-suggestion-item.ps-highlighted { background: rgba(47,191,113,0.1); }

[data-theme="dark"] .add-item-section { background: rgba(255,255,255,0.03); }

[data-theme="dark"] .totals-input {
    background: rgba(255,255,255,0.06);
    border-color: rgba(255,255,255,0.15);
    color: #fff;
}

[data-theme="dark"] .totals-input:focus { border-color: var(--green-bright); }
