/**
 * 7GEN Dashboard - Widget Styles
 * Base widget appearance. Individual widget types extend this.
 */

.widget {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: box-shadow 0.2s, transform 0.2s;
    /* Contain everything */
    min-width: 0;
    max-width: 100%;
}

.widget:hover {
    box-shadow: 0 4px 12px var(--shadow-color);
}

.widget.focused {
    border-color: var(--accent);
    box-shadow: 0 0 0 1px var(--accent);
}

/* Widget Header */
.widget-header {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-sm) var(--space-md);
    background: var(--bg-tertiary);
    border-bottom: 1px solid var(--border-color);
    cursor: grab;
    user-select: none;
}
.widget-header:active { cursor: grabbing; }

.widget-drag-handle {
    color: var(--text-secondary);
    font-size: 14px;
    line-height: 1;
    opacity: 0.5;
    letter-spacing: -2px;
}
.widget-header:hover .widget-drag-handle { opacity: 1; }

.widget-title {
    flex: 1;
    font-size: var(--font-size-sm);
    font-weight: 600;
    color: var(--text-primary);
}

/* Size button shows S/M/L — make it a touch wider so the letter sits centered */
.widget-btn.widget-size {
    width: 28px;
    font-weight: 600;
    font-size: 11px;
}

/* Dragging feedback */
.widget.dragging {
    opacity: 0.4;
}
.widget-grid.drag-active {
    /* Subtle hint that reordering is active */
    outline: 1px dashed var(--border-color);
    outline-offset: -8px;
}

.widget-controls {
    display: flex;
    gap: var(--space-xs);
}

.widget-btn {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: 4px;
    color: var(--text-secondary);
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
}

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

/* Widget Content */
.widget-content {
    flex: 1;
    padding: var(--space-md);
    overflow: auto;
    min-height: 0; /* Allow flex child to shrink and scroll */
}

/* Widget States */
.widget.minimized {
    flex: 0 0 auto !important;
    min-height: 0 !important;
    height: auto !important;
}

.widget.minimized .widget-content {
    display: none;
}

.widget.minimized .widget-resize {
    display: none;
}

.widget.minimized .widget-header {
    border-bottom: none;
}

.widget.maximized {
    position: fixed !important;
    top: 60px;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 200;
    border-radius: 0;
    flex: none !important;
    width: 100% !important;
    height: calc(100vh - 60px) !important;
    max-height: none !important;
    min-height: auto !important;
    margin: 0;
}

.widget.maximized .widget-content {
    height: calc(100vh - 60px - 50px); /* viewport - header - widget header */
    max-height: none;
    overflow-y: auto;
}

/* Widget Loading State */
.widget.loading .widget-content::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 24px;
    height: 24px;
    margin: -12px;
    border: 2px solid var(--bg-tertiary);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* Widget Error State */
.widget.error {
    border-color: var(--error);
}

.widget.error .widget-content {
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--error);
}

/* Resize Handle - hidden for now (fixed layouts) */
.widget-resize {
    display: none;
    position: absolute;
    bottom: 0;
    right: 0;
    width: 16px;
    height: 16px;
    cursor: se-resize;
}

.widget-resize::after {
    content: '';
    position: absolute;
    bottom: 4px;
    right: 4px;
    width: 8px;
    height: 8px;
    border-right: 2px solid var(--text-secondary);
    border-bottom: 2px solid var(--text-secondary);
    opacity: 0;
    transition: opacity 0.2s;
}

.widget:hover .widget-resize::after {
    opacity: 1;
}

/* Widget Compact View */
.widget-compact {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    text-align: center;
}

.compact-count {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--accent);
}

.compact-label {
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
}

/* Widget Toolbar */
.widget-toolbar {
    display: flex;
    justify-content: flex-end;
    margin-bottom: var(--space-md);
}

/* List Container */
.list-container {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

.list-item {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: var(--space-sm) var(--space-md);
    background: var(--bg-tertiary);
    border-radius: var(--border-radius);
}

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

/* Role specific */
.role-color {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    flex-shrink: 0;
}

.role-name {
    flex: 1;
    font-weight: 500;
}

.role-slug {
    color: var(--text-secondary);
    font-size: var(--font-size-sm);
    font-family: monospace;
}

.role-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 11px;
    color: white;
    margin-right: 4px;
}

/* User specific */
.user-item {
    display: grid;
    grid-template-columns: 1fr auto auto;
    gap: var(--space-md);
}

.user-info {
    display: flex;
    flex-direction: column;
}

.user-name {
    font-weight: 500;
}

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

.user-roles {
    display: flex;
    align-items: center;
    gap: 4px;
}

.user-actions {
    display: flex;
    gap: var(--space-xs);
}

/* Button icon */
.btn-icon {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    cursor: pointer;
    font-size: 14px;
}

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

/* Modal - hidden by default, JS sets display:flex when opening */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-content {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: var(--space-lg);
    width: 100%;
    max-width: 400px;
    max-height: 80vh;
    overflow-y: auto;
}

.modal-content h3 {
    margin-bottom: var(--space-lg);
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: var(--space-sm);
    margin-top: var(--space-lg);
}

/* Checkbox group */
.checkbox-group {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    cursor: pointer;
}

.checkbox-label input {
    width: 16px;
    height: 16px;
}

/* Empty state */
.empty {
    text-align: center;
    color: var(--text-secondary);
    padding: var(--space-lg);
}

/* ============================================
   TASKS WIDGET
   ============================================ */

/* Compact view */
.tasks-compact {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
}

.task-counts {
    display: flex;
    gap: var(--space-lg);
    text-align: center;
}

.count-item {
    display: flex;
    flex-direction: column;
}

.count-item.urgent .count-number {
    color: var(--error);
}

.count-item.active .count-number {
    color: var(--accent);
}

.count-number {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-primary);
}

.count-label {
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
}

/* Filter tabs */
.filter-tabs {
    display: flex;
    gap: 4px;
}

.filter-btn {
    padding: 4px 12px;
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    color: var(--text-secondary);
    font-size: var(--font-size-sm);
    cursor: pointer;
}

.filter-btn:hover {
    border-color: var(--accent);
}

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

/* Task list */
.task-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-xs);
}

