/* ===== CSS Variables ===== */
:root {
    --primary-color: #0097a7;
    --primary-dark: #006978;
    --primary-light: #4dd0e1;
    --secondary-color: #0288d1;
    --secondary-dark: #01579b;
    --background: #f5f5f5;
    --surface: #ffffff;
    --error: #b00020;
    --success: #4caf50;
    --on-primary: #ffffff;
    --on-surface: #212121;
    --on-surface-medium: #666666;
    --on-surface-disabled: #9e9e9e;
    --divider: #e0e0e0;
    --high-priority: #f44336;
    --medium-priority: #ff9800;
    --low-priority: #4caf50;
    --shadow-1: 0 2px 1px -1px rgba(0,0,0,0.2), 0 1px 1px 0 rgba(0,0,0,0.14), 0 1px 3px 0 rgba(0,0,0,0.12);
    --shadow-2: 0 3px 1px -2px rgba(0,0,0,0.2), 0 2px 2px 0 rgba(0,0,0,0.14), 0 1px 5px 0 rgba(0,0,0,0.12);
    --shadow-3: 0 3px 3px -2px rgba(0,0,0,0.2), 0 3px 4px 0 rgba(0,0,0,0.14), 0 1px 8px 0 rgba(0,0,0,0.12);
    --shadow-4: 0 2px 4px -1px rgba(0,0,0,0.2), 0 4px 5px 0 rgba(0,0,0,0.14), 0 1px 10px 0 rgba(0,0,0,0.12);
    --radius: 8px;
    --sidebar-width: 280px;
}

/* ===== Reset & Base ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Roboto', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: var(--background);
    color: var(--on-surface);
    line-height: 1.5;
    overflow: hidden;
}

.hidden {
    display: none !important;
}

/* ===== App Container ===== */
.app-container {
    display: flex;
    height: 100vh;
    height: 100dvh;
}

/* ===== Auth Screen ===== */
.auth-screen {
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-dark) 100%);
}

.auth-container {
    width: 100%;
    max-width: 420px;
    padding: 24px;
}

.auth-header {
    text-align: center;
    margin-bottom: 32px;
    color: white;
}

.auth-icon {
    font-size: 64px;
    margin-bottom: 16px;
}

.auth-logo {
    width: 80px;
    height: 80px;
    margin-bottom: 8px;
}

.sidebar-logo {
    width: 36px;
    height: 36px;
    flex-shrink: 0;
}

.auth-header h1 {
    font-size: 32px;
    font-weight: 500;
    margin-bottom: 8px;
}

.auth-subtitle {
    font-size: 14px;
    opacity: 0.8;
}

.auth-tabs {
    display: flex;
    background: rgba(255, 255, 255, 0.2);
    border-radius: var(--radius) var(--radius) 0 0;
    overflow: hidden;
}

.auth-tab {
    flex: 1;
    padding: 16px;
    border: none;
    background: transparent;
    color: rgba(255, 255, 255, 0.7);
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.auth-tab.active {
    background: var(--surface);
    color: var(--on-surface);
}

.auth-form {
    background: var(--surface);
    padding: 32px 24px;
    border-radius: 0 0 var(--radius) var(--radius);
    box-shadow: var(--shadow-4);
}

.input-with-icon {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border: 1px solid var(--divider);
    border-radius: var(--radius);
    transition: border-color 0.2s;
}

.input-with-icon:focus-within {
    border-color: var(--primary-color);
}

.input-with-icon .material-icons {
    color: var(--on-surface-medium);
    font-size: 20px;
}

.input-with-icon input {
    flex: 1;
    border: none;
    background: transparent;
    font-size: 16px;
    outline: none;
    color: var(--on-surface);
}

.toggle-password {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
}

.toggle-password .material-icons {
    color: var(--on-surface-medium);
}

.btn-full {
    width: 100%;
    margin-top: 16px;
}

.auth-error {
    color: var(--error);
    font-size: 14px;
    margin-top: 16px;
    text-align: center;
    min-height: 20px;
}

/* ===== Main App ===== */
.main-app {
    display: flex;
    width: 100%;
    height: 100vh;
    height: 100dvh;
}

/* ===== Sidebar ===== */
.sidebar {
    width: var(--sidebar-width);
    background: var(--surface);
    box-shadow: var(--shadow-2);
    display: flex;
    flex-direction: column;
    z-index: 10;
}

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

.sidebar-header .material-icons {
    font-size: 32px;
    color: var(--primary-color);
}

.sidebar-header h1 {
    font-size: 24px;
    font-weight: 500;
    color: var(--primary-color);
}

.sidebar-nav {
    padding: 8px 0;
    border-bottom: 1px solid var(--divider);
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 16px;
    width: 100%;
    padding: 12px 16px;
    border: none;
    background: transparent;
    text-align: left;
    font-size: 14px;
    font-weight: 500;
    color: var(--on-surface);
    cursor: pointer;
    border-radius: 0;
    transition: background 0.2s;
    text-decoration: none;
}

#usersNavItem,
.nav-item[data-filter="noit"] {
    display: none;
}

#usersNavItem.can-view-users,
.nav-item[data-filter="noit"].can-view-noit {
    display: flex;
}

.nav-item:hover {
    background: rgba(0, 151, 167, 0.08);
}

.nav-item.active {
    background: rgba(0, 151, 167, 0.12);
    color: var(--primary-color);
}

.nav-item .material-icons {
    font-size: 24px;
    color: var(--on-surface-medium);
}

.nav-item.active .material-icons,
.nav-item:hover .material-icons {
    color: var(--primary-color);
}

/* ===== Categories Section ===== */
.categories-section {
    padding: 16px;
    flex: 1;
    overflow-y: auto;
    min-height: 0;
}

.branches-section {
    padding: 16px;
    max-height: 200px;
    overflow-y: auto;
    border-top: 1px solid var(--divider);
}

.districts-section {
    padding: 16px;
    max-height: 200px;
    overflow-y: auto;
    border-top: 1px solid var(--divider);
}

.district-item {
    cursor: pointer;
}

.district-item:hover {
    background: var(--hover);
}

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

.categories-header h2 {
    font-size: 14px;
    font-weight: 500;
    color: var(--on-surface-medium);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.category-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 12px;
    border-radius: var(--radius);
    cursor: pointer;
    transition: background 0.2s;
    margin-bottom: 4px;
}

.category-item:hover {
    background: var(--background);
}

.category-item.active {
    background: rgba(0, 151, 167, 0.12);
}

.category-color {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    flex-shrink: 0;
}

.category-item span:last-child {
    flex: 1;
    font-size: 14px;
}

.category-delete {
    opacity: 0;
    transition: opacity 0.2s;
}

.category-item:hover .category-delete {
    opacity: 1;
}

/* ===== Stats Section ===== */
.stats-section {
    padding: 16px;
    border-top: 1px solid var(--divider);
}

.stats-section h2 {
    font-size: 14px;
    font-weight: 500;
    color: var(--on-surface-medium);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 12px;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}

.stat-item {
    text-align: center;
    padding: 8px;
    background: var(--background);
    border-radius: var(--radius);
}

.stat-value {
    display: block;
    font-size: 24px;
    font-weight: 500;
    color: var(--primary-color);
}

.stat-label {
    display: block;
    font-size: 11px;
    color: var(--on-surface-medium);
    margin-top: 4px;
}

/* ===== User Section ===== */
.user-section {
    padding: 16px;
    border-top: 1px solid var(--divider);
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: auto;
}

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

.user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--primary-color);
    color: var(--on-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    font-weight: 500;
}

