:root {
    --bg: #eef1f6;
    --sidebar: #141c2b;
    --sidebar-text: #d7dee8;
    --navy: #1a2744;
    --burgundy: #8b1e3f;
    --burgundy-hover: #6e1832;
    --accent: #8b1e3f;
    --accent-hover: #6e1832;
    --card: #ffffff;
    --text: #151b28;
    --muted: #6b7280;
    --border: #e2e8f0;
    --danger: #b91c1c;
    --radius: 14px;
    --shadow: 0 10px 28px rgba(20, 28, 43, 0.07);
    --gradient-hero: linear-gradient(135deg, #1a2744 0%, #3d1f3a 48%, #8b1e3f 100%);
    --sidebar-width: 260px;
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    font-family: "Segoe UI", "Candara", "Gill Sans", sans-serif;
}

* { box-sizing: border-box; }

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

body {
    margin: 0;
    background: linear-gradient(160deg, #e8edf5 0%, #f4f6fa 42%, #f7eef2 100%);
    color: var(--text);
    min-height: 100vh;
    min-height: 100dvh;
}

body.nav-open {
    overflow: hidden;
}

.login-page {
    min-height: 100vh;
    min-height: 100dvh;
    display: grid;
    place-items: center;
    padding: 1.25rem;
    padding-top: max(1.25rem, var(--safe-top));
    padding-bottom: max(1.25rem, var(--safe-bottom));
    background:
        radial-gradient(circle at top right, rgba(139, 30, 63, 0.16), transparent 42%),
        radial-gradient(circle at bottom left, rgba(26, 39, 68, 0.14), transparent 38%),
        var(--bg);
}

.login-wrap { width: 100%; max-width: 420px; }

.login-card {
    background: var(--card);
    border-radius: 18px;
    padding: 1.5rem;
    box-shadow: var(--shadow);
    border: 1px solid rgba(255,255,255,0.7);
}

.login-brand, .sidebar-brand {
    display: flex;
    gap: 0.85rem;
    align-items: center;
}

.brand-mark {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    background: var(--gradient-hero);
    color: #fff;
    display: grid;
    place-items: center;
    font-weight: 700;
    letter-spacing: 0.5px;
    flex-shrink: 0;
}

.app-shell {
    display: grid;
    grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
    min-height: 100vh;
    min-height: 100dvh;
}

.app-sidebar {
    background: linear-gradient(180deg, #141c2b 0%, #1a1420 100%);
    color: var(--sidebar-text);
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    position: sticky;
    top: 0;
    height: 100vh;
    height: 100dvh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.sidebar-brand {
    position: relative;
    padding-right: 0.25rem;
}

.sidebar-brand strong {
    display: block;
    color: #fff;
    font-size: 0.95rem;
    line-height: 1.25;
}

.sidebar-brand small {
    color: #93a4b8;
}

.sidebar-close {
    display: none;
    margin-left: auto;
    width: 40px;
    height: 40px;
    border: 0;
    border-radius: 10px;
    background: rgba(255,255,255,0.08);
    color: #fff;
    font-size: 1.5rem;
    line-height: 1;
    cursor: pointer;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    flex: 1;
}

.sidebar-nav .nav-link {
    color: #c9d4e2;
    text-decoration: none;
    padding: 0.85rem 0.95rem;
    border-radius: 10px;
    transition: background 0.15s ease, color 0.15s ease;
    min-height: 44px;
    display: flex;
    align-items: center;
}

.sidebar-nav .nav-link:hover {
    background: rgba(255,255,255,0.06);
    color: #fff;
}

.sidebar-nav .nav-link.active {
    background: var(--gradient-hero);
    color: #fff;
}

.sidebar-footer { margin-top: auto; }

.user-chip {
    font-size: 0.85rem;
    margin-bottom: 0.6rem;
    color: #aeb9c7;
    word-break: break-word;
}

.app-main {
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.app-topbar {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.7rem 1rem;
    padding-top: max(0.7rem, var(--safe-top));
    background: #fff;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 20;
    min-height: 56px;
}

.topbar-menu-btn {
    display: none;
    align-items: center;
    gap: 0.45rem;
    min-height: 40px;
    padding: 0.4rem 0.7rem;
}

.menu-icon {
    width: 18px;
    height: 14px;
    display: inline-block;
    background:
        linear-gradient(#334155, #334155) 0 0 / 100% 2px no-repeat,
        linear-gradient(#334155, #334155) 0 6px / 100% 2px no-repeat,
        linear-gradient(#334155, #334155) 0 12px / 100% 2px no-repeat;
}

.topbar-title {
    display: none;
    min-width: 0;
}

.topbar-title strong {
    display: block;
    font-size: 0.92rem;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.topbar-title small {
    display: block;
    color: var(--muted);
    font-size: 0.72rem;
}

.topbar-spacer { flex: 1; }

.notification-toggle {
    border: 1px solid var(--border);
    border-radius: 10px;
    width: 40px;
    height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.notification-dropdown {
    width: min(360px, calc(100vw - 1.5rem));
    max-width: calc(100vw - 1.5rem);
    padding: 0;
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
}

.notification-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border);
    background: #f8fafc;
}

.notification-list {
    max-height: min(360px, 55vh);
    overflow: auto;
    -webkit-overflow-scrolling: touch;
}

.notification-item {
    display: block;
    padding: 0.85rem 1rem;
    text-decoration: none;
    color: inherit;
    border-bottom: 1px solid #f1f5f9;
}

.notification-item:hover { background: #f8fafc; }
.notification-item.is-unread { background: #f0fdfa; }

.notification-item-title {
    font-weight: 600;
    font-size: 0.9rem;
    margin-bottom: 0.2rem;
}

.notification-item-body {
    font-size: 0.82rem;
    color: #4b5563;
    white-space: pre-wrap;
}

.notification-item-meta {
    font-size: 0.75rem;
    color: var(--muted);
    margin-top: 0.35rem;
}

.deadline-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.8rem;
    padding: 0.2rem 0.55rem;
    border-radius: 999px;
    background: #f1f5f9;
    color: #334155;
}

.deadline-pill.is-overdue {
    background: #fee2e2;
    color: #991b1b;
}

.job-detail {
    position: relative;
    z-index: 1;
}

.job-detail-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.25rem 1.5rem;
    display: grid;
    gap: 1.5rem;
    position: relative;
    z-index: 1;
}

.job-detail-card h2 {
    font-size: 1rem;
    margin: 0 0 0.75rem;
    color: #111827;
}

.job-description {
    white-space: pre-wrap;
    line-height: 1.6;
    color: #374151;
    overflow-wrap: anywhere;
}

.job-detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem 1.25rem;
}

.job-detail-grid > div {
    min-width: 0;
}

.job-detail-grid .label {
    display: block;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--muted);
    margin-bottom: 0.25rem;
}

.job-detail-grid .value {
    overflow-wrap: anywhere;
    word-break: break-word;
    line-height: 1.4;
}

.job-view-actions {
    display: flex;
    gap: 0.6rem;
    flex-wrap: wrap;
    align-items: center;
    position: relative;
    z-index: 3;
}

.job-view-actions .btn {
    min-height: 42px;
    min-width: 110px;
    padding: 0.5rem 1rem;
    pointer-events: auto;
    position: relative;
    z-index: 3;
}

.page-header .back-link {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    min-height: 36px;
    padding: 0.25rem 0.15rem;
    font-weight: 600;
    color: var(--accent);
    text-decoration: none;
    position: relative;
    z-index: 3;
}

.page-header .back-link:hover,
.page-header .back-link:focus {
    color: var(--accent-hover);
    text-decoration: underline;
}

.attachment-gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 0.85rem;
}

.attachment-thumb {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    text-decoration: none;
    color: inherit;
    border: 1px solid var(--border);
    border-radius: 10px;
    overflow: hidden;
    background: #fff;
    cursor: pointer;
    position: relative;
    z-index: 1;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.attachment-thumb:hover,
.attachment-thumb:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.12);
    outline: none;
}

.attachment-thumb img {
    width: 100%;
    height: 140px;
    object-fit: cover;
    display: block;
    background: #f3f4f6;
}

.attachment-thumb span {
    font-size: 0.78rem;
    padding: 0 0.6rem 0.6rem;
    color: #4b5563;
    word-break: break-word;
}

.attachment-file-list {
    margin: 0.75rem 0 0;
    padding-left: 1.1rem;
}

.edit-attachments-list {
    display: grid;
    gap: 0.4rem;
}

.edit-att-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
    flex-wrap: wrap;
}

/* Compact jobs tables — even column distribution */
.jobs-table-shell .jobs-table {
    table-layout: fixed;
    width: 100%;
}

.jobs-table thead th {
    font-size: 0.72rem;
    padding: 0.7rem 0.75rem;
    background: #f8fafc;
    border-bottom: 1px solid var(--border);
}

.jobs-table tbody td {
    padding: 0.85rem 0.75rem;
    vertical-align: middle;
    border-color: #eef2f7;
}

.jobs-table tbody tr:hover {
    background: #f8fafc;
}

/* 5-col dashboard/jobs rows: Job | Assignee | Status | Deadline | Actions */
.jobs-table th:nth-child(1),
.jobs-table td:nth-child(1) { width: 28%; }
.jobs-table th:nth-child(2),
.jobs-table td:nth-child(2) { width: 18%; }
.jobs-table th:nth-child(3),
.jobs-table td:nth-child(3) { width: 16%; }
.jobs-table th:nth-child(4),
.jobs-table td:nth-child(4) { width: 20%; }
.jobs-table th:nth-child(5),
.jobs-table td:nth-child(5) { width: 18%; }

.jobs-table .job-title-link {
    font-weight: 600;
    color: #111827;
    text-decoration: none;
}

.jobs-table .job-title-link:hover {
    color: var(--accent);
}

.jobs-table .job-excerpt {
    margin-top: 0.25rem;
    color: #6b7280;
    font-size: 0.82rem;
    line-height: 1.35;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.jobs-table .job-meta-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    margin-top: 0.45rem;
}

.meta-chip {
    display: inline-flex;
    align-items: center;
    font-size: 0.72rem;
    padding: 0.15rem 0.45rem;
    border-radius: 999px;
    background: #ecfdf5;
    color: #065f46;
}

.meta-chip.muted {
    background: #f3f4f6;
    color: #4b5563;
}

.assignee-name {
    font-size: 0.9rem;
    color: #374151;
}

.date-cell {
    font-size: 0.85rem;
    color: #4b5563;
    white-space: nowrap;
}

.jobs-table .col-actions {
    width: 18%;
}

.jobs-table .action-btns {
    display: flex;
    gap: 0.35rem;
    flex-wrap: wrap;
    justify-content: center;
}

.jobs-table .deadline-pill {
    font-size: 0.75rem;
    white-space: nowrap;
}

.app-content {
    padding: 1.25rem 1.5rem 2rem;
    padding-bottom: max(2rem, calc(1rem + var(--safe-bottom)));
    flex: 1;
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 0.85rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.page-header h1 {
    font-size: clamp(1.25rem, 4vw, 1.5rem);
    margin: 0;
}

.page-header p {
    margin: 0.25rem 0 0;
    color: var(--muted);
}

.page-header .btn {
    min-height: 40px;
}

.filter-bar .card-body { padding: 1rem; }

.filter-actions {
    display: flex;
    gap: 0.5rem;
}

.table-shell {
    background: var(--card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    overflow: hidden;
}

.table-shell .table-responsive {
    -webkit-overflow-scrolling: touch;
}

.table-shell .table {
    margin: 0;
    vertical-align: middle;
    width: 100%;
    table-layout: fixed;
    min-width: 640px;
}

.jobs-table-shell .jobs-table {
    min-width: 760px;
}

.table-shell th {
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--muted);
    background: #f8fafc;
    border-bottom-width: 1px;
    white-space: nowrap;
    text-align: center;
    padding-left: 0.75rem;
    padding-right: 0.75rem;
}

.table-shell td {
    font-size: 0.92rem;
    text-align: center;
    vertical-align: middle;
    padding-left: 0.75rem;
    padding-right: 0.75rem;
}

/* Primary label column stays left-aligned for readability */
.table-shell th:first-child,
.table-shell td:first-child {
    text-align: left;
    padding-left: 1rem;
}

.table-shell th:last-child,
.table-shell td:last-child {
    text-align: center;
    padding-right: 1rem;
}

/* Users: Name | Email | Created | Actions */
#usersTableShell .table th:nth-child(1),
#usersTableShell .table td:nth-child(1) { width: 22%; }
#usersTableShell .table th:nth-child(2),
#usersTableShell .table td:nth-child(2) { width: 34%; }
#usersTableShell .table th:nth-child(3),
#usersTableShell .table td:nth-child(3) { width: 22%; }
#usersTableShell .table th:nth-child(4),
#usersTableShell .table td:nth-child(4) { width: 22%; }

/* My Jobs: Title | Description | Attachment | Deadline | Status | Action */
#jobsTableShell .table th:nth-child(1),
#jobsTableShell .table td:nth-child(1) { width: 20%; }
#jobsTableShell .table th:nth-child(2),
#jobsTableShell .table td:nth-child(2) { width: 22%; text-align: left; }
#jobsTableShell .table th:nth-child(3),
#jobsTableShell .table td:nth-child(3) { width: 12%; }
#jobsTableShell .table th:nth-child(4),
#jobsTableShell .table td:nth-child(4) { width: 16%; }
#jobsTableShell .table th:nth-child(5),
#jobsTableShell .table td:nth-child(5) { width: 14%; }
#jobsTableShell .table th:nth-child(6),
#jobsTableShell .table td:nth-child(6) { width: 16%; }

.desc-cell {
    max-width: none;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.status-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.28rem 0.7rem;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 600;
    line-height: 1.2;
    white-space: nowrap;
    flex-shrink: 0;
}

.jobs-table td:has(> .status-badge),
.dashboard-job-status {
    white-space: nowrap;
}

.status-New { background: #dbeafe; color: #1e3a8a; }
.status-Running { background: #fef3c7; color: #92400e; }
.status-Revision { background: #ffe4e6; color: #9f1239; }
.status-Completed { background: #d1fae5; color: #065f46; }

.edit-request-callout {
    margin-bottom: 1.25rem;
    padding: 1rem 1.1rem;
    border: 1px solid #fda4af;
    border-radius: var(--radius);
    background: #fff1f2;
}

.edit-request-callout h2 {
    margin-bottom: 0.35rem;
    color: #9f1239;
}

.edit-request-meta {
    margin: 0 0 0.55rem;
    font-size: 0.85rem;
    color: var(--muted);
}

.edit-request-comment {
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    color: #881337;
    line-height: 1.45;
}

.edit-history-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
}

.edit-history-item {
    padding: 0.85rem 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: #fafafa;
}

.edit-history-item.edit-history-edit_requested {
    border-color: #fda4af;
    background: #fff1f2;
}

.edit-history-head {
    display: flex;
    justify-content: space-between;
    gap: 0.75rem;
    flex-wrap: wrap;
    margin-bottom: 0.25rem;
}

.edit-history-head span {
    font-size: 0.85rem;
    color: var(--muted);
}

.edit-history-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem 0.75rem;
    font-size: 0.88rem;
    color: #374151;
    margin-bottom: 0.35rem;
}

.edit-history-method,
.edit-history-status {
    color: var(--muted);
}

.edit-history-comment {
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    margin-top: 0.35rem;
    padding-top: 0.45rem;
    border-top: 1px solid var(--border);
    color: #1f2937;
    line-height: 1.45;
}

/* Dashboard */
.dashboard-header {
    align-items: center;
    flex-wrap: nowrap;
    gap: 1rem;
}

.dashboard-header > div:first-child {
    min-width: 0;
    flex: 1 1 auto;
}

.dashboard-toolbar {
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    gap: 0.65rem;
    flex: 0 0 auto;
    margin-left: auto;
}

.dashboard-search {
    width: 240px;
    max-width: 280px;
    flex: 0 1 280px;
    border-radius: 999px;
    border-color: var(--border);
    background: #fff;
    min-height: 42px;
    padding-left: 1rem;
    padding-right: 1rem;
}

.dashboard-alert {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 0.95rem 1.1rem;
    margin-bottom: 1rem;
    border-left: 4px solid #9f1239;
    color: #374151;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0.85rem;
    margin-bottom: 1.35rem;
}

.stat-card {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.1rem 1.15rem;
    text-decoration: none;
    color: inherit;
    text-align: left;
    min-height: 124px;
    transition: border-color 0.15s ease, transform 0.15s ease;
    cursor: pointer;
    font: inherit;
    width: 100%;
}

.stat-card:hover {
    border-color: #cbd5e1;
    transform: translateY(-1px);
    color: inherit;
}

.stat-label {
    font-size: 0.82rem;
    color: var(--muted);
    font-weight: 500;
}

.stat-value {
    font-size: clamp(1.75rem, 3vw, 2.1rem);
    font-weight: 700;
    color: #111827;
    line-height: 1.1;
}

.stat-detail {
    font-size: 0.8rem;
    color: var(--muted);
    margin-top: auto;
}

.btn-accent-post {
    background: var(--burgundy);
    border-color: var(--burgundy);
    color: #fff;
    min-height: 42px;
    font-weight: 600;
    white-space: nowrap;
    flex: 0 0 auto;
}

.btn-accent-post:hover,
.btn-accent-post:focus {
    background: var(--burgundy-hover);
    border-color: var(--burgundy-hover);
    color: #fff;
}

.dashboard-section {
    margin-bottom: 1.5rem;
}

.dashboard-section-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 0.85rem;
    flex-wrap: wrap;
    margin-bottom: 0.85rem;
}

.dashboard-section-header h2 {
    margin: 0;
    font-size: 1.2rem;
    color: #111827;
}

.dashboard-section-header p {
    margin: 0.25rem 0 0;
    color: var(--muted);
    font-size: 0.9rem;
}

.dashboard-job-list {
    display: grid;
    gap: 0.65rem;
}

.dashboard-job-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto;
    gap: 0.85rem;
    align-items: center;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 0.95rem 1.1rem;
}

.dashboard-job-main {
    min-width: 0;
}

.dashboard-job-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    justify-content: flex-end;
}

@media (max-width: 991px) {
    .stats-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .dashboard-header {
        flex-wrap: wrap;
    }

    .dashboard-toolbar {
        width: auto;
        max-width: 100%;
    }

    .dashboard-search {
        width: 200px;
        flex: 1 1 180px;
        max-width: none;
    }
}

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

    .dashboard-header {
        align-items: stretch;
    }

    .dashboard-toolbar {
        width: 100%;
        flex-wrap: nowrap;
    }

    .dashboard-search {
        width: auto;
        flex: 1 1 auto;
        min-width: 0;
    }

    .btn-accent-post {
        width: auto;
        flex: 0 0 auto;
        padding-left: 0.85rem;
        padding-right: 0.85rem;
    }

    .dashboard-job-row {
        grid-template-columns: 1fr;
        align-items: start;
    }

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

.empty-state {
    text-align: center;
    padding: 2.5rem 1.25rem;
    color: var(--muted);
}

.empty-state h3 {
    color: var(--text);
    font-size: 1.1rem;
    margin-bottom: 0.35rem;
}

.table-loading {
    position: relative;
    min-height: 120px;
}

.table-loading::after {
    content: "";
    position: absolute;
    inset: 0;
    background: rgba(255,255,255,0.55);
    display: none;
    pointer-events: none;
    z-index: 2;
}

.table-loading.is-loading::after {
    display: block;
    pointer-events: auto;
    cursor: wait;
}

.spinner-inline {
    width: 1rem;
    height: 1rem;
    border: 2px solid rgba(255,255,255,0.4);
    border-top-color: #fff;
    border-radius: 50%;
    display: inline-block;
    animation: spin 0.7s linear infinite;
    vertical-align: -0.15rem;
    margin-right: 0.35rem;
}

@keyframes spin { to { transform: rotate(360deg); } }

.pagination-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.75rem;
    padding: 0.85rem 1rem;
    border-top: 1px solid var(--border);
    flex-wrap: wrap;
    background: #fff;
}

.job-cards {
    display: grid;
    gap: 1rem;
}

.jobs-board {
    min-height: 120px;
}

.jobs-board-inner {
    display: grid;
    gap: 1.75rem;
}

.jobs-day-section {
    display: grid;
    gap: 0.95rem;
}

.jobs-day-header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.75rem;
}

.jobs-day-label {
    margin: 0;
    font-size: 1.15rem;
    font-weight: 700;
    color: #151b28;
    letter-spacing: -0.01em;
}

.jobs-day-count {
    font-size: 0.84rem;
    color: var(--muted);
    white-space: nowrap;
}

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

.job-card {
    background: var(--card);
    border: 1px solid rgba(226, 232, 240, 0.95);
    border-radius: 14px;
    box-shadow: var(--shadow);
    padding: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: fadeIn 0.25s ease;
    transition: opacity 0.25s ease, filter 0.25s ease, transform 0.2s ease;
}

.job-card.is-taken {
    opacity: 0.58;
    filter: grayscale(0.28);
}

.job-card.is-claiming {
    opacity: 0.7;
    pointer-events: none;
}

.job-card.is-taken .btn-take {
    pointer-events: none;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(4px); }
    to { opacity: 1; transform: none; }
}