.task-item {
    display: flex;
    align-items: flex-start;
    gap: var(--space-sm);
    padding: var(--space-sm) var(--space-md);
    background: var(--bg-tertiary);
    border-radius: var(--border-radius);
    border-left: 3px solid transparent;
}

.task-item.overdue {
    border-left-color: var(--error);
}

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

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

.task-check {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: 2px solid var(--border-color);
    border-radius: 50%;
    color: var(--text-secondary);
    cursor: pointer;
    flex-shrink: 0;
    font-size: 12px;
}

.task-check:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.task-check.checked {
    background: var(--success);
    border-color: var(--success);
    color: white;
}

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

.task-title {
    font-weight: 500;
    margin-bottom: 2px;
}

.task-meta {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-sm);
    font-size: 11px;
    color: var(--text-secondary);
}

.task-due.overdue {
    color: var(--error);
    font-weight: 600;
}

.task-due.today {
    color: var(--accent);
    font-weight: 600;
}

.task-priority {
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--warning);
    color: white;
    border-radius: 50%;
    font-size: 12px;
    font-weight: bold;
    flex-shrink: 0;
}

.task-priority.high {
    background: var(--error);
}

.no-tasks {
    text-align: center;
    color: var(--text-secondary);
    padding: var(--space-lg);
}

/* Unassigned task indicator */
.task-item.unassigned {
    border-left-color: var(--warning);
    background: rgba(255, 152, 0, 0.05);
}

/* Quick assign dropdown */
.task-assign-select {
    padding: 4px 8px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    color: var(--text-primary);
    font-size: 11px;
    cursor: pointer;
    flex-shrink: 0;
}

.task-assign-select:hover {
    border-color: var(--accent);
}

.task-item.unassigned .task-assign-select {
    border-color: var(--warning);
}

/* ============================================
   PROJECTS WIDGET
   ============================================ */

/* Compact view */
.projects-compact {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.projects-compact .stage-chart {
    flex: 1;
    width: 100%;
}

.projects-compact .compact-footer {
    display: flex;
    justify-content: space-between;
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
    padding-top: var(--space-sm);
    border-top: 1px solid var(--border-color);
}

/* Kanban view */
.project-kanban {
    display: flex;
    gap: var(--space-sm);
    overflow-x: auto;
    padding-bottom: var(--space-sm);
}

.project-stage {
    flex: 0 0 200px;
    min-width: 180px;
    display: flex;
    flex-direction: column;
    max-height: 100%;
}

.stage-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-sm);
    border-left: 3px solid;
    background: var(--bg-tertiary);
    border-radius: var(--border-radius);
    margin-bottom: var(--space-sm);
}

.stage-name {
    font-weight: 600;
    font-size: var(--font-size-sm);
}

.stage-count {
    background: var(--bg-secondary);
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
}

.stage-projects {
    display: flex;
    flex-direction: column;
    gap: var(--space-xs);
    overflow-y: auto;
    flex: 1;
}

.project-card {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: var(--space-sm);
    cursor: pointer;
    transition: border-color 0.2s, transform 0.1s;
}

.project-card:hover {
    border-color: var(--accent);
    transform: translateY(-1px);
}

.project-code {
    font-size: 10px;
    color: var(--text-secondary);
    font-family: monospace;
}

.project-name {
    font-weight: 500;
    font-size: var(--font-size-sm);
    margin: 4px 0;
    line-height: 1.3;
}

.project-meta {
    display: flex;
    flex-direction: column;
    gap: 2px;
    font-size: 11px;
    color: var(--text-secondary);
}

.project-assignees {
    display: flex;
    gap: var(--space-xs);
    margin-top: var(--space-xs);
    font-size: 11px;
}

.assignee {
    padding: 2px 6px;
    background: var(--bg-secondary);
    border-radius: var(--border-radius);
}

.assignee.unassigned {
    color: var(--warning);
    border: 1px dashed var(--warning);
    background: transparent;
}

.empty-stage {
    text-align: center;
    color: var(--text-secondary);
    font-size: var(--font-size-sm);
    padding: var(--space-md);
}

/* Project List View */
.project-list-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border-color);
    text-transform: uppercase;
}

.col-status { width: 4px; flex-shrink: 0; }
.col-info { flex: 1; min-width: 0; }
.col-client { flex: 1; min-width: 0; }
.col-value { width: 65px; flex-shrink: 0; text-align: right; }
.col-team { width: 64px; flex-shrink: 0; }
.col-stage { width: 70px; flex-shrink: 0; }
.col-actions { width: 28px; flex-shrink: 0; }

.projects-widget {
    overflow: hidden;
}

.project-list {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    width: 100%;
}

.project-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
    transition: background 0.15s;
    box-sizing: border-box;
}

.project-row:hover {
    background: var(--bg-tertiary);
}

.project-status {
    width: 4px;
    height: 36px;
    border-radius: 2px;
    flex-shrink: 0;
}

