body { font-family: 'Sarabun', 'Inter', sans-serif; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.fade-in { animation: fadeIn 0.5s ease-in-out forwards; }
.chart-container { position: relative; height: 40vh; width: 100%; }
.tab-active { border-color: #ef4444; color: #ef4444; background-color: rgba(239, 68, 68, 0.1); }
.drag-handle { cursor: move; }
.sortable-ghost { opacity: 0.4; background-color: #374151; }
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: #1f2937; border-radius: 10px; }
::-webkit-scrollbar-thumb { background: #4b5563; border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: #6b7280; }
#sidebar { transition: transform 0.3s ease-in-out; }
.calendar-scroll-area {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 0.5rem;
}
.calendar-scroll-content {
    min-width: 720px;
}
.calendar-grid-wrapper {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    min-width: 720px;
}
.responsive-calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, minmax(110px, 1fr));
    gap: 0.5rem;
    min-width: 720px;
}
.calendar-day-headers {
    display: grid;
    grid-template-columns: repeat(7, minmax(110px, 1fr));
    gap: 0.5rem;
    text-align: center;
    min-width: 720px;
}
.calendar-cell {
    min-height: 7rem;
    border-radius: 0.75rem;
    border: 1px solid #374151;
    background: rgba(31,41,55,0.5);
    padding: 0.6rem;
    display: flex;
    flex-direction: column;
}
.calendar-cell--today {
    border-color: #ef4444;
    background: rgba(239,68,68,0.12);
}
.calendar-cell__tasks {
    margin-top: 0.4rem;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    overflow-y: auto;
    max-height: 4.5rem;
}
.calendar-cell--placeholder {
    background: rgba(31,41,55,0.4);
    border: 1px dashed rgba(75,85,99,0.4);
}
.calendar-cell--empty {
    border-style: dashed;
    border-color: rgba(71,85,105,0.6);
    background: rgba(15,23,42,0.35);
}
.calendar-task-text {
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.calendar-card-title {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    min-width: 0;
}
.calendar-card-subtitle {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.calendar-cell__summary {
    display: none;
}
.calendar-cell__header {
    width: 100%;
}
.calendar-cell__summary--has-task {
    color: #facc15;
    font-weight: 600;
}
.calendar-cell__summary--empty {
    color: #94a3b8;
}
.assign-user-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.65rem 0.8rem;
    border: 1px solid rgba(55,65,81,0.8);
    border-radius: 0.75rem;
    background: rgba(31,41,55,0.8);
    cursor: pointer;
    transition: border-color 0.2s ease, background 0.2s ease;
}
.assign-user-card:hover {
    border-color: #f87171;
    background: rgba(55,65,81,0.9);
}
.assign-user-card--selected {
    border-color: #f87171;
    background: rgba(127,29,29,0.25);
}
.assign-user-card__name {
    font-size: 0.9rem;
    font-weight: 600;
    color: #f3f4f6;
}
.assign-user-card__meta {
    font-size: 0.75rem;
    color: #cbd5f5;
}
.assign-user-badge {
    min-width: 2.5rem;
    text-align: center;
    padding: 0.2rem 0.5rem;
    border-radius: 999px;
    font-size: 0.7rem;
    font-weight: 700;
    background: rgba(248,113,113,0.2);
    color: #fecaca;
}
.calendar-cell__count {
    display: inline-flex;
}
.assignee-badge {
    min-height: 1.75rem;
    max-width: 10rem;
    padding: 0.15rem 0.75rem;
    border-radius: 0.75rem;
    background: #111827;
    color: #bfdbfe;
    font-weight: 600;
    font-size: 0.85rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    border: 1px solid #60a5fa;
    transition: color 0.2s ease, transform 0.15s ease, border-color 0.15s ease;
}
.assignee-badge:hover,
.assignee-badge:focus {
    color: #ffffff;
    border-color: #93c5fd;
    transform: translateY(-1px);
    outline: none;
}
.assignee-badge--empty {
    background: #4b5563;
    color: #cbd5f5;
    cursor: not-allowed;
}
.assignee-popover {
    position: fixed;
    z-index: 60;
    min-width: 12rem;
    max-width: 16rem;
    background: #0f172a;
    border: 1px solid #334155;
    border-radius: 0.75rem;
    padding: 0.75rem;
    color: #e2e8f0;
    box-shadow: 0 15px 35px rgba(15,23,42,0.55);
    transition: opacity 0.15s ease, transform 0.15s ease;
}
.assignee-popover.hidden {
    opacity: 0;
    pointer-events: none;
}
.assignee-popover__header {
    font-weight: 600;
    font-size: 0.95rem;
    margin-bottom: 0.15rem;
}
.assignee-popover__meta {
    font-size: 0.75rem;
    color: #94a3b8;
}
.calendar-cell__indicators {
    display: none;
    flex-wrap: wrap;
    gap: 0.2rem;
    margin-top: 0.35rem;
}
.calendar-indicator {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    padding: 0.05rem 0.3rem;
    min-width: 1.25rem;
    font-size: 0.6rem;
    font-weight: 700;
    text-transform: uppercase;
}
.calendar-indicator--more {
    background: rgba(148,163,184,0.15);
    color: #e2e8f0;
    border: 1px dashed rgba(148,163,184,0.4);
}
#chat-toggle-button {
    position: fixed;
    bottom: 1.75rem;
    right: 1.5rem;
    z-index: 50;
    background: #dc2626;
    color: #fff;
    font-weight: 600;
    border-radius: 999px;
    padding: 0.6rem 1rem;
    display: none;
    align-items: center;
    gap: 0.45rem;
    box-shadow: 0 15px 30px rgba(15,23,42,0.6);
    cursor: grab;
    user-select: none;
}
#chat-toggle-button.visible { display: inline-flex; }
#chat-toggle-button:hover { background: #b91c1c; }
#chat-toggle-button.dragging {
    cursor: grabbing;
}
#chat-toggle-button .chat-toggle-badge {
    background: #fef3c7;
    color: #b45309;
    font-size: 0.65rem;
    font-weight: 700;
    padding: 0.1rem 0.45rem;
    border-radius: 999px;
    display: none;
}
#chat-toggle-button .chat-toggle-badge.visible { display: inline-flex; }
#chat-panel {
    position: fixed;
    bottom: 4.5rem;
    right: 1.5rem;
    width: 420px;
    max-width: calc(100% - 2rem);
    height: 560px;
    background: #0f172a;
    border: 1px solid #334155;
    border-radius: 1.25rem;
    z-index: 60;
    display: none;
    flex-direction: column;
    box-shadow: 0 25px 40px rgba(15,23,42,0.75);
}
#chat-panel.open { display: flex; }
.chat-panel__header {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid #1e293b;
    cursor: move;
    user-select: none;
}
#chat-panel.dragging .chat-panel__header {
    cursor: grabbing;
}
.chat-panel__messages {
    flex: 1;
    overflow-y: auto;
    padding: 1rem 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}
