* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Poppins', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

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

:root {
    --primary: #2563EB;
    --primary-dark: #1D4ED8;
    --secondary: #3B82F6;
    --text-primary: #0F172A;
    --text-secondary: #64748B;
    --bg-primary: #FFFFFF;
    --bg-secondary: #F8FAFC;
    --bg-tertiary: #F1F5F9;
    --border: #E2E8F0;
    --gradient: linear-gradient(135deg, #2563EB 0%, #3B82F6 100%);
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

body {
    font-family: 'Poppins', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif !important;
    color: var(--text-primary);
    line-height: 1.6;
    background-color: var(--bg-secondary);
    display: flex;
    min-height: 100%;
    min-height: 100dvh;
    height: 100%;
    max-height: 100dvh;
    overflow: hidden;
}

/* Sidebar */
.sidebar {
    width: 260px;
    background: var(--bg-primary);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    height: 100%;
    height: 100dvh;
    position: fixed;
    left: 0;
    top: 0;
    transition: width 0.3s ease;
}

.sidebar.collapsed {
    width: 80px;
}

.sidebar.collapsed .logo-text {
    opacity: 0;
    width: 0;
    overflow: hidden;
}

.sidebar.collapsed .sidebar-toggle svg {
    transform: rotate(180deg);
}

.sidebar.collapsed .nav-item span {
    opacity: 0;
    width: 0;
    overflow: hidden;
}

.sidebar.collapsed .nav-item {
    justify-content: center;
    padding: 12px;
}

.sidebar-header {
    padding: 24px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
    font-weight: 700;
    font-size: 20px;
    color: var(--text-primary);
    text-decoration: none;
}

.logo-text {
    background: var(--gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    white-space: nowrap;
    transition: opacity 0.2s;
}

.sidebar-nav {
    flex: 1;
    padding: 16px 0;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.sidebar-nav > a {
    flex-shrink: 0;
}

.sidebar-toggle {
    margin-top: auto;
    margin-left: 24px;
    margin-right: 24px;
    margin-bottom: 16px;
    width: calc(100% - 48px);
    height: 40px;
    border-radius: 8px;
    border: none;
    background: var(--bg-secondary);
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    flex-shrink: 0;
}

.sidebar-toggle:hover {
    background: var(--bg-tertiary);
    color: var(--primary);
}

.sidebar.collapsed .sidebar-toggle {
    margin-left: 16px;
    margin-right: 16px;
    width: calc(100% - 32px);
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 24px;
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 500;
    font-size: 15px;
    transition: all 0.2s;
    border-left: 3px solid transparent;
    position: relative;
}

.nav-item span {
    white-space: nowrap;
    transition: opacity 0.2s;
}

.sidebar.collapsed .nav-item {
    padding: 12px;
}

.nav-item:hover {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

.nav-item.active {
    background: var(--bg-secondary);
    color: var(--primary);
    border-left-color: var(--primary);
}

/* Main Content */
.main-content {
    flex: 1;
    margin-left: 260px;
    display: flex;
    flex-direction: column;
    min-height: 0;
    min-width: 0;
    height: 100%;
    max-height: 100dvh;
    overflow: hidden;
    transition: margin-left 0.3s ease;
}

.sidebar.collapsed ~ .main-content {
    margin-left: 80px;
}

.top-header {
    background: var(--bg-primary);
    border-bottom: 1px solid var(--border);
    padding: 14px clamp(16px, 3vw, 32px);
    position: sticky;
    top: 0;
    z-index: 100;
    flex-shrink: 0;
    overflow: visible;
}

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

.page-title {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-primary);
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 16px;
}

/* Header notifications bell */
.header-notifications-wrap {
    position: relative;
}

.header-notifications-btn {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg-secondary);
    color: var(--text-secondary);
    cursor: pointer;
    transition: background 0.2s, color 0.2s, border-color 0.2s;
}

.header-notifications-btn:hover {
    background: var(--bg-tertiary);
    color: var(--primary);
    border-color: var(--primary);
}

.header-notifications-icon {
    flex-shrink: 0;
}

.header-notifications-badge {
    position: absolute;
    top: 4px;
    right: 4px;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 9px;
    background: #DC2626;
    color: white;
    font-size: 11px;
    font-weight: 700;
    line-height: 18px;
    text-align: center;
}

.header-notifications-badge[hidden] {
    display: none !important;
}

/* Header notifications dropdown */
.header-dropdown-panel {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    width: min(360px, calc(100vw - 48px));
    max-height: min(420px, 70dvh);
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    z-index: 200;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.header-dropdown-panel[hidden] {
    display: none !important;
}

.header-notifications-panel {
    width: min(380px, calc(100vw - 48px));
}

.header-dropdown-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.header-dropdown-panel-title {
    margin: 0;
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
}

.header-dropdown-panel-action {
    padding: 0;
    border: none;
    background: none;
    font-size: 13px;
    font-weight: 500;
    color: var(--primary);
    cursor: pointer;
    font-family: inherit;
}

.header-dropdown-panel-action:hover {
    text-decoration: underline;
}

.header-notifications-list {
    list-style: none;
    margin: 0;
    padding: 8px 0;
    overflow-y: auto;
    flex: 1;
    min-height: 0;
}

.header-notification-item {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    transition: background 0.15s;
}

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

.header-notification-item.unread {
    background: rgba(37, 99, 235, 0.06);
}

.header-notification-meta {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 8px;
    margin-bottom: 4px;
}

.header-notification-dept {
    font-size: 12px;
    font-weight: 600;
    color: var(--primary);
}

.header-notification-time {
    font-size: 11px;
    color: var(--text-secondary);
    flex-shrink: 0;
}

.header-notification-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0 0 4px;
}

.header-notification-message {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.45;
    margin: 0;
}

.header-notifications-empty {
    margin: 0;
    padding: 24px 16px;
    text-align: center;
    font-size: 14px;
    color: var(--text-secondary);
}

.header-notifications-empty[hidden] {
    display: none !important;
}

.search-box {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--bg-secondary);
    padding: 10px 16px;
    border-radius: 8px;
    border: 1px solid var(--border);
    color: var(--text-secondary);
}

.search-box input {
    border: none;
    background: transparent;
    outline: none;
    font-size: 14px;
    color: var(--text-primary);
    width: 100%;
    min-width: 0;
    max-width: 250px;
}

.search-box input::placeholder {
    color: var(--text-secondary);
}

.user-menu {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 16px;
    background: var(--bg-secondary);
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s;
}

.user-menu:hover {
    background: var(--bg-tertiary);
}

.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
    font-size: 14px;
}

.user-name {
    font-weight: 500;
    font-size: 14px;
    color: var(--text-primary);
}

/* Content Sections — fill viewport below header; scroll when needed */
.content-section {
    display: none;
    flex: 1 1 auto;
    flex-direction: column;
    min-height: 0;
    min-width: 0;
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
    overflow-y: auto;
    padding: clamp(16px, 3vw, 32px);
    -webkit-overflow-scrolling: touch;
}

.content-section.active {
    display: flex;
}

/* Messages: internal panes handle scroll; section fills remaining height */
#messages.content-section.active {
    overflow: hidden;
    flex: 1 1 0%;
    min-height: 0;
}

