*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --bg: #0f1117;
    --bg-card: #1a1d27;
    --bg-column: #151820;
    --border: #2a2f3d;
    --text: #e8eaed;
    --text-muted: #8b92a5;
    --primary: #5b7fff;
    --primary-hover: #4a6ef0;
    --danger: #ef4444;
    --danger-hover: #dc2626;
    --success: #22c55e;
    --radius: 10px;
    --shadow: 0 4px 24px rgba(0, 0, 0, 0.3);
    --column-important: #ef4444;
    --column-medium: #f59e0b;
    --column-when-time: #8b5cf6;
    --column-in-progress: #3b82f6;
    --column-done: #22c55e;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    line-height: 1.5;
}

/* Auth pages */
.auth-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 20px;
    background: linear-gradient(135deg, #0f1117 0%, #1a1d3a 100%);
}

.auth-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 40px;
    width: 100%;
    max-width: 400px;
    box-shadow: var(--shadow);
}

.auth-card--wide {
    max-width: 560px;
}

.auth-card h1 {
    font-size: 1.75rem;
    margin-bottom: 8px;
}

.auth-subtitle {
    color: var(--text-muted);
    margin-bottom: 24px;
}

/* Header */
.header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 24px;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-left,
.header-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo {
    font-size: 1.25rem;
    font-weight: 700;
}

.user-badge {
    color: var(--text-muted);
    font-size: 0.875rem;
}

.role-badge {
    background: var(--primary);
    color: #fff;
    font-size: 0.75rem;
    padding: 2px 8px;
    border-radius: 20px;
    font-weight: 600;
}

/* Board */
.board {
    display: flex;
    gap: 16px;
    padding: 24px;
    overflow-x: auto;
    min-height: calc(100vh - 65px);
    align-items: flex-start;
}

.column {
    flex: 0 0 280px;
    background: var(--bg-column);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    max-height: calc(100vh - 113px);
}

.column-header {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

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

.column-dot--important { background: var(--column-important); }
.column-dot--medium { background: var(--column-medium); }
.column-dot--when_time { background: var(--column-when-time); }
.column-dot--in_progress { background: var(--column-in-progress); }
.column-dot--done { background: var(--column-done); }

.column-count {
    margin-left: auto;
    background: var(--border);
    color: var(--text-muted);
    font-size: 0.75rem;
    padding: 1px 7px;
    border-radius: 10px;
    font-weight: 500;
}

.column-tasks {
    padding: 8px;
    overflow-y: auto;
    flex: 1;
    min-height: 60px;
}

.column-tasks.sortable-ghost .task-card {
    opacity: 0.3;
}

/* Task card */
.task-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 8px;
    cursor: grab;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.task-card:hover {
    border-color: var(--primary);
    box-shadow: 0 2px 12px rgba(91, 127, 255, 0.15);
}

.task-card:active {
    cursor: grabbing;
}

.task-card.sortable-drag {
    opacity: 0.9;
    box-shadow: var(--shadow);
}

.task-card-title {
    font-weight: 600;
    font-size: 0.9rem;
    margin-bottom: 4px;
    word-break: break-word;
}

.task-card-desc {
    font-size: 0.8rem;
    color: var(--text-muted);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin-bottom: 8px;
}

.task-card-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.task-card-agent {
    background: var(--border);
    padding: 2px 8px;
    border-radius: 4px;
}

/* Forms */
.form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.form-inline {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 12px;
    padding: 16px;
    background: var(--bg);
    border-radius: 8px;
    margin-bottom: 16px;
}

.form-row {
    display: flex;
    gap: 16px;
}

.form-row .form-group {
    flex: 1;
}

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

.form-group label {
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-muted);
}

.form-group input,
.form-group textarea,
.form-group select {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 10px 12px;
    color: var(--text);
    font-size: 0.9rem;
    font-family: inherit;
    transition: border-color 0.15s;
}

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