.job-card-thumb {
    position: relative;
    aspect-ratio: 4 / 3;
    background: #e8edf5;
    overflow: hidden;
}

.job-card-thumb-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.job-card-thumb-placeholder {
    width: 100%;
    height: 100%;
    display: grid;
    place-items: center;
    color: #94a3b8;
    font-size: 0.82rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    background: linear-gradient(135deg, #e8edf5 0%, #f1f5f9 100%);
}

.job-card-taken-badge {
    position: absolute;
    top: 0.55rem;
    left: 0.55rem;
    z-index: 2;
    background: rgba(17, 24, 39, 0.78);
    color: #fff;
    font-size: 0.7rem;
    font-weight: 600;
    padding: 0.2rem 0.5rem;
    border-radius: 999px;
    max-width: calc(100% - 1.1rem);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.job-card-body {
    display: grid;
    gap: 0.55rem;
    padding: 0.85rem 0.95rem 0.95rem;
    flex: 1;
}

.job-card-title,
.job-card h3 {
    margin: 0;
    font-size: 1rem;
    line-height: 1.3;
    color: #151b28;
    overflow-wrap: anywhere;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.job-card-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}

.meta-pill {
    display: inline-flex;
    align-items: center;
    padding: 0.2rem 0.55rem;
    border-radius: 999px;
    background: #f1f5f9;
    color: #475569;
    font-size: 0.74rem;
    font-weight: 600;
}

.job-card-desc,
.job-card p {
    margin: 0;
    color: #64748b;
    font-size: 0.88rem;
    line-height: 1.45;
    white-space: normal;
    overflow-wrap: anywhere;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    min-height: 2.55em;
}

.job-card-footer {
    display: grid;
    gap: 0.75rem;
    margin-top: auto;
    padding-top: 0.75rem;
    border-top: 1px solid #eef2f7;
}

.job-card-due-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.82rem;
    color: #475569;
}

.job-card-due-row .due-label {
    font-weight: 600;
    color: #334155;
}

.job-card-actions {
    display: flex;
    gap: 0.55rem;
    flex-wrap: wrap;
    align-items: center;
}

.job-card-actions .btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 40px;
    padding: 0.45rem 0.85rem;
    line-height: 1.2;
    flex: 1 1 auto;
    border-radius: 10px;
    font-weight: 600;
}