.project-status { width: 4px; flex-shrink: 0; }
.project-info { flex: 1; min-width: 0; overflow: hidden; }
.project-client { flex: 1; min-width: 0; overflow: hidden; }
.project-value { width: 65px; flex-shrink: 0; text-align: right; font-size: 13px; }
.project-team { 
    display: flex; 
    gap: 4px; 
    flex-shrink: 0;
}
.project-team .team-member {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-tertiary);
    border-radius: 4px;
    font-size: 14px;
}
.project-team .team-member.unassigned {
    opacity: 0.4;
}
.project-stage-name { width: 70px; flex-shrink: 0; font-size: 11px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.project-actions { width: 28px; flex-shrink: 0; }
.project-actions .edit-project {
    width: 28px;
    height: 28px;
    padding: 0;
    border: none;
    background: transparent;
    cursor: pointer;
    font-size: 14px;
    opacity: 0.5;
    transition: opacity 0.15s;
}
.project-row:hover .edit-project {
    opacity: 1;
}

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

.project-info .project-code {
    font-size: 10px;
    color: var(--text-secondary);
}

.project-info .project-name,
.project-client .business,
.project-client .contact {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 13px;
}

.project-info .project-code {
    font-size: 10px;
    color: var(--text-secondary);
    font-family: monospace;
}

.project-info .project-name {
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.project-client {
    display: flex;
    flex-direction: column;
    font-size: 12px;
}

.project-client .business {
    font-weight: 500;
}

.project-client .contact {
    color: var(--text-secondary);
    font-size: 11px;
}

.project-value {
    font-weight: 500;
    font-size: 13px;
}

.project-team {
    display: flex;
    gap: 4px;
}

.team-member {
    font-size: 14px;
}

.team-member.unassigned {
    opacity: 0.3;
}

.project-count {
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
}

.no-projects {
    text-align: center;
    padding: var(--space-xl);
    color: var(--text-secondary);
}

/* Modal improvements */
.modal-lg {
    max-width: 600px;
}

.form-row {
    display: flex;
    gap: var(--space-md);
}

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

/* ============================================
   DESIGN QUEUE WIDGET
   ============================================ */

/* Compact view */
.design-queue-compact {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
}

.queue-counts {
    display: flex;
    gap: var(--space-lg);
    text-align: center;
}

.queue-counts .count-item.active .count-number {
    color: var(--accent);
}

.queue-counts .count-item.pending .count-number {
    color: var(--warning);
}

.queue-counts .count-item.urgent .count-number {
    color: var(--error);
}

/* Full view - project cards */
.design-project-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

.design-project-card {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: var(--space-md);
    background: var(--bg-tertiary);
    border-radius: var(--border-radius);
    border-left: 4px solid var(--border-color);
    cursor: pointer;
    transition: all 0.15s;
}

.design-project-card:hover {
    background: var(--bg-hover);
    transform: translateX(4px);
}

.design-project-card.high-priority {
    border-left-color: var(--error);
}

.project-stage-badge {
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    color: white;
    white-space: nowrap;
}

.design-project-card .project-info {
    flex: 1;
    min-width: 0;
}

.design-project-card .project-code {
    font-size: 10px;
    color: var(--text-secondary);
    font-family: monospace;
}

.design-project-card .project-name {
    font-weight: 600;
    margin: 2px 0;
}

.design-project-card .project-client {
    font-size: 12px;
    color: var(--text-secondary);
}

.design-project-card .project-meta {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
    font-size: 12px;
    color: var(--text-secondary);
}

.design-project-card .project-actions {
    margin-left: var(--space-sm);
}

.no-projects {
    text-align: center;
    padding: var(--space-xl);
    color: var(--text-secondary);
}

/* Task expandable notes */
.task-item.has-notes {
    cursor: pointer;
}

.task-item.has-notes:hover {
    background: var(--bg-hover);
}

.task-header {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
}

.note-indicator {
    font-size: 12px;
    opacity: 0.7;
}

.task-notes {
    margin-top: var(--space-sm);
    padding: var(--space-sm);
    background: var(--bg-primary);
    border-radius: var(--border-radius);
    font-size: 13px;
    color: var(--text-secondary);
    white-space: pre-wrap;
    border-left: 3px solid var(--accent);
}

.task-item.expanded {
    background: var(--bg-tertiary);
}

.task-project-link {
    color: var(--accent);
    text-decoration: none;
    font-size: 12px;
}

.task-project-link:hover {
    text-decoration: underline;
}

/* Task Detail Modal */
.task-detail-body {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
}

.task-detail-meta {
    display: flex;
    flex-direction: column;
    gap: var(--space-xs);
}

.detail-row {
    display: flex;
    gap: var(--space-sm);
}

.detail-label {
    color: var(--text-secondary);
    font-size: 12px;
    min-width: 80px;
}

.task-detail-notes {
    padding: var(--space-md);
    background: var(--bg-tertiary);
    border-radius: var(--border-radius);
    border-left: 3px solid var(--accent);
}

.task-detail-notes .notes-content {
    margin-top: var(--space-sm);
    white-space: pre-wrap;
    line-height: 1.5;
}

.task-detail-actions {
    display: flex;
    gap: var(--space-sm);
    padding-top: var(--space-md);
    border-top: 1px solid var(--border-color);
}

.task-detail-actions .btn {
    flex: 1;
    text-align: center;
}

.task-item {
    cursor: pointer;
}

.project-link {
    color: var(--accent);
    font-weight: 600;
    text-decoration: none;
}

.project-link:hover {
    text-decoration: underline;
}

.high-priority {
    color: var(--error);
    font-weight: 600;
}

/* Task Type Badge */
.task-type-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 10px;
    font-weight: 600;
    color: white;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-right: var(--space-xs);
    vertical-align: middle;
}

.task-header {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: var(--space-xs);
}

.task-assignee.unassigned {
    color: var(--warning);
}

/* Form hint text */
.form-hint {
    font-size: 11px;
    color: var(--text-secondary);
    margin-top: 4px;
}

.required {
    color: var(--error);
}

/* Form row for side-by-side fields */
.form-row {
    display: flex;
    gap: var(--space-md);
}

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

/* Modal actions with delete on left, cancel/save on right */
.modal-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: var(--space-md);
    margin-top: var(--space-lg);
}

.modal-actions-right {
    display: flex;
    gap: var(--space-sm);
}

/* Task edit button */
.task-edit-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px 8px;
    opacity: 0.5;
    transition: opacity 0.2s;
    font-size: 14px;
}

.task-item:hover .task-edit-btn {
    opacity: 1;
}

/* Delete button style */
.btn-danger {
    background: var(--error);
    color: white;
    border-color: var(--error);
}

.btn-danger:hover {
    background: #dc2626;
}

/* ============================================
   TEAM WIDGET
   ============================================ */

.team-widget {
    height: 100%;
    display: flex;
    flex-direction: column;
}

.team-grid {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-md);
    padding: var(--space-md);
    overflow-y: auto;
    flex: 1;
    align-content: flex-start;
}

.team-member {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: var(--space-md);
    background: var(--bg-tertiary);
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    width: 140px;
    flex-shrink: 0;
}

.team-member:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px var(--shadow-color);
}

.member-avatar {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    margin-bottom: var(--space-sm);
}

.member-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.avatar-initials {
    color: white;
    font-weight: 600;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
}

.member-info {
    width: 100%;
}

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

.member-location {
    font-size: 11px;
    color: var(--text-secondary);
    margin-bottom: 2px;
}