/* Dashboard: same outer padding as Messages (from .content-section; do not override here). */
#dashboard.content-section {
    overflow: hidden;
    display: none;
    flex-direction: column;
    flex: 1 1 0%;
    min-height: 0;
    min-width: 0;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

#dashboard.content-section.active {
    display: flex;
    flex-direction: column;
    flex: 1 1 0%;
    min-height: 0;
}

/* Messages Section — three equal-width columns; gap scales with viewport */
.messages-container {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    align-items: stretch;
    gap: clamp(8px, 1.5vw, 20px);
    flex: 1 1 0%;
    min-height: 0;
    min-width: 0;
    width: 100%;
    max-width: 100%;
    align-self: stretch;
    transition: gap 0.2s ease;
}

.messages-sidebar {
    background: var(--bg-primary);
    border-radius: 12px;
    border: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-height: 0;
    min-width: 0;
}

.messages-header {
    height: 77px;
    padding: 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-sizing: border-box;
}

/* Messages section — aligned column headers (Conversations / active chat / Tasks) */
.messages-header h2,
.chat-header-info h2,
.tasks-column-header h2 {
    font-size: 18px;
    font-weight: 600;
    letter-spacing: -0.02em;
    color: var(--text-primary);
    margin: 0;
    line-height: 1.25;
}

.btn-icon {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    border: none;
    background: var(--bg-secondary);
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-icon:hover {
    background: var(--bg-tertiary);
    color: var(--primary);
}

.conversation-list {
    flex: 1;
    overflow-y: auto;
}

.conversation-item {
    display: flex;
    gap: 12px;
    padding: 16px 20px;
    cursor: pointer;
    transition: background 0.2s;
    border-left: 3px solid transparent;
}

.conversation-item:hover {
    background: var(--bg-secondary);
}

.conversation-item.active {
    background: var(--bg-secondary);
    border-left-color: var(--primary);
}

.conversation-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
    font-size: 16px;
    flex-shrink: 0;
}

.conversation-info {
    flex: 1;
    min-width: 0;
}

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

.conversation-name {
    font-weight: 600;
    font-size: 14px;
    color: var(--text-primary);
}

.conversation-time {
    font-size: 12px;
    color: var(--text-secondary);
}

.conversation-preview {
    font-size: 13px;
    color: var(--text-secondary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.messages-main {
    background: var(--bg-primary);
    border-radius: 12px;
    border: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-height: 0;
    min-width: 0;
}

.chat-header {
    padding: 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 77px;
    box-sizing: border-box;
}

.chat-header-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.chat-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
    font-size: 16px;
}

.chat-status {
    font-size: 13px;
    color: var(--text-secondary);
}

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

.conversation-filters {
    padding: 16px 20px;
    border-top: 1px solid var(--border);
    display: flex;
    gap: 8px;
}

.conversation-filters .search-box {
    flex: 1;
    min-width: 0;
}

.conversation-filters .search-box input {
    width: 100%;
    min-width: 0;
}

.filter-btn {
    flex: 1;
    padding: 10px 16px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--bg-secondary);
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
}

.filter-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--bg-tertiary);
}

.filter-btn.active {
    background: var(--gradient);
    border-color: var(--primary);
    color: white;
}

.messages-tasks-column {
    background: var(--bg-primary);
    border-radius: 12px;
    border: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-height: 0;
    min-width: 0;
}

.tasks-column-header {
    padding: 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
    height: 77px;
    box-sizing: border-box;
    gap: 8px;
    min-width: 0;
}

.tasks-column-header h2 {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
}

.tasks-column-header .btn {
    padding: 8px 16px;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}

.tasks-column-list {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.task-item {
    padding: 16px;
    background: var(--bg-secondary);
    border-radius: 8px;
    border: 1px solid var(--border);
    transition: all 0.2s;
}

.task-item:hover {
    background: var(--bg-tertiary);
    border-color: var(--primary);
}

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

.task-item-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
    flex: 1;
    min-width: 0;
    line-height: 1.4;
}

.task-item-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--border);
}

.task-item-priority {
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    flex-shrink: 0;
}

.task-item-priority.high {
    background: #FEE2E2;
    color: #DC2626;
}

.task-item-priority.medium {
    background: #FEF3C7;
    color: #D97706;
}

.task-item-priority.low {
    background: #D1FAE5;
    color: #059669;
}

.task-item-header .task-item-location {
    font-size: 13px;
    color: #DC2626;
    margin-bottom: 0;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 6px;
    flex-shrink: 0;
    text-align: right;
}

.task-item-header .task-item-location svg {
    flex-shrink: 0;
    color: #DC2626;
}

.task-item-description {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.5;
    margin-bottom: 8px;
}

.task-item-time {
    font-size: 12px;
    color: var(--text-secondary);
    flex-shrink: 0;
}

.task-item-actions {
    display: flex;
    justify-content: flex-end;
    flex-shrink: 0;
}

/* Modal Styles */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal-overlay.active {
    display: flex;
}

