@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

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

:root {
    --bg: #f1f5f9;
    --bg-accent: #e0e7ff;
    --card: #ffffff;
    --text: #0f172a;
    --text-muted: #64748b;
    --text-light: #94a3b8;
    --border: #e2e8f0;
    --border-light: #f1f5f9;
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --primary-light: #eef2ff;
    --secondary: #f8fafc;
    --danger: #ef4444;
    --danger-dark: #dc2626;
    --danger-light: #fef2f2;
    --success: #10b981;
    --success-light: #ecfdf5;
    --warning: #f59e0b;
    --radius: 12px;
    --radius-sm: 8px;
    --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
    --shadow: 0 4px 6px -1px rgba(15, 23, 42, 0.07), 0 2px 4px -2px rgba(15, 23, 42, 0.05);
    --shadow-lg: 0 10px 25px -5px rgba(15, 23, 42, 0.1), 0 8px 10px -6px rgba(15, 23, 42, 0.05);
    --header-height: 64px;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
    max-width: 100%;
}

html {
    overflow-x: hidden;
}

body::before {
    display: none;
}

a {
    color: var(--primary);
    text-decoration: none;
    transition: color 0.15s;
}

.container {
    width: 80%;
    max-width: none;
    margin: 0 auto;
    padding: 0 20px;
}

/* Header */
.header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--card);
    border-bottom: 1px solid var(--border);
    height: var(--header-height);
}

.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: var(--header-height);
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.02em;
}

.logo-icon {
    width: 32px;
    height: 32px;
    background: var(--primary);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 0.9rem;
}

.nav {
    display: flex;
    gap: 20px;
}

.nav a {
    padding: 0;
    border-radius: 0;
    color: var(--text-muted);
    font-weight: 500;
    font-size: 0.9rem;
    background: none;
    box-shadow: none;
}

.nav a:hover {
    color: var(--primary);
    background: none;
}

.nav a.active {
    color: var(--primary);
    font-weight: 600;
    background: none;
    box-shadow: none;
}

.main {
    padding: 32px 0 80px;
    max-width: 100%;
    overflow-x: hidden;
}

/* Footer */
.footer {
    text-align: center;
    padding: 20px 0;
    color: var(--text-light);
    font-size: 0.8rem;
    border-top: 1px solid var(--border);
    background: var(--card);
}

/* Layout alignment */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
    gap: 20px;
}

.form-page {
    max-width: 100%;
    margin-left: auto;
    margin-right: auto;
}

.task-panel {
    max-width: 100%;
    margin-left: auto;
    margin-right: auto;
    overflow: hidden;
    word-wrap: break-word;
}

.page-header h1 {
    font-size: 1.875rem;
    font-weight: 700;
    letter-spacing: -0.03em;
    line-height: 1.2;
}

.page-intro {
    color: var(--text-muted);
    margin-top: 6px;
    font-size: 0.95rem;
    max-width: 520px;
}

.subtitle {
    color: var(--text-muted);
    margin-top: 6px;
    font-size: 0.95rem;
}

.subtitle-meta {
    color: var(--text-light);
    font-size: 0.875rem;
}

.project-desc-preview {
    font-size: 0.8rem;
    margin-top: 4px;
}

.user-edit-form {
    max-width: 760px;
    margin-left: auto;
    margin-right: auto;
    padding: 1.75rem;
}

.assignee-cell {
    max-width: 280px;
    font-size: 0.875rem;
}
    max-width: 280px;
    font-size: 0.875rem;
}

.ts-wrapper.multi .ts-control {
    min-height: 44px;
}

.ts-wrapper.multi .ts-control > .item {
    background: var(--primary-light);
    color: var(--primary-dark);
    border-radius: 6px;
    border: 0;
}

.breadcrumb {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.breadcrumb a {
    color: var(--text-muted);
}

.breadcrumb a:hover {
    color: var(--primary);
}

.breadcrumb-sep {
    color: var(--text-light);
}

.task-title-row {
    display: flex;
    align-items: baseline;
    gap: 8px;
    padding-bottom: 12px;
    margin-bottom: 12px;
    border-bottom: 1px solid var(--border-light);
    flex-wrap: wrap;
}

.task-section .task-title-row {
    margin-top: 0;
}

.task-section .task-title-row + h2 {
    margin-top: 0;
}

.task-title-label {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-muted);
    flex-shrink: 0;
}

.task-title-text {
    font-size: 0.95rem;
    font-weight: 600;
    line-height: 1.4;
    color: var(--text);
    word-break: break-word;
    overflow-wrap: anywhere;
    min-width: 0;
}