.user-details {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.user-name {
    font-size: 14px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-role {
    font-size: 12px;
    color: var(--on-surface-medium);
}

.btn-logout {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 10px;
}

.btn-logout .material-icons {
    font-size: 18px;
}

/* ===== Main Content ===== */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* ===== Top Bar ===== */
.top-bar {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px 24px;
    padding-top: max(16px, env(safe-area-inset-top, 0));
    background: var(--surface);
    box-shadow: var(--shadow-1);
    z-index: 5;
    flex-shrink: 0;
}

.search-box {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 16px;
    background: var(--background);
    border-radius: 24px;
}

.search-box .material-icons {
    color: var(--on-surface-medium);
}

.search-box input {
    flex: 1;
    border: none;
    background: transparent;
    font-size: 14px;
    outline: none;
    color: var(--on-surface);
}

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

.view-toggle {
    display: flex;
    border: 1px solid var(--divider);
    border-radius: var(--radius);
    overflow: hidden;
}

.view-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 36px;
    border: none;
    background: transparent;
    cursor: pointer;
    transition: all 0.2s;
}

.view-btn .material-icons {
    font-size: 20px;
    color: var(--on-surface-medium);
}

.view-btn.active {
    background: var(--primary-color);
}

.view-btn.active .material-icons {
    color: var(--on-primary);
}

.view-btn:hover:not(.active) {
    background: var(--background);
}

.filter-select {
    padding: 8px 32px 8px 12px;
    border: 1px solid var(--divider);
    border-radius: var(--radius);
    background: var(--surface);
    font-size: 14px;
    color: var(--on-surface);
    cursor: pointer;
    outline: none;
}

.filter-select:focus {
    border-color: var(--primary-color);
}

/* ===== Icon Button ===== */
.icon-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border: none;
    background: transparent;
    border-radius: 50%;
    cursor: pointer;
    transition: background 0.2s;
}

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

.icon-btn .material-icons {
    color: var(--on-surface-medium);
}

.material-icons {
    font-family: 'Material Icons';
    font-weight: normal;
    font-style: normal;
    font-size: 24px;
    line-height: 1;
    letter-spacing: normal;
    text-transform: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1em;
    height: 1em;
    overflow: hidden;
    white-space: nowrap;
    word-wrap: normal;
    direction: ltr;
    font-feature-settings: 'liga';
    -webkit-font-smoothing: antialiased;
}

.material-icons-fallback {
    font-family: 'Segoe UI Symbol', 'Apple Color Emoji', 'Noto Color Emoji', sans-serif !important;
    font-style: normal;
    font-weight: 400;
    line-height: 1;
    letter-spacing: normal;
    text-transform: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1em;
    height: 1em;
}

/* ===== Tasks Section ===== */
.tasks-section {
    flex: 1;
    padding: 24px;
    overflow-y: auto;
}

.tasks-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 24px;
}

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

.tasks-count {
    font-size: 14px;
    color: var(--on-surface-medium);
}

/* ===== Task Item ===== */
.tasks-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

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

