:root,
body[data-theme="light"] {
    --bg: #f4f5f7;
    --bg-taskboard-card: #f4f5f7;
    --surface: #ffffff;
    --surface-soft: #f9fafb;
    --surface-alt: #f3f4f6;
    --surface-tooltip: #e8e8e9;

    --text: #111827;
    --badge-text: #111827;
    --text-muted: #6b7280;
    --border: #e5e7eb;

    --sidebar-bg: #111827;
    --sidebar-text: #d1d5db;
    --sidebar-active: #1f2937;

    --topbar-bg: #ffffff;
    --button-bg: #111827;
    --button-text: #ffffff;

    --project-task-link: #050aff;

    --shadow: 0 10px 30px rgba(0,0,0,.08);
}

body[data-theme="dark"] {
    --bg: #0f172a;
    --bg-taskboard-card: #020617;
    --surface: #111827;
    --surface-soft: #1f2937;
    --surface-alt: #172033;
    --surface-tooltip: #333333;

    --text: #f9fafb;
    --badge-text: #111827;
    --text-muted: #9ca3af;
    --border: #374151;

    --sidebar-bg: #020617;
    --sidebar-text: #cbd5e1;
    --sidebar-active: #1e293b;

    --topbar-bg: #111827;
    --button-bg: #2563eb;
    --button-text: #ffffff;

    --project-task-link: #87ceeb;

    --shadow: 0 10px 30px rgba(0,0,0,.35);
}

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

.app-shell {
    display: grid;
    grid-template-columns: 240px 1fr;
    min-height: 100vh;
}

.sidebar {
    background: var(--sidebar-bg);
    color: var(--surface);
    padding: 24px 18px;
}

.sidebar-logo {
    font-weight: 700;
    font-size: 20px;
    margin-bottom: 32px;
}

.sidebar-nav {
    display: grid;
    gap: 8px;
}

.sidebar-nav a {
    color: var(--sidebar-text);
    text-decoration: none;
    padding: 12px 14px;
    border-radius: 10px;
}

.sidebar-nav a:hover,
.sidebar-nav a.active {
    background: var(--sidebar-active);
    color: var(--sidebar-text);
}

.main-area {
    min-width: 0;
}

.app-topbar {
    height: 60px;
    background: var(--topbar-bg);
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 18px;
    padding: 0 24px;
}

.app-topbar a {
    color: var(--topbar-bg);
}

.container {
    max-width: 1100px;
    margin: 32px auto;
    padding: 0 24px;
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 22px;
}

.page-header h1 {
    margin: 0;
}

.page-actions {
    display: flex;
    gap: 10px;
}

.card {
    background: var(--surface);
    color: var(--text);
    box-shadow: var(--shadow);
    border-radius: 14px;
    padding: 24px;
    overflow: hidden;
    margin-bottom: 24px;
}

.dashboard-task-board-card {
    overflow: visible;
}

.topbar {
    height: 60px;
    background: var(--topbar-bg);
    color: var(--surface-soft);
    display: flex;
    align-items: center;
    gap: 24px;
    padding: 0 24px;
}

.topbar a {
    color: var(--button-text);
    margin-left: auto;
}

.container {
    max-width: 95%;
    margin: 32px auto;
    padding: 0 24px;
}

.card,
.login-card {
    background: white;
    border-radius: 14px;
    padding: 24px;
    box-shadow: 0 10px 30px rgba(0,0,0,.08);
}

.login-page {
    display: grid;
    place-items: center;
    min-height: 100vh;
}

.login-card {
    width: 360px;
}

input,
button {width: 100%;
    padding: 12px;
    margin: 8px 0 16px;
}

button {
    background: var(--button-bg);
    color: white;
    border: none;
    cursor: pointer;
}

.error {
    color: #b91c1c;
}

.time-block {
    display: grid;
    grid-template-columns: 150px 1fr auto;
    gap: 16px;
    padding: 14px 0;
    border-bottom: 1px solid #eee;
}

.time-block small {
    display: block;
    color: #666;
}

.badge {
    background: #e5e7eb;
    color: var(--badge-text);
    border-radius: 999px;
    padding: 4px 10px;
    text-align: center;
}

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.button-link {
    display: inline-block;
    background: var(--button-bg);
    color: white;
    padding: 10px 16px;
    border-radius: 10px;
    text-decoration: none;
}

.topbar a {
    color: white;
    text-decoration: none;
}

.project-row,
.task-row {
    display: grid;
    grid-template-columns: minmax(260px, 1fr) 120px 120px 150px;
    gap: 18px;
    align-items: center;
    padding: 18px 24px;
    border-bottom: 1px solid #eee;
}

.project-row:last-child,
.task-row:last-child {
    border-bottom: none;
}

.project-row strong,
.task-row strong {
    display: block;
    font-size: 16px;
    margin-bottom: 4px;
}

.project-row strong a,
.task-row strong a{
    color: var(--project-task-link);
}

.project-row small,
.task-row small {
    display: block;
    color: #666;
}