.header-actions {
    display: flex;
    gap: 10px;
    flex-shrink: 0;
}

/* Cards */
.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow-sm);
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border-light);
}

.card-header h2,
.card-header h3 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 8px;
}

.card-icon {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    flex-shrink: 0;
}

.card-icon-indigo { background: var(--primary-light); color: var(--primary); }
.card-icon-green { background: var(--success-light); color: var(--success); }
.card-icon-red { background: var(--danger-light); color: var(--danger); }
.card-icon-amber { background: #fffbeb; color: var(--warning); }

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 18px;
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    font-weight: 600;
    font-family: inherit;
    border: none;
    cursor: pointer;
    text-align: center;
    transition: all 0.15s;
    white-space: nowrap;
    line-height: 1.4;
}

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

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

.btn-secondary {
    background: var(--card);
    color: var(--text);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
}

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

.btn-danger {
    background: var(--danger);
    color: #fff;
    box-shadow: 0 2px 8px rgba(239, 68, 68, 0.25);
}

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

.btn-sm {
    padding: 6px 12px;
    font-size: 0.8rem;
}

.btn-icon {
    font-size: 1rem;
    line-height: 1;
}

/* Alerts */
.alert {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 18px;
    border-radius: var(--radius-sm);
    margin-bottom: 24px;
    font-weight: 500;
    font-size: 0.9rem;
}

.alert-success {
    background: var(--success-light);
    color: #065f46;
    border: 1px solid #a7f3d0;
}

.alert-error {
    background: var(--danger-light);
    color: #991b1b;
    border: 1px solid #fecaca;
}

/* Stats */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow-sm);
    display: flex;
    align-items: center;
    gap: 14px;
}

.stat-icon {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    flex-shrink: 0;
}

.stat-icon-total { background: var(--primary-light); }
.stat-icon-open { background: #e0e7ff; }
.stat-icon-progress { background: #fffbeb; }
.stat-icon-critical { background: var(--danger-light); }

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

.stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    line-height: 1;
    letter-spacing: -0.02em;
}

.stat-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 4px;
    font-weight: 500;
}

/* Project selector */
.project-bar {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 24px;
    padding: 20px 24px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.project-form {
    flex: 1;
    min-width: 0;
}

.project-form-row {
    display: flex;
    gap: 12px;
    align-items: center;
}

.project-form-row .ts-wrapper {
    flex: 1;
    max-width: none;
}

.project-form-row .btn {
    flex-shrink: 0;
}

.project-form label {
    display: block;
    font-weight: 600;
    font-size: 0.875rem;
    margin-bottom: 8px;
}

.project-name-display {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text);
}

/* Table */
.table-card {
    padding: 0;
    overflow: hidden;
    box-shadow: var(--shadow);
}

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

.table-card-header h2 {
    font-size: 1rem;
    font-weight: 600;
}

.table-count {
    font-size: 0.85rem;
    color: var(--text-muted);
    background: var(--secondary);
    padding: 4px 12px;
    border-radius: 20px;
    border: 1px solid var(--border);
}

.table-responsive {
    overflow-x: auto;
}

.task-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

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

.task-table th {
    padding: 12px 20px;
    text-align: left;
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    white-space: nowrap;
    border-bottom: 1px solid var(--border);
}

.task-table td {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-light);
    vertical-align: middle;
}

.task-table tbody tr {
    transition: background 0.1s;
}

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

.task-table th:nth-child(1),
.task-table td:nth-child(1),
.task-table th:nth-child(3),
.task-table td:nth-child(3),
.task-table th:nth-child(5),
.task-table td:nth-child(5),
.task-table th:nth-child(6),
.task-table td:nth-child(6),
.task-table th:last-child,
.task-table td:last-child {
    text-align: center;
}

.task-table th:nth-child(2),
.task-table td:nth-child(2),
.task-table th:nth-child(4),
.task-table td:nth-child(4),
.task-table th:nth-child(7),
.task-table td:nth-child(7) {
    text-align: left;
}

.task-table td .badge {
    justify-content: center;
}

.task-table td:last-child .btn {
    margin: 0 auto;
}