.modal-content {
    background: var(--bg-primary);
    border-radius: 12px;
    border: 1px solid var(--border);
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

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

.modal-header h3 {
    font-size: 20px;
    font-weight: 600;
    margin: 0;
    color: var(--text-primary);
}

.modal-close {
    width: 32px;
    height: 32px;
}

.task-creation-form {
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.modal-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    margin-top: 8px;
}

.modal-actions .btn {
    padding: 10px 20px;
    font-size: 14px;
}

/* File Upload Styles */
.file-upload-area {
    position: relative;
}

.file-upload-area input[type="file"] {
    position: absolute;
    opacity: 0;
    width: 100%;
    height: 100%;
    cursor: pointer;
    z-index: 2;
}

.file-upload-placeholder {
    border: 2px dashed var(--border);
    border-radius: 12px;
    padding: 48px 24px;
    text-align: center;
    transition: all 0.2s;
    cursor: pointer;
    background: var(--bg-secondary);
}

/* Compact file upload (upload document modal) */
.file-upload-area-compact .file-upload-placeholder {
    padding: 20px 16px;
}

.file-upload-area-compact .file-upload-placeholder svg {
    margin-bottom: 8px;
}

.file-upload-area-compact .file-upload-placeholder p {
    margin-bottom: 4px;
    font-size: 13px;
}

.file-upload-area-compact .file-upload-placeholder span {
    font-size: 11px;
}

.add-link-section .form-hint {
    display: block;
    margin-top: 6px;
    font-size: 12px;
    color: var(--text-secondary);
}

.file-upload-placeholder:hover {
    border-color: var(--primary);
    background: var(--bg-tertiary);
}

.file-upload-placeholder svg {
    color: var(--text-secondary);
    margin-bottom: 16px;
}

.file-upload-placeholder p {
    color: var(--text-primary);
    font-weight: 500;
    margin-bottom: 8px;
    font-size: 14px;
}

.file-upload-placeholder span {
    color: var(--text-secondary);
    font-size: 12px;
}

.file-upload-preview {
    border: 2px solid var(--border);
    border-radius: 12px;
    padding: 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--bg-secondary);
}

.file-upload-preview svg {
    color: var(--primary);
    flex-shrink: 0;
}

.file-upload-preview span {
    flex: 1;
    color: var(--text-primary);
    font-size: 14px;
    font-weight: 500;
}

.file-upload-area img.file-upload-preview,
.add-lf-photo-preview {
    max-width: 100%;
    max-height: 200px;
    object-fit: contain;
    border-radius: 8px;
    display: block;
    margin-top: 8px;
}

#remove-file-btn {
    margin-left: auto;
    color: var(--text-secondary);
}

#remove-file-btn:hover {
    color: #DC2626;
}

.chat-messages {
    flex: 0 0 auto;
    height: 696px;
    min-height: 0;
    overflow-y: auto;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.message {
    display: flex;
    gap: 12px;
    align-items: flex-start;
}

.message.sent {
    flex-direction: row-reverse;
}

.message-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
    font-size: 12px;
    flex-shrink: 0;
}

.message-content {
    max-width: 70%;
}

.message-bubble {
    padding: 12px 16px;
    border-radius: 12px;
    background: var(--bg-secondary);
    position: relative;
}

.message.sent .message-bubble {
    background: var(--gradient);
    color: white;
}

.message-bubble p {
    margin-bottom: 4px;
    font-size: 14px;
    line-height: 1.5;
}

.message-time {
    font-size: 11px;
    opacity: 0.7;
}

.chat-input {
    padding: 20px;
    border-top: 1px solid var(--border);
    display: flex;
    gap: 12px;
    align-items: center;
    height: 72px;
    box-sizing: border-box;
}

.chat-input input {
    flex: 1;
    padding: 12px 16px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
}

.chat-input input:focus {
    border-color: var(--primary);
}

.btn-send {
    width: 44px;
    height: 44px;
    border-radius: 8px;
    border: none;
    background: var(--gradient);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.2s;
}

.btn-send:hover {
    transform: scale(1.05);
}

/* Tasks Section */
.tasks-header {
    margin-bottom: 24px;
}

.tasks-header h2 {
    font-size: 24px;
    font-weight: 700;
}

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

.tasks-left,
.tasks-right {
    display: flex;
    flex-direction: column;
}

.tasks-toggle {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
    background: var(--bg-secondary);
    padding: 4px;
    border-radius: 8px;
}

.toggle-btn {
    flex: 1;
    padding: 10px 16px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 14px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
}

.toggle-btn:hover {
    color: var(--text-primary);
    background: var(--bg-tertiary);
}

.toggle-btn.active {
    background: var(--gradient);
    color: white;
}

.tasks-list {
    flex: 1;
    overflow-y: auto;
    max-height: calc(100vh - 300px);
}

.task-list-view {
    display: none;
    flex-direction: column;
    gap: 16px;
}

.task-list-view.active {
    display: flex;
}

.task-form-view {
    display: none;
}

.task-form-view.active {
    display: block;
}

.tasks-form-container {
    flex: 1;
    overflow-y: auto;
    max-height: calc(100vh - 300px);
}

.task-card {
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 24px;
    transition: all 0.2s;
}

.task-card:hover {
    box-shadow: var(--shadow-lg);
    transform: translateY(-2px);
}

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

.task-priority {
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
}

.task-priority.high {
    background: #FEE2E2;
    color: #DC2626;
}

.task-priority.medium {
    background: #FEF3C7;
    color: #D97706;
}

.task-priority.low {
    background: #D1FAE5;
    color: #059669;
}

.task-id {
    font-size: 12px;
    color: var(--text-secondary);
    font-weight: 500;
}