.project-row small,
.task-row small {
    display: block;
    color: #666;
}

textarea,
select {
    width: 100%;
    padding: 12px;
    margin: 8px 0 16px;
}

.topbar {
    height: 60px;
    background: var(--topbar-bg);
    color: white;
    display: flex;
    align-items: center;
    gap: 24px;
    padding: 0 24px;
}

.topnav {
    display: flex;
    gap: 18px;
}

.topbar-user {
    margin-left: auto;
}

.topbar a {
    color: white;
    text-decoration: none;
}

.topbar a:hover {
    text-decoration: underline;
}

.card {
    overflow: hidden;
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.button-link {
    display: inline-block;
    background: var(--button-bg);
    color: white;
    padding: 10px 16px;
    border-radius: 10px;
    text-decoration: none;
    transition: .2s;
}

.button-link:hover {
    opacity: .9;
}

.button-link.secondary {
    background: var(--text-muted);
}

.button-link,
button,
.btn {
    background: var(--button-bg);
    color: var(--button-text);
}

.flash {
    padding: 14px 18px;
    border-radius: 12px;
    margin-bottom: 20px;
    font-weight: 600;
}

.flash-success {
    background: #dcfce7;
    color: #166534;
}

.flash-error {
    background: #fee2e2;
    color: #991b1b;
}

.user-row {
    display: grid;
    grid-template-columns: minmax(260px, 1fr) 120px 120px;
    gap: 18px;
    align-items: center;
    padding: 18px 24px;
    border-bottom: 1px solid #eee;
}

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

.user-row small {
    display: block;
    color: #666;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 8px 0 16px;
}

.checkbox-label input {
    width: auto;
    margin: 0;
}

.schedule-table {
    display: grid;
    gap: 0;
}

.schedule-row {
    display: grid;
    grid-template-columns: 140px 80px repeat(4, 1fr);
    gap: 12px;
    align-items: center;
    padding: 14px 0;
    border-bottom: 1px solid #eee;
}

.schedule-heading {
    font-weight: 700;
    color: #374151;
}

.schedule-row input[type="time"] {
    margin: 0;
}

.comment-form textarea {
    min-height: 90px;
}

.comments-list {
    margin-top: 24px;
}

.comment-item {
    padding: 16px 0;
    border-bottom: 1px solid #eee;
}

.comment-item:last-child {
    border-bottom: none;
}

.comment-meta {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    color: var(--text-muted);
    font-size: 14px;
    margin-bottom: 6px;
}

.comment-item p {
    margin: 0;
    line-height: 1.5;
}

.dashboard-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
}

@media (max-width: 900px) {
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
}

.activity-item {
    padding: 16px 0;
    border-bottom: 1px solid #eee;
}

.activity-item:last-child {
    border-bottom: none;
}

.activity-meta {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    color: var(--text-muted);
    font-size: 14px;
    margin-bottom: 6px;
}

.activity-description {
    font-weight: 600;
    margin-bottom: 4px;
}

@media (max-width: 900px) {
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
}

.activity-entity {
    margin-bottom: 4px;
    color: var(--border);
    font-size: 14px;
}

.activity-comment {
    margin: 8px 0 4px;
    padding: 10px 12px;
    background: var(--surface-soft);
    border-left: 3px solid #d1d5db;
    color: var(--border);
    font-size: 14px;
    line-height: 1.5;
}

.activity-changes {
    margin-top: 8px;
    font-size: 14px;
}

.activity-change {
    padding: 4px 0;
    color: var(--border);
}

.dashboard-task {
    display: grid;
    grid-template-columns: 1fr auto auto;
    gap: 12px;
    align-items: center;
    padding: 14px 0;
    border-bottom: 1px solid #eee;
}

.dashboard-task:last-child {
    border-bottom: none;
}

.dashboard-task small {
    display: block;
    color: var(--text-muted);
}

/* =========================================================
   DASHBOARD TASK BOARD
   ========================================================= */

.dashboard-task-board-card {
    width: 100%;
    margin-bottom: 24px;
    background: var(--bg-taskboard-card);
    overflow: hidden;
}

.task-board {
    display: flex;
    align-items: stretch;
    gap: 0;
    width: 100%;
    overflow-x: auto;
    overflow-y: visible;
    padding-bottom: 12px;
}

/* One fixed-width column per project */
.task-column {
    position: relative;
    flex: 0 0 300px;
    width: 300px;
    min-width: 300px;
    padding: 15px;
    border: 1px solid var(--border);
    z-index: 1;
}

.task-column:nth-child(odd) {
    background: var(--surface);
}

.task-column:nth-child(even) {
    background: var(--surface-soft);
}

.task-column h3 {
    margin: 0 0 14px;
    padding: 10px;
    border-radius: 10px;
    background: navy;
    color: #ffffff;
    font-size: 18px;
}

/* Raise the complete column when one of its task cards is hovered */
.task-column:has(.task-card:hover) {
    z-index: 50;
}