.job-card-actions .btn-outline-secondary {
    border-color: #d6dde8;
    color: #1f2937;
    background: #fff;
}

.job-card-actions .btn-outline-secondary:hover {
    background: #f8fafc;
    border-color: #cbd5e1;
    color: #111827;
}

.job-card-actions .btn-outline-danger {
    border-color: #fecdd3;
    color: #9f1239;
}

.job-card-actions.admin-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.55rem;
}

.job-card-actions.admin-actions .btn-delete {
    grid-column: 1 / -1;
}

.form-check-input:checked {
    background-color: var(--burgundy);
    border-color: var(--burgundy);
}

.form-check-input:focus {
    box-shadow: 0 0 0 0.2rem rgba(139, 30, 63, 0.2);
}

.job-details-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    align-items: center;
}

.job-details-section + .job-details-section {
    margin-top: 1.15rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}

.job-details-section h6 {
    margin: 0 0 0.4rem;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--muted);
}

.job-details-description {
    margin: 0;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    color: #1f2937;
}

.job-details-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 0.85rem;
}

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

.btn-primary:hover,
.btn-primary:focus {
    background: var(--accent-hover);
    border-color: var(--accent-hover);
}

.live-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #10b981;
    display: inline-block;
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.5);
    animation: pulse 2s infinite;
    margin-right: 0.35rem;
}