.tasks-grid .task-item {
    flex-direction: column;
    border: 1px solid var(--border-color, #e0e0e0);
    border-radius: 12px;
    padding: 12px;
    background: var(--surface, #fff);
    cursor: pointer;
    transition: box-shadow 0.2s;
}

.tasks-grid .task-item:hover {
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.tasks-grid .task-checkbox {
    align-self: flex-start;
}

.tasks-grid .task-content {
    width: 100%;
}

.tasks-grid .task-meta {
    flex-wrap: wrap;
}

.tasks-grid .task-assignees {
    margin-top: 8px;
}

.task-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 16px;
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow-1);
    transition: box-shadow 0.2s, transform 0.2s;
    animation: slideIn 0.3s ease-out;
    cursor: pointer;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.task-item:hover {
    box-shadow: var(--shadow-3);
}

.task-item.completed {
    opacity: 0.6;
}

.task-item.completed .task-title {
    text-decoration: line-through;
}

.task-checkbox {
    position: relative;
    width: 20px;
    height: 20px;
    margin-top: 2px;
    flex-shrink: 0;
}

.task-checkbox input {
    position: absolute;
    opacity: 0;
    width: 100%;
    height: 100%;
    cursor: pointer;
}

.task-checkbox .checkmark {
    position: absolute;
    top: 0;
    left: 0;
    width: 20px;
    height: 20px;
    border: 2px solid var(--on-surface-medium);
    border-radius: 4px;
    transition: all 0.2s;
}

.task-checkbox input:checked + .checkmark {
    background: var(--primary-color);
    border-color: var(--primary-color);
}

.task-checkbox input:checked + .checkmark::after {
    content: '';
    position: absolute;
    left: 6px;
    top: 2px;
    width: 5px;
    height: 10px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

.task-content {
    flex: 1;
    min-width: 0;
}

.task-title {
    font-size: 16px;
    font-weight: 400;
    margin-bottom: 4px;
}

.task-description {
    font-size: 14px;
    color: var(--on-surface-medium);
    margin-bottom: 8px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

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

.task-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
}

.badge-priority-high {
    background: rgba(244, 67, 54, 0.12);
    color: var(--high-priority);
}

.badge-priority-medium {
    background: rgba(255, 152, 0, 0.12);
    color: var(--medium-priority);
}

.badge-priority-low {
    background: rgba(76, 175, 80, 0.12);
    color: var(--low-priority);
}

.badge-category {
    background: rgba(0, 151, 167, 0.12);
    color: var(--primary-color);
}

.badge-due {
    background: var(--background);
    color: var(--on-surface-medium);
}

.badge-due.overdue {
    background: rgba(244, 67, 54, 0.12);
    color: var(--high-priority);
}

.badge-subtasks {
    background: rgba(3, 218, 198, 0.12);
    color: var(--secondary-dark);
}

.badge-photos {
    background: rgba(156, 39, 176, 0.12);
    color: #9C27B0;
}

.badge-assignees {
    background: rgba(33, 150, 243, 0.12);
    color: #2196F3;
}

.badge-author {
    background: rgba(255, 152, 0, 0.12);
    color: #FF9800;
}

.task-actions {
    display: flex;
    gap: 4px;
    opacity: 0;
    transition: opacity 0.2s;
}

.task-item:hover .task-actions {
    opacity: 1;
}

.task-actions .icon-btn {
    width: 32px;
    height: 32px;
}

.task-actions .icon-btn .material-icons {
    font-size: 18px;
}

.task-actions .delete-btn:hover .material-icons {
    color: var(--error);
}

/* ===== Empty State ===== */
.empty-state {
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 64px 24px;
    text-align: center;
}

.empty-state.visible {
    display: flex;
}

.empty-state .material-icons {
    font-size: 96px;
    color: var(--on-surface-disabled);
    margin-bottom: 16px;
}

.empty-state h3 {
    font-size: 20px;
    font-weight: 500;
    margin-bottom: 8px;
}

.empty-state p {
    font-size: 14px;
    color: var(--on-surface-medium);
}

/* ===== Loading State ===== */
.loading-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 48px 16px;
    text-align: center;
}

.loading-state p {
    font-size: 14px;
    color: var(--on-surface-medium);
    margin-top: 16px;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--outline-variant, #e0e0e0);
    border-top-color: var(--primary, #6750A4);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* ===== Calendar ===== */
.calendar-section {
    flex: 1;
    padding: 24px;
    overflow-y: auto;
}

.calendar-header {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 24px;
    margin-bottom: 24px;
}

.calendar-header h2 {
    font-size: 24px;
    font-weight: 400;
    min-width: 200px;
    text-align: center;
}

.calendar-nav {
    width: 48px;
    height: 48px;
}

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 1px;
    background: var(--divider);
    border-radius: var(--radius);
    overflow: hidden;
}

.calendar-weekday {
    padding: 12px;
    background: var(--surface);
    text-align: center;
    font-size: 12px;
    font-weight: 500;
    color: var(--on-surface-medium);
    text-transform: uppercase;
}

.calendar-day {
    min-height: 100px;
    padding: 8px;
    background: var(--surface);
    position: relative;
}

.calendar-day.empty {
    background: rgba(0, 0, 0, 0.02);
}

.calendar-day.has-tasks {
    background: rgba(76, 175, 80, 0.05);
    border: 1px solid rgba(76, 175, 80, 0.2);
}

.calendar-day.has-tasks:hover {
    background: rgba(76, 175, 80, 0.1);
}

.calendar-day.today {
    background: rgba(98, 0, 238, 0.05);
}

.calendar-day-number {
    font-size: 14px;
    font-weight: 500;
    color: var(--on-surface);
    margin-bottom: 4px;
}

.calendar-day.today .calendar-day-number {
    background: var(--primary-color);
    color: white;
    border-radius: 50%;
}

.calendar-day.has-tasks .calendar-day-number {
    background: rgba(76, 175, 80, 0.2);
    border-radius: 2px;
    font-weight: bold;
}

.calendar-task {
    padding: 2px 4px;
    border-radius: 3px;
    font-size: 10px;
    margin-bottom: 1px;
    cursor: pointer;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: all 0.2s;
    border: 1px solid transparent;
    min-height: 16px;
    line-height: 1.2;
}

.calendar-task:hover {
    opacity: 0.8;
}

.calendar-task.completed {
    opacity: 0.5;
    text-decoration: line-through;
}

.calendar-task-high {
    background: rgba(244, 67, 54, 0.15);
    color: var(--high-priority);
    border-left: 2px solid var(--high-priority);
}

.calendar-task-medium {
    background: rgba(255, 152, 0, 0.15);
    color: var(--medium-priority);
    border-left: 2px solid var(--medium-priority);
}

.calendar-task-low {
    background: rgba(76, 175, 80, 0.15);
    color: var(--low-priority);
    border-left: 2px solid var(--low-priority);
}

/* ===== Users Section ===== */
.users-section {
    flex: 1;
    padding: 24px;
    overflow-y: auto;
}

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

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

.users-header .btn {
    display: flex;
    align-items: center;
    gap: 8px;
}

.users-header .material-icons {
    font-size: 20px;
}

.users-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.user-item {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px;
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow-1);
}

.user-avatar-lg {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--primary-color);
    color: var(--on-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    font-weight: 500;
    flex-shrink: 0;
}

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

.user-info .user-name {
    font-size: 16px;
    font-weight: 500;
    margin-bottom: 4px;
}

.user-info .user-email {
    font-size: 14px;
    color: var(--on-surface-medium);
    margin-bottom: 4px;
}

.user-info .user-meta {
    font-size: 12px;
    color: var(--on-surface-disabled);
}

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

.role-employee {
    background: rgba(76, 175, 80, 0.12);
    color: var(--low-priority);
}

.role-manager {
    background: rgba(255, 152, 0, 0.12);
    color: var(--medium-priority);
}

.role-director {
    background: rgba(33, 150, 243, 0.12);
    color: #2196F3;
}

.role-dept-head {
    background: rgba(156, 39, 176, 0.12);
    color: #9C27B0;
}

.role-admin {
    background: rgba(244, 67, 54, 0.12);
    color: var(--high-priority);
}

.user-status {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    flex-shrink: 0;
}

.user-status.active {
    background: var(--success);
}

.user-status.inactive {
    background: var(--on-surface-disabled);
}

.user-item .task-actions {
    display: flex;
    gap: 4px;
    opacity: 0;
    transition: opacity 0.2s;
}

.user-item:hover .task-actions {
    opacity: 1;
}

/* ===== FAB Button ===== */
.fab {
    position: fixed;
    bottom: 32px;
    right: 32px;
    width: 56px;
    height: 56px;
    border: none;
    background: var(--secondary-color);
    border-radius: 16px;
    box-shadow: var(--shadow-4);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    z-index: 20;
}

.fab:hover {
    box-shadow: 0 6px 10px -4px rgba(0,0,0,0.2), 0 8px 10px 0 rgba(0,0,0,0.14), 0 3px 14px 0 rgba(0,0,0,0.12);
    transform: scale(1.05);
}

.fab .material-icons {
    font-size: 24px;
    color: #000;
}

/* ===== Modal ===== */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 100;
}

.modal.visible {
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
}

.modal-content {
    position: relative;
    width: 100%;
    max-width: 560px;
    max-height: 90vh;
    margin: 0 24px;
    background: var(--surface);
    border-radius: 16px;
    box-shadow: var(--shadow-4);
    overflow-y: auto;
    animation: modalIn 0.3s ease-out;
}

/* Modals without modal-header/form wrapper need padding */
#remindModal .modal-content,
#avatarModal .modal-content {
    padding: 24px;
}