.task-title {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.task-description {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 16px;
    line-height: 1.5;
}


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

.task-card.completed {
    opacity: 0.8;
    background: var(--bg-secondary);
}

.task-status-badge {
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
}

.completed-badge {
    background: #D1FAE5;
    color: #059669;
}

/* Task Form */
.form-card {
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 24px;
}

.form-card h3 {
    font-size: 20px;
    font-weight: 600;
    margin-bottom: 24px;
    color: var(--text-primary);
}

.task-form {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.form-group label {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}

.form-group input,
.form-group textarea,
.form-group select {
    padding: 10px 16px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    color: var(--text-primary);
    background: var(--bg-primary);
    outline: none;
    transition: border-color 0.2s;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    border-color: var(--primary);
}

.form-group textarea {
    resize: vertical;
    min-height: 100px;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.form-actions {
    display: flex;
    gap: 12px;
    margin-top: 8px;
}

/* Tasks Assigned by Me */
.assigned-tasks-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.task-card-small {
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 16px;
    transition: all 0.2s;
}

.task-card-small:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}

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

.task-title-small {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 6px;
    color: var(--text-primary);
}

.task-description-small {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 12px;
    line-height: 1.5;
}


.btn-small {
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-small.btn-primary {
    background: var(--gradient);
    color: white;
}

.btn-small.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn-small.btn-outline {
    background: transparent;
    color: var(--text-primary);
    border: 1px solid var(--border);
}

.btn-small.btn-outline:hover {
    border-color: var(--primary);
    color: var(--primary);
}

/* Lost & Found Section */
.lost-found-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.lost-found-header h2 {
    font-size: 24px;
    font-weight: 700;
}

.lost-found-container {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.lost-found-filters {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px 20px;
    background: white;
    border-radius: 12px;
    border: 1px solid var(--border);
}

#users .lost-found-filters {
    margin-bottom: 24px;
}

#settings .lost-found-filters {
    height: 72px;
    margin-bottom: 24px;
    justify-content: space-between;
}

#settings .lost-found-filters .settings-nav-item {
    display: inline-block;
    margin-left: 8px;
}

#settings .lost-found-filters .settings-nav-item:first-of-type {
    margin-left: auto;
}

.lost-found-filters h2 {
    font-size: 24px;
    font-weight: 700;
    margin: 0;
    flex-shrink: 0;
}

.lost-found-filters .header-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
    margin-left: auto;
}

.lost-found-filters .sort-by-label {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
    margin: 0;
    margin-left: auto;
    white-space: nowrap;
}

.lost-found-filters .header-actions .sort-by-dropdown {
    margin-right: 10px;
}

.lost-found-filters .sort-by-dropdown {
    width: 250px;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: white;
    color: var(--text-primary);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg width='12' height='8' viewBox='0 0 12 8' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1L6 6L11 1' stroke='%23666' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
    margin-left: auto;
}

.lost-found-filters .sort-by-dropdown:hover {
    border-color: var(--primary);
}

.lost-found-filters .sort-by-dropdown:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.filter-tabs {
    display: flex;
    gap: 8px;
}

.filter-tab {
    padding: 8px 16px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 14px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

.filter-tab:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.filter-tab.active {
    background: var(--gradient);
    color: white;
}

.status-filter {
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg-primary);
    font-size: 14px;
    color: var(--text-primary);
    cursor: pointer;
}

.lost-found-list {
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
}

.list-header {
    display: grid;
    grid-template-columns: 100px 1.5fr 2fr 1fr 100px 1.2fr 1.2fr 1.5fr 1.5fr 80px;
    gap: 16px;
    padding: 12px 20px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    align-items: center;
}

.knowledge-base-list .list-header {
    grid-template-columns: 300px 1.5fr 1fr 1fr 80px;
}

.knowledge-base-list .list-item {
    grid-template-columns: 300px 1.5fr 1fr 1fr 80px;
}

#tasks-list .list-header {
    grid-template-columns: 100px 100px 1.5fr 2fr 1fr 1.2fr 1.2fr 1.5fr 1.5fr;
}

#tasks-list .list-item {
    grid-template-columns: 100px 100px 1.5fr 2fr 1fr 1.2fr 1.2fr 1.5fr 1.5fr;
    cursor: pointer;
}

#lost-found .lost-found-list .list-header {
    grid-template-columns: 80px 100px 1.5fr 2fr 1fr 1.2fr 1.5fr 1.5fr 80px;
}

#lost-found .lost-found-list .list-item {
    grid-template-columns: 80px 100px 1.5fr 2fr 1fr 1.2fr 1.5fr 1.5fr 80px;
}

#shift-notes-list .list-header {
    grid-template-columns: 120px 120px 120px 1fr;
}

#shift-notes-list .list-item {
    grid-template-columns: 120px 120px 120px 1fr;
}

/* Match site list/table text: meta columns + name + description */
#shift-notes-list .item-shift {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
}

#shift-notes-list .item-user {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}

#shift-notes-list .item-note {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.5;
}

.shift-notes-date-nav {
    display: flex;
    align-items: center;
    gap: 8px;
}

.shift-notes-date-display {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
    min-width: 140px;
    text-align: center;
}