/* =========================================================
   TASK CARDS
   ========================================================= */

.task-card {
    position: relative;
    z-index: 1;
    display: block;
    margin-bottom: 12px;
    padding: 14px;
    border-left: 8px solid #9ca3af;
    border-radius: 12px;
    background: var(--surface-alt);
    color: var(--text);
    box-shadow: var(--shadow);
    text-decoration: none;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.task-card:last-child {
    margin-bottom: 0;
}

.task-card:hover {
    z-index: 100;
    transform: translateY(-1px);
}

.task-card-main-link {
    color: inherit;
    text-decoration: none;
}

.task-card-main-link:hover {
    text-decoration: underline;
}

.task-card strong {
    display: block;
    margin-bottom: 8px;
    font-size: 12px;
}

.task-card-description {
    margin: 8px 0;
    color: var(--text);
    font-size: 12px;
    line-height: 1.35;
}

.task-card-meta {
    display: flex;
    gap: 8px;
    margin-bottom: 6px;
    color: var(--text);
    font-size: 12px;
}

.task-card small {
    display: block;
    margin-top: 4px;
    color: var(--text-muted);
    font-size: 10px;
}

/* Priority colors */

.task-priority-urgent {
    border-left-color: #b10707;
}

.task-priority-high {
    border-left-color: #f97316;
}

.task-priority-medium {
    border-left-color: #eab308;
}

.task-priority-low {
    border-left-color: #03aa41;
}

/* Completed tasks */

.task-status-completed {
    opacity: 0.55;
}

.task-status-completed strong {
    text-decoration: line-through;
}

/* =========================================================
   COMMENT BUTTON
   ========================================================= */

.comment-button {
    display: inline-block;
    width: 100%;
    margin: 8px 0;
    padding: 6px 10px;
    border: none;
    border-radius: 8px;
    background: var(--sidebar-bg);
    color: #ffffff;
    font-size: 12px;
    cursor: pointer;
}

/* =========================================================
   COMMENTS TOOLTIP
   ========================================================= */

.task-comments-tooltip {
    display: none;
    position: absolute;

    /*
     * Show below the card, but lift it above all neighboring cards.
     * Keeping it within the column avoids changing the board geometry.
     */
    left: 12px;
    top: calc(100% + 6px);

    z-index: 1000;
    width: 280px;
    max-height: 260px;
    overflow-y: auto;

    padding: 14px;
    border: 1px solid var(--border);
    border-radius: 12px;

    background: var(--surface-tooltip);
    color: var(--text);
    box-shadow: 0 14px 36px rgba(0, 0, 0, 0.35);

    font-size: 11px;
    cursor: default;
}

.task-card:hover .task-comments-tooltip,
.task-comments-tooltip:hover {
    display: block;
}

.tooltip-comment {
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
}

.tooltip-comment:last-child {
    border-bottom: none;
}

.tooltip-comment small {
    color: var(--text-muted);
}

.tooltip-comment p {
    margin: 4px 0 0;
    color: var(--text);
    font-size: 11px;
    line-height: 1.4;
}


.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(17, 24, 39, .55);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
}

.modal-overlay[hidden] {
    display: none;
}

.modal-box {
    width: min(520px, calc(100vw - 32px));
    background: var(--surface);
    color: var(--text);
    border-radius: 16px;
    padding: 24px;
    box-shadow: 0 20px 60px rgba(0,0,0,.3);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-header h2 {
    margin: 0;
}

.modal-close {
    border: none;
    background: transparent;
    font-size: 28px;
    cursor: pointer;
}

.modal-subtitle {
    color: var(--text-muted);
    margin-top: 6px;
}

.modal-box textarea {
    min-height: 120px;
}

input,
textarea,
select {
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
}

/* Theme cleanup overrides */

.card,
.modal-box,
.comment-item,
.activity-item {
    background: var(--surface);
    color: var(--text);
}

.dashboard-grid .card,
.dashboard-task-board-card {
    background: var(--surface);
    color: var(--text);
}

.activity-comment {
    background: var(--surface-soft);
    color: var(--text);
    border-left-color: var(--border);
}

.activity-description,
.activity-entity,
.activity-change,
.task-card-description,
.comment-item p,
.tooltip-comment p {
    color: var(--text);
}

.activity-meta,
.activity-meta span,
.activity-item small,
.task-card small,
.comment-meta,
.comment-meta span,
.tooltip-comment small,
.modal-subtitle {
    color: var(--text-muted);
}

input,
textarea,
select {
    background: var(--surface-soft);
    color: var(--text);
    border-color: var(--border);
}

input::placeholder,
textarea::placeholder {
    color: var(--text-muted);
}

body[data-theme="dark"] .card {
    box-shadow: var(--shadow);
}

body[data-theme="dark"] .activity-comment {
    background: var(--surface-soft);
}

.theme-toggle {
    padding: 8px 12px;
    border-radius: 8px;
    background: var(--button-bg);
    color: var(--text);
    text-decoration: none;
}