@keyframes modalIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.modal-small {
    max-width: 480px;
}

.modal-small .modal-header {
    padding: 20px 24px 0;
}

.modal-small form {
    padding: 16px 24px 20px;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 24px 24px 0;
}

.modal-header h2 {
    font-size: 20px;
    font-weight: 500;
}

/* ===== Form ===== */
.task-form,
.category-form {
    padding: 24px;
}

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

.form-group label {
    display: block;
    font-size: 12px;
    font-weight: 500;
    color: var(--on-surface-medium);
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.form-group input:not([type="checkbox"]):not([type="radio"]),
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid var(--divider);
    border-radius: var(--radius);
    font-size: 16px;
    font-family: inherit;
    color: var(--on-surface);
    background: var(--surface);
    transition: border-color 0.2s;
}

.form-group input:not([type="checkbox"]):not([type="radio"]):focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary-color);
}

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

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

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

/* ===== Buttons ===== */
.btn {
    padding: 10px 24px;
    border: none;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.2s;
}

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

.btn-primary:hover {
    background: var(--primary-dark);
    box-shadow: var(--shadow-2);
}

.btn-text {
    background: transparent;
    color: var(--primary-color);
}

.btn-text:hover {
    background: rgba(0, 151, 167, 0.08);
}

/* ===== Color Picker ===== */
.color-picker {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.color-option {
    width: 32px;
    height: 32px;
    border: 2px solid transparent;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.2s;
}

.color-option:hover {
    transform: scale(1.1);
}

.color-option.active {
    border-color: var(--on-surface);
    box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--on-surface);
}

/* ===== Scrollbar ===== */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--on-surface-disabled);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--on-surface-medium);
}

/* ===== Subtasks ===== */
.subtasks-container {
    border: 1px solid var(--divider);
    border-radius: var(--radius);
    padding: 12px;
}

.subtasks-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 8px;
}

.subtask-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px;
    background: var(--background);
    border-radius: var(--radius);
}

.subtask-item input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.subtask-item .subtask-text {
    flex: 1;
    font-size: 14px;
}

.subtask-item .subtask-text.completed {
    text-decoration: line-through;
    color: var(--on-surface-disabled);
}

.subtask-item .delete-subtask-btn {
    opacity: 0;
    transition: opacity 0.2s;
}

.subtask-item:hover .delete-subtask-btn {
    opacity: 1;
}

.add-subtask-row {
    display: flex;
    gap: 8px;
}

.add-subtask-row input {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid var(--divider);
    border-radius: var(--radius);
    font-size: 14px;
}

.add-subtask-row input:focus {
    outline: none;
    border-color: var(--primary-color);
}

.btn-small {
    padding: 8px 12px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-small .material-icons {
    font-size: 20px;
}

/* ===== Assign Buttons & Users List ===== */
.assign-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 12px;
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--divider);
    color: var(--on-surface);
    padding: 8px 14px;
    border-radius: var(--radius);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.btn-outline:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
    background: rgba(0, 151, 167, 0.04);
}

.btn-outline.active {
    border-color: var(--primary-color);
    background: rgba(0, 151, 167, 0.12);
    color: var(--primary-color);
}

.assign-users-list {
    max-height: 200px;
    overflow-y: auto;
    border: 1px solid var(--divider);
    border-radius: var(--radius);
    padding: 4px;
}

.assign-user-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.15s;
    font-size: 14px;
}

.assign-user-item:hover {
    background: var(--background);
}

.assign-user-item.selected {
    background: rgba(0, 151, 167, 0.08);
}

.assign-user-item input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: var(--primary-color);
}

.assign-user-item .assign-user-name {
    flex: 1;
}

.assign-user-item .assign-user-branch {
    font-size: 12px;
    color: var(--on-surface-disabled);
}

.assign-users-empty {
    padding: 16px;
    text-align: center;
    color: var(--on-surface-disabled);
    font-size: 14px;
}

/* ===== Subtask Verification States ===== */
.subtask-display-item.completed {
    background: rgba(255, 152, 0, 0.06);
    border-left: 3px solid #FF9800;
}

.subtask-display-item.verified {
    background: rgba(76, 175, 80, 0.06);
    border-left: 3px solid #4CAF50;
}

.subtask-status-icon {
    display: flex;
    align-items: center;
    flex-shrink: 0;
}

.subtask-status-icon.pending-verify {
    color: #FF9800;
}

.subtask-status-icon.verified {
    color: #4CAF50;
}

.subtask-verified-info {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    color: #4CAF50;
}

.btn-verify-subtask {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-top: 6px;
    padding: 4px 12px;
    font-size: 12px;
    font-weight: 500;
    color: white;
    background: #4CAF50;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    transition: background 0.2s;
}

.btn-verify-subtask:hover {
    background: #388E3C;
}

.btn-verify-subtask .material-icons {
    font-size: 14px !important;
}

.subtask-display-item.completed .subtask-display-text {
    text-decoration: line-through;
    color: var(--on-surface-disabled);
}

.subtask-display-item.verified .subtask-display-text {
    text-decoration: line-through;
    color: var(--on-surface-disabled);
}

/* ===== Subtask Plan/Fact/Progress ===== */
.subtask-plan-fact {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 8px;
    flex-wrap: wrap;
}

.subtask-field {
    display: flex;
    align-items: center;
    gap: 6px;
}

.subtask-field label {
    font-size: 12px;
    color: var(--on-surface-disabled);
    font-weight: 500;
    min-width: 36px;
}

.subtask-plan-input,
.subtask-fact-input {
    width: 80px;
    padding: 4px 8px;
    font-size: 13px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--on-surface);
    text-align: center;
}

.subtask-plan-input:focus,
.subtask-fact-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(var(--primary-rgb), 0.2);
}