.header-cell {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.header-cell.sortable {
    cursor: pointer;
    user-select: none;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: color 0.2s;
}

.header-cell.sortable:hover {
    color: var(--primary);
}

.header-cell.sortable.active {
    color: var(--primary);
}

.sort-indicator {
    width: 12px;
    height: 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.2s;
}

.header-cell.sortable:hover .sort-indicator,
.header-cell.sortable.active .sort-indicator {
    opacity: 0.5;
}

.header-cell.sortable.active .sort-indicator {
    opacity: 1;
}

.sort-indicator::before {
    content: '⇅';
    font-size: 12px;
    line-height: 1;
}

.header-cell.sortable.active.asc .sort-indicator::before {
    content: '↑';
}

.header-cell.sortable.active.desc .sort-indicator::before {
    content: '↓';
}

.list-item {
    display: grid;
    grid-template-columns: 100px 1.5fr 2fr 1fr 100px 1.2fr 1.2fr 1.5fr 1.5fr 80px;
    gap: 16px;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    align-items: center;
    transition: background 0.2s;
}

.knowledge-base-list .list-item {
    grid-template-columns: 300px 1.5fr 1fr 1fr 80px;
}

.list-item:hover {
    background: var(--bg-secondary);
}

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

.item-name {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 14px;
}

.item-description {
    color: var(--text-secondary);
    font-size: 13px;
}

.item-location {
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 500;
}

.item-department {
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 500;
}

.item-date {
    color: var(--text-secondary);
    font-size: 12px;
}

.item-task-number,
.item-number {
    font-weight: 600;
    color: var(--primary);
    font-size: 13px;
}

.item-assigned-by,
.item-assigned-to {
    color: var(--text-secondary);
    font-size: 12px;
}

.item-created,
.item-completed {
    color: var(--text-secondary);
    font-size: 12px;
}

.item-claimed,
.item-created-by {
    color: var(--text-secondary);
    font-size: 12px;
}

.task-details-notes {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 2px solid var(--border);
}

.task-details-notes-label {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 14px;
    margin-bottom: 8px;
}

.task-details-notes-content {
    color: var(--text-secondary);
    font-size: 14px;
    line-height: 1.6;
    white-space: pre-wrap;
}

.btn-icon-small {
    width: 32px;
    height: 32px;
    padding: 0;
    border: none;
    background: var(--bg-secondary);
    color: var(--text-secondary);
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-icon-small:hover {
    background: var(--bg-tertiary);
    color: var(--primary);
}

.task-details-content {
    padding: 24px;
}

.task-details-row {
    display: flex;
    justify-content: space-between;
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
}

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

.task-details-label {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 14px;
}

.task-details-value {
    color: var(--text-secondary);
    font-size: 14px;
    text-align: right;
}

.task-details-value-pre {
    white-space: pre-wrap;
}

.item-status {
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    text-align: center;
    width: fit-content;
}

.item-status.lost {
    background: #FEE2E2;
    color: #DC2626;
}

.item-status.found {
    background: #DBEAFE;
    color: #2563EB;
}

.item-status.claimed {
    background: #D1FAE5;
    color: #059669;
}

.item-status.high {
    background: #FEE2E2;
    color: #DC2626;
}

.item-status.medium {
    background: #FEF3C7;
    color: #D97706;
}

.item-status.low {
    background: #D1FAE5;
    color: #059669;
}

.item-status.completed {
    background: #D1FAE5;
    color: #059669;
}

.item-status.in-progress {
    background: #DBEAFE;
    color: #2563EB;
}

.item-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

#lost-found .lost-found-list .item-actions,
.knowledge-base-list .item-actions,
#shift-notes-list .item-actions {
    justify-content: flex-start;
}

.completed-text {
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 500;
}

/* Users Section */
.users-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.users-header h2 {
    font-size: 24px;
    font-weight: 700;
}

.users-table-container {
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
}

.users-table {
    width: 100%;
    border-collapse: collapse;
}

.users-table thead {
    background: var(--bg-secondary);
}

.users-table th {
    padding: 16px 24px;
    text-align: left;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.users-table tbody tr {
    border-top: 1px solid var(--border);
    transition: background 0.2s;
}

.users-table tbody tr:hover {
    background: var(--bg-secondary);
}

.users-table td {
    padding: 16px 24px;
    font-size: 14px;
}

.user-cell {
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-name {
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 2px;
}

.user-email {
    font-size: 13px;
    color: var(--text-secondary);
}

.badge {
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
}

.badge-admin {
    background: #DBEAFE;
    color: #1E40AF;
}

.badge-user {
    background: #E0E7FF;
    color: #4338CA;
}

.status-badge {
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
}

.status-badge.active {
    background: #D1FAE5;
    color: #059669;
}

.status-badge.inactive {
    background: #FEE2E2;
    color: #DC2626;
}

.action-buttons {
    display: flex;
    gap: 8px;
}

.btn-icon-small {
    width: 32px;
    height: 32px;
    border-radius: 6px;
    border: none;
    background: var(--bg-secondary);
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-icon-small:hover {
    background: var(--bg-tertiary);
    color: var(--primary);
}

/* Settings Section */
.settings-header {
    margin-bottom: 24px;
}

.settings-header h2 {
    font-size: 24px;
    font-weight: 700;
}

.settings-container {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.settings-nav {
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 8px;
    display: flex;
    gap: 8px;
    width: fit-content;
}

.settings-nav-item {
    display: block;
    padding: 10px 20px;
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 600;
    font-size: 14px;
    border-radius: 8px;
    transition: all 0.2s;
    white-space: nowrap;
}

.settings-nav-item:hover {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

.settings-nav-item.active {
    background: var(--gradient);
    color: white;
}

.settings-content {
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 32px;
}

.settings-panel {
    display: none;
}

.settings-panel.active {
    display: block;
}

.settings-panel .btn.btn-primary {
    margin-top: 24px;
}

.settings-panel h3 {
    font-size: 20px;
    font-weight: 600;
    margin-bottom: 24px;
}

.settings-single-page .settings-section-title {
    font-size: 20px;
    font-weight: 600;
    margin-bottom: 24px;
}

.settings-single-page .settings-section-title:not(:first-child) {
    margin-top: 32px;
}

.settings-single-page .btn.btn-primary {
    margin-top: 24px;
}

.setting-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 24px 0;
    border-bottom: 1px solid var(--border);
}

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

.setting-info {
    flex: 1;
}

.setting-info label {
    display: block;
    font-weight: 600;
    font-size: 14px;
    margin-bottom: 4px;
    color: var(--text-primary);
}

.setting-info p {
    font-size: 13px;
    color: var(--text-secondary);
}

.setting-input {
    padding: 10px 16px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    color: var(--text-primary);
    background: var(--bg-primary);
    min-width: 200px;
    outline: none;
    transition: border-color 0.2s;
}

.setting-input:focus {
    border-color: var(--primary);
}

/* Days off (push notifications) — weekday chips */
.setting-item--days-off {
    flex-direction: column;
    align-items: stretch;
    gap: 16px;
}

.setting-item--days-off .setting-info {
    flex: none;
}

.days-off-select {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: flex-start;
}

.days-off-chip {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin: 0;
    padding: 8px 12px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
    user-select: none;
    transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

.days-off-chip:hover {
    border-color: var(--primary);
    color: var(--text-primary);
}

.days-off-chip input {
    position: absolute;
    inset: 0;
    margin: 0;
    opacity: 0;
    cursor: pointer;
    width: 100%;
    height: 100%;
}

.days-off-chip:focus-within {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

.days-off-chip:has(input:checked) {
    background: rgba(37, 99, 235, 0.08);
    border-color: var(--primary);
    color: var(--primary);
}

.setting-item--days-off-muted .days-off-select {
    opacity: 0.55;
    pointer-events: none;
}

@media (min-width: 720px) {
    .setting-item--days-off {
        flex-direction: row;
        align-items: flex-start;
        justify-content: space-between;
        gap: 24px;
    }

    .setting-item--days-off .days-off-select {
        flex: 1;
        justify-content: flex-end;
        max-width: min(100%, 520px);
    }
}

.toggle-switch {
    position: relative;
    display: inline-block;
    width: 48px;
    height: 24px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-switch .toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--border);
    transition: 0.3s;
    border-radius: 24px;
}

.toggle-switch .toggle-slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: 0.3s;
    border-radius: 50%;
}

.toggle-switch input:checked + .toggle-slider {
    background: var(--gradient);
}

.toggle-switch input:checked + .toggle-slider:before {
    transform: translateX(24px);
}

.integration-item-setting {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 24px;
    border: 1px solid var(--border);
    border-radius: 12px;
    margin-bottom: 16px;
}

.integration-info {
    display: flex;
    align-items: center;
    gap: 16px;
}

.integration-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    background: var(--bg-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 14px;
    color: var(--text-primary);
}

.integration-info h4 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 4px;
}

.integration-info p {
    font-size: 13px;
    color: var(--text-secondary);
}

.btn {
    padding: 10px 20px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 14px;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.btn-primary {
    background: var(--gradient);
    color: white;
    box-shadow: var(--shadow-md);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.btn-success {
    background: linear-gradient(135deg, #10B981 0%, #059669 100%);
    color: white;
    box-shadow: var(--shadow-md);
}

.btn-success:hover {
    background: linear-gradient(135deg, #059669 0%, #047857 100%);
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.btn-outline {
    background: transparent;
    color: var(--text-primary);
    border: 1px solid var(--border);
}

.btn-outline:hover {
    border-color: var(--primary);
    color: var(--primary);
}

/* Responsive */
@media (max-width: 1024px) {
    .messages-container {
        gap: clamp(6px, 1.5vw, 14px);
    }

    .lost-found-container {
        max-width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

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

    .settings-nav {
        display: flex;
        gap: 8px;
        overflow-x: auto;
    }
}

/* Messages: stack into three equal-height rows */
@media (max-width: 900px) {
    #messages .messages-container {
        grid-template-columns: 1fr;
        grid-template-rows: repeat(3, minmax(0, 1fr));
        min-height: 0;
        flex: 1 1 0%;
        align-self: stretch;
    }
}

@media (max-width: 768px) {
    .content-section {
        padding: 12px;
    }

    .header-content {
        flex-wrap: wrap;
        gap: 10px;
    }

    .page-title {
        font-size: clamp(18px, 5vw, 22px);
    }

    .header-actions {
        flex-wrap: wrap;
        justify-content: flex-end;
        gap: 10px;
    }

    .search-box {
        max-width: 100%;
        flex: 1 1 160px;
    }

    .search-box input {
        max-width: none;
    }

    .sidebar {
        width: 80px;
    }

    .sidebar .logo-text {
        display: none;
    }

    .nav-item span {
        display: none;
    }

    .main-content {
        margin-left: 80px;
    }

    .tasks-container {
        grid-template-columns: 1fr;
    }
    
    .form-row {
        grid-template-columns: 1fr;
    }

    .list-item {
        grid-template-columns: 1fr;
        gap: 8px;
        text-align: left;
    }

    .item-actions {
        justify-content: flex-start;
    }

    .analytics-grid {
        grid-template-columns: 1fr;
    }

    .chart-container {
        grid-template-columns: 1fr;
    }

    .chart-card {
        min-width: 100%;
    }

    .chart-bars {
        gap: 4px;
    }

    .chart-bar-wrapper {
        gap: 4px;
    }

    .chart-value {
        font-size: 10px;
    }

    .chart-labels {
        font-size: 10px;
        gap: 4px;
    }

    .chart-bars-container {
        height: 250px;
    }

    .chart-bars {
        gap: 4px;
    }

    .chart-bar-wrapper {
        gap: 4px;
    }

    .chart-value {
        font-size: 10px;
    }

    .chart-labels {
        font-size: 10px;
        gap: 4px;
    }
}

/* Styles for hourly charts with many bars */
.chart-placeholder:has(.chart-bars .chart-bar-wrapper:nth-child(20)) {
    overflow-x: auto;
}

.chart-placeholder:has(.chart-bars .chart-bar-wrapper:nth-child(20)) .chart-bars-container {
    min-width: 800px;
}

.chart-placeholder:has(.chart-bars .chart-bar-wrapper:nth-child(20)) .chart-bars {
    gap: 4px;
}

.chart-placeholder:has(.chart-bars .chart-bar-wrapper:nth-child(20)) .chart-bar {
    min-width: 6px;
    max-width: 24px;
}

.chart-placeholder:has(.chart-bars .chart-bar-wrapper:nth-child(20)) .chart-labels {
    min-width: 800px;
    font-size: 10px;
}

.chart-placeholder:has(.chart-bars .chart-bar-wrapper:nth-child(20)) .chart-value {
    font-size: 10px;
}

/* Dashboard Section — sole child of #dashboard; fills padded area of .content-section */
#dashboard.content-section > .dashboard-container {
    display: flex;
    flex-direction: column;
    flex: 1 1 0%;
    align-self: stretch;
    align-items: stretch;
    min-height: 0;
    min-width: 0;
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    padding-bottom: env(safe-area-inset-bottom, 0);
    box-sizing: border-box;
}

/* Manager analytics — fills .dashboard-container; chart rows absorb extra height */
.manager-analytics {
    display: flex;
    flex-direction: column;
    gap: clamp(10px, 2.2vw, 16px);
    width: 100%;
    max-width: 100%;
    min-width: 0;
    min-height: 0;
    box-sizing: border-box;
    flex: 1 1 0%;
    align-self: stretch;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: clamp(12px, 2.5vw, 20px) clamp(14px, 3vw, 28px) clamp(14px, 3vw, 24px);
}

.manager-analytics-header,
.analytics-kpi-strip {
    flex-shrink: 0;
}

.manager-analytics-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    flex-wrap: wrap;
    min-width: 0;
}

.manager-analytics-title {
    font-size: clamp(1.1rem, 2.8vw, 1.35rem);
    font-weight: 700;
    color: var(--text-primary);
    margin: 0 0 4px;
    letter-spacing: -0.02em;
    word-break: break-word;
}

.manager-analytics-subtitle {
    font-size: clamp(12px, 2.5vw, 13px);
    color: var(--text-secondary);
    margin: 0;
    line-height: 1.4;
}

.manager-analytics-badge {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--primary);
    background: rgba(37, 99, 235, 0.08);
    border: 1px solid rgba(37, 99, 235, 0.2);
    padding: 6px 10px;
    border-radius: 8px;
    white-space: nowrap;
}

/* KPI strip */
.analytics-kpi-strip {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: clamp(8px, 2vw, 12px);
    margin-top: clamp(8px, 1.5vw, 18px);
    min-width: 0;
}

.analytics-kpi-card {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    padding: 14px 16px;
    background: linear-gradient(145deg, var(--bg-secondary) 0%, var(--bg-primary) 100%);
    border: 1px solid var(--border);
    border-radius: 12px;
    min-width: 0;
    box-shadow: var(--shadow-sm);
}

.analytics-kpi-body {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.analytics-kpi-label {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
    line-height: 1.3;
}

.analytics-kpi-value {
    font-size: clamp(1.5rem, 2.8vw, 1.85rem);
    font-weight: 800;
    color: var(--text-primary);
    letter-spacing: -0.03em;
    line-height: 1.15;
}

.analytics-kpi-delta {
    font-size: 11px;
    color: var(--text-secondary);
    margin-top: 2px;
}

.analytics-kpi-delta--up {
    color: #059669;
    font-weight: 600;
}

/* Chart rows — grow to use remaining viewport height inside .manager-analytics */
.analytics-charts-row,
.analytics-insights-row {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    /* One row fills flex height; 1024px breakpoint switches to two equal rows */
    grid-template-rows: minmax(0, 1fr);
    gap: clamp(10px, 2vw, 14px);
    margin-top: clamp(8px, 1.5vw, 14px);
    min-width: 0;
    min-height: 0;
    width: 100%;
    flex: 1 1 0%;
    align-items: stretch;
    align-content: stretch;
}

.analytics-chart-panel {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: clamp(12px, 2.5vw, 16px) clamp(14px, 2.5vw, 18px) clamp(14px, 2.5vw, 18px);
    min-width: 0;
    min-height: 0;
    max-width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    gap: 12px;
    box-sizing: border-box;
    flex: 1 1 0%;
}

.analytics-chart-panel--compact {
    padding-bottom: 16px;
    justify-content: flex-start;
}

.analytics-chart-panel-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    flex-wrap: wrap;
    flex-shrink: 0;
}

.analytics-chart-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
    letter-spacing: -0.02em;
}

.analytics-chart-caption {
    font-size: 12px;
    color: var(--text-secondary);
    margin: 4px 0 0;
}

.analytics-time-hero {
    font-size: 22px;
    font-weight: 800;
    color: var(--primary);
    letter-spacing: -0.03em;
}

/* Mini bar charts — expand with available panel height */
.mini-chart {
    width: 100%;
    flex: 1 1 auto;
    min-height: 0;
}

.mini-chart:not(.mini-chart--messages) {
    display: flex;
    flex-direction: column;
}

.mini-chart--messages {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
}

.mini-chart-plot {
    min-width: 0;
    max-width: 100%;
    min-height: 0;
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
}

.mini-chart.mini-chart--grouped {
    flex: 1 1 auto;
    min-height: 0;
}

.mini-chart-bars {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: clamp(2px, 1vw, 6px);
    flex: 1 1 auto;
    min-height: clamp(100px, 18vh, 200px);
    min-width: min(100%, 260px);
    padding: 0 4px 0 0;
    border-bottom: 1px solid var(--border);
}

/* Stretch columns so --bar-pct height percentages resolve against the plot area */
.mini-chart-bars--single {
    align-items: stretch;
}

.mini-chart-bars--hours .mini-chart-bar-col {
    display: grid;
    grid-template-rows: minmax(0, 1fr) auto;
    gap: 6px;
    align-items: stretch;
    justify-items: center;
    min-height: 0;
}

.mini-chart-bars--hours .mini-chart-bar {
    align-self: end;
    width: 100%;
}

.mini-chart-bars--departments .mini-chart-bar-col {
    display: grid;
    grid-template-rows: auto minmax(0, 1fr) auto;
    gap: 6px;
    align-items: center;
    justify-items: center;
    min-height: 0;
}

.mini-chart-bars--departments .mini-chart-bar {
    align-self: end;
}

.mini-chart-bars--grouped {
    min-height: clamp(96px, 16vh, 180px);
    min-width: min(100%, 280px);
}

.mini-chart-bar-col {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.mini-chart-bar-col--pair {
    min-width: 0;
}

.mini-chart-bars--single .mini-chart-bar-col {
    gap: 6px;
}

.mini-chart-bars--single .mini-chart-bar-value {
    font-size: 10px;
    font-weight: 700;
    color: var(--text-secondary);
    line-height: 1;
    white-space: nowrap;
}

.mini-chart-bars--single .mini-chart-bar-value--peak {
    color: var(--primary);
}

.mini-chart-bars--departments {
    min-width: min(100%, 400px);
    gap: 12px;
    justify-content: space-between;
    border-bottom: none;
}

.mini-chart-x--dept {
    font-size: 8px;
    font-weight: 600;
    color: var(--text-secondary);
    text-align: center;
    line-height: 1.15;
    letter-spacing: -0.02em;
    max-width: 100%;
    white-space: nowrap;
}

@media (min-width: 1000px) {
    .mini-chart-x--dept {
        font-size: 9px;
    }
}

.mini-chart--departments .mini-chart-bar {
    max-width: 18px;
    min-width: 14px;
    background: #2563eb;
    border: none;
    box-shadow: none;
    border-radius: 3px 3px 2px 2px;
    transition: none;
}

.mini-chart-bars--hours {
    min-width: min(100%, 640px);
    gap: 2px;
    border-bottom: none;
}

.mini-chart--hours .mini-chart-bar {
    max-width: 100%;
    min-width: 3px;
    background: #2563eb;
    border: none;
    box-shadow: none;
    border-radius: 3px 3px 2px 2px;
    transition: none;
}

.mini-chart-x--hour {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    gap: 0;
    font-size: 7px;
    font-weight: 600;
    color: var(--text-secondary);
    line-height: 1.05;
    text-align: center;
}

.mini-chart-x--hour .hour-num {
    font-weight: 700;
}

.mini-chart-x--hour .hour-ampm {
    font-size: 0.65em;
    font-weight: 600;
    letter-spacing: 0.02em;
}

.mini-chart-x--hour.today {
    color: var(--primary);
}

@media (min-width: 1000px) {
    .mini-chart-x--hour {
        font-size: 8px;
    }
}

.mini-chart-bar-pair {
    display: flex;
    align-items: flex-end;
    justify-content: center;
    gap: 3px;
    height: 100%;
    width: 100%;
}

.mini-chart-bar {
    width: 100%;
    max-width: 28px;
    height: var(--bar-pct, 50%);
    min-height: 6px;
    border-radius: 6px 6px 2px 2px;
    background: linear-gradient(180deg, #2563eb 0%, #93c5fd 100%);
    transition: transform 0.15s ease;
}

@media (prefers-reduced-motion: no-preference) {
    .mini-chart-bars--single .mini-chart-bar:hover {
        transform: scaleY(1.02);
    }

    .mini-chart-bars--single.mini-chart-bars--hours .mini-chart-bar:hover {
        transform: none;
    }

    .mini-chart-bars--single.mini-chart-bars--departments .mini-chart-bar:hover {
        transform: none;
    }
}

.mini-chart-bar--peak {
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.35);
}

.mini-chart-bar--assigned {
    max-width: 14px;
    background: linear-gradient(180deg, #2563eb 0%, #60a5fa 100%);
}

.mini-chart-bar--done {
    max-width: 14px;
    background: linear-gradient(180deg, #059669 0%, #34d399 100%);
}

.mini-chart-x {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
}

.mini-chart-x.today {
    color: var(--primary);
}

.mini-chart-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    font-size: 11px;
    color: var(--text-secondary);
}

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

.mini-chart-legend-swatch {
    width: 10px;
    height: 10px;
    border-radius: 2px;
    display: inline-block;
}

.mini-chart-legend-swatch--assigned {
    background: linear-gradient(180deg, #2563eb, #60a5fa);
}

.mini-chart-legend-swatch--done {
    background: linear-gradient(180deg, #059669, #34d399);
}

/* Compare bars (weekly load) */
.analytics-compare-bars {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 4px;
}

.analytics-compare-item {
    display: grid;
    grid-template-columns: minmax(72px, auto) minmax(0, 1fr) minmax(28px, auto);
    align-items: center;
    gap: clamp(6px, 2vw, 10px);
    font-size: 12px;
    min-width: 0;
}

.analytics-compare-label {
    color: var(--text-secondary);
    font-weight: 500;
}

.analytics-compare-track {
    height: 10px;
    background: var(--bg-tertiary);
    border-radius: 6px;
    overflow: hidden;
}

.analytics-compare-fill {
    height: 100%;
    border-radius: 6px;
    background: var(--gradient);
    transition: width 0.3s ease;
}

.analytics-compare-fill--muted {
    background: linear-gradient(90deg, #94a3b8 0%, #cbd5e1 100%);
}

.analytics-compare-num {
    font-weight: 700;
    color: var(--text-primary);
    text-align: right;
}

/* Time distribution strip */
.analytics-time-distribution {
    margin-top: 4px;
}

.analytics-time-bar {
    display: flex;
    height: 14px;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.06);
}

.analytics-time-seg {
    display: block;
    height: 100%;
    min-width: 4px;
}

.analytics-time-seg--fast {
    background: linear-gradient(90deg, #1d4ed8 0%, #3b82f6 100%);
}

.analytics-time-seg--mid {
    background: linear-gradient(90deg, #059669 0%, #34d399 100%);
}

.analytics-time-seg--slow {
    background: linear-gradient(90deg, #d97706 0%, #fbbf24 100%);
}

.analytics-time-legend {
    list-style: none;
    margin: 12px 0 0;
    padding: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 10px 16px;
    font-size: 11px;
    color: var(--text-secondary);
}

.analytics-time-legend li {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.analytics-time-legend strong {
    color: var(--text-primary);
    font-weight: 700;
}

.analytics-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.analytics-dot--blue {
    background: #3b82f6;
}

.analytics-dot--green {
    background: #34d399;
}

.analytics-dot--amber {
    background: #fbbf24;
}

/* Shared compact nav buttons (e.g. shift notes date arrows) */
.events-nav-btn {
    width: 32px;
    height: 32px;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg-primary);
    color: var(--text-secondary);
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.events-nav-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--bg-tertiary);
}

/* Responsive adjustments for Dashboard */
@media (max-width: 1024px) {
    .analytics-charts-row,
    .analytics-insights-row {
        grid-template-columns: 1fr;
        grid-template-rows: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 768px) {
    .analytics-kpi-strip {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .analytics-compare-item {
        grid-template-columns: 1fr minmax(0, 1fr) auto;
    }
}

@media (max-width: 480px) {
    .analytics-kpi-strip {
        grid-template-columns: 1fr;
    }

    .analytics-chart-panel-head {
        flex-direction: column;
        align-items: flex-start;
    }

    .analytics-compare-item {
        display: flex;
        flex-direction: column;
        align-items: stretch;
        gap: 6px;
    }

    .analytics-compare-num {
        align-self: flex-end;
    }
}