.chat-panel__composer {
    border-top: 1px solid #1e293b;
    padding: 0.75rem 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}
.chat-message {
    display: flex;
    gap: 0.65rem;
    width: 100%;
    align-items: flex-end;
}
.chat-message__bubble {
    background: #1f2937;
    border-radius: 1rem;
    padding: 0.65rem 0.85rem;
    max-width: min(75%, 520px);
    width: fit-content;
    box-shadow: 0 8px 18px rgba(15,23,42,0.55);
}
.chat-message__avatar {
    flex-shrink: 0;
    font-size: 0.95rem;
    box-shadow: 0 6px 20px rgba(0,0,0,0.35);
}
.chat-message--theirs {
    justify-content: flex-start;
}
.chat-message--mine {
    justify-content: flex-end;
    text-align: right;
}
.chat-message--mine .chat-message__avatar {
    order: 2;
    margin-left: 0.35rem;
}
.chat-message__meta {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    margin-bottom: 0.2rem;
    font-size: 0.7rem;
    letter-spacing: 0.01em;
    color: #cbd5f5;
}
.chat-message__name { font-weight: 600; color: #f1f5f9; }
.chat-message__time { color: #94a3b8; }
.chat-message--mine .chat-message__meta {
    justify-content: flex-end;
}
.chat-message--mine .chat-message__bubble {
    background: linear-gradient(135deg,#dc2626,#ef4444);
    color: #fff;
}
.chat-message--mine .chat-message__bubble p,
.chat-message--mine .chat-message__bubble span,
.chat-message--mine .chat-message__time {
    color: #fee2e2;
}
.chat-message__attachments {
    margin-top: 0.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}
.chat-attachment-card {
    border: 1px dashed rgba(148,163,184,0.5);
    border-radius: 0.75rem;
    padding: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    background: rgba(15,23,42,0.6);
}
.chat-attachment-card img {
    border-radius: 0.5rem;
    max-height: 140px;
    width: auto;
}
.chat-attachment-preview {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}
.chat-attachment-preview-item {
    border: 1px dashed #475569;
    border-radius: 0.75rem;
    padding: 0.4rem 0.6rem;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.8rem;
    background: rgba(15,23,42,0.7);
}
.chat-attachment-preview-item button {
    color: #f87171;
}
.chat-page {
    background: #0f172a;
    border: 1px solid #1e293b;
    border-radius: 1rem;
    padding: 1.5rem;
    min-height: calc(100vh - 4rem);
    display: flex;
    flex-direction: column;
    gap: 1rem;
    max-width: 1080px;
    margin: 0 auto;
}
.chat-page__header {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}
@media (min-width: 640px) {
    .chat-page__header {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
    }
}
.chat-page__stats {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}
.chat-page__stat-card {
    background: rgba(30,41,59,0.9);
    border: 1px solid rgba(71,85,105,0.6);
    border-radius: 0.75rem;
    padding: 0.75rem 1rem;
    min-width: 140px;
}
.chat-page__messages {
    flex: 1;
    min-height: 360px;
    max-height: calc(100vh - 24rem);
    overflow-y: auto;
    padding: 1rem;
    border: 1px solid #1e293b;
    border-radius: 1rem;
    background: rgba(15,23,42,0.7);
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}
.chat-page__messages::-webkit-scrollbar {
    width: 8px;
}
.chat-page__messages::-webkit-scrollbar-thumb {
    background: rgba(148,163,184,0.4);
    border-radius: 999px;
}
.chat-page__composer {
    border: 1px solid #1e293b;
    border-radius: 1rem;
    padding: 1rem;
    background: rgba(15,23,42,0.9);
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}
.chat-page__composer-actions {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}
@media (min-width: 640px) {
    .chat-page__composer-actions {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
    }
}
@media (max-width: 768px) {
    #chat-toggle-button {
        right: 1rem;
        bottom: 1rem;
    }
    #chat-panel {
        right: 0.5rem;
        left: 0.5rem;
        width: auto;
        bottom: 5rem;
        height: calc(85vh);
    }
}
@media (max-width: 1024px) {
    .calendar-scroll-content,
    .calendar-grid-wrapper,
    .calendar-day-headers,
    .responsive-calendar-grid {
        min-width: 640px;
    }
}
@media (max-width: 640px) {
    .calendar-scroll-area {
        overflow-x: visible;
    }
    .calendar-scroll-content,
    .calendar-grid-wrapper,
    .calendar-day-headers,
    .responsive-calendar-grid {
        min-width: 100%;
    }
    .calendar-day-headers,
    .responsive-calendar-grid {
        grid-template-columns: repeat(7, minmax(0, 1fr));
        gap: 0.35rem;
    }
    .calendar-cell {
        min-height: 4.5rem;
        padding: 0.35rem;
        aspect-ratio: auto;
        align-items: center;
        justify-content: center;
        text-align: center;
    }
    .calendar-cell__count {
        display: none;
    }
    .calendar-cell__header {
        justify-content: center;
        margin-bottom: 0.1rem;
        gap: 0.2rem;
    }
    .calendar-cell__tasks {
        display: none;
    }
    .calendar-cell__indicators {
        display: none;
    }
    .calendar-cell__summary {
        display: block;
        font-size: 0.65rem;
        line-height: 1.1;
        margin-top: 0.15rem;
        width: 100%;
    }
}
body[data-theme="light"] { background-color: #f4f6fb; color: #111827; }
body[data-theme="light"] .bg-gray-900,
body[data-theme="light"] .bg-gray-900\/50 { background-color: #ffffff !important; color: #111827 !important; }
body[data-theme="light"] .bg-gray-800,
body[data-theme="light"] .bg-gray-800\/50 { background-color: #f8fafc !important; color: #111827 !important; }
body[data-theme="light"] .bg-gray-700 { background-color: #e5e7eb !important; color: #111827 !important; }
body[data-theme="light"] .bg-gray-600 { background-color: #cbd5f5 !important; color: #111827 !important; }
body[data-theme="light"] .bg-gray-500 { background-color: #9ca3af !important; color: #111827 !important; }
body[data-theme="light"] .text-white,
body[data-theme="light"] .text-gray-200,
body[data-theme="light"] .text-gray-300 { color: #111827 !important; }
body[data-theme="light"] .text-gray-400,
body[data-theme="light"] .text-gray-500 { color: #4b5563 !important; }
body[data-theme="light"] .border-gray-700,
body[data-theme="light"] .border-gray-600 { border-color: #d1d5db !important; }
body[data-theme="light"] .bg-gray-900\/40,
body[data-theme="light"] .bg-gray-900\/10 { background-color: rgba(255,255,255,0.9) !important; }
body[data-theme="light"] .bg-gray-700\/40 { background-color: rgba(226,232,240,0.8) !important; }
body[data-theme="light"] .bg-gray-800\/70 { background-color: rgba(248,250,252,0.95) !important; border-color: #e5e7eb !important; color: #111827 !important; }
body[data-theme="light"] .card-panel table thead { background-color: #e5e7eb !important; color: #111827 !important; }
body[data-theme="light"] .card-panel table tbody td { color: #1f2937 !important; border-color: #e5e7eb !important; }
.user-detail-modal {
    background: rgba(15,23,42,0.98);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 1.5rem;
    box-shadow: 0 25px 50px rgba(15,23,42,0.6);
    color: #f8fafc;
}
.user-detail-field {
    background: rgba(31,41,55,0.9);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 0.85rem;
    padding: 1rem;
    transition: border-color 0.2s ease;
}
.user-detail-field:hover { border-color: rgba(248,113,113,0.4); }
body[data-theme="light"] .user-detail-modal {
    background: #ffffff;
    color: #0f172a;
    border-color: #e2e8f0;
    box-shadow: 0 25px 50px rgba(15,23,42,0.2);
}
body[data-theme="light"] .user-detail-field {
    background: #f8fafc;
    border-color: #e2e8f0;
    color: #0f172a;
}
.user-detail-field p:first-child {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: inherit;
    opacity: 0.65;
}
.card-panel {
    background: rgba(15,23,42,0.9);
    border: 1px solid rgba(255,255,255,0.07);
    border-radius: 1rem;
    box-shadow: 0 15px 35px rgba(0,0,0,0.35);
}
.card-panel--light {
    background: rgba(255,255,255,0.95);
    border-color: #e5e7eb;
    color: #111827;
    box-shadow: 0 15px 35px rgba(15,23,42,0.08);
}
body[data-theme="light"] .card-panel {
    background: rgba(255,255,255,0.95);
    border-color: #e5e7eb;
    color: #111827;
    box-shadow: 0 15px 35px rgba(15,23,42,0.08);
}
.user-table {
    table-layout: fixed;
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}
.user-table th,
.user-table td {
    padding-left: 1.25rem;
    padding-right: 1.25rem;
}
.user-table th:nth-child(1),
.user-table td:nth-child(1) { width: 26%; }
.user-table th:nth-child(2),
.user-table td:nth-child(2) { width: 22%; }
.user-table th:nth-child(3),
.user-table td:nth-child(3) { width: 20%; }
.user-table th:nth-child(4),
.user-table td:nth-child(4) { width: 18%; }
.user-table th:nth-child(5),
.user-table td:nth-child(5) { width: 10%; }
.user-table th:nth-child(6),
.user-table td:nth-child(6) { width: 12%; }
.user-row {
    cursor: pointer;
    transition: background-color 0.15s ease;
}
.user-row:hover { background-color: rgba(255,255,255,0.05); }
body[data-theme="light"] .user-row:hover { background-color: rgba(15,23,42,0.05); }
body[data-theme="light"] .text-red-400 { color: #b91c1c !important; }
.theme-card {
    border: 1px solid rgba(255,255,255,0.15);
    background: linear-gradient(145deg, rgba(31,41,55,0.95), rgba(15,23,42,0.75));
    border-radius: 1rem;
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    transition: border-color 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
}
.theme-card--active {
    border-color: #f87171;
    box-shadow: 0 10px 25px rgba(248,113,113,0.2);
    transform: translateY(-2px);
}
.theme-card__content {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    align-items: center;
}
.theme-card__title {
    font-size: 1.125rem;
    font-weight: 600;
    color: #f3f4f6;
    margin-bottom: 0.25rem;
}
.theme-card__description {
    font-size: 0.9rem;
    color: #cbd5f5;
}
.theme-card__tag {
    display: inline-flex;
    font-size: 0.75rem;
    margin-top: 0.5rem;
    padding: 0.2rem 0.6rem;
    border-radius: 999px;
    background: rgba(248,113,113,0.12);
    color: #fda4af;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.theme-card__preview {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    min-width: 120px;
}
.theme-card__swatch {
    height: 14px;
    border-radius: 999px;
    opacity: 0.9;
}
.theme-card__swatch--surface { opacity: 0.7; }
.theme-card__swatch--accent { opacity: 0.5; }
.theme-card__actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.theme-card__status {
    font-size: 0.85rem;
    color: #f3f4f6;
}
.theme-card input[type="radio"] {
    width: 1.15rem;
    height: 1.15rem;
    accent-color: #f87171;
}
body[data-theme="light"] .theme-card {
    background: #ffffff;
    border-color: #e5e7eb;
    color: #111827;
}
body[data-theme="light"] .theme-card__title { color: #111827; }
body[data-theme="light"] .theme-card__description { color: #4b5563; }
body[data-theme="light"] .theme-card__tag { background: rgba(14,165,233,0.15); color: #0369a1; }
body[data-theme="light"] .theme-card__status { color: #1f2937; }