.subtask-plan-display,
.subtask-fact-display {
    font-size: 13px;
    font-weight: 500;
    color: var(--on-surface);
    min-width: 30px;
}

.subtask-progress {
    position: relative;
    width: 100px;
    height: 20px;
    background: var(--surface-variant);
    border-radius: 10px;
    overflow: hidden;
}

.subtask-progress-bar {
    height: 100%;
    border-radius: 10px;
    transition: width 0.3s ease;
}

.subtask-progress-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 11px;
    font-weight: 600;
    color: var(--on-surface);
    z-index: 1;
}

.subtask-comment-input {
    width: 100%;
    margin-top: 6px;
    padding: 6px 10px;
    font-size: 13px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--on-surface);
    resize: vertical;
    min-height: 60px;
    font-family: inherit;
}

.subtask-comment-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(var(--primary-rgb), 0.2);
}

.subtask-comment-wrapper {
    margin-top: 6px;
}

.subtask-comment-toggle {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    color: var(--on-surface-medium);
    cursor: pointer;
    padding: 2px 6px;
    border-radius: var(--radius);
    transition: background 0.2s;
}

.subtask-comment-toggle:hover {
    background: var(--surface-variant);
    color: var(--primary);
}

.subtask-comment-expandable {
    margin-top: 4px;
}

.subtask-comment-display {
    white-space: pre-wrap;
    font-size: 13px;
    color: var(--on-surface-medium);
    padding: 6px 10px;
    background: var(--surface-variant);
    border-radius: var(--radius);
}