@keyframes pulse {
    0% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.45); }
    70% { box-shadow: 0 0 0 8px rgba(16, 185, 129, 0); }
    100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

.toast-container {
    max-width: min(360px, calc(100vw - 1.5rem));
    padding-top: max(1rem, var(--safe-top)) !important;
    pointer-events: none;
    z-index: 1080;
}

.toast-container .toast {
    pointer-events: auto;
}

/* Backdrop lives outside the grid; hidden unless mobile drawer is open */
.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.45);
    z-index: 35;
    pointer-events: none;
}

.sidebar-backdrop.is-visible {
    display: block;
    pointer-events: auto;
}

/* Tablet + mobile: drawer sidebar */
@media (max-width: 991.98px) {
    .app-shell {
        grid-template-columns: 1fr;
    }

    .app-sidebar {
        position: fixed;
        inset: 0 auto 0 0;
        width: min(300px, 86vw);
        z-index: 40;
        transform: translateX(-105%);
        transition: transform 0.22s ease;
        box-shadow: 8px 0 30px rgba(0,0,0,0.2);
        padding-top: max(1.25rem, var(--safe-top));
        padding-bottom: max(1.25rem, var(--safe-bottom));
    }

    .app-shell.sidebar-open .app-sidebar {
        transform: none;
    }

    .sidebar-close {
        display: inline-grid;
        place-items: center;
    }

    .topbar-menu-btn {
        display: inline-flex;
    }

    .topbar-title {
        display: block;
        flex: 1;
        min-width: 0;
    }

    .topbar-spacer {
        display: none;
    }

    .app-content {
        padding: 1rem;
    }

    .jobs-table .col-actions {
        width: 20%;
    }

    .page-header > .btn,
    .page-header > .d-flex,
    .page-header > .job-view-actions {
        width: 100%;
    }

    .page-header > .d-flex,
    .page-header > .job-view-actions {
        display: flex !important;
    }

    .page-header > .d-flex .btn,
    .page-header > .job-view-actions .btn {
        flex: 1;
    }

    .job-detail-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .job-detail-grid .value {
        font-size: 0.92rem;
    }

    .filter-actions {
        width: 100%;
    }

    .filter-actions .btn {
        flex: 1;
        min-height: 42px;
    }

    .job-detail-card {
        padding: 1rem;
    }

    .modal-dialog {
        margin: 0.75rem;
    }
}