.row-priority-critical td:first-child { box-shadow: inset 3px 0 0 #ef4444; }
.row-priority-high td:first-child { box-shadow: inset 3px 0 0 #f97316; }
.row-priority-medium td:first-child { box-shadow: inset 3px 0 0 #f59e0b; }
.row-priority-low td:first-child { box-shadow: inset 3px 0 0 #3b82f6; }

.task-title-cell a {
    font-weight: 600;
    color: var(--text);
    transition: color 0.15s;
}

.task-title-cell a:hover {
    color: var(--primary);
}

.task-desc-cell {
    color: var(--text-muted);
    max-width: 260px;
    line-height: 1.5;
}

.table-num {
    text-align: center;
    color: var(--text-muted);
    font-weight: 500;
}

/* Pagination */
.pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 16px 24px;
    border-top: 1px solid var(--border);
    background: var(--secondary);
    flex-wrap: wrap;
}

.pagination-info {
    font-size: 0.85rem;
    color: var(--text-muted);
    font-weight: 500;
}

.pagination-links {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.pagination-btn,
.pagination-num {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    height: 36px;
    padding: 0 12px;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-weight: 600;
    border: 1px solid var(--border);
    background: var(--card);
    color: var(--text);
    transition: all 0.15s;
}

.pagination-num {
    min-width: 36px;
    padding: 0;
}

.pagination-btn:hover,
.pagination-num:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--primary-light);
}

.pagination-num.active {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
    cursor: default;
}

.pagination-btn.disabled {
    opacity: 0.4;
    cursor: not-allowed;
    pointer-events: none;
}

/* Badges */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    white-space: nowrap;
}

.badge-priority-low { background: #dbeafe; color: #1d4ed8; }
.badge-priority-medium { background: #fef3c7; color: #b45309; }
.badge-priority-high { background: #ffedd5; color: #c2410c; }
.badge-priority-critical { background: #fee2e2; color: #b91c1c; }

.badge-status-open { background: #e0e7ff; color: #4338ca; }
.badge-status-in_progress { background: #ede9fe; color: #6d28d9; }
.badge-status-done { background: #d1fae5; color: #065f46; }

/* Empty state */
.empty-state {
    text-align: center;
    padding: 64px 32px;
}

.empty-icon {
    width: 72px;
    height: 72px;
    background: var(--primary-light);
    border-radius: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    margin: 0 auto 20px;
}

.empty-state h2 {
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 8px;
    letter-spacing: -0.02em;
}

.empty-state p {
    color: var(--text-muted);
    margin-bottom: 24px;
    max-width: 360px;
    margin-left: auto;
    margin-right: auto;
}

.empty-state-actions {
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
}

/* Forms */
.form-card {
    box-shadow: var(--shadow);
}

.form-section {
    margin-bottom: 28px;
    padding-bottom: 28px;
    border-bottom: 1px solid var(--border-light);
}

.form-section:last-of-type {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}

.form-section-title {
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    margin-bottom: 16px;
}

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

.form-group {
    margin-bottom: 18px;
}

.form-group:last-child {
    margin-bottom: 0;
}

.form-group label {
    display: block;
    font-weight: 600;
    margin-bottom: 8px;
    font-size: 0.875rem;
    color: var(--text);
}

.form-group input[type="text"],
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 11px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-family: inherit;
    background: var(--card);
    color: var(--text);
    transition: border-color 0.15s, box-shadow 0.15s;
}

.form-group input[type="text"]:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

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

.editor-group {
    margin-bottom: 18px;
}

.editor-source {
    display: none;
}

.rich-editor {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    min-height: 180px;
}

.rich-editor .ql-toolbar {
    border: none;
    border-bottom: 1px solid var(--border);
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
    background: var(--secondary);
}

.rich-editor .ql-container {
    border: none;
    font-size: 0.9rem;
    font-family: inherit;
    min-height: 140px;
}

.rich-editor .ql-editor {
    min-height: 140px;
    line-height: 1.6;
}

.description-html ul,
.description-html ol {
    margin: 8px 0 8px 20px;
    padding-left: 16px;
}

.description-html p {
    margin-bottom: 8px;
}

.description-html p:last-child {
    margin-bottom: 0;
}

.description-html a {
    color: var(--primary);
    text-decoration: underline;
    word-break: break-all;
}

.description-html h1,
.description-html h2,
.description-html h3 {
    font-size: 1rem;
    margin: 10px 0 6px;
    word-break: break-word;
}

.description-box {
    background: var(--secondary);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    padding: 14px 16px;
    max-width: 100%;
    overflow: hidden;
}

.description-html {
    white-space: normal;
    line-height: 1.7;
    color: var(--text);
    font-size: 0.95rem;
    overflow-wrap: anywhere;
    word-break: break-word;
    max-width: 100%;
}

.description-html * {
    max-width: 100%;
    overflow-wrap: anywhere;
}

.description-text {
    white-space: pre-wrap;
    line-height: 1.7;
    color: var(--text);
    font-size: 0.95rem;
    overflow-wrap: anywhere;
    word-break: break-word;
    max-width: 100%;
}

.form-group input[type="file"] {
    width: 100%;
    padding: 10px 0;
    font-size: 0.9rem;
    font-family: inherit;
}

.file-upload {
    border: 2px dashed var(--border);
    border-radius: var(--radius-sm);
    padding: 28px 20px;
    text-align: center;
    background: var(--secondary);
    transition: border-color 0.15s, background 0.15s;
    cursor: pointer;
    position: relative;
}

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

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

.file-upload-icon {
    font-size: 1.75rem;
    margin-bottom: 8px;
}

.file-upload-text {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text);
}

.file-upload-hint {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 4px;
}

.hint {
    display: block;
    margin-top: 6px;
    color: var(--text-muted);
    font-size: 0.8rem;
}

.form-actions {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 12px;
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid var(--border-light);
}

/* Searchable dropdown (Tom Select) */
.ts-wrapper {
    width: 100%;
}

.ts-wrapper.single .ts-control,
.ts-wrapper.multi .ts-control {
    min-height: 42px;
    padding: 8px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--card);
    box-shadow: none;
    font-size: 0.9rem;
    font-family: inherit;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.ts-wrapper.single.input-active .ts-control,
.ts-wrapper.single.focus .ts-control,
.ts-wrapper.multi.input-active .ts-control,
.ts-wrapper.multi.focus .ts-control {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

.ts-wrapper .ts-control input {
    font-size: 0.9rem;
    font-family: inherit;
    color: var(--text);
}

.ts-wrapper .ts-control input::placeholder {
    color: var(--text-light);
}

.ts-dropdown {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-lg);
    background: var(--card);
    margin-top: 4px;
    overflow: hidden;
}

.ts-dropdown .dropdown-input {
    border: none;
    border-bottom: 1px solid var(--border-light);
    padding: 10px 14px;
    font-size: 0.9rem;
    font-family: inherit;
    background: var(--secondary);
    outline: none;
}

.ts-dropdown .dropdown-input:focus {
    background: var(--primary-light);
}

.ts-dropdown .dropdown-input-wrap {
    padding: 0;
}

.ts-dropdown .option {
    padding: 10px 14px;
    font-size: 0.9rem;
    color: var(--text);
    cursor: pointer;
}

.ts-dropdown .option:hover,
.ts-dropdown .option.active {
    background: var(--primary-light);
    color: var(--primary-dark);
}

.ts-dropdown .option.selected {
    background: var(--primary);
    color: #fff;
}

.ts-dropdown .no-results {
    padding: 12px 14px;
    color: var(--text-muted);
    font-size: 0.85rem;
}

.ts-wrapper .item {
    background: var(--primary-light);
    color: var(--primary-dark);
    border-radius: 4px;
    font-size: 0.85rem;
    border: none;
}

.project-form-row .ts-wrapper {
    flex: 1;
    max-width: 360px;
}

.project-bar .project-form-row .ts-wrapper {
    max-width: none;
}

.project-bar .ts-wrapper.single .ts-control {
    min-height: 40px;
}

.status-form .ts-wrapper {
    width: 100%;
}

/* Task view - simple layout */
.task-panel-top {
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border-light);
    margin-bottom: 20px;
}

.task-panel-controls {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.task-control-row {
    display: grid;
    grid-template-columns: 72px 1fr;
    align-items: center;
    gap: 12px;
}

.task-control-row label {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-muted);
    text-align: right;
}

/* Priority & status colored selects */
.task-control-priority.task-priority-low .ts-wrapper .ts-control { background: #dbeafe; border-color: #93c5fd; color: #1d4ed8; }
.task-control-priority.task-priority-medium .ts-wrapper .ts-control { background: #fef3c7; border-color: #fcd34d; color: #b45309; }
.task-control-priority.task-priority-high .ts-wrapper .ts-control { background: #ffedd5; border-color: #fdba74; color: #c2410c; }
.task-control-priority.task-priority-critical .ts-wrapper .ts-control { background: #fee2e2; border-color: #fca5a5; color: #b91c1c; }

.task-control-status.task-status-open .ts-wrapper .ts-control { background: #e0e7ff; border-color: #a5b4fc; color: #4338ca; }
.task-control-status.task-status-in_progress .ts-wrapper .ts-control { background: #ede9fe; border-color: #c4b5fd; color: #6d28d9; }
.task-control-status.task-status-done .ts-wrapper .ts-control { background: #d1fae5; border-color: #6ee7b7; color: #065f46; }

.task-control-priority .ts-dropdown .ts-option[data-value="low"] { background: #dbeafe; color: #1d4ed8; }
.task-control-priority .ts-dropdown .ts-option[data-value="medium"] { background: #fef3c7; color: #b45309; }
.task-control-priority .ts-dropdown .ts-option[data-value="high"] { background: #ffedd5; color: #c2410c; }
.task-control-priority .ts-dropdown .ts-option[data-value="critical"] { background: #fee2e2; color: #b91c1c; }

.task-control-status .ts-dropdown .ts-option[data-value="open"] { background: #e0e7ff; color: #4338ca; }
.task-control-status .ts-dropdown .ts-option[data-value="in_progress"] { background: #ede9fe; color: #6d28d9; }
.task-control-status .ts-dropdown .ts-option[data-value="done"] { background: #d1fae5; color: #065f46; }

.task-control-priority .ts-wrapper .ts-control .item,
.task-control-status .ts-wrapper .ts-control .item {
    background: transparent;
}

.task-control-priority .ts-wrapper .ts-control,
.task-control-status .ts-wrapper .ts-control {
    font-weight: 600;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.task-control-priority .ts-dropdown .ts-option,
.task-control-status .ts-dropdown .ts-option {
    font-weight: 600;
}

.task-control-priority .ts-dropdown .ts-option.active,
.task-control-status .ts-dropdown .ts-option.active {
    filter: brightness(0.95);
}

.task-control-row .ts-wrapper {
    width: 100%;
    min-width: 0;
}

.task-panel-meta {
    padding-bottom: 20px;
    margin-bottom: 20px;
    border-bottom: 1px solid var(--border-light);
    width: 100%;
    overflow-x: auto;
}

.task-meta-table {
    width: 100%;
    table-layout: fixed;
    border-collapse: collapse;
    font-size: 0.875rem;
    color: var(--text-muted);
    line-height: 1.5;
}

.task-meta-table td {
    width: 25%;
    padding: 0 12px 0 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    vertical-align: top;
}

.task-meta-table td:last-child {
    padding-right: 0;
}

.task-meta-table strong {
    color: var(--text);
}

.task-section {
    margin-bottom: 24px;
    max-width: 100%;
    overflow: hidden;
}

.task-section:last-of-type {
    margin-bottom: 0;
}

.task-section h2 {
    font-size: 0.95rem;
    font-weight: 600;
    margin-bottom: 12px;
    color: var(--text);
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border-light);
}

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

.simple-gallery a {
    display: block;
    border-radius: var(--radius-sm);
    overflow: hidden;
    border: 1px solid var(--border);
}

.simple-gallery img {
    width: 100%;
    height: 120px;
    object-fit: cover;
    display: block;
}

.simple-comment-form {
    margin-bottom: 16px;
}

.simple-comment-form input,
.simple-comment-form textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-family: inherit;
    margin-bottom: 10px;
    display: block;
}

.simple-comment-form .btn {
    margin-top: 4px;
}

.simple-comment-form textarea {
    resize: vertical;
    min-height: 80px;
}

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

.no-comments {
    margin-top: 12px;
}

.simple-comments {
    margin-top: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.simple-comment {
    padding: 14px;
    background: var(--secondary);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-light);
}

.simple-comment-head {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 6px;
    font-size: 0.85rem;
}

.simple-comment-head span {
    color: var(--text-muted);
}

.simple-comment p {
    font-size: 0.9rem;
    line-height: 1.6;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.task-panel-footer {
    display: flex;
    justify-content: flex-end;
    padding-top: 20px;
    margin-top: 8px;
    border-top: 1px solid var(--border-light);
}

/* Gallery (edit page) */
.image-gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 12px;
}

.image-gallery.small {
    grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
}

.gallery-item {
    display: block;
    border-radius: var(--radius-sm);
    overflow: hidden;
    border: 1px solid var(--border);
    transition: transform 0.15s, box-shadow 0.15s;
}

.gallery-item:hover {
    transform: scale(1.02);
    box-shadow: var(--shadow);
}

.gallery-item img,
.gallery-item-with-delete img {
    width: 100%;
    height: 130px;
    object-fit: cover;
    display: block;
}

.gallery-item-with-delete {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    overflow: hidden;
    transition: border-color 0.15s;
}

.gallery-item-with-delete:hover {
    border-color: var(--danger);
}

.delete-image-label {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 10px;
    font-size: 0.8rem;
    background: var(--secondary);
    cursor: pointer;
    color: var(--text-muted);
    font-weight: 500;
}

.delete-image-label:has(input:checked) {
    background: var(--danger-light);
    color: var(--danger);
}

.status-form .ts-wrapper {
    width: 100%;
}

.text-muted {
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* Responsive */
@media (max-width: 1024px) {
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .container {
        width: 80%;
        padding: 0 16px;
    }

    .main {
        padding: 20px 0 60px;
    }

    .header-inner {
        flex-direction: column;
        height: auto;
        padding: 12px 0;
        gap: 12px;
    }

    .header {
        height: auto;
        position: relative;
    }

    .nav {
        width: 100%;
        justify-content: center;
    }

    .nav a {
        flex: 1;
        text-align: center;
        padding: 8px 10px;
    }

    .page-header {
        flex-direction: column;
    }

    .header-actions {
        width: 100%;
    }

    .header-actions .btn {
        flex: 1;
    }

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

    .project-bar {
        flex-direction: column;
        align-items: stretch;
    }

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

    .project-form-row select {
        max-width: none;
    }

    .project-form-row .ts-wrapper {
        max-width: none;
        width: 100%;
    }

    .task-panel-controls {
        grid-template-columns: 1fr;
    }

    .task-control-row {
        grid-template-columns: 72px 1fr;
    }

    .task-meta-table {
        font-size: 0.75rem;
    }

    .task-meta-table td {
        padding-right: 8px;
    }

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

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

    .form-actions .btn {
        width: 100%;
    }

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

    .pagination-links {
        justify-content: center;
    }
}

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

    .page-header h1 {
        font-size: 1.5rem;
    }
}

/* Auth pages */
.auth-body {
    min-height: 100vh;
    background: #0f172a;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

.auth-bg {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 0;
}

.auth-blob {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    opacity: 0.55;
}

.auth-blob-1 {
    width: 520px;
    height: 520px;
    background: #6366f1;
    top: -120px;
    left: -80px;
    animation: authFloat 18s ease-in-out infinite;
}

.auth-blob-2 {
    width: 420px;
    height: 420px;
    background: #8b5cf6;
    bottom: -100px;
    right: -60px;
    animation: authFloat 22s ease-in-out infinite reverse;
}

.auth-blob-3 {
    width: 280px;
    height: 280px;
    background: #22d3ee;
    top: 40%;
    left: 45%;
    opacity: 0.25;
    animation: authFloat 14s ease-in-out infinite 2s;
}

.auth-grid {
    position: absolute;
    inset: 0;
    background-image:
        linear-gradient(rgba(255, 255, 255, 0.03) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.03) 1px, transparent 1px);
    background-size: 48px 48px;
    mask-image: radial-gradient(ellipse at center, black 30%, transparent 75%);
}

@keyframes authFloat {
    0%, 100% { transform: translate(0, 0) scale(1); }
    33% { transform: translate(30px, -20px) scale(1.05); }
    66% { transform: translate(-20px, 25px) scale(0.95); }
}

.auth-layout {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 420px;
    padding: 1.5rem;
}

.auth-layout-split {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0;
    max-width: 960px;
    min-height: 580px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 24px;
    backdrop-filter: blur(20px);
    box-shadow:
        0 25px 50px -12px rgba(0, 0, 0, 0.45),
        inset 0 1px 0 rgba(255, 255, 255, 0.08);
    overflow: hidden;
    animation: authSlideUp 0.6s cubic-bezier(0.16, 1, 0.3, 1) both;
}

@keyframes authSlideUp {
    from {
        opacity: 0;
        transform: translateY(24px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.auth-showcase {
    padding: 3rem;
    display: flex;
    align-items: center;
    background: linear-gradient(145deg, rgba(99, 102, 241, 0.35) 0%, rgba(139, 92, 246, 0.2) 100%);
    border-right: 1px solid rgba(255, 255, 255, 0.08);
}

.auth-showcase-inner {
    color: #f8fafc;
}

.auth-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 2rem;
}

.auth-logo {
    width: 44px;
    height: 44px;
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(8px);
}

.auth-logo svg {
    width: 22px;
    height: 22px;
    color: #fff;
}

.auth-brand-name {
    font-size: 1.1rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.auth-showcase-title {
    font-size: 1.85rem;
    font-weight: 700;
    line-height: 1.25;
    letter-spacing: -0.03em;
    margin-bottom: 0.75rem;
}

.auth-showcase-text {
    color: rgba(248, 250, 252, 0.75);
    font-size: 0.95rem;
    line-height: 1.65;
    margin-bottom: 2rem;
    max-width: 320px;
}

.auth-features {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
}

.auth-features li {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.9rem;
    color: rgba(248, 250, 252, 0.9);
}

.auth-feature-icon {
    width: 22px;
    height: 22px;
    background: rgba(16, 185, 129, 0.2);
    color: #6ee7b7;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    font-weight: 700;
    flex-shrink: 0;
}

.auth-panel {
    padding: 3rem;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--card);
}

.auth-card {
    width: 100%;
    max-width: 380px;
    padding: 0;
    background: transparent;
    box-shadow: none;
    border: none;
}

.auth-layout:not(.auth-layout-split) .auth-card {
    padding: 2.25rem;
    background: var(--card);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
}

.auth-card-header {
    margin-bottom: 1.75rem;
}

.auth-card-header h1 {
    margin: 0 0 0.4rem;
    font-size: 1.65rem;
    font-weight: 700;
    letter-spacing: -0.03em;
    color: var(--text);
}

.auth-subtitle {
    color: var(--text-muted);
    margin: 0;
    font-size: 0.925rem;
}

.auth-alert {
    margin-bottom: 1.25rem;
}

.auth-form .form-group {
    margin-bottom: 1.15rem;
}

.auth-form label {
    display: block;
    font-size: 0.825rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 0.45rem;
}

.auth-input-wrap {
    position: relative;
    display: flex;
    align-items: center;
}

.auth-input-icon {
    position: absolute;
    left: 14px;
    display: flex;
    align-items: center;
    pointer-events: none;
    color: var(--text-light);
}

.auth-input-icon svg {
    width: 18px;
    height: 18px;
}

.auth-input-wrap input {
    width: 100%;
    padding: 0.75rem 2.75rem 0.75rem 2.75rem;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.925rem;
    font-family: inherit;
    color: var(--text);
    background: var(--secondary);
    transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
}

.auth-input-wrap input::placeholder {
    color: var(--text-light);
}

.auth-input-wrap input:hover {
    border-color: #cbd5e1;
}

.auth-input-wrap input:focus {
    outline: none;
    border-color: var(--primary);
    background: var(--card);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

.auth-password-toggle {
    position: absolute;
    right: 10px;
    background: none;
    border: none;
    padding: 6px;
    cursor: pointer;
    color: var(--text-light);
    display: flex;
    align-items: center;
    border-radius: 6px;
    transition: color 0.15s, background 0.15s;
}

.auth-password-toggle:hover {
    color: var(--text-muted);
    background: var(--border-light);
}

.auth-password-toggle svg {
    width: 18px;
    height: 18px;
}

.auth-password-toggle .icon-hide {
    display: none;
}

.auth-password-toggle.is-visible .icon-show {
    display: none;
}

.auth-password-toggle.is-visible .icon-hide {
    display: block;
}

.auth-submit {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-top: 0.75rem;
    padding: 0.8rem 1.25rem;
    font-size: 0.95rem;
    font-weight: 600;
    border-radius: var(--radius-sm);
    box-shadow: 0 4px 14px rgba(99, 102, 241, 0.35);
    transition: transform 0.15s, box-shadow 0.15s, background 0.15s;
}

.auth-submit svg {
    width: 18px;
    height: 18px;
    transition: transform 0.15s;
}

.auth-submit:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(99, 102, 241, 0.45);
}

.auth-submit:hover svg {
    transform: translateX(2px);
}

.btn-block {
    width: 100%;
}

.auth-footer-text {
    text-align: center;
    margin: 1.75rem 0 0;
    color: var(--text-muted);
    font-size: 0.875rem;
}

.auth-footer-text a {
    color: var(--primary);
    font-weight: 600;
    text-decoration: none;
}

.auth-footer-text a:hover {
    color: var(--primary-dark);
    text-decoration: underline;
}

.auth-flash {
    width: 100%;
    margin-bottom: 1rem;
}

.nav-user {
    color: var(--text-muted);
    font-size: 0.9rem;
    padding: 0 0.5rem;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.nav-role {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 2px 8px;
    border-radius: 999px;
}

.badge-role-admin {
    background: #fef3c7;
    color: #b45309;
}

.badge-role-user {
    background: var(--primary-light);
    color: var(--primary-dark);
}

/* Create user page */
.user-create-header {
    align-items: flex-start;
}

.user-create-header .btn svg {
    width: 16px;
    height: 16px;
}

.user-create-header-text {
    flex: 1;
}

.user-create-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #b45309;
    background: #fffbeb;
    border: 1px solid #fde68a;
    padding: 4px 10px;
    border-radius: 999px;
    margin-bottom: 10px;
}

.user-create-badge svg {
    width: 14px;
    height: 14px;
}

.user-create-layout {
    display: grid;
    grid-template-columns: 300px 1fr;
    gap: 24px;
    align-items: start;
}

.user-create-aside {
    padding: 1.5rem;
    position: sticky;
    top: calc(var(--header-height) + 20px);
}

.user-create-aside h2 {
    font-size: 1rem;
    font-weight: 700;
    margin-bottom: 6px;
    letter-spacing: -0.02em;
}

.user-create-aside-text {
    color: var(--text-muted);
    font-size: 0.875rem;
    margin-bottom: 1.25rem;
    line-height: 1.5;
}

.role-guide-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 1.25rem;
}

.role-guide-item {
    display: flex;
    gap: 12px;
    padding: 12px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-light);
    background: var(--secondary);
}

.role-guide-icon {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.role-guide-icon svg {
    width: 18px;
    height: 18px;
}

.role-guide-admin .role-guide-icon {
    background: #fffbeb;
    color: #b45309;
}

.role-guide-user .role-guide-icon {
    background: var(--primary-light);
    color: var(--primary);
}

.role-guide-item strong {
    display: block;
    font-size: 0.875rem;
    margin-bottom: 2px;
}

.role-guide-item p {
    font-size: 0.8rem;
    color: var(--text-muted);
    line-height: 1.45;
    margin: 0;
}

.user-create-tip {
    display: flex;
    gap: 10px;
    padding: 12px;
    background: var(--primary-light);
    border-radius: var(--radius-sm);
    border: 1px solid #c7d2fe;
}

.user-create-tip-icon {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    font-size: 0.75rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.user-create-tip p {
    font-size: 0.8rem;
    color: var(--primary-dark);
    line-height: 1.45;
    margin: 0;
}

.user-create-form {
    padding: 1.75rem;
}

.input-icon-wrap {
    position: relative;
    display: flex;
    align-items: center;
}

.input-icon-wrap .input-icon {
    position: absolute;
    left: 12px;
    color: var(--text-light);
    display: flex;
    pointer-events: none;
}

.input-icon-wrap .input-icon svg {
    width: 17px;
    height: 17px;
}

.input-icon-wrap input {
    width: 100%;
    padding: 11px 42px 11px 40px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-family: inherit;
    background: var(--card);
    color: var(--text);
    transition: border-color 0.15s, box-shadow 0.15s;
}

.input-icon-wrap input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

.input-toggle {
    position: absolute;
    right: 8px;
    background: none;
    border: none;
    padding: 6px;
    cursor: pointer;
    color: var(--text-light);
    display: flex;
    border-radius: 6px;
}

.input-toggle:hover {
    color: var(--text-muted);
    background: var(--border-light);
}

.input-toggle svg {
    width: 17px;
    height: 17px;
}

.input-toggle .icon-hide {
    display: none;
}

.input-toggle.is-visible .icon-show {
    display: none;
}

.input-toggle.is-visible .icon-hide {
    display: block;
}

.field-hint {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 10px;
}

.role-picker {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}

.role-card {
    cursor: pointer;
}

.role-card input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.role-card-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 8px;
    padding: 1.25rem 1rem;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    background: var(--secondary);
    transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
}

.role-card input:checked + .role-card-inner {
    border-color: var(--primary);
    background: var(--primary-light);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.12);
}

.role-card:hover .role-card-inner {
    border-color: #c7d2fe;
}

.role-card-icon {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.role-card-icon svg {
    width: 22px;
    height: 22px;
}

.role-card-icon-user {
    background: var(--primary-light);
    color: var(--primary);
}

.role-card-icon-admin {
    background: #fffbeb;
    color: #b45309;
}

.role-card-label {
    font-weight: 700;
    font-size: 0.95rem;
    color: var(--text);
}

.role-card-desc {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.user-create-actions .btn-primary {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.user-create-actions .btn-primary svg {
    width: 18px;
    height: 18px;
}

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

    .user-create-aside {
        position: static;
    }
}

@media (max-width: 600px) {
    .role-picker,
    .user-create-form .form-row {
        grid-template-columns: 1fr;
    }

    .user-create-form {
        padding: 1.25rem;
    }
}

@media (max-width: 768px) {
    .auth-layout-split {
        grid-template-columns: 1fr;
        max-width: 440px;
        min-height: auto;
    }

    .auth-showcase {
        display: none;
    }

    .auth-panel {
        padding: 2rem 1.75rem;
    }

    .auth-body-split .auth-layout-split {
        border-radius: 20px;
    }
}

@media (max-width: 480px) {
    .auth-layout,
    .auth-layout-split {
        padding: 1rem;
        border-radius: 16px;
    }

    .auth-panel {
        padding: 1.75rem 1.25rem;
    }

    .auth-card-header h1 {
        font-size: 1.45rem;
    }
}