/* ===== Subsubtasks ===== */
.subtask-main-row {
    display: flex;
    align-items: center;
    gap: 8px;
}
.subsubtasks-container {
    margin-left: 28px;
    margin-top: 4px;
    padding-left: 12px;
    border-left: 2px solid var(--border-color, #e0e0e0);
}
.subsubtask-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 3px 0;
    font-size: 13px;
}
.subsubtask-text {
    flex: 1;
    color: var(--on-surface, #333);
}
.subsubtask-text.completed {
    text-decoration: line-through;
    opacity: 0.5;
}
.subsubtask-due {
    font-size: 11px;
    color: var(--on-surface-medium, #888);
    white-space: nowrap;
}
.subsubtask-badge {
    font-size: 10px;
    background: var(--primary, #1976d2);
    color: #fff;
    border-radius: 10px;
    padding: 0 5px;
    margin-left: 2px;
    line-height: 16px;
}
.add-subsubtask-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 6px;
}
.subsubtask-input {
    flex: 1;
    padding: 4px 8px;
    font-size: 12px;
    border: 1px solid var(--border-color, #e0e0e0);
    border-radius: 4px;
    background: var(--surface, #fff);
    color: var(--on-surface, #333);
}
.subsubtask-input:focus {
    outline: none;
    border-color: var(--primary);
}
.subsubtask-expanded-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 0;
    font-size: 16px;
    flex-wrap: wrap;
}
.subsubtask-expanded-item > span:first-of-type {
    flex: 0 1 auto;
    min-width: 0;
    word-break: break-word;
}

.subsubtask-comment-input,
.subsubtask-comment-display {
    flex: 0 1 180px !important;
    max-width: 180px !important;
}

.subsubtask-completed-date {
    flex: 0 0 auto;
    white-space: nowrap;
}

@media (max-width: 768px) {
    .subsubtask-expanded-item > span:first-of-type {
        flex: 1 1 auto;
    }

    .subsubtask-comment-input,
    .subsubtask-comment-display {
        flex: 1 1 100% !important;
        max-width: 100% !important;
    }

    .subsubtask-completed-date {
        flex: 1 1 100%;
    }
}
.subsubtask-plan-input,
.subsubtask-fact-input {
    width: 70px;
    font-size: 13px;
    padding: 3px 6px;
    border: 1px solid var(--border-color, #e0e0e0);
    border-radius: 4px;
    background: var(--surface, #fff);
}
.subsubtask-plan-display {
    font-size: 13px;
    color: var(--primary, #1976d2);
}
.subsubtask-fact-display {
    font-size: 13px;
    color: #4CAF50;
}
.subsubtask-due-input {
    padding: 3px 6px;
    border: 1px solid var(--border-color, #e0e0e0);
    border-radius: 4px;
    background: var(--surface, #fff);
}

/* ===== Photos ===== */
.photos-container {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.photos-preview {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.photo-preview-item {
    position: relative;
    width: 80px;
    height: 80px;
    border-radius: var(--radius);
    overflow: hidden;
}

.photo-preview-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.photo-preview-item .remove-photo {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 20px;
    height: 20px;
    background: rgba(0, 0, 0, 0.6);
    border: none;
    border-radius: 50%;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
}

.upload-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}

.upload-btn .material-icons {
    font-size: 20px;
}

/* ===== Task Expanded View ===== */
.task-expanded-container {
    margin-top: 16px;
    animation: slideIn 0.3s ease-out;
}

.task-expanded {
    background: var(--surface);
    border-radius: 12px;
    box-shadow: var(--shadow-3);
    overflow: hidden;
}

.task-expanded-header {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 20px 24px;
    border-bottom: 1px solid var(--divider);
}

.task-expanded-header h2 {
    flex: 1;
    font-size: 20px;
    font-weight: 500;
}

.task-expanded-edit {
    margin-left: auto;
    opacity: 0.7;
    transition: opacity 0.2s;
}

.task-expanded-edit:hover {
    opacity: 1;
}

.task-expanded-body {
    padding: 24px;
    padding-bottom: 80px;
}

.task-expanded-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 20px;
}

.task-expanded-description h3,
.task-expanded-subtasks h3,
.task-expanded-photos h3 {
    font-size: 14px;
    font-weight: 700;
    color: var(--on-surface-medium);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}

.task-expanded-description p {
    font-size: 15px;
    line-height: 1.6;
    white-space: pre-wrap;
    word-wrap: break-word;
    background: var(--background);
    padding: 12px 16px;
    border-radius: var(--radius);
    border-left: 3px solid var(--primary-color);
}

.task-expanded-description {
    margin-bottom: 12px;
}

.task-expanded-subtasks {
    background: var(--background);
    border-radius: var(--radius);
    padding: 12px 16px;
}

.subtasks-display-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.subtask-display-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    background: var(--surface);
    border-radius: var(--radius);
    cursor: pointer;
    border: 1px solid var(--divider);
}

.subtask-display-item.completed .subtask-display-text {
    text-decoration: line-through;
    color: var(--on-surface-disabled);
}

.subtask-display-checkbox {
    width: 20px;
    height: 20px;
    cursor: pointer;
}

.subtask-display-text {
  font-size: 14px;
}

.subtask-display-content {
  flex: 1;
  min-width: 0;
}

.subtask-display-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 4px;
}

.subtask-assigned-info,
.subtask-completed-info {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: var(--on-surface-medium);
  padding: 2px 6px;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.04);
}

.subtask-assigned-info .material-icons {
  color: #2196F3;
}

.subtask-completed-info {
  background: rgba(76, 175, 80, 0.1);
  color: var(--low-priority);
}

.subtask-completed-info .material-icons {
  color: var(--success);
}

.photos-display-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 12px;
    justify-items: center;
}

.photo-display-item {
    position: relative;
    width: 100%;
    padding-bottom: 100%;
    border-radius: var(--radius);
    overflow: hidden;
    cursor: pointer;
}

.photo-display-item img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.2s;
}

.photo-display-item:hover img {
    transform: scale(1.05);
}

/* ===== Notifications ===== */
.notifications {
    position: fixed;
    top: 24px;
    right: 24px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.notification {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow-4);
    animation: slideInRight 0.3s ease-out;
    min-width: 280px;
}

.notification-success {
    border-left: 4px solid var(--success);
}

.notification-error {
    border-left: 4px solid var(--error);
}

.notification .material-icons {
    font-size: 20px;
}

.notification-success .material-icons {
    color: var(--success);
}

.notification-error .material-icons {
    color: var(--error);
}

.notification.fade-out {
    opacity: 0;
    transform: translateX(100%);
    transition: all 0.3s;
}

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(100%);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* ===== Day Tasks Modal ===== */
.calendar-task-more {
    font-size: 9px;
    color: var(--primary-color);
    padding: 2px;
    cursor: pointer;
    font-weight: bold;
}

.calendar-day.has-tasks {
    background: rgba(76, 175, 80, 0.08);
}

.day-tasks-list {
    max-height: 70vh;
    overflow-y: auto;
    padding: 10px;
}

.day-task-item {
    padding: 15px;
    margin-bottom: 10px;
    border-radius: 8px;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    cursor: pointer;
    transition: all 0.2s;
}

.day-task-item:hover {
    border-color: var(--primary-color);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.day-task-item-header {
    display: flex;
    gap: 8px;
    margin-bottom: 8px;
}

.day-task-item-title {
    font-weight: 600;
    font-size: 15px;
    margin-bottom: 5px;
}

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

/* ===== Calendar Task Modal ===== */
.calendar-task-modal {
    padding: 10px;
    max-height: 70vh;
    overflow-y: auto;
}

.calendar-task-modal-content {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.calendar-task-modal .task-badges-row {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.calendar-task-modal .task-detail-row {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.calendar-task-modal .task-detail-row strong {
    font-size: 12px;
    color: var(--text-secondary);
}

.calendar-task-modal .task-detail-row p {
    margin: 0;
    color: var(--text-color);
}

/* Excel files */
.excel-preview {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
}

.file-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: rgba(76, 175, 80, 0.1);
    border-radius: var(--radius);
    font-size: 13px;
}

.file-item .file-name {
    max-width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.file-item .remove-file {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    color: var(--text-secondary);
}

.file-item .remove-file:hover {
    background: rgba(244, 67, 54, 0.1);
    color: var(--high-priority);
}

/* Photo Modal */
.photo-modal-content {
    max-width: 90vw;
    max-height: 90vh;
    background: transparent;
    box-shadow: none;
    position: relative;
    padding: 0;
    overflow: visible;
}

.photo-modal-content img {
    max-width: 100%;
    max-height: 90vh;
    object-fit: contain;
    border-radius: var(--radius);
}

.photo-modal-close {
    position: absolute;
    top: 12px;
    right: 12px;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(2px);
    z-index: 10;
}

.photo-modal-close .material-icons {
    color: #fff;
}

/* ===== Hamburger Button (hidden on desktop) ===== */
.hamburger-btn {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    color: var(--on-surface-medium);
    border-radius: 50%;
    transition: background 0.2s;
}
.hamburger-btn:hover {
    background: var(--background);
}

/* ===== Sidebar Overlay (mobile) ===== */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 9;
}

/* ===== Tablet (768px - 1024px) ===== */
@media (max-width: 1024px) {
    .sidebar {
        width: 220px;
    }
    .sidebar-header h1 {
        font-size: 20px;
    }
}

/* ===== Mobile (below 768px) ===== */
@media (max-width: 768px) {
    /* Hamburger visible */
    .hamburger-btn {
        display: flex;
        align-items: center;
        justify-content: center;
    }

    /* Sidebar: overlay mode */
    .sidebar {
        position: fixed;
        top: 0;
        left: -280px;
        width: 280px;
        height: 100vh;
        height: 100dvh;
        z-index: 10;
        transition: left 0.3s ease;
        overflow-y: auto;
        padding-bottom: env(safe-area-inset-bottom, 0);
    }
    .sidebar.open {
        left: 0;
    }
    .sidebar.open + .sidebar-overlay {
        display: block;
    }

    /* Main content full width */
    .main-content {
        margin-left: 0;
        width: 100%;
    }

    /* Top bar */
    .top-bar {
        flex-wrap: wrap;
        padding: 8px 12px;
        gap: 8px;
    }
    .search-box {
        flex: 1;
        min-width: 0;
        order: 1;
    }
    .search-box input {
        width: 100%;
        min-width: 0;
    }
    .top-actions {
        order: 2;
        flex-wrap: wrap;
        gap: 6px;
        width: 100%;
    }
    .filter-select {
        max-width: 45%;
        flex: 1;
        min-width: 0;
        font-size: 13px;
    }
    .view-toggle {
        flex-shrink: 0;
    }

    /* Modals: fullscreen */
    .modal-content {
        max-width: 100% !important;
        width: 100%;
        margin: 0;
        border-radius: 0;
        max-height: 100vh;
        max-height: 100dvh;
        height: auto;
        min-height: 100vh;
        min-height: 100dvh;
        overflow-y: auto;
        box-sizing: border-box;
        padding-bottom: env(safe-area-inset-bottom, 0);
    }
    .modal.visible {
        align-items: flex-start;
        padding: 0;
        overflow-y: auto;
    }
    .modal-header {
        padding: 16px 16px 0;
    }
    .task-form .form-row {
        flex-direction: column;
    }
    .task-form .form-row .form-group {
        width: 100%;
    }
    .deadline-notify-options {
        gap: 8px !important;
    }
    .deadline-notify-options label {
        font-size: 12px !important;
        min-width: 45%;
    }
    .modal-content .form-actions {
        padding: 12px 16px;
        position: sticky;
        bottom: 0;
        background: var(--surface);
        border-top: 1px solid var(--divider);
        z-index: 2;
        margin-top: 8px;
    }

    /* Task cards: single column */
    .task-item {
        padding: 10px 12px;
    }
    .task-content {
        min-width: 0;
        overflow: hidden;
    }
    .task-title {
        font-size: 14px;
        white-space: normal;
        word-break: break-word;
    }
    .task-badges {
        flex-wrap: wrap;
        gap: 4px;
    }
    .task-badge {
        font-size: 11px;
        padding: 2px 6px;
    }
    .badge-assignees {
        max-width: 100%;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    .badge-assignees img {
        width: 18px !important;
        height: 18px !important;
    }

    /* Calendar: simplified list view */
    .calendar-grid {
        display: none;
    }
    .calendar-mobile-list {
        display: block !important;
    }

    /* Mobile calendar list styles */
    .calendar-mobile-day {
        margin-bottom: 12px;
    }
    .calendar-mobile-day-header {
        font-weight: 600;
        font-size: 14px;
        padding: 8px 12px;
        background: var(--background);
        border-radius: 8px;
        margin-bottom: 4px;
        color: var(--on-surface-medium);
    }
    .calendar-mobile-day-header.today {
        background: var(--primary-color);
        color: var(--on-primary);
    }
    .calendar-mobile-task {
        display: flex;
        align-items: center;
        gap: 8px;
        padding: 10px 12px;
        background: var(--surface);
        border-radius: 8px;
        margin-bottom: 4px;
        cursor: pointer;
        transition: background 0.2s;
    }
    .calendar-mobile-task:hover {
        background: var(--background);
    }
    .calendar-mobile-task-dot {
        width: 8px;
        height: 8px;
        border-radius: 50%;
        flex-shrink: 0;
    }
    .calendar-mobile-task.priority-high .calendar-mobile-task-dot { background: #ef4444; }
    .calendar-mobile-task.priority-medium .calendar-mobile-task-dot { background: #f59e0b; }
    .calendar-mobile-task.priority-low .calendar-mobile-task-dot { background: #22c55e; }
    .calendar-mobile-task span:last-child {
        flex: 1;
        font-size: 14px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    /* Stats */
    .stats-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 6px;
    }
    .stat-value {
        font-size: 20px;
    }
    .stat-label {
        font-size: 10px;
    }
    .stat-card {
        padding: 8px 4px;
    }

    /* Users section */
    .user-item {
        flex-wrap: wrap;
        gap: 8px;
    }

    /* FAB */
    .fab {
        bottom: 16px;
        right: 16px;
        width: 52px;
        height: 52px;
    }

    /* Expanded task */
    .task-expanded {
        padding: 16px;
    }
    .task-expanded-header {
        flex-wrap: wrap;
        gap: 8px;
    }
    .task-expanded-header h2 {
        font-size: 18px;
        flex: 1;
        min-width: 0;
        word-break: break-word;
    }

    /* Assign users list */
    .assign-users-list {
        max-height: 150px;
    }

    /* Auth screen */
    .auth-container {
        padding: 16px;
        max-width: 100%;
        margin: 0 12px;
    }
    .auth-logo {
        width: 56px;
        height: 56px;
    }
    .auth-header h1 {
        font-size: 22px;
    }
    .auth-header p {
        font-size: 13px;
    }
    .auth-form .form-group {
        margin-bottom: 12px;
    }
}

/* ===== Small phones (below 480px) ===== */
@media (max-width: 480px) {
    .top-actions {
        gap: 4px;
    }
    .filter-select {
        max-width: 100px;
        font-size: 12px;
    }
    .view-toggle {
        gap: 2px;
    }
    .stats-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 4px;
    }
    .stat-value {
        font-size: 18px;
    }
    .stat-label {
        font-size: 9px;
    }
    .stat-card {
        padding: 6px 2px;
    }
    .badge-assignees .task-badge {
        font-size: 11px;
    }
}

/* ===== Dashboard ===== */
.main-content.dashboard-main {
    overflow-y: auto;
}

.dashboard-content {
    padding: 24px;
    width: 100%;
    box-sizing: border-box;
}

.dashboard-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 300px;
    gap: 12px;
    color: var(--on-surface-medium);
}

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

.stat-card {
    background: var(--surface);
    border-radius: 12px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    border: 1px solid var(--outline-variant);
    transition: transform 0.2s;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.12);
}

.stat-card .material-icons {
    font-size: 28px;
}

.stat-total .material-icons { color: #2196F3; }
.stat-progress .material-icons { color: #FF9800; }
.stat-overdue .material-icons { color: #f44336; }
.stat-completed .material-icons { color: #4CAF50; }
.clickable-chart {
    cursor: pointer;
    position: relative;
}
.clickable-chart:hover {
    box-shadow: 0 4px 16px rgba(0,0,0,0.12);
    transform: translateY(-1px);
    transition: all 0.2s;
}
.chart-export-btn {
    position: absolute;
    top: 12px;
    right: 12px;
    background: var(--surface);
    border: 1px solid var(--outline-variant);
    border-radius: 6px;
    padding: 4px 8px;
    cursor: pointer;
    font-size: 12px;
    color: var(--on-surface-medium);
    display: flex;
    align-items: center;
    gap: 4px;
    opacity: 0;
    transition: opacity 0.2s;
    z-index: 2;
}
.clickable-chart:hover .chart-export-btn {
    opacity: 1;
}
.chart-export-btn:hover {
    background: var(--surface-variant);
    color: var(--on-surface);
}

.dashboard-branch-filter {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 16px;
}

.branch-filter-select {
    padding: 6px 12px;
    border-radius: 8px;
    border: 1px solid var(--outline-variant);
    background: var(--surface);
    color: var(--on-surface);
    font-size: 14px;
    cursor: pointer;
    min-width: 200px;
}

.stat-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--on-surface);
}

.stat-label {
    font-size: 13px;
    color: var(--on-surface-medium);
}

.charts-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 24px;
    width: 100%;
}

.chart-card {
    background: var(--surface);
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    border: 1px solid var(--outline-variant);
}

.chart-card h3 {
    margin: 0 0 16px 0;
    font-size: 16px;
    font-weight: 600;
    color: var(--on-surface);
}

.chart-container {
    height: 250px;
    position: relative;
}

.chart-container-tall {
    height: 350px;
}

.deadlines-card {
    background: var(--surface);
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    border: 1px solid var(--outline-variant);
    margin-bottom: 24px;
}

.deadlines-card h3 {
    margin: 0 0 16px 0;
    font-size: 16px;
    font-weight: 600;
    color: var(--on-surface);
}

.deadlines-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.deadline-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 14px;
    border-radius: 8px;
    background: var(--surface-variant);
    transition: background 0.2s;
}

.deadline-item:hover {
    background: var(--primary-container);
}

.deadline-info {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
    min-width: 0;
}

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

.deadline-title {
    font-size: 14px;
    color: var(--on-surface);
    text-decoration: none;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.deadline-title:hover {
    text-decoration: underline;
}

.deadline-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.deadline-date {
    font-size: 13px;
    color: var(--on-surface-medium);
}

.deadline-badge {
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 10px;
    font-weight: 600;
}

.badge-urgent {
    background: rgba(244, 67, 54, 0.15);
    color: #f44336;
}

.badge-soon {
    background: rgba(255, 152, 0, 0.15);
    color: #FF9800;
}

/* Period filter */
.period-filter {
    display: flex;
    gap: 4px;
    background: var(--surface-variant);
    border-radius: 8px;
    padding: 4px;
}

.period-btn {
    padding: 6px 14px;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: var(--on-surface-medium);
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
}

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

.period-btn.active {
    background: var(--primary-container, #D1FAE5);
    color: var(--on-primary-container, #065F46);
    font-weight: 600;
    box-shadow: 0 1px 4px rgba(0,0,0,0.1);
}

/* Period picker */
.period-picker {
    display: flex;
    align-items: center;
    gap: 4px;
}

.picker-label {
    font-size: 14px;
    font-weight: 500;
    color: var(--on-surface);
    min-width: 120px;
    text-align: center;
}

/* Clickable stat cards */
.stat-card.clickable {
    cursor: pointer;
}

.stat-card.clickable:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(0,0,0,0.15);
}

.stat-card.clickable:active {
    transform: translateY(-1px);
}

/* Task list inline panel */
.dash-task-panel {
    background: var(--surface-variant, #f5f5f5);
    border-radius: 8px;
    padding: 16px;
    margin-top: 12px;
    border: 1px solid var(--outline-variant);
}

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

.dash-task-panel-header h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: var(--on-surface);
}

.dashboard-task-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.dash-task-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    border-radius: 8px;
    background: var(--surface-variant);
    text-decoration: none;
    color: var(--on-surface);
    transition: background 0.2s;
    gap: 12px;
}

.dash-task-item:hover {
    background: var(--primary-container);
}

.dash-task-item.task-done {
    opacity: 0.6;
}

.dash-task-item.task-overdue {
    border-left: 3px solid #f44336;
}

.dash-task-left {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
    min-width: 0;
}

.dash-task-priority {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.dash-task-title {
    font-size: 14px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.dash-task-right {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.dash-task-progress {
    font-size: 12px;
    font-weight: 600;
    color: var(--primary);
    background: rgba(33, 150, 243, 0.1);
    padding: 2px 8px;
    border-radius: 10px;
}

.dash-task-date {
    font-size: 12px;
    color: var(--on-surface-medium);
}

/* Task detail modal */
.task-detail-modal {
    max-width: 720px;
    width: 92%;
}

.task-detail-modal .modal-body {
    padding: 20px 28px 28px;
}

.task-detail-modal .modal-header {
    padding: 20px 28px 0;
}

#taskDetailModal.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
}

.td-header {
    margin-bottom: 20px;
}

.td-status-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
}

.td-priority {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 12px;
    color: white;
    font-size: 12px;
    font-weight: 600;
}

.td-status {
    font-size: 13px;
    font-weight: 500;
}

.td-status.status-done { color: #4CAF50; }
.td-status.status-overdue { color: #f44336; }
.td-status.status-active { color: #2196F3; }

.td-due {
    font-size: 13px;
    color: var(--on-surface-medium);
}

.td-due.td-overdue {
    color: #f44336;
    font-weight: 600;
}

.td-section {
    margin-bottom: 16px;
}

.td-section-title {
    font-size: 13px;
    font-weight: 700;
    color: var(--on-surface-medium);
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.td-description {
    background: var(--surface-variant);
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 14px;
    line-height: 1.5;
    white-space: pre-wrap;
    border-left: 3px solid var(--primary);
}

.td-assignees {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.td-assignee {
    background: var(--primary-container);
    color: var(--on-primary-container);
    padding: 4px 12px;
    border-radius: 16px;
    font-size: 13px;
}

.td-subtasks {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.td-subtask {
    background: var(--surface-variant);
    padding: 10px 14px;
    border-radius: 8px;
}

.td-subtask.subtask-done {
    opacity: 0.6;
}

.td-subtask-header {
    display: flex;
    align-items: center;
    gap: 8px;
}

.td-subtask-check {
    font-size: 14px;
}

.td-subtask-title {
    font-size: 14px;
}

.td-subtask-progress {
    position: relative;
    height: 20px;
    background: rgba(0,0,0,0.06);
    border-radius: 10px;
    margin-top: 8px;
    overflow: hidden;
}

.td-progress-bar {
    height: 100%;
    border-radius: 10px;
    transition: width 0.3s;
}

.td-progress-text {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 11px;
    font-weight: 600;
    color: var(--on-surface);
}

/* Dashboard responsive */
@media (max-width: 768px) {
    .stats-cards {
        grid-template-columns: repeat(2, 1fr);
    }
    .charts-row {
        grid-template-columns: 1fr;
    }
    .stat-value {
        font-size: 22px;
    }
    .dashboard-content {
        padding: 16px;
    }
    .period-filter {
        flex-wrap: wrap;
    }
}

/* Users page tabs */
.users-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 24px;
    border-bottom: 2px solid var(--outline-variant);
    padding-bottom: 0;
}

.users-tab {
    padding: 10px 20px;
    border: none;
    background: transparent;
    font-size: 14px;
    font-weight: 500;
    color: var(--on-surface-medium);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: color 0.2s, border-color 0.2s;
}

.users-tab:hover {
    color: var(--primary);
}

.users-tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
    font-weight: 600;
}

.users-tab-content {
    min-height: 200px;
}

/* Users page modals (fixed positioning like dashboard) */
#userModal.modal-overlay,
#branchModal.modal-overlay,
#districtModal.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.5);
}

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