/* Phones */
@media (max-width: 575.98px) {
    .job-detail-grid {
        grid-template-columns: 1fr;
    }

    .login-card {
        padding: 1.25rem;
        border-radius: 14px;
    }

    .app-topbar {
        padding-left: 0.75rem;
        padding-right: 0.75rem;
        gap: 0.5rem;
    }

    .menu-label {
        display: none;
    }

    .topbar-menu-btn {
        padding: 0.4rem 0.55rem;
    }

    .app-content {
        padding: 0.85rem;
        padding-bottom: max(1.25rem, calc(0.85rem + var(--safe-bottom)));
    }

    .page-header {
        margin-bottom: 0.85rem;
    }

    .filter-bar .card-body {
        padding: 0.85rem;
    }

    .jobs-day-grid {
        grid-template-columns: 1fr;
    }

    .job-card-actions {
        display: grid;
        grid-template-columns: 1fr 1fr;
    }

    .job-card-actions .btn {
        width: 100%;
        justify-content: center;
    }

    .attachment-gallery {
        grid-template-columns: 1fr 1fr;
    }

    .attachment-thumb img {
        height: 110px;
    }

    .pagination-bar {
        flex-direction: column;
        align-items: stretch;
        text-align: center;
    }

    .pagination-bar .btn-group {
        width: 100%;
    }

    .pagination-bar .btn-group .btn {
        flex: 1;
    }

    .notification-dropdown {
        width: calc(100vw - 1rem);
        max-width: calc(100vw - 1rem);
    }

    .table-shell .table,
    .jobs-table-shell .jobs-table {
        min-width: 620px;
    }

    .desc-cell {
        max-width: 160px;
    }

    /* Stack admin action buttons under title on very small cards */
    .action-btns .btn {
        min-height: 36px;
        padding: 0.25rem 0.55rem;
        font-size: 0.8rem;
    }
}

/* Prefer card-scroll hint under tables on touch */
@media (hover: none) and (max-width: 991.98px) {
    .table-shell .table-responsive {
        position: relative;
    }

    .table-shell .table-responsive::after {
        content: "Swipe to see more →";
        display: block;
        padding: 0.45rem 0.85rem;
        font-size: 0.75rem;
        color: var(--muted);
        background: #f8fafc;
        border-top: 1px solid var(--border);
    }
}