.member-role {
    font-size: 10px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Filter tabs that wrap */
.filter-tabs-wrap {
    flex-wrap: wrap;
}

/* Team compact view */
.team-compact {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
}

.team-count {
    text-align: center;
}

.team-count .count-number {
    font-size: 32px;
    font-weight: 700;
    color: var(--accent);
}

.team-count .count-label {
    display: block;
    font-size: 12px;
    color: var(--text-secondary);
}

.no-team {
    grid-column: 1 / -1;
    text-align: center;
    color: var(--text-secondary);
    padding: var(--space-xl);
}

/* Member local time */
.member-time {
    font-size: 11px;
    color: var(--text-secondary);
    font-weight: 500;
}

.member-time.late {
    color: var(--warning);
}

.member-time.late::before {
    content: '🌙 ';
}

/* Dim late-night members slightly */
.team-member.late-night {
    opacity: 0.7;
}

.team-member.late-night:hover {
    opacity: 1;
}

/* Icon button */
.btn-icon {
    padding: 4px 8px;
    font-size: 14px;
    line-height: 1;
}

/* WhatsApp button on team member */
.team-member {
    position: relative;
}

.whatsapp-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    transition: transform 0.2s;
}

.whatsapp-btn img {
    width: 100%;
    height: 100%;
}

.whatsapp-btn:hover {
    transform: scale(1.15);
}

/* ============================================
   DESIGNER TASKS WIDGET
   ============================================ */

.designer-tasks-widget .task-list {
    padding: var(--space-md);
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

.designer-task-item {
    display: flex;
    gap: var(--space-md);
    padding: var(--space-md);
    background: var(--bg-tertiary);
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: background 0.2s;
}

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

.designer-task-item.overdue {
    border-left: 3px solid var(--error);
}

.designer-task-item .task-check {
    background: none;
    border: 2px solid var(--border-color);
    border-radius: 50%;
    width: 24px;
    height: 24px;
    cursor: pointer;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
}

.designer-task-item .task-check:hover {
    border-color: var(--accent);
    background: var(--accent);
    color: white;
}

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

.designer-task-item .task-title {
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
}

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

.designer-task-item .task-meta {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-sm);
    font-size: 12px;
}

.designer-task-item .task-project-link {
    color: var(--accent);
    text-decoration: none;
    font-weight: 500;
}

.designer-task-item .task-project-link:hover {
    text-decoration: underline;
}

.designer-task-item .task-stage {
    color: var(--text-secondary);
    background: var(--bg-secondary);
    padding: 2px 8px;
    border-radius: 10px;
}

.designer-task-item .task-due {
    color: var(--text-secondary);
}

.designer-task-item .task-due.overdue {
    color: var(--error);
    font-weight: 600;
}

/* Accent button for Designer tool */
.btn-accent {
    background: var(--accent);
    color: white;
    text-decoration: none;
}