fieldset {
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

legend {
    padding: 0 8px;
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 0.875rem;
    font-weight: 500;
    border: none;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.15s, color 0.15s;
    white-space: nowrap;
    font-family: inherit;
}

.btn-primary {
    background: var(--primary);
    color: #fff;
}

.btn-primary:hover {
    background: var(--primary-hover);
}

.btn-secondary {
    background: var(--border);
    color: var(--text);
}

.btn-secondary:hover {
    background: #3a4050;
}

.btn-danger {
    background: var(--danger);
    color: #fff;
}

.btn-danger:hover {
    background: var(--danger-hover);
}

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

.btn-ghost:hover {
    background: var(--border);
    color: var(--text);
}

.btn-block {
    width: 100%;
}

.btn-sm {
    padding: 4px 10px;
    font-size: 0.8rem;
}

/* Modal */
.modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal[hidden] {
    display: none;
}

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
}

.modal-content {
    position: relative;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    width: 100%;
    max-width: 520px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow);
}

.modal-content--wide {
    max-width: 640px;
}

.modal-content--task {
    max-width: 560px;
}

.task-card-date {
    color: var(--text-muted);
    white-space: nowrap;
}

.task-meta {
    display: flex;
    gap: 20px;
    padding: 12px 14px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
}

.task-meta-item {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.task-meta-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
}

.task-meta-value {
    font-size: 0.875rem;
    font-weight: 500;
}

.activity-section {
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid var(--border);
}

.activity-title {
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: 12px;
}

.activity-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-height: 280px;
    overflow-y: auto;
}

.activity-item {
    display: flex;
    gap: 10px;
    padding: 10px 12px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
}

.activity-icon {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    flex-shrink: 0;
    color: var(--text-muted);
}

.activity-item--moved .activity-icon {
    background: rgba(59, 130, 246, 0.2);
    color: #60a5fa;
}

.activity-item--created .activity-icon {
    background: rgba(34, 197, 94, 0.2);
    color: #4ade80;
}

.activity-item--updated .activity-icon,
.activity-item--reassigned .activity-icon {
    background: rgba(245, 158, 11, 0.2);
    color: #fbbf24;
}

.activity-body {
    min-width: 0;
}

.activity-message {
    font-size: 0.85rem;
    line-height: 1.4;
}

.activity-time {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 4px;
}

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

.modal-header h2 {
    font-size: 1.25rem;
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.5rem;
    cursor: pointer;
    line-height: 1;
    padding: 4px;
}

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

.modal-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 8px;
}

.modal-actions-right {
    display: flex;
    gap: 8px;
    margin-left: auto;
}

/* Agents list */
.agents-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.agent-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
}

.agent-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.agent-name {
    font-weight: 600;
    font-size: 0.9rem;
}

.agent-username {
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* Alerts */
.alert {
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 16px;
    font-size: 0.875rem;
}

.alert-error {
    background: rgba(239, 68, 68, 0.15);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: #fca5a5;
}

.alert-success {
    background: rgba(34, 197, 94, 0.15);
    border: 1px solid rgba(34, 197, 94, 0.3);
    color: #86efac;
}

.loading {
    color: var(--text-muted);
    text-align: center;
    padding: 40px;
    font-size: 0.9rem;
}

.empty-state {
    color: var(--text-muted);
    text-align: center;
    padding: 20px;
    font-size: 0.85rem;
}

/* Responsive */
@media (max-width: 768px) {
    .header {
        flex-direction: column;
        gap: 12px;
        align-items: stretch;
    }

    .header-left,
    .header-right {
        justify-content: center;
        flex-wrap: wrap;
    }

    .board {
        flex-direction: column;
        padding: 16px;
    }

    .column {
        flex: none;
        width: 100%;
        max-height: none;
    }

    .form-row {
        flex-direction: column;
    }

    .form-inline {
        flex-direction: column;
        align-items: stretch;
    }
}