.btn-accent:hover {
    background: var(--accent-hover, #0d9488);
}

/* ============================================
   TASK VIEW MODAL (matches screenshot)
   ============================================ */

.task-view-modal {
    max-width: 400px;
}

.task-view-modal h3 {
    margin: 0 0 var(--space-lg) 0;
    font-size: 1.25rem;
    font-weight: 600;
}

.task-view-details {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

.task-view-row {
    display: flex;
    gap: var(--space-md);
}

.task-view-row .label {
    color: var(--text-secondary);
    min-width: 90px;
}

.task-view-row .value {
    color: var(--text-primary);
}

.task-view-row .project-link {
    color: var(--accent);
    text-decoration: none;
    font-weight: 500;
}

.task-view-row .project-link:hover {
    text-decoration: underline;
}

.task-view-notes {
    margin-top: var(--space-md);
    padding: var(--space-md);
    background: var(--bg-tertiary);
    border-left: 3px solid var(--accent);
    border-radius: 0 var(--border-radius) var(--border-radius) 0;
}

.task-view-notes .notes-label {
    color: var(--text-secondary);
    font-size: 0.85rem;
    margin-bottom: var(--space-xs);
}

.task-view-notes .notes-content {
    color: var(--text-primary);
    line-height: 1.5;
}

.task-view-actions {
    display: flex;
    gap: var(--space-md);
    margin-top: var(--space-lg);
    padding-top: var(--space-lg);
    border-top: 1px solid var(--border-color);
}

.task-view-actions .btn {
    flex: 1;
}

.task-view-footer {
    display: flex;
    justify-content: flex-end;
    margin-top: var(--space-md);
}

/* Project badge in designer task list */
.designer-task-item .task-project-badge {
    color: var(--accent);
    font-weight: 500;
    font-size: 12px;
}

/* ============================================
   INLINE CREATE FORMS
   ============================================ */

.inline-select-create {
    display: flex;
    gap: var(--space-sm);
}

.inline-select-create select {
    flex: 1;
}

.inline-create-form {
    margin-top: var(--space-sm);
    padding: var(--space-md);
    background: var(--bg-tertiary);
    border-radius: var(--border-radius);
    border: 1px dashed var(--border-color);
}

.inline-create-form .form-row {
    margin-bottom: 0;
    align-items: flex-end;
}

.inline-create-form .btn-tiny {
    height: 36px;
    white-space: nowrap;
}

/* ============================================
   BUSINESSES WIDGET
   ============================================ */

.businesses-widget .business-list {
    padding: var(--space-md);
}

.business-row {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: var(--space-md);
    background: var(--bg-tertiary);
    border-radius: var(--border-radius);
    margin-bottom: var(--space-sm);
    cursor: pointer;
    transition: background 0.2s;
}

.business-row:hover {
    background: var(--bg-secondary);
}

.business-icon {
    font-size: 1.5rem;
    width: 40px;
    text-align: center;
}

.business-info {
    flex: 1;
}

.business-name {
    font-weight: 600;
    color: var(--text-primary);
}

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

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

/* Design Book link sits at the right edge of each business row. Anchor
   styled like a small button. flex-shrink:0 + a hard min-width so the
   row layout doesn't squeeze it on narrow widget widths. */
.business-design-book {
    flex-shrink: 0;
    text-decoration: none;
    white-space: nowrap;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 4px 10px;
    font-size: 12px;
    border-radius: 6px;
}
.business-design-book:hover {
    background: var(--bg-primary);
    border-color: var(--accent, #2563eb);
    color: var(--accent, #2563eb);
}

/* ============================================
   CLIENTS WIDGET
   ============================================ */

.clients-widget .client-list {
    padding: var(--space-md);
}

.client-row {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: var(--space-md);
    background: var(--bg-tertiary);
    border-radius: var(--border-radius);
    margin-bottom: var(--space-sm);
    cursor: pointer;
    transition: background 0.2s;
}

.client-row:hover {
    background: var(--bg-secondary);
}

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

.client-info {
    flex: 1;
}

.client-name {
    font-weight: 600;
    color: var(--text-primary);
}

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

.badge-primary {
    background: var(--accent);
    color: white;
    padding: 2px 6px;
    border-radius: 8px;
    font-size: 10px;
    font-weight: 600;
}

.client-email {
    font-size: 12px;
    color: var(--accent);
    text-decoration: none;
}

.client-email:hover {
    text-decoration: underline;
}

/* Search input in widget toolbar */
.search-input {
    padding: 6px 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 13px;
    width: 150px;
}

.search-input:focus {
    outline: none;
    border-color: var(--accent);
}

/* Checkbox label */
.checkbox-label {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    cursor: pointer;
}

.checkbox-label input[type="checkbox"] {
    width: 16px;
    height: 16px;
}

/* Role Widget - Widget Selection */
.modal-wide {
    max-width: 600px;
}

.widgets-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 8px;
    max-height: 200px;
    overflow-y: auto;
    padding: 12px;
    background: var(--bg-secondary);
    border-radius: 6px;
    border: 1px solid var(--border-color);
}

.widget-checkbox {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    background: var(--bg-primary);
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    transition: background 0.15s;
}

.widget-checkbox:hover {
    background: var(--bg-hover);
}

.widget-checkbox input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
}

.widget-checkbox .widget-name {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.form-group-small {
    max-width: 80px;
}

/* Role Delete Confirmation */
.affected-users {
    margin: 16px 0;
    padding: 12px;
    background: rgba(244, 67, 54, 0.1);
    border-radius: 6px;
    border-left: 3px solid #f44336;
}

.warning-text {
    color: #f44336;
    font-weight: 500;
    margin-bottom: 8px;
}

.affected-users ul {
    margin: 0;
    padding-left: 20px;
    max-height: 150px;
    overflow-y: auto;
}

.affected-users li {
    padding: 4px 0;
    font-size: 13px;
}

.btn-danger {
    background: #f44336 !important;
    color: white !important;
}

.btn-danger:hover {
    background: #d32f2f !important;
}

.delete-role {
    opacity: 0.5;
    transition: opacity 0.15s;
}

.list-item:hover .delete-role {
    opacity: 1;
}

/* Widget selection with size dropdown */
.widget-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    background: var(--bg-primary);
    border-radius: 4px;
}

.widget-row .widget-checkbox {
    flex: 1;
    padding: 0;
    background: none;
}

.widget-row .widget-size {
    width: 80px;
    padding: 4px 6px;
    font-size: 12px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background: var(--bg-secondary);
    color: var(--text-primary);
}

.widget-row .widget-size:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* No backdrop for maximized - clean look */

/* Change maximize icon when maximized */
.widget.maximized .widget-maximize::after {
    content: '⧉';
}

/* Archive Widget */
.archive-compact {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
}

.archive-count {
    font-size: 2.5rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.archive-label {
    font-size: 0.85rem;
    color: var(--text-muted);
}

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

.archive-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    background: var(--bg-secondary);
    border-radius: 6px;
    border: 1px solid var(--border-color);
}

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

.archive-code {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-family: monospace;
}

.archive-name {
    font-weight: 500;
    color: var(--text-primary);
}

.archive-business {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

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

.restore-btn {
    background: var(--accent-color);
    color: white;
}

/* Task Product Thumbnails (shared between Tasks and DesignerTasks widgets) */
.task-products { display: flex; gap: 4px; margin-top: 4px; }
.task-product-thumb { 
    width: 28px; height: 28px; border-radius: 4px; 
    background: var(--bg-tertiary); cursor: pointer;
    border: 1px solid var(--border-color); transition: transform 0.1s;
}
.task-product-thumb:hover { transform: scale(1.1); border-color: var(--accent); }
.task-product-thumb img { width: 100%; height: 100%; object-fit: contain; }

/* Designer Task Product Thumbnails (larger, right-aligned) */
.designer-task-item { display: flex; align-items: flex-start; }
.designer-task-products { 
    display: flex; gap: 6px; margin-left: auto; padding-left: 12px;
    flex-shrink: 0;
}
.designer-product-thumb { 
    width: 44px; height: 44px; border-radius: 6px; 
    background: var(--bg-tertiary); cursor: pointer;
    border: 1px solid var(--border-color); transition: transform 0.15s, border-color 0.15s;
}
.designer-product-thumb:hover { 
    transform: scale(1.08); 
    border-color: var(--accent);
    box-shadow: 0 2px 8px var(--shadow-color);
}
.designer-product-thumb img { width: 100%; height: 100%; object-fit: contain; border-radius: 5px; }

/* Task Attachments */
.task-attachments-list {
    margin-bottom: 8px;
    max-height: 120px;
    overflow-y: auto;
}

.attachment-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 4px 8px;
    background: var(--bg-tertiary, #f5f5f5);
    border-radius: 4px;
    margin-bottom: 4px;
    font-size: 0.85rem;
}

.attachment-link {
    color: var(--text-primary, #333);
    text-decoration: none;
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.attachment-link:hover {
    text-decoration: underline;
}

.attachment-remove {
    color: #dc3545 !important;
    margin-left: 8px;
    flex-shrink: 0;
}

.attachment-upload {
    display: flex;
    align-items: center;
    gap: 8px;
}

.upload-hint {
    font-size: 0.8rem;
    color: var(--text-secondary, #666);
}

.no-attachments {
    color: var(--text-secondary, #888);
    font-size: 0.85rem;
    font-style: italic;
    padding: 4px 0;
}

/* Task attachments in card */
.task-attachments {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid var(--border-color, #e0e0e0);
}

.task-attachment-thumb {
    width: 48px;
    height: 48px;
    border-radius: 4px;
    overflow: hidden;
    border: 1px solid var(--border-color, #ddd);
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-tertiary, #f5f5f5);
}

.task-attachment-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.task-attachment-thumb:hover {
    border-color: var(--primary, #1d9bf0);
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.task-attachment-doc {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 8px;
    background: var(--bg-tertiary, #f5f5f5);
    border: 1px solid var(--border-color, #ddd);
    border-radius: 4px;
    font-size: 0.8rem;
    color: var(--text-primary, #333);
    text-decoration: none;
    max-width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.task-attachment-doc:hover {
    background: var(--bg-secondary, #e9ecef);
    border-color: var(--primary, #1d9bf0);
}

/* Complexity Widget */
.complexity-widget .widget-subtitle {
    font-size: 0.85rem;
    color: var(--text-secondary, #666);
}

.complexity-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 12px 0;
}

.complexity-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: var(--bg-secondary, #f5f5f5);
    border-radius: 8px;
    border: 1px solid var(--border-color, #e0e0e0);
}

.complexity-level {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    font-weight: bold;
    color: white;
    flex-shrink: 0;
}

.complexity-info {
    flex: 1;
}

.complexity-name {
    font-weight: 600;
    color: var(--text-primary, #333);
}

.complexity-hours {
    font-size: 0.85rem;
    color: var(--text-secondary, #666);
}

.complexity-desc {
    font-size: 0.8rem;
    color: var(--text-tertiary, #999);
    margin-top: 2px;
}

.complexity-actions {
    display: flex;
    gap: 4px;
}

.complexity-item:hover {
    border-color: var(--primary, #1d9bf0);
}

/* Task Complexity Badge */
.task-complexity-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: bold;
    color: white;
    margin-right: 6px;
}

/* Capacity Widget */
.capacity-widget .chart-container {
    padding: 12px;
}

.capacity-widget .no-data {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--text-secondary, #666);
    font-style: italic;
}

/* Campaigns Widget */
.campaigns-widget {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.campaigns-toolbar {
    display: flex;
    justify-content: flex-end;
    margin-bottom: var(--space-md);
}

.campaigns-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.campaigns-table th,
.campaigns-table td {
    padding: var(--space-sm);
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.campaigns-table th {
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 0.8rem;
    text-transform: uppercase;
}

.campaigns-table .empty-state {
    text-align: center;
    color: var(--text-secondary);
    padding: var(--space-xl);
}

.campaign-actions {
    display: flex;
    gap: var(--space-xs);
}

.status-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.75rem;
    color: white;
    text-transform: capitalize;
}

.campaigns-compact {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
}

.campaigns-count {
    font-size: 2rem;
    font-weight: bold;
}

.campaigns-label {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* Campaign Modal */
.campaign-modal .modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-lg);
}

.campaign-modal .modal-title {
    margin: 0;
}

.campaign-modal .modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-secondary);
}

.campaign-modal .form-group {
    margin-bottom: var(--space-md);
}

.campaign-modal .form-group label {
    display: block;
    margin-bottom: var(--space-xs);
    font-weight: 500;
}

.campaign-modal .form-group input,
.campaign-modal .form-group textarea,
.campaign-modal .form-group select {
    width: 100%;
    padding: var(--space-sm);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    background: var(--bg-primary);
    color: var(--text-primary);
}

.campaign-modal .form-actions {
    display: flex;
    justify-content: flex-end;
    gap: var(--space-sm);
    margin-top: var(--space-lg);
}

/* ============================================
   QUICK LINKS WIDGET
   ============================================ */

.quick-links-widget {
    padding: var(--space-sm);
}

.quick-links-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: var(--space-sm);
}

.quick-link-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: var(--space-md);
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    text-decoration: none;
    color: var(--text-primary);
    transition: all 0.2s;
    text-align: center;
}

.quick-link-card:hover {
    background: var(--bg-secondary);
    border-color: var(--accent);
    transform: translateY(-2px);
}

.quick-link-card .quick-link-icon {
    font-size: 1.5rem;
    margin-bottom: var(--space-xs);
}

.quick-link-card .quick-link-label {
    font-weight: 600;
    font-size: var(--font-size-sm);
}

.quick-link-card .quick-link-desc {
    font-size: 11px;
    color: var(--text-secondary);
    margin-top: var(--space-xs);
}

/* Compact mode */
.quick-links-compact {
    display: flex;
    justify-content: center;
    padding: var(--space-sm);
}

.quick-links-icons {
    display: flex;
    gap: var(--space-sm);
}

.quick-links-icons .quick-link-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    text-decoration: none;
    font-size: 1.2rem;
    transition: all 0.2s;
}

.quick-links-icons .quick-link-icon:hover {
    background: var(--accent);
    border-color: var(--accent);
}


/* ──────────────────────────────────────────────────────────────────────── */
/* Sales Performance widget */
/* ──────────────────────────────────────────────────────────────────────── */

.sales-performance-widget {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
    padding: var(--space-sm);
}

/* Top toolbar: year selector on the left, month-pager filling the rest.
   Replaces the old separate .sp-header + .sp-month-nav rows with a
   single inline row. The .sp-keys-card block (Total Earnings / Monthly
   / Projected) was retired — those figures now live in the comp summary
   card below the chart. */
.sp-toolbar {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    margin-bottom: var(--space-sm);
}

.sp-year-selector {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
    color: var(--text-secondary);
    font-size: 0.85rem;
    flex-shrink: 0;
}

.sp-year-select {
    padding: 4px 6px;
    font-size: 0.85rem;
}

.sp-month-nav {
    flex: 1 1 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-sm);
    padding: var(--space-xs) var(--space-sm);
    background: var(--bg-tertiary);
    border-radius: var(--border-radius);
}

/* Compact toolbar on narrow widget widths — stack year above the
   month nav so neither gets cramped. */
@media (max-width: 480px) {
    .sp-toolbar { flex-direction: column; align-items: stretch; }
}

.sp-nav-btn {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    border-radius: var(--border-radius);
    padding: 4px 10px;
    cursor: pointer;
    font-size: 0.9rem;
}

.sp-nav-btn:hover {
    background: var(--bg-secondary);
}

.sp-month-title {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    font-weight: 600;
}

.sp-month-tag {
    font-size: 0.7rem;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 999px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.sp-tag-past    { background: rgba(107, 114, 128, 0.3); color: #c4c8d0; }
.sp-tag-current { background: rgba(34, 197, 94, 0.25); color: #86efac; }
.sp-tag-future  { background: rgba(168, 85, 247, 0.25); color: #d8b4fe; }

.sp-chart-wrap {
    position: relative;
    height: 180px;
}

/* ─────────────────────────────────────────────────────────────────────
   Company Performance widget — Accounts role.

   Shares visual DNA with Sales Performance (year selector, month nav,
   past/current/future tags) but surfaces four KPIs instead of three,
   plus a per-rep table underneath the chart.
   ───────────────────────────────────────────────────────────────────── */
.company-performance-widget {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
    padding: var(--space-sm);
}

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

.cp-year-selector {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.cp-year-select {
    padding: 4px 6px;
    font-size: 0.85rem;
}

/* Five-up KPI grid — drops to 3 cols at medium widths, 2 at narrow. */
.cp-kpis {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: var(--space-sm);
}

@media (max-width: 1100px) {
    .cp-kpis { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 700px) {
    .cp-kpis { grid-template-columns: repeat(2, 1fr); }
}

.cp-kpi {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: var(--space-sm) var(--space-md);
    text-align: center;
    min-width: 0;
}

.cp-kpi-label {
    color: var(--text-secondary);
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.cp-kpi-value {
    font-size: 1.4rem;
    font-weight: 700;
    margin: 4px 0 0;
    font-variant-numeric: tabular-nums;
    color: var(--text-primary);
}

.cp-kpi-sub {
    color: var(--text-secondary);
    font-size: 0.7rem;
    margin-top: 2px;
}

/* Category colors on the KPI figures — matches the chart legend. */
.cp-kpi-gross      .cp-kpi-value { color: #22c55e; }
.cp-kpi-commission .cp-kpi-value { color: #60a5fa; }
.cp-kpi-projected  .cp-kpi-value { color: #c4a3ff; }
.cp-kpi-expenses   .cp-kpi-value { color: #f472b6; }
.cp-kpi-operating  .cp-kpi-value { color: #fb923c; }

/* One-line net strip — quick eyeball of "are we profitable this month?". */
.cp-net-strip {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-xs) var(--space-md);
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    font-size: 0.85rem;
}

.cp-net-label { color: var(--text-secondary); }

.cp-net-value {
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.cp-net-positive { color: #22c55e; }
.cp-net-negative { color: #f87171; }

.cp-month-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-sm);
    padding: var(--space-xs) var(--space-sm);
    background: var(--bg-tertiary);
    border-radius: var(--border-radius);
}

.cp-nav-btn {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    border-radius: var(--border-radius);
    padding: 4px 10px;
    cursor: pointer;
    font-size: 0.9rem;
}

.cp-nav-btn:hover { background: var(--bg-secondary); }

.cp-month-title {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    font-weight: 600;
}

.cp-month-tag {
    font-size: 0.7rem;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 999px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.cp-tag-past    { background: rgba(107, 114, 128, 0.3); color: #c4c8d0; }
.cp-tag-current { background: rgba(34, 197, 94, 0.25); color: #86efac; }
.cp-tag-future  { background: rgba(168, 85, 247, 0.25); color: #d8b4fe; }

.cp-chart-wrap {
    position: relative;
    height: 300px;
}

/* ─────────────────────────────────────────────────────────────────────
   Reps Performance widget — Accounts drill-down into individual reps.

   Two-column layout: narrow rep picker on the left, SalesPerformance-style
   card + chart on the right.
   ───────────────────────────────────────────────────────────────────── */
.reps-performance-widget {
    display: grid;
    grid-template-columns: 200px 1fr;
    gap: var(--space-md);
    padding: var(--space-sm);
    min-height: 360px;
}

@media (max-width: 720px) {
    .reps-performance-widget {
        grid-template-columns: 1fr;
    }
}

/* Left column: rep picker. */
.rp-rep-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
    border-right: 1px solid var(--border-color);
    padding-right: var(--space-sm);
    min-height: 0;
    overflow-y: auto;
}

@media (max-width: 720px) {
    .rp-rep-list {
        border-right: none;
        border-bottom: 1px solid var(--border-color);
        padding-right: 0;
        padding-bottom: var(--space-sm);
    }
}

.rp-rep-list-title {
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    padding: 4px 8px;
}

.rp-rep-item {
    background: transparent;
    border: 1px solid transparent;
    color: var(--text-primary);
    border-radius: var(--border-radius);
    padding: 8px 10px;
    text-align: left;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: var(--space-xs);
    font-size: 0.9rem;
    transition: background 0.12s ease, border-color 0.12s ease;
}

.rp-rep-item:hover {
    background: var(--bg-tertiary);
}

.rp-rep-active {
    background: var(--bg-tertiary);
    border-color: var(--accent);
    font-weight: 600;
}

.rp-rep-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.rp-rep-rate {
    color: var(--text-secondary);
    font-size: 0.75rem;
    font-variant-numeric: tabular-nums;
}

/* Right column: performance panel. Layout & visual tokens mirror
   SalesPerformanceWidget so the per-rep view feels identical to what
   that rep sees on their own dashboard. */
.rp-panel {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
    min-width: 0;
}

.rp-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: var(--space-sm);
}

.rp-panel-title {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.rp-panel-name {
    font-weight: 700;
    color: var(--text-primary);
    font-size: 1rem;
}

.rp-panel-rate {
    color: var(--text-secondary);
    font-size: 0.75rem;
}

.rp-year-selector {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.rp-year-select {
    padding: 4px 6px;
    font-size: 0.85rem;
}

.rp-keys-card {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: var(--space-md);
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
}

/* Compensation summary card — table-style breakdown of base / commission /
   bonuses / total. Lives under the monthly chart; collapses cleanly to a
   single column when the panel is narrow. */
.rp-comp-card {
    margin-top: var(--space-md);
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: var(--space-md);
}
.rp-comp-empty .rp-comp-empty-msg {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.4;
}
.rp-comp-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: var(--space-sm);
}
/* 3-column grid: label | YTD value | projected-EOY value. Header row
   uses the same template so the columns stay aligned. */
.rp-comp-headers,
.rp-comp-grid > .rp-comp-row {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 12px;
    align-items: baseline;
}
.rp-comp-headers {
    padding: 6px 0;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 4px;
}
.rp-comp-col-head {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    text-align: right;
}
.rp-comp-col-head.rp-comp-col-eoy { color: var(--accent, #2563eb); }

.rp-comp-grid {
    display: flex;
    flex-direction: column;
    gap: 0;
}
.rp-comp-row {
    padding: 8px 0;
    border-bottom: 1px solid color-mix(in srgb, var(--border-color) 50%, transparent);
}
.rp-comp-row:last-child { border-bottom: none; }
.rp-comp-label {
    font-size: 13px;
    color: var(--text-primary);
}
.rp-comp-value {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    text-align: right;
}
.rp-comp-value.rp-comp-eoy {
    color: var(--accent, #2563eb);
}
.rp-comp-sub {
    display: block;
    font-size: 11px;
    font-weight: 400;
    color: var(--text-secondary);
    margin-top: 2px;
}
.rp-comp-total {
    margin-top: 4px;
    padding-top: 12px !important;
    border-top: 1px solid var(--border-color);
    border-bottom: none !important;
}
.rp-comp-total .rp-comp-value { font-size: 16px; }
.rp-comp-total .rp-comp-value.rp-comp-eoy {
    font-size: 18px;
    color: #22c55e;
}

.rp-key-main {
    text-align: center;
    padding-bottom: var(--space-sm);
    border-bottom: 1px solid var(--border-color);
}

.rp-key-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-md);
}

.rp-key-col {
    text-align: center;
    min-width: 0;
}

.rp-key-label {
    color: var(--text-secondary);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.rp-key-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--accent);
    margin: 4px 0 0;
    font-variant-numeric: tabular-nums;
}

.rp-key-value-sm {
    font-size: 1.35rem;
    font-weight: 700;
    margin: 4px 0 0;
    font-variant-numeric: tabular-nums;
}

.rp-key-earned    { color: #22c55e; }
.rp-key-projected { color: #c4a3ff; }

.rp-key-sub {
    color: var(--text-secondary);
    font-size: 0.75rem;
    margin-top: 2px;
}

.rp-month-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-sm);
    padding: var(--space-xs) var(--space-sm);
    background: var(--bg-tertiary);
    border-radius: var(--border-radius);
}

.rp-nav-btn {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    border-radius: var(--border-radius);
    padding: 4px 10px;
    cursor: pointer;
    font-size: 0.9rem;
}

.rp-nav-btn:hover { background: var(--bg-secondary); }

.rp-month-title {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    font-weight: 600;
}

.rp-month-tag {
    font-size: 0.7rem;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 999px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.rp-tag-past    { background: rgba(107, 114, 128, 0.3); color: #c4c8d0; }
.rp-tag-current { background: rgba(34, 197, 94, 0.25); color: #86efac; }
.rp-tag-future  { background: rgba(168, 85, 247, 0.25); color: #d8b4fe; }

.rp-chart-wrap {
    position: relative;
    height: 180px;
}

/* ─────────────────────────────────────────────────────────────────────
   Operating Costs widget — editable 12-month grid of fixed overhead.

   Simple two-column-ish grid (month label, $ input, inline save status).
   On wider widths it falls into a 2-column layout so all 12 months fit
   without scrolling; on narrow widths it collapses to one column.
   ───────────────────────────────────────────────────────────────────── */
.operating-costs-widget {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
    padding: var(--space-sm);
}

.oc-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: var(--space-sm);
}

.oc-year-selector {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.oc-year-select {
    padding: 4px 6px;
    font-size: 0.85rem;
}

.oc-total {
    display: flex;
    align-items: baseline;
    gap: var(--space-xs);
    padding: 4px 10px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
}

.oc-total-label {
    color: var(--text-secondary);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.oc-total-value {
    font-weight: 700;
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
}

.oc-hint {
    color: var(--text-secondary);
    font-size: 0.8rem;
    font-style: italic;
}

/* Two columns on wide widgets, one on narrow. */
.oc-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-xs) var(--space-md);
}

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

.oc-row {
    display: grid;
    grid-template-columns: 1fr 160px 60px;
    align-items: center;
    gap: var(--space-sm);
    padding: 6px 4px;
    border-bottom: 1px solid var(--border-color);
}

.oc-row:last-child,
.oc-row:nth-last-child(2) { border-bottom: none; }

.oc-month {
    font-weight: 500;
    color: var(--text-primary);
}

/* Subtle dim on months that are still showing the default — gives the
   user a quick at-a-glance map of "which months have I actually set?". */
.oc-row-default .oc-month,
.oc-row-default .oc-input {
    color: var(--text-secondary);
}

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

.oc-currency {
    position: absolute;
    left: 8px;
    color: var(--text-secondary);
    font-size: 0.9rem;
    pointer-events: none;
}

.oc-input {
    width: 100%;
    padding: 6px 8px 6px 20px;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    background: var(--bg-primary);
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
    font-size: 0.95rem;
    text-align: right;
}

.oc-input:focus {
    outline: none;
    border-color: var(--accent);
    background: var(--bg-secondary);
}

/* Dirty row: subtle amber tint + left accent so the user can tell at a
   glance which months have unsaved edits before they hit Save. */
.oc-row-dirty {
    background: color-mix(in srgb, #f59e0b 12%, transparent);
    box-shadow: inset 3px 0 0 #f59e0b;
}
.oc-row-dirty .oc-input {
    border-color: #f59e0b;
}
.oc-row-invalid .oc-input {
    border-color: #f87171;
}

/* Footer: Save button + inline status message. */
.oc-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.75rem;
    padding-top: 0.75rem;
    margin-top: 0.5rem;
    border-top: 1px solid var(--border-color);
}

.oc-save-status {
    font-size: 0.8rem;
    color: var(--text-secondary);
    min-height: 1em;
}
.oc-save-status-saving { color: var(--text-secondary); }
.oc-save-status-saved  { color: #22c55e; }
.oc-save-status-error  { color: #f87171; }

.oc-save-btn {
    padding: 0.5rem 1.25rem;
    border-radius: 6px;
    border: 1px solid var(--accent-color, #2563eb);
    background: var(--accent-color, #2563eb);
    color: #fff;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s, opacity 0.15s;
}
.oc-save-btn:hover:not(:disabled) {
    background: color-mix(in srgb, var(--accent-color, #2563eb) 85%, black);
}
.oc-save-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